From a6373f7e10512c2c240ac2284ad5dcee7b987c7f Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 2 Oct 2018 19:39:39 -0400 Subject: [PATCH] Extract Appearance preferences into separate controller --- Tusker.xcodeproj/project.pbxproj | 4 + .../AppearanceTableViewController.swift | 49 ++++ .../Preferences/Preferences.storyboard | 213 +++++++++++------- .../PreferencesTableViewController.swift | 24 +- 4 files changed, 186 insertions(+), 104 deletions(-) create mode 100644 Tusker/Screens/Preferences/AppearanceTableViewController.swift diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index bcf5d272fa..2062092ec4 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -100,6 +100,7 @@ D6757A7E2157E02600721E32 /* XCBRequestSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6757A7D2157E02600721E32 /* XCBRequestSpec.swift */; }; D6757A822157E8FA00721E32 /* XCBSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6757A812157E8FA00721E32 /* XCBSession.swift */; }; D679C09F215850EF00DA27FE /* XCBActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D679C09E215850EF00DA27FE /* XCBActions.swift */; }; + D67E0513216438A7000E0927 /* AppearanceTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D67E0512216438A7000E0927 /* AppearanceTableViewController.swift */; }; D6BED170212663DA00F02DA0 /* SwiftSoup.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D6BED174212667E900F02DA0 /* StatusTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */; }; D6C693CA2161253F007D6A6D /* SilentActionPermissionsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693C92161253F007D6A6D /* SilentActionPermissionsTableViewController.swift */; }; @@ -280,6 +281,7 @@ D6757A7D2157E02600721E32 /* XCBRequestSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCBRequestSpec.swift; sourceTree = ""; }; D6757A812157E8FA00721E32 /* XCBSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCBSession.swift; sourceTree = ""; }; D679C09E215850EF00DA27FE /* XCBActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCBActions.swift; sourceTree = ""; }; + D67E0512216438A7000E0927 /* AppearanceTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceTableViewController.swift; sourceTree = ""; }; D6BED16E212663DA00F02DA0 /* SwiftSoup.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SwiftSoup.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D6BED173212667E900F02DA0 /* StatusTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusTableViewCell.swift; sourceTree = ""; }; D6C693C92161253F007D6A6D /* SilentActionPermissionsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SilentActionPermissionsTableViewController.swift; sourceTree = ""; }; @@ -551,6 +553,7 @@ isa = PBXGroup; children = ( D663626521360DD700C9CBA2 /* Preferences.storyboard */, + D67E0512216438A7000E0927 /* AppearanceTableViewController.swift */, D663626721360E2C00C9CBA2 /* PreferencesTableViewController.swift */, D641C78E213DF2AA004B4513 /* VisibilityTableViewController.swift */, D6C693C92161253F007D6A6D /* SilentActionPermissionsTableViewController.swift */, @@ -1105,6 +1108,7 @@ D663626821360E2C00C9CBA2 /* PreferencesTableViewController.swift in Sources */, D64F80E2215875CC00BEF393 /* XCBActionType.swift in Sources */, D66362752137068A00C9CBA2 /* Visibility+Helpers.swift in Sources */, + D67E0513216438A7000E0927 /* AppearanceTableViewController.swift in Sources */, D6C693FC2162FE6F007D6A6D /* LoadingViewController.swift in Sources */, D646C95A213B5D0500269FB5 /* LargeImageInteractionController.swift in Sources */, D6F953EC212519E700CF0F2B /* TimelineTableViewController.swift in Sources */, diff --git a/Tusker/Screens/Preferences/AppearanceTableViewController.swift b/Tusker/Screens/Preferences/AppearanceTableViewController.swift new file mode 100644 index 0000000000..1e9d8ce0cf --- /dev/null +++ b/Tusker/Screens/Preferences/AppearanceTableViewController.swift @@ -0,0 +1,49 @@ +// +// AppearanceTableViewController.swift +// Tusker +// +// Created by Shadowfacts on 10/2/18. +// Copyright © 2018 Shadowfacts. All rights reserved. +// + +import UIKit + +class AppearanceTableViewController: UITableViewController { + + @IBOutlet weak var showRepliesInProfilesSwitch: UISwitch! + @IBOutlet weak var circularAvatarsSwitch: UISwitch! + @IBOutlet weak var hideCustomEmojiInUsernamesSwitch: UISwitch! + + 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) + } + + /* + // 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. + } + */ + + // MARK: - Interaction + + @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 + } + +} diff --git a/Tusker/Screens/Preferences/Preferences.storyboard b/Tusker/Screens/Preferences/Preferences.storyboard index 42cac7ef4e..a2e9ae7d92 100644 --- a/Tusker/Screens/Preferences/Preferences.storyboard +++ b/Tusker/Screens/Preferences/Preferences.storyboard @@ -17,98 +17,37 @@ - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - + @@ -143,7 +82,7 @@ - + @@ -175,16 +114,128 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -222,7 +273,7 @@ - + @@ -270,7 +321,7 @@ - + @@ -289,7 +340,7 @@ - + @@ -307,7 +358,7 @@ - + diff --git a/Tusker/Screens/Preferences/PreferencesTableViewController.swift b/Tusker/Screens/Preferences/PreferencesTableViewController.swift index 02a222412d..95286bd39f 100644 --- a/Tusker/Screens/Preferences/PreferencesTableViewController.swift +++ b/Tusker/Screens/Preferences/PreferencesTableViewController.swift @@ -15,18 +15,8 @@ class PreferencesTableViewController: UITableViewController { 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) - } + @IBOutlet weak var defaultPostVisibilityLabel: UILabel! override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) @@ -43,17 +33,5 @@ class PreferencesTableViewController: UITableViewController { // 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 - } }