mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Merge commit 'a260717c8890ff2150e50b5a402650968aef5b14'
This commit is contained in:
commit
7e63102417
@ -12,22 +12,35 @@ protocol PasscodeBackground {
|
||||
var foregroundImage: UIImage? { get }
|
||||
|
||||
func makeBackgroundNode() -> ASDisplayNode?
|
||||
func makeForegroundNode(backgroundNode: ASDisplayNode?) -> ASDisplayNode?
|
||||
}
|
||||
|
||||
final class CustomPasscodeBackground: PasscodeBackground {
|
||||
private let colors: [UIColor]
|
||||
private let backgroundNode: GradientBackgroundNode
|
||||
let inverted: Bool
|
||||
|
||||
public private(set) var size: CGSize
|
||||
public private(set) var backgroundImage: UIImage? = nil
|
||||
public private(set) var foregroundImage: UIImage? = nil
|
||||
|
||||
init(size: CGSize, colors: [UIColor]) {
|
||||
init(size: CGSize, colors: [UIColor], inverted: Bool) {
|
||||
self.size = size
|
||||
self.colors = colors
|
||||
self.inverted = inverted
|
||||
self.backgroundNode = createGradientBackgroundNode(colors: self.colors)
|
||||
}
|
||||
|
||||
func makeBackgroundNode() -> ASDisplayNode? {
|
||||
return createGradientBackgroundNode(colors: self.colors)
|
||||
return self.backgroundNode
|
||||
}
|
||||
|
||||
func makeForegroundNode(backgroundNode: ASDisplayNode?) -> ASDisplayNode? {
|
||||
if self.inverted, let backgroundNode = backgroundNode as? GradientBackgroundNode {
|
||||
return GradientBackgroundNode.CloneNode(parentNode: backgroundNode)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,6 +73,10 @@ final class GradientPasscodeBackground: PasscodeBackground {
|
||||
func makeBackgroundNode() -> ASDisplayNode? {
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeForegroundNode(backgroundNode: ASDisplayNode?) -> ASDisplayNode? {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
final class ImageBasedPasscodeBackground: PasscodeBackground {
|
||||
@ -111,4 +128,8 @@ final class ImageBasedPasscodeBackground: PasscodeBackground {
|
||||
func makeBackgroundNode() -> ASDisplayNode? {
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeForegroundNode(backgroundNode: ASDisplayNode?) -> ASDisplayNode? {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
||||
}
|
||||
self.keyboardNode.backspace = { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.inputFieldNode.delete()
|
||||
let _ = strongSelf.inputFieldNode.delete()
|
||||
if let gradientNode = strongSelf.backgroundCustomNode as? GradientBackgroundNode {
|
||||
gradientNode.animateEvent(transition: .animated(duration: 0.55, curve: .spring), backwards: true)
|
||||
}
|
||||
@ -203,14 +203,40 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
switch self.wallpaper {
|
||||
case let .gradient(_, colors, _):
|
||||
self.background = CustomPasscodeBackground(size: size, colors: colors.compactMap { UIColor(rgb: $0) })
|
||||
case let .color(colorValue):
|
||||
let color = UIColor(argb: colorValue)
|
||||
let baseColor: UIColor
|
||||
let lightness = color.lightness
|
||||
if lightness < 0.1 || lightness > 0.9 {
|
||||
baseColor = self.theme.chat.message.outgoing.bubble.withoutWallpaper.fill
|
||||
} else{
|
||||
baseColor = color
|
||||
}
|
||||
|
||||
let color1: UIColor
|
||||
let color2: UIColor
|
||||
let color3: UIColor
|
||||
let color4: UIColor
|
||||
if self.theme.overallDarkAppearance {
|
||||
color1 = baseColor.withMultiplied(hue: 1.034, saturation: 0.819, brightness: 0.214)
|
||||
color2 = baseColor.withMultiplied(hue: 1.029, saturation: 0.77, brightness: 0.132)
|
||||
color3 = color1
|
||||
color4 = color2
|
||||
} else {
|
||||
color1 = baseColor.withMultiplied(hue: 1.029, saturation: 0.312, brightness: 1.26)
|
||||
color2 = baseColor.withMultiplied(hue: 1.034, saturation: 0.729, brightness: 0.942)
|
||||
color3 = baseColor.withMultiplied(hue: 1.029, saturation: 0.729, brightness: 1.231)
|
||||
color4 = baseColor.withMultiplied(hue: 1.034, saturation: 0.583, brightness: 1.043)
|
||||
}
|
||||
self.background = CustomPasscodeBackground(size: size, colors: [color1, color2, color3, color4], inverted: false)
|
||||
case let .gradient(_, colors, settings):
|
||||
self.background = CustomPasscodeBackground(size: size, colors: colors.compactMap { UIColor(rgb: $0) }, inverted: (settings.intensity ?? 0) < 0)
|
||||
case .image, .file:
|
||||
if let image = chatControllerBackgroundImage(theme: self.theme, wallpaper: self.wallpaper, mediaBox: self.accountManager.mediaBox, composed: false, knockoutMode: false) {
|
||||
self.background = ImageBasedPasscodeBackground(image: image, size: size)
|
||||
} else {
|
||||
if case let .file(file) = self.wallpaper, !file.settings.colors.isEmpty {
|
||||
self.background = CustomPasscodeBackground(size: size, colors: file.settings.colors.compactMap { UIColor(rgb: $0) })
|
||||
self.background = CustomPasscodeBackground(size: size, colors: file.settings.colors.compactMap { UIColor(rgb: $0) }, inverted: (file.settings.intensity ?? 0) < 0)
|
||||
} else {
|
||||
self.background = GradientPasscodeBackground(size: size, backgroundColors: self.theme.passcode.backgroundColors.colors, buttonColor: self.theme.passcode.buttonColor)
|
||||
}
|
||||
@ -229,6 +255,11 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
||||
} else if let customBackgroundNode = background.makeBackgroundNode() {
|
||||
self.backgroundCustomNode = customBackgroundNode
|
||||
self.insertSubnode(customBackgroundNode, aboveSubnode: self.backgroundImageNode)
|
||||
if let background = background as? CustomPasscodeBackground, background.inverted {
|
||||
self.backgroundDimNode.backgroundColor = UIColor(rgb: 0x000000, alpha: 0.75)
|
||||
} else {
|
||||
self.backgroundDimNode.backgroundColor = UIColor(rgb: 0x000000, alpha: 0.15)
|
||||
}
|
||||
self.backgroundDimNode.isHidden = false
|
||||
}
|
||||
self.keyboardNode.updateBackground(self.presentationData, background)
|
||||
@ -326,7 +357,7 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
||||
if let gradientNode = self.backgroundCustomNode as? GradientBackgroundNode {
|
||||
gradientNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
gradientNode.animateEvent(transition: .animated(duration: 0.35, curve: .spring))
|
||||
self.backgroundDimNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
self.backgroundDimNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
}
|
||||
if !iconFrame.isEmpty {
|
||||
self.iconNode.animateIn(fromScale: 0.416)
|
||||
|
@ -4,6 +4,7 @@ import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import GradientBackground
|
||||
|
||||
private let regularTitleFont = Font.regular(36.0)
|
||||
private let regularSubtitleFont: UIFont = {
|
||||
@ -110,6 +111,7 @@ final class PasscodeEntryButtonNode: HighlightTrackingButtonNode {
|
||||
private var highlightedImage: UIImage?
|
||||
|
||||
private var blurredBackgroundNode: NavigationBackgroundNode?
|
||||
private var gradientBackgroundNode: GradientBackgroundNode.CloneNode?
|
||||
private let backgroundNode: ASImageNode
|
||||
|
||||
var action: (() -> Void)?
|
||||
@ -121,11 +123,15 @@ final class PasscodeEntryButtonNode: HighlightTrackingButtonNode {
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
|
||||
if background is CustomPasscodeBackground {
|
||||
let blurredBackgroundColor = (selectDateFillStaticColor(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper), dateFillNeedsBlur(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper))
|
||||
|
||||
let blurredBackgroundNode = NavigationBackgroundNode(color: blurredBackgroundColor.0, enableBlur: blurredBackgroundColor.1)
|
||||
self.blurredBackgroundNode = blurredBackgroundNode
|
||||
if let background = background as? CustomPasscodeBackground {
|
||||
if false, background.inverted {
|
||||
let gradientBackgroundNode = background.makeForegroundNode(backgroundNode: background.makeBackgroundNode())
|
||||
self.gradientBackgroundNode = gradientBackgroundNode as? GradientBackgroundNode.CloneNode
|
||||
} else {
|
||||
let blurredBackgroundColor = (background.inverted ? UIColor(rgb: 0xffffff, alpha: 0.1) : UIColor(rgb: 0x000000, alpha: 0.2), dateFillNeedsBlur(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper))
|
||||
let blurredBackgroundNode = NavigationBackgroundNode(color: blurredBackgroundColor.0, enableBlur: blurredBackgroundColor.1)
|
||||
self.blurredBackgroundNode = blurredBackgroundNode
|
||||
}
|
||||
}
|
||||
|
||||
self.backgroundNode = ASImageNode()
|
||||
@ -135,6 +141,9 @@ final class PasscodeEntryButtonNode: HighlightTrackingButtonNode {
|
||||
|
||||
super.init()
|
||||
|
||||
if let gradientBackgroundNode = self.gradientBackgroundNode {
|
||||
self.addSubnode(gradientBackgroundNode)
|
||||
}
|
||||
if let blurredBackgroundNode = self.blurredBackgroundNode {
|
||||
self.addSubnode(blurredBackgroundNode)
|
||||
}
|
||||
@ -172,6 +181,12 @@ final class PasscodeEntryButtonNode: HighlightTrackingButtonNode {
|
||||
self.regularImage = generateButtonImage(background: self.background, frame: self.frame, title: self.title, subtitle: self.subtitle, highlighted: false)
|
||||
self.highlightedImage = generateButtonImage(background: self.background, frame: self.frame, title: self.title, subtitle: self.subtitle, highlighted: true)
|
||||
self.updateState(highlighted: self.isHighlighted)
|
||||
|
||||
if let gradientBackgroundNode = self.gradientBackgroundNode {
|
||||
let containerSize = self.background.size
|
||||
let shiftedContentsRect = CGRect(origin: CGPoint(x: self.frame.minX / containerSize.width, y: self.frame.minY / containerSize.height), size: CGSize(width: self.frame.width / containerSize.width, height: self.frame.height / containerSize.height))
|
||||
gradientBackgroundNode.layer.contentsRect = shiftedContentsRect
|
||||
}
|
||||
}
|
||||
|
||||
private func updateState(highlighted: Bool) {
|
||||
@ -192,6 +207,9 @@ final class PasscodeEntryButtonNode: HighlightTrackingButtonNode {
|
||||
override func layout() {
|
||||
super.layout()
|
||||
|
||||
if let gradientBackgroundNode = self.gradientBackgroundNode {
|
||||
gradientBackgroundNode.frame = self.bounds
|
||||
}
|
||||
if let blurredBackgroundNode = self.blurredBackgroundNode {
|
||||
blurredBackgroundNode.frame = self.bounds
|
||||
blurredBackgroundNode.update(size: blurredBackgroundNode.bounds.size, cornerRadius: blurredBackgroundNode.bounds.height / 2.0, transition: .immediate)
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"app": "7.8.3",
|
||||
"app": "7.9",
|
||||
"bazel": "4.0.0",
|
||||
"xcode": "12.4"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user