mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
272f538060
commit
4018360cab
@ -13,6 +13,7 @@ swift_library(
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/rlottie:RLottieBinding",
|
||||
"//submodules/lottie-ios:Lottie",
|
||||
"//submodules/GZip:GZip",
|
||||
"//submodules/AppBundle:AppBundle",
|
||||
"//submodules/Display:Display",
|
||||
],
|
||||
|
@ -2,6 +2,7 @@ import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Lottie
|
||||
import GZip
|
||||
import AppBundle
|
||||
import Display
|
||||
|
||||
@ -32,7 +33,15 @@ public final class AnimationNode: ASDisplayNode {
|
||||
super.init()
|
||||
|
||||
self.setViewBlock({
|
||||
if let animationName = animationName, let url = getAppBundle().url(forResource: animationName, withExtension: "json"), let animation = Animation.filepath(url.path) {
|
||||
var animation: Animation?
|
||||
if let animationName {
|
||||
if let url = getAppBundle().url(forResource: animationName, withExtension: "json"), let maybeAnimation = Animation.filepath(url.path) {
|
||||
animation = maybeAnimation
|
||||
} else if let url = getAppBundle().url(forResource: animationName, withExtension: "tgs"), let data = try? Data(contentsOf: URL(fileURLWithPath: url.path)), let unpackedData = TGGUnzipData(data, 5 * 1024 * 1024) {
|
||||
animation = try? Animation.from(data: unpackedData, strategy: .codable)
|
||||
}
|
||||
}
|
||||
if let animation {
|
||||
let view = AnimationView(animation: animation, configuration: LottieConfiguration(renderingEngine: .mainThread, decodingStrategy: .codable))
|
||||
view.animationSpeed = self.speed
|
||||
view.backgroundColor = .clear
|
||||
@ -104,6 +113,10 @@ public final class AnimationNode: ASDisplayNode {
|
||||
self.animationView()?.currentProgress = 1.0
|
||||
}
|
||||
|
||||
public func setProgress(_ progress: CGFloat) {
|
||||
self.animationView()?.currentProgress = progress
|
||||
}
|
||||
|
||||
public func setAnimation(name: String, colors: [String: UIColor]? = nil) {
|
||||
self.currentParams = (name, colors)
|
||||
if let url = getAppBundle().url(forResource: name, withExtension: "json"), let animation = Animation.filepath(url.path) {
|
||||
|
@ -20,6 +20,11 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
case `default`
|
||||
}
|
||||
|
||||
public enum PresentationMode {
|
||||
case `default`
|
||||
case modal
|
||||
}
|
||||
|
||||
public final class Environment: Equatable {
|
||||
public let statusBarHeight: CGFloat
|
||||
public let navigationHeight: CGFloat
|
||||
@ -139,11 +144,6 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: Transition) {
|
||||
self.currentLayout = (layout, navigationHeight)
|
||||
|
||||
var theme = self.theme ?? self.presentationData.theme
|
||||
if theme.list.blocksBackgroundColor.rgb == theme.list.plainBackgroundColor.rgb {
|
||||
theme = theme.withModalBlocksBackground()
|
||||
}
|
||||
|
||||
let environment = ViewControllerComponentContainer.Environment(
|
||||
statusBarHeight: layout.statusBarHeight ?? 0.0,
|
||||
navigationHeight: navigationHeight,
|
||||
@ -152,7 +152,7 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
metrics: layout.metrics,
|
||||
deviceMetrics: layout.deviceMetrics,
|
||||
isVisible: self.currentIsVisible,
|
||||
theme: theme,
|
||||
theme: self.theme ?? self.presentationData.theme,
|
||||
strings: self.presentationData.strings,
|
||||
dateTimeFormat: self.presentationData.dateTimeFormat,
|
||||
controller: { [weak self] in
|
||||
@ -203,7 +203,7 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
private var presentationDataDisposable: Disposable?
|
||||
public private(set) var validLayout: ContainerViewLayout?
|
||||
|
||||
public init<C: Component>(context: AccountContext, component: C, navigationBarAppearance: NavigationBarAppearance, statusBarStyle: StatusBarStyle = .default, theme: PresentationTheme? = nil) where C.EnvironmentType == ViewControllerComponentContainer.Environment {
|
||||
public init<C: Component>(context: AccountContext, component: C, navigationBarAppearance: NavigationBarAppearance, statusBarStyle: StatusBarStyle = .default, presentationMode: PresentationMode = .default, theme: PresentationTheme? = nil) where C.EnvironmentType == ViewControllerComponentContainer.Environment {
|
||||
self.context = context
|
||||
self.component = AnyComponent(component)
|
||||
self.theme = theme
|
||||
@ -224,7 +224,12 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
self.presentationDataDisposable = (self.context.sharedContext.presentationData
|
||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||
if let strongSelf = self {
|
||||
strongSelf.node.presentationData = presentationData
|
||||
var theme = presentationData.theme
|
||||
if case .modal = presentationMode, theme.list.blocksBackgroundColor.rgb == theme.list.plainBackgroundColor.rgb {
|
||||
theme = theme.withModalBlocksBackground()
|
||||
}
|
||||
|
||||
strongSelf.node.presentationData = presentationData.withUpdated(theme: theme)
|
||||
|
||||
switch statusBarStyle {
|
||||
case .none:
|
||||
|
@ -1032,7 +1032,7 @@ public final class PremiumGiftScreen: ViewControllerComponentContainer, Attachme
|
||||
completion: { duration in
|
||||
completionImpl?(duration)
|
||||
}
|
||||
), navigationBarAppearance: .transparent)
|
||||
), navigationBarAppearance: .transparent, presentationMode: .modal)
|
||||
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ final class PeerInfoAvatarListNode: ASDisplayNode {
|
||||
self.bottomCoverNode = ASDisplayNode()
|
||||
self.bottomCoverNode.backgroundColor = .black
|
||||
|
||||
self.maskNode = DynamicIslandMaskNode(size: CGSize(width: 512.0, height: 512.0))
|
||||
self.maskNode = DynamicIslandMaskNode()
|
||||
self.pinchSourceNode = PinchSourceContainerNode()
|
||||
|
||||
self.avatarContainerNode = PeerInfoAvatarTransformContainerNode(context: context)
|
||||
@ -3678,29 +3678,35 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
private class DynamicIslandMaskNode: ManagedAnimationNode {
|
||||
var frameIndex: Int = 0
|
||||
private class DynamicIslandMaskNode: ASDisplayNode {
|
||||
private var animationNode: AnimationNode?
|
||||
|
||||
var isForum = false {
|
||||
didSet {
|
||||
if self.isForum != oldValue {
|
||||
self.update(frameIndex: self.frameIndex)
|
||||
self.animationNode?.removeFromSupernode()
|
||||
let animationNode = AnimationNode(animation: "ForumAvatarMask")
|
||||
self.addSubnode(animationNode)
|
||||
self.animationNode = animationNode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func update(_ value: CGFloat) {
|
||||
let lowerBound = 0
|
||||
let upperBound = 540
|
||||
let frameIndex = lowerBound + Int(value * CGFloat(upperBound - lowerBound))
|
||||
if frameIndex != self.frameIndex {
|
||||
self.update(frameIndex: frameIndex)
|
||||
}
|
||||
override init() {
|
||||
let animationNode = AnimationNode(animation: "UserAvatarMask")
|
||||
self.animationNode = animationNode
|
||||
|
||||
super.init()
|
||||
|
||||
self.addSubnode(animationNode)
|
||||
}
|
||||
|
||||
func update(frameIndex: Int) {
|
||||
self.frameIndex = frameIndex
|
||||
self.trackTo(item: ManagedAnimationItem(source: .local(self.isForum ? "ForumAvatarMask" : "UserAvatarMask"), frames: .range(startFrame: frameIndex, endFrame: frameIndex), duration: 0.001))
|
||||
func update(_ value: CGFloat) {
|
||||
self.animationNode?.setProgress(value)
|
||||
}
|
||||
|
||||
override func layout() {
|
||||
self.animationNode?.frame = self.bounds
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user