mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 15:44:32 +00:00
Working Animation Lock Screen
This commit is contained in:
parent
68b912463c
commit
71e6be4218
9 changed files with 158 additions and 30 deletions
|
|
@ -11,30 +11,27 @@ import Defaults
|
|||
struct LockScreenLiveActivity: View {
|
||||
@EnvironmentObject var vm: DynamicIslandViewModel
|
||||
@ObservedObject private var lockScreenManager = LockScreenManager.shared
|
||||
@StateObject private var iconAnimator = LockIconAnimator(initiallyLocked: LockScreenManager.shared.isLocked)
|
||||
@State private var isHovering: Bool = false
|
||||
@State private var gestureProgress: CGFloat = 0
|
||||
@State private var isExpanded: Bool = false
|
||||
@Namespace private var lockIconSpace
|
||||
|
||||
private var iconName: String {
|
||||
lockScreenManager.isLocked ? "lock.fill" : "lock.open.fill"
|
||||
}
|
||||
|
||||
private var iconColor: Color {
|
||||
.white
|
||||
}
|
||||
|
||||
private var indicatorDimension: CGFloat {
|
||||
max(0, vm.effectiveClosedNotchHeight - 12)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
// Left - Lock icon with subtle glow
|
||||
Color.clear
|
||||
.overlay(alignment: .leading) {
|
||||
if isExpanded {
|
||||
Image(systemName: iconName)
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.foregroundStyle(iconColor)
|
||||
.matchedGeometryEffect(id: "lock-icon", in: lockIconSpace)
|
||||
.frame(width: vm.effectiveClosedNotchHeight - 12, height: vm.effectiveClosedNotchHeight - 12)
|
||||
LockIconProgressView(progress: iconAnimator.progress, iconColor: iconColor)
|
||||
.frame(width: indicatorDimension, height: indicatorDimension)
|
||||
}
|
||||
}
|
||||
.frame(width: isExpanded ? max(0, vm.effectiveClosedNotchHeight - (isHovering ? 0 : 12) + gestureProgress / 2) : 0, height: vm.effectiveClosedNotchHeight - (isHovering ? 0 : 12))
|
||||
|
|
@ -50,6 +47,7 @@ struct LockScreenLiveActivity: View {
|
|||
}
|
||||
.frame(height: vm.effectiveClosedNotchHeight + (isHovering ? 8 : 0))
|
||||
.onAppear {
|
||||
iconAnimator.update(isLocked: lockScreenManager.isLocked, animated: false)
|
||||
// Expand immediately without animation to avoid conflicts
|
||||
withAnimation(.smooth(duration: 0.4)) {
|
||||
isExpanded = true
|
||||
|
|
@ -70,6 +68,9 @@ struct LockScreenLiveActivity: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: lockScreenManager.isLocked) { _, newValue in
|
||||
iconAnimator.update(isLocked: newValue)
|
||||
}
|
||||
.animation(.spring(response: 0.5, dampingFraction: 0.85), value: lockScreenManager.isLocked)
|
||||
.animation(.easeOut(duration: 0.25), value: isExpanded)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue