Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Amperfy/Screens/Player/PlayerUIHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ class PlayerUIHandler: NSObject {
config.image = .shuffle
shuffleButton.configuration = config
}
shuffleButton.isEnabled = appDelegate.storage.settings.user.isPlayerShuffleButtonEnabled
let isShuffleButtonVisible = player.playerMode == .music &&
appDelegate.storage.settings.user.isPlayerShuffleButtonEnabled
shuffleButton.isHidden = !isShuffleButtonVisible
shuffleButton.isEnabled = isShuffleButtonVisible
shuffleButton.isSelected = player.isShuffle
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ContextQueueNextSectionHeader: UIView {
switch player.playerMode {
case .music:
repeatButton.isHidden = false
shuffleButton.isHidden = false
shuffleButton.isHidden = !appDelegate.storage.settings.user.isPlayerShuffleButtonEnabled
case .podcast:
repeatButton.isHidden = true
shuffleButton.isHidden = true
Expand Down
19 changes: 16 additions & 3 deletions Amperfy/Screens/View/LibraryElementDetailTableHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ class LibraryElementDetailTableHeaderView: UIView {

private var config: PlayShuffleInfoConfiguration?

private var isPlayShuffledButtonHidden: Bool {
guard let config else { return true }
let isHiddenBySetting = config.isShuffleOnContextNeccessary &&
!appDelegate.storage.settings.user.isPlayerShuffleButtonEnabled
return config.isShuffleHidden || isHiddenBySetting
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.layoutMargins = UIEdgeInsets(
Expand Down Expand Up @@ -97,6 +104,7 @@ class LibraryElementDetailTableHeaderView: UIView {

func refresh() {
guard let config = config else { return }
refreshPlayShuffledButtonAvailability()
if config.isEmbeddedInOtherView {
layoutMargins = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
} else {
Expand Down Expand Up @@ -161,7 +169,7 @@ class LibraryElementDetailTableHeaderView: UIView {
for: .normal
)
playShuffledButton.layer.cornerRadius = 10.0
playShuffledButton.isHidden = configuration.isShuffleHidden
refreshPlayShuffledButtonAvailability()
activate()
registerForTraitChanges(
[UITraitUserInterfaceStyle.self, UITraitHorizontalSizeClass.self],
Expand All @@ -173,12 +181,17 @@ class LibraryElementDetailTableHeaderView: UIView {

func activate() {
playAllButton.isEnabled = true
playShuffledButton.isEnabled = !(config?.isShuffleOnContextNeccessary ?? true) || appDelegate
.storage.settings.user.isPlayerShuffleButtonEnabled
refreshPlayShuffledButtonAvailability()
}

func deactivate() {
playAllButton.isEnabled = false
playShuffledButton.isEnabled = false
}

private func refreshPlayShuffledButtonAvailability() {
let isHidden = isPlayShuffledButtonHidden
playShuffledButton.isHidden = isHidden
playShuffledButton.isEnabled = !isHidden
}
}
4 changes: 2 additions & 2 deletions Amperfy/SwiftUI/Settings/DisplaySettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct DisplaySettingsView: View {
SettingsSection(
content: {
SettingsCheckBoxRow(
title: "Disable Player Shuffle Button",
title: "Hide Player Shuffle Button",
isOn: Binding<Bool>(
get: { !settings.isPlayerShuffleButtonEnabled },
set: {
Expand All @@ -162,7 +162,7 @@ struct DisplaySettingsView: View {
)
},
footer:
"The player shuffle button is displayed but non-interactive."
"Hide player shuffle controls throughout the app."
)
}
}
Expand Down