commit 66476c749505702fb483b5fd3a83c203caa57d90
parent b3866accb807914b62975b5c8706e03d19e9c6bf
Author: Marc Stibane <marc@taler.net>
Date: Mon, 28 Apr 2025 00:09:01 +0200
Animations
Diffstat:
3 files changed, 51 insertions(+), 24 deletions(-)
diff --git a/TalerWallet1/Helper/Animations.swift b/TalerWallet1/Helper/Animations.swift
@@ -22,50 +22,58 @@
*/
import SwiftUI
+var fastAnimations = true
#if DEBUG
var debugAnimations = true
#endif
extension Animation {
#if DEBUG
- static var debug: Animation {
- Animation.easeInOut(duration: 2.0)
- }
+ static var debug: Animation { .easeInOut(duration: 2.0) }
#endif
- static var spring1: Animation {
- Animation.interactiveSpring(response: 0.6, dampingFraction: 0.6, blendDuration: 0.25)
+ static var springFast: Animation {
+ .interactiveSpring(response: 0.6, dampingFraction: 0.6, blendDuration: 0.25)
+ }
+ static var springSlow: Animation {
+ .interactiveSpring(response: 0.9, dampingFraction: 0.75, blendDuration: 0.5)
}
static var easeIn1: Animation {
#if DEBUG
- debugAnimations ? Animation.debug : Animation.easeIn(duration: 0.25)
-#else
- Animation.easeIn(duration: 0.25)
+ if debugAnimations { return .debug }
#endif
+ return .easeIn(duration: (fastAnimations ? 0.25 : 0.5))
}
- static var shake1: Animation {
+ static var fly1: Animation {
#if DEBUG
- debugAnimations ? Animation.debug : Animation.spring1
-#else
- Animation.spring1
+ if debugAnimations { return .debug }
#endif
+ return fastAnimations ? .springFast
+ : .springSlow
}
- static var fly1: Animation {
+ static var remove1: Animation {
#if DEBUG
- debugAnimations ? Animation.debug : Animation.spring1
-#else
- Animation.spring1
+ if debugAnimations { return .debug }
#endif
+ return fastAnimations ? .springFast.delay(0.2)
+ : .springSlow.delay(0.5)
}
-
+
static var basic1: Animation {
#if DEBUG
- debugAnimations ? Animation.debug : Animation.default
-#else
- Animation.default
+ if debugAnimations { return .debug }
#endif
+ /// The `default` animation is ``spring(response:dampingFraction:blendDuration:)``
+ /// with:
+ /// - `response` equal to `0.55`
+ /// - `dampingFraction` equal to `1.0`
+ /// - `blendDuration` equal to `0.0`
+ ///
+ /// Prior to iOS 17, macOS 14, tvOS 17, and watchOS 10, the `default` animation is ``easeInOut``.
+ return fastAnimations ? .default
+ : .springSlow
}
}
diff --git a/TalerWallet1/Views/OIM/OIMbackground.swift b/TalerWallet1/Views/OIM/OIMbackground.swift
@@ -20,7 +20,8 @@ struct OIMamountV: View {
func updateColor() {
color = debugAnimations ? WalletColors().attention
- : WalletColors().talerColor
+ : fastAnimations ? WalletColors().talerColor
+ : WalletColors().confirm
}
var body: some View {
HStack {
@@ -29,11 +30,29 @@ struct OIMamountV: View {
AmountV(currencyName, amount: amount, isNegative: nil)
.foregroundColor(color)
#if DEBUG
- .onTapGesture {
- debugAnimations.toggle()
+ .onTapGesture(count: 2) {
+ if debugAnimations {
+ debugAnimations = false
+ fastAnimations = true
+ } else {
+ debugAnimations = true
+ }
updateColor()
}
#endif
+ .onTapGesture(count: 1) {
+#if DEBUG
+ if debugAnimations {
+ debugAnimations = false
+ fastAnimations = false
+ } else {
+ fastAnimations.toggle()
+ }
+#else
+ fastAnimations.toggle()
+#endif
+ updateColor()
+ }
}
}.padding(.horizontal, UIScreen.hasFaceID ? 20 : 4)
.ignoresSafeArea(edges: .all)
diff --git a/TalerWallet1/Views/OIM/OIMlayout.swift b/TalerWallet1/Views/OIM/OIMlayout.swift
@@ -78,7 +78,7 @@ struct OIMlayoutView: View {
cash.updateFund(fund)
}
DispatchQueue.main.async {
- withAnimation(.fly1) {
+ withAnimation(.remove1) {
symLog.log(" OIMlayoutView remove \(value)")
cash.removeCash(id: fund.id, value: fund.value)
}