mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
feat(media): decouple airplay and output, merged output for lock screen
This commit is contained in:
parent
5e1e8f613b
commit
9d17e4aafb
7 changed files with 296 additions and 84 deletions
|
|
@ -34,6 +34,10 @@ struct MusicSlotConfigurationView: View {
|
|||
|
||||
private let slotCount = MusicControlButton.slotCount
|
||||
|
||||
private var isAppleMusicActive: Bool {
|
||||
musicManager.bundleIdentifier == "com.apple.Music"
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
header
|
||||
|
|
@ -195,15 +199,23 @@ private struct ScrollHintIndicator: View {
|
|||
}
|
||||
}
|
||||
|
||||
private func isControlDisabled(_ control: MusicControlButton) -> Bool {
|
||||
if control == .mediaOutput && !showMediaOutputControl { return true }
|
||||
if control.isAppleMusicExclusive && !isAppleMusicActive { return true }
|
||||
return false
|
||||
}
|
||||
|
||||
private func paletteItem(for control: MusicControlButton) -> some View {
|
||||
VStack(spacing: 6) {
|
||||
let disabled = isControlDisabled(control)
|
||||
|
||||
return VStack(spacing: 6) {
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.fill(Color(nsColor: .controlBackgroundColor))
|
||||
.frame(width: 44, height: 44)
|
||||
.overlay {
|
||||
Image(systemName: control.iconName)
|
||||
.font(.system(size: control.prefersLargeScale ? 18 : 15, weight: .medium))
|
||||
.foregroundStyle(control == .mediaOutput && !showMediaOutputControl ? .secondary : .primary)
|
||||
.foregroundStyle(disabled ? .secondary : .primary)
|
||||
}
|
||||
.onDrag {
|
||||
NSItemProvider(object: NSString(string: "control:\(control.rawValue)"))
|
||||
|
|
@ -220,8 +232,8 @@ private struct ScrollHintIndicator: View {
|
|||
.minimumScaleFactor(0.8)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.opacity(control == .mediaOutput && !showMediaOutputControl ? 0.4 : 1)
|
||||
.disabled(control == .mediaOutput && !showMediaOutputControl)
|
||||
.opacity(disabled ? 0.4 : 1)
|
||||
.disabled(disabled)
|
||||
}
|
||||
|
||||
private func place(_ control: MusicControlButton) {
|
||||
|
|
@ -233,17 +245,20 @@ private struct ScrollHintIndicator: View {
|
|||
}
|
||||
|
||||
private func slotValue(at index: Int) -> MusicControlButton {
|
||||
let normalized = musicControlSlots.normalized(allowingMediaOutput: showMediaOutputControl)
|
||||
let normalized = musicControlSlots.normalized(allowingMediaOutput: showMediaOutputControl, isAppleMusicActive: isAppleMusicActive)
|
||||
guard normalized.indices.contains(index) else { return .none }
|
||||
return normalized[index]
|
||||
}
|
||||
|
||||
private var pickerOptions: [MusicControlButton] {
|
||||
let base = MusicControlButton.pickerOptions
|
||||
if showMediaOutputControl {
|
||||
return base
|
||||
var base = MusicControlButton.pickerOptions
|
||||
if !showMediaOutputControl {
|
||||
base = base.filter { $0 != .mediaOutput }
|
||||
}
|
||||
return base.filter { $0 != .mediaOutput }
|
||||
if !isAppleMusicActive {
|
||||
base = base.filter { !$0.isAppleMusicExclusive }
|
||||
}
|
||||
return base
|
||||
}
|
||||
|
||||
private func previewIconColor(for slot: MusicControlButton) -> Color {
|
||||
|
|
|
|||
|
|
@ -2373,6 +2373,11 @@ struct Media: View {
|
|||
@Default(.lockScreenMusicAlbumParallaxEnabled) private var lockScreenMusicAlbumParallaxEnabled
|
||||
@Default(.showStandardMediaControls) private var showStandardMediaControls
|
||||
@Default(.autoHideInactiveNotchMediaPlayer) private var autoHideInactiveNotchMediaPlayer
|
||||
@ObservedObject private var musicManager = MusicManager.shared
|
||||
|
||||
private var isAppleMusicActive: Bool {
|
||||
musicManager.bundleIdentifier == "com.apple.Music"
|
||||
}
|
||||
|
||||
private func highlightID(_ title: String) -> String {
|
||||
SettingsTab.media.highlightID(for: title)
|
||||
|
|
@ -2532,6 +2537,11 @@ struct Media: View {
|
|||
Defaults.Toggle("Show lock screen media panel", key: .enableLockScreenMediaWidget)
|
||||
Defaults.Toggle("Show media app icon", key: .lockScreenShowAppIcon)
|
||||
.disabled(!enableLockScreenMediaWidget)
|
||||
if isAppleMusicActive {
|
||||
Defaults.Toggle("Show merged AirPlay and output devices", key: .lockScreenMusicMergedAirPlayOutput)
|
||||
.disabled(!enableLockScreenMediaWidget)
|
||||
.settingsHighlight(id: highlightID("Show merged AirPlay and output devices"))
|
||||
}
|
||||
Defaults.Toggle("Show panel border", key: .lockScreenPanelShowsBorder)
|
||||
.disabled(!enableLockScreenMediaWidget)
|
||||
if lockScreenGlassCustomizationMode == .customLiquid {
|
||||
|
|
@ -4282,6 +4292,12 @@ struct LockScreenSettings: View {
|
|||
@Default(.lockScreenCalendarSelectionMode) private var lockScreenCalendarSelectionMode
|
||||
@Default(.lockScreenSelectedCalendarIDs) private var lockScreenSelectedCalendarIDs
|
||||
@Default(.lockScreenShowCalendarEventAfterStartEnabled) private var lockScreenShowCalendarEventAfterStartEnabled
|
||||
@Default(.lockScreenMusicMergedAirPlayOutput) private var lockScreenMusicMergedAirPlayOutput
|
||||
@ObservedObject private var musicManager = MusicManager.shared
|
||||
|
||||
private var isAppleMusicActive: Bool {
|
||||
musicManager.bundleIdentifier == "com.apple.Music"
|
||||
}
|
||||
|
||||
private func highlightID(_ title: String) -> String {
|
||||
SettingsTab.lockScreen.highlightID(for: title)
|
||||
|
|
@ -4437,6 +4453,11 @@ struct LockScreenSettings: View {
|
|||
Defaults.Toggle("Show media app icon", key: .lockScreenShowAppIcon)
|
||||
.disabled(!enableLockScreenMediaWidget)
|
||||
.settingsHighlight(id: highlightID("Show media app icon"))
|
||||
if isAppleMusicActive {
|
||||
Defaults.Toggle("Show merged AirPlay and output devices", key: .lockScreenMusicMergedAirPlayOutput)
|
||||
.disabled(!enableLockScreenMediaWidget)
|
||||
.settingsHighlight(id: highlightID("Show merged AirPlay and output devices"))
|
||||
}
|
||||
Defaults.Toggle("Show panel border", key: .lockScreenPanelShowsBorder)
|
||||
.disabled(!enableLockScreenMediaWidget)
|
||||
.settingsHighlight(id: highlightID("Show panel border"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue