diff --git a/Persephone/Controllers/BrowseController.swift b/Persephone/Controllers/BrowseController.swift
index 3e2c314..f5470c4 100644
--- a/Persephone/Controllers/BrowseController.swift
+++ b/Persephone/Controllers/BrowseController.swift
@@ -7,26 +7,24 @@
//
import AppKit
+import ReSwift
class BrowseController: NSViewController {
- @IBOutlet var artistsButton: NSButton!
- @IBOutlet var albumsButton: NSButton!
-
@IBOutlet var browseTabView: NSTabView!
- @IBAction func switchToTab(_ sender: NSButton) {
- artistsButton.state = .off
- albumsButton.state = .off
+ override func viewDidLoad() {
+ super.viewDidLoad()
- switch sender.identifier?.rawValue {
- case "artists":
- artistsButton.state = .on
- browseTabView.selectTabViewItem(at: 0)
- case "albums":
- albumsButton.state = .on
- browseTabView.selectTabViewItem(at: 1)
- default:
- return
+ App.store.subscribe(self) {
+ $0.select { $0.uiState }
}
}
}
+
+extension BrowseController: StoreSubscriber {
+ typealias BrowseSubscriberStateType = UIState
+
+ func newState(state: BrowseSubscriberStateType) {
+ browseTabView.selectTabViewItem(at: state.browseViewState.rawValue)
+ }
+}
diff --git a/Persephone/Controllers/WindowController.swift b/Persephone/Controllers/WindowController.swift
index c920afd..de56e58 100644
--- a/Persephone/Controllers/WindowController.swift
+++ b/Persephone/Controllers/WindowController.swift
@@ -27,6 +27,8 @@ class WindowController: NSWindowController {
@IBOutlet var shuffleState: NSButton!
@IBOutlet var repeatState: NSButton!
+ @IBOutlet var browseViewControls: NSSegmentedControl!
+
override func windowDidLoad() {
super.windowDidLoad()
window?.titleVisibility = .hidden
@@ -38,6 +40,8 @@ class WindowController: NSWindowController {
}
}
+ browseViewControls.setSelected(true, forSegment: App.store.state.uiState.browseViewState.rawValue)
+
App.store.dispatch(MainWindowDidOpenAction())
trackProgress.font = .timerFont
@@ -160,6 +164,12 @@ class WindowController: NSWindowController {
App.mpdClient.setRepeatState(repeatState: sender.state == .on)
}
+ @IBAction func setBrowseViewState(_ sender: NSSegmentedControl) {
+ guard let browseViewState = BrowseViewState(rawValue: sender.selectedSegment)
+ else { return }
+
+ App.store.dispatch(SetVisibleBrowseView(browseViewState: browseViewState))
+ }
}
extension WindowController: NSWindowDelegate {
diff --git a/Persephone/Resources/Base.lproj/Main.storyboard b/Persephone/Resources/Base.lproj/Main.storyboard
index dbcda5f..fa32ceb 100644
--- a/Persephone/Resources/Base.lproj/Main.storyboard
+++ b/Persephone/Resources/Base.lproj/Main.storyboard
@@ -302,6 +302,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -314,6 +331,7 @@
+
@@ -321,6 +339,8 @@
+
+
@@ -505,123 +525,64 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
diff --git a/Persephone/State/Actions/UIActions.swift b/Persephone/State/Actions/UIActions.swift
index 7cc2135..67794fc 100644
--- a/Persephone/State/Actions/UIActions.swift
+++ b/Persephone/State/Actions/UIActions.swift
@@ -18,6 +18,10 @@ struct DatabaseUpdateStartedAction: Action {}
struct DatabaseUpdateFinishedAction: Action {}
+struct SetVisibleBrowseView: Action {
+ let browseViewState: BrowseViewState
+}
+
struct SetSelectedQueueItem: Action {
let selectedQueueItem: QueueItem?
}
diff --git a/Persephone/State/Reducers/UIReducer.swift b/Persephone/State/Reducers/UIReducer.swift
index c7dc494..abd3c98 100644
--- a/Persephone/State/Reducers/UIReducer.swift
+++ b/Persephone/State/Reducers/UIReducer.swift
@@ -27,6 +27,9 @@ func uiReducer(action: Action, state: UIState?) -> UIState {
case is DatabaseUpdateFinishedAction:
state.databaseUpdating = false
+ case let action as SetVisibleBrowseView:
+ state.browseViewState = action.browseViewState
+
case let action as SetSelectedSong:
state.selectedSong = action.selectedSong
diff --git a/Persephone/State/UIState.swift b/Persephone/State/UIState.swift
index 16ef4a6..19b74f8 100644
--- a/Persephone/State/UIState.swift
+++ b/Persephone/State/UIState.swift
@@ -14,8 +14,14 @@ enum MainWindowState {
case minimised
}
+enum BrowseViewState: Int {
+ case artists = 0
+ case albums = 1
+}
+
struct UIState: StateType {
var mainWindowState: MainWindowState = .closed
+ var browseViewState: BrowseViewState = .albums
var databaseUpdating: Bool = false
diff --git a/Persephone/Views/BrowseViewButton.swift b/Persephone/Views/BrowseViewButton.swift
index 5e679c5..445316c 100644
--- a/Persephone/Views/BrowseViewButton.swift
+++ b/Persephone/Views/BrowseViewButton.swift
@@ -14,10 +14,5 @@ class BrowseViewButton: NSButton {
// Drawing code here.
self.layer?.cornerRadius = 4
self.layer?.masksToBounds = true
- if #available(OSX 10.14, *) {
- self.layer?.backgroundColor = NSColor.controlAccentColor.cgColor
- } else {
- // Fallback on earlier versions
- }
}
}