passforios/pass/Controllers/GeneralSettingsTableViewController.swift

46 lines
1.5 KiB
Swift
Raw Normal View History

2017-02-09 21:45:31 +08:00
//
// GeneralSettingsTableViewController.swift
// pass
//
// Created by Mingshen Sun on 9/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
2017-02-14 11:16:30 +08:00
import SwiftyUserDefaults
2017-02-09 21:45:31 +08:00
class GeneralSettingsTableViewController: BasicStaticTableViewController {
2017-02-14 11:16:30 +08:00
let hideUnknownSwitch = UISwitch(frame: CGRect.zero)
2017-02-09 21:45:31 +08:00
override func viewDidLoad() {
navigationItemTitle = "General"
2017-02-09 22:13:31 +08:00
tableData = [
// section 0
2017-02-10 16:44:59 +08:00
[[.title: "About Repository", .action: "segue", .link: "showAboutRepositorySegue"],],
2017-02-14 11:16:30 +08:00
[[.title: "Hide Unkonwn Fields", .action: "none",],],
2017-02-09 22:13:31 +08:00
]
2017-02-09 21:45:31 +08:00
super.viewDidLoad()
2017-02-14 11:16:30 +08:00
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = super.tableView(tableView, cellForRowAt: indexPath)
if indexPath == IndexPath(row: 0, section: 1) {
cell.accessoryType = .none
hideUnknownSwitch.onTintColor = UIColor(displayP3Red: 0, green: 122.0/255, blue: 1, alpha: 1)
cell.accessoryView = hideUnknownSwitch
cell.selectionStyle = .none
hideUnknownSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction(_:)), for: UIControlEvents.valueChanged)
hideUnknownSwitch.isOn = Defaults[.isHideUnknownOn]
}
return cell
}
func hideUnknownSwitchAction(_ sender: Any?) {
Defaults[.isHideUnknownOn] = hideUnknownSwitch.isOn
2017-02-09 21:45:31 +08:00
}
2017-02-14 11:16:30 +08:00
2017-02-09 21:45:31 +08:00
}