Tusker/Tusker/Screens/Preferences/PreferencesTableViewControl...

60 lines
2.1 KiB
Swift
Raw Normal View History

2018-08-28 23:16:17 +00:00
//
// PreferencesTableViewController.swift
// Tusker
//
// Created by Shadowfacts on 8/28/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import UIKit
class PreferencesTableViewController: UITableViewController {
static func create() -> UIViewController {
guard let navigationController = UIStoryboard(name: "Preferences", bundle: nil).instantiateInitialViewController() as? UINavigationController else { fatalError() }
return navigationController
}
@IBOutlet weak var showRepliesInProfilesSwitch: UISwitch!
2018-08-28 23:49:31 +00:00
@IBOutlet weak var circularAvatarsSwitch: UISwitch!
@IBOutlet weak var hideCustomEmojiInUsernamesSwitch: UISwitch!
@IBOutlet weak var defaultPostVisibilityLabel: UILabel!
2018-08-28 23:16:17 +00:00
override func viewDidLoad() {
super.viewDidLoad()
showRepliesInProfilesSwitch.setOn(Preferences.shared.showRepliesInProfiles, animated: false)
2018-08-28 23:49:31 +00:00
circularAvatarsSwitch.setOn(Preferences.shared.avatarStyle == .circle, animated: false)
hideCustomEmojiInUsernamesSwitch.setOn(Preferences.shared.hideCustomEmojiInUsernames, animated: false)
2018-08-28 23:16:17 +00:00
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
defaultPostVisibilityLabel.text = Preferences.shared.defaultPostVisibility.displayName
}
2018-08-28 23:16:17 +00:00
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
@IBAction func showRepliesInProfilesChanged(_ sender: Any) {
Preferences.shared.showRepliesInProfiles = showRepliesInProfilesSwitch.isOn
}
2018-08-28 23:49:31 +00:00
@IBAction func circularAvatarsChanged(_ sender: Any) {
Preferences.shared.avatarStyle = circularAvatarsSwitch.isOn ? .circle : .roundRect
}
@IBAction func hideCustomEmojiInUsernamesChanged(_ sender: Any) {
Preferences.shared.hideCustomEmojiInUsernames = hideCustomEmojiInUsernamesSwitch.isOn
}
2018-08-28 23:16:17 +00:00
}