Add onboarding, auth flow, design system and project structure
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
50
Rosetta/DesignSystem/Components/LottieView.swift
Normal file
50
Rosetta/DesignSystem/Components/LottieView.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
import SwiftUI
|
||||
import Lottie
|
||||
|
||||
struct LottieView: UIViewRepresentable {
|
||||
let animationName: String
|
||||
var loopMode: LottieLoopMode = .playOnce
|
||||
var animationSpeed: CGFloat = 1.5
|
||||
var isPlaying: Bool = true
|
||||
|
||||
func makeUIView(context: Context) -> LottieAnimationView {
|
||||
let animationView = LottieAnimationView(name: animationName)
|
||||
animationView.contentMode = .scaleAspectFit
|
||||
animationView.loopMode = loopMode
|
||||
animationView.animationSpeed = animationSpeed
|
||||
animationView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
||||
animationView.setContentCompressionResistancePriority(.defaultLow, for: .vertical)
|
||||
if isPlaying {
|
||||
animationView.play()
|
||||
}
|
||||
return animationView
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: LottieAnimationView, context: Context) {
|
||||
uiView.loopMode = loopMode
|
||||
uiView.animationSpeed = animationSpeed
|
||||
|
||||
if isPlaying && !uiView.isAnimationPlaying {
|
||||
uiView.play()
|
||||
} else if !isPlaying {
|
||||
uiView.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Crossfading Lottie Container
|
||||
|
||||
struct CrossfadingLottieView: View {
|
||||
let animationName: String
|
||||
let animationID: Int
|
||||
|
||||
var body: some View {
|
||||
LottieView(
|
||||
animationName: animationName,
|
||||
loopMode: .playOnce,
|
||||
animationSpeed: 1.5
|
||||
)
|
||||
.id(animationID)
|
||||
.transition(.opacity.animation(.easeInOut(duration: 0.4)))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user