Ver código fonte

通知完成

南鑫林 5 anos atrás
pai
commit
730d1b38cf

+ 2 - 0
RainbowPlanet/Podfile

@@ -70,6 +70,8 @@ target 'RainbowPlanet' do
   # 内存泄露
   pod 'MLeaksFinder'
 #  pod 'FBMemoryProfiler'
+  # bug统计
+  pod 'Bugly'
 
 
 #======================第三方平台===========

+ 5 - 1
RainbowPlanet/Podfile.lock

@@ -22,6 +22,7 @@ PODS:
   - AliyunVideoSDKPro (3.11.0)
   - BaiduMapKit (4.4.2)
   - BMKLocationKit (1.5.0)
+  - Bugly (2.5.0)
   - Cache (5.2.0)
   - DeviceKit (2.1.0)
   - DPScrollNumberLabel (0.0.2)
@@ -104,6 +105,7 @@ DEPENDENCIES:
   - AliyunVideoSDKPro
   - BaiduMapKit
   - BMKLocationKit (= 1.5.0)
+  - Bugly
   - Cache
   - DeviceKit
   - DPScrollNumberLabel
@@ -157,6 +159,7 @@ SPEC REPOS:
     - AliyunVideoSDKPro
     - BaiduMapKit
     - BMKLocationKit
+    - Bugly
     - Cache
     - DeviceKit
     - DPScrollNumberLabel
@@ -207,6 +210,7 @@ SPEC CHECKSUMS:
   AliyunVideoSDKPro: da710c1e7fb93b1e9a741b3619814c6608780b4b
   BaiduMapKit: 11acde2e7c06e31b7de60b323880a5eb7c4dccb6
   BMKLocationKit: 40d267478acd8704ddebd0e9deaddc727b13df9f
+  Bugly: 3ca9f255c01025582df26f9222893b383c7e4b4e
   Cache: 807c5d86d01a177f06ede9865add3aea269bbfd4
   DeviceKit: 2f6c28410d5a5fe2977be7f8cb9b313d28bdae69
   DPScrollNumberLabel: 5124eaccf3029bb84116de391e1273cba676f4f5
@@ -249,6 +253,6 @@ SPEC CHECKSUMS:
   YYText: 5c461d709e24d55a182d1441c41dc639a18a4849
   ZipArchive: e25a4373192673e3229ac8d6e9f64a3e5713c966
 
-PODFILE CHECKSUM: 5ee04af728b239abe6553f922c24805895ba3bed
+PODFILE CHECKSUM: e792d8f1072d2e2d566e4d47594e9772c674d58a
 
 COCOAPODS: 1.7.5

+ 1 - 1
RainbowPlanet/RainbowPlanet/Model/UserModel/PushConfigModel.swift

@@ -21,7 +21,7 @@ class PushConfigModel : NSObject, Mappable{
 	required init?(map: Map){}
 	private override init(){}
     
-    static enum pushConfigType : String {
+    enum pushConfigType : String {
         case commentStatus = "comment_status"
         case followStatus = "follow_status"
         case likeStatus = "like_status"

+ 69 - 9
RainbowPlanet/RainbowPlanet/Modules/MineModule/PushNotificationSettings/View/PushNotificationSettingsTableViewCell.swift

@@ -69,14 +69,6 @@ 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
@@ -93,7 +85,6 @@ class PushNotificationSettingsTableViewCell: UITableViewCell {
     
     lazy var onSwitch: UISwitch = {
         let onSwitch = UISwitch()
-        onSwitch.isOn = true
         onSwitch.backgroundColor = kf1f1f1Color
         onSwitch.onTintColor = kThemeColor
         onSwitch.tintColor = kf1f1f1Color
@@ -125,4 +116,73 @@ class PushNotificationSettingsTableViewCell: UITableViewCell {
             onSwitch.setOn(false, animated: true)
         }
     }
+    
+    var pushConfigModel : PushConfigModel? {
+        didSet {
+            if indexPath?.section == 1 {
+                switch indexPath?.row {
+                case 0:
+                    if pushConfigModel?.systemStatus == 0 {
+                         onSwitch.setOn(false, animated: false)
+                    } else if pushConfigModel?.systemStatus == 1 {
+                         onSwitch.setOn(true, animated: false)
+                    }
+                    break
+                case 1:
+                    if pushConfigModel?.commentStatus == 0 {
+                        onSwitch.setOn(false, animated: false)
+                    } else if pushConfigModel?.commentStatus == 1 {
+                        onSwitch.setOn(true, animated: false)
+                    }
+                    break
+                case 2:
+                    if pushConfigModel?.likeStatus == 0 {
+                        onSwitch.setOn(false, animated: false)
+                    } else if pushConfigModel?.likeStatus == 1 {
+                        onSwitch.setOn(true, animated: false)
+                    }
+                    break
+                case 3:
+                    if pushConfigModel?.followStatus == 0 {
+                        onSwitch.setOn(false, animated: false)
+                    } else if pushConfigModel?.followStatus == 1 {
+                        onSwitch.setOn(true, animated: false)
+                    }
+                    break
+                default:
+                    break
+                }
+            }
+        }
+    }
+    
+    @objc func onSwitchAction(onSwitch:UISwitch) {
+        if indexPath?.section == 0 {
+            self.onSwitch.isOn = !onSwitch.isOn
+            NXLPermission.openSettingsURL()
+        }else {
+            switch indexPath?.row {
+            case 0:
+                userChangePushConfigApi(type: PushConfigModel.pushConfigType.systemStatus)
+                break
+            case 1:
+                userChangePushConfigApi(type: PushConfigModel.pushConfigType.commentStatus)
+
+                break
+            case 2:
+                userChangePushConfigApi(type: PushConfigModel.pushConfigType.likeStatus)
+                break
+            case 3:
+                userChangePushConfigApi(type: PushConfigModel.pushConfigType.followStatus)
+                break
+            default:
+                break
+            }
+        }
+    }
+    
+    func userChangePushConfigApi(type: PushConfigModel.pushConfigType) {
+        SwiftMoyaNetWorkServiceUser.shared().userChangePushConfigApi(type: type) {(data) -> (Void) in }
+    }
+    
 }

+ 11 - 1
RainbowPlanet/RainbowPlanet/Modules/MineModule/PushNotificationSettings/ViewController/PushNotificationSettingsViewController.swift

@@ -14,11 +14,13 @@ class PushNotificationSettingsViewController: BaseViewController {
     let sections = [["接收推送通知"],
                     ["系统通知","评论和回复","赞与互动","关注"]]
     
+    var pushConfigModel : PushConfigModel?
+    
     override func viewDidLoad() {
         super.viewDidLoad()
         setupViews()
         setupLayouts()
-        // Do any additional setup after loading the view.
+        setupData()
     }
     
     override func setupViews() {
@@ -32,6 +34,13 @@ class PushNotificationSettingsViewController: BaseViewController {
             make.top.equalTo(kNavBarTotalHeight)
         }
     }
+    override func setupData() {
+        SwiftMoyaNetWorkServiceUser.shared().userPushConfigApi {
+            [weak self] (pushConfigModel) -> (Void) in
+            self?.pushConfigModel = pushConfigModel as? PushConfigModel
+            self?.tableView.reloadData()
+        }
+    }
     
     private lazy var tableView: UITableView = {
         let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
@@ -58,6 +67,7 @@ extension PushNotificationSettingsViewController : UITableViewDelegate,UITableVi
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = PushNotificationSettingsTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
         cell.title = sections[indexPath.section][indexPath.row]
+        cell.pushConfigModel = self.pushConfigModel
         return cell
     }