Files
suixinkan_uikit/suixinkan/UI/Loading/LottieLoadingView.swift
汉秋 39186cfe25 Add Lottie global loading overlay and fix stuck loading states.
Replace per-VC activity indicators with a ref-counted GlobalLoadingManager, and resolve duplicate show/hide calls on Profile, Statistics, and Home tabs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 17:43:13 +08:00

52 lines
1.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// LottieLoadingView.swift
// suixinkan
//
import Lottie
import SnapKit
import UIKit
/// Lottie Loading 使 `Resources/Lottie/loading.json`
final class LottieLoadingView: UIView {
private let animationView: LottieAnimationView
override init(frame: CGRect) {
animationView = LottieLoadingView.makeAnimationView()
super.init(frame: frame)
addSubview(animationView)
animationView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
///
func startAnimating() {
animationView.loopMode = .loop
animationView.play()
}
///
func stopAnimating() {
animationView.stop()
}
private static func makeAnimationView() -> LottieAnimationView {
if let url = loadingAnimationURL() {
return LottieAnimationView(filePath: url.path)
}
return LottieAnimationView()
}
private static func loadingAnimationURL() -> URL? {
Bundle.main.url(forResource: "loading", withExtension: "json", subdirectory: "Resources/Lottie")
?? Bundle.main.url(forResource: "loading", withExtension: "json")
}
}