Skip to content

Commit

Permalink
Using NSSwitch for prefs, moved playback-related prefs to separate tab
Browse files Browse the repository at this point in the history
  • Loading branch information
insidegui committed May 30, 2020
1 parent 201f5d7 commit b5d6d76
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 653 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ disabled_rules:
- trailing_whitespace
- multiple_closures_with_trailing_closure
- large_tuple
- implicit_getter

opt_in_rules:
- redundant_nil_coalescing
Expand Down
10 changes: 4 additions & 6 deletions WWDC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
DD0159A91ED09F5D00F980F1 /* AppCoordinator+Bookmarks.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD0159A81ED09F5D00F980F1 /* AppCoordinator+Bookmarks.swift */; };
DD0159CF1ED0CD3A00F980F1 /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD0159CE1ED0CD3A00F980F1 /* PreferencesWindowController.swift */; };
DD0159D11ED0CEF500F980F1 /* PreferencesCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD0159D01ED0CEF500F980F1 /* PreferencesCoordinator.swift */; };
DD0159D61ED0D98F00F980F1 /* ITSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = DD0159D51ED0D98F00F980F1 /* ITSwitch.m */; };
DD0159D91ED11A9800F980F1 /* ModalLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD0159D81ED11A9800F980F1 /* ModalLoadingView.swift */; };
DD0159FC1ED23F7700F980F1 /* RemoteEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD0159FB1ED23F7700F980F1 /* RemoteEnvironment.swift */; };
DD0F0C561E7B8DD600B52184 /* Storage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD0F0C551E7B8DD600B52184 /* Storage.swift */; };
Expand Down Expand Up @@ -133,6 +132,7 @@
DDA60E1320A90655002EECF5 /* SessionCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDA60E1220A90655002EECF5 /* SessionCellView.swift */; };
DDA60E1520A907B6002EECF5 /* SessionCollectionViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDA60E1420A907B6002EECF5 /* SessionCollectionViewItem.swift */; };
DDA60E1720A9083E002EECF5 /* RelatedSessionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDA60E1620A9083E002EECF5 /* RelatedSessionsViewController.swift */; };
DDA7B7182482EB8900F86668 /* PlaybackPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDA7B7172482EB8900F86668 /* PlaybackPreferencesViewController.swift */; };
DDAE001B1EC52D2B0036C7E9 /* SessionProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAE001A1EC52D2B0036C7E9 /* SessionProgress.swift */; };
DDAE001D1EC534BF0036C7E9 /* TrackColorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAE001C1EC534BF0036C7E9 /* TrackColorView.swift */; };
DDAE7C4F1E5BA4E300CEA205 /* transcript.json in Resources */ = {isa = PBXBuildFile; fileRef = DDAE7C4E1E5BA4E300CEA205 /* transcript.json */; };
Expand Down Expand Up @@ -428,8 +428,6 @@
DD0159A81ED09F5D00F980F1 /* AppCoordinator+Bookmarks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "AppCoordinator+Bookmarks.swift"; sourceTree = "<group>"; };
DD0159CE1ED0CD3A00F980F1 /* PreferencesWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesWindowController.swift; sourceTree = "<group>"; };
DD0159D01ED0CEF500F980F1 /* PreferencesCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesCoordinator.swift; sourceTree = "<group>"; };
DD0159D41ED0D98F00F980F1 /* ITSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ITSwitch.h; sourceTree = "<group>"; };
DD0159D51ED0D98F00F980F1 /* ITSwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ITSwitch.m; sourceTree = "<group>"; };
DD0159D81ED11A9800F980F1 /* ModalLoadingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModalLoadingView.swift; sourceTree = "<group>"; };
DD0159FB1ED23F7700F980F1 /* RemoteEnvironment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteEnvironment.swift; sourceTree = "<group>"; };
DD0F0C551E7B8DD600B52184 /* Storage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Storage.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -539,6 +537,7 @@
DDA60E1220A90655002EECF5 /* SessionCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionCellView.swift; sourceTree = "<group>"; };
DDA60E1420A907B6002EECF5 /* SessionCollectionViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionCollectionViewItem.swift; sourceTree = "<group>"; };
DDA60E1620A9083E002EECF5 /* RelatedSessionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelatedSessionsViewController.swift; sourceTree = "<group>"; };
DDA7B7172482EB8900F86668 /* PlaybackPreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackPreferencesViewController.swift; sourceTree = "<group>"; };
DDAE001A1EC52D2B0036C7E9 /* SessionProgress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionProgress.swift; sourceTree = "<group>"; };
DDAE001C1EC534BF0036C7E9 /* TrackColorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackColorView.swift; sourceTree = "<group>"; };
DDAE7C4E1E5BA4E300CEA205 /* transcript.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = transcript.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -806,6 +805,7 @@
DD0159D01ED0CEF500F980F1 /* PreferencesCoordinator.swift */,
DD0159CE1ED0CD3A00F980F1 /* PreferencesWindowController.swift */,
DDC6781A1EDB629C00A4E19C /* GeneralPreferencesViewController.swift */,
DDA7B7172482EB8900F86668 /* PlaybackPreferencesViewController.swift */,
);
name = Preferences;
sourceTree = "<group>";
Expand Down Expand Up @@ -917,8 +917,6 @@
DD36A4C01E478CF500B2EA88 /* Views */ = {
isa = PBXGroup;
children = (
DD0159D41ED0D98F00F980F1 /* ITSwitch.h */,
DD0159D51ED0D98F00F980F1 /* ITSwitch.m */,
DDF32EB11EBE34E10028E39D /* Base */,
DDF32EB01EBE34CE0028E39D /* TableView */,
DD2E27871EAC2CCB0009D7B6 /* ShelfView.swift */,
Expand Down Expand Up @@ -2051,7 +2049,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DD0159D61ED0D98F00F980F1 /* ITSwitch.m in Sources */,
DDB28F8E1EAD257B0077703F /* PlaybackViewModel.swift in Sources */,
DD4648491ECA5EC0005C57C6 /* NSToolbarItemViewer+Overrides.m in Sources */,
DDF32EAB1EBE2E240028E39D /* WWDCTableRowView.swift in Sources */,
Expand Down Expand Up @@ -2118,6 +2115,7 @@
4DBA2F7620FE71BF00ED0253 /* DownloadsStatusButton.swift in Sources */,
DD6E06F81EDBC62D000EAEA4 /* TranscriptTableViewController.swift in Sources */,
DD36A4B01E478C6A00B2EA88 /* AppDelegate.swift in Sources */,
DDA7B7182482EB8900F86668 /* PlaybackPreferencesViewController.swift in Sources */,
DD6E06FC1EDBCA7E000EAEA4 /* TranscriptTableCellView.swift in Sources */,
4D66CA52217E2C9B0006A8C9 /* DownloadsManagementTableView.swift in Sources */,
DDF32EB91EBE65B50028E39D /* AppCoordinator+Shelf.swift in Sources */,
Expand Down
58 changes: 24 additions & 34 deletions WWDC/GeneralPreferencesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ class GeneralPreferencesViewController: NSViewController {
return vc
}

@IBOutlet weak var searchInTranscriptsSwitch: ITSwitch!
@IBOutlet weak var searchInBookmarksSwitch: ITSwitch!
@IBOutlet weak var refreshPeriodicallySwitch: ITSwitch!
@IBOutlet weak var skipBackAndForwardBy30SecondsSwitch: ITSwitch!
@IBOutlet weak var enableUserDataSyncSwitch: ITSwitch!
@IBOutlet weak var searchInTranscriptsSwitch: NSSwitch!
@IBOutlet weak var searchInBookmarksSwitch: NSSwitch!
@IBOutlet weak var refreshPeriodicallySwitch: NSSwitch!
@IBOutlet weak var enableUserDataSyncSwitch: NSSwitch!

@IBOutlet weak var downloadsFolderLabel: NSTextField!

Expand All @@ -53,7 +52,6 @@ class GeneralPreferencesViewController: NSViewController {
@IBOutlet weak var includeBookmarksLabel: NSTextField!
@IBOutlet weak var includeTranscriptsLabel: NSTextField!
@IBOutlet weak var refreshAutomaticallyLabel: NSTextField!
@IBOutlet weak var skipBackAndForwardBy30SecondsLabel: NSTextField!
@IBOutlet weak var enableUserDataSyncLabel: NSTextField!
@IBOutlet weak var syncDescriptionLabel: NSTextField!
@IBOutlet weak var transcriptLanguagesPopUp: NSPopUpButton!
Expand All @@ -65,7 +63,6 @@ class GeneralPreferencesViewController: NSViewController {
@IBOutlet weak var dividerA: NSBox!
@IBOutlet weak var dividerB: NSBox!
@IBOutlet weak var dividerC: NSBox!
@IBOutlet weak var dividerD: NSBox!
@IBOutlet weak var dividerE: NSBox!

override func viewDidLoad() {
Expand All @@ -76,29 +73,20 @@ class GeneralPreferencesViewController: NSViewController {
includeBookmarksLabel.textColor = .prefsPrimaryText
includeTranscriptsLabel.textColor = .prefsPrimaryText
refreshAutomaticallyLabel.textColor = .prefsPrimaryText
skipBackAndForwardBy30SecondsLabel.textColor = .prefsPrimaryText
downloadsFolderLabel.textColor = .prefsSecondaryText
enableUserDataSyncLabel.textColor = .prefsPrimaryText
syncDescriptionLabel.textColor = .prefsSecondaryText
languagesDescriptionLabel.textColor = .prefsSecondaryText

dividerA.fillColor = .darkGridColor
dividerB.fillColor = .darkGridColor
dividerC.fillColor = .darkGridColor
dividerD.fillColor = .darkGridColor
dividerE.fillColor = .darkGridColor
dividerA.fillColor = .separatorColor
dividerB.fillColor = .separatorColor
dividerC.fillColor = .separatorColor
dividerE.fillColor = .separatorColor

searchInTranscriptsSwitch.tintColor = .primary
searchInBookmarksSwitch.tintColor = .primary
refreshPeriodicallySwitch.tintColor = .primary
skipBackAndForwardBy30SecondsSwitch.tintColor = .primary
enableUserDataSyncSwitch.tintColor = .primary

searchInTranscriptsSwitch.checked = Preferences.shared.searchInTranscripts
searchInBookmarksSwitch.checked = Preferences.shared.searchInBookmarks
refreshPeriodicallySwitch.checked = Preferences.shared.refreshPeriodically
skipBackAndForwardBy30SecondsSwitch.checked = Preferences.shared.skipBackAndForwardBy30Seconds
enableUserDataSyncSwitch.checked = Preferences.shared.syncUserData
searchInTranscriptsSwitch.isOn = Preferences.shared.searchInTranscripts
searchInBookmarksSwitch.isOn = Preferences.shared.searchInBookmarks
refreshPeriodicallySwitch.isOn = Preferences.shared.refreshPeriodically
enableUserDataSyncSwitch.isOn = Preferences.shared.syncUserData

downloadsFolderLabel.stringValue = Preferences.shared.localVideoStorageURL.path

Expand Down Expand Up @@ -127,7 +115,6 @@ class GeneralPreferencesViewController: NSViewController {
.drive(enableUserDataSyncSwitch.rx.isEnabled)
.disposed(by: disposeBag)
#else
dividerD?.isHidden = true
enableUserDataSyncSwitch?.isHidden = true
syncDescriptionLabel?.isHidden = true
#endif
Expand Down Expand Up @@ -167,25 +154,21 @@ class GeneralPreferencesViewController: NSViewController {
}

@IBAction func searchInTranscriptsSwitchAction(_ sender: Any) {
Preferences.shared.searchInTranscripts = searchInTranscriptsSwitch.checked
Preferences.shared.searchInTranscripts = searchInTranscriptsSwitch.isOn
}

@IBAction func searchInBookmarksSwitchAction(_ sender: Any) {
Preferences.shared.searchInBookmarks = searchInBookmarksSwitch.checked
Preferences.shared.searchInBookmarks = searchInBookmarksSwitch.isOn
}

@IBAction func refreshPeriodicallySwitchAction(_ sender: Any) {
Preferences.shared.refreshPeriodically = refreshPeriodicallySwitch.checked
}

@IBAction func skipBackAndForwardBy30SecondsSwitchAction(_ sender: Any) {
Preferences.shared.skipBackAndForwardBy30Seconds = skipBackAndForwardBy30SecondsSwitch.checked
Preferences.shared.refreshPeriodically = refreshPeriodicallySwitch.isOn
}

@IBAction func enableUserDataSyncSwitchAction(_ sender: Any) {
#if ICLOUD
Preferences.shared.syncUserData = enableUserDataSyncSwitch.checked
userDataSyncEngine?.isEnabled = enableUserDataSyncSwitch.checked
Preferences.shared.syncUserData = enableUserDataSyncSwitch.isOn
userDataSyncEngine?.isEnabled = enableUserDataSyncSwitch.isOn
#endif
}

Expand Down Expand Up @@ -323,3 +306,10 @@ class GeneralPreferencesViewController: NSViewController {
}

}

extension NSSwitch {
var isOn: Bool {
get { state == .on }
set { state = newValue ? .on : .off }
}
}
31 changes: 0 additions & 31 deletions WWDC/ITSwitch.h

This file was deleted.

Loading

0 comments on commit b5d6d76

Please sign in to comment.