From 05a3f563e97c5a40c4d879089a89f789f84af995 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 10 Dec 2019 21:16:09 +0400 Subject: [PATCH] Theme improvements --- .../Display/WallpaperBackgroundNode.swift | 14 ++- .../Themes/ThemeAccentColorController.swift | 31 ++++-- .../ThemeAccentColorControllerNode.swift | 99 +++++++++++++++--- .../Themes/ThemeSettingsAccentColorItem.swift | 44 +++----- .../Themes/ThemeSettingsController.swift | 2 +- .../Themes/WallpaperColorPanelNode.swift | 1 + .../SyncCore/Sources/TelegramWallpaper.swift | 10 +- .../Sources/DefaultDayPresentationTheme.swift | 2 +- .../Contents.json | 2 +- .../ic_gradrotate.pdf} | Bin 4296 -> 4095 bytes .../WebSearchNavigationContentNode.swift | 4 +- 11 files changed, 147 insertions(+), 62 deletions(-) rename submodules/TelegramUI/Images.xcassets/Settings/{ThemeColorSwapIcon.imageset => ThemeColorRotateIcon.imageset}/Contents.json (75%) rename submodules/TelegramUI/Images.xcassets/Settings/{ThemeColorSwapIcon.imageset/ic_input_change.pdf => ThemeColorRotateIcon.imageset/ic_gradrotate.pdf} (75%) diff --git a/submodules/Display/Display/WallpaperBackgroundNode.swift b/submodules/Display/Display/WallpaperBackgroundNode.swift index c25ccdf927..fb3f47874a 100644 --- a/submodules/Display/Display/WallpaperBackgroundNode.swift +++ b/submodules/Display/Display/WallpaperBackgroundNode.swift @@ -33,13 +33,25 @@ public final class WallpaperBackgroundNode: ASDisplayNode { } } } - + public var image: UIImage? { didSet { self.contentNode.contents = self.image?.cgImage } } + public var rotation: CGFloat = 0.0 { + didSet { + let transition: ContainedViewLayoutTransition = .animated(duration: 0.3, curve: .easeInOut) + var fromValue: CGFloat = 0.0 + if let value = (self.layer.value(forKeyPath: "transform.rotation.z") as? NSNumber)?.floatValue { + fromValue = CGFloat(value) + } + self.contentNode.layer.transform = CATransform3DMakeRotation(self.rotation, 0.0, 0.0, 1.0) + self.contentNode.layer.animateRotation(from: fromValue, to: self.rotation, duration: 0.3) + } + } + public var imageContentMode: UIView.ContentMode { didSet { self.contentNode.contentMode = self.imageContentMode diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift index dc88e5fc57..2608b5e0e6 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift @@ -203,10 +203,13 @@ final class ThemeAccentColorController: ViewController { let settings = (sharedData.entries[ApplicationSpecificSharedDataKeys.presentationThemeSettings] as? PresentationThemeSettings) ?? PresentationThemeSettings.defaultSettings let accentColor: UIColor + var initialWallpaper: TelegramWallpaper? let backgroundColors: (UIColor, UIColor?)? let messageColors: (UIColor, UIColor?)? var defaultMessagesColor: UIColor? + var ignoreDefaultWallpaper = false + if let themeReference = strongSelf.mode.themeReference { accentColor = settings.themeSpecificAccentColors[themeReference.index]?.color ?? defaultDayAccentColor let wallpaper: TelegramWallpaper @@ -214,12 +217,24 @@ final class ThemeAccentColorController: ViewController { wallpaper = customWallpaper } else { let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: nil, bubbleColors: nil) ?? defaultPresentationTheme + if case let .builtin(themeName) = themeReference { + if case .dayClassic = themeName, settings.themeSpecificAccentColors[themeReference.index] != nil { + ignoreDefaultWallpaper = true + } else if case .nightAccent = themeName { + ignoreDefaultWallpaper = true + } + } + wallpaper = theme.chat.defaultWallpaper } + if !wallpaper.isColorOrGradient && !ignoreDefaultWallpaper { + initialWallpaper = wallpaper + } + if let initialBackgroundColor = strongSelf.initialBackgroundColor { backgroundColors = (initialBackgroundColor, nil) - } else { + } else if !ignoreDefaultWallpaper { if case let .color(color) = wallpaper { backgroundColors = (UIColor(rgb: UInt32(bitPattern: color)), nil) } else if case let .gradient(topColor, bottomColor, _) = wallpaper { @@ -227,6 +242,8 @@ final class ThemeAccentColorController: ViewController { } else { backgroundColors = nil } + } else { + backgroundColors = nil } if let bubbleColors = settings.themeSpecificAccentColors[themeReference.index]?.customBubbleColors { @@ -236,11 +253,11 @@ final class ThemeAccentColorController: ViewController { messageColors = (bubbleColors.0, nil) } } else { - messageColors = nil - } - - if strongSelf.mode.themeReference == .builtin(.dayClassic) { - defaultMessagesColor = UIColor(rgb: 0xe1ffc7) + if let themeReference = strongSelf.mode.themeReference, themeReference == .builtin(.dayClassic), settings.themeSpecificAccentColors[themeReference.index] == nil { + messageColors = (UIColor(rgb: 0xe1ffc7), nil) + } else { + messageColors = nil + } } } else if case let .edit(theme, wallpaper, _, _, _) = strongSelf.mode { accentColor = theme.rootController.navigationBar.accentTextColor @@ -265,7 +282,7 @@ final class ThemeAccentColorController: ViewController { messageColors = nil } - let initialState = ThemeColorState(section: strongSelf.section, accentColor: accentColor, backgroundColors: backgroundColors, defaultMessagesColor: defaultMessagesColor, messagesColors: messageColors) + let initialState = ThemeColorState(section: strongSelf.section, accentColor: accentColor, initialWallpaper: initialWallpaper, backgroundColors: backgroundColors, defaultMessagesColor: defaultMessagesColor, messagesColors: messageColors) strongSelf.controllerNode.updateState({ _ in return initialState diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift index 54fbf63c8e..444799f6b0 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift @@ -11,6 +11,10 @@ import TelegramUIPreferences import ChatListUI import AccountContext +private func radiansToDegrees(_ radians: CGFloat) -> CGFloat { + return radians * 180.0 / CGFloat.pi +} + private func generateMaskImage(color: UIColor) -> UIImage? { return generateImage(CGSize(width: 1.0, height: 80.0), opaque: false, rotatedContext: { size, context in let bounds = CGRect(origin: CGPoint(), size: size) @@ -36,25 +40,31 @@ struct ThemeColorState { fileprivate var section: ThemeColorSection? fileprivate var colorPanelCollapsed: Bool var accentColor: UIColor + var initialWallpaper: TelegramWallpaper? var backgroundColors: (UIColor, UIColor?)? var defaultMessagesColor: UIColor? var messagesColors: (UIColor, UIColor?)? + var rotation: CGFloat init() { self.section = nil self.colorPanelCollapsed = false self.accentColor = .clear + self.initialWallpaper = nil self.backgroundColors = nil self.messagesColors = nil + self.rotation = 0.0 } - init(section: ThemeColorSection, accentColor: UIColor, backgroundColors: (UIColor, UIColor?)?, defaultMessagesColor: UIColor?, messagesColors: (UIColor, UIColor?)?) { + init(section: ThemeColorSection, accentColor: UIColor, initialWallpaper: TelegramWallpaper?, backgroundColors: (UIColor, UIColor?)?, defaultMessagesColor: UIColor?, messagesColors: (UIColor, UIColor?)?, rotation: CGFloat = 0.0) { self.section = section self.colorPanelCollapsed = false self.accentColor = accentColor + self.initialWallpaper = initialWallpaper self.backgroundColors = backgroundColors self.defaultMessagesColor = defaultMessagesColor self.messagesColors = messagesColors + self.rotation = rotation } func areColorsEqual(to otherState: ThemeColorState) -> Bool { @@ -117,10 +127,11 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate private var serviceColorDisposable: Disposable? private var colorsDisposable: Disposable? - private let colors = Promise<(UIColor, (UIColor, UIColor?)?, (UIColor, UIColor?)?)>() + private let colors = Promise<(UIColor, (UIColor, UIColor?)?, (UIColor, UIColor?)?, TelegramWallpaper?, CGFloat)>() private let themePromise = Promise() private var wallpaper: TelegramWallpaper private var serviceBackgroundColor: UIColor? + private let serviceBackgroundColorPromise = Promise() private var tapGestureRecognizer: UITapGestureRecognizer? @@ -129,14 +140,18 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate private var validLayout: (ContainerViewLayout, CGFloat, CGFloat)? var requiresWallpaperChange: Bool { - return self.state.backgroundColors == nil && self.chatBackgroundNode.image != nil + switch self.wallpaper { + case .image, .file: + return true + default: + return false + } } init(context: AccountContext, mode: ThemeAccentColorControllerMode, theme: PresentationTheme, wallpaper: TelegramWallpaper, dismiss: @escaping () -> Void, apply: @escaping (ThemeColorState, UIColor?) -> Void) { self.context = context self.mode = mode self.state = ThemeColorState() - self.presentationData = context.sharedContext.currentPresentationData.with { $0 } self.theme = theme self.wallpaper = self.presentationData.chatWallpaper @@ -223,6 +238,8 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate var updated = current if let firstColor = firstColor { updated.backgroundColors = (firstColor, secondColor) + } else { + updated.backgroundColors = nil } return updated }) @@ -250,6 +267,20 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate } } + self.colorPanelNode.rotate = { [weak self] in + if let strongSelf = self { + strongSelf.updateState({ current in + var updated = current + var newRotation = updated.rotation + CGFloat.pi / 4.0 + if newRotation >= CGFloat.pi * 2.0 { + newRotation = 0.0 + } + updated.rotation = newRotation + return updated + }, animated: true) + } + } + self.toolbarNode.cancel = { dismiss() } @@ -261,22 +292,42 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate self.colorsDisposable = (self.colors.get() |> deliverOn(Queue.concurrentDefaultQueue()) - |> map { accentColor, backgroundColors, messagesColors -> (PresentationTheme, (TelegramWallpaper, UIImage?), UIColor) in - var wallpaper = context.sharedContext.currentPresentationData.with { $0 }.chatWallpaper + |> map { accentColor, backgroundColors, messagesColors, initialWallpaper, rotation -> (PresentationTheme, (TelegramWallpaper, UIImage?), UIColor) in + var wallpaper: TelegramWallpaper var wallpaperImage: UIImage? + var backgroundColors = backgroundColors if let backgroundColors = backgroundColors { if let bottomColor = backgroundColors.1 { - wallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings()) + wallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings(rotation: Int32(radiansToDegrees(rotation)))) wallpaperImage = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: context.sharedContext.accountManager.mediaBox, knockoutMode: false) } else { wallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb)) } + } else if let themeReference = mode.themeReference, case let .builtin(theme) = themeReference, initialWallpaper == nil { + var suggestedWallpaper: TelegramWallpaper + switch theme { + case .dayClassic: + let topColor = accentColor.withMultiplied(hue: 1.010, saturation: 0.414, brightness: 0.957) + let bottomColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.867, brightness: 0.965) + suggestedWallpaper = .gradient(Int32(bitPattern: topColor.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings()) + backgroundColors = (topColor, bottomColor) + case .nightAccent: + let color = accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18) + suggestedWallpaper = .color(Int32(bitPattern: color.rgb)) + backgroundColors = (color, nil) + default: + suggestedWallpaper = .builtin(WallpaperSettings()) + } + wallpaperImage = chatControllerBackgroundImage(theme: nil, wallpaper: suggestedWallpaper, mediaBox: context.sharedContext.accountManager.mediaBox, knockoutMode: false) + wallpaper = suggestedWallpaper + } else { + wallpaper = initialWallpaper ?? .builtin(WallpaperSettings()) } let serviceBackgroundColor = serviceColor(for: (wallpaper, wallpaperImage)) let updatedTheme: PresentationTheme if let themeReference = mode.themeReference { - updatedTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: accentColor, bubbleColors: messagesColors, serviceBackgroundColor: serviceBackgroundColor, preview: true) ?? defaultPresentationTheme + updatedTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: accentColor, bubbleColors: messagesColors, backgroundColors: backgroundColors, serviceBackgroundColor: serviceBackgroundColor, preview: true) ?? defaultPresentationTheme } else if case let .edit(theme, _, _, _, _) = mode { updatedTheme = customizePresentationTheme(theme, editing: false, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: messagesColors) } else { @@ -297,6 +348,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate strongSelf.themeUpdated?(theme) strongSelf.themePromise.set(.single(theme)) strongSelf.serviceBackgroundColor = serviceBackgroundColor + strongSelf.serviceBackgroundColorPromise.set(.single(serviceBackgroundColor)) strongSelf.colorPanelNode.updateTheme(theme) strongSelf.toolbarNode.updateThemeAndStrings(theme: theme, strings: strongSelf.presentationData.strings) @@ -319,11 +371,13 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate strongSelf.updateMessagesLayout(layout: layout, bottomInset: messagesBottomInset, transition: .immediate) } }) - - self.serviceColorDisposable = (self.themePromise.get() + + self.serviceColorDisposable = (((self.themePromise.get() |> mapToSignal { theme -> Signal in return chatServiceBackgroundColor(wallpaper: wallpaper, mediaBox: context.account.postbox.mediaBox) - } + }) + |> take(1) + |> then(self.serviceBackgroundColorPromise.get())) |> deliverOnMainQueue).start(next: { [weak self] color in if let strongSelf = self { strongSelf.pageControlBackgroundNode.backgroundColor = color @@ -369,11 +423,11 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate let colorsChanged = !previousState.areColorsEqual(to: self.state) if colorsChanged { - self.colors.set(.single((self.state.accentColor, self.state.backgroundColors, self.state.messagesColors))) + self.colors.set(.single((self.state.accentColor, self.state.backgroundColors, self.state.messagesColors, self.state.initialWallpaper, self.state.rotation))) } let colorPanelCollapsed = self.state.colorPanelCollapsed - + let sectionChanged = previousState.section != self.state.section if sectionChanged, let section = self.state.section { self.view.endEditing(true) @@ -386,18 +440,28 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate firstColor = self.state.accentColor ?? .blue secondColor = nil case .background: + if let themeReference = self.mode.themeReference, case let .builtin(theme) = themeReference { + switch theme { + case .dayClassic: + defaultColor = self.state.accentColor.withMultiplied(hue: 1.019, saturation: 0.867, brightness: 0.965) + case .nightAccent: + defaultColor = self.state.accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18) + default: + break + } + } if let backgroundColors = self.state.backgroundColors { firstColor = backgroundColors.0 secondColor = backgroundColors.1 - } else if let image = self.chatBackgroundNode.image { + } else if let image = self.chatBackgroundNode.image, previousState.initialWallpaper != nil { firstColor = averageColor(from: image) secondColor = nil } else { - firstColor = .white + firstColor = nil secondColor = nil } case .messages: - defaultColor = self.state.defaultMessagesColor ?? (self.state.accentColor ?? UIColor(rgb: 0x007e55)) + defaultColor = self.state.defaultMessagesColor ?? (self.state.accentColor ?? UIColor(rgb: 0x007ee5)) if let messagesColors = self.state.messagesColors { firstColor = messagesColors.0 secondColor = messagesColors.1 @@ -434,6 +498,9 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate func updateSection(_ section: ThemeColorSection) { self.updateState({ current in var updated = current + if section == .background { + updated.initialWallpaper = nil + } updated.section = section return updated }, animated: true) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsAccentColorItem.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsAccentColorItem.swift index db7cd0e027..2fc1c4d720 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsAccentColorItem.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsAccentColorItem.swift @@ -33,26 +33,7 @@ private func generateSwatchImage(theme: PresentationTheme, color: PresentationTh context.setLineWidth(2.0) if selected { - context.saveGState() - context.addEllipse(in: bounds.insetBy(dx: 4.0, dy: 4.0)) - context.clip() - - if let colors = bubbles { - var colors: (UIColor, UIColor) = (colors.0, colors.1 ?? colors.0) - - let gradientColors = [colors.0.cgColor, colors.1.cgColor] as CFArray - var locations: [CGFloat] = [0.0, 1.0] - let colorSpace = CGColorSpaceCreateDeviceRGB() - let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)! - - context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions()) - - context.fill(CGRect(x: 0.0, y: 0.0, width: size.width / 2.0, height: size.height)) - } else { - context.fill(bounds) - } - - context.restoreGState() + context.fillEllipse(in: bounds.insetBy(dx: 4.0, dy: 4.0)) context.strokeEllipse(in: bounds.insetBy(dx: 1.0, dy: 1.0)) if more { @@ -63,8 +44,10 @@ private func generateSwatchImage(theme: PresentationTheme, color: PresentationTh context.fillEllipse(in: CGRect(origin: CGPoint(x: 25.0, y: 18.0), size: dotSize)) } } else { + context.fillEllipse(in: bounds) + context.saveGState() - context.addEllipse(in: bounds) + context.addEllipse(in: bounds.insetBy(dx: 10.0, dy: 10.0)) context.clip() if let colors = bubbles { @@ -75,11 +58,7 @@ private func generateSwatchImage(theme: PresentationTheme, color: PresentationTh let colorSpace = CGColorSpaceCreateDeviceRGB() let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)! - context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions()) - - context.fill(CGRect(x: 0.0, y: 0.0, width: size.width / 2.0, height: size.height)) - } else { - context.fill(bounds) + context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 10.0), end: CGPoint(x: 0.0, y: size.height - 10.0), options: CGGradientDrawingOptions()) } context.restoreGState() @@ -362,6 +341,9 @@ class ThemeSettingsAccentColorItemNode: ListViewItemNode, ItemListItemNode { var updated = false var selectedNode: ThemeSettingsAccentColorNode? + strongSelf.customNode.frame = CGRect(origin: CGPoint(x: nodeOffset, y: 9.0), size: CGSize(width: 42.0, height: 42.0)) + nodeOffset += nodeSize.width + 18.0 + var i = 0 for color in item.colors { let imageNode: ThemeSettingsAccentColorNode @@ -395,11 +377,9 @@ class ThemeSettingsAccentColorItemNode: ListViewItemNode, ItemListItemNode { selectedNode = imageNode } - imageNode.setup(theme: item.theme, color: accentColor, bubbles: accentColor.customBubbleColors, selected: selected, more: itemColor != nil, action: { [weak self, weak imageNode] in + imageNode.setup(theme: item.theme, color: accentColor, bubbles: accentColor.customBubbleColors, selected: selected, more: true, action: { [weak self, weak imageNode] in if selected { - if itemColor != nil { - item.openColorPicker() - } + item.openColorPicker() } else { item.updated(itemColor) } @@ -414,7 +394,7 @@ class ThemeSettingsAccentColorItemNode: ListViewItemNode, ItemListItemNode { i += 1 } - strongSelf.customNode.frame = CGRect(origin: CGPoint(x: nodeOffset, y: 9.0), size: CGSize(width: 42.0, height: 42.0)) +// strongSelf.customNode.frame = CGRect(origin: CGPoint(x: nodeOffset, y: 9.0), size: CGSize(width: 42.0, height: 42.0)) for k in (i ..< strongSelf.colorNodes.count).reversed() { let node = strongSelf.colorNodes[k] @@ -422,7 +402,7 @@ class ThemeSettingsAccentColorItemNode: ListViewItemNode, ItemListItemNode { node.removeFromSupernode() } - let contentSize = CGSize(width: strongSelf.customNode.frame.maxX + nodeInset, height: strongSelf.scrollNode.frame.height) + let contentSize = CGSize(width: strongSelf.colorNodes.last!.frame.maxX + nodeInset, height: strongSelf.scrollNode.frame.height) if strongSelf.scrollNode.view.contentSize != contentSize { strongSelf.scrollNode.view.contentSize = contentSize } diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift index 3c833fd91c..3928b1bc34 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift @@ -486,7 +486,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The themeSpecificAccentColors[currentTheme.index] = color if case let .builtin(theme) = currentTheme, theme == .dayClassic || theme == .nightAccent { - if let wallpaper = current.themeSpecificChatWallpapers[currentTheme.index], wallpaper.isColorOrGradient { + if let wallpaper = current.themeSpecificChatWallpapers[currentTheme.index], wallpaper.isColorOrGradient || wallpaper.isBuiltin { themeSpecificChatWallpapers[currentTheme.index] = nil } } diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift index 5ee5a40572..2e1e633876 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift @@ -344,6 +344,7 @@ final class WallpaperColorPanelNode: ASDisplayNode { var colorsChanged: ((UIColor?, UIColor?, Bool) -> Void)? var colorSelected: (() -> Void)? + var rotate: (() -> Void)? private var validLayout: CGSize? diff --git a/submodules/SyncCore/Sources/TelegramWallpaper.swift b/submodules/SyncCore/Sources/TelegramWallpaper.swift index 6a4272756b..47015e2362 100644 --- a/submodules/SyncCore/Sources/TelegramWallpaper.swift +++ b/submodules/SyncCore/Sources/TelegramWallpaper.swift @@ -5,12 +5,14 @@ public struct WallpaperSettings: PostboxCoding, Equatable { public let motion: Bool public let color: Int32? public let intensity: Int32? + public let rotation: Int32? - public init(blur: Bool = false, motion: Bool = false, color: Int32? = nil, intensity: Int32? = nil) { + public init(blur: Bool = false, motion: Bool = false, color: Int32? = nil, intensity: Int32? = nil, rotation: Int32? = nil) { self.blur = blur self.motion = motion self.color = color self.intensity = intensity + self.rotation = rotation } public init(decoder: PostboxDecoder) { @@ -18,6 +20,7 @@ public struct WallpaperSettings: PostboxCoding, Equatable { self.motion = decoder.decodeInt32ForKey("m", orElse: 0) != 0 self.color = decoder.decodeOptionalInt32ForKey("c") self.intensity = decoder.decodeOptionalInt32ForKey("i") + self.rotation = decoder.decodeOptionalInt32ForKey("r") } public func encode(_ encoder: PostboxEncoder) { @@ -33,6 +36,11 @@ public struct WallpaperSettings: PostboxCoding, Equatable { } else { encoder.encodeNil(forKey: "i") } + if let rotation = self.rotation { + encoder.encodeInt32(rotation, forKey: "r") + } else { + encoder.encodeNil(forKey: "r") + } } } diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index fa3faf030e..5261520510 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -31,7 +31,7 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ac } else { if let accentColor = accentColor { let hsb = accentColor.hsb - bubbleColors = (UIColor(hue: hsb.0, saturation: hsb.2 > 0.0 ? 0.14 : 0.0, brightness: 0.79 + hsb.2 * 0.21, alpha: 1.0), nil) + bubbleColors = (UIColor(hue: hsb.0, saturation: (hsb.1 > 0.0 && hsb.2 > 0.0) ? 0.14 : 0.0, brightness: 0.79 + hsb.2 * 0.21, alpha: 1.0), nil) if accentColor.lightness > 0.705 { outgoingAccent = UIColor(hue: hsb.0, saturation: min(1.0, hsb.1 * 1.1), brightness: min(hsb.2, 0.6), alpha: 1.0) } else { diff --git a/submodules/TelegramUI/Images.xcassets/Settings/ThemeColorSwapIcon.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Settings/ThemeColorRotateIcon.imageset/Contents.json similarity index 75% rename from submodules/TelegramUI/Images.xcassets/Settings/ThemeColorSwapIcon.imageset/Contents.json rename to submodules/TelegramUI/Images.xcassets/Settings/ThemeColorRotateIcon.imageset/Contents.json index 8dec65adad..64dd68cd8b 100644 --- a/submodules/TelegramUI/Images.xcassets/Settings/ThemeColorSwapIcon.imageset/Contents.json +++ b/submodules/TelegramUI/Images.xcassets/Settings/ThemeColorRotateIcon.imageset/Contents.json @@ -2,7 +2,7 @@ "images" : [ { "idiom" : "universal", - "filename" : "ic_input_change.pdf" + "filename" : "ic_gradrotate.pdf" } ], "info" : { diff --git a/submodules/TelegramUI/Images.xcassets/Settings/ThemeColorSwapIcon.imageset/ic_input_change.pdf b/submodules/TelegramUI/Images.xcassets/Settings/ThemeColorRotateIcon.imageset/ic_gradrotate.pdf similarity index 75% rename from submodules/TelegramUI/Images.xcassets/Settings/ThemeColorSwapIcon.imageset/ic_input_change.pdf rename to submodules/TelegramUI/Images.xcassets/Settings/ThemeColorRotateIcon.imageset/ic_gradrotate.pdf index 6151d0db8b2a6465012ae0487ec5a59ee9b77cbb..79d0913c74d47dc119aece08de0bee2ac15f3a43 100644 GIT binary patch delta 735 zcmX@1_+NfPKz;0F?><>W4%g>#tlA1}J@${+EO6i3FlmuXRp*te-_wgeF4yYHO6uDw z5g#1?#W7yRFY3mbm*$zzVq)J2%=;Sy^C-3Eq)=J@_O%!#a~Npmv7yXQJ}wcMV>+7FaC3O(;4Psv_3f{2$zIL#?`v86PD=isZqy^NZsTL|w-u>-%f9to;^u6v zzi>SM-is~qlNT^aF&kSNZQjcy!6Tq&s1T#!RGOKSqF`w0WMMJ+37?LRk)Z()ni?BN z85pPok*0#aZ+?nPVo9okhKrSvfuW@#T*+h`ehY0=QxgRP5Kzcd-~uxY3``Bo(Z!5S zjEpDG=T}WPv9LgwGcdKlRBwz$otddAx?W>rGYs>LO$|&YYYW)L8=IIU8dw?`q$MR9 zS(qB987HP08>JYeSy~#JrTwrRH6{8U}wiwT#{H+Qc;we#${}7Xu+kb>gw;t F1ppAv7Hj|j delta 979 zcmew_e?oCWKz(Y6W1h4j&z|?%Um8~_X?9+*)IYJ3-ymQ~L$Jb$|BdGgQuDhGu+QGC zGJTHZuf=<&^)Cu?pB#E*wa-M2_nb$4R($*&S8{D)$2IQG7rxydUnAbJ7lm>2D=oX$ z8)_WwwK}_X%I&Kh9WyqV-aCIyxsmM!!;;`yCTYR!bBosQ+WGB&{e*LD=Z(JPg{G|0 z*u2W*s^b#fKwE>3^AG2CM7D^n=Z#MOx8`(ML(;KRwY<#dn|3ZQ_IUX`pGQ5+efr-u z3PR71>27p4x$y00#>$QNvidF8c7&ChrY?_AKCpSxhD04FB_(CUYPL4dkkyvU=4cxy z>(`vvX((}@TU=r1$E^lmo*t`@|E9X>DeK+@p3Rk}tGqZ{dIVptd}TiW&Z+3mTj3@F z>;Ar+w}MYzhv#zn=FrriLN6RsoMyCI#cB)AloL+Y{nhYAIs5$9ZS@@m-+ph*+QoNv zt<@IMDXh_4g4ws2PNaC7m`}0P`MPyy-s6M9z29PI$9bK)A5tCGIB${z*W?=l#`OZ5 z{C>_5P0-1D<;{D}U~4_gS@mg$H^;uYnwWFv#Ai{zg}Z{QRgA3O6%?F1)^W*x<;46e z0-jkDraW(-n3Mfqq1*4V>y7Ddv)POm+uV1&f7WLHipI~OK8s5~)acD@WI6wQhv4DA zjWG$or#$??`;&F<^R}a(6$})>w5175$OtSnIh9vnvmnzi zZhnOr4X4t~oD>B^OGh&Uqsh{II-G`vriR8wh6aX{1Nfwnc*T4c+UBNa3I-sckf*=} zW*8Wl8(5-?8JiiIPQJ#cT5o1)fG%fXZh@)Z6pK0wQ*(5^#-`>N<{6tCAi1feC^0i9 zwTR2cMnOL~b8;2GT6}V{NvefWvPDXwg^{Ikiix2`qKUa>im8!7s)4adnxP$+4M8Oe eu?lu}T*W1cMI{wQscBrsmWGyGs;aL3Zd?Gfpoxe8 diff --git a/submodules/WebSearchUI/Sources/WebSearchNavigationContentNode.swift b/submodules/WebSearchUI/Sources/WebSearchNavigationContentNode.swift index b50c59dc6f..a50bd0b118 100644 --- a/submodules/WebSearchUI/Sources/WebSearchNavigationContentNode.swift +++ b/submodules/WebSearchUI/Sources/WebSearchNavigationContentNode.swift @@ -53,11 +53,11 @@ final class WebSearchNavigationContentNode: NavigationBarContentNode { } override var nominalHeight: CGFloat { - return 54.0 + return 56.0 } override func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition) { - let searchBarFrame = CGRect(origin: CGPoint(x: 0.0, y: size.height - self.nominalHeight), size: CGSize(width: size.width, height: 54.0)) + let searchBarFrame = CGRect(origin: CGPoint(x: 0.0, y: size.height - self.nominalHeight), size: CGSize(width: size.width, height: 56.0)) self.searchBar.frame = searchBarFrame self.searchBar.updateLayout(boundingSize: searchBarFrame.size, leftInset: leftInset, rightInset: rightInset, transition: transition) }