mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Theme updates
This commit is contained in:
parent
b11b306c30
commit
154c74a607
@ -38,7 +38,7 @@ open class GalleryControllerNode: ASDisplayNode, UIScrollViewDelegate, UIGesture
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(controllerInteraction: GalleryControllerInteraction, pageGap: CGFloat = 20.0) {
|
public init(controllerInteraction: GalleryControllerInteraction, pageGap: CGFloat = 20.0, disableTapNavigation: Bool = false) {
|
||||||
self.backgroundNode = ASDisplayNode()
|
self.backgroundNode = ASDisplayNode()
|
||||||
self.backgroundNode.backgroundColor = UIColor.black
|
self.backgroundNode.backgroundColor = UIColor.black
|
||||||
self.scrollView = UIScrollView()
|
self.scrollView = UIScrollView()
|
||||||
@ -48,7 +48,7 @@ open class GalleryControllerNode: ASDisplayNode, UIScrollViewDelegate, UIGesture
|
|||||||
self.scrollView.contentInsetAdjustmentBehavior = .never
|
self.scrollView.contentInsetAdjustmentBehavior = .never
|
||||||
}
|
}
|
||||||
|
|
||||||
self.pager = GalleryPagerNode(pageGap: pageGap)
|
self.pager = GalleryPagerNode(pageGap: pageGap, disableTapNavigation: disableTapNavigation)
|
||||||
self.footerNode = GalleryFooterNode(controllerInteraction: controllerInteraction)
|
self.footerNode = GalleryFooterNode(controllerInteraction: controllerInteraction)
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
@ -78,6 +78,7 @@ public struct GalleryPagerTransaction {
|
|||||||
|
|
||||||
public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
|
public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
|
||||||
private let pageGap: CGFloat
|
private let pageGap: CGFloat
|
||||||
|
private let disableTapNavigation: Bool
|
||||||
|
|
||||||
private let scrollView: UIScrollView
|
private let scrollView: UIScrollView
|
||||||
|
|
||||||
@ -111,8 +112,10 @@ public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate, UIGest
|
|||||||
public var completeCustomDismiss: () -> Void = { }
|
public var completeCustomDismiss: () -> Void = { }
|
||||||
public var baseNavigationController: () -> NavigationController? = { return nil }
|
public var baseNavigationController: () -> NavigationController? = { return nil }
|
||||||
|
|
||||||
public init(pageGap: CGFloat) {
|
public init(pageGap: CGFloat, disableTapNavigation: Bool) {
|
||||||
self.pageGap = pageGap
|
self.pageGap = pageGap
|
||||||
|
self.disableTapNavigation = disableTapNavigation
|
||||||
|
|
||||||
self.scrollView = UIScrollView()
|
self.scrollView = UIScrollView()
|
||||||
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
|
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
|
||||||
self.scrollView.contentInsetAdjustmentBehavior = .never
|
self.scrollView.contentInsetAdjustmentBehavior = .never
|
||||||
@ -434,6 +437,9 @@ public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate, UIGest
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func canGoToPreviousItem() -> Bool {
|
private func canGoToPreviousItem() -> Bool {
|
||||||
|
if self.disableTapNavigation {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if let index = self.centralItemIndex, index > 0 {
|
if let index = self.centralItemIndex, index > 0 {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
@ -442,6 +448,9 @@ public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate, UIGest
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func canGoToNextItem() -> Bool {
|
private func canGoToNextItem() -> Bool {
|
||||||
|
if self.disableTapNavigation {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if let index = self.centralItemIndex, index < self.items.count - 1 {
|
if let index = self.centralItemIndex, index < self.items.count - 1 {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,6 +3,6 @@ import UIKit
|
|||||||
import Display
|
import Display
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
|
|
||||||
public func createGradientBackgroundNode() -> GradientBackgroundNode {
|
public func createGradientBackgroundNode(useSharedAnimationPhase: Bool = false) -> GradientBackgroundNode {
|
||||||
return GradientBackgroundNode()
|
return GradientBackgroundNode(useSharedAnimationPhase: useSharedAnimationPhase)
|
||||||
}
|
}
|
||||||
|
@ -180,15 +180,23 @@ public final class GradientBackgroundNode: ASDisplayNode {
|
|||||||
|
|
||||||
private let cloneNodes = SparseBag<Weak<CloneNode>>()
|
private let cloneNodes = SparseBag<Weak<CloneNode>>()
|
||||||
|
|
||||||
override public init() {
|
private let useSharedAnimationPhase: Bool
|
||||||
|
static var sharedPhase: Int = 0
|
||||||
|
|
||||||
|
public init(useSharedAnimationPhase: Bool = false) {
|
||||||
|
self.useSharedAnimationPhase = useSharedAnimationPhase
|
||||||
self.contentView = UIImageView()
|
self.contentView = UIImageView()
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
self.view.addSubview(self.contentView)
|
self.view.addSubview(self.contentView)
|
||||||
|
|
||||||
|
if useSharedAnimationPhase {
|
||||||
|
self.phase = GradientBackgroundNode.sharedPhase
|
||||||
|
} else {
|
||||||
self.phase = 0
|
self.phase = 0
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
}
|
}
|
||||||
@ -280,6 +288,9 @@ public final class GradientBackgroundNode: ASDisplayNode {
|
|||||||
} else {
|
} else {
|
||||||
self.phase = self.phase - 1
|
self.phase = self.phase - 1
|
||||||
}
|
}
|
||||||
|
if self.useSharedAnimationPhase {
|
||||||
|
GradientBackgroundNode.sharedPhase = self.phase
|
||||||
|
}
|
||||||
if let size = self.validLayout {
|
if let size = self.validLayout {
|
||||||
self.updateLayout(size: size, transition: transition)
|
self.updateLayout(size: size, transition: transition)
|
||||||
}
|
}
|
||||||
|
@ -147,34 +147,31 @@ public final class CachedPatternWallpaperMaskRepresentation: CachedMediaResource
|
|||||||
public final class CachedPatternWallpaperRepresentation: CachedMediaResourceRepresentation {
|
public final class CachedPatternWallpaperRepresentation: CachedMediaResourceRepresentation {
|
||||||
public let keepDuration: CachedMediaRepresentationKeepDuration = .general
|
public let keepDuration: CachedMediaRepresentationKeepDuration = .general
|
||||||
|
|
||||||
public let color: UInt32
|
public let colors: [UInt32]
|
||||||
public let bottomColor: UInt32?
|
|
||||||
public let intensity: Int32
|
public let intensity: Int32
|
||||||
public let rotation: Int32?
|
public let rotation: Int32?
|
||||||
|
|
||||||
public var uniqueId: String {
|
public var uniqueId: String {
|
||||||
var id: String
|
var id: String = "pattern-wallpaper"
|
||||||
if let bottomColor = self.bottomColor {
|
for color in self.colors {
|
||||||
id = "pattern-wallpaper-\(self.color)-\(bottomColor)-\(self.intensity)"
|
id.append("-\(color)")
|
||||||
} else {
|
|
||||||
id = "pattern-wallpaper-\(self.color)-\(self.intensity)"
|
|
||||||
}
|
}
|
||||||
|
id.append("-\(self.intensity)")
|
||||||
if let rotation = self.rotation, rotation != 0 {
|
if let rotation = self.rotation, rotation != 0 {
|
||||||
id += "-\(rotation)deg"
|
id += "-\(rotation)deg"
|
||||||
}
|
}
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(color: UInt32, bottomColor: UInt32?, intensity: Int32, rotation: Int32?) {
|
public init(colors: [UInt32], intensity: Int32, rotation: Int32?) {
|
||||||
self.color = color
|
self.colors = colors
|
||||||
self.bottomColor = bottomColor
|
|
||||||
self.intensity = intensity
|
self.intensity = intensity
|
||||||
self.rotation = rotation
|
self.rotation = rotation
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to: CachedMediaResourceRepresentation) -> Bool {
|
public func isEqual(to: CachedMediaResourceRepresentation) -> Bool {
|
||||||
if let to = to as? CachedPatternWallpaperRepresentation {
|
if let to = to as? CachedPatternWallpaperRepresentation {
|
||||||
return self.color == to.color && self.bottomColor == to.bottomColor && self.intensity == intensity && self.rotation == to.rotation
|
return self.colors == to.colors && self.intensity == intensity && self.rotation == to.rotation
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll
|
|||||||
let prepare: Signal<CreateThemeResult, CreateThemeError>
|
let prepare: Signal<CreateThemeResult, CreateThemeError>
|
||||||
if let resolvedWallpaper = resolvedWallpaper, case let .file(file) = resolvedWallpaper, resolvedWallpaper.isPattern {
|
if let resolvedWallpaper = resolvedWallpaper, case let .file(file) = resolvedWallpaper, resolvedWallpaper.isPattern {
|
||||||
let resource = file.file.resource
|
let resource = file.file.resource
|
||||||
let representation = CachedPatternWallpaperRepresentation(color: file.settings.colors.count >= 1 ? file.settings.colors[0] : 0xd6e2ee, bottomColor: file.settings.colors.count >= 2 ? file.settings.colors[1] : file.settings.colors[0], intensity: file.settings.intensity ?? 50, rotation: file.settings.rotation)
|
let representation = CachedPatternWallpaperRepresentation(colors: file.settings.colors.count >= 1 ? file.settings.colors : [0xd6e2ee], intensity: file.settings.intensity ?? 50, rotation: file.settings.rotation)
|
||||||
|
|
||||||
var data: Data?
|
var data: Data?
|
||||||
if let path = context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
if let path = context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||||
|
@ -173,7 +173,7 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
let prepareWallpaper: Signal<CreateThemeResult, CreateThemeError>
|
let prepareWallpaper: Signal<CreateThemeResult, CreateThemeError>
|
||||||
if let patternWallpaper = state.patternWallpaper, case let .file(file) = patternWallpaper, !state.backgroundColors.isEmpty {
|
if let patternWallpaper = state.patternWallpaper, case let .file(file) = patternWallpaper, !state.backgroundColors.isEmpty {
|
||||||
let resource = file.file.resource
|
let resource = file.file.resource
|
||||||
let representation = CachedPatternWallpaperRepresentation(color: state.backgroundColors.count >= 1 ? state.backgroundColors[0] : 0, bottomColor: state.backgroundColors.count >= 2 ? state.backgroundColors[1] : 0, intensity: state.patternIntensity, rotation: state.rotation)
|
let representation = CachedPatternWallpaperRepresentation(colors: state.backgroundColors.count >= 1 ? state.backgroundColors : [0], intensity: state.patternIntensity, rotation: state.rotation)
|
||||||
|
|
||||||
var data: Data?
|
var data: Data?
|
||||||
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||||
@ -455,12 +455,14 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
let themeSpecificAccentColor = settings.themeSpecificAccentColors[themeReference.index]
|
let themeSpecificAccentColor = settings.themeSpecificAccentColors[themeReference.index]
|
||||||
accentColor = themeSpecificAccentColor?.color ?? defaultDayAccentColor
|
accentColor = themeSpecificAccentColor?.color ?? defaultDayAccentColor
|
||||||
|
|
||||||
|
var referenceTheme: PresentationTheme?
|
||||||
if let accentColor = themeSpecificAccentColor, let customWallpaper = settings.themeSpecificChatWallpapers[coloredThemeIndex(reference: themeReference, accentColor: accentColor)] {
|
if let accentColor = themeSpecificAccentColor, let customWallpaper = settings.themeSpecificChatWallpapers[coloredThemeIndex(reference: themeReference, accentColor: accentColor)] {
|
||||||
wallpaper = customWallpaper
|
wallpaper = customWallpaper
|
||||||
} else if let customWallpaper = settings.themeSpecificChatWallpapers[themeReference.index] {
|
} else if let customWallpaper = settings.themeSpecificChatWallpapers[themeReference.index] {
|
||||||
wallpaper = customWallpaper
|
wallpaper = customWallpaper
|
||||||
} else {
|
} else {
|
||||||
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: themeSpecificAccentColor?.color, wallpaper: themeSpecificAccentColor?.wallpaper) ?? defaultPresentationTheme
|
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: themeSpecificAccentColor?.color, wallpaper: themeSpecificAccentColor?.wallpaper) ?? defaultPresentationTheme
|
||||||
|
referenceTheme = theme
|
||||||
wallpaper = theme.chat.defaultWallpaper
|
wallpaper = theme.chat.defaultWallpaper
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,6 +487,8 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
} else {
|
} else {
|
||||||
if let themeReference = strongSelf.mode.themeReference, themeReference == .builtin(.dayClassic), settings.themeSpecificAccentColors[themeReference.index] == nil {
|
if let themeReference = strongSelf.mode.themeReference, themeReference == .builtin(.dayClassic), settings.themeSpecificAccentColors[themeReference.index] == nil {
|
||||||
messageColors = (UIColor(rgb: 0xe1ffc7), nil)
|
messageColors = (UIColor(rgb: 0xe1ffc7), nil)
|
||||||
|
} else if let referenceTheme = referenceTheme {
|
||||||
|
messageColors = (referenceTheme.chat.message.outgoing.bubble.withoutWallpaper.fill, referenceTheme.chat.message.outgoing.bubble.withoutWallpaper.gradientFill)
|
||||||
} else {
|
} else {
|
||||||
messageColors = nil
|
messageColors = nil
|
||||||
}
|
}
|
||||||
|
@ -1240,7 +1240,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
|||||||
|> mapToSignal { cachedWallpaper in
|
|> mapToSignal { cachedWallpaper in
|
||||||
if let wallpaper = cachedWallpaper?.wallpaper, case let .file(file) = wallpaper {
|
if let wallpaper = cachedWallpaper?.wallpaper, case let .file(file) = wallpaper {
|
||||||
let resource = file.file.resource
|
let resource = file.file.resource
|
||||||
let representation = CachedPatternWallpaperRepresentation(color: file.settings.colors.count >= 1 ? file.settings.colors[0] : 0xd6e2ee, bottomColor: file.settings.colors.count >= 2 ? file.settings.colors[1] : 0xd6e2ee, intensity: file.settings.intensity ?? 50, rotation: file.settings.rotation)
|
let representation = CachedPatternWallpaperRepresentation(colors: file.settings.colors.count >= 1 ? file.settings.colors : [0xd6e2ee], intensity: file.settings.intensity ?? 50, rotation: file.settings.rotation)
|
||||||
|
|
||||||
let _ = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, reference: .wallpaper(wallpaper: .slug(file.slug), resource: file.file.resource)).start()
|
let _ = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, reference: .wallpaper(wallpaper: .slug(file.slug), resource: file.file.resource)).start()
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ public class WallpaperGalleryController: ViewController {
|
|||||||
}, replaceRootController: { controller, ready in
|
}, replaceRootController: { controller, ready in
|
||||||
}, editMedia: { _ in
|
}, editMedia: { _ in
|
||||||
})
|
})
|
||||||
self.displayNode = WallpaperGalleryControllerNode(controllerInteraction: controllerInteraction, pageGap: 0.0)
|
self.displayNode = WallpaperGalleryControllerNode(controllerInteraction: controllerInteraction, pageGap: 0.0, disableTapNavigation: true)
|
||||||
self.displayNodeDidLoad()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
(self.displayNode as? WallpaperGalleryControllerNode)?.nativeStatusBar = self.statusBar
|
(self.displayNode as? WallpaperGalleryControllerNode)?.nativeStatusBar = self.statusBar
|
||||||
@ -498,7 +498,7 @@ public class WallpaperGalleryController: ViewController {
|
|||||||
}
|
}
|
||||||
} else if case let .file(file) = wallpaper, let resource = resource {
|
} else if case let .file(file) = wallpaper, let resource = resource {
|
||||||
if wallpaper.isPattern, !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
if wallpaper.isPattern, !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
||||||
let representation = CachedPatternWallpaperRepresentation(color: file.settings.colors[0], bottomColor: file.settings.colors.count >= 2 ? file.settings.colors[1] : file.settings.colors[0], intensity: intensity, rotation: file.settings.rotation)
|
let representation = CachedPatternWallpaperRepresentation(colors: file.settings.colors, intensity: intensity, rotation: file.settings.rotation)
|
||||||
|
|
||||||
var data: Data?
|
var data: Data?
|
||||||
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||||
@ -671,14 +671,23 @@ public class WallpaperGalleryController: ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let entry = self.currentEntry(), case let .wallpaper(wallpaper, _) = entry, case let .file(_, _, _, _, true, _, _, _ , settings) = wallpaper, !settings.colors.isEmpty {
|
if let entry = self.currentEntry(), case let .wallpaper(wallpaper, _) = entry, case let .file(_, _, _, _, true, _, _, _ , settings) = wallpaper, !settings.colors.isEmpty {
|
||||||
if self.patternPanelNode?.backgroundColors != nil, let snapshotView = self.patternPanelNode?.scrollNode.view.snapshotContentTree() {
|
/*if self.patternPanelNode?.backgroundColors != nil, let snapshotView = self.patternPanelNode?.scrollNode.view.snapshotContentTree() {
|
||||||
self.patternPanelNode?.view.addSubview(snapshotView)
|
self.patternPanelNode?.view.addSubview(snapshotView)
|
||||||
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false) { [weak snapshotView] _ in
|
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false) { [weak snapshotView] _ in
|
||||||
snapshotView?.removeFromSuperview()
|
snapshotView?.removeFromSuperview()
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
//self.patternPanelNode?.backgroundColors = ([settings.colors[0]], nil)
|
//self.patternPanelNode?.backgroundColors = ([settings.colors[0]], nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.colorsPanelEnabled || self.patternPanelEnabled {
|
||||||
|
self.colorsPanelEnabled = false
|
||||||
|
self.patternPanelEnabled = false
|
||||||
|
|
||||||
|
if let (layout, _) = self.validLayout {
|
||||||
|
self.containerLayoutUpdated(layout, transition: .animated(duration: 0.3, curve: .spring))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,9 +284,10 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
|
|
||||||
switch entry {
|
switch entry {
|
||||||
case let .wallpaper(wallpaper, _):
|
case let .wallpaper(wallpaper, _):
|
||||||
|
self.nativeNode.update(wallpaper: wallpaper)
|
||||||
|
|
||||||
if case let .file(_, _, _, _, isPattern, _, _, _, settings) = wallpaper, isPattern {
|
if case let .file(_, _, _, _, isPattern, _, _, _, settings) = wallpaper, isPattern {
|
||||||
self.nativeNode.isHidden = false
|
self.nativeNode.isHidden = false
|
||||||
self.nativeNode.update(wallpaper: wallpaper)
|
|
||||||
self.patternButtonNode.isSelected = isPattern
|
self.patternButtonNode.isSelected = isPattern
|
||||||
|
|
||||||
if isPattern && settings.colors.count >= 3 {
|
if isPattern && settings.colors.count >= 3 {
|
||||||
@ -629,13 +630,13 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
}))
|
}))
|
||||||
} else if self.arguments.patternEnabled != previousArguments.patternEnabled {
|
} else if self.arguments.patternEnabled != previousArguments.patternEnabled {
|
||||||
self.patternButtonNode.isSelected = self.arguments.patternEnabled
|
self.patternButtonNode.isSelected = self.arguments.patternEnabled
|
||||||
|
}
|
||||||
|
|
||||||
if let (layout, _) = self.validLayout {
|
if let (layout, _) = self.validLayout {
|
||||||
self.updateButtonsLayout(layout: layout, offset: CGPoint(), transition: .immediate)
|
self.updateButtonsLayout(layout: layout, offset: CGPoint(), transition: .immediate)
|
||||||
self.updateMessagesLayout(layout: layout, offset: CGPoint(), transition: .immediate)
|
self.updateMessagesLayout(layout: layout, offset: CGPoint(), transition: .immediate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override func screenFrameUpdated(_ frame: CGRect) {
|
override func screenFrameUpdated(_ frame: CGRect) {
|
||||||
let offset = -frame.minX
|
let offset = -frame.minX
|
||||||
@ -949,9 +950,8 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
motionAlpha = 0.0
|
motionAlpha = 0.0
|
||||||
patternAlpha = 1.0
|
patternAlpha = 1.0
|
||||||
|
|
||||||
patternFrame = leftButtonFrame.offsetBy(dx: -centerOffset, dy: 0.0)
|
patternFrame = leftButtonFrame
|
||||||
colorsFrame = colorsFrame.offsetBy(dx: centerOffset, dy: 0.0)
|
playAlpha = 0.0
|
||||||
playAlpha = 1.0
|
|
||||||
|
|
||||||
colorsAlpha = 1.0
|
colorsAlpha = 1.0
|
||||||
case .image:
|
case .image:
|
||||||
@ -959,13 +959,18 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
blurFrame = leftButtonFrame
|
blurFrame = leftButtonFrame
|
||||||
motionAlpha = 1.0
|
motionAlpha = 1.0
|
||||||
motionFrame = rightButtonFrame
|
motionFrame = rightButtonFrame
|
||||||
case .gradient:
|
case let .gradient(colors, _):
|
||||||
motionAlpha = 0.0
|
motionAlpha = 0.0
|
||||||
patternAlpha = 1.0
|
patternAlpha = 1.0
|
||||||
|
|
||||||
|
if colors.count >= 2 {
|
||||||
|
playAlpha = 1.0
|
||||||
patternFrame = leftButtonFrame.offsetBy(dx: -centerOffset, dy: 0.0)
|
patternFrame = leftButtonFrame.offsetBy(dx: -centerOffset, dy: 0.0)
|
||||||
colorsFrame = colorsFrame.offsetBy(dx: centerOffset, dy: 0.0)
|
colorsFrame = colorsFrame.offsetBy(dx: centerOffset, dy: 0.0)
|
||||||
playAlpha = 1.0
|
} else {
|
||||||
|
playAlpha = 0.0
|
||||||
|
patternFrame = leftButtonFrame
|
||||||
|
}
|
||||||
|
|
||||||
colorsAlpha = 1.0
|
colorsAlpha = 1.0
|
||||||
case let .file(file):
|
case let .file(file):
|
||||||
@ -973,9 +978,14 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
motionAlpha = 0.0
|
motionAlpha = 0.0
|
||||||
patternAlpha = 1.0
|
patternAlpha = 1.0
|
||||||
|
|
||||||
|
if file.settings.colors.count >= 2 {
|
||||||
|
playAlpha = 1.0
|
||||||
patternFrame = leftButtonFrame.offsetBy(dx: -centerOffset, dy: 0.0)
|
patternFrame = leftButtonFrame.offsetBy(dx: -centerOffset, dy: 0.0)
|
||||||
colorsFrame = colorsFrame.offsetBy(dx: centerOffset, dy: 0.0)
|
colorsFrame = colorsFrame.offsetBy(dx: centerOffset, dy: 0.0)
|
||||||
playAlpha = 1.0
|
} else {
|
||||||
|
playAlpha = 0.0
|
||||||
|
patternFrame = leftButtonFrame
|
||||||
|
}
|
||||||
|
|
||||||
colorsAlpha = 1.0
|
colorsAlpha = 1.0
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,7 +75,7 @@ public func chatControllerBackgroundImage(theme: PresentationTheme?, wallpaper i
|
|||||||
case let .file(file):
|
case let .file(file):
|
||||||
if wallpaper.isPattern, !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
if wallpaper.isPattern, !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
||||||
var image: UIImage?
|
var image: UIImage?
|
||||||
let _ = mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(color: file.settings.colors[0], bottomColor: file.settings.colors.count >= 2 ? file.settings.colors[1] : file.settings.colors[0], intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true, attemptSynchronously: true).start(next: { data in
|
let _ = mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(colors: file.settings.colors, intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true, attemptSynchronously: true).start(next: { data in
|
||||||
if data.complete {
|
if data.complete {
|
||||||
image = UIImage(contentsOfFile: data.path)?.precomposed()
|
image = UIImage(contentsOfFile: data.path)?.precomposed()
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ public func chatControllerBackgroundImageSignal(wallpaper: TelegramWallpaper, me
|
|||||||
}
|
}
|
||||||
case let .file(file):
|
case let .file(file):
|
||||||
if wallpaper.isPattern, !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
if wallpaper.isPattern, !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
||||||
let representation = CachedPatternWallpaperRepresentation(color: file.settings.colors.count >= 1 ? file.settings.colors[0] : 0, bottomColor: file.settings.colors.count >= 2 ? file.settings.colors[1] : 0, intensity: intensity, rotation: file.settings.rotation)
|
let representation = CachedPatternWallpaperRepresentation(colors: file.settings.colors, intensity: intensity, rotation: file.settings.rotation)
|
||||||
|
|
||||||
let effectiveMediaBox: MediaBox
|
let effectiveMediaBox: MediaBox
|
||||||
if FileManager.default.fileExists(atPath: mediaBox.cachedRepresentationCompletePath(file.file.resource.id, representation: representation)) {
|
if FileManager.default.fileExists(atPath: mediaBox.cachedRepresentationCompletePath(file.file.resource.id, representation: representation)) {
|
||||||
@ -214,7 +214,7 @@ public func chatControllerBackgroundImageSignal(wallpaper: TelegramWallpaper, me
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return .single((interrimImage, false)) |> then(effectiveMediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(color: file.settings.colors[0], bottomColor: file.settings.colors.count >= 1 ? file.settings.colors[1] : file.settings.colors[0], intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true, attemptSynchronously: false)
|
return .single((interrimImage, false)) |> then(effectiveMediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(colors: file.settings.colors, intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true, attemptSynchronously: false)
|
||||||
|> map { data -> (UIImage?, Bool)? in
|
|> map { data -> (UIImage?, Bool)? in
|
||||||
return (UIImage(contentsOfFile: data.path)?.precomposed(), true)
|
return (UIImage(contentsOfFile: data.path)?.precomposed(), true)
|
||||||
})
|
})
|
||||||
|
@ -432,7 +432,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
self.botStart = botStart
|
self.botStart = botStart
|
||||||
self.peekData = peekData
|
self.peekData = peekData
|
||||||
|
|
||||||
self.chatBackgroundNode = WallpaperBackgroundNode(context: context)
|
self.chatBackgroundNode = WallpaperBackgroundNode(context: context, useSharedAnimationPhase: true)
|
||||||
|
|
||||||
var locationBroadcastPanelSource: LocationBroadcastPanelSource
|
var locationBroadcastPanelSource: LocationBroadcastPanelSource
|
||||||
var groupCallPanelSource: GroupCallPanelSource
|
var groupCallPanelSource: GroupCallPanelSource
|
||||||
|
@ -1610,6 +1610,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
}
|
}
|
||||||
self.updatePlainInputSeparator(transition: .immediate)
|
self.updatePlainInputSeparator(transition: .immediate)
|
||||||
self.inputPanelBackgroundSeparatorNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelSeparatorColor
|
self.inputPanelBackgroundSeparatorNode.backgroundColor = self.chatPresentationInterfaceState.theme.chat.inputPanel.panelSeparatorColor
|
||||||
|
|
||||||
|
self.backgroundNode.updateBubbleTheme(bubbleTheme: chatPresentationInterfaceState.theme, bubbleCorners: chatPresentationInterfaceState.bubbleCorners)
|
||||||
}
|
}
|
||||||
|
|
||||||
let keepSendButtonEnabled = chatPresentationInterfaceState.interfaceState.forwardMessageIds != nil || chatPresentationInterfaceState.interfaceState.editMessage != nil
|
let keepSendButtonEnabled = chatPresentationInterfaceState.interfaceState.forwardMessageIds != nil || chatPresentationInterfaceState.interfaceState.editMessage != nil
|
||||||
|
@ -101,7 +101,7 @@ final class ChatMessageBubbleBackdrop: ASDisplayNode {
|
|||||||
let maskMode = self.fixedMaskMode ?? inputMaskMode
|
let maskMode = self.fixedMaskMode ?? inputMaskMode
|
||||||
|
|
||||||
if self.currentType != type || self.theme != theme || self.currentMaskMode != maskMode || self.essentialGraphics !== essentialGraphics || self.backgroundNode !== backgroundNode {
|
if self.currentType != type || self.theme != theme || self.currentMaskMode != maskMode || self.essentialGraphics !== essentialGraphics || self.backgroundNode !== backgroundNode {
|
||||||
let typeUpdated = self.currentType != type
|
let typeUpdated = self.currentType != type || self.theme != theme || self.currentMaskMode != maskMode || self.backgroundNode !== backgroundNode
|
||||||
|
|
||||||
self.currentType = type
|
self.currentType = type
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
|
@ -2211,6 +2211,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
backgroundView.frame = self.textInputBackgroundNode.frame
|
backgroundView.frame = self.textInputBackgroundNode.frame
|
||||||
|
|
||||||
func updateIsCaretHidden(view: UIView, isHidden: Bool) {
|
func updateIsCaretHidden(view: UIView, isHidden: Bool) {
|
||||||
|
return;
|
||||||
if String(describing: type(of: view)).contains("TextSelectionView") {
|
if String(describing: type(of: view)).contains("TextSelectionView") {
|
||||||
view.isHidden = isHidden
|
view.isHidden = isHidden
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,6 +19,7 @@ import WallpaperResources
|
|||||||
import Svg
|
import Svg
|
||||||
import GZip
|
import GZip
|
||||||
import TelegramUniversalVideoContent
|
import TelegramUniversalVideoContent
|
||||||
|
import GradientBackground
|
||||||
|
|
||||||
public func fetchCachedResourceRepresentation(account: Account, resource: MediaResource, representation: CachedMediaResourceRepresentation) -> Signal<CachedMediaResourceRepresentationResult, NoError> {
|
public func fetchCachedResourceRepresentation(account: Account, resource: MediaResource, representation: CachedMediaResourceRepresentation) -> Signal<CachedMediaResourceRepresentationResult, NoError> {
|
||||||
if let representation = representation as? CachedStickerAJpegRepresentation {
|
if let representation = representation as? CachedStickerAJpegRepresentation {
|
||||||
@ -480,11 +481,7 @@ private func fetchCachedPatternWallpaperRepresentation(resource: MediaResource,
|
|||||||
let path = NSTemporaryDirectory() + "\(Int64.random(in: Int64.min ... Int64.max))"
|
let path = NSTemporaryDirectory() + "\(Int64.random(in: Int64.min ... Int64.max))"
|
||||||
let url = URL(fileURLWithPath: path)
|
let url = URL(fileURLWithPath: path)
|
||||||
|
|
||||||
var colors: [UIColor] = []
|
let colors: [UIColor] = representation.colors.map(UIColor.init(rgb:))
|
||||||
if let bottomColor = representation.bottomColor {
|
|
||||||
colors.append(UIColor(rgb: bottomColor))
|
|
||||||
}
|
|
||||||
colors.append(UIColor(rgb: representation.color))
|
|
||||||
|
|
||||||
let intensity = CGFloat(representation.intensity) / 100.0
|
let intensity = CGFloat(representation.intensity) / 100.0
|
||||||
|
|
||||||
@ -510,6 +507,16 @@ private func fetchCachedPatternWallpaperRepresentation(resource: MediaResource,
|
|||||||
if colors.count == 1, let color = colors.first {
|
if colors.count == 1, let color = colors.first {
|
||||||
c.setFillColor(color.cgColor)
|
c.setFillColor(color.cgColor)
|
||||||
c.fill(rect)
|
c.fill(rect)
|
||||||
|
} else if colors.count >= 3 {
|
||||||
|
let drawingRect = rect
|
||||||
|
let image = GradientBackgroundNode.generatePreview(size: CGSize(width: 60.0, height: 60.0), colors: colors)
|
||||||
|
c.translateBy(x: drawingRect.midX, y: drawingRect.midY)
|
||||||
|
c.scaleBy(x: 1.0, y: -1.0)
|
||||||
|
c.translateBy(x: -drawingRect.midX, y: -drawingRect.midY)
|
||||||
|
c.draw(image.cgImage!, in: drawingRect)
|
||||||
|
c.translateBy(x: drawingRect.midX, y: drawingRect.midY)
|
||||||
|
c.scaleBy(x: 1.0, y: -1.0)
|
||||||
|
c.translateBy(x: -drawingRect.midX, y: -drawingRect.midY)
|
||||||
} else {
|
} else {
|
||||||
let gradientColors = colors.map { $0.cgColor } as CFArray
|
let gradientColors = colors.map { $0.cgColor } as CFArray
|
||||||
let delta: CGFloat = 1.0 / (CGFloat(colors.count) - 1.0)
|
let delta: CGFloat = 1.0 / (CGFloat(colors.count) - 1.0)
|
||||||
@ -535,6 +542,10 @@ private func fetchCachedPatternWallpaperRepresentation(resource: MediaResource,
|
|||||||
c.clip(to: rect, mask: cgImage)
|
c.clip(to: rect, mask: cgImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if colors.count >= 3 {
|
||||||
|
c.setBlendMode(.softLight)
|
||||||
|
}
|
||||||
|
|
||||||
if colors.count == 1, let color = colors.first {
|
if colors.count == 1, let color = colors.first {
|
||||||
c.setFillColor(patternColor(for: color, intensity: intensity).cgColor)
|
c.setFillColor(patternColor(for: color, intensity: intensity).cgColor)
|
||||||
c.fill(rect)
|
c.fill(rect)
|
||||||
|
@ -167,7 +167,7 @@ public func upgradedAccounts(accountManager: AccountManager, rootPath: String, e
|
|||||||
let _ = accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
let _ = accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
||||||
if wallpaper.isPattern {
|
if wallpaper.isPattern {
|
||||||
if !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
if !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
||||||
let _ = accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(color: file.settings.colors[0], bottomColor: file.settings.colors.count >= 2 ? file.settings.colors[1] : file.settings.colors[0], intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true).start()
|
let _ = accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(colors: file.settings.colors, intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true).start()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if file.settings.blur {
|
if file.settings.blur {
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit f89519e4fbfe7c0abceefcc60acd22d3b763598e
|
Subproject commit c918c50087466adf5fdca47f2f62de58eccf514b
|
@ -178,6 +178,7 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
|
private let useSharedAnimationPhase: Bool
|
||||||
|
|
||||||
private let contentNode: ASDisplayNode
|
private let contentNode: ASDisplayNode
|
||||||
private var gradientBackgroundNode: GradientBackgroundNode?
|
private var gradientBackgroundNode: GradientBackgroundNode?
|
||||||
@ -245,8 +246,9 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(context: AccountContext) {
|
public init(context: AccountContext, useSharedAnimationPhase: Bool = false) {
|
||||||
self.context = context
|
self.context = context
|
||||||
|
self.useSharedAnimationPhase = useSharedAnimationPhase
|
||||||
self.imageContentMode = .scaleAspectFill
|
self.imageContentMode = .scaleAspectFill
|
||||||
|
|
||||||
self.contentNode = ASDisplayNode()
|
self.contentNode = ASDisplayNode()
|
||||||
@ -289,7 +291,7 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
|
|
||||||
if gradientColors.count >= 3 {
|
if gradientColors.count >= 3 {
|
||||||
if self.gradientBackgroundNode == nil {
|
if self.gradientBackgroundNode == nil {
|
||||||
let gradientBackgroundNode = createGradientBackgroundNode()
|
let gradientBackgroundNode = createGradientBackgroundNode(useSharedAnimationPhase: self.useSharedAnimationPhase)
|
||||||
self.gradientBackgroundNode = gradientBackgroundNode
|
self.gradientBackgroundNode = gradientBackgroundNode
|
||||||
self.insertSubnode(gradientBackgroundNode, aboveSubnode: self.contentNode)
|
self.insertSubnode(gradientBackgroundNode, aboveSubnode: self.contentNode)
|
||||||
gradientBackgroundNode.addSubnode(self.patternImageNode)
|
gradientBackgroundNode.addSubnode(self.patternImageNode)
|
||||||
|
@ -810,10 +810,8 @@ public func drawThemeImage(context c: CGContext, theme: PresentationTheme, wallp
|
|||||||
let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)!
|
let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)!
|
||||||
c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: drawingRect.height), end: CGPoint(x: 0.0, y: 0.0), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation])
|
c.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: drawingRect.height), end: CGPoint(x: 0.0, y: 0.0), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation])
|
||||||
}
|
}
|
||||||
case .file:
|
case let .file(file):
|
||||||
c.setFillColor(theme.chatList.backgroundColor.cgColor)
|
c.setFillColor(theme.chatList.backgroundColor.cgColor)
|
||||||
c.fill(drawingRect)
|
|
||||||
|
|
||||||
if let image = wallpaperImage, let cgImage = image.cgImage {
|
if let image = wallpaperImage, let cgImage = image.cgImage {
|
||||||
let size = image.size.aspectFilled(drawingRect.size)
|
let size = image.size.aspectFilled(drawingRect.size)
|
||||||
c.draw(cgImage, in: CGRect(origin: CGPoint(x: (drawingRect.size.width - size.width) / 2.0, y: (drawingRect.size.height - size.height) / 2.0), size: size))
|
c.draw(cgImage, in: CGRect(origin: CGPoint(x: (drawingRect.size.width - size.width) / 2.0, y: (drawingRect.size.height - size.height) / 2.0), size: size))
|
||||||
@ -1026,7 +1024,7 @@ public func themeImage(account: Account, accountManager: AccountManager, source:
|
|||||||
let _ = accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
let _ = accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
||||||
|
|
||||||
if wallpaper.wallpaper.isPattern, !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
if wallpaper.wallpaper.isPattern, !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
||||||
return accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(color: file.settings.colors[0], bottomColor: file.settings.colors.count >= 2 ? file.settings.colors[1] : file.settings.colors[0], intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true)
|
return accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(colors: file.settings.colors, intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true)
|
||||||
|> mapToSignal { data in
|
|> mapToSignal { data in
|
||||||
if data.complete, let data = try? Data(contentsOf: URL(fileURLWithPath: data.path)), let image = UIImage(data: data) {
|
if data.complete, let data = try? Data(contentsOf: URL(fileURLWithPath: data.path)), let image = UIImage(data: data) {
|
||||||
return .single((theme, image, thumbnailData))
|
return .single((theme, image, thumbnailData))
|
||||||
@ -1325,7 +1323,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
|||||||
|
|
||||||
if wallpaper.wallpaper.isPattern {
|
if wallpaper.wallpaper.isPattern {
|
||||||
if !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
if !file.settings.colors.isEmpty, let intensity = file.settings.intensity {
|
||||||
return accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(color: file.settings.colors[0], bottomColor: file.settings.colors.count >= 2 ? file.settings.colors[1] : file.settings.colors[0], intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true)
|
return accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(colors: file.settings.colors, intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true)
|
||||||
|> mapToSignal { _ in
|
|> mapToSignal { _ in
|
||||||
return .single((effectiveBackgroundColor, incomingColor, outgoingColor, nil, rotation))
|
return .single((effectiveBackgroundColor, incomingColor, outgoingColor, nil, rotation))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user