mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Working button remapping
This commit is contained in:
parent
9f57cc0a38
commit
40bcbb1c7f
6 changed files with 124 additions and 32 deletions
|
|
@ -17,7 +17,8 @@ import AppKit
|
|||
struct MinimalisticMusicPlayerView: View {
|
||||
@EnvironmentObject var vm: DynamicIslandViewModel
|
||||
let albumArtNamespace: Namespace.ID
|
||||
@Default(.showMediaOutputControl) var showMediaOutputControl
|
||||
@Default(.musicAuxLeftControl) private var leftAuxControl
|
||||
@Default(.musicAuxRightControl) private var rightAuxControl
|
||||
@ObservedObject private var reminderManager = ReminderLiveActivityManager.shared
|
||||
@Default(.enableReminderLiveActivity) private var enableReminderLiveActivity
|
||||
@Default(.enableLyrics) private var enableLyrics
|
||||
|
|
@ -601,9 +602,7 @@ private struct MinimalisticReminderDetailsView: View {
|
|||
private var playbackControls: some View {
|
||||
HStack(spacing: 16) {
|
||||
if Defaults[.showShuffleAndRepeat] {
|
||||
controlButton(icon: "shuffle", isActive: musicManager.isShuffled) {
|
||||
Task { await musicManager.toggleShuffle() }
|
||||
}
|
||||
auxButton(for: leftAuxControl)
|
||||
}
|
||||
|
||||
controlButton(icon: "backward.fill", size: 18) {
|
||||
|
|
@ -616,16 +615,8 @@ private struct MinimalisticReminderDetailsView: View {
|
|||
Task { await musicManager.nextTrack() }
|
||||
}
|
||||
|
||||
// (lyrics toggle removed from UI; controlled via Settings -> Media -> Enable Lyrics)
|
||||
|
||||
if Defaults[.showShuffleAndRepeat] {
|
||||
if showMediaOutputControl {
|
||||
MinimalisticMediaOutputButton()
|
||||
} else {
|
||||
controlButton(icon: repeatIcon, isActive: musicManager.repeatMode != .off) {
|
||||
Task { await musicManager.toggleRepeat() }
|
||||
}
|
||||
}
|
||||
auxButton(for: rightAuxControl)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
|
|
@ -657,6 +648,26 @@ private struct MinimalisticReminderDetailsView: View {
|
|||
action: action
|
||||
)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func auxButton(for control: MusicAuxiliaryControl) -> some View {
|
||||
switch control {
|
||||
case .shuffle:
|
||||
controlButton(icon: "shuffle", isActive: musicManager.isShuffled) {
|
||||
Task { await musicManager.toggleShuffle() }
|
||||
}
|
||||
case .repeatMode:
|
||||
controlButton(icon: repeatIcon, isActive: musicManager.repeatMode != .off) {
|
||||
Task { await musicManager.toggleRepeat() }
|
||||
}
|
||||
case .mediaOutput:
|
||||
MinimalisticMediaOutputButton()
|
||||
case .lyrics:
|
||||
controlButton(icon: enableLyrics ? "quote.bubble.fill" : "quote.bubble", isActive: enableLyrics) {
|
||||
enableLyrics.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
private struct MinimalisticMediaOutputButton: View {
|
||||
@ObservedObject private var routeManager = AudioRouteManager.shared
|
||||
@StateObject private var volumeModel = MediaOutputVolumeViewModel()
|
||||
|
|
|
|||
|
|
@ -120,7 +120,9 @@ struct MusicControlsView: View {
|
|||
@State private var dragging: Bool = false
|
||||
@State private var lastDragged: Date = .distantPast
|
||||
let showShuffleAndRepeat: Bool
|
||||
@Default(.showMediaOutputControl) private var showMediaOutputControl
|
||||
@Default(.musicAuxLeftControl) private var leftAuxControl
|
||||
@Default(.musicAuxRightControl) private var rightAuxControl
|
||||
@Default(.enableLyrics) private var enableLyrics
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
|
|
@ -213,12 +215,7 @@ struct MusicControlsView: View {
|
|||
private var playbackControls: some View {
|
||||
HStack(spacing: 8) {
|
||||
if showShuffleAndRepeat {
|
||||
HoverButton(
|
||||
icon: "shuffle", iconColor: musicManager.isShuffled ? .red : .white,
|
||||
scale: .medium
|
||||
) {
|
||||
MusicManager.shared.toggleShuffle()
|
||||
}
|
||||
auxButton(for: leftAuxControl)
|
||||
}
|
||||
HoverButton(icon: "backward.fill", scale: .medium) {
|
||||
MusicManager.shared.previousTrack()
|
||||
|
|
@ -230,13 +227,7 @@ struct MusicControlsView: View {
|
|||
MusicManager.shared.nextTrack()
|
||||
}
|
||||
if showShuffleAndRepeat {
|
||||
if showMediaOutputControl {
|
||||
MediaOutputPickerButton()
|
||||
} else {
|
||||
HoverButton(icon: repeatIcon, iconColor: repeatIconColor, scale: .medium) {
|
||||
MusicManager.shared.toggleRepeat()
|
||||
}
|
||||
}
|
||||
auxButton(for: rightAuxControl)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
|
|
@ -261,6 +252,38 @@ struct MusicControlsView: View {
|
|||
return .red
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func auxButton(for control: MusicAuxiliaryControl) -> some View {
|
||||
switch control {
|
||||
case .shuffle:
|
||||
HoverButton(
|
||||
icon: "shuffle",
|
||||
iconColor: musicManager.isShuffled ? .red : .white,
|
||||
scale: .medium
|
||||
) {
|
||||
MusicManager.shared.toggleShuffle()
|
||||
}
|
||||
case .repeatMode:
|
||||
HoverButton(
|
||||
icon: repeatIcon,
|
||||
iconColor: repeatIconColor,
|
||||
scale: .medium
|
||||
) {
|
||||
MusicManager.shared.toggleRepeat()
|
||||
}
|
||||
case .mediaOutput:
|
||||
MediaOutputPickerButton()
|
||||
case .lyrics:
|
||||
HoverButton(
|
||||
icon: enableLyrics ? "quote.bubble.fill" : "quote.bubble",
|
||||
iconColor: enableLyrics ? .accentColor : .white,
|
||||
scale: .medium
|
||||
) {
|
||||
enableLyrics.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Main View
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue