80 lines
2.1 KiB
Swift
80 lines
2.1 KiB
Swift
//
|
|
// IMAIMsgLoadingView.swift
|
|
// Crush
|
|
//
|
|
// Created by Leon on 2025/8/28.
|
|
//
|
|
import UIKit
|
|
import Lottie
|
|
|
|
class IMAIMsgLoadingConfig : IMContentBaseConfig {
|
|
override func contentSize(model: SessionBaseModel) -> CGSize {
|
|
return CGSize(width: 20, height: 20)
|
|
}
|
|
|
|
|
|
override func cellInsets(model: SessionBaseModel) -> UIEdgeInsets {
|
|
return UIEdgeInsets(top: 16, left: 24, bottom: 16, right: 24)
|
|
}
|
|
|
|
override func contentInsets(model: SessionBaseModel) -> UIEdgeInsets {
|
|
return UIEdgeInsets(top: 16, left: 24, bottom: 16, right: 24)
|
|
}
|
|
|
|
override func contentViewClass(model: SessionBaseModel) -> IMContentBaseView.Type {
|
|
return IMAIMsgLoadingView.self
|
|
}
|
|
}
|
|
|
|
class IMAIMsgLoadingView :IMContentBaseView{
|
|
var block: UIView!
|
|
var lottie: LottieAnimationView!
|
|
|
|
required override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
setupUI()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
func setupUI() {
|
|
block = {
|
|
let v = UIView()
|
|
v.backgroundColor = .c.csedn
|
|
v.cornerRadius = 16
|
|
addSubview(v)
|
|
v.snp.makeConstraints { make in
|
|
make.edges.equalToSuperview()
|
|
}
|
|
return v
|
|
}()
|
|
|
|
lottie = {
|
|
let animation = LottieAnimation.named("three_dots_msg_loading")
|
|
let animationView = LottieAnimationView(animation: animation)
|
|
|
|
animationView.contentMode = .scaleAspectFit
|
|
animationView.loopMode = .loop
|
|
animationView.backgroundBehavior = .pauseAndRestore
|
|
animationView.backgroundColor = .clear
|
|
animationView.size = CGSize(width: 20, height: 20)
|
|
block.addSubview(animationView)
|
|
animationView.snp.makeConstraints { make in
|
|
make.center.equalToSuperview()
|
|
make.size.equalTo(CGSize(width: 20, height: 20))
|
|
}
|
|
return animationView
|
|
}()
|
|
|
|
lottie.play()
|
|
}
|
|
|
|
deinit{
|
|
lottie.stop()
|
|
|
|
}
|
|
}
|