mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
[WIP] Message effects
This commit is contained in:
parent
fe8c2d8c15
commit
7ef63a81df
43 changed files with 3050 additions and 704 deletions
|
|
@ -59,6 +59,8 @@ public protocol WallpaperBubbleBackgroundNode: ASDisplayNode {
|
|||
func update(rect: CGRect, within containerSize: CGSize, animator: ControlledTransitionAnimator)
|
||||
func offset(value: CGPoint, animationCurve: ContainedViewLayoutTransitionCurve, duration: Double)
|
||||
func offsetSpring(value: CGFloat, duration: Double, damping: CGFloat)
|
||||
|
||||
func reloadBindings()
|
||||
}
|
||||
|
||||
public enum WallpaperDisplayMode {
|
||||
|
|
@ -323,7 +325,7 @@ private final class EffectImageLayer: SimpleLayer, GradientBackgroundPatternOver
|
|||
}
|
||||
}
|
||||
|
||||
final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode {
|
||||
public final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode {
|
||||
final class BubbleBackgroundNodeImpl: ASDisplayNode, WallpaperBubbleBackgroundNode {
|
||||
var implicitContentUpdate: Bool = true
|
||||
|
||||
|
|
@ -631,6 +633,9 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
gradientWallpaperNode.layer.animateSpring(from: NSValue(cgPoint: scaledOffset), to: NSValue(cgPoint: CGPoint()), keyPath: "contentsRect.position", duration: duration, initialVelocity: 0.0, damping: damping, additive: true)
|
||||
}
|
||||
}
|
||||
|
||||
func reloadBindings() {
|
||||
}
|
||||
}
|
||||
|
||||
final class BubbleBackgroundPortalNodeImpl: ASDisplayNode, WallpaperBubbleBackgroundNode {
|
||||
|
|
@ -679,6 +684,10 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
|
||||
func offsetSpring(value: CGFloat, duration: Double, damping: CGFloat) {
|
||||
}
|
||||
|
||||
func reloadBindings() {
|
||||
self.portalView.reloadPortal()
|
||||
}
|
||||
}
|
||||
|
||||
private final class BubbleBackgroundNodeReference {
|
||||
|
|
@ -812,7 +821,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
}
|
||||
}
|
||||
|
||||
var rotation: CGFloat = 0.0 {
|
||||
public var rotation: CGFloat = 0.0 {
|
||||
didSet {
|
||||
var fromValue: CGFloat = 0.0
|
||||
if let value = (self.layer.value(forKeyPath: "transform.rotation.z") as? NSNumber)?.floatValue {
|
||||
|
|
@ -845,7 +854,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
private static var cachedSharedPattern: (PatternKey, UIImage)?
|
||||
|
||||
private let _isReady = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||
var isReady: Signal<Bool, NoError> {
|
||||
public var isReady: Signal<Bool, NoError> {
|
||||
return self._isReady.get()
|
||||
}
|
||||
|
||||
|
|
@ -920,7 +929,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
self.dimLayer.opacity = dimAlpha
|
||||
}
|
||||
|
||||
func update(wallpaper: TelegramWallpaper, animated: Bool) {
|
||||
public func update(wallpaper: TelegramWallpaper, animated: Bool) {
|
||||
if self.wallpaper == wallpaper {
|
||||
return
|
||||
}
|
||||
|
|
@ -1074,7 +1083,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
self.updateDimming()
|
||||
}
|
||||
|
||||
func _internalUpdateIsSettingUpWallpaper() {
|
||||
public func _internalUpdateIsSettingUpWallpaper() {
|
||||
self.isSettingUpWallpaper = true
|
||||
}
|
||||
|
||||
|
|
@ -1301,7 +1310,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
transition.updateFrame(layer: self.patternImageLayer, frame: CGRect(origin: CGPoint(), size: size))
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, displayMode: WallpaperDisplayMode, transition: ContainedViewLayoutTransition) {
|
||||
public func updateLayout(size: CGSize, displayMode: WallpaperDisplayMode, transition: ContainedViewLayoutTransition) {
|
||||
let isFirstLayout = self.validLayout == nil
|
||||
self.validLayout = (size, displayMode)
|
||||
|
||||
|
|
@ -1357,7 +1366,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
private var isAnimating = false
|
||||
private var isLooping = false
|
||||
|
||||
func animateEvent(transition: ContainedViewLayoutTransition, extendAnimation: Bool) {
|
||||
public func animateEvent(transition: ContainedViewLayoutTransition, extendAnimation: Bool) {
|
||||
guard !(self.isLooping && self.isAnimating) else {
|
||||
return
|
||||
}
|
||||
|
|
@ -1373,7 +1382,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
self.outgoingBubbleGradientBackgroundNode?.animateEvent(transition: transition, extendAnimation: extendAnimation, backwards: false, completion: {})
|
||||
}
|
||||
|
||||
func updateIsLooping(_ isLooping: Bool) {
|
||||
public func updateIsLooping(_ isLooping: Bool) {
|
||||
let wasLooping = self.isLooping
|
||||
self.isLooping = isLooping
|
||||
|
||||
|
|
@ -1382,7 +1391,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
}
|
||||
}
|
||||
|
||||
func updateBubbleTheme(bubbleTheme: PresentationTheme, bubbleCorners: PresentationChatBubbleCorners) {
|
||||
public func updateBubbleTheme(bubbleTheme: PresentationTheme, bubbleCorners: PresentationChatBubbleCorners) {
|
||||
if self.bubbleTheme !== bubbleTheme || self.bubbleCorners != bubbleCorners {
|
||||
self.bubbleTheme = bubbleTheme
|
||||
self.bubbleCorners = bubbleCorners
|
||||
|
|
@ -1430,7 +1439,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
}
|
||||
}
|
||||
|
||||
func hasBubbleBackground(for type: WallpaperBubbleType) -> Bool {
|
||||
public func hasBubbleBackground(for type: WallpaperBubbleType) -> Bool {
|
||||
guard let bubbleTheme = self.bubbleTheme, let bubbleCorners = self.bubbleCorners else {
|
||||
return false
|
||||
}
|
||||
|
|
@ -1474,13 +1483,18 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
public func makeLegacyBubbleBackground(for type: WallpaperBubbleType) -> WallpaperBubbleBackgroundNode? {
|
||||
let node = WallpaperBackgroundNodeImpl.BubbleBackgroundNodeImpl(backgroundNode: self, bubbleType: type)
|
||||
node.updateContents()
|
||||
return node
|
||||
}
|
||||
|
||||
func makeBubbleBackground(for type: WallpaperBubbleType) -> WallpaperBubbleBackgroundNode? {
|
||||
public func makeBubbleBackground(for type: WallpaperBubbleType) -> WallpaperBubbleBackgroundNode? {
|
||||
if !self.hasBubbleBackground(for: type) {
|
||||
return nil
|
||||
}
|
||||
|
||||
#if true
|
||||
var sourceView: PortalSourceView?
|
||||
switch type {
|
||||
case .free:
|
||||
|
|
@ -1499,14 +1513,9 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
let node = WallpaperBackgroundNodeImpl.BubbleBackgroundNodeImpl(backgroundNode: self, bubbleType: type)
|
||||
return node
|
||||
}
|
||||
#else
|
||||
let node = WallpaperBackgroundNodeImpl.BubbleBackgroundNodeImpl(backgroundNode: self, bubbleType: type)
|
||||
node.updateContents()
|
||||
return node
|
||||
#endif
|
||||
}
|
||||
|
||||
func makeFreeBackground() -> PortalView? {
|
||||
public func makeFreeBackground() -> PortalView? {
|
||||
if !self.hasBubbleBackground(for: .free) {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1519,7 +1528,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
}
|
||||
}
|
||||
|
||||
func hasExtraBubbleBackground() -> Bool {
|
||||
public func hasExtraBubbleBackground() -> Bool {
|
||||
var isInvertedGradient = false
|
||||
switch self.wallpaper {
|
||||
case let .file(file):
|
||||
|
|
@ -1532,7 +1541,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
return isInvertedGradient
|
||||
}
|
||||
|
||||
func makeDimmedNode() -> ASDisplayNode? {
|
||||
public func makeDimmedNode() -> ASDisplayNode? {
|
||||
if let gradientBackgroundNode = self.gradientBackgroundNode {
|
||||
return GradientBackgroundNode.CloneNode(parentNode: gradientBackgroundNode)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue