mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Tune wallpaper pattern scale on iPad
This commit is contained in:
parent
4f5e7548d9
commit
2adf8a010d
16 changed files with 139 additions and 70 deletions
|
|
@ -138,7 +138,7 @@ final class MetalWallpaperBackgroundNode: ASDisplayNode, WallpaperBackgroundNode
|
|||
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, tile: Bool, transition: ContainedViewLayoutTransition) {
|
||||
func updateLayout(size: CGSize, displayMode: WallpaperDisplayMode, transition: ContainedViewLayoutTransition) {
|
||||
if self.metalLayer.drawableSize != size {
|
||||
self.metalLayer.drawableSize = size
|
||||
|
||||
|
|
|
|||
|
|
@ -54,13 +54,30 @@ public protocol WallpaperBubbleBackgroundNode: ASDisplayNode {
|
|||
func offsetSpring(value: CGFloat, duration: Double, damping: CGFloat)
|
||||
}
|
||||
|
||||
public enum WallpaperDisplayMode {
|
||||
case aspectFill
|
||||
case aspectFit
|
||||
case halfAspectFill
|
||||
|
||||
var argumentsDisplayMode: PatternWallpaperArguments.DisplayMode {
|
||||
switch self {
|
||||
case .aspectFill:
|
||||
return .aspectFill
|
||||
case .aspectFit:
|
||||
return .aspectFit
|
||||
case .halfAspectFill:
|
||||
return .halfAspectFill
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public protocol WallpaperBackgroundNode: ASDisplayNode {
|
||||
var isReady: Signal<Bool, NoError> { get }
|
||||
var rotation: CGFloat { get set }
|
||||
|
||||
func update(wallpaper: TelegramWallpaper)
|
||||
func _internalUpdateIsSettingUpWallpaper()
|
||||
func updateLayout(size: CGSize, tile: Bool, transition: ContainedViewLayoutTransition)
|
||||
func updateLayout(size: CGSize, displayMode: WallpaperDisplayMode, transition: ContainedViewLayoutTransition)
|
||||
func updateIsLooping(_ isLooping: Bool)
|
||||
func animateEvent(transition: ContainedViewLayoutTransition, extendAnimation: Bool)
|
||||
func updateBubbleTheme(bubbleTheme: PresentationTheme, bubbleCorners: PresentationChatBubbleCorners)
|
||||
|
|
@ -599,7 +616,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
|
||||
private let bakedBackgroundView: UIImageView
|
||||
|
||||
private var validLayout: (CGSize, Bool)?
|
||||
private var validLayout: (CGSize, WallpaperDisplayMode)?
|
||||
private var wallpaper: TelegramWallpaper?
|
||||
private var isSettingUpWallpaper: Bool = false
|
||||
|
||||
|
|
@ -884,8 +901,8 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
}
|
||||
}
|
||||
|
||||
if let (size, tile) = self.validLayout {
|
||||
self.updateLayout(size: size, tile: tile, transition: .immediate)
|
||||
if let (size, displayMode) = self.validLayout {
|
||||
self.updateLayout(size: size, displayMode: displayMode, transition: .immediate)
|
||||
self.updateBubbles()
|
||||
|
||||
if scheduleLoopingEvent {
|
||||
|
|
@ -953,7 +970,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
}
|
||||
}
|
||||
|
||||
private func loadPatternForSizeIfNeeded(size: CGSize, tile: Bool, transition: ContainedViewLayoutTransition) {
|
||||
private func loadPatternForSizeIfNeeded(size: CGSize, displayMode: WallpaperDisplayMode, transition: ContainedViewLayoutTransition) {
|
||||
guard let wallpaper = self.wallpaper else {
|
||||
return
|
||||
}
|
||||
|
|
@ -1024,8 +1041,8 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
|
||||
strongSelf.validPatternImage = ValidPatternImage(wallpaper: wallpaper, invertPattern: invertPattern, generate: generator)
|
||||
strongSelf.validPatternGeneratedImage = nil
|
||||
if let (size, tile) = strongSelf.validLayout {
|
||||
strongSelf.loadPatternForSizeIfNeeded(size: size, tile: tile, transition: .immediate)
|
||||
if let (size, displayMode) = strongSelf.validLayout {
|
||||
strongSelf.loadPatternForSizeIfNeeded(size: size, displayMode: displayMode, transition: .immediate)
|
||||
} else {
|
||||
strongSelf._isReady.set(true)
|
||||
}
|
||||
|
|
@ -1067,7 +1084,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
self.patternImageLayer.suspendCompositionUpdates = false
|
||||
self.patternImageLayer.updateCompositionIfNeeded()
|
||||
} else {
|
||||
let patternArguments = TransformImageArguments(corners: ImageCorners(), imageSize: size, boundingSize: size, intrinsicInsets: UIEdgeInsets(), custom: PatternWallpaperArguments(colors: [patternBackgroundColor], rotation: nil, customPatternColor: patternColor, preview: false, tile: tile), scale: min(2.0, UIScreenScale))
|
||||
let patternArguments = TransformImageArguments(corners: ImageCorners(), imageSize: size, boundingSize: size, intrinsicInsets: UIEdgeInsets(), custom: PatternWallpaperArguments(colors: [patternBackgroundColor], rotation: nil, customPatternColor: patternColor, preview: false, displayMode: displayMode.argumentsDisplayMode), scale: min(2.0, UIScreenScale))
|
||||
if self.useSharedAnimationPhase || self.patternImageLayer.contents == nil {
|
||||
if let drawingContext = validPatternImage.generate(patternArguments) {
|
||||
if let image = drawingContext.generateImage() {
|
||||
|
|
@ -1121,9 +1138,9 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
transition.updateFrame(layer: self.patternImageLayer, frame: CGRect(origin: CGPoint(), size: size))
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, tile: Bool, transition: ContainedViewLayoutTransition) {
|
||||
func updateLayout(size: CGSize, displayMode: WallpaperDisplayMode, transition: ContainedViewLayoutTransition) {
|
||||
let isFirstLayout = self.validLayout == nil
|
||||
self.validLayout = (size, tile)
|
||||
self.validLayout = (size, displayMode)
|
||||
|
||||
if let blurredBackgroundPortalSourceView = self.blurredBackgroundPortalSourceView {
|
||||
transition.updateFrame(view: blurredBackgroundPortalSourceView, frame: CGRect(origin: CGPoint(), size: size))
|
||||
|
|
@ -1151,7 +1168,7 @@ final class WallpaperBackgroundNodeImpl: ASDisplayNode, WallpaperBackgroundNode
|
|||
outgoingBubbleGradientBackgroundNode.updateLayout(size: size, transition: transition, extendAnimation: false, backwards: false, completion: {})
|
||||
}
|
||||
|
||||
self.loadPatternForSizeIfNeeded(size: size, tile: tile, transition: transition)
|
||||
self.loadPatternForSizeIfNeeded(size: size, displayMode: displayMode, transition: transition)
|
||||
|
||||
/*for (animationNode, relativePosition) in self.inlineAnimationNodes {
|
||||
let sizeNorm = CGSize(width: 1440, height: 2960)
|
||||
|
|
@ -2021,7 +2038,7 @@ final class WallpaperBackgroundNodeMergedImpl: ASDisplayNode, WallpaperBackgroun
|
|||
self.isSettingUpWallpaper = true
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, tile: Bool, transition: ContainedViewLayoutTransition) {
|
||||
func updateLayout(size: CGSize, displayMode: WallpaperDisplayMode, transition: ContainedViewLayoutTransition) {
|
||||
self.validLayout = size
|
||||
|
||||
self.staticView.frame = CGRect(origin: CGPoint(), size: size)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue