Atoll/DynamicIsland/components/Timer/TimerIconAnimation.swift
2025-11-01 15:09:25 +05:30

49 lines
1.2 KiB
Swift

//
// TimerIconAnimation.swift
// DynamicIsland
//
// Created by Ebullioscopic on 2025-01-13.
//
import SwiftUI
import Defaults
struct TimerIconAnimation: View {
@Default(.accentColor) private var accentColor
var body: some View {
ZStack {
Circle()
.fill(accentColor.gradient)
.frame(width: 24, height: 24)
Image(systemName: "timer")
.font(.system(size: 12, weight: .medium))
.foregroundStyle(.white)
}
}
}
struct TimerIconView: NSViewRepresentable {
func makeNSView(context: Context) -> NSView {
let hostingView = NSHostingView(rootView: TimerIconAnimation())
hostingView.translatesAutoresizingMaskIntoConstraints = false
return hostingView
}
func updateNSView(_ nsView: NSView, context: Context) {
if let hostingView = nsView as? NSHostingView<TimerIconAnimation> {
hostingView.rootView = TimerIconAnimation()
}
}
}
#Preview {
TimerIconAnimation()
.frame(width: 50, height: 50)
.background(.black)
.onAppear {
// Start a demo timer for preview
TimerManager.shared.startDemoTimer(duration: 300)
}
}