Restore theme color list, add gradients

This commit is contained in:
Ali 2021-06-17 22:08:47 +04:00
parent a63f2fb104
commit cd5935b61d
5 changed files with 94 additions and 79 deletions

View File

@ -52,7 +52,7 @@ final class SettingsThemeWallpaperNode: ASDisplayNode {
self.displayLoading = displayLoading self.displayLoading = displayLoading
self.imageNode.contentAnimations = [.subsequentUpdates] self.imageNode.contentAnimations = [.subsequentUpdates]
self.statusNode = RadialStatusNode(backgroundNodeColor: overlayBackgroundColor, enableBlur: true) self.statusNode = RadialStatusNode(backgroundNodeColor: UIColor(white: 0.0, alpha: 0.2), enableBlur: true)
let progressDiameter: CGFloat = 50.0 let progressDiameter: CGFloat = 50.0
self.statusNode.frame = CGRect(x: 0.0, y: 0.0, width: progressDiameter, height: progressDiameter) self.statusNode.frame = CGRect(x: 0.0, y: 0.0, width: progressDiameter, height: progressDiameter)
self.statusNode.isUserInteractionEnabled = false self.statusNode.isUserInteractionEnabled = false

View File

@ -11,79 +11,93 @@ import TelegramPresentationData
import TelegramUIPreferences import TelegramUIPreferences
import AccountContext import AccountContext
private func availableColors(theme: PresentationTheme) -> [UInt32] { private func availableGradients(theme: PresentationTheme) -> [[UInt32]] {
if theme.overallDarkAppearance { if theme.overallDarkAppearance {
return ([ return [
0xffffff, [0x1e3557, 0x151a36, 0x1c4352, 0x2a4541] as [UInt32],
0xd4dfea, [0x1d223f, 0x1d1832, 0x1b2943, 0x141631] as [UInt32],
0xb3cde1, [0x203439, 0x102028, 0x1d3c3a, 0x172635] as [UInt32],
0x6ab7ea, [0x1c2731, 0x1a1c25, 0x27303b, 0x1b1b21] as [UInt32],
0x008dd0, [0x3a1c3a, 0x24193c, 0x392e3e, 0x1a1632] as [UInt32],
0xd3e2da, [0x2c211b, 0x44332a, 0x22191f, 0x3b2d36] as [UInt32],
0xc8e6c9, [0x1e3557, 0x182036, 0x1c4352, 0x16263a] as [UInt32],
0xc5e1a5, [0x111236, 0x14424f, 0x0b2334, 0x3b315d] as [UInt32],
0x61b06e, [0x2d4836, 0x172b19, 0x364331, 0x103231] as [UInt32]
0xcdcfaf, ]
0xa7a895,
0x7c6f72,
0xffd7ae,
0xffb66d,
0xde8751,
0xefd5e0,
0xdba1b9,
0xffafaf,
0xf16a60,
0xe8bcea,
0x9592ed,
0xd9bc60,
0xb17e49,
0xd5cef7,
0xdf506b,
0x8bd2cc,
0x3c847e,
0x22612c,
0x244d7c,
0x3d3b85,
0x65717d,
0x18222d,
0x000000
] as [UInt32]).filter { color in
return UIColor(rgb: color).hsb.b <= 0.4
}
} else { } else {
return [ return [
0xffffff, [0xdbddbb, 0x6ba587, 0xd5d88d, 0x88b884] as [UInt32],
0xd4dfea, [0x8dc0eb, 0xb9d1ea, 0xc6b1ef, 0xebd7ef] as [UInt32],
0xb3cde1, [0x97beeb, 0xb1e9ea, 0xc6b1ef, 0xefb7dc] as [UInt32],
0x6ab7ea, [0x8adbf2, 0x888dec, 0xe39fea, 0x679ced] as [UInt32],
0x008dd0, [0xb0cdeb, 0x9fb0ea, 0xbbead5, 0xb2e3dd] as [UInt32],
0xd3e2da, [0xdaeac8, 0xa2b4ff, 0xeccbff, 0xb9e2ff] as [UInt32],
0xc8e6c9, [0xdceb92, 0x8fe1d6, 0x67a3f2, 0x85d685] as [UInt32],
0xc5e1a5, [0xeaa36e, 0xf0e486, 0xf29ebf, 0xe8c06e] as [UInt32],
0x61b06e, [0xffc3b2, 0xe2c0ff, 0xffe7b2, 0xf8cece] as [UInt32]
0xcdcfaf, ]
0xa7a895, }
0x7c6f72, }
0xffd7ae,
0xffb66d, private func availableColors(theme: PresentationTheme) -> [UInt32] {
0xde8751, if theme.overallDarkAppearance {
0xefd5e0, return [
0xdba1b9, 0x1D2D3C,
0xffafaf, 0x111B26,
0xf16a60, 0x0B141E,
0xe8bcea, 0x1F361F,
0x9592ed, 0x131F15,
0xd9bc60, 0x0E1710,
0xb17e49, 0x2F2E27,
0xd5cef7, 0x2A261F,
0xdf506b, 0x191817,
0x8bd2cc, 0x432E30,
0x3c847e, 0x2E1C1E,
0x22612c, 0x1F1314,
0x244d7c, 0x432E3C,
0x3d3b85, 0x2E1C28,
0x65717d, 0x1F131B,
0x18222d, 0x3C2E43,
0x291C2E,
0x1D1221,
0x312E43,
0x1E1C2E,
0x141221,
0x2F3F3F,
0x212D30,
0x141E20,
0x272524,
0x191716,
0x000000
]
} else {
return [
0xD3DFEA,
0xA5C5DB,
0x6F99C8,
0xD2E3A9,
0xA4D48E,
0x7DBB6E,
0xE6DDAE,
0xD5BE91,
0xCBA479,
0xEBC0B9,
0xE0A79D,
0xC97870,
0xEBB9C8,
0xE09DB7,
0xD27593,
0xDAC2ED,
0xD3A5E7,
0xB587D2,
0xC2C2ED,
0xA5A5E7,
0x7F7FD0,
0xC2E2ED,
0xA5D6E7,
0x7FBAD0,
0xD6C2B9,
0x9C8882,
0x000000 0x000000
] ]
} }
@ -155,7 +169,7 @@ final class ThemeColorsGridController: ViewController {
} }
override func loadDisplayNode() { override func loadDisplayNode() {
self.displayNode = ThemeColorsGridControllerNode(context: self.context, presentationData: self.presentationData, colors: availableColors(theme: self.presentationData.theme), present: { [weak self] controller, arguments in self.displayNode = ThemeColorsGridControllerNode(context: self.context, presentationData: self.presentationData, gradients: availableGradients(theme: self.presentationData.theme), colors: availableColors(theme: self.presentationData.theme), present: { [weak self] controller, arguments in
self?.present(controller, in: .window(.root), with: arguments, blockInteraction: true) self?.present(controller, in: .window(.root), with: arguments, blockInteraction: true)
}, pop: { [weak self] in }, pop: { [weak self] in
if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController { if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController {

View File

@ -88,7 +88,7 @@ final class ThemeColorsGridControllerNode: ASDisplayNode {
private var disposable: Disposable? private var disposable: Disposable?
init(context: AccountContext, presentationData: PresentationData, colors: [UInt32], present: @escaping (ViewController, Any?) -> Void, pop: @escaping () -> Void, presentColorPicker: @escaping () -> Void) { init(context: AccountContext, presentationData: PresentationData, gradients: [[UInt32]], colors: [UInt32], present: @escaping (ViewController, Any?) -> Void, pop: @escaping () -> Void, presentColorPicker: @escaping () -> Void) {
self.context = context self.context = context
self.presentationData = presentationData self.presentationData = presentationData
self.present = present self.present = present
@ -142,7 +142,9 @@ final class ThemeColorsGridControllerNode: ASDisplayNode {
}) })
self.controllerInteraction = interaction self.controllerInteraction = interaction
let wallpapers = colors.map { TelegramWallpaper.color($0) } var wallpapers: [TelegramWallpaper] = []
wallpapers.append(contentsOf: gradients.map { TelegramWallpaper.gradient(nil, $0, WallpaperSettings()) })
wallpapers.append(contentsOf: colors.map { TelegramWallpaper.color($0) })
let transition = context.sharedContext.presentationData let transition = context.sharedContext.presentationData
|> map { presentationData -> (ThemeColorsGridEntryTransition, Bool) in |> map { presentationData -> (ThemeColorsGridEntryTransition, Bool) in
var entries: [ThemeColorsGridControllerEntry] = [] var entries: [ThemeColorsGridControllerEntry] = []

View File

@ -145,12 +145,12 @@ final class ThemeGridController: ViewController {
}) })
} }
}, presentColors: { [weak self] in }, presentColors: { [weak self] in
/*if let strongSelf = self { if let strongSelf = self {
let controller = ThemeColorsGridController(context: strongSelf.context) let controller = ThemeColorsGridController(context: strongSelf.context)
(strongSelf.navigationController as? NavigationController)?.pushViewController(controller) (strongSelf.navigationController as? NavigationController)?.pushViewController(controller)
}*/ }
if let strongSelf = self { /*if let strongSelf = self {
let _ = (strongSelf.context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.presentationThemeSettings]) let _ = (strongSelf.context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.presentationThemeSettings])
|> take(1) |> take(1)
|> deliverOnMainQueue).start(next: { [weak self] sharedData in |> deliverOnMainQueue).start(next: { [weak self] sharedData in
@ -189,7 +189,7 @@ final class ThemeGridController: ViewController {
} }
strongSelf.push(controller) strongSelf.push(controller)
}) })
} }*/
}, emptyStateUpdated: { [weak self] empty in }, emptyStateUpdated: { [weak self] empty in
if let strongSelf = self { if let strongSelf = self {
if empty != strongSelf.isEmpty { if empty != strongSelf.isEmpty {

View File

@ -280,7 +280,6 @@ final class WallpaperPatternPanelNode: ASDisplayNode {
if existingIds.contains(file.file.fileId) { if existingIds.contains(file.file.fileId) {
return false return false
} else { } else {
print("slug: \(file.slug)")
existingIds.insert(file.file.fileId) existingIds.insert(file.file.fileId)
return true return true
} }