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

60 lines
2.1 KiB
Swift

//
// 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!
@IBOutlet weak var circularAvatarsSwitch: UISwitch!
@IBOutlet weak var hideCustomEmojiInUsernamesSwitch: UISwitch!
@IBOutlet weak var defaultPostVisibilityLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
showRepliesInProfilesSwitch.setOn(Preferences.shared.showRepliesInProfiles, animated: false)
circularAvatarsSwitch.setOn(Preferences.shared.avatarStyle == .circle, animated: false)
hideCustomEmojiInUsernamesSwitch.setOn(Preferences.shared.hideCustomEmojiInUsernames, animated: false)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
defaultPostVisibilityLabel.text = Preferences.shared.defaultPostVisibility.displayName
}
/*
// 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
}
@IBAction func circularAvatarsChanged(_ sender: Any) {
Preferences.shared.avatarStyle = circularAvatarsSwitch.isOn ? .circle : .roundRect
}
@IBAction func hideCustomEmojiInUsernamesChanged(_ sender: Any) {
Preferences.shared.hideCustomEmojiInUsernames = hideCustomEmojiInUsernamesSwitch.isOn
}
}