|
@@ -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 }
|
|
|
+ }
|
|
|
+
|
|
|
}
|