diff --git a/DynamicIsland/ContentView.swift b/DynamicIsland/ContentView.swift index a6f416c..9ee6c0e 100644 --- a/DynamicIsland/ContentView.swift +++ b/DynamicIsland/ContentView.swift @@ -834,7 +834,9 @@ struct ContentView: View { ) let effectiveCenterWidth = inlineSneakPeekActive ? 380 : centerBaseWidth let notchWidth = wingBaseWidth + effectiveCenterWidth + rightWingWidth - let badgeSize = max(16, notchContentHeight * 0.45) + let badgeBaseSize = max(13, notchContentHeight * 0.36) + let badgeDisplaySize = badgeDisplaySize(for: secondary, baseSize: badgeBaseSize) + let badgeOffset = badgeOverlayOffset(for: secondary, badgeSize: badgeDisplaySize) HStack(spacing: 0) { ZStack(alignment: .bottomTrailing) { @@ -849,8 +851,8 @@ struct ContentView: View { .clipShape(RoundedRectangle(cornerRadius: MusicPlayerImageSizes.cornerRadiusInset.closed)) .matchedGeometryEffect(id: "albumArt", in: albumArtNamespace) .albumArtFlip(angle: musicManager.flipAngle) - albumArtBadge(for: secondary, badgeSize: badgeSize) - .offset(x: badgeSize * 0.2, y: badgeSize * 0.25) + albumArtBadge(for: secondary, badgeSize: badgeDisplaySize) + .offset(x: badgeOffset.width, y: badgeOffset.height) .id(secondary?.id ?? "music-badge") .contentTransition(.symbolEffect(.replace)) } @@ -1066,6 +1068,26 @@ struct ContentView: View { } } + private func badgeDisplaySize(for secondary: MusicSecondaryLiveActivity?, baseSize: CGFloat) -> CGFloat { + guard let secondary else { return baseSize } + switch secondary { + case .extensionPayload: + return max(11, baseSize * 0.86) + default: + return baseSize + } + } + + private func badgeOverlayOffset(for secondary: MusicSecondaryLiveActivity?, badgeSize: CGFloat) -> CGSize { + guard let secondary else { return CGSize(width: badgeSize * 0.2, height: badgeSize * 0.25) } + switch secondary { + case .extensionPayload: + return CGSize(width: badgeSize * 0.14, height: badgeSize * 0.12) + default: + return CGSize(width: badgeSize * 0.2, height: badgeSize * 0.25) + } + } + @ViewBuilder private func musicRightWing(for secondary: MusicSecondaryLiveActivity?, notchHeight: CGFloat, trailingWidth: CGFloat) -> some View { switch secondary { diff --git a/DynamicIsland/components/Extensions/ExtensionLiveActivityViews.swift b/DynamicIsland/components/Extensions/ExtensionLiveActivityViews.swift index 6167aae..0a45cfd 100644 --- a/DynamicIsland/components/Extensions/ExtensionLiveActivityViews.swift +++ b/DynamicIsland/components/Extensions/ExtensionLiveActivityViews.swift @@ -314,7 +314,10 @@ struct ExtensionInlineSneakPeekView: View { private let wingPadding: CGFloat = 16 private var descriptor: AtollLiveActivityDescriptor? { payload?.descriptor } - private var resolvedAccent: Color { descriptor?.accentColor.swiftUIColor ?? accentColor } + private var resolvedAccent: Color { + guard let descriptor else { return accentColor } + return descriptor.accentColor.resolvedColor(fallback: accentColor) + } private var trailingRenderable: ExtensionTrailingRenderable? { descriptor.map { resolvedExtensionTrailingRenderable(for: $0) } } diff --git a/DynamicIsland/components/Extensions/ExtensionRenderingHelpers.swift b/DynamicIsland/components/Extensions/ExtensionRenderingHelpers.swift index 94d30ee..af5dcd8 100644 --- a/DynamicIsland/components/Extensions/ExtensionRenderingHelpers.swift +++ b/DynamicIsland/components/Extensions/ExtensionRenderingHelpers.swift @@ -21,6 +21,10 @@ extension AtollColorDescriptor { } return NSColor(red: red, green: green, blue: blue, alpha: alpha) } + + func resolvedColor(fallback accent: Color) -> Color { + isAccent ? accent : swiftUIColor + } } // MARK: - Font Conversion @@ -287,7 +291,7 @@ struct ExtensionProgressIndicatorView: View { var body: some View { switch indicator { case let .ring(diameter, strokeWidth, color): - let ringColor = color?.swiftUIColor ?? accent + let ringColor = color?.resolvedColor(fallback: accent) ?? accent let resolvedDiameter = resolvedRingDiameter(requested: diameter) ZStack { Circle() @@ -300,7 +304,7 @@ struct ExtensionProgressIndicatorView: View { } .frame(width: resolvedDiameter, height: resolvedDiameter) case let .bar(width, height, cornerRadius, color): - let barColor = color?.swiftUIColor ?? accent + let barColor = color?.resolvedColor(fallback: accent) ?? accent Capsule() .fill(Color.white.opacity(0.18)) .frame(width: width ?? 80, height: height) @@ -311,13 +315,13 @@ struct ExtensionProgressIndicatorView: View { .animation(.smooth(duration: 0.25), value: progress) } case let .percentage(font, color): - let textColor = color?.swiftUIColor ?? accent + let textColor = color?.resolvedColor(fallback: accent) ?? accent Text("\(Int(progress * 100))%") .font(font.swiftUIFont()) .foregroundStyle(textColor) .monospacedDigit() case let .countdown(font, color): - let textColor = color?.swiftUIColor ?? accent + let textColor = color?.resolvedColor(fallback: accent) ?? accent let text = countdownText Text(text) .font(font.swiftUIFont()) @@ -383,7 +387,7 @@ struct ExtensionEdgeContentView: View { frameWidth: max(24, availableWidth - 12) ) case let .countdownText(targetDate, font: font, color: color): - ExtensionCountdownTextView(targetDate: targetDate, font: font, accent: accent, customColor: color?.swiftUIColor) + ExtensionCountdownTextView(targetDate: targetDate, font: font, accent: accent, customColor: color?.resolvedColor(fallback: accent)) .frame(maxWidth: .infinity, alignment: alignment) case let .icon(descriptor): ExtensionIconView( @@ -409,7 +413,7 @@ struct ExtensionEdgeContentView: View { } private func resolvedColor(_ descriptorColor: AtollColorDescriptor?) -> Color { - descriptorColor?.swiftUIColor ?? accent + descriptorColor?.resolvedColor(fallback: accent) ?? accent } }