mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Working LottieAnimations with Scaling and stuff
This commit is contained in:
parent
c00b6db984
commit
e500f5a5b2
13 changed files with 1451 additions and 1 deletions
74
DynamicIsland/components/IdleAnimationView.swift
Normal file
74
DynamicIsland/components/IdleAnimationView.swift
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// IdleAnimationView.swift
|
||||
// DynamicIsland
|
||||
//
|
||||
// Created by AI Assistant on 11/10/2025.
|
||||
// Unified view for displaying idle animations (Lottie or built-in face)
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Lottie
|
||||
import LottieUI
|
||||
import Defaults
|
||||
|
||||
struct IdleAnimationView: View {
|
||||
@Default(.selectedIdleAnimation) var selectedAnimation
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if let animation = selectedAnimation {
|
||||
AnimationContentView(animation: animation)
|
||||
} else {
|
||||
// Fallback to original face if nothing selected
|
||||
MinimalFaceFeatures(height: 20, width: 30)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Internal view that renders the actual animation content
|
||||
private struct AnimationContentView: View {
|
||||
let animation: CustomIdleAnimation
|
||||
|
||||
var body: some View {
|
||||
let config = animation.transformConfig
|
||||
|
||||
switch animation.source {
|
||||
case .lottieFile(let url):
|
||||
LottieView(state: LUStateData(
|
||||
type: .loadedFrom(url),
|
||||
speed: animation.speed,
|
||||
loopMode: .loop
|
||||
))
|
||||
.frame(width: config.cropWidth * config.scale,
|
||||
height: config.cropHeight * config.scale)
|
||||
.offset(x: config.offsetX, y: config.offsetY)
|
||||
.rotationEffect(.degrees(config.rotation))
|
||||
.opacity(config.opacity)
|
||||
|
||||
case .lottieURL(let url):
|
||||
LottieView(state: LUStateData(
|
||||
type: .loadedFrom(url),
|
||||
speed: animation.speed,
|
||||
loopMode: .loop
|
||||
))
|
||||
.frame(width: config.cropWidth * config.scale,
|
||||
height: config.cropHeight * config.scale)
|
||||
.offset(x: config.offsetX, y: config.offsetY)
|
||||
.rotationEffect(.degrees(config.rotation))
|
||||
.opacity(config.opacity)
|
||||
|
||||
case .builtInFace:
|
||||
MinimalFaceFeatures(height: 20, width: 30)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Preview
|
||||
#Preview {
|
||||
ZStack {
|
||||
Color.black
|
||||
IdleAnimationView()
|
||||
}
|
||||
.frame(width: 100, height: 50)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue