mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Update Third Party stuff
This commit is contained in:
parent
94a612f327
commit
27b16a3d15
8 changed files with 636 additions and 99 deletions
|
|
@ -9,18 +9,20 @@ struct ExtensionStandaloneLayout {
|
|||
let leadingWidth: CGFloat
|
||||
let centerWidth: CGFloat
|
||||
let trailingWidth: CGFloat
|
||||
let suppressingCenterText: Bool
|
||||
}
|
||||
|
||||
struct ExtensionLiveActivityStandaloneView: View {
|
||||
let payload: ExtensionLiveActivityPayload
|
||||
let layout: ExtensionStandaloneLayout
|
||||
let isHovering: Bool
|
||||
let notchState: NotchState
|
||||
|
||||
private var descriptor: AtollLiveActivityDescriptor { payload.descriptor }
|
||||
private var contentHeight: CGFloat { layout.contentHeight }
|
||||
private var accentColor: Color { descriptor.accentColor.swiftUIColor }
|
||||
private var resolvedLeadingContent: AtollTrailingContent {
|
||||
descriptor.leadingContent ?? .icon(descriptor.leadingIcon)
|
||||
resolvedExtensionLeadingContent(for: descriptor)
|
||||
}
|
||||
private var resolvedCenterStyle: ExtensionCenterContentView.Style {
|
||||
switch descriptor.centerTextStyle {
|
||||
|
|
@ -33,6 +35,10 @@ struct ExtensionLiveActivityStandaloneView: View {
|
|||
}
|
||||
}
|
||||
|
||||
private var shouldSuppressCenterText: Bool {
|
||||
layout.suppressingCenterText
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
ExtensionLeadingContentView(
|
||||
|
|
@ -40,7 +46,8 @@ struct ExtensionLiveActivityStandaloneView: View {
|
|||
badge: descriptor.badgeIcon,
|
||||
accent: accentColor,
|
||||
frameWidth: layout.leadingWidth,
|
||||
frameHeight: contentHeight
|
||||
frameHeight: contentHeight,
|
||||
defaultIcon: descriptor.leadingIcon
|
||||
)
|
||||
.frame(width: layout.leadingWidth, height: contentHeight)
|
||||
|
||||
|
|
@ -48,12 +55,16 @@ struct ExtensionLiveActivityStandaloneView: View {
|
|||
.fill(Color.black)
|
||||
.frame(width: layout.centerWidth, height: contentHeight)
|
||||
.overlay(
|
||||
ExtensionCenterContentView(
|
||||
descriptor: descriptor,
|
||||
accent: accentColor,
|
||||
width: layout.centerWidth,
|
||||
style: resolvedCenterStyle
|
||||
)
|
||||
Group {
|
||||
if !shouldSuppressCenterText {
|
||||
ExtensionCenterContentView(
|
||||
descriptor: descriptor,
|
||||
accent: accentColor,
|
||||
width: layout.centerWidth,
|
||||
style: resolvedCenterStyle
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
ExtensionMusicWingView(
|
||||
|
|
@ -64,6 +75,10 @@ struct ExtensionLiveActivityStandaloneView: View {
|
|||
.frame(width: layout.trailingWidth, height: contentHeight)
|
||||
}
|
||||
.frame(width: layout.totalWidth, height: layout.outerHeight + (isHovering ? 8 : 0))
|
||||
.transition(.asymmetric(
|
||||
insertion: .scale(scale: 0.95).combined(with: .opacity).animation(.spring(response: 0.4, dampingFraction: 0.8)),
|
||||
removal: .scale(scale: 0.95).combined(with: .opacity).animation(.spring(response: 0.3, dampingFraction: 0.9))
|
||||
))
|
||||
.animation(.smooth(duration: 0.25), value: payload.id)
|
||||
.onAppear {
|
||||
logExtensionDiagnostics("Displaying extension live activity \(payload.descriptor.id) for \(payload.bundleIdentifier) as standalone view")
|
||||
|
|
@ -82,32 +97,37 @@ struct ExtensionMusicWingView: View {
|
|||
|
||||
private var descriptor: AtollLiveActivityDescriptor { payload.descriptor }
|
||||
private var accentColor: Color { descriptor.accentColor.swiftUIColor }
|
||||
private var trailingRenderable: ExtensionTrailingRenderable {
|
||||
resolvedExtensionTrailingRenderable(for: descriptor)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .trailing, spacing: 6) {
|
||||
if case .none = descriptor.trailingContent {
|
||||
EmptyView()
|
||||
} else {
|
||||
ExtensionEdgeContentView(
|
||||
content: descriptor.trailingContent,
|
||||
accent: accentColor,
|
||||
availableWidth: trailingWidth,
|
||||
alignment: .trailing
|
||||
)
|
||||
switch trailingRenderable {
|
||||
case let .content(content):
|
||||
if case .none = content {
|
||||
EmptyView()
|
||||
} else {
|
||||
ExtensionEdgeContentView(
|
||||
content: content,
|
||||
accent: accentColor,
|
||||
availableWidth: trailingWidth,
|
||||
alignment: .trailing
|
||||
)
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
}
|
||||
|
||||
if let indicator = descriptor.progressIndicator, indicator != .none {
|
||||
}
|
||||
case let .indicator(indicator):
|
||||
ExtensionProgressIndicatorView(
|
||||
indicator: indicator,
|
||||
progress: descriptor.progress,
|
||||
accent: accentColor,
|
||||
estimatedDuration: descriptor.estimatedDuration
|
||||
estimatedDuration: descriptor.estimatedDuration,
|
||||
maxVisualHeight: notchHeight
|
||||
)
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
} else {
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
|
||||
.padding(.trailing, 8)
|
||||
|
|
@ -127,23 +147,39 @@ struct ExtensionLeadingContentView: View {
|
|||
let accent: Color
|
||||
let frameWidth: CGFloat
|
||||
let frameHeight: CGFloat
|
||||
let defaultIcon: AtollIconDescriptor
|
||||
|
||||
var body: some View {
|
||||
if case let .icon(iconDescriptor) = content {
|
||||
ExtensionCompositeIconView(
|
||||
leading: iconDescriptor,
|
||||
badge: badge,
|
||||
accent: accent,
|
||||
size: frameHeight
|
||||
)
|
||||
} else {
|
||||
ExtensionEdgeContentView(
|
||||
content: content,
|
||||
accent: accent,
|
||||
availableWidth: frameWidth,
|
||||
alignment: .leading
|
||||
)
|
||||
Group {
|
||||
switch content {
|
||||
case let .icon(iconDescriptor):
|
||||
ExtensionCompositeIconView(
|
||||
leading: iconDescriptor,
|
||||
badge: badge,
|
||||
accent: accent,
|
||||
size: frameHeight
|
||||
)
|
||||
case let .animation(data, size):
|
||||
let resolvedSize = CGSize(
|
||||
width: min(size.width, frameHeight),
|
||||
height: min(size.height, frameHeight)
|
||||
)
|
||||
ExtensionLottieView(data: data, size: resolvedSize)
|
||||
.frame(width: frameHeight, height: frameHeight)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: frameHeight * 0.18, style: .continuous)
|
||||
.fill(Color.white.opacity(0.08))
|
||||
)
|
||||
default:
|
||||
ExtensionCompositeIconView(
|
||||
leading: defaultIcon,
|
||||
badge: badge,
|
||||
accent: accent,
|
||||
size: frameHeight
|
||||
)
|
||||
}
|
||||
}
|
||||
.frame(width: frameWidth, height: frameHeight)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,3 +238,125 @@ private func logExtensionDiagnostics(_ message: String) {
|
|||
guard Defaults[.extensionDiagnosticsLoggingEnabled] else { return }
|
||||
Logger.log(message, category: .extensions)
|
||||
}
|
||||
|
||||
struct ExtensionInlineSneakPeekView: View {
|
||||
let payload: ExtensionLiveActivityPayload?
|
||||
let title: String
|
||||
let subtitle: String
|
||||
let accentColor: Color
|
||||
let notchHeight: CGFloat
|
||||
let closedNotchWidth: CGFloat
|
||||
let isHovering: Bool
|
||||
let gestureProgress: CGFloat
|
||||
|
||||
private var descriptor: AtollLiveActivityDescriptor? { payload?.descriptor }
|
||||
private var resolvedAccent: Color { descriptor?.accentColor.swiftUIColor ?? accentColor }
|
||||
|
||||
private var contentHeight: CGFloat {
|
||||
max(0, notchHeight - (isHovering ? 0 : 12))
|
||||
}
|
||||
|
||||
private var leadingWidth: CGFloat {
|
||||
let base = max(contentHeight, 44)
|
||||
return max(base * 0.85, base + gestureProgress / 2)
|
||||
}
|
||||
|
||||
private var centerWidth: CGFloat {
|
||||
max(closedNotchWidth + (isHovering ? 8 : 0), 120)
|
||||
}
|
||||
|
||||
private var trailingWidth: CGFloat {
|
||||
guard let payload else { return max(leadingWidth, 120) }
|
||||
return ExtensionLayoutMetrics.trailingWidth(
|
||||
for: payload,
|
||||
baseWidth: leadingWidth,
|
||||
maxWidth: leadingWidth + centerWidth * 0.6
|
||||
)
|
||||
}
|
||||
|
||||
private var marqueeFrameWidth: CGFloat {
|
||||
max(48, centerWidth - 24)
|
||||
}
|
||||
|
||||
private var resolvedTitle: String {
|
||||
title.isEmpty ? "Extension" : title
|
||||
}
|
||||
|
||||
private var resolvedSubtitle: String {
|
||||
subtitle.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
leadingWing
|
||||
.frame(width: leadingWidth, height: contentHeight)
|
||||
|
||||
Rectangle()
|
||||
.fill(Color.black)
|
||||
.frame(width: centerWidth, height: contentHeight)
|
||||
.overlay(alignment: .bottomLeading) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
if !resolvedTitle.isEmpty {
|
||||
MarqueeText(
|
||||
.constant(resolvedTitle),
|
||||
font: .system(size: 12, weight: .semibold),
|
||||
nsFont: .subheadline,
|
||||
textColor: .white,
|
||||
minDuration: 0.4,
|
||||
frameWidth: marqueeFrameWidth
|
||||
)
|
||||
}
|
||||
if !resolvedSubtitle.isEmpty {
|
||||
Text(resolvedSubtitle)
|
||||
.font(.system(size: 11, weight: .regular))
|
||||
.foregroundStyle(Color.white.opacity(0.75))
|
||||
.lineLimit(1)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.bottom, 6)
|
||||
}
|
||||
|
||||
trailingWing
|
||||
.frame(width: trailingWidth, height: contentHeight)
|
||||
}
|
||||
.frame(height: notchHeight + (isHovering ? 8 : 0), alignment: .center)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var leadingWing: some View {
|
||||
if let descriptor {
|
||||
ExtensionLeadingContentView(
|
||||
content: resolvedExtensionLeadingContent(for: descriptor),
|
||||
badge: descriptor.badgeIcon,
|
||||
accent: resolvedAccent,
|
||||
frameWidth: leadingWidth,
|
||||
frameHeight: contentHeight,
|
||||
defaultIcon: descriptor.leadingIcon
|
||||
)
|
||||
} else {
|
||||
RoundedRectangle(cornerRadius: contentHeight * 0.25, style: .continuous)
|
||||
.fill(resolvedAccent.gradient)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var trailingWing: some View {
|
||||
if let payload {
|
||||
ExtensionMusicWingView(
|
||||
payload: payload,
|
||||
notchHeight: contentHeight,
|
||||
trailingWidth: trailingWidth
|
||||
)
|
||||
} else {
|
||||
Rectangle()
|
||||
.fill(resolvedAccent.gradient)
|
||||
.mask {
|
||||
AudioSpectrumView(isPlaying: .constant(true))
|
||||
.frame(width: 18, height: 12)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue