add detailed description to explain "unknown fields"
This commit is contained in:
parent
8cfd8fcf5b
commit
0889bbfaa4
1 changed files with 18 additions and 2 deletions
|
|
@ -11,7 +11,7 @@ import SwiftyUserDefaults
|
||||||
|
|
||||||
class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
||||||
|
|
||||||
let hideUnknownSwitch = UISwitch(frame: CGRect.zero)
|
let hideUnknownSwitch = UISwitch()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
navigationItemTitle = "General"
|
navigationItemTitle = "General"
|
||||||
|
|
@ -30,7 +30,15 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
||||||
if indexPath == IndexPath(row: 0, section: 1) {
|
if indexPath == IndexPath(row: 0, section: 1) {
|
||||||
cell.accessoryType = .none
|
cell.accessoryType = .none
|
||||||
hideUnknownSwitch.onTintColor = UIColor(displayP3Red: 0, green: 122.0/255, blue: 1, alpha: 1)
|
hideUnknownSwitch.onTintColor = UIColor(displayP3Red: 0, green: 122.0/255, blue: 1, alpha: 1)
|
||||||
cell.accessoryView = hideUnknownSwitch
|
hideUnknownSwitch.sizeToFit()
|
||||||
|
let detailButton = UIButton(type: .detailDisclosure)
|
||||||
|
hideUnknownSwitch.frame = CGRect(x: 0, y: 0, width: hideUnknownSwitch.bounds.width, height: hideUnknownSwitch.bounds.height)
|
||||||
|
detailButton.frame = CGRect(x: hideUnknownSwitch.bounds.width+10, y: 5, width: detailButton.bounds.width, height: detailButton.bounds.height)
|
||||||
|
detailButton.addTarget(self, action: #selector(GeneralSettingsTableViewController.tapHideUnknownSwitchDetailButton(_:)), for: UIControlEvents.touchDown)
|
||||||
|
let accessoryView = UIView(frame: CGRect(x: 0, y: 0, width: detailButton.bounds.width + hideUnknownSwitch.bounds.width+10, height: hideUnknownSwitch.bounds.height))
|
||||||
|
accessoryView.addSubview(detailButton)
|
||||||
|
accessoryView.addSubview(hideUnknownSwitch)
|
||||||
|
cell.accessoryView = accessoryView
|
||||||
cell.selectionStyle = .none
|
cell.selectionStyle = .none
|
||||||
hideUnknownSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction(_:)), for: UIControlEvents.valueChanged)
|
hideUnknownSwitch.addTarget(self, action: #selector(hideUnknownSwitchAction(_:)), for: UIControlEvents.valueChanged)
|
||||||
hideUnknownSwitch.isOn = Defaults[.isHideUnknownOn]
|
hideUnknownSwitch.isOn = Defaults[.isHideUnknownOn]
|
||||||
|
|
@ -38,6 +46,14 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tapHideUnknownSwitchDetailButton(_ sender: Any?) {
|
||||||
|
print("tap")
|
||||||
|
let alertMessage = "Only \"key: value\" format in additional fields is supported. Unsupported fields will be given an \"unkown\" key. Turn on this switch to hide unsupported fields."
|
||||||
|
let alert = UIAlertController(title: "Hide Unknown Fields", message: alertMessage, preferredStyle: UIAlertControllerStyle.alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
|
||||||
|
self.present(alert, animated: true, completion: nil)
|
||||||
|
}
|
||||||
|
|
||||||
func hideUnknownSwitchAction(_ sender: Any?) {
|
func hideUnknownSwitchAction(_ sender: Any?) {
|
||||||
Defaults[.isHideUnknownOn] = hideUnknownSwitch.isOn
|
Defaults[.isHideUnknownOn] = hideUnknownSwitch.isOn
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue