mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Update Extension Live Activity for positioning
This commit is contained in:
parent
a1678afe0a
commit
1bfce0c19a
2 changed files with 61 additions and 13 deletions
|
|
@ -202,6 +202,63 @@ struct ExtensionCompositeIconView: View {
|
|||
}
|
||||
}
|
||||
|
||||
struct ExtensionBadgeIconView: View {
|
||||
let descriptor: AtollIconDescriptor
|
||||
let accent: Color
|
||||
let size: CGFloat
|
||||
|
||||
private var symbolSize: CGFloat { size * 0.5 }
|
||||
private var imageSize: CGFloat { size * 0.62 }
|
||||
private var imageCornerRadius: CGFloat { size * 0.18 }
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
switch descriptor {
|
||||
case let .symbol(name, _, weight):
|
||||
Image(systemName: name)
|
||||
.font(.system(size: symbolSize, weight: weight.swiftUI))
|
||||
.foregroundStyle(accent)
|
||||
case let .image(data, _, _):
|
||||
if let image = NSImage(data: data) {
|
||||
Image(nsImage: image)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: imageSize, height: imageSize)
|
||||
.clipShape(RoundedRectangle(cornerRadius: imageCornerRadius, style: .continuous))
|
||||
} else {
|
||||
fallbackSymbol
|
||||
}
|
||||
case let .appIcon(bundleIdentifier, _, _):
|
||||
if let icon = AppIconAsNSImage(for: bundleIdentifier) {
|
||||
Image(nsImage: icon)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: imageSize, height: imageSize)
|
||||
.clipShape(RoundedRectangle(cornerRadius: imageCornerRadius, style: .continuous))
|
||||
} else {
|
||||
fallbackSymbol
|
||||
}
|
||||
case let .lottie(animationData, _):
|
||||
ExtensionLottieView(data: animationData, size: CGSize(width: imageSize, height: imageSize))
|
||||
case .none:
|
||||
fallbackSymbol
|
||||
}
|
||||
}
|
||||
.frame(width: size, height: size)
|
||||
}
|
||||
|
||||
private var fallbackSymbol: some View {
|
||||
Image(systemName: "app.dashed")
|
||||
.font(.system(size: symbolSize, weight: .medium))
|
||||
.foregroundStyle(accent)
|
||||
.frame(width: imageSize, height: imageSize)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: imageCornerRadius, style: .continuous)
|
||||
.fill(accent.opacity(0.15))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Lottie Rendering
|
||||
|
||||
struct ExtensionLottieView: View {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue