mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
通知消息设置
This commit is contained in:
parent
27f04da064
commit
b8982f2060
@ -35,10 +35,17 @@
|
||||
0667D192247D162C005DE2ED /* MessageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0667D191247D162C005DE2ED /* MessageTableViewCell.swift */; };
|
||||
0667D194247D1BA0005DE2ED /* Date+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0667D193247D1BA0005DE2ED /* Date+Extension.swift */; };
|
||||
06802E5320ECC40C00767047 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0661A549204FDA4100965E4E /* Assets.xcassets */; };
|
||||
06885EB6247FB9880004A303 /* MessageSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06885EB5247FB9880004A303 /* MessageSettingsViewController.swift */; };
|
||||
068F66B3247BD84C00DAD25A /* MessageListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068F66B2247BD84C00DAD25A /* MessageListViewController.swift */; };
|
||||
06B1158D247BA6D5006D91FB /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06B1158C247BA6D5006D91FB /* CloudKit.framework */; };
|
||||
06B1158F247BB1FB006D91FB /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B1158E247BB1FB006D91FB /* Message.swift */; };
|
||||
06B11591247BC132006D91FB /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B1158E247BB1FB006D91FB /* Message.swift */; };
|
||||
06C5952D2480E3F8006B98F3 /* LabelCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06C5952C2480E3F8006B98F3 /* LabelCell.swift */; };
|
||||
06C5952F248107F5006B98F3 /* iCloudStatusCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06C5952E248107F5006B98F3 /* iCloudStatusCell.swift */; };
|
||||
06C5953124811392006B98F3 /* ArchiveSettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06C5953024811392006B98F3 /* ArchiveSettingCell.swift */; };
|
||||
06C5953324811505006B98F3 /* ArchiveSettingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06C5953224811505006B98F3 /* ArchiveSettingManager.swift */; };
|
||||
06C5953424811505006B98F3 /* ArchiveSettingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06C5953224811505006B98F3 /* ArchiveSettingManager.swift */; };
|
||||
06C595362481160F006B98F3 /* BKLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06C595352481160F006B98F3 /* BKLabel.swift */; };
|
||||
06CF784721C7A50300A052D7 /* NotificationServiceExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 06CF784021C7A50300A052D7 /* NotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
06CF784C21C7A51200A052D7 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06CF784B21C7A51200A052D7 /* NotificationService.swift */; };
|
||||
6AF9CC9B5F6CD2BF86509897 /* libPods-Bark.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4EA0C04469BF7B418FF3CB7 /* libPods-Bark.a */; };
|
||||
@ -109,10 +116,16 @@
|
||||
0683486A2050F1310024B6DA /* Bark.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Bark.entitlements; sourceTree = "<group>"; };
|
||||
0683487020510FB20024B6DA /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
|
||||
0683487220510FB20024B6DA /* UserNotificationsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotificationsUI.framework; path = System/Library/Frameworks/UserNotificationsUI.framework; sourceTree = SDKROOT; };
|
||||
06885EB5247FB9880004A303 /* MessageSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageSettingsViewController.swift; sourceTree = "<group>"; };
|
||||
068F66B2247BD84C00DAD25A /* MessageListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListViewController.swift; sourceTree = "<group>"; };
|
||||
06B1158C247BA6D5006D91FB /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; };
|
||||
06B1158E247BB1FB006D91FB /* Message.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
|
||||
06B11590247BBC15006D91FB /* NotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NotificationServiceExtension.entitlements; sourceTree = "<group>"; };
|
||||
06C5952C2480E3F8006B98F3 /* LabelCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelCell.swift; sourceTree = "<group>"; };
|
||||
06C5952E248107F5006B98F3 /* iCloudStatusCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iCloudStatusCell.swift; sourceTree = "<group>"; };
|
||||
06C5953024811392006B98F3 /* ArchiveSettingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArchiveSettingCell.swift; sourceTree = "<group>"; };
|
||||
06C5953224811505006B98F3 /* ArchiveSettingManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArchiveSettingManager.swift; sourceTree = "<group>"; };
|
||||
06C595352481160F006B98F3 /* BKLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BKLabel.swift; sourceTree = "<group>"; };
|
||||
06CF784021C7A50300A052D7 /* NotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
06CF784421C7A50300A052D7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
06CF784B21C7A51200A052D7 /* NotificationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
|
||||
@ -164,6 +177,7 @@
|
||||
0637FA8920E0D58800E80174 /* NewServerViewController.swift */,
|
||||
0603706C20E23EC000F4CA05 /* BarkSFSafariViewController.swift */,
|
||||
068F66B2247BD84C00DAD25A /* MessageListViewController.swift */,
|
||||
06885EB5247FB9880004A303 /* MessageSettingsViewController.swift */,
|
||||
);
|
||||
path = Controller;
|
||||
sourceTree = "<group>";
|
||||
@ -173,6 +187,10 @@
|
||||
children = (
|
||||
0603706820E1F89500F4CA05 /* PreviewCardCell.swift */,
|
||||
0667D191247D162C005DE2ED /* MessageTableViewCell.swift */,
|
||||
06C5952C2480E3F8006B98F3 /* LabelCell.swift */,
|
||||
06C5952E248107F5006B98F3 /* iCloudStatusCell.swift */,
|
||||
06C5953024811392006B98F3 /* ArchiveSettingCell.swift */,
|
||||
06C595352481160F006B98F3 /* BKLabel.swift */,
|
||||
);
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
@ -191,6 +209,7 @@
|
||||
0637FA7D20E0969800E80174 /* Client.swift */,
|
||||
06B1158E247BB1FB006D91FB /* Message.swift */,
|
||||
0667D193247D1BA0005DE2ED /* Date+Extension.swift */,
|
||||
06C5953224811505006B98F3 /* ArchiveSettingManager.swift */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@ -498,10 +517,13 @@
|
||||
0603706920E1F89500F4CA05 /* PreviewCardCell.swift in Sources */,
|
||||
0637FA8C20E0D7A700E80174 /* BaseViewController.swift in Sources */,
|
||||
0603706D20E23EC000F4CA05 /* BarkSFSafariViewController.swift in Sources */,
|
||||
06C5953124811392006B98F3 /* ArchiveSettingCell.swift in Sources */,
|
||||
06B1158F247BB1FB006D91FB /* Message.swift in Sources */,
|
||||
06C595362481160F006B98F3 /* BKLabel.swift in Sources */,
|
||||
0637FA7820E0926D00E80174 /* BarkTargetType.swift in Sources */,
|
||||
0637FA7E20E0969800E80174 /* Client.swift in Sources */,
|
||||
0661A545204FDA4100965E4E /* HomeViewController.swift in Sources */,
|
||||
06C5952F248107F5006B98F3 /* iCloudStatusCell.swift in Sources */,
|
||||
0637FA8620E0AB6600E80174 /* UIColor+Extension.swift in Sources */,
|
||||
0637FA8A20E0D58800E80174 /* NewServerViewController.swift in Sources */,
|
||||
0637FA8220E09C4B00E80174 /* BarkNavigationController.swift in Sources */,
|
||||
@ -510,6 +532,9 @@
|
||||
0604F7DF20620D4900B32F09 /* ServerManager.swift in Sources */,
|
||||
0667D192247D162C005DE2ED /* MessageTableViewCell.swift in Sources */,
|
||||
0603706720E1E31600F4CA05 /* Defines.swift in Sources */,
|
||||
06885EB6247FB9880004A303 /* MessageSettingsViewController.swift in Sources */,
|
||||
06C5953324811505006B98F3 /* ArchiveSettingManager.swift in Sources */,
|
||||
06C5952D2480E3F8006B98F3 /* LabelCell.swift in Sources */,
|
||||
0637FA7C20E0930E00E80174 /* BarkApi.swift in Sources */,
|
||||
0637FA8020E0981E00E80174 /* BarkSettings.swift in Sources */,
|
||||
0603706B20E20A7C00F4CA05 /* String+Extension.swift in Sources */,
|
||||
@ -523,6 +548,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
06CF784C21C7A51200A052D7 /* NotificationService.swift in Sources */,
|
||||
06C5953424811505006B98F3 /* ArchiveSettingManager.swift in Sources */,
|
||||
06B11591247BC132006D91FB /* Message.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@ -48,3 +48,14 @@ automaticallyCopyTitle = "Automatically copy push content";
|
||||
automaticallyCopy = "Automatically copy push content \nwhen a push is received";
|
||||
|
||||
historyMessage = "History Message";
|
||||
|
||||
unknown = "Unknown";
|
||||
available = "Available";
|
||||
restricted = "Restricted";
|
||||
settings = "Settings";
|
||||
|
||||
iCloudSatatus = "iCloud sync";
|
||||
iCloudSync = "Notification messages will be synced when iCloud is available";
|
||||
|
||||
defaultArchiveSettings = "Archive by default";
|
||||
archiveNote = "When the isArchive parameter is not specified in the push request URL, whether to archive the notification message will be decided according to this setting";
|
||||
|
||||
@ -48,3 +48,14 @@ automaticallyCopyTitle = "自动复制推送内容";
|
||||
automaticallyCopy = "携带automaticallyCopy参数时,将自动复制推送内容。\n携带copy参数时,将只复制copy参数的值";
|
||||
|
||||
historyMessage = "历史消息";
|
||||
|
||||
unknown = "未知";
|
||||
available = "已开启";
|
||||
restricted = "未开启";
|
||||
settings = "设置";
|
||||
|
||||
iCloudSatatus = "iCloud 同步";
|
||||
iCloudSync = "通知消息将在iCloud可用时同步";
|
||||
|
||||
defaultArchiveSettings = "默认保存";
|
||||
archiveNote = "当推送请求URL没有指定 isArchive 参数时,将按照此设置来决定是否保存通知消息";
|
||||
|
||||
@ -42,7 +42,7 @@ class MessageListViewController: BaseViewController {
|
||||
}
|
||||
|
||||
@objc func settingClick (){
|
||||
|
||||
self.navigationController?.pushViewController(MessageSettingsViewController(), animated: true)
|
||||
}
|
||||
|
||||
func refresh() {
|
||||
|
||||
72
Controller/MessageSettingsViewController.swift
Normal file
72
Controller/MessageSettingsViewController.swift
Normal file
@ -0,0 +1,72 @@
|
||||
//
|
||||
// MessageSettingsViewController.swift
|
||||
// Bark
|
||||
//
|
||||
// Created by huangfeng on 2020/5/28.
|
||||
// Copyright © 2020 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Material
|
||||
class MessageSettingsViewController: BaseViewController {
|
||||
let tableView: UITableView = {
|
||||
let tableView = UITableView()
|
||||
tableView.separatorStyle = .none
|
||||
tableView.backgroundColor = Color.grey.lighten5
|
||||
tableView.register(LabelCell.self, forCellReuseIdentifier: "\(LabelCell.self)")
|
||||
tableView.register(iCloudStatusCell.self, forCellReuseIdentifier: "\(iCloudStatusCell.self)")
|
||||
tableView.register(ArchiveSettingCell.self, forCellReuseIdentifier: "\(ArchiveSettingCell.self)")
|
||||
|
||||
return tableView
|
||||
}()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.title = NSLocalizedString("settings")
|
||||
|
||||
self.view.addSubview(tableView)
|
||||
tableView.dataSource = self
|
||||
tableView.delegate = self
|
||||
tableView.snp.makeConstraints { (make) in
|
||||
make.edges.equalToSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension MessageSettingsViewController: UITableViewDelegate,UITableViewDataSource {
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return 6
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
switch indexPath.row {
|
||||
case 0:
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "\(LabelCell.self)") as! LabelCell
|
||||
cell.textLabel?.text = "iCloud"
|
||||
return cell
|
||||
case 1:
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "\(iCloudStatusCell.self)") as! iCloudStatusCell
|
||||
return cell
|
||||
case 2:
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "\(LabelCell.self)") as! LabelCell
|
||||
cell.textLabel?.text = NSLocalizedString("iCloudSync")
|
||||
return cell
|
||||
case 3:
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "\(LabelCell.self)") as! LabelCell
|
||||
cell.textLabel?.text = NSLocalizedString("defaultArchiveSettings")
|
||||
return cell
|
||||
case 4:
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "\(ArchiveSettingCell.self)") as! ArchiveSettingCell
|
||||
return cell
|
||||
case 5:
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "\(LabelCell.self)") as! LabelCell
|
||||
cell.textLabel?.text = NSLocalizedString("archiveNote")
|
||||
return cell
|
||||
|
||||
default:
|
||||
return UITableViewCell()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
26
Model/ArchiveSettingManager.swift
Normal file
26
Model/ArchiveSettingManager.swift
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// ArchiveSettingManager.swift
|
||||
// Bark
|
||||
//
|
||||
// Created by huangfeng on 2020/5/29.
|
||||
// Copyright © 2020 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class ArchiveSettingManager: NSObject {
|
||||
static let shared = ArchiveSettingManager()
|
||||
let defaults = UserDefaults.init(suiteName: "group.bark")
|
||||
var isArchive: Bool {
|
||||
get {
|
||||
return defaults?.bool(forKey: "isArchive") ?? true
|
||||
|
||||
}
|
||||
set{
|
||||
defaults?.set(newValue, forKey: "isArchive")
|
||||
}
|
||||
}
|
||||
private override init(){
|
||||
super.init()
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,13 @@ class Client: NSObject {
|
||||
private override init() {
|
||||
super.init()
|
||||
}
|
||||
var currentNavigationController:UINavigationController? {
|
||||
get {
|
||||
let controller = UIApplication.shared.delegate?.window??.rootViewController as? BarkSnackbarController
|
||||
let nav = controller?.rootViewController as? UINavigationController
|
||||
return nav
|
||||
}
|
||||
}
|
||||
|
||||
let appVersion:String = {
|
||||
var version = "0.0.0"
|
||||
|
||||
@ -57,8 +57,7 @@ class NotificationService: UNNotificationServiceExtension {
|
||||
isArchive = archive == "1" ? true : false
|
||||
}
|
||||
if isArchive == nil {
|
||||
let defaults = UserDefaults.init(suiteName: "group.bark")
|
||||
isArchive = defaults?.bool(forKey: "isArchive") ?? false
|
||||
isArchive = ArchiveSettingManager.shared.isArchive
|
||||
}
|
||||
let alert = (userInfo["aps"] as? [String:Any])?["alert"] as? [String:Any]
|
||||
let title = alert?["title"] as? String
|
||||
|
||||
40
View/ArchiveSettingCell.swift
Normal file
40
View/ArchiveSettingCell.swift
Normal file
@ -0,0 +1,40 @@
|
||||
//
|
||||
// ArchiveSettingCell.swift
|
||||
// Bark
|
||||
//
|
||||
// Created by huangfeng on 2020/5/29.
|
||||
// Copyright © 2020 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class ArchiveSettingCell: UITableViewCell {
|
||||
let switchButton: UISwitch = {
|
||||
let btn = UISwitch()
|
||||
return btn
|
||||
}()
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
self.selectionStyle = .none
|
||||
|
||||
self.textLabel?.text = NSLocalizedString("defaultArchiveSettings")
|
||||
|
||||
addSubview(switchButton)
|
||||
switchButton.snp.makeConstraints { (make) in
|
||||
make.right.equalToSuperview().offset(-16)
|
||||
make.centerY.equalToSuperview()
|
||||
}
|
||||
|
||||
switchButton.isOn = ArchiveSettingManager.shared.isArchive
|
||||
switchButton.addTarget(self, action: #selector(switchToggle(sender:)), for: .valueChanged)
|
||||
|
||||
}
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@objc func switchToggle(sender:UISwitch) {
|
||||
ArchiveSettingManager.shared.isArchive = sender.isOn
|
||||
}
|
||||
|
||||
}
|
||||
24
View/BKLabel.swift
Normal file
24
View/BKLabel.swift
Normal file
@ -0,0 +1,24 @@
|
||||
//
|
||||
// BKLabel.swift
|
||||
// Bark
|
||||
//
|
||||
// Created by huangfeng on 2020/5/29.
|
||||
// Copyright © 2020 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class BKLabel: UILabel {
|
||||
|
||||
var hitTestSlop:UIEdgeInsets = UIEdgeInsets.zero
|
||||
|
||||
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
||||
if hitTestSlop == UIEdgeInsets.zero {
|
||||
return super.point(inside: point, with:event)
|
||||
}
|
||||
else{
|
||||
return self.bounds.inset(by: hitTestSlop).contains(point)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
25
View/LabelCell.swift
Normal file
25
View/LabelCell.swift
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// LabelCell.swift
|
||||
// Bark
|
||||
//
|
||||
// Created by huangfeng on 2020/5/29.
|
||||
// Copyright © 2020 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Material
|
||||
|
||||
class LabelCell: UITableViewCell {
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
self.selectionStyle = .none
|
||||
|
||||
self.backgroundColor = Color.grey.lighten5
|
||||
self.textLabel?.textColor = Color.darkText.secondary
|
||||
self.textLabel?.fontSize = 12
|
||||
self.textLabel?.numberOfLines = 0
|
||||
}
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@ class MessageTableViewCell: UITableViewCell {
|
||||
|
||||
let titleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = RobotoFont.regular(with: 16)
|
||||
label.font = RobotoFont.medium(with: 16)
|
||||
label.textColor = Color.darkText.primary
|
||||
label.numberOfLines = 0
|
||||
return label
|
||||
@ -20,13 +20,15 @@ class MessageTableViewCell: UITableViewCell {
|
||||
let bodyLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = RobotoFont.regular(with: 14)
|
||||
label.textColor = Color.darkText.secondary
|
||||
label.textColor = Color.darkText.primary
|
||||
label.numberOfLines = 0
|
||||
return label
|
||||
}()
|
||||
|
||||
let urlLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
let label = BKLabel()
|
||||
label.hitTestSlop = UIEdgeInsets(top: -20, left: -20, bottom: -20, right: -20)
|
||||
label.isUserInteractionEnabled = true
|
||||
label.font = RobotoFont.regular(with: 14)
|
||||
label.textColor = Color.blue.darken1
|
||||
label.numberOfLines = 0
|
||||
@ -56,6 +58,8 @@ class MessageTableViewCell: UITableViewCell {
|
||||
addSubview(urlLabel)
|
||||
addSubview(dateLabel)
|
||||
addSubview(separatorLine)
|
||||
|
||||
self.urlLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(urlTap)))
|
||||
}
|
||||
func layoutView(){
|
||||
titleLabel.snp.remakeConstraints { (make) in
|
||||
@ -79,18 +83,18 @@ class MessageTableViewCell: UITableViewCell {
|
||||
|
||||
urlLabel.snp.makeConstraints { (make) in
|
||||
make.left.equalTo(bodyLabel)
|
||||
make.top.equalTo(bodyLabel.snp.bottom).offset(6)
|
||||
make.top.equalTo(bodyLabel.snp.bottom).offset(12)
|
||||
}
|
||||
if (message?.url?.count ?? 0) > 0{
|
||||
dateLabel.snp.remakeConstraints { (make) in
|
||||
make.left.equalTo(urlLabel)
|
||||
make.top.equalTo(urlLabel.snp.bottom).offset(6)
|
||||
make.top.equalTo(urlLabel.snp.bottom).offset(12)
|
||||
}
|
||||
}
|
||||
else{
|
||||
dateLabel.snp.remakeConstraints { (make) in
|
||||
make.left.equalTo(bodyLabel)
|
||||
make.top.equalTo(bodyLabel.snp.bottom).offset(6)
|
||||
make.top.equalTo(bodyLabel.snp.bottom).offset(12)
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,13 +111,29 @@ class MessageTableViewCell: UITableViewCell {
|
||||
}
|
||||
var message:Message? {
|
||||
didSet{
|
||||
self.titleLabel.text = message?.title
|
||||
self.bodyLabel.text = message?.body
|
||||
setupTextValue(label: self.titleLabel, text: message?.title)
|
||||
setupTextValue(label: self.bodyLabel, text: message?.body)
|
||||
|
||||
self.urlLabel.text = message?.url
|
||||
self.dateLabel.text = (message?.createDate ?? Date()).agoFormatString()
|
||||
layoutView()
|
||||
|
||||
}
|
||||
}
|
||||
func setupTextValue(label:UILabel, text:String?){
|
||||
let style = NSMutableParagraphStyle()
|
||||
style.lineSpacing = 3
|
||||
|
||||
let attrStr = NSAttributedString(string: text ?? "",
|
||||
attributes: [
|
||||
.paragraphStyle: style,
|
||||
.font: label.font!,
|
||||
.foregroundColor: label.textColor!])
|
||||
label.attributedText = attrStr
|
||||
}
|
||||
|
||||
@objc func urlTap(){
|
||||
if let urlStr = self.message?.url, let url = URL(string: urlStr){ Client.shared.currentNavigationController?.present(BarkSFSafariViewController(url: url), animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
38
View/iCloudStatusCell.swift
Normal file
38
View/iCloudStatusCell.swift
Normal file
@ -0,0 +1,38 @@
|
||||
//
|
||||
// iCloudStatusCell.swift
|
||||
// Bark
|
||||
//
|
||||
// Created by huangfeng on 2020/5/29.
|
||||
// Copyright © 2020 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import CloudKit
|
||||
|
||||
class iCloudStatusCell: UITableViewCell {
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: .value1, reuseIdentifier: reuseIdentifier)
|
||||
self.selectionStyle = .none
|
||||
|
||||
self.textLabel?.text = NSLocalizedString("iCloudSatatus")
|
||||
self.detailTextLabel?.text = ""
|
||||
CKContainer.default().accountStatus { (status, error) in
|
||||
dispatch_sync_safely_main_queue {
|
||||
switch status {
|
||||
case .available:
|
||||
self.detailTextLabel?.text = NSLocalizedString("available")
|
||||
|
||||
case .noAccount, .restricted:
|
||||
self.detailTextLabel?.text = NSLocalizedString("restricted")
|
||||
case .couldNotDetermine:
|
||||
self.detailTextLabel?.text = NSLocalizedString("unknown")
|
||||
@unknown default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user