import UIKit

// swiftlint: disable force_unwrapping
// swiftlint: disable force_cast
class NotificationSettingsViewController: UITableViewController {
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let setting = SettingsEnum(rawValue: indexPath.row)!
        switch setting {
        case .notificationsFromUnknown:
            let cell = tableView.dequeueReusableCell(withIdentifier: "NotificationsFromUnknownTableViewCell", for: indexPath) as! SwitchTableViewCell
            cell.switchView.isOn = Settings.notificationsFromUnknown.getBool()
            cell.valueChangedListener = { (switchView: UISwitch) in
                Settings.notificationsFromUnknown.setValue(switchView.isOn)
            }
            return cell
        }
    }

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath as IndexPath, animated: true)
    }

    internal enum SettingsEnum: Int {
        case notificationsFromUnknown = 0
    }
}
