// Copyright (c) 2022 NetEase, Inc. All rights reserved.
// Use of this source code is governed by a MIT license that can be
// found in the LICENSE file.

import Foundation

@objcMembers
public class MessageRemindViewModel: NSObject {
    var sectionData = [SettingSectionModel]()

    let repo = SettingRepo()

    func getData() {
        sectionData.append(getFirstSection())
        sectionData.append(getSecondSection())
        sectionData.append(getThirdSection())
    }

    private func getFirstSection() -> SettingSectionModel {
        let model = SettingSectionModel()
        weak var weakSelf = self
        let messageNotify = SettingCellModel()
        messageNotify.cellName = '新消息通知'
        messageNotify.type = SettingCellType.SettingSwitchCell.rawValue
        messageNotify.cornerType = .topLeft.union(.topRight).union(.bottomLeft).union(.bottomRight)
        messageNotify.switchOpen = repo.getPushEnable()
        messageNotify.swichChange = { isOpen in
            weakSelf?.repo.setPushEnable(isOpen)
        }
        model.cellModels.append(contentsOf: [messageNotify])
        return model
    }

    private func getSecondSection() -> SettingSectionModel {
        let model = SettingSectionModel()
        weak var weakSelf = self
        let ringBellItem = SettingCellModel()
        ringBellItem.cellName = '响铃模式'
        ringBellItem.type = SettingCellType.SettingSwitchCell.rawValue
        ringBellItem.cornerType = .topLeft.union(.topRight)
        ringBellItem.switchOpen = repo.getRingMode()
        ringBellItem.swichChange = { isOpen in
            weakSelf?.repo.setRingMode(isOpen)
        }

        let vibrationItem = SettingCellModel()
        vibrationItem.cellName = '震动模式'
        vibrationItem.type = SettingCellType.SettingSwitchCell.rawValue
        vibrationItem.cornerType = .bottomLeft.union(.bottomRight)
        vibrationItem.switchOpen = repo.getVibrateMode()
        vibrationItem.swichChange = { isOpen in
            weakSelf?.repo.setVibrateMode(isOpen)
        }
        model.cellModels.append(contentsOf: [ringBellItem, vibrationItem])
        return model
    }

    private func getThirdSection() -> SettingSectionModel {
        let model = SettingSectionModel()
        weak var weakSelf = self
        let receiveItem = SettingCellModel()
        receiveItem.cellName = 'PC/Web同步接收推送'
        receiveItem.type = SettingCellType.SettingSwitchCell.rawValue
        receiveItem.cornerType = .topLeft.union(.topRight)
        receiveItem.switchOpen = repo.getMultiPortPushMode()
        receiveItem.swichChange = { isOpen in
            weakSelf?.repo.updateMultiPortPushMode(isOpen)
        }

        let messageDetailItem = SettingCellModel()
        messageDetailItem.cellName = '通知栏不显示消息详情'
        messageDetailItem.type = SettingCellType.SettingSwitchCell.rawValue
        messageDetailItem.cornerType = .bottomLeft.union(.bottomRight)
        messageDetailItem.switchOpen = repo.getPushShowDetail()
        messageDetailItem.swichChange = { isOpen in
            weakSelf?.repo.setPushShowDetail(isOpen)
        }

        model.cellModels.append(contentsOf: [messageDetailItem])
        return model
    }
}

    }```

**功能描述:**

本页面提供iOS消息提醒设置的相关功能,包括:

* **新消息通知开关**: 控制是否接收新消息通知
* **响铃模式**: 控制是否开启声音提醒
* **震动模式**: 控制是否开启震动提醒
* **PC/Web同步接收推送**: 控制是否在PC/Web端同步接收推送
* **通知栏不显示消息详情**: 控制是否在通知栏显示消息详情

**使用说明:**

1. 打开App设置
2. 进入消息提醒设置页面
3. 根据需要调整相关设置

**注意:**

* 某些设置需要开启通知权限才能生效
* 不同机型可能存在设置差异

**相关推荐:**

* [iOS 通知设置](https://www.apple.com/cn/ios/feature-availability/)
* [iOS 应用程序权限设置](https://support.apple.com/en-us/HT205033)

原文地址: https://www.cveoy.top/t/topic/nxm9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录