Merge main into PR #439

This commit is contained in:
Hariharan Mudaliar 2026-05-20 13:19:46 +05:30
commit 2b43513db0
No known key found for this signature in database
GPG key ID: 025583EB0BE5640E
37 changed files with 12872 additions and 574 deletions

View file

@ -21,7 +21,7 @@ import Defaults
/// A view that displays the battery status with an icon and charging indicator.
struct BatteryView: View {
@Default(.showPowerStatusIcons) var showPowerStatusIcons
var levelBattery: Float
var isPluggedIn: Bool
var isCharging: Bool
@ -79,7 +79,7 @@ struct BatteryView: View {
)
.padding(.leading, 2)
if iconStatus != "" && (isForNotification || Defaults[.showPowerStatusIcons]) {
if iconStatus != "" && (isForNotification || showPowerStatusIcons) {
ZStack {
Image(iconStatus)
.resizable()
@ -182,6 +182,7 @@ struct BatteryMenuView: View {
/// A view that displays the battery status and allows interaction to show detailed information.
struct DynamicIslandBatteryView: View {
@Default(.showBatteryPercentage) var showBatteryPercentage
@State var batteryWidth: CGFloat = 26
var isCharging: Bool = false
var isInLowPowerMode: Bool = false
@ -199,7 +200,7 @@ struct DynamicIslandBatteryView: View {
var body: some View {
HStack {
if Defaults[.showBatteryPercentage] {
if showBatteryPercentage {
ZStack(alignment: .trailing) {
Text("100%")
.font(.callout)
@ -268,6 +269,443 @@ struct DynamicIslandBatteryView: View {
}
}
private struct BatteryTemporaryHUDMetrics {
let width: CGFloat
let height: CGFloat
let topRadius: CGFloat
let bottomRadius: CGFloat
}
private extension BatteryTemporaryHUDKind {
func metrics(
style: BatteryNotificationStyle,
closedNotchWidth: CGFloat,
baseHeight: CGFloat
) -> BatteryTemporaryHUDMetrics {
let compactBaseRadius = max(baseHeight / 2, 16)
let compactTopRadius = max(12, compactBaseRadius - 4)
switch (self, style) {
case (.charging, _), (.lowBattery, .compact), (.fullBattery, .compact):
return BatteryTemporaryHUDMetrics(
width: closedNotchWidth + 180,
height: baseHeight,
topRadius: compactTopRadius,
bottomRadius: compactBaseRadius
)
case (.lowBattery, .standard):
return BatteryTemporaryHUDMetrics(
width: closedNotchWidth + 150,
height: baseHeight + 75,
topRadius: 22,
bottomRadius: 40
)
case (.fullBattery, .standard):
return BatteryTemporaryHUDMetrics(
width: closedNotchWidth + 140,
height: baseHeight + 70,
topRadius: 18,
bottomRadius: 36
)
}
}
}
private struct BatteryCompactStatusRow: View {
let title: String
let batteryLevel: Int
let tint: Color
var body: some View {
HStack {
Text(verbatim: title)
.font(.system(size: 14))
.foregroundColor(.white.opacity(0.8))
Spacer()
HStack(spacing: 6) {
Text("\(batteryLevel)%")
.font(.system(size: 14))
.foregroundColor(tint)
HStack(spacing: 1.5) {
ZStack(alignment: .leading) {
RoundedRectangle(cornerRadius: 6, style: .continuous)
.fill(tint.opacity(0.3))
GeometryReader { geo in
let clamped = max(0, min(batteryLevel, 100))
let width = CGFloat(clamped) / 100 * geo.size.width
Rectangle()
.fill(tint.gradient)
.frame(width: max(0, width))
}
}
.frame(width: 28, height: 16)
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
RoundedRectangle(cornerRadius: 1.5, style: .continuous)
.fill(batteryLevel == 100 ? tint.gradient : tint.opacity(0.3).gradient)
.frame(width: 2, height: 6)
}
}
}
.padding(.horizontal, 16)
}
}
struct BatteryTemporaryActivityView: View {
let kind: BatteryTemporaryHUDKind
let batteryLevel: Int
let isLowPowerMode: Bool
let closedNotchWidth: CGFloat
let baseHeight: CGFloat
let isDynamicIslandMode: Bool
let topCornerRadius: CGFloat
@Default(.lowBatteryHUDStyle) var lowBatteryHUDStyle
@Default(.fullBatteryHUDStyle) var fullBatteryHUDStyle
var styleOverride: BatteryNotificationStyle? = nil
@State private var pulse = false
@State private var showBatteryIndicator = false
@State private var changeBatteryIndicator = true
private var style: BatteryNotificationStyle {
if kind == .charging {
return .compact
}
if let styleOverride {
return styleOverride
}
switch kind {
case .charging:
return .compact
case .lowBattery:
return lowBatteryHUDStyle
case .fullBattery:
return fullBatteryHUDStyle
}
}
private var metrics: BatteryTemporaryHUDMetrics {
kind.metrics(
style: style,
closedNotchWidth: closedNotchWidth,
baseHeight: baseHeight
)
}
private var batteryTint: Color {
switch kind {
case .charging:
if isLowPowerMode {
return .yellow
} else if batteryLevel <= 20 {
return .red
}
return .green
case .lowBattery:
return isLowPowerMode ? .yellow : .red
case .fullBattery:
return isLowPowerMode ? .yellow : .green
}
}
private var surfaceShape: AnyShape {
if isDynamicIslandMode {
return AnyShape(DynamicIslandPillShape(cornerRadius: dynamicIslandPillCornerRadiusInsets.opened))
} else {
return AnyShape(NotchShape(topCornerRadius: topCornerRadius, bottomCornerRadius: metrics.bottomRadius))
}
}
var body: some View {
ZStack(alignment: .bottom) {
content
}
.frame(width: metrics.width, height: metrics.height, alignment: .bottom)
.clipShape(surfaceShape)
.onAppear(perform: prepareAnimations)
}
@ViewBuilder
private var content: some View {
if style == .compact {
BatteryCompactStatusRow(
title: compactTitle,
batteryLevel: batteryLevel,
tint: batteryTint
)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
} else {
VStack {
Spacer()
HStack {
VStack(alignment: .leading, spacing: kind == .lowBattery ? 2 : 3) {
standardTitle
standardDescription
}
Spacer()
standardIndicator
}
.padding(.leading, kind == .lowBattery ? 40 : 35)
.padding(.trailing, kind == .lowBattery ? 45 : 40)
.padding(.bottom, 20)
}
}
}
private var compactTitle: String {
switch kind {
case .charging:
return "Charging"
case .lowBattery:
return "Low Battery"
case .fullBattery:
return "Full Battery"
}
}
@ViewBuilder
private var standardTitle: some View {
HStack(spacing: 5) {
Text(verbatim: kind == .lowBattery ? "Battery Low" : "Full Battery")
.font(.system(size: kind == .lowBattery ? 13 : 13, weight: .semibold))
.foregroundStyle(.white.opacity(0.82))
.lineLimit(1)
Text("\(batteryLevel)%")
.font(.system(size: kind == .lowBattery ? 12 : 13, weight: .semibold))
.foregroundStyle(batteryTint)
}
}
@ViewBuilder
private var standardDescription: some View {
switch kind {
case .charging:
EmptyView()
case .lowBattery:
if isLowPowerMode {
(
Text(verbatim: "Low Power Mode enabled")
.foregroundColor(.yellow)
.font(.system(size: 10, weight: .medium))
+
Text(verbatim: ", it is recommended to charge it.")
.foregroundColor(.gray.opacity(0.6))
.font(.system(size: 10, weight: .medium))
)
} else {
Text(verbatim: "Turn on Low Power Mode or it\nis recommended to charge it.")
.font(.system(size: 10, weight: .medium))
.foregroundStyle(.gray.opacity(0.6))
.lineLimit(2)
}
case .fullBattery:
Text(verbatim: "Your Mac is fully charged.")
.font(.system(size: 10))
.foregroundStyle(.gray.opacity(0.6))
.fontWeight(.medium)
.lineLimit(1)
}
}
@ViewBuilder
private var standardIndicator: some View {
switch kind {
case .charging:
EmptyView()
case .lowBattery:
if isLowPowerMode {
yellowLowIndicator
} else {
redLowIndicator
}
case .fullBattery:
if showBatteryIndicator {
if isLowPowerMode {
yellowFullIndicator
.transition(.opacity.combined(with: .scale))
} else {
greenFullIndicator
.transition(.opacity.combined(with: .scale))
}
} else {
magSafeIndicator
.transition(.opacity.combined(with: .scale))
}
}
}
private var redLowIndicator: some View {
ZStack {
RoundedRectangle(cornerRadius: 30)
.fill(.red.opacity(0.2))
.frame(width: 70, height: 40)
HStack(spacing: 2) {
RoundedRectangle(cornerRadius: 10)
.fill(.red.opacity(0.4))
.frame(width: 40, height: 24)
RoundedRectangle(cornerRadius: 10)
.fill(.red.opacity(0.4))
.frame(width: 3, height: 8)
}
.padding(.trailing, 5)
RoundedRectangle(cornerRadius: 8)
.fill(Color.red.gradient)
.frame(width: 8, height: 14)
.opacity(pulse ? 1 : 0.3)
.offset(x: -15)
RoundedRectangle(cornerRadius: 30)
.stroke(Color.red.opacity(0.9), lineWidth: 1.5)
.frame(width: pulse ? 8 : 30, height: pulse ? 14 : 32)
.offset(x: -15)
.opacity(pulse ? 0.3 : 1)
}
}
private var yellowLowIndicator: some View {
ZStack {
RoundedRectangle(cornerRadius: 30)
.fill(.yellow.opacity(0.2))
.frame(width: 70, height: 40)
HStack(spacing: 2) {
RoundedRectangle(cornerRadius: 10)
.fill(.yellow.opacity(0.4))
.frame(width: 40, height: 24)
RoundedRectangle(cornerRadius: 10)
.fill(.yellow.opacity(0.4))
.frame(width: 3, height: 8)
}
.padding(.trailing, 5)
RoundedRectangle(cornerRadius: 8)
.fill(.yellow.gradient)
.frame(width: 8, height: 14)
.offset(x: -15)
}
}
private var greenFullIndicator: some View {
ZStack {
RoundedRectangle(cornerRadius: 30)
.fill(.green.opacity(0.2))
.frame(width: 70, height: 40)
HStack(spacing: 2) {
RoundedRectangle(cornerRadius: 10)
.fill(.green.opacity(0.4))
.frame(width: 44, height: 24)
.overlay(
RoundedRectangle(cornerRadius: 4)
.fill(Color.green.gradient)
.frame(width: 34, height: 14)
.opacity(pulse ? 1 : 0.4)
)
RoundedRectangle(cornerRadius: 10)
.fill(.green.opacity(0.4))
.frame(width: 3, height: 8)
}
}
}
private var yellowFullIndicator: some View {
ZStack {
RoundedRectangle(cornerRadius: 30)
.fill(.yellow.opacity(0.2))
.frame(width: 70, height: 40)
HStack(spacing: 2) {
RoundedRectangle(cornerRadius: 10)
.fill(.yellow.opacity(0.4))
.frame(width: 44, height: 24)
.overlay(
RoundedRectangle(cornerRadius: 4)
.fill(Color.yellow.gradient)
.frame(width: 34, height: 14)
.opacity(pulse ? 1 : 0.4)
)
RoundedRectangle(cornerRadius: 10)
.fill(.yellow.opacity(0.4))
.frame(width: 3, height: 8)
}
}
}
private var magSafeIndicator: some View {
HStack(spacing: 0) {
Rectangle()
.fill(.gray.opacity(0.15))
.frame(width: 30, height: 5)
ZStack {
RoundedRectangle(cornerRadius: 2)
.fill(.gray.opacity(0.2).gradient)
.frame(width: 30, height: 40)
Circle()
.fill(changeBatteryIndicator ? .orange : .green)
.shadow(color: changeBatteryIndicator ? .orange : .green, radius: 5)
.frame(width: 5, height: 5)
}
Rectangle()
.fill(.white.opacity(0.4))
.frame(width: 3, height: 32)
}
}
private func prepareAnimations() {
pulse = false
showBatteryIndicator = kind == .fullBattery && style == .standard
changeBatteryIndicator = true
guard style == .standard else { return }
switch kind {
case .charging:
break
case .lowBattery:
if !isLowPowerMode {
withAnimation(.easeInOut(duration: 1).repeatForever(autoreverses: true)) {
pulse = true
}
}
case .fullBattery:
withAnimation(.easeInOut(duration: 1).repeatForever(autoreverses: true)) {
pulse = true
}
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
withAnimation(.spring(duration: 0.4)) {
showBatteryIndicator = false
}
}
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
withAnimation(.spring(duration: 0.2)) {
changeBatteryIndicator = false
}
}
}
}
}
#Preview {
DynamicIslandBatteryView(
batteryWidth: 30,

View file

@ -36,6 +36,7 @@ struct LockScreenMusicPanel: View {
@ObservedObject var musicManager = MusicManager.shared
@ObservedObject private var routeManager = AudioRouteManager.shared
@ObservedObject private var fullscreenArtworkManager = FullScreenArtworkWindowManager.shared
@StateObject private var volumeModel = MediaOutputVolumeViewModel()
@ObservedObject private var airPlayManager = AppleMusicAirPlayManager.shared
@ObservedObject private var animator: LockScreenPanelAnimator
@ -46,6 +47,7 @@ struct LockScreenMusicPanel: View {
@State private var isExpanded = false
@State private var isVolumeSliderVisible = false
@State private var isAirPlayPopoverPresented = false
@State private var isArtworkFullscreen = false
@State private var collapseWorkItem: DispatchWorkItem?
@State private var parallaxResumeWorkItem: DispatchWorkItem?
@ -66,6 +68,9 @@ struct LockScreenMusicPanel: View {
@Default(.enableLyrics) private var enableLyrics
@Default(.lockScreenMusicAlbumParallaxEnabled) private var lockScreenParallaxEnabled
@Default(.lockScreenMusicPanelWidth) private var collapsedPanelWidth
@Default(.lockScreenMusicFullscreenArtworkEnabled) private var fullscreenArtworkEnabled
@Default(.lockScreenKeepAlbumArtVisibleDuringFullscreenArtwork) private var keepAlbumArtVisibleDuringFullscreenArtwork
@Default(.lockScreenMusicFullscreenVideoArtwork) private var fullscreenVideoArtwork
init(animator: LockScreenPanelAnimator) {
_animator = ObservedObject(wrappedValue: animator)
@ -118,6 +123,22 @@ struct LockScreenMusicPanel: View {
private var usesEnhancedCustomLiquidBorder: Bool {
usesCustomLiquidGlass && useEnhancedLiquidBorder
}
private var hidesInlineArtworkForSpotifyCanvasFallback: Bool {
fullscreenArtworkManager.isShowingSpotifyCanvasFallback
}
private var usesSpotifyCanvasFallbackContentPresentation: Bool {
fullscreenArtworkManager.isShowingSpotifyCanvasFallback
}
private var showsDetachedFullscreenLyrics: Bool {
usesSpotifyCanvasFallbackContentPresentation && enableLyrics
}
private var shouldShowInlineLyrics: Bool {
enableLyrics && !showsDetachedFullscreenLyrics
}
var body: some View {
if isActive && musicManager.hasActiveSession {
@ -132,16 +153,27 @@ struct LockScreenMusicPanel: View {
ZStack(alignment: .topLeading) {
panelBackgroundLayer
panelForeground
.shadow(
color: usesSpotifyCanvasFallbackContentPresentation ? Color.black.opacity(0.55) : .clear,
radius: usesSpotifyCanvasFallbackContentPresentation ? 10 : 0,
x: 0,
y: usesSpotifyCanvasFallbackContentPresentation ? 2 : 0
)
}
.frame(width: currentSize.width, height: currentSize.height, alignment: .topLeading)
.clipShape(RoundedRectangle(cornerRadius: panelCornerRadius, style: .continuous))
.overlay {
if showPanelBorder {
if showPanelBorder && !usesSpotifyCanvasFallbackContentPresentation {
panelBorderOverlay
}
}
.shadow(color: Color.black.opacity(0.3), radius: 20, x: 0, y: 10)
.contentShape(RoundedRectangle(cornerRadius: panelCornerRadius, style: .continuous))
.shadow(
color: usesSpotifyCanvasFallbackContentPresentation ? Color.black.opacity(0.35) : Color.black.opacity(0.3),
radius: usesSpotifyCanvasFallbackContentPresentation ? 26 : 20,
x: 0,
y: usesSpotifyCanvasFallbackContentPresentation ? 14 : 10
)
.contentShape(Rectangle())
.animation(.easeInOut(duration: 0.28), value: isExpanded)
.animation(.easeInOut(duration: 0.24), value: shouldShowVolumeSlider)
.onAppear {
@ -163,6 +195,11 @@ struct LockScreenMusicPanel: View {
parallaxResumeWorkItem = nil
isParallaxSuspended = false
}
.onReceive(NotificationCenter.default.publisher(for: .atollArtworkWallpaperDismissed)) { _ in
withAnimation(.easeInOut(duration: 0.28)) {
isArtworkFullscreen = false
}
}
.onChange(of: isExpanded) { _, expanded in
updatePanelSize()
}
@ -222,9 +259,13 @@ struct LockScreenMusicPanel: View {
collapsedLayout
}
}
.padding(.horizontal, isExpanded ? 24 : 20)
.padding(.vertical, isExpanded ? 22 : 16)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.padding(.horizontal, usesSpotifyCanvasFallbackContentPresentation ? (isExpanded ? 24 : 22) : (isExpanded ? 24 : 20))
.padding(.vertical, usesSpotifyCanvasFallbackContentPresentation ? (isExpanded ? 18 : 14) : (isExpanded ? 22 : 16))
.frame(
maxWidth: .infinity,
maxHeight: .infinity,
alignment: usesSpotifyCanvasFallbackContentPresentation ? .center : .topLeading
)
}
private var collapsedLayout: some View {
@ -239,25 +280,40 @@ struct LockScreenMusicPanel: View {
}
private var expandedLayout: some View {
HStack(alignment: .center, spacing: expandedContentSpacing) {
albumArtButton(size: 230, cornerRadius: expandedAlbumArtCornerRadius)
.frame(width: 230, height: 230)
Group {
if hidesInlineArtworkForSpotifyCanvasFallback {
VStack(alignment: .leading, spacing: 20) {
expandedHeader
progressBar
.padding(.top, 10)
.frame(maxWidth: .infinity)
playbackControls(alignment: .leading)
}
.frame(maxWidth: .infinity, alignment: .leading)
} else {
HStack(alignment: .center, spacing: expandedContentSpacing) {
albumArtButton(size: 230, cornerRadius: expandedAlbumArtCornerRadius)
.frame(width: 230, height: 230)
VStack(alignment: .leading, spacing: 20) {
expandedHeader
progressBar
.padding(.top, 10)
.frame(maxWidth: .infinity)
playbackControls(alignment: .leading)
VStack(alignment: .leading, spacing: 20) {
expandedHeader
progressBar
.padding(.top, 10)
.frame(maxWidth: .infinity)
playbackControls(alignment: .leading)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
}
.frame(maxHeight: .infinity, alignment: .center)
}
private var collapsedHeader: some View {
HStack(alignment: .center, spacing: 16) {
albumArtButton(size: 60, cornerRadius: collapsedAlbumArtCornerRadius)
HStack(alignment: .center, spacing: hidesInlineArtworkForSpotifyCanvasFallback ? 10 : 16) {
if !hidesInlineArtworkForSpotifyCanvasFallback {
albumArtButton(size: 60, cornerRadius: collapsedAlbumArtCornerRadius)
}
GeometryReader { geo in
VStack(alignment: .leading, spacing: 1) {
@ -329,30 +385,48 @@ struct LockScreenMusicPanel: View {
}
private func albumArtButton(size: CGFloat, cornerRadius: CGFloat) -> some View {
Button(action: toggleExpanded) {
ZStack(alignment: .bottomTrailing) {
albumArtImage(size: size, cornerRadius: cornerRadius)
if showAppIcon, let icon = lockScreenAppIcon {
icon
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: appIconSize, height: appIconSize)
let artworkCornerRadius = resolvedArtworkCornerRadius(from: cornerRadius)
.shadow(color: Color.black.opacity(0.35), radius: 6, x: 0, y: 4)
.offset(x: appIconOffset, y: appIconOffset)
.transition(.scale.combined(with: .opacity))
}
return ZStack(alignment: .bottomTrailing) {
if isArtworkFullscreen && !keepAlbumArtVisibleDuringFullscreenArtwork {
RoundedRectangle(cornerRadius: artworkCornerRadius, style: .continuous)
.fill(Color.white.opacity(0.06))
.overlay(
Image(systemName: "photo.fill")
.font(.system(size: size * 0.3, weight: .light))
.foregroundColor(.white.opacity(0.2))
)
} else {
albumArtImage(size: size, cornerRadius: cornerRadius)
if showAppIcon, let icon = lockScreenAppIcon {
icon
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: appIconSize, height: appIconSize)
.shadow(color: Color.black.opacity(0.35), radius: 6, x: 0, y: 4)
.offset(x: appIconOffset, y: appIconOffset)
.transition(.scale.combined(with: .opacity))
}
.albumArtFlip(angle: musicManager.flipAngle)
.parallax3D(enableOverride: lockScreenParallaxEnabled, suspended: isParallaxSuspended)
.frame(width: size)
.background(albumArtBackground(cornerRadius: cornerRadius))
.clipShape(RoundedRectangle(cornerRadius: musicManager.albumArt.size.width/musicManager.albumArt.size.height > 1.0 ? appIconCornerRadius/3 : appIconCornerRadius, style: .continuous))
}
}
.buttonStyle(PlainButtonStyle())
.albumArtFlip(angle: isArtworkFullscreen && !keepAlbumArtVisibleDuringFullscreenArtwork ? 0 : musicManager.flipAngle)
.parallax3D(
enableOverride: lockScreenParallaxEnabled && (!isArtworkFullscreen || keepAlbumArtVisibleDuringFullscreenArtwork),
suspended: isParallaxSuspended
)
.frame(width: size)
.background(albumArtBackground(cornerRadius: artworkCornerRadius))
.clipShape(RoundedRectangle(cornerRadius: artworkCornerRadius, style: .continuous))
.opacity(musicManager.isPlaying ? 1 : 0.4)
.scaleEffect(musicManager.isPlaying ? 1 : 0.85)
.animation(.easeInOut(duration: 0.2), value: musicManager.isPlaying)
.animation(.easeInOut(duration: 0.28), value: isArtworkFullscreen)
.onTapGesture {
toggleExpanded()
}
.onRightClick {
expandArtworkToFullscreen()
}
}
@ViewBuilder
@ -384,6 +458,41 @@ struct LockScreenMusicPanel: View {
}
}
private func expandArtworkToFullscreen() {
guard fullscreenArtworkEnabled else { return }
if FullScreenArtworkWindowManager.shared.isShowing {
FullScreenArtworkWindowManager.shared.hide()
withAnimation(.easeInOut(duration: 0.28)) {
isArtworkFullscreen = false
}
return
}
guard musicManager.hasActiveSession else { return }
let artwork = musicManager.albumArt
let videoURL = musicManager.videoArtworkURL
withAnimation(.easeInOut(duration: 0.28)) {
isArtworkFullscreen = true
}
FullScreenArtworkWindowManager.shared.onDismiss = {
Task { @MainActor in
withAnimation(.easeInOut(duration: 0.28)) {
NotificationCenter.default.post(name: .atollArtworkWallpaperDismissed, object: nil)
}
}
}
FullScreenArtworkWindowManager.shared.show(
artwork: artwork,
videoURL: fullscreenVideoArtwork ? videoURL : nil,
allowLiveWallpaper: fullscreenVideoArtwork
)
}
private func registerInteraction() {
cancelCollapseTimer()
guard isExpanded else { return }
@ -484,7 +593,7 @@ struct LockScreenMusicPanel: View {
private func playbackControls(alignment: Alignment) -> some View {
let spacing: CGFloat = isExpanded ? 24 : 20
let verticalSpacing: CGFloat = (shouldShowVolumeSlider || enableLyrics) ? 14 : 10
let verticalSpacing: CGFloat = (shouldShowVolumeSlider || shouldShowInlineLyrics) ? 14 : 10
return VStack(spacing: verticalSpacing) {
controlsRow(alignment: alignment, spacing: spacing)
@ -505,7 +614,7 @@ struct LockScreenMusicPanel: View {
}
}
if enableLyrics {
if shouldShowInlineLyrics {
lyricsSection(alignment: alignment)
.transition(.move(edge: .top).combined(with: .opacity))
}
@ -949,7 +1058,7 @@ struct LockScreenMusicPanel: View {
}
private var lyricsExtraHeight: CGFloat {
lyricsHeight(forExpanded: isExpanded, enabled: enableLyrics)
lyricsHeight(forExpanded: isExpanded, enabled: shouldShowInlineLyrics)
}
private var accessorySectionExtraHeight: CGFloat {
@ -979,7 +1088,7 @@ struct LockScreenMusicPanel: View {
private func panelAdditionalHeight(forExpanded expanded: Bool) -> CGFloat {
sliderHeight(forExpanded: expanded, visible: shouldShowVolumeSlider) +
accessorySectionExtraHeight +
lyricsHeight(forExpanded: expanded, enabled: enableLyrics)
lyricsHeight(forExpanded: expanded, enabled: shouldShowInlineLyrics)
}
private func updatePanelSize(animated: Bool = true) {
@ -1034,7 +1143,9 @@ struct LockScreenMusicPanel: View {
@ViewBuilder
private var panelBackgroundLayer: some View {
if usesCustomLiquidGlass {
if usesSpotifyCanvasFallbackContentPresentation {
canvasFallbackScrim
} else if usesCustomLiquidGlass {
customLiquidPanelBackdrop
} else if usesStandardLiquidGlass {
standardLiquidPanelBackdrop
@ -1045,6 +1156,31 @@ struct LockScreenMusicPanel: View {
}
}
private var canvasFallbackScrim: some View {
RoundedRectangle(cornerRadius: panelCornerRadius, style: .continuous)
.fill(.ultraThinMaterial)
.environment(\.colorScheme, .dark)
.overlay {
LinearGradient(
colors: [
Color.black.opacity(0.32),
Color.black.opacity(0.18),
Color.black.opacity(0.32)
],
startPoint: .top,
endPoint: .bottom
)
.clipShape(RoundedRectangle(cornerRadius: panelCornerRadius, style: .continuous))
}
.overlay {
RoundedRectangle(cornerRadius: panelCornerRadius, style: .continuous)
.stroke(Color.white.opacity(0.10), lineWidth: 0.6)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.allowsHitTesting(false)
.accessibilityHidden(true)
}
@ViewBuilder
private var standardLiquidPanelBackdrop: some View {
if #available(macOS 26.0, *) {
@ -1132,7 +1268,8 @@ struct LockScreenMusicPanel: View {
Image(nsImage: musicManager.albumArt)
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(RoundedRectangle(cornerRadius: musicManager.albumArt.size.width/musicManager.albumArt.size.height > 1.0 ? cornerRadius/3 : cornerRadius))
.compositingGroup()
.clipShape(RoundedRectangle(cornerRadius: resolvedArtworkCornerRadius(from: cornerRadius), style: .continuous))
}
@ViewBuilder
@ -1170,6 +1307,13 @@ struct LockScreenMusicPanel: View {
isExpanded ? 18 : 12
}
private func resolvedArtworkCornerRadius(from baseCornerRadius: CGFloat) -> CGFloat {
let aspectRatio = musicManager.albumArt.size.height > 0
? musicManager.albumArt.size.width / musicManager.albumArt.size.height
: 1
return aspectRatio > 1.0 ? baseCornerRadius / 3 : baseCornerRadius
}
@available(macOS 26.0, *)
private func clearLiquidGlassSurface(cornerRadius: CGFloat) -> some View {
RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
@ -1384,3 +1528,87 @@ private struct GlassTextBackdrop: View {
.accessibilityHidden(true)
}
}
// MARK: - Right Click Gesture
private struct RightClickOverlay: ViewModifier {
let action: () -> Void
func body(content: Content) -> some View {
content.overlay(
RightClickReceiverView(action: action)
.frame(maxWidth: .infinity, maxHeight: .infinity)
)
}
}
private struct RightClickReceiverView: NSViewRepresentable {
let action: () -> Void
func makeNSView(context: Context) -> RightClickNSView {
let view = RightClickNSView()
view.onRightClick = action
return view
}
func updateNSView(_ nsView: RightClickNSView, context: Context) {
nsView.onRightClick = action
}
}
private extension View {
func onRightClick(perform action: @escaping () -> Void) -> some View {
modifier(RightClickOverlay(action: action))
}
}
final class RightClickNSView: NSView {
var onRightClick: (() -> Void)?
private var eventMonitor: Any?
deinit {
removeEventMonitor()
}
override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
if window == nil {
removeEventMonitor()
} else {
installEventMonitorIfNeeded()
}
}
override func hitTest(_ point: NSPoint) -> NSView? {
nil
}
private func installEventMonitorIfNeeded() {
guard eventMonitor == nil else { return }
eventMonitor = NSEvent.addLocalMonitorForEvents(matching: [.rightMouseDown]) { [weak self] event in
guard let self, let window = self.window, event.window === window else {
return event
}
let pointInView = self.convert(event.locationInWindow, from: nil)
guard self.bounds.contains(pointInView) else {
return event
}
self.onRightClick?()
return nil
}
}
private func removeEventMonitor() {
guard let eventMonitor else { return }
NSEvent.removeMonitor(eventMonitor)
self.eventMonitor = nil
}
}
extension Notification.Name {
static let atollArtworkWallpaperDismissed = Notification.Name("atollArtworkWallpaperDismissed")
}

View file

@ -45,10 +45,6 @@ struct LockScreenTimerWidget: View {
}
}
private func displayFont(size: CGFloat) -> Font {
.system(size: size, weight: .semibold, design: .rounded)
}
private var hasHoursComponent: Bool {
abs(timerManager.remainingTime) >= 3600
}
@ -57,12 +53,6 @@ struct LockScreenTimerWidget: View {
abs(timerManager.remainingTime) >= 36_000 // 10 hours or more
}
private var titleFrameWidth: CGFloat {
if hasDoubleDigitHours { return 60 }
if hasHoursComponent { return 80 }
return 110
}
private var countdownFrameWidth: CGFloat {
if hasDoubleDigitHours { return 200 }
if hasHoursComponent { return 185 }
@ -74,10 +64,6 @@ struct LockScreenTimerWidget: View {
return .system(size: baseSize, weight: .bold, design: .rounded)
}
private var timerLabel: String {
timerManager.timerName.isEmpty ? "Timer" : timerManager.timerName
}
private var countdownText: String {
timerManager.formattedRemainingTime()
}
@ -195,8 +181,7 @@ struct LockScreenTimerWidget: View {
controlButtons
.padding(.trailing, 12)
titleSection
.frame(maxWidth: .infinity)
Spacer()
countdownSection
.padding(.leading, 12)
@ -261,19 +246,6 @@ struct LockScreenTimerWidget: View {
.layoutPriority(2)
}
private var titleSection: some View {
MarqueeText(
.constant(timerLabel),
font: displayFont(size: 15),
nsFont: .title3,
textColor: accentColor,
minDuration: 0.16,
frameWidth: titleFrameWidth
)
.frame(maxWidth: .infinity, alignment: .center)
.layoutPriority(0)
}
private var accentRibbon: some View {
Capsule()
.fill(accentGradient)

View file

@ -1261,7 +1261,15 @@ struct LockScreenWeatherWidget: View {
private func chargingStatusFallback(for info: LockScreenWeatherSnapshot.ChargingInfo) -> String {
if info.isPluggedIn && !info.isCharging {
return NSLocalizedString("Fully charged", comment: "Charging fallback label when already charged")
let level = info.batteryLevel.map(clampedBatteryLevel)
if level == 100 {
return NSLocalizedString("Fully charged", comment: "Charging fallback label when already charged")
}
if let level {
let onHold = NSLocalizedString("On hold", comment: "Plugged in but charging is paused by the system")
return "\(level)% • \(onHold)"
}
return NSLocalizedString("On hold", comment: "Plugged in but charging is paused by the system")
}
return NSLocalizedString("Charging", comment: "Charging fallback label when no estimate is available")
}
@ -1456,7 +1464,17 @@ struct LockScreenWeatherWidget: View {
}
if charging.isPluggedIn && !charging.isCharging {
return NSLocalizedString("Battery fully charged", comment: "Battery is full")
let level = charging.batteryLevel.map(clampedBatteryLevel)
if level == 100 {
return NSLocalizedString("Battery fully charged", comment: "Battery is full")
}
if let level {
return String(
format: NSLocalizedString("Battery at %d percent, charging on hold", comment: "Plugged in but charging is paused by the system"),
level
)
}
return NSLocalizedString("Charging on hold", comment: "Plugged in but charging is paused by the system")
}
if snapshot.showsChargingPercentage, let level = charging.batteryLevel {

View file

@ -36,10 +36,12 @@ struct DynamicIslandHeader: View {
@Default(.showClipboardIcon) var showClipboardIcon
@Default(.showColorPickerIcon) var showColorPickerIcon
@Default(.clipboardDisplayMode) var clipboardDisplayMode
@Default(.showBatteryIndicator) var showBatteryIndicator
@Default(.enableMinimalisticUI) var enableMinimalisticUI
var body: some View {
HStack(spacing: 0) {
if !Defaults[.enableMinimalisticUI] {
if !enableMinimalisticUI {
HStack {
let shouldShowTabs = coordinator.alwaysShowTabs || vm.notchState == .open || !shelfState.items.isEmpty
if shouldShowTabs {
@ -55,7 +57,7 @@ struct DynamicIslandHeader: View {
}
if vm.notchState == .open && !Defaults[.enableMinimalisticUI] {
if vm.notchState == .open && !enableMinimalisticUI {
let spacerWidth = min(vm.closedNotchSize.width, 300)
Rectangle()
.fill(NSScreen.screens
@ -67,7 +69,7 @@ struct DynamicIslandHeader: View {
}
HStack(spacing: 4) {
if vm.notchState == .open && !Defaults[.enableMinimalisticUI] {
if vm.notchState == .open && !enableMinimalisticUI {
if Defaults[.showMirror] {
Button(action: {
vm.toggleCameraPreview()
@ -230,7 +232,7 @@ struct DynamicIslandHeader: View {
if Defaults[.showBatteryIndicator] {
if showBatteryIndicator {
DynamicIslandBatteryView(
batteryWidth: 30,
isCharging: batteryModel.isCharging,

View file

@ -113,6 +113,7 @@ struct MinimalisticMusicPlayerView: View {
// Compact progress bar
progressBar
.padding(.top, 6)
.clipped()
// Compact playback controls
if shouldShowControlHUDRow {
@ -133,7 +134,7 @@ struct MinimalisticMusicPlayerView: View {
reminderList
}
.padding(.horizontal, 12)
.padding(.top, -15)
.padding(.top, 12)
.padding(.bottom, ReminderLiveActivityManager.baselineMinimalisticBottomPadding)
.frame(maxWidth: .infinity)
.frame(height: calculateDynamicHeight(), alignment: .top)
@ -254,7 +255,7 @@ struct MinimalisticMusicPlayerView: View {
height += 6 + 4 // progress bar + top padding
// Add playback controls height
height += 40 + 2 // controls + top padding
height += 54 + 2 // controls + top padding
// Add lyrics height if enabled in settings (reserve space even while loading)
if enableLyrics {
@ -706,7 +707,7 @@ private struct MinimalisticReminderDetailsView: View {
// MARK: - Playback Controls (Larger)
private var playbackControls: some View {
HStack(spacing: 16) {
HStack(spacing: 10) {
ForEach(Array(displayedSlots.enumerated()), id: \.offset) { _, slot in
slotView(for: slot)
}
@ -834,10 +835,10 @@ private struct MinimalisticReminderDetailsView: View {
private var playPauseButton: some View {
MinimalisticSquircircleButton(
icon: musicManager.isPlaying ? (musicManager.isLiveStream ? "stop.fill" : "pause.fill") : "play.fill",
fontSize: 28,
fontSize: 26,
fontWeight: .semibold,
frameSize: CGSize(width: 60, height: 60),
cornerRadius: 24,
frameSize: CGSize(width: 54, height: 54),
cornerRadius: 22,
foregroundColor: .white,
pressEffect: .none,
symbolEffectStyle: .replace,
@ -867,8 +868,8 @@ private struct MinimalisticReminderDetailsView: View {
icon: icon,
fontSize: size,
fontWeight: .medium,
frameSize: CGSize(width: 40, height: 40),
cornerRadius: 16,
frameSize: CGSize(width: 36, height: 36),
cornerRadius: 14,
foregroundColor: isActive ? resolvedActiveColor : .white.opacity(0.85),
pressEffect: pressEffect,
symbolEffectStyle: symbolEffect,
@ -991,8 +992,8 @@ private struct MinimalisticReminderDetailsView: View {
icon: routeManager.activeDevice?.iconName ?? "speaker.wave.2",
fontSize: 18,
fontWeight: .medium,
frameSize: CGSize(width: 40, height: 40),
cornerRadius: 16,
frameSize: CGSize(width: 36, height: 36),
cornerRadius: 14,
foregroundColor: .white.opacity(0.85),
symbolEffectStyle: .replace
) {
@ -1051,8 +1052,8 @@ private struct MinimalisticReminderDetailsView: View {
icon: "airplayaudio",
fontSize: 18,
fontWeight: .medium,
frameSize: CGSize(width: 40, height: 40),
cornerRadius: 16,
frameSize: CGSize(width: 36, height: 36),
cornerRadius: 14,
foregroundColor: .white.opacity(0.85),
symbolEffectStyle: .replace
) {
@ -1113,8 +1114,17 @@ private struct MinimalisticReminderDetailsView: View {
struct MinimalisticAlbumArtView: View {
@ObservedObject var musicManager = MusicManager.shared
@ObservedObject var vm: DynamicIslandViewModel
@Default(.showLiveCanvasInDynamicIsland) private var showLiveCanvasInDynamicIsland
let albumArtNamespace: Namespace.ID
private var usesLiveCanvasArtwork: Bool {
showLiveCanvasInDynamicIsland && musicManager.videoArtworkURL != nil
}
private var albumArtCornerRadius: CGFloat {
musicManager.albumArt.size.width / musicManager.albumArt.size.height > 1.0 ? 4 : 12
}
var body: some View {
ZStack(alignment: .bottomTrailing) {
if Defaults[.lightingEffect] {
@ -1128,16 +1138,27 @@ struct MinimalisticAlbumArtView: View {
Color.clear
.aspectRatio(1, contentMode: .fit)
.background(
Image(nsImage: musicManager.albumArt)
.resizable()
.scaledToFill()
DynamicIslandArtworkSourceView(
cornerRadius: albumArtCornerRadius,
contentMode: .fill
)
)
.clipped()
.clipShape(RoundedRectangle(cornerRadius: 12))
.scaleEffect(x: 1.3, y: 1.4)
.clipShape(RoundedRectangle(cornerRadius: albumArtCornerRadius))
.scaleEffect(x: 1.08, y: 1.1)
.rotationEffect(.degrees(92))
.blur(radius: 35)
.opacity(min(0.6, 1 - max(musicManager.albumArt.getBrightness(), 0.3)))
.blur(radius: 16)
.opacity(
usesLiveCanvasArtwork
? (musicManager.isPlaying ? 0.55 : 0.18)
: min(0.45, 1 - max(musicManager.albumArt.getBrightness(), 0.3))
)
.shadow(
color: Color(nsColor: musicManager.avgColor).opacity(usesLiveCanvasArtwork ? 0.22 : 0.12),
radius: usesLiveCanvasArtwork ? 10 : 7,
x: 0,
y: 0
)
}
private var albumArtButton: some View {
@ -1147,13 +1168,10 @@ struct MinimalisticAlbumArtView: View {
Color.clear
.aspectRatio(1, contentMode: .fit)
.background(
Image(nsImage: musicManager.albumArt)
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(RoundedRectangle(cornerRadius: musicManager.albumArt.size.width/musicManager.albumArt.size.height > 1.0 ? 4 : 12))
DynamicIslandArtworkSourceView(
cornerRadius: albumArtCornerRadius,
contentMode: .fit
)
)
.clipped()
.matchedGeometryEffect(id: "albumArt", in: albumArtNamespace)

View file

@ -23,6 +23,129 @@
import Combine
import Defaults
import SwiftUI
import AppKit
import AVFoundation
private final class DynamicIslandArtworkLoopController {
let player: AVQueuePlayer
private var looper: AVPlayerLooper?
private var playbackStateCancellable: AnyCancellable?
init(url: URL) {
let item = AVPlayerItem(url: url)
player = AVQueuePlayer()
player.isMuted = true
player.actionAtItemEnd = .none
looper = AVPlayerLooper(player: player, templateItem: item)
if MusicManager.shared.isPlaying {
player.play()
}
playbackStateCancellable = MusicManager.shared.$isPlaying
.removeDuplicates()
.receive(on: DispatchQueue.main)
.sink { [weak self] isPlaying in
guard let self else { return }
if isPlaying {
self.player.play()
} else {
self.player.pause()
}
}
}
deinit {
player.pause()
looper = nil
playbackStateCancellable = nil
}
}
private final class DynamicIslandArtworkVideoContainerView: NSView {
let playerLayer = AVPlayerLayer()
override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
wantsLayer = true
layer?.backgroundColor = NSColor.clear.cgColor
playerLayer.videoGravity = .resizeAspectFill
playerLayer.backgroundColor = NSColor.clear.cgColor
layer?.addSublayer(playerLayer)
}
required init?(coder: NSCoder) {
nil
}
override func layout() {
super.layout()
playerLayer.frame = bounds
}
}
private struct DynamicIslandArtworkVideoView: NSViewRepresentable {
let url: URL
let videoGravity: AVLayerVideoGravity
func makeCoordinator() -> Coordinator {
Coordinator()
}
func makeNSView(context: Context) -> DynamicIslandArtworkVideoContainerView {
let view = DynamicIslandArtworkVideoContainerView(frame: .zero)
context.coordinator.attach(layer: view.playerLayer, url: url, gravity: videoGravity)
return view
}
func updateNSView(_ nsView: DynamicIslandArtworkVideoContainerView, context: Context) {
context.coordinator.attach(layer: nsView.playerLayer, url: url, gravity: videoGravity)
}
final class Coordinator {
private var controller: DynamicIslandArtworkLoopController?
private var currentURL: URL?
func attach(layer: AVPlayerLayer, url: URL, gravity: AVLayerVideoGravity) {
layer.videoGravity = gravity
if currentURL != url || controller == nil {
currentURL = url
controller = DynamicIslandArtworkLoopController(url: url)
}
if layer.player !== controller?.player {
layer.player = controller?.player
}
}
}
}
struct DynamicIslandArtworkSourceView: View {
@ObservedObject private var musicManager = MusicManager.shared
@Default(.showLiveCanvasInDynamicIsland) private var showLiveCanvasInDynamicIsland
let cornerRadius: CGFloat
let contentMode: ContentMode
private var liveCanvasURL: URL? {
guard showLiveCanvasInDynamicIsland else { return nil }
return musicManager.videoArtworkURL
}
var body: some View {
Group {
if let liveCanvasURL {
DynamicIslandArtworkVideoView(url: liveCanvasURL, videoGravity: .resizeAspectFill)
} else {
Image(nsImage: musicManager.albumArt)
.resizable()
.aspectRatio(contentMode: contentMode)
}
}
.clipShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))
}
}
// MARK: - Music Player Components
@ -43,8 +166,23 @@ struct MusicPlayerView: View {
struct AlbumArtView: View {
@ObservedObject var musicManager = MusicManager.shared
@ObservedObject var vm: DynamicIslandViewModel
@Default(.showLiveCanvasInDynamicIsland) private var showLiveCanvasInDynamicIsland
let albumArtNamespace: Namespace.ID
private var usesLiveCanvasArtwork: Bool {
showLiveCanvasInDynamicIsland && musicManager.videoArtworkURL != nil
}
private var albumArtCornerRadius: CGFloat {
Defaults[.cornerRadiusScaling]
? musicManager.albumArt.size.width / musicManager.albumArt.size.height > 1.0
? MusicPlayerImageSizes.cornerRadiusInset.opened / 3
: MusicPlayerImageSizes.cornerRadiusInset.opened
: musicManager.albumArt.size.width / musicManager.albumArt.size.height > 1.0
? MusicPlayerImageSizes.cornerRadiusInset.closed / 3
: MusicPlayerImageSizes.cornerRadiusInset.closed
}
var body: some View {
ZStack(alignment: .bottomTrailing) {
if Defaults[.lightingEffect] {
@ -58,24 +196,26 @@ struct AlbumArtView: View {
Color.clear
.aspectRatio(1, contentMode: .fit)
.background(
Image(nsImage: musicManager.albumArt)
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(
RoundedRectangle(
cornerRadius: Defaults[.cornerRadiusScaling]
? musicManager.albumArt.size.width/musicManager.albumArt.size.height > 1.0 ? MusicPlayerImageSizes.cornerRadiusInset.opened/3 : MusicPlayerImageSizes.cornerRadiusInset.opened
: musicManager.albumArt.size.width/musicManager.albumArt.size.height > 1.0 ? MusicPlayerImageSizes.cornerRadiusInset.closed/3 : MusicPlayerImageSizes.cornerRadiusInset.closed
)
)
DynamicIslandArtworkSourceView(
cornerRadius: albumArtCornerRadius,
contentMode: .fill
)
)
.clipped()
.scaleEffect(x: 1.3, y: 1.4)
.rotationEffect(.degrees(92))
.blur(radius: 40)
.opacity(musicManager.isPlaying ? 0.5 : 0)
.opacity(
usesLiveCanvasArtwork
? (musicManager.isPlaying ? 0.62 : 0.18)
: (musicManager.isPlaying ? 0.5 : 0)
)
.shadow(
color: Color(nsColor: musicManager.avgColor).opacity(usesLiveCanvasArtwork ? 0.24 : 0.16),
radius: usesLiveCanvasArtwork ? 22 : 14,
x: 0,
y: 0
)
}
private var albumArtButton: some View {
@ -111,18 +251,10 @@ struct AlbumArtView: View {
Color.clear
.aspectRatio(1, contentMode: .fit)
.overlay {
Image(nsImage: musicManager.albumArt)
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(
RoundedRectangle(
cornerRadius: Defaults[.cornerRadiusScaling]
? musicManager.albumArt.size.width/musicManager.albumArt.size.height > 1.0 ? MusicPlayerImageSizes.cornerRadiusInset.opened/3 : MusicPlayerImageSizes.cornerRadiusInset.opened
: musicManager.albumArt.size.width/musicManager.albumArt.size.height > 1.0 ? MusicPlayerImageSizes.cornerRadiusInset.closed/3 : MusicPlayerImageSizes.cornerRadiusInset.closed
)
) // ensures that even the rectagular album cover is rounded just like the MacOS media player
DynamicIslandArtworkSourceView(
cornerRadius: albumArtCornerRadius,
contentMode: .fit
)
}
.matchedGeometryEffect(id: "albumArt", in: albumArtNamespace)
.clipped()

View file

@ -731,6 +731,19 @@ struct SettingsView: View {
SettingsSearchEntry(tab: .battery, title: "Show power status notifications", keywords: ["notifications", "power"], highlightID: SettingsTab.battery.highlightID(for: "Show power status notifications")),
SettingsSearchEntry(tab: .battery, title: "Show power status icons", keywords: ["power icons", "charging icon"], highlightID: SettingsTab.battery.highlightID(for: "Show power status icons")),
SettingsSearchEntry(tab: .battery, title: "Play low battery alert sound", keywords: ["low battery", "alert", "sound"], highlightID: SettingsTab.battery.highlightID(for: "Play low battery alert sound")),
SettingsSearchEntry(tab: .battery, title: "Charging HUD", keywords: ["battery", "charging", "temporary activity"], highlightID: SettingsTab.battery.highlightID(for: "Charging HUD")),
SettingsSearchEntry(tab: .battery, title: "Low battery HUD", keywords: ["battery", "low", "temporary activity"], highlightID: SettingsTab.battery.highlightID(for: "Low battery HUD")),
SettingsSearchEntry(tab: .battery, title: "Fully charged HUD", keywords: ["battery", "full", "temporary activity"], highlightID: SettingsTab.battery.highlightID(for: "Fully charged HUD")),
SettingsSearchEntry(tab: .battery, title: "Charging duration", keywords: ["charging", "duration", "seconds"], highlightID: SettingsTab.battery.highlightID(for: "Charging duration")),
SettingsSearchEntry(tab: .battery, title: "Low battery duration", keywords: ["low battery", "duration", "seconds"], highlightID: SettingsTab.battery.highlightID(for: "Low battery duration")),
SettingsSearchEntry(tab: .battery, title: "Full battery duration", keywords: ["full battery", "duration", "seconds"], highlightID: SettingsTab.battery.highlightID(for: "Full battery duration")),
SettingsSearchEntry(tab: .battery, title: "Test charging HUD", keywords: ["battery", "test", "charging", "preview"], highlightID: nil),
SettingsSearchEntry(tab: .battery, title: "Test low battery HUD", keywords: ["battery", "test", "low", "preview"], highlightID: nil),
SettingsSearchEntry(tab: .battery, title: "Test full battery HUD", keywords: ["battery", "test", "full", "preview"], highlightID: nil),
SettingsSearchEntry(tab: .battery, title: "Low battery style", keywords: ["battery", "style", "compact", "standard"], highlightID: SettingsTab.battery.highlightID(for: "Low battery style")),
SettingsSearchEntry(tab: .battery, title: "Low battery threshold", keywords: ["battery", "threshold", "percent"], highlightID: SettingsTab.battery.highlightID(for: "Low battery threshold")),
SettingsSearchEntry(tab: .battery, title: "Full battery style", keywords: ["battery", "style", "compact", "standard"], highlightID: SettingsTab.battery.highlightID(for: "Full battery style")),
SettingsSearchEntry(tab: .battery, title: "Full charge threshold", keywords: ["battery", "threshold", "full"], highlightID: SettingsTab.battery.highlightID(for: "Full charge threshold")),
// HUDs
SettingsSearchEntry(tab: .devices, title: "Show Bluetooth device connections", keywords: ["bluetooth", "hud"], highlightID: SettingsTab.devices.highlightID(for: "Show Bluetooth device connections")),
@ -754,6 +767,10 @@ struct SettingsView: View {
SettingsSearchEntry(tab: .hudAndOSD, title: "Keyboard Backlight OSD", keywords: ["keyboard", "backlight", "osd"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Keyboard Backlight OSD")),
SettingsSearchEntry(tab: .hudAndOSD, title: "Material", keywords: ["material", "frosted", "liquid", "glass", "solid", "osd"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Material")),
SettingsSearchEntry(tab: .hudAndOSD, title: "Icon & Progress Color", keywords: ["color", "icon", "white", "black", "gray", "osd"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Icon & Progress Color")),
SettingsSearchEntry(tab: .hudAndOSD, title: "Volume step", keywords: ["volume", "step", "percent"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Volume step")),
SettingsSearchEntry(tab: .hudAndOSD, title: "Volume fine step", keywords: ["volume", "fine", "step", "percent"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Volume fine step")),
SettingsSearchEntry(tab: .hudAndOSD, title: "Brightness step", keywords: ["brightness", "step", "percent"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Brightness step")),
SettingsSearchEntry(tab: .hudAndOSD, title: "Brightness fine step", keywords: ["brightness", "fine", "step", "percent"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Brightness fine step")),
SettingsSearchEntry(tab: .hudAndOSD, title: "Third-party DDC app integration", keywords: ["ddc", "third party", "external", "display", "betterdisplay", "lunar"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Third-party DDC app integration")),
SettingsSearchEntry(tab: .hudAndOSD, title: "Third-party DDC provider", keywords: ["provider", "betterdisplay", "lunar", "integration", "refresh detection"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Third-party DDC provider")),
SettingsSearchEntry(tab: .hudAndOSD, title: "Enable external volume control listener", keywords: ["external volume", "ddc volume", "betterdisplay volume", "lunar volume", "disable native volume"], highlightID: SettingsTab.hudAndOSD.highlightID(for: "Enable external volume control listener")),
@ -763,6 +780,7 @@ struct SettingsView: View {
SettingsSearchEntry(tab: .media, title: "Skip buttons", keywords: ["skip", "controls", "±10"], highlightID: SettingsTab.media.highlightID(for: "Skip buttons")),
SettingsSearchEntry(tab: .media, title: "Sneak Peek Style", keywords: ["sneak peek", "preview"], highlightID: SettingsTab.media.highlightID(for: "Sneak Peek Style")),
SettingsSearchEntry(tab: .media, title: "Enable lyrics", keywords: ["lyrics", "song text"], highlightID: SettingsTab.media.highlightID(for: "Enable lyrics")),
SettingsSearchEntry(tab: .media, title: "Show live canvas in Dynamic Island", keywords: ["canvas", "live canvas", "album art", "dynamic island", "spotify canvas"], highlightID: SettingsTab.media.highlightID(for: "Show live canvas in Dynamic Island")),
SettingsSearchEntry(tab: .media, title: "Auto-hide inactive notch media player", keywords: ["auto hide", "inactive", "placeholder", "notch media"], highlightID: SettingsTab.media.highlightID(for: "Auto-hide inactive notch media player")),
SettingsSearchEntry(tab: .media, title: "Show Change Media Output control", keywords: ["airplay", "route picker", "media output"], highlightID: SettingsTab.media.highlightID(for: "Show Change Media Output control")),
SettingsSearchEntry(tab: .media, title: "Enable album art parallax", keywords: ["parallax", "lock screen", "album art"], highlightID: SettingsTab.media.highlightID(for: "Enable album art parallax")),
@ -1305,10 +1323,62 @@ struct GeneralSettings: View {
}
struct Charge: View {
@ObservedObject private var batteryStatusViewModel = BatteryStatusViewModel.shared
@Default(.showPowerStatusNotifications) private var showPowerStatusNotifications
@Default(.showChargingBatteryHUD) private var showChargingBatteryHUD
@Default(.showLowBatteryHUD) private var showLowBatteryHUD
@Default(.showFullBatteryHUD) private var showFullBatteryHUD
@Default(.chargingBatteryHUDDuration) private var chargingBatteryHUDDuration
@Default(.lowBatteryHUDDuration) private var lowBatteryHUDDuration
@Default(.fullBatteryHUDDuration) private var fullBatteryHUDDuration
@Default(.lowBatteryHUDThreshold) private var lowBatteryHUDThreshold
@Default(.fullBatteryHUDThreshold) private var fullBatteryHUDThreshold
@Default(.lowBatteryHUDStyle) private var lowBatteryHUDStyle
@Default(.fullBatteryHUDStyle) private var fullBatteryHUDStyle
private func highlightID(_ title: String) -> String {
SettingsTab.battery.highlightID(for: title)
}
private var chargingDurationBinding: Binding<Double> {
Binding(
get: { Double(chargingBatteryHUDDuration) },
set: { chargingBatteryHUDDuration = Int($0.rounded()) }
)
}
private var lowBatteryDurationBinding: Binding<Double> {
Binding(
get: { Double(lowBatteryHUDDuration) },
set: { lowBatteryHUDDuration = Int($0.rounded()) }
)
}
private var fullBatteryDurationBinding: Binding<Double> {
Binding(
get: { Double(fullBatteryHUDDuration) },
set: { fullBatteryHUDDuration = Int($0.rounded()) }
)
}
private var lowBatteryThresholdBinding: Binding<Double> {
Binding(
get: { Double(lowBatteryHUDThreshold) },
set: { lowBatteryHUDThreshold = Int($0.rounded()) }
)
}
private var fullBatteryThresholdBinding: Binding<Double> {
Binding(
get: { Double(fullBatteryHUDThreshold) },
set: { fullBatteryHUDThreshold = Int($0.rounded()) }
)
}
private func sectionOpacity(_ isEnabled: Bool) -> Double {
isEnabled ? 1 : 0.5
}
var body: some View {
Form {
if BatteryActivityManager.shared.hasBattery() {
@ -1340,6 +1410,157 @@ struct Charge: View {
} header: {
Text("Battery Information")
}
Section {
Defaults.Toggle(key: .showChargingBatteryHUD) {
Text("Charging HUD")
}
.settingsHighlight(id: highlightID("Charging HUD"))
Defaults.Toggle(key: .showLowBatteryHUD) {
Text("Low battery HUD")
}
.settingsHighlight(id: highlightID("Low battery HUD"))
Defaults.Toggle(key: .showFullBatteryHUD) {
Text("Fully charged HUD")
}
.settingsHighlight(id: highlightID("Fully charged HUD"))
} header: {
Text("Battery HUDs")
} footer: {
Text("These temporary HUDs recreate the charging, low-battery, and full-battery notch alerts.")
}
Section {
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Charging duration")
Spacer()
Text("\(chargingBatteryHUDDuration)s")
.foregroundStyle(.secondary)
}
Slider(value: chargingDurationBinding, in: 1...10, step: 1)
}
.settingsHighlight(id: highlightID("Charging duration"))
.disabled(!showPowerStatusNotifications || !showChargingBatteryHUD)
.opacity(sectionOpacity(showPowerStatusNotifications && showChargingBatteryHUD))
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Low battery duration")
Spacer()
Text("\(lowBatteryHUDDuration)s")
.foregroundStyle(.secondary)
}
Slider(value: lowBatteryDurationBinding, in: 1...10, step: 1)
}
.settingsHighlight(id: highlightID("Low battery duration"))
.disabled(!showPowerStatusNotifications || !showLowBatteryHUD)
.opacity(sectionOpacity(showPowerStatusNotifications && showLowBatteryHUD))
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Full battery duration")
Spacer()
Text("\(fullBatteryHUDDuration)s")
.foregroundStyle(.secondary)
}
Slider(value: fullBatteryDurationBinding, in: 1...10, step: 1)
}
.settingsHighlight(id: highlightID("Full battery duration"))
.disabled(!showPowerStatusNotifications || !showFullBatteryHUD)
.opacity(sectionOpacity(showPowerStatusNotifications && showFullBatteryHUD))
} header: {
Text("HUD Duration")
}
Section {
Button {
batteryStatusViewModel.triggerTestHUD(kind: .charging)
} label: {
Label("Test charging HUD", systemImage: "bolt.fill")
}
.disabled(!showPowerStatusNotifications || !showChargingBatteryHUD)
Button {
batteryStatusViewModel.triggerTestHUD(kind: .lowBattery)
} label: {
Label("Test low battery HUD", systemImage: "battery.25")
}
.disabled(!showPowerStatusNotifications || !showLowBatteryHUD)
Button {
batteryStatusViewModel.triggerTestHUD(kind: .fullBattery)
} label: {
Label("Test full battery HUD", systemImage: "battery.100")
}
.disabled(!showPowerStatusNotifications || !showFullBatteryHUD)
} header: {
Text("HUD Tests")
} footer: {
Text("Runs the real notch animation on the current target display. If an external screen is using Dynamic Island mode, the battery HUD is sent there first.")
}
Section {
VStack(alignment: .leading, spacing: 10) {
Picker("Low battery style", selection: $lowBatteryHUDStyle) {
ForEach(BatteryNotificationStyle.allCases) { style in
Text(style.title)
.tag(style)
}
}
.pickerStyle(.segmented)
Text("Compact matches the charging HUD. Standard uses the expanded DynamicNotch-style card.")
.font(.caption)
.foregroundStyle(.secondary)
}
.settingsHighlight(id: highlightID("Low battery style"))
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Low battery threshold")
Spacer()
Text("\(lowBatteryHUDThreshold)%")
.foregroundStyle(.secondary)
}
Slider(value: lowBatteryThresholdBinding, in: 5...30, step: 1)
}
.settingsHighlight(id: highlightID("Low battery threshold"))
} header: {
Text("Low Battery")
}
.disabled(!showPowerStatusNotifications || !showLowBatteryHUD)
.opacity(sectionOpacity(showPowerStatusNotifications && showLowBatteryHUD))
Section {
VStack(alignment: .leading, spacing: 10) {
Picker("Full battery style", selection: $fullBatteryHUDStyle) {
ForEach(BatteryNotificationStyle.allCases) { style in
Text(style.title)
.tag(style)
}
}
.pickerStyle(.segmented)
Text("Compact keeps the alert inline. Standard uses the taller full-charge HUD with the charging animation.")
.font(.caption)
.foregroundStyle(.secondary)
}
.settingsHighlight(id: highlightID("Full battery style"))
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Full charge threshold")
Spacer()
Text("\(fullBatteryHUDThreshold)%")
.foregroundStyle(.secondary)
}
Slider(value: fullBatteryThresholdBinding, in: 80...100, step: 1)
}
.settingsHighlight(id: highlightID("Full charge threshold"))
} header: {
Text("Full Battery")
}
.disabled(!showPowerStatusNotifications || !showFullBatteryHUD)
.opacity(sectionOpacity(showPowerStatusNotifications && showFullBatteryHUD))
} else {
ContentUnavailableView {
VStack(spacing: 16) {
@ -1997,6 +2218,10 @@ private struct ExternalDisplayIntegrationsSection: View {
@Default(.enableThirdPartyDDCIntegration) var enableThirdPartyDDCIntegration
@Default(.thirdPartyDDCProvider) var thirdPartyDDCProvider
@Default(.enableExternalVolumeControlListener) var enableExternalVolumeControlListener
@Default(.volumeStepPercent) var volumeStepPercent
@Default(.volumeFineStepPercent) var volumeFineStepPercent
@Default(.brightnessStepPercent) var brightnessStepPercent
@Default(.brightnessFineStepPercent) var brightnessFineStepPercent
@ObservedObject private var betterDisplayManager = BetterDisplayManager.shared
@ObservedObject private var lunarManager = LunarManager.shared
@ -2067,6 +2292,74 @@ private struct ExternalDisplayIntegrationsSection: View {
var body: some View {
Form {
Section {
Stepper(value: $volumeStepPercent, in: 1...25) {
HStack {
Text("Volume step")
Spacer()
Text("\(volumeStepPercent)%")
.foregroundStyle(.secondary)
.monospacedDigit()
}
}
.settingsHighlight(id: highlightID("Volume step"))
.disabled(enableExternalVolumeControlListener)
Stepper(value: $volumeFineStepPercent, in: 1...25) {
HStack {
Text("Volume fine step")
Spacer()
Text("\(volumeFineStepPercent)%")
.foregroundStyle(.secondary)
.monospacedDigit()
}
}
.settingsHighlight(id: highlightID("Volume fine step"))
.disabled(enableExternalVolumeControlListener)
if enableExternalVolumeControlListener {
Text("Disabled while external display volume integration is active.")
.font(.caption)
.foregroundStyle(.secondary)
}
Stepper(value: $brightnessStepPercent, in: 1...25) {
HStack {
Text("Brightness step")
Spacer()
Text("\(brightnessStepPercent)%")
.foregroundStyle(.secondary)
.monospacedDigit()
}
}
.settingsHighlight(id: highlightID("Brightness step"))
.disabled(enableThirdPartyDDCIntegration)
Stepper(value: $brightnessFineStepPercent, in: 1...25) {
HStack {
Text("Brightness fine step")
Spacer()
Text("\(brightnessFineStepPercent)%")
.foregroundStyle(.secondary)
.monospacedDigit()
}
}
.settingsHighlight(id: highlightID("Brightness fine step"))
.disabled(enableThirdPartyDDCIntegration)
if enableThirdPartyDDCIntegration {
Text("Disabled while external display brightness integration is active.")
.font(.caption)
.foregroundStyle(.secondary)
}
} header: {
Text("Step size")
} footer: {
Text("Percent change per key press. Fine step applies when holding Shift+Option.")
.foregroundStyle(.secondary)
.font(.caption)
}
Section {
Toggle("Enable third-party DDC app integration", isOn: $enableThirdPartyDDCIntegration)
.settingsHighlight(id: highlightID("Third-party DDC app integration"))
@ -2450,6 +2743,7 @@ struct Media: View {
@Default(.lockScreenGlassStyle) private var lockScreenGlassStyle
@Default(.lockScreenGlassCustomizationMode) private var lockScreenGlassCustomizationMode
@Default(.lockScreenMusicAlbumParallaxEnabled) private var lockScreenMusicAlbumParallaxEnabled
@Default(.lockScreenMusicFullscreenArtworkEnabled) private var lockScreenMusicFullscreenArtworkEnabled
@Default(.showStandardMediaControls) private var showStandardMediaControls
@Default(.autoHideInactiveNotchMediaPlayer) private var autoHideInactiveNotchMediaPlayer
@Default(.parallaxEffectIntensity) private var parallaxEffectIntensity
@ -2505,6 +2799,11 @@ struct Media: View {
.font(.caption)
}
}
if mediaController == .spotify {
SpotifyAuthSettingsSection()
}
Section {
Defaults.Toggle(key: .showStandardMediaControls) {
Text("Show media controls in Dynamic Island")
@ -2603,6 +2902,11 @@ struct Media: View {
Text("Enable lyrics")
}
.settingsHighlight(id: highlightID("Enable lyrics"))
Defaults.Toggle(key: .showLiveCanvasInDynamicIsland) {
Text("Show live canvas in Dynamic Island")
}
.settingsHighlight(id: highlightID("Show live canvas in Dynamic Island"))
.help("Replaces the artwork tile with the live canvas when the current app provides one, and reuses that moving canvas for the surrounding lighting effect.")
//Parallax Effect Intensity to control how much parallax is wanted
Slider(value: $parallaxEffectIntensity, in: 0...12, step: 1.0) {
@ -2696,6 +3000,27 @@ struct Media: View {
.opacity(enableLockScreenMediaWidget ? 1 : 0.5)
.settingsHighlight(id: highlightID("Enable media panel blur"))
}
VStack(alignment: .leading, spacing: 4) {
Defaults.Toggle(key: .lockScreenMusicFullscreenArtworkEnabled) {
Text("Fullscreen artwork on right-click")
}
.disabled(!enableLockScreenMediaWidget)
.settingsHighlight(id: highlightID("Fullscreen artwork on right-click"))
Defaults.Toggle(key: .lockScreenUseArtworkLayoutOverFullscreenCanvas) {
Text("Use album art layout over fullscreen canvas")
}
.disabled(!enableLockScreenMediaWidget || !lockScreenMusicFullscreenArtworkEnabled)
.settingsHighlight(id: highlightID("Use album art layout over fullscreen canvas"))
Defaults.Toggle(key: .lockScreenKeepAlbumArtVisibleDuringFullscreenArtwork) {
Text("Keep album art visible during fullscreen artwork")
}
.disabled(!enableLockScreenMediaWidget || !lockScreenMusicFullscreenArtworkEnabled)
.settingsHighlight(id: highlightID("Keep album art visible during fullscreen artwork"))
Text("Right-click the album art on the lock screen to set it as the wallpaper. Right-click again or click the background to restore the original wallpaper. If a canvas is available, Atoll can also keep the same album art + player layout on top of the live canvas.")
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
} header: {
Text("Lock Screen Integration")
} footer: {
@ -4576,6 +4901,7 @@ struct LockScreenSettings: View {
@Default(.lockScreenTimerGlassCustomizationMode) private var lockScreenTimerGlassCustomizationMode
@Default(.lockScreenTimerWidgetUsesBlur) private var timerGlassModeIsGlass
@Default(.enableLockScreenMediaWidget) private var enableLockScreenMediaWidget
@Default(.lockScreenMusicFullscreenArtworkEnabled) private var lockScreenMusicFullscreenArtworkEnabled
@Default(.enableLockScreenTimerWidget) private var enableLockScreenTimerWidget
@Default(.enableLockScreenWeatherWidget) private var enableLockScreenWeatherWidget
@Default(.enableLockScreenFocusWidget) private var enableLockScreenFocusWidget
@ -4809,6 +5135,27 @@ struct LockScreenSettings: View {
.opacity(enableLockScreenMediaWidget ? 1 : 0.5)
.settingsHighlight(id: highlightID("Enable media panel blur"))
}
VStack(alignment: .leading, spacing: 4) {
Defaults.Toggle(key: .lockScreenMusicFullscreenArtworkEnabled) {
Text("Fullscreen artwork on right-click")
}
.disabled(!enableLockScreenMediaWidget)
.settingsHighlight(id: highlightID("Fullscreen artwork on right-click"))
Defaults.Toggle(key: .lockScreenUseArtworkLayoutOverFullscreenCanvas) {
Text("Use album art layout over fullscreen canvas")
}
.disabled(!enableLockScreenMediaWidget || !lockScreenMusicFullscreenArtworkEnabled)
.settingsHighlight(id: highlightID("Use album art layout over fullscreen canvas"))
Defaults.Toggle(key: .lockScreenKeepAlbumArtVisibleDuringFullscreenArtwork) {
Text("Keep album art visible during fullscreen artwork")
}
.disabled(!enableLockScreenMediaWidget || !lockScreenMusicFullscreenArtworkEnabled)
.settingsHighlight(id: highlightID("Keep album art visible during fullscreen artwork"))
Text("Right-click the album art on the lock screen to set it as the wallpaper. Right-click again or click the background to restore the original wallpaper. If a canvas is available, Atoll can also keep the same album art + player layout on top of the live canvas.")
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
if !showStandardMediaControls {
Text("Enable Dynamic Island media controls to manage the lock screen panel.")

View file

@ -0,0 +1,129 @@
/*
* Atoll (DynamicIsland)
* Copyright (C) 2024-2026 Atoll Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import AppKit
import Defaults
import SwiftUI
struct SpotifyAuthSettingsSection: View {
@Default(.spotifySPDCCookie) private var spotifySPDCCookie
@ObservedObject private var spotifyAuthManager = SpotifyAuthManager.shared
@State private var showingLoginSheet = false
private var hasCookie: Bool {
!SpotifyAuthManager.sanitizeCookie(spotifySPDCCookie).isEmpty
}
var body: some View {
Section {
VStack(alignment: .leading, spacing: 8) {
Text("Sign in to Spotify to capture the `sp_dc` cookie automatically, or paste it in below.")
.font(.caption)
.foregroundStyle(.secondary)
Button {
showingLoginSheet = true
} label: {
Label("Sign in with Spotify", systemImage: "person.crop.circle.badge.checkmark")
}
.buttonStyle(.borderedProminent)
TextField("sp_dc cookie", text: $spotifySPDCCookie, axis: .vertical)
.textFieldStyle(.roundedBorder)
.font(.caption.monospaced())
.lineLimit(2...4)
.textSelection(.enabled)
}
HStack(spacing: 10) {
Circle()
.fill(spotifyAuthManager.isAuthenticated ? Color.green : (hasCookie ? Color.orange : Color.secondary))
.frame(width: 8, height: 8)
Text(spotifyAuthManager.sessionStatusText)
.foregroundStyle(.secondary)
}
if let authErrorMessage = spotifyAuthManager.authErrorMessage, !authErrorMessage.isEmpty {
Text(authErrorMessage)
.font(.caption)
.foregroundStyle(.red)
}
HStack {
Button("Paste from Clipboard") {
pasteCookieFromClipboard()
}
Button(spotifyAuthManager.isAuthorizing ? "Validating..." : "Validate Cookie") {
spotifySPDCCookie = SpotifyAuthManager.sanitizeCookie(spotifySPDCCookie)
Task {
await spotifyAuthManager.validateSession()
}
}
.disabled(!hasCookie || spotifyAuthManager.isAuthorizing)
Button("Clear") {
spotifySPDCCookie = ""
spotifyAuthManager.clearSession()
}
.disabled(!hasCookie && !spotifyAuthManager.isAuthenticated)
}
DisclosureGroup("Get the cookie manually") {
VStack(alignment: .leading, spacing: 6) {
Text("1. Open Spotify in a browser and log in")
.font(.caption)
Text("2. Developer Tools -> Application/Storage -> Cookies -> https://open.spotify.com")
.font(.caption)
Text("3. Copy the value of `sp_dc` and paste it here")
.font(.caption)
HStack(spacing: 12) {
Link("Open Spotify Web Player", destination: URL(string: "https://open.spotify.com")!)
Link("Method source", destination: URL(string: "https://github.com/Paxsenix0/Spotify-Canvas-API")!)
}
.font(.caption)
}
.padding(.top, 4)
}
.font(.caption)
.foregroundStyle(.secondary)
} header: {
Text("Spotify Canvas Session")
} footer: {
Text("Atoll uses the local `sp_dc` cookie only to request Spotify's internal web-player token and fetch the matching Canvas for the current track.")
.foregroundStyle(.secondary)
.font(.caption)
}
.sheet(isPresented: $showingLoginSheet) {
SpotifyLoginSheet { capturedValue in
let sanitized = SpotifyAuthManager.sanitizeCookie(capturedValue)
spotifySPDCCookie = sanitized
Task {
await spotifyAuthManager.validateSession()
}
}
}
}
private func pasteCookieFromClipboard() {
guard let clipboardText = NSPasteboard.general.string(forType: .string) else { return }
spotifySPDCCookie = SpotifyAuthManager.sanitizeCookie(clipboardText)
}
}

View file

@ -0,0 +1,272 @@
/*
* Atoll (DynamicIsland)
* Copyright (C) 2024-2026 Atoll Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import AppKit
import os
import SwiftUI
@preconcurrency import WebKit
private enum SpotifyLoginConstants {
static let loginURL = URL(string: "https://accounts.spotify.com/en/login")!
static let externalLoginURL = URL(string: "https://open.spotify.com/")!
static let cookieInstructionsURL = URL(
string: "https://github.com/Paxsenix0/Spotify-Canvas-API#how-to-get-sp_dc-cookie"
)!
static let cookieDomainSuffix = "spotify.com"
static let cookieName = "sp_dc"
static let userAgent =
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 "
+ "(KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"
static let blockedOAuthHostSuffixes = ["accounts.google.com", "accounts.youtube.com"]
static let googleSignInRedirectURL = URL(string: "https://accounts.spotify.com/en/login")!
}
private let spotifyLoginLogger = os.Logger(subsystem: "com.Ebullioscopic.Atoll", category: "SpotifyLogin")
struct SpotifyLoginSheet: View {
@Environment(\.dismiss) private var dismiss
let onCapture: (String) -> Void
@State private var statusText: String =
"Sign in with email & password, Apple, or Facebook. Google blocks in-app sign-in — use “Open in Browser” for Google accounts."
@State private var didCapture = false
var body: some View {
VStack(spacing: 0) {
HStack {
VStack(alignment: .leading, spacing: 2) {
Text("Connect Spotify")
.font(.headline)
Text(statusText)
.font(.caption)
.foregroundStyle(.secondary)
}
Spacer()
Button {
NSWorkspace.shared.open(SpotifyLoginConstants.externalLoginURL)
} label: {
Label("Open in Browser", systemImage: "safari")
}
.help("Spotify often blocks in-app logins. Sign in via your normal browser, then paste sp_dc in Settings.")
Button("Reset Session") {
NotificationCenter.default.post(name: .spotifyLoginSheetReset, object: nil)
statusText = "Session cleared. Sign in again to capture the cookie."
}
Button("Cancel") { dismiss() }
.keyboardShortcut(.cancelAction)
}
.padding(12)
Divider()
SpotifyLoginWebView { value in
guard !didCapture else { return }
didCapture = true
statusText = "Captured sp_dc cookie. Validating…"
onCapture(value)
dismiss()
} onStatus: { message in
statusText = message
}
}
.frame(minWidth: 520, minHeight: 640)
}
}
extension Notification.Name {
static let spotifyLoginSheetReset = Notification.Name("SpotifyLoginSheetReset")
}
struct SpotifyLoginWebView: NSViewRepresentable {
let onCapture: (String) -> Void
let onStatus: (String) -> Void
func makeCoordinator() -> Coordinator {
Coordinator(onCapture: onCapture, onStatus: onStatus)
}
func makeNSView(context: Context) -> WKWebView {
let configuration = WKWebViewConfiguration()
configuration.websiteDataStore = .nonPersistent()
configuration.preferences.javaScriptCanOpenWindowsAutomatically = false
let webView = FirstClickWebView(frame: .zero, configuration: configuration)
webView.customUserAgent = SpotifyLoginConstants.userAgent
webView.navigationDelegate = context.coordinator
webView.uiDelegate = context.coordinator
webView.allowsBackForwardNavigationGestures = true
context.coordinator.attach(webView: webView)
webView.load(URLRequest(url: SpotifyLoginConstants.loginURL))
DispatchQueue.main.async { [weak webView] in
webView?.window?.makeFirstResponder(webView)
}
return webView
}
func updateNSView(_ nsView: WKWebView, context: Context) {}
static func dismantleNSView(_ nsView: WKWebView, coordinator: Coordinator) {
coordinator.detach()
}
private final class FirstClickWebView: WKWebView {
override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }
}
@MainActor
final class Coordinator: NSObject, WKNavigationDelegate, WKUIDelegate, WKHTTPCookieStoreObserver {
private let onCapture: (String) -> Void
private let onStatus: (String) -> Void
private weak var webView: WKWebView?
private var resetObserver: NSObjectProtocol?
init(onCapture: @escaping (String) -> Void, onStatus: @escaping (String) -> Void) {
self.onCapture = onCapture
self.onStatus = onStatus
super.init()
resetObserver = NotificationCenter.default.addObserver(
forName: .spotifyLoginSheetReset,
object: nil,
queue: .main
) { [weak self] _ in
Task { @MainActor in self?.resetSession() }
}
}
deinit {
if let resetObserver {
NotificationCenter.default.removeObserver(resetObserver)
}
}
func attach(webView: WKWebView) {
self.webView = webView
webView.configuration.websiteDataStore.httpCookieStore.add(self)
}
func detach() {
webView?.configuration.websiteDataStore.httpCookieStore.remove(self)
webView = nil
}
private func resetSession() {
guard let webView else { return }
let store = webView.configuration.websiteDataStore
let types = WKWebsiteDataStore.allWebsiteDataTypes()
store.removeData(ofTypes: types, modifiedSince: .distantPast) { [weak self] in
Task { @MainActor in
self?.webView?.load(URLRequest(url: SpotifyLoginConstants.loginURL))
}
}
}
func cookiesDidChange(in cookieStore: WKHTTPCookieStore) {
cookieStore.getAllCookies { [weak self] cookies in
Task { @MainActor in
self?.handle(cookies: cookies)
}
}
}
// MARK: - WKNavigationDelegate
func webView(
_ webView: WKWebView,
decidePolicyFor navigationAction: WKNavigationAction,
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void
) {
if let url = navigationAction.request.url, Self.isBlockedOAuthHost(url.host) {
decisionHandler(.cancel)
spotifyLoginLogger.debug(
"Blocked embedded OAuth navigation to host=\(url.host ?? "", privacy: .public)"
)
onStatus(
"Google blocks in-app sign-in. Use email & password, Apple, or tap “Open in Browser” to sign in there and paste sp_dc in Settings."
)
webView.load(URLRequest(url: SpotifyLoginConstants.googleSignInRedirectURL))
return
}
decisionHandler(.allow)
}
private static func isBlockedOAuthHost(_ host: String?) -> Bool {
guard let host else { return false }
return SpotifyLoginConstants.blockedOAuthHostSuffixes.contains { host.hasSuffix($0) }
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
let host = webView.url?.host ?? ""
spotifyLoginLogger.debug("didFinish host=\(host, privacy: .public)")
if host.contains("accounts.spotify.com") {
onStatus("Sign in to your Spotify account.")
} else if host.contains("open.spotify.com") {
onStatus("Open Spotify shouldn't load here — capture should fire before this. Falling back.")
} else if host.contains("www.spotify.com") || host.contains("spotify.com") {
onStatus("Logged in. Finishing capture…")
}
webView.configuration.websiteDataStore.httpCookieStore.getAllCookies { [weak self] cookies in
let names = cookies
.filter { $0.domain.hasSuffix("spotify.com") }
.map { "\($0.name)@\($0.domain)" }
.joined(separator: ", ")
spotifyLoginLogger.debug("cookies after load: \(names, privacy: .public)")
Task { @MainActor in
self?.handle(cookies: cookies)
}
}
}
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
onStatus("Load failed: \(error.localizedDescription)")
}
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
onStatus("Load failed: \(error.localizedDescription)")
}
// Allow pop-ups (e.g. SSO providers) to load inline in the same webview.
func webView(
_ webView: WKWebView,
createWebViewWith configuration: WKWebViewConfiguration,
for navigationAction: WKNavigationAction,
windowFeatures: WKWindowFeatures
) -> WKWebView? {
if navigationAction.targetFrame == nil, let url = navigationAction.request.url {
if Self.isBlockedOAuthHost(url.host) {
onStatus(
"Google blocks in-app sign-in. Use email & password, Apple, or tap “Open in Browser” to sign in there and paste sp_dc in Settings."
)
return nil
}
webView.load(URLRequest(url: url))
}
return nil
}
// MARK: - Capture
private func handle(cookies: [HTTPCookie]) {
let match = cookies.first { cookie in
cookie.name == SpotifyLoginConstants.cookieName
&& cookie.domain.hasSuffix(SpotifyLoginConstants.cookieDomainSuffix)
}
guard let match, !match.value.isEmpty else { return }
onCapture(match.value)
}
}
}

View file

@ -0,0 +1,56 @@
/*
* Atoll (DynamicIsland)
* Copyright (C) 2024-2026 Atoll Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import SwiftUI
/// Standalone inline HUD shown in the closed Dynamic Island when the
/// File Tray (Shelf) has items and no higher-priority live activity is active.
///
/// Layout mirrors the battery inline HUD:
/// [tray icon] ─── [ notch ] ─── [bold green count]
struct ShelfInlineLiveActivity: View {
@EnvironmentObject var vm: DynamicIslandViewModel
@ObservedObject private var shelfState = ShelfStateViewModel.shared
private let sideWidth: CGFloat = 24
var body: some View {
HStack(spacing: 0) {
// LEFT of notch — tray icon (white, same style as the screenshot)
Image(systemName: "tray.fill")
.font(.system(size: 13, weight: .medium))
.foregroundStyle(.white)
.frame(width: sideWidth, alignment: .leading)
// Physical notch / pill space
Rectangle()
.fill(Color.black)
.frame(width: vm.closedNotchSize.width)
// RIGHT of notch — file count in white
Text("\(shelfState.items.count)")
.font(.system(.callout, design: .rounded, weight: .bold))
.foregroundStyle(.white)
.contentTransition(.numericText(countsDown: false))
.animation(.smooth(duration: 0.3), value: shelfState.items.count)
.frame(width: sideWidth, alignment: .trailing)
}
.frame(height: vm.effectiveClosedNotchHeight, alignment: .center)
}
}