Fixed 1 color picker bug made home UI padding

This commit is contained in:
Venkatesh 2026-03-31 20:35:47 +08:00
commit 90b5dae3ba
12 changed files with 58 additions and 122 deletions

View file

@ -991,7 +991,7 @@ struct ContentView: View {
.background( .background(
Image(nsImage: musicManager.albumArt) Image(nsImage: musicManager.albumArt)
.resizable() .resizable()
.aspectRatio(contentMode: .fit) .scaledToFill()
) )
.clipped() .clipped()
.clipShape(RoundedRectangle(cornerRadius: MusicPlayerImageSizes.cornerRadiusInset.closed)) .clipShape(RoundedRectangle(cornerRadius: MusicPlayerImageSizes.cornerRadiusInset.closed))

View file

@ -928,6 +928,9 @@
} }
} }
} }
},
"%0.1f" : {
}, },
"%d%%" : { "%d%%" : {
"localizations" : { "localizations" : {
@ -1853,10 +1856,6 @@
} }
} }
}, },
"±10 Seconds" : {
"comment" : "Display name for the \"±10 Seconds\" music skip behavior option.",
"isCommentAutoGenerated" : true
},
"0" : { "0" : {
"comment" : "A label displayed in a circular gauge to indicate the minimum battery level.", "comment" : "A label displayed in a circular gauge to indicate the minimum battery level.",
"isCommentAutoGenerated" : true, "isCommentAutoGenerated" : true,
@ -2330,10 +2329,6 @@
} }
} }
}, },
"Accent" : {
"comment" : "Display name for the caps lock indicator tint mode.",
"isCommentAutoGenerated" : true
},
"Accent color" : { "Accent color" : {
"localizations" : { "localizations" : {
"ar" : { "ar" : {
@ -2737,10 +2732,6 @@
"comment" : "Label for the active GPU field in the GPU usage dashboard.", "comment" : "Label for the active GPU field in the GPU usage dashboard.",
"isCommentAutoGenerated" : true "isCommentAutoGenerated" : true
}, },
"Adaptive gradient" : {
"comment" : "Display name for the timer icon color mode: adaptive gradient.",
"isCommentAutoGenerated" : true
},
"Add" : { "Add" : {
"localizations" : { "localizations" : {
"ar" : { "ar" : {
@ -4579,10 +4570,6 @@
} }
} }
}, },
"Apple Music" : {
"comment" : "Media controller type for Apple Music",
"isCommentAutoGenerated" : true
},
"Applies the notch-style parallax effect to the lock screen media widget album art." : { "Applies the notch-style parallax effect to the lock screen media widget album art." : {
"localizations" : { "localizations" : {
"ko" : { "ko" : {
@ -5164,10 +5151,6 @@
} }
} }
}, },
"Bar" : {
"comment" : "Name of the timer progress style that shows a horizontal bar.",
"isCommentAutoGenerated" : true
},
"Battery" : { "Battery" : {
"localizations" : { "localizations" : {
"ar" : { "ar" : {
@ -10531,10 +10514,6 @@
} }
} }
}, },
"Digital" : {
"comment" : "The display name for the \"Digital\" reminder presentation style.",
"isCommentAutoGenerated" : true
},
"Dimensions" : { "Dimensions" : {
"localizations" : { "localizations" : {
"ko" : { "ko" : {
@ -11892,9 +11871,6 @@
}, },
"Enable album art parallax" : { "Enable album art parallax" : {
},
"Enable album art parallax effect" : {
}, },
"Enable and style the media controls that appear above the system clock when the screen is locked." : { "Enable and style the media controls that appear above the system clock when the screen is locked." : {
"comment" : "A description of the media panel settings in the lock screen settings view.", "comment" : "A description of the media panel settings in the lock screen settings view.",
@ -14849,10 +14825,6 @@
} }
} }
}, },
"Green" : {
"comment" : "Display name for the green caps lock indicator tint mode.",
"isCommentAutoGenerated" : true
},
"Height:" : { "Height:" : {
"extractionState" : "stale", "extractionState" : "stale",
"localizations" : { "localizations" : {
@ -19228,6 +19200,7 @@
} }
}, },
"Minutes" : { "Minutes" : {
"extractionState" : "stale",
"localizations" : { "localizations" : {
"fr" : { "fr" : {
"stringUnit" : { "stringUnit" : {
@ -21731,10 +21704,6 @@
} }
} }
}, },
"Now Playing" : {
"comment" : "Name of the media controller type for the \"Now Playing\" option.",
"isCommentAutoGenerated" : true
},
"Number of lines kept in the scrollback buffer. Higher values use more memory." : { "Number of lines kept in the scrollback buffer. Higher values use more memory." : {
"localizations" : { "localizations" : {
"ko" : { "ko" : {
@ -22281,10 +22250,6 @@
} }
} }
}, },
"Panel" : {
"comment" : "Display name for the clipboard display mode \"Panel\".",
"isCommentAutoGenerated" : true
},
"Panel mode shows clipboard in a floating window near the notch." : { "Panel mode shows clipboard in a floating window near the notch." : {
"comment" : "A description of the \"Panel\" clipboard display mode.", "comment" : "A description of the \"Panel\" clipboard display mode.",
"isCommentAutoGenerated" : true, "isCommentAutoGenerated" : true,
@ -22340,6 +22305,9 @@
} }
} }
} }
},
"Parallax Effect Intensity" : {
}, },
"Pause" : { "Pause" : {
"shouldTranslate" : false "shouldTranslate" : false
@ -24560,10 +24528,6 @@
} }
} }
}, },
"Ring" : {
"comment" : "The name of the timer progress style that shows a ring shape.",
"isCommentAutoGenerated" : true
},
"Rotation:" : { "Rotation:" : {
"extractionState" : "stale", "extractionState" : "stale",
"localizations" : { "localizations" : {
@ -25611,10 +25575,6 @@
} }
} }
}, },
"Separate Tab" : {
"comment" : "Display name for the clipboard display mode option to open the clipboard in a separate tab.",
"isCommentAutoGenerated" : true
},
"Separate Tab mode integrates Copied Items and Notes into a single view. If both are enabled, Notes appear on the right and Clipboard on the left." : { "Separate Tab mode integrates Copied Items and Notes into a single view. If both are enabled, Notes appear on the right and Clipboard on the left." : {
"comment" : "A description of the \"Separate Tab\" clipboard display mode.", "comment" : "A description of the \"Separate Tab\" clipboard display mode.",
"isCommentAutoGenerated" : true, "isCommentAutoGenerated" : true,
@ -26974,14 +26934,6 @@
} }
} }
}, },
"Shows screen assistant as a dropdown attached to the AI button" : {
"comment" : "Description of the screen assistant display mode option that shows the screen assistant as a dropdown attached to the AI button.",
"isCommentAutoGenerated" : true
},
"Shows screen assistant in a floating panel near the notch" : {
"comment" : "Description of the screen assistant display mode option that shows the screen assistant in a floating panel near the notch.",
"isCommentAutoGenerated" : true
},
"Shows the model's reasoning process before the final answer" : { "Shows the model's reasoning process before the final answer" : {
"localizations" : { "localizations" : {
"fr" : { "fr" : {
@ -27093,10 +27045,6 @@
} }
} }
}, },
"Skip forward or backward by ten seconds" : {
"comment" : "Description of a music skip behavior option.",
"isCommentAutoGenerated" : true
},
"Slider color" : { "Slider color" : {
"localizations" : { "localizations" : {
"ar" : { "ar" : {
@ -27704,10 +27652,6 @@
} }
} }
}, },
"Spotify" : {
"comment" : "Spotify media controller type.",
"isCommentAutoGenerated" : true
},
"Square" : { "Square" : {
"localizations" : { "localizations" : {
"ar" : { "ar" : {
@ -27853,10 +27797,6 @@
} }
} }
}, },
"Standard previous/next track controls" : {
"comment" : "Description of the music skip behavior option to use standard previous/next track controls.",
"isCommentAutoGenerated" : true
},
"Start" : { "Start" : {
"localizations" : { "localizations" : {
"fr" : { "fr" : {
@ -29697,10 +29637,6 @@
}, },
"shouldTranslate" : false "shouldTranslate" : false
}, },
"Track Skip" : {
"comment" : "Display name for the \"Track Skip\" music skip behavior.",
"isCommentAutoGenerated" : true
},
"Transform" : { "Transform" : {
"extractionState" : "stale", "extractionState" : "stale",
"localizations" : { "localizations" : {
@ -32089,10 +32025,6 @@
} }
} }
}, },
"Youtube Music" : {
"comment" : "Spotify music service.",
"isCommentAutoGenerated" : true
},
"YouTube Music requires this third-party app to be installed: " : { "YouTube Music requires this third-party app to be installed: " : {
"localizations" : { "localizations" : {
"ar" : { "ar" : {

View file

@ -301,7 +301,7 @@ struct LockScreenMusicPanel: View {
if showAppIcon, let icon = lockScreenAppIcon { if showAppIcon, let icon = lockScreenAppIcon {
icon icon
.resizable() .resizable()
.aspectRatio(contentMode: .fill) .scaledToFill()
.frame(width: appIconSize, height: appIconSize) .frame(width: appIconSize, height: appIconSize)
.clipShape(RoundedRectangle(cornerRadius: appIconCornerRadius, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: appIconCornerRadius, style: .continuous))
.shadow(color: Color.black.opacity(0.35), radius: 6, x: 0, y: 4) .shadow(color: Color.black.opacity(0.35), radius: 6, x: 0, y: 4)
@ -310,7 +310,7 @@ struct LockScreenMusicPanel: View {
} }
} }
.albumArtFlip(angle: musicManager.flipAngle) .albumArtFlip(angle: musicManager.flipAngle)
.parallax3D(magnitude: 12, enableOverride: lockScreenParallaxEnabled, suspended: isParallaxSuspended) .parallax3D(enableOverride: lockScreenParallaxEnabled, suspended: isParallaxSuspended)
.frame(width: size, height: size) .frame(width: size, height: size)
.background(albumArtBackground(cornerRadius: cornerRadius)) .background(albumArtBackground(cornerRadius: cornerRadius))
} }
@ -1049,7 +1049,7 @@ struct LockScreenMusicPanel: View {
private func albumArtImage(size: CGFloat, cornerRadius: CGFloat) -> some View { private func albumArtImage(size: CGFloat, cornerRadius: CGFloat) -> some View {
Image(nsImage: musicManager.albumArt) Image(nsImage: musicManager.albumArt)
.resizable() .resizable()
.aspectRatio(contentMode: .fit) .scaledToFill()
.frame(width: size, height: size) .frame(width: size, height: size)
.clipShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))
} }
@ -1082,7 +1082,7 @@ struct LockScreenMusicPanel: View {
} }
private var appIconCornerRadius: CGFloat { private var appIconCornerRadius: CGFloat {
isExpanded ? 18 : 10 isExpanded ? 18 : 12
} }
private var appIconOffset: CGFloat { private var appIconOffset: CGFloat {

View file

@ -63,6 +63,7 @@ struct MinimalisticMusicView: View {
// Lyrics under the author name (same font size as author) // Lyrics under the author name (same font size as author)
if enableLyrics { if enableLyrics {
lyricsLineView lyricsLineView
.font(.system(size: 11, weight: .regular))
} }
} }
.frame(width: geo.size.width, height: geo.size.height, alignment: .center) .frame(width: geo.size.width, height: geo.size.height, alignment: .center)

View file

@ -34,6 +34,7 @@ struct DynamicIslandHeader: View {
@Default(.enableTimerFeature) var enableTimerFeature @Default(.enableTimerFeature) var enableTimerFeature
@Default(.timerDisplayMode) var timerDisplayMode @Default(.timerDisplayMode) var timerDisplayMode
@Default(.showClipboardIcon) var showClipboardIcon @Default(.showClipboardIcon) var showClipboardIcon
@Default(.showColorPickerIcon) var showColorPickerIcon
@Default(.clipboardDisplayMode) var clipboardDisplayMode @Default(.clipboardDisplayMode) var clipboardDisplayMode
var body: some View { var body: some View {
@ -50,6 +51,8 @@ struct DynamicIslandHeader: View {
.blur(radius: vm.notchState == .closed ? 20 : 0) .blur(radius: vm.notchState == .closed ? 20 : 0)
.animation(.smooth.delay(0.1), value: vm.notchState) .animation(.smooth.delay(0.1), value: vm.notchState)
.zIndex(2) .zIndex(2)
.padding(8)
} }
if vm.notchState == .open && !Defaults[.enableMinimalisticUI] { if vm.notchState == .open && !Defaults[.enableMinimalisticUI] {
@ -128,7 +131,7 @@ struct DynamicIslandHeader: View {
} }
// ColorPicker button // ColorPicker button
if Defaults[.enableColorPickerFeature] { if Defaults[.enableColorPickerFeature] && showColorPickerIcon{
Button(action: { Button(action: {
switch Defaults[.colorPickerDisplayMode] { switch Defaults[.colorPickerDisplayMode] {
case .panel: case .panel:
@ -293,7 +296,7 @@ private extension DynamicIslandHeader {
Defaults[.settingsIconInNotch] Defaults[.settingsIconInNotch]
&& Defaults[.enableClipboardManager] && Defaults[.enableClipboardManager]
&& Defaults[.showClipboardIcon] && Defaults[.showClipboardIcon]
&& Defaults[.enableColorPickerFeature] && Defaults[.showColorPickerIcon]
&& Defaults[.enableTimerFeature] && Defaults[.enableTimerFeature]
} }
} }

View file

@ -374,7 +374,7 @@ struct MinimalisticMusicPlayerView: View {
private struct MinimalisticReminderEventListView: View { private struct MinimalisticReminderEventListView: View {
let reminders: [ReminderLiveActivityManager.ReminderEntry] let reminders: [ReminderLiveActivityManager.ReminderEntry]
private let textFont = Font.system(size: 13, weight: .semibold) private let textFont = Font.system(size: 13, weight: .regular)
private let separatorSpacing: CGFloat = 10 private let separatorSpacing: CGFloat = 10
var body: some View { var body: some View {
@ -1128,7 +1128,7 @@ struct MinimalisticAlbumArtView: View {
.background( .background(
Image(nsImage: musicManager.albumArt) Image(nsImage: musicManager.albumArt)
.resizable() .resizable()
.aspectRatio(contentMode: .fit) .scaledToFill()
) )
.clipped() .clipped()
.clipShape(RoundedRectangle(cornerRadius: 12)) .clipShape(RoundedRectangle(cornerRadius: 12))
@ -1147,13 +1147,13 @@ struct MinimalisticAlbumArtView: View {
.background( .background(
Image(nsImage: musicManager.albumArt) Image(nsImage: musicManager.albumArt)
.resizable() .resizable()
.aspectRatio(contentMode: .fit) .scaledToFill()
) )
.clipped() .clipped()
.clipShape(RoundedRectangle(cornerRadius: 12)) .clipShape(RoundedRectangle(cornerRadius: 12))
.matchedGeometryEffect(id: "albumArt", in: albumArtNamespace) .matchedGeometryEffect(id: "albumArt", in: albumArtNamespace)
.albumArtFlip(angle: musicManager.flipAngle) .albumArtFlip(angle: musicManager.flipAngle)
.parallax3D(magnitude: 12) .parallax3D()
} }
.buttonStyle(PlainButtonStyle()) .buttonStyle(PlainButtonStyle())
.opacity(musicManager.isPlaying ? 1 : 0.4) .opacity(musicManager.isPlaying ? 1 : 0.4)

View file

@ -33,7 +33,6 @@ struct MusicPlayerView: View {
var body: some View { var body: some View {
HStack(alignment: .top, spacing: 12) { HStack(alignment: .top, spacing: 12) {
AlbumArtView(vm: vm, albumArtNamespace: albumArtNamespace) AlbumArtView(vm: vm, albumArtNamespace: albumArtNamespace)
.padding(.all, 5)
MusicControlsView() MusicControlsView()
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
} }
@ -61,7 +60,7 @@ struct AlbumArtView: View {
.background( .background(
Image(nsImage: musicManager.albumArt) Image(nsImage: musicManager.albumArt)
.resizable() .resizable()
.aspectRatio(contentMode: .fit) .scaledToFill()
) )
.clipped() .clipped()
.clipShape( .clipShape(
@ -86,7 +85,9 @@ struct AlbumArtView: View {
appIconOverlay appIconOverlay
} }
.albumArtFlip(angle: musicManager.flipAngle) .albumArtFlip(angle: musicManager.flipAngle)
.parallax3D(magnitude: 12) .parallax3D()
.padding(.bottom, -5)
} }
.buttonStyle(PlainButtonStyle()) .buttonStyle(PlainButtonStyle())
.scaleEffect(musicManager.isPlaying ? 1 : 0.85) .scaleEffect(musicManager.isPlaying ? 1 : 0.85)
@ -109,7 +110,8 @@ struct AlbumArtView: View {
.overlay { .overlay {
Image(nsImage: musicManager.albumArt) Image(nsImage: musicManager.albumArt)
.resizable() .resizable()
.aspectRatio(contentMode: .fit) .scaledToFill() //to ensure the thumbnail will always be within the square icon
} }
.matchedGeometryEffect(id: "albumArt", in: albumArtNamespace) .matchedGeometryEffect(id: "albumArt", in: albumArtNamespace)
.clipped() .clipped()
@ -126,8 +128,8 @@ struct AlbumArtView: View {
if vm.notchState == .open && !musicManager.usingAppIconForArtwork { if vm.notchState == .open && !musicManager.usingAppIconForArtwork {
AppIcon(for: musicManager.bundleIdentifier ?? "com.apple.Music") AppIcon(for: musicManager.bundleIdentifier ?? "com.apple.Music")
.resizable() .resizable()
.aspectRatio(contentMode: .fill) .scaledToFill()
.frame(width: 30, height: 30) .frame(width: 36, height: 36)
.offset(x: 10, y: 10) .offset(x: 10, y: 10)
.transition(.scale.combined(with: .opacity).animation(.bouncy.delay(0.3))) .transition(.scale.combined(with: .opacity).animation(.bouncy.delay(0.3)))
.zIndex(2) .zIndex(2)
@ -207,9 +209,9 @@ struct MusicControlsView: View {
MarqueeText( MarqueeText(
lyricsBinding, lyricsBinding,
font: .headline, font: .system(size: 12, weight: .regular),
nsFont: .headline, nsFont: .headline,
textColor: .white.opacity(0.8), textColor: .white.opacity(0.7),
minDuration: 0.35, minDuration: 0.35,
frameWidth: width frameWidth: width
) )
@ -605,6 +607,7 @@ struct NotchHomeView: View {
.combined(with: .blurReplace.animation(.smooth.speed(0.9))) .combined(with: .blurReplace.animation(.smooth.speed(0.9)))
.combined(with: .move(edge: .top))) .combined(with: .move(edge: .top)))
.blur(radius: vm.notchState == .closed ? 30 : 0) .blur(radius: vm.notchState == .closed ? 30 : 0)
.padding(8) //Put the main padding here for consistency!!!
} }
private var minimalisticOverridePayload: ExtensionNotchExperiencePayload? { private var minimalisticOverridePayload: ExtensionNotchExperiencePayload? {
@ -713,6 +716,7 @@ struct MusicSliderView: View {
LiveStreamProgressIndicator(tint: sliderTint) LiveStreamProgressIndicator(tint: sliderTint)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.frame(height: sliderFrameHeight) .frame(height: sliderFrameHeight)
case .inline: case .inline:
HStack(spacing: 10) { HStack(spacing: 10) {
Spacer() Spacer()
@ -720,6 +724,7 @@ struct MusicSliderView: View {
LiveStreamProgressIndicator(tint: sliderTint) LiveStreamProgressIndicator(tint: sliderTint)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.frame(height: sliderFrameHeight) .frame(height: sliderFrameHeight)
Spacer() Spacer()
.frame(width: 48) .frame(width: 48)
} }
@ -748,10 +753,10 @@ struct MusicSliderView: View {
) )
} }
private var sliderTint: Color { private var sliderTint: Color {//
switch Defaults[.sliderColor] { switch Defaults[.sliderColor] {
case .albumArt: case .albumArt:
return Color(nsColor: color).ensureMinimumBrightness(factor: 0.8) return Color(nsColor: color).ensureMinimumBrightness(factor: 0.6)
case .accent: case .accent:
return .accentColor return .accentColor
case .white: case .white:

View file

@ -2443,6 +2443,9 @@ struct Media: View {
@Default(.lockScreenMusicAlbumParallaxEnabled) private var lockScreenMusicAlbumParallaxEnabled @Default(.lockScreenMusicAlbumParallaxEnabled) private var lockScreenMusicAlbumParallaxEnabled
@Default(.showStandardMediaControls) private var showStandardMediaControls @Default(.showStandardMediaControls) private var showStandardMediaControls
@Default(.autoHideInactiveNotchMediaPlayer) private var autoHideInactiveNotchMediaPlayer @Default(.autoHideInactiveNotchMediaPlayer) private var autoHideInactiveNotchMediaPlayer
@Default(.parallaxEffectIntensity) private var parallaxEffectIntensity
@ObservedObject private var musicManager = MusicManager.shared @ObservedObject private var musicManager = MusicManager.shared
private var isAppleMusicActive: Bool { private var isAppleMusicActive: Bool {
@ -2587,10 +2590,18 @@ struct Media: View {
Text("Enable lyrics") Text("Enable lyrics")
} }
.settingsHighlight(id: highlightID("Enable lyrics")) .settingsHighlight(id: highlightID("Enable lyrics"))
Defaults.Toggle(key: .enableParallaxEffect) {
Text("Enable album art parallax effect") //Parallax Effect Intensity to control how much parallax is wanted
Slider(value: $parallaxEffectIntensity, in: 0...12, step: 1.0) {
HStack {
Text("Parallax Effect Intensity")
Spacer()
Text("\(parallaxEffectIntensity, specifier: "%0.1f")")
.foregroundStyle(.secondary)
}
} }
.settingsHighlight(id: highlightID("Enable album art parallax effect")) .settingsHighlight(id: highlightID("Enable album art parallax effect"))
Picker("Sneak Peek Style", selection: $sneakPeekStyles){ Picker("Sneak Peek Style", selection: $sneakPeekStyles){
ForEach(SneakPeekStyle.allCases) { style in ForEach(SneakPeekStyle.allCases) { style in
Text(style.rawValue).tag(style) Text(style.rawValue).tag(style)

View file

@ -31,7 +31,6 @@ struct TabButton: View {
var body: some View { var body: some View {
Button(action: onClick) { Button(action: onClick) {
Image(systemName: icon) Image(systemName: icon)
.padding(.horizontal, 15)
.contentShape(Capsule()) .contentShape(Capsule())
} }
.buttonStyle(PlainButtonStyle()) .buttonStyle(PlainButtonStyle())

View file

@ -105,7 +105,7 @@ struct TabSelectionView: View {
return tabsArray return tabsArray
} }
var body: some View { var body: some View {
HStack(spacing: 0) { HStack(spacing: 32) {
ForEach(tabs) { tab in ForEach(tabs) { tab in
let isSelected = isSelected(tab) let isSelected = isSelected(tab)
let activeAccent = tab.accentColor ?? .white let activeAccent = tab.accentColor ?? .white
@ -117,23 +117,10 @@ struct TabSelectionView: View {
} }
.frame(height: 26) .frame(height: 26)
.foregroundStyle(isSelected ? activeAccent : .gray) .foregroundStyle(isSelected ? activeAccent : .gray)
.background {
if isSelected {
Capsule()
.fill((tab.accentColor ?? Color(nsColor: .secondarySystemFill)).opacity(0.25))
.shadow(color: (tab.accentColor ?? .clear).opacity(0.4), radius: 8)
.matchedGeometryEffect(id: "capsule", in: animation)
} else {
Capsule()
.fill(Color.clear)
.matchedGeometryEffect(id: "capsule", in: animation)
.hidden()
}
}
} }
} }
.animation(.smooth(duration: 0.3), value: coordinator.currentView) .animation(.smooth(duration: 0.3), value: coordinator.currentView)
.clipShape(Capsule())
.onAppear { .onAppear {
ensureValidSelection(with: tabs) ensureValidSelection(with: tabs)
} }

View file

@ -22,17 +22,16 @@ import AppKit
import Defaults import Defaults
struct ParallaxMotionModifier: ViewModifier { struct ParallaxMotionModifier: ViewModifier {
var magnitude: Double
var enableOverride: Bool? var enableOverride: Bool?
var isSuspended: Bool var isSuspended: Bool
@Default(.enableParallaxEffect) var enableParallaxEffect @Default(.parallaxEffectIntensity) var parallaxEffectIntensity
@State private var offset: CGSize = .zero @State private var offset: CGSize = .zero
@State private var isHovering = false @State private var isHovering = false
@State private var viewSize: CGSize = .zero @State private var viewSize: CGSize = .zero
func body(content: Content) -> some View { func body(content: Content) -> some View {
if isSuspended || !(enableOverride ?? enableParallaxEffect) { if isSuspended || !(enableOverride ?? (parallaxEffectIntensity > 0.0)) {
content content
} else { } else {
content content
@ -69,11 +68,11 @@ struct ParallaxMotionModifier: ViewModifier {
} }
} }
.rotation3DEffect( .rotation3DEffect(
.degrees(offset.height * magnitude), // Y movement rotates around X axis .degrees(offset.height * parallaxEffectIntensity), // Y movement rotates around X axis
axis: (x: 1, y: 0, z: 0) axis: (x: 1, y: 0, z: 0)
) )
.rotation3DEffect( .rotation3DEffect(
.degrees(offset.width * -magnitude), // X movement rotates around Y axis (inverted to look naturally) .degrees(offset.width * -parallaxEffectIntensity), // X movement rotates around Y axis (inverted to look naturally)
axis: (x: 0, y: 1, z: 0) axis: (x: 0, y: 1, z: 0)
) )
.scaleEffect(isHovering ? 1.02 : 1.0) // Subtle scale up on hover .scaleEffect(isHovering ? 1.02 : 1.0) // Subtle scale up on hover
@ -83,10 +82,9 @@ struct ParallaxMotionModifier: ViewModifier {
extension View { extension View {
func parallax3D( func parallax3D(
magnitude: Double = 10,
enableOverride: Bool? = nil, enableOverride: Bool? = nil,
suspended: Bool = false suspended: Bool = false
) -> some View { ) -> some View {
modifier(ParallaxMotionModifier(magnitude: magnitude, enableOverride: enableOverride, isSuspended: suspended)) modifier(ParallaxMotionModifier(enableOverride: enableOverride, isSuspended: suspended))
} }
} }

View file

@ -776,7 +776,7 @@ extension Defaults.Keys {
static let sneakPeekStyles = Key<SneakPeekStyle>("sneakPeekStyles", default: .standard) static let sneakPeekStyles = Key<SneakPeekStyle>("sneakPeekStyles", default: .standard)
static let showSneakPeekOnTrackChange = Key<Bool>("showSneakPeekOnTrackChange", default: true) static let showSneakPeekOnTrackChange = Key<Bool>("showSneakPeekOnTrackChange", default: true)
static let enableFullscreenMediaDetection = Key<Bool>("enableFullscreenMediaDetection", default: true) static let enableFullscreenMediaDetection = Key<Bool>("enableFullscreenMediaDetection", default: true)
static let enableParallaxEffect = Key<Bool>("enableParallaxEffect", default: true) static let parallaxEffectIntensity = Key<Double>("parallaxEffectIntensity", default: 6.0)
static let waitInterval = Key<Double>("waitInterval", default: 3) static let waitInterval = Key<Double>("waitInterval", default: 3)
static let showShuffleAndRepeat = Key<Bool>("showShuffleAndRepeat", default: true) static let showShuffleAndRepeat = Key<Bool>("showShuffleAndRepeat", default: true)
static let showMediaOutputControl = Key<Bool>("showMediaOutputControl", default: true) static let showMediaOutputControl = Key<Bool>("showMediaOutputControl", default: true)