Skip to content

Commit

Permalink
DisplaySettings: disable player shuffle button
Browse files Browse the repository at this point in the history
  • Loading branch information
BLeeEZ committed May 20, 2024
1 parent 3105ff6 commit c41a012
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions Amperfy/Screens/Player/PopupPlayer+Visuals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import AmperfyKit
extension PopupPlayerVC {

func refresh() {
refreshContextQueueSectionHeader()
refreshUserQueueSectionHeader()
refreshCellMasks()
refreshVisibleCellsSubtitleColor()
Expand Down
5 changes: 5 additions & 0 deletions Amperfy/Screens/Player/PopupPlayerVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ class PopupPlayerVC: UIViewController, UIScrollViewDelegate {
userQueueSectionView.display(name: PlayerQueueType.user.description, buttonPressAction: self.clearUserQueue)
}
}

func refreshContextQueueSectionHeader() {
guard let contextNextQueueSectionHeader = contextNextQueueSectionHeader else { return }
contextNextQueueSectionHeader.refresh()
}

// MARK: - UIScrollViewDelegate
func scrollViewDidScroll(_ scrollView: UIScrollView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ContextQueueNextSectionHeader: UIView {

func refreshShuffleButton() {
guard let rootView = rootView else { return }
shuffleButton.isEnabled = appDelegate.storage.settings.isPlayerShuffleButtonEnabled
shuffleButton.isSelected = player.isShuffle
var config = rootView.getPlayerButtonConfiguration(isSelected: shuffleButton.isSelected)
config.image = .shuffle
Expand Down
5 changes: 5 additions & 0 deletions Amperfy/Screens/ViewController/SettingsHostVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class SettingsHostVC: UIViewController {
self.appDelegate.storage.settings.isShowArtistDuration = newValue
}))

settings.isPlayerShuffleButtonEnabled = self.appDelegate.storage.settings.isPlayerShuffleButtonEnabled
changesAgent.append(settings.$isPlayerShuffleButtonEnabled.sink(receiveValue: { newValue in
self.appDelegate.storage.settings.isPlayerShuffleButtonEnabled = newValue
}))

settings.isShowMusicPlayerSkipButtons = self.appDelegate.storage.settings.isShowMusicPlayerSkipButtons
changesAgent.append(settings.$isShowMusicPlayerSkipButtons.sink(receiveValue: { newValue in
self.appDelegate.storage.settings.isShowMusicPlayerSkipButtons = newValue
Expand Down
15 changes: 15 additions & 0 deletions Amperfy/SwiftUI/Settings/DisplaySettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ struct DisplaySettingsView: View {
, footer: {
Text("Display artist duration in table rows.")
})

Section(content: {
HStack {
Text("Disable Player Shuffle Button")
Spacer()
Toggle(isOn: Binding<Bool>(
get: { !settings.isPlayerShuffleButtonEnabled },
set: { settings.isPlayerShuffleButtonEnabled = !$0 }
)) {}
.frame(width: 130)
}
}
, footer: {
Text("Player Shuffle Button is displayed but it can't be interacted with.")
})
}
}
.navigationTitle("Display")
Expand Down
1 change: 1 addition & 0 deletions Amperfy/SwiftUI/Settings/ObservableSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ final class Settings: ObservableObject {
@Published var isShowSongDuration = false
@Published var isShowAlbumDuration = false
@Published var isShowArtistDuration = false
@Published var isPlayerShuffleButtonEnabled = true
@Published var screenLockPreventionPreference: ScreenLockPreventionPreference = .defaultValue
@Published var streamingMaxBitrateWifiPreference: StreamingMaxBitratePreference = .defaultValue
@Published var streamingMaxBitrateCellularPreference: StreamingMaxBitratePreference = .defaultValue
Expand Down
6 changes: 6 additions & 0 deletions AmperfyKit/Storage/PersistentStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public class PersistentStorage {
case ShowSongDuration = "showSongDuration"
case ShowAlbumDuration = "showAlbumDuration"
case ShowArtistDuration = "showArtistDuration"
case PlayerShuffleButtonEnabled = "enablePlayerShuffleButton"
case ShowMusicPlayerSkipButtons = "showMusicPlayerSkipButtons"

case SongActionOnTab = "songActionOnTab"
Expand Down Expand Up @@ -335,6 +336,11 @@ public class PersistentStorage {
set { UserDefaults.standard.set(newValue, forKey: UserDefaultsKey.ShowArtistDuration.rawValue) }
}

public var isPlayerShuffleButtonEnabled: Bool {
get { return UserDefaults.standard.object(forKey: UserDefaultsKey.PlayerShuffleButtonEnabled.rawValue) as? Bool ?? true }
set { UserDefaults.standard.set(newValue, forKey: UserDefaultsKey.PlayerShuffleButtonEnabled.rawValue) }
}

public var isShowMusicPlayerSkipButtons: Bool {
get { return UserDefaults.standard.object(forKey: UserDefaultsKey.ShowMusicPlayerSkipButtons.rawValue) as? Bool ?? false }
set { UserDefaults.standard.set(newValue, forKey: UserDefaultsKey.ShowMusicPlayerSkipButtons.rawValue) }
Expand Down

0 comments on commit c41a012

Please sign in to comment.