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/AsyncDisplayKit:AsyncDisplayKit",
|
||||||
"//submodules/rlottie:RLottieBinding",
|
"//submodules/rlottie:RLottieBinding",
|
||||||
"//submodules/lottie-ios:Lottie",
|
"//submodules/lottie-ios:Lottie",
|
||||||
|
"//submodules/GZip:GZip",
|
||||||
"//submodules/AppBundle:AppBundle",
|
"//submodules/AppBundle:AppBundle",
|
||||||
"//submodules/Display:Display",
|
"//submodules/Display:Display",
|
||||||
],
|
],
|
||||||
|
@ -2,6 +2,7 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Lottie
|
import Lottie
|
||||||
|
import GZip
|
||||||
import AppBundle
|
import AppBundle
|
||||||
import Display
|
import Display
|
||||||
|
|
||||||
@ -32,7 +33,15 @@ public final class AnimationNode: ASDisplayNode {
|
|||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
self.setViewBlock({
|
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))
|
let view = AnimationView(animation: animation, configuration: LottieConfiguration(renderingEngine: .mainThread, decodingStrategy: .codable))
|
||||||
view.animationSpeed = self.speed
|
view.animationSpeed = self.speed
|
||||||
view.backgroundColor = .clear
|
view.backgroundColor = .clear
|
||||||
@ -104,6 +113,10 @@ public final class AnimationNode: ASDisplayNode {
|
|||||||
self.animationView()?.currentProgress = 1.0
|
self.animationView()?.currentProgress = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func setProgress(_ progress: CGFloat) {
|
||||||
|
self.animationView()?.currentProgress = progress
|
||||||
|
}
|
||||||
|
|
||||||
public func setAnimation(name: String, colors: [String: UIColor]? = nil) {
|
public func setAnimation(name: String, colors: [String: UIColor]? = nil) {
|
||||||
self.currentParams = (name, colors)
|
self.currentParams = (name, colors)
|
||||||
if let url = getAppBundle().url(forResource: name, withExtension: "json"), let animation = Animation.filepath(url.path) {
|
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`
|
case `default`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PresentationMode {
|
||||||
|
case `default`
|
||||||
|
case modal
|
||||||
|
}
|
||||||
|
|
||||||
public final class Environment: Equatable {
|
public final class Environment: Equatable {
|
||||||
public let statusBarHeight: CGFloat
|
public let statusBarHeight: CGFloat
|
||||||
public let navigationHeight: CGFloat
|
public let navigationHeight: CGFloat
|
||||||
@ -139,11 +144,6 @@ open class ViewControllerComponentContainer: ViewController {
|
|||||||
func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: Transition) {
|
func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: Transition) {
|
||||||
self.currentLayout = (layout, navigationHeight)
|
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(
|
let environment = ViewControllerComponentContainer.Environment(
|
||||||
statusBarHeight: layout.statusBarHeight ?? 0.0,
|
statusBarHeight: layout.statusBarHeight ?? 0.0,
|
||||||
navigationHeight: navigationHeight,
|
navigationHeight: navigationHeight,
|
||||||
@ -152,7 +152,7 @@ open class ViewControllerComponentContainer: ViewController {
|
|||||||
metrics: layout.metrics,
|
metrics: layout.metrics,
|
||||||
deviceMetrics: layout.deviceMetrics,
|
deviceMetrics: layout.deviceMetrics,
|
||||||
isVisible: self.currentIsVisible,
|
isVisible: self.currentIsVisible,
|
||||||
theme: theme,
|
theme: self.theme ?? self.presentationData.theme,
|
||||||
strings: self.presentationData.strings,
|
strings: self.presentationData.strings,
|
||||||
dateTimeFormat: self.presentationData.dateTimeFormat,
|
dateTimeFormat: self.presentationData.dateTimeFormat,
|
||||||
controller: { [weak self] in
|
controller: { [weak self] in
|
||||||
@ -203,7 +203,7 @@ open class ViewControllerComponentContainer: ViewController {
|
|||||||
private var presentationDataDisposable: Disposable?
|
private var presentationDataDisposable: Disposable?
|
||||||
public private(set) var validLayout: ContainerViewLayout?
|
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.context = context
|
||||||
self.component = AnyComponent(component)
|
self.component = AnyComponent(component)
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
@ -224,7 +224,12 @@ open class ViewControllerComponentContainer: ViewController {
|
|||||||
self.presentationDataDisposable = (self.context.sharedContext.presentationData
|
self.presentationDataDisposable = (self.context.sharedContext.presentationData
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
|
||||||
if let strongSelf = self {
|
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 {
|
switch statusBarStyle {
|
||||||
case .none:
|
case .none:
|
||||||
|
@ -1032,7 +1032,7 @@ public final class PremiumGiftScreen: ViewControllerComponentContainer, Attachme
|
|||||||
completion: { duration in
|
completion: { duration in
|
||||||
completionImpl?(duration)
|
completionImpl?(duration)
|
||||||
}
|
}
|
||||||
), navigationBarAppearance: .transparent)
|
), navigationBarAppearance: .transparent, presentationMode: .modal)
|
||||||
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
|
||||||
|
@ -1044,7 +1044,7 @@ final class PeerInfoAvatarListNode: ASDisplayNode {
|
|||||||
self.bottomCoverNode = ASDisplayNode()
|
self.bottomCoverNode = ASDisplayNode()
|
||||||
self.bottomCoverNode.backgroundColor = .black
|
self.bottomCoverNode.backgroundColor = .black
|
||||||
|
|
||||||
self.maskNode = DynamicIslandMaskNode(size: CGSize(width: 512.0, height: 512.0))
|
self.maskNode = DynamicIslandMaskNode()
|
||||||
self.pinchSourceNode = PinchSourceContainerNode()
|
self.pinchSourceNode = PinchSourceContainerNode()
|
||||||
|
|
||||||
self.avatarContainerNode = PeerInfoAvatarTransformContainerNode(context: context)
|
self.avatarContainerNode = PeerInfoAvatarTransformContainerNode(context: context)
|
||||||
@ -3678,29 +3678,35 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DynamicIslandMaskNode: ManagedAnimationNode {
|
private class DynamicIslandMaskNode: ASDisplayNode {
|
||||||
var frameIndex: Int = 0
|
private var animationNode: AnimationNode?
|
||||||
|
|
||||||
var isForum = false {
|
var isForum = false {
|
||||||
didSet {
|
didSet {
|
||||||
if self.isForum != oldValue {
|
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) {
|
override init() {
|
||||||
let lowerBound = 0
|
let animationNode = AnimationNode(animation: "UserAvatarMask")
|
||||||
let upperBound = 540
|
self.animationNode = animationNode
|
||||||
let frameIndex = lowerBound + Int(value * CGFloat(upperBound - lowerBound))
|
|
||||||
if frameIndex != self.frameIndex {
|
super.init()
|
||||||
self.update(frameIndex: frameIndex)
|
|
||||||
}
|
self.addSubnode(animationNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(frameIndex: Int) {
|
func update(_ value: CGFloat) {
|
||||||
self.frameIndex = frameIndex
|
self.animationNode?.setProgress(value)
|
||||||
self.trackTo(item: ManagedAnimationItem(source: .local(self.isForum ? "ForumAvatarMask" : "UserAvatarMask"), frames: .range(startFrame: frameIndex, endFrame: frameIndex), duration: 0.001))
|
}
|
||||||
|
|
||||||
|
override func layout() {
|
||||||
|
self.animationNode?.frame = self.bounds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user