mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Update Liquid Glass for Lock Screen Widgets
This commit is contained in:
parent
8720de3cf7
commit
2d86127175
5 changed files with 31 additions and 162 deletions
|
|
@ -304,148 +304,6 @@ struct ExtensionNotchSectionView: View {
|
|||
}
|
||||
}
|
||||
|
||||
struct ExtensionInlineSneakPeekView: View {
|
||||
let payload: ExtensionLiveActivityPayload?
|
||||
let accentColor: Color
|
||||
let notchHeight: CGFloat
|
||||
let closedNotchWidth: CGFloat
|
||||
let isHovering: Bool
|
||||
|
||||
private let wingPadding: CGFloat = 16
|
||||
|
||||
private var descriptor: AtollLiveActivityDescriptor? { payload?.descriptor }
|
||||
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) }
|
||||
}
|
||||
|
||||
private var contentHeight: CGFloat {
|
||||
max(0, notchHeight - (isHovering ? 0 : 12))
|
||||
}
|
||||
|
||||
private var centerWidth: CGFloat {
|
||||
max(closedNotchWidth + (isHovering ? 8 : 0), 120)
|
||||
}
|
||||
|
||||
private var iconDiameter: CGFloat {
|
||||
max(contentHeight - 8, 28)
|
||||
}
|
||||
|
||||
private var leftWingWidth: CGFloat {
|
||||
wingPadding + iconDiameter
|
||||
}
|
||||
|
||||
private var baseTrailingWidth: CGFloat {
|
||||
max(iconDiameter, 56)
|
||||
}
|
||||
|
||||
private var trailingContentWidth: CGFloat {
|
||||
guard let payload else { return baseTrailingWidth }
|
||||
return ExtensionLayoutMetrics.trailingWidth(
|
||||
for: payload,
|
||||
baseWidth: baseTrailingWidth,
|
||||
maxWidth: baseTrailingWidth + centerWidth * 0.6
|
||||
)
|
||||
}
|
||||
|
||||
private var rightWingWidth: CGFloat {
|
||||
wingPadding + trailingContentWidth
|
||||
}
|
||||
|
||||
private var trailingContentAvailableWidth: CGFloat {
|
||||
max(0, trailingContentWidth - wingPadding)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
leadingWing
|
||||
centerSection
|
||||
trailingWing
|
||||
}
|
||||
.frame(height: notchHeight + (isHovering ? 8 : 0), alignment: .center)
|
||||
}
|
||||
|
||||
private var leadingWing: some View {
|
||||
Color.clear
|
||||
.frame(width: leftWingWidth, height: contentHeight)
|
||||
.background(alignment: .leading) {
|
||||
Group {
|
||||
if let descriptor {
|
||||
ExtensionLeadingContentView(
|
||||
content: resolvedExtensionLeadingContent(for: descriptor),
|
||||
badge: descriptor.badgeIcon,
|
||||
accent: resolvedAccent,
|
||||
frameWidth: iconDiameter,
|
||||
frameHeight: iconDiameter,
|
||||
defaultIcon: descriptor.leadingIcon
|
||||
)
|
||||
} else {
|
||||
RoundedRectangle(cornerRadius: iconDiameter * 0.25, style: .continuous)
|
||||
.fill(resolvedAccent.gradient)
|
||||
.frame(width: iconDiameter, height: iconDiameter)
|
||||
}
|
||||
}
|
||||
.frame(width: iconDiameter, height: iconDiameter)
|
||||
.frame(maxHeight: .infinity, alignment: .center)
|
||||
.padding(.leading, wingPadding / 2)
|
||||
}
|
||||
}
|
||||
|
||||
private var centerSection: some View {
|
||||
Rectangle()
|
||||
.fill(Color.black)
|
||||
.frame(width: centerWidth, height: contentHeight)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var trailingWing: some View {
|
||||
Color.clear
|
||||
.frame(width: rightWingWidth, height: contentHeight)
|
||||
.background(alignment: .trailing) {
|
||||
if let descriptor, let trailingRenderable {
|
||||
VStack(alignment: .trailing, spacing: 6) {
|
||||
switch trailingRenderable {
|
||||
case let .content(content):
|
||||
if case .none = content {
|
||||
Spacer(minLength: 0)
|
||||
} else {
|
||||
ExtensionEdgeContentView(
|
||||
content: content,
|
||||
accent: resolvedAccent,
|
||||
availableWidth: trailingContentAvailableWidth,
|
||||
alignment: .trailing
|
||||
)
|
||||
.frame(maxWidth: trailingContentAvailableWidth, alignment: .trailing)
|
||||
}
|
||||
case let .indicator(indicator):
|
||||
ExtensionProgressIndicatorView(
|
||||
indicator: indicator,
|
||||
progress: descriptor.progress,
|
||||
accent: resolvedAccent,
|
||||
estimatedDuration: descriptor.estimatedDuration,
|
||||
maxVisualHeight: contentHeight
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.padding(.trailing, wingPadding / 2)
|
||||
.padding(.vertical, 6)
|
||||
} else {
|
||||
RoundedRectangle(cornerRadius: 8, style: .continuous)
|
||||
.fill(resolvedAccent.opacity(0.25))
|
||||
.frame(width: max(32, trailingContentAvailableWidth * 0.6), height: max(16, contentHeight * 0.4))
|
||||
.padding(.trailing, wingPadding / 2)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing)
|
||||
.padding(.vertical, 6)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ExtensionNotchSectionHeader: View {
|
||||
let section: AtollNotchContentSection
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue