Bläddra i källkod

系统消息完成

jeremy 5 år sedan
förälder
incheckning
207bc14012

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/MineModule/PushNotificationSettings/View/PushNotificationSettingsOneSectionHeaderView.swift

@@ -17,7 +17,7 @@ class PushNotificationSettingsOneSectionHeaderView: BaseView {
     
     override func setupLayouts() {
         titleLabel.snp.makeConstraints { (make) in
-            make.bottom.equalTo(5)
+            make.bottom.equalTo(-5)
             make.left.equalTo(14)
         }
     }

+ 56 - 2
RainbowPlanet/RainbowPlanet/Modules/MineModule/PushNotificationSettings/View/PushNotificationSettingsTableViewCell.swift

@@ -9,10 +9,18 @@
 import UIKit
 
 class PushNotificationSettingsTableViewCell: UITableViewCell {
+        
+    deinit {
+        if observe != nil {
+            NotificationCenter.default.removeObserver(observe!)
+        }
+        NXLLog("deinit")
+    }
+    weak var observe : NSObjectProtocol?
 
-       class func cellWith(tableView:UITableView,indexPath:IndexPath) -> PushNotificationSettingsTableViewCell {
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> PushNotificationSettingsTableViewCell {
         let ID = "PushNotificationSettingsTableViewCell"
-        tableView.register(SetTableViewCell.self, forCellReuseIdentifier: ID)
+        tableView.register(PushNotificationSettingsTableViewCell.self, forCellReuseIdentifier: ID)
         let cell : PushNotificationSettingsTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! PushNotificationSettingsTableViewCell
         cell.indexPath = indexPath
         return cell
@@ -22,6 +30,7 @@ class PushNotificationSettingsTableViewCell: UITableViewCell {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
         setupViews()
         setupLayouts()
+        setupData()
     }
     
     required init?(coder aDecoder: NSCoder) {
@@ -37,6 +46,7 @@ class PushNotificationSettingsTableViewCell: UITableViewCell {
     private func setupViews() {
         self.selectionStyle = .none
         addSubview(titleLabel)
+        addSubview(onSwitch)
         addSubview(lineLabel)
     }
     
@@ -45,6 +55,10 @@ class PushNotificationSettingsTableViewCell: UITableViewCell {
             make.centerY.equalToSuperview()
             make.left.equalTo(14)
         }
+        onSwitch.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.right.equalTo(-14)
+        }
         lineLabel.snp.makeConstraints { (make) in
             make.bottom.right.equalToSuperview()
             make.left.equalTo(14)
@@ -52,6 +66,17 @@ class PushNotificationSettingsTableViewCell: UITableViewCell {
         }
     }
     
+    func setupData() {
+        onSwitch.addTarget(self, action: #selector(onSwitchAction(onSwitch:)), for: UIControl.Event.touchUpInside)
+    }
+    
+    @objc func onSwitchAction(onSwitch:UISwitch) {
+        self.onSwitch.isOn = !onSwitch.isOn
+        if indexPath?.section == 0 {
+            NXLPermission.openSettingsURL()
+        }
+    }
+    
     private lazy var titleLabel: UILabel = {
         let titleLabel = UILabel()
         titleLabel.textColor = k333333Color
@@ -66,9 +91,38 @@ class PushNotificationSettingsTableViewCell: UITableViewCell {
         return lineLabel
     }()
     
+    lazy var onSwitch: UISwitch = {
+        let onSwitch = UISwitch()
+        onSwitch.isOn = true
+        onSwitch.backgroundColor = kf1f1f1Color
+        onSwitch.onTintColor = kThemeColor
+        onSwitch.tintColor = kf1f1f1Color
+        onSwitch.thumbTintColor = .white
+        onSwitch.cornerRadius = 15.5
+        onSwitch.masksToBounds = true
+        return onSwitch
+    }()
+    
     var title : String? {
         didSet {
             titleLabel.text = title
+            if indexPath?.section == 0 {
+                isAllowedNotification()
+                observe = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main, using: {
+                    [weak self] (notification) in
+                    self?.isAllowedNotification()
+                })
+            }
+            
+        }
+    }
+    
+    /// 推送通知的调试
+    func isAllowedNotification() {
+        if NXLPermission.isAllowed(.notification) {
+            onSwitch.setOn(true, animated: true)
+        }else {
+            onSwitch.setOn(false, animated: true)
         }
     }
 }

+ 10 - 15
RainbowPlanet/RainbowPlanet/Modules/MineModule/PushNotificationSettings/ViewController/PushNotificationSettingsViewController.swift

@@ -16,18 +16,20 @@ class PushNotificationSettingsViewController: BaseViewController {
     
     override func viewDidLoad() {
         super.viewDidLoad()
-
+        setupViews()
+        setupLayouts()
         // Do any additional setup after loading the view.
     }
     
     override func setupViews() {
-        navigationBar.title = "设置"
+        navigationBar.title = "推送通知设置"
         view.addSubview(tableView)
     }
     
     override func setupLayouts() {
         tableView.snp.makeConstraints { (make) in
-            make.edges.equalToSuperview()
+            make.right.left.bottom.equalToSuperview()
+            make.top.equalTo(kNavBarTotalHeight)
         }
     }
     
@@ -54,17 +56,9 @@ extension PushNotificationSettingsViewController : UITableViewDelegate,UITableVi
     }
     
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        switch indexPath.section {
-        case 2:
-            let cell = SetLogoutTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
-            cell.title = sections[indexPath.section][indexPath.row]
-            return cell
-        default:
-            let cell = SetTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
-            cell.title = sections[indexPath.section][indexPath.row]
-            return cell
-        }
-       
+        let cell = PushNotificationSettingsTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+        cell.title = sections[indexPath.section][indexPath.row]
+        return cell
     }
     
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
@@ -75,7 +69,8 @@ extension PushNotificationSettingsViewController : UITableViewDelegate,UITableVi
     func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
         switch section {
         case 1:
-            return nil
+            let headerView = PushNotificationSettingsOneSectionHeaderView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 40))
+            return headerView
         default:
             return nil
         }

+ 4 - 2
RainbowPlanet/RainbowPlanet/Modules/MineModule/Set/ViewController/SetViewController.swift

@@ -43,9 +43,11 @@ class SetViewController: BaseViewController {
                 switch indexPath.row {
                 // 帐号绑定
                 case 0:
-
                    Mediator.push(MineRouterModuleType.pushAccountSecurity)
-
+                    break
+                case 1:
+                    let vc = PushNotificationSettingsViewController()
+                    self?.navigationController?.pushViewController(vc, animated: true)
                     break
                 default:
                    showSwiftProgressHUDInfo()

+ 6 - 0
RainbowPlanet/RainbowPlanet/Modules/RongCloudIMModule/IMChatRoom/ViewController/IMChatRoomViewController.swift

@@ -30,6 +30,10 @@ class IMChatRoomViewController: RCConversationViewController {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         self.navigationController?.navigationBar.isHidden = false
+        let imageView = UIImageView(image: kImage(name: "guide_1"))
+        view.addSubview(imageView)
+        self.conversationMessageCollectionView.backgroundColor = UIColor.clear
+        view.bringSubviewToFront(self.conversationMessageCollectionView)
         self.conversationMessageCollectionView.reloadData()
     }
     
@@ -59,6 +63,8 @@ class IMChatRoomViewController: RCConversationViewController {
 //        #define PLUGIN_BOARD_ITEM_REMOTE_CONTROL_TAG 1108
 //        #define PLUGIN_BOARD_ITEM_TRANSFER_TAG 1109
     }
+    
+    
 
 
 }