Improve theme color customization

This commit is contained in:
Ilya Laktyushin 2019-12-06 19:38:01 +04:00
parent d2e593f60d
commit 60df3014fa
48 changed files with 5089 additions and 3876 deletions

View file

@ -5158,3 +5158,7 @@ Any member of this group will be able to see messages in the channel.";
"Map.HomeAndWorkTitle" = "Home & Work Addresses";
"Map.HomeAndWorkInfo" = "Telegram uses the Home and Work addresses from your Contact Card.\n\nKeep your Contact Card up to date for quick access to sending Home and Work addresses.";
"Map.SearchNoResultsDescription" = "There were no results for \"%@\".\nTry a new search.";
"Theme.Context.ChangeColors" = "Change Colors";
"EditTheme.ChangeColors" = "Change Colors";

View file

@ -150,6 +150,7 @@ public struct ChatAvailableMessageActions {
public enum WallpaperUrlParameter {
case slug(String, WallpaperPresentationOptions, UIColor?, Int32?)
case color(UIColor)
case gradient(UIColor, UIColor)
}
public enum ResolvedUrl {

View file

@ -646,7 +646,7 @@ private func preparedContactListNodeTransition(account: Account, presentationDat
var scrollToItem: ListViewScrollToItem?
if firstTime && shouldFixScroll && toEntries.count >= 1 {
scrollToItem = ListViewScrollToItem(index: 0, position: .top(-50.0), animated: false, curve: .Default(duration: 0.0), directionHint: .Up)
scrollToItem = ListViewScrollToItem(index: 0, position: .top(-46.0), animated: false, curve: .Default(duration: 0.0), directionHint: .Up)
}
return ContactsListNodeTransition(deletions: deletions, insertions: insertions, updates: updates, indexSections: indexSections, firstTime: firstTime, isEmpty: isEmpty, scrollToItem: scrollToItem, animation: animation)

View file

@ -124,7 +124,7 @@ public final class LocationPickerController: ViewController {
}
let controller = ActionSheetController(presentationData: strongSelf.presentationData)
var title = strongSelf.presentationData.strings.Map_LiveLocationGroupDescription
if case let .share(peer, _, _) = strongSelf.mode, let receiver = peer {
if case let .share(peer, _, _) = strongSelf.mode, let receiver = peer as? TelegramUser {
title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(receiver.compactDisplayTitle).0
}
controller.setItemGroups([

View file

@ -38,21 +38,6 @@ public extension TermsOfServiceControllerTheme {
convenience init(presentationTheme: PresentationTheme) {
self.init(statusBarStyle: presentationTheme.rootController.statusBarStyle.style, navigationBackground: presentationTheme.rootController.navigationBar.backgroundColor, navigationSeparator: presentationTheme.rootController.navigationBar.separatorColor, listBackground: presentationTheme.list.blocksBackgroundColor, itemBackground: presentationTheme.list.itemBlocksBackgroundColor, itemSeparator: presentationTheme.list.itemBlocksSeparatorColor, primary: presentationTheme.list.itemPrimaryTextColor, accent: presentationTheme.list.itemAccentColor, disabled: presentationTheme.rootController.navigationBar.disabledButtonColor)
}
var presentationTheme: PresentationTheme {
let theme: PresentationTheme
switch itemBackground.argb {
case defaultPresentationTheme.list.itemBlocksBackgroundColor.argb:
theme = defaultPresentationTheme
case defaultDarkPresentationTheme.list.itemBlocksBackgroundColor.argb:
theme = defaultDarkPresentationTheme
case defaultDarkAccentPresentationTheme.list.itemBlocksBackgroundColor.argb:
theme = defaultDarkAccentPresentationTheme
default:
theme = defaultPresentationTheme
}
return theme
}
}
public class TermsOfServiceController: ViewController, StandalonePresentableController {

View file

@ -161,7 +161,7 @@ func uploadCustomWallpaper(context: AccountContext, wallpaper: WallpaperGalleryE
} else {
themeSpecificChatWallpapers[current.theme.index] = wallpaper
}
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
})).start()
}

View file

@ -18,11 +18,13 @@ import AccountContext
private final class EditThemeControllerArguments {
let context: AccountContext
let updateState: ((EditThemeControllerState) -> EditThemeControllerState) -> Void
let openColors: () -> Void
let openFile: () -> Void
init(context: AccountContext, updateState: @escaping ((EditThemeControllerState) -> EditThemeControllerState) -> Void, openFile: @escaping () -> Void) {
init(context: AccountContext, updateState: @escaping ((EditThemeControllerState) -> EditThemeControllerState) -> Void, openColors: @escaping () -> Void, openFile: @escaping () -> Void) {
self.context = context
self.updateState = updateState
self.openColors = openColors
self.openFile = openFile
}
}
@ -51,6 +53,7 @@ private enum EditThemeControllerEntry: ItemListNodeEntry {
case slugInfo(PresentationTheme, String)
case chatPreviewHeader(PresentationTheme, String)
case chatPreview(PresentationTheme, PresentationTheme, TelegramWallpaper, PresentationFontSize, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, [ChatPreviewMessageItem])
case changeColors(PresentationTheme, String)
case uploadTheme(PresentationTheme, String)
case uploadInfo(PresentationTheme, String)
@ -58,7 +61,7 @@ private enum EditThemeControllerEntry: ItemListNodeEntry {
switch self {
case .title, .slug, .slugInfo:
return EditThemeControllerSection.info.rawValue
case .chatPreviewHeader, .chatPreview, .uploadTheme, .uploadInfo:
case .chatPreviewHeader, .chatPreview, .changeColors, .uploadTheme, .uploadInfo:
return EditThemeControllerSection.chatPreview.rawValue
}
}
@ -75,10 +78,12 @@ private enum EditThemeControllerEntry: ItemListNodeEntry {
return 3
case .chatPreview:
return 4
case .uploadTheme:
case .changeColors:
return 5
case .uploadInfo:
case .uploadTheme:
return 6
case .uploadInfo:
return 7
}
}
@ -114,6 +119,12 @@ private enum EditThemeControllerEntry: ItemListNodeEntry {
} else {
return false
}
case let .changeColors(lhsTheme, lhsText):
if case let .changeColors(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
} else {
return false
}
case let .uploadTheme(lhsTheme, lhsText):
if case let .uploadTheme(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
@ -162,6 +173,10 @@ private enum EditThemeControllerEntry: ItemListNodeEntry {
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .chatPreview(theme, componentTheme, wallpaper, fontSize, strings, dateTimeFormat, nameDisplayOrder, items):
return ThemeSettingsChatPreviewItem(context: arguments.context, theme: theme, componentTheme: componentTheme, strings: strings, sectionId: self.section, fontSize: fontSize, wallpaper: wallpaper, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, messageItems: items)
case let .changeColors(theme, text):
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
arguments.openColors()
})
case let .uploadTheme(theme, text):
return ItemListActionItem(presentationData: presentationData, title: text, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
arguments.openFile()
@ -173,7 +188,7 @@ private enum EditThemeControllerEntry: ItemListNodeEntry {
}
public enum EditThemeControllerMode: Equatable {
case create
case create(PresentationTheme?)
case edit(PresentationCloudTheme)
}
@ -239,6 +254,7 @@ private func editThemeControllerEntries(presentationData: PresentationData, stat
entries.append(.chatPreviewHeader(presentationData.theme, presentationData.strings.EditTheme_Preview.uppercased()))
entries.append(.chatPreview(presentationData.theme, previewTheme, previewTheme.chat.defaultWallpaper, presentationData.fontSize, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (previewIncomingReplyName, previewIncomingReplyText), text: previewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: previewOutgoingText)]))
entries.append(.changeColors(presentationData.theme, presentationData.strings.EditTheme_ChangeColors))
entries.append(.uploadTheme(presentationData.theme, uploadText))
entries.append(.uploadInfo(presentationData.theme, uploadInfo))
@ -249,10 +265,19 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll
let initialState: EditThemeControllerState
let previewThemePromise = Promise<PresentationTheme>()
switch mode {
case .create:
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
initialState = EditThemeControllerState(mode: mode, title: generateThemeName(accentColor: presentationData.theme.rootController.navigationBar.buttonColor), slug: "", updatedTheme: nil, updating: false)
previewThemePromise.set(.single(presentationData.theme.withUpdated(name: "", defaultWallpaper: presentationData.chatWallpaper)))
case let .create(existingTheme):
let theme: PresentationTheme
let wallpaper: TelegramWallpaper
if let existingTheme = existingTheme {
theme = existingTheme
wallpaper = theme.chat.defaultWallpaper
} else {
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
theme = presentationData.theme
wallpaper = presentationData.chatWallpaper
}
initialState = EditThemeControllerState(mode: mode, title: generateThemeName(accentColor: theme.rootController.navigationBar.buttonColor), slug: "", updatedTheme: nil, updating: false)
previewThemePromise.set(.single(theme.withUpdated(name: "", defaultWallpaper: wallpaper)))
case let .edit(info):
if let file = info.theme.file, let path = context.sharedContext.accountManager.mediaBox.completedResourcePath(file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path)), let theme = makePresentationTheme(data: data, resolvedWallpaper: info.resolvedWallpaper) {
if case let .file(file) = theme.chat.defaultWallpaper, file.id == 0 {
@ -279,12 +304,27 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll
}
var presentControllerImpl: ((ViewController, Any?) -> Void)?
var pushControllerImpl: ((ViewController) -> Void)?
var dismissImpl: (() -> Void)?
var dismissInputImpl: (() -> Void)?
var errorImpl: ((EditThemeEntryTag) -> Void)?
let arguments = EditThemeControllerArguments(context: context, updateState: { f in
updateState(f)
}, openColors: {
let _ = (previewThemePromise.get()
|> take(1)
|> deliverOnMainQueue).start(next: { theme in
let controller = ThemeAccentColorController(context: context, mode: .edit(theme: theme, wallpaper: nil, defaultThemeReference: nil, completion: { updatedTheme in
updateState { current in
var state = current
previewThemePromise.set(.single(updatedTheme))
state.updatedTheme = updatedTheme
return state
}
}))
pushControllerImpl?(controller)
})
}, openFile: {
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let controller = legacyICloudFilePicker(theme: presentationData.theme, mode: .import, documentTypes: ["org.telegram.Telegram-iOS.theme"], completion: { urls in
@ -468,7 +508,7 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
themeSpecificChatWallpapers[themeReference.index] = nil
return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
})
} |> deliverOnMainQueue).start(completed: {
if !hasCustomFile {
@ -509,7 +549,7 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
themeSpecificChatWallpapers[themeReference.index] = nil
return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
})
} |> deliverOnMainQueue).start(completed: {
if let themeResource = themeResource, !hasCustomFile {
@ -569,6 +609,9 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll
presentControllerImpl = { [weak controller] c, a in
controller?.present(c, in: .window(.root), with: a)
}
pushControllerImpl = { [weak controller] c in
controller?.push(c)
}
dismissImpl = { [weak controller] in
controller?.view.endEditing(true)
let _ = controller?.dismiss()

View file

@ -99,7 +99,7 @@ final class SettingsThemeWallpaperNode: ASDisplayNode {
self.backgroundNode.isHidden = false
self.backgroundNode.backgroundColor = UIColor(rgb: UInt32(bitPattern: color))
}
case let .gradient(topColor, bottomColor):
case let .gradient(topColor, bottomColor, _):
self.imageNode.isHidden = false
self.backgroundNode.isHidden = true
self.imageNode.setSignal(gradientImage([UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor))]))

View file

@ -13,9 +13,26 @@ import PresentationDataUtils
private let colors: [Int32] = [0x007aff, 0x00c2ed, 0x29b327, 0xeb6ca4, 0xf08200, 0x9472ee, 0xd33213, 0xedb400, 0x6d839e]
enum ThemeAccentColorControllerMode {
case colors(themeReference: PresentationThemeReference)
case background(themeReference: PresentationThemeReference)
case edit(theme: PresentationTheme, wallpaper: TelegramWallpaper?, defaultThemeReference: PresentationThemeReference?, completion: (PresentationTheme) -> Void)
var themeReference: PresentationThemeReference? {
switch self {
case let .colors(themeReference), let .background(themeReference):
return themeReference
case let .edit(_, _, defaultThemeReference, _):
return defaultThemeReference
default:
return nil
}
}
}
final class ThemeAccentColorController: ViewController {
private let context: AccountContext
private let themeReference: PresentationThemeReference
private let mode: ThemeAccentColorControllerMode
private let section: ThemeColorSection
private let initialBackgroundColor: UIColor?
private var presentationData: PresentationData
@ -24,7 +41,7 @@ final class ThemeAccentColorController: ViewController {
return self.displayNode as! ThemeAccentColorControllerNode
}
let segmentedTitleView: ThemeColorSegmentedTitleView
private let segmentedTitleView: ThemeColorSegmentedTitleView
private let _ready = Promise<Bool>()
override public var ready: Promise<Bool> {
@ -33,21 +50,28 @@ final class ThemeAccentColorController: ViewController {
var completion: (() -> Void)?
init(context: AccountContext, themeReference: PresentationThemeReference, section: ThemeColorSection) {
init(context: AccountContext, mode: ThemeAccentColorControllerMode) {
self.context = context
self.themeReference = themeReference
self.section = section
self.mode = mode
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
var section: ThemeColorSection = .accent
if case .background = mode {
section = .background
}
self.section = section
self.segmentedTitleView = ThemeColorSegmentedTitleView(theme: self.presentationData.theme, strings: self.presentationData.strings, selectedSection: section)
if section == .background {
if case .background = mode {
self.initialBackgroundColor = colors.randomElement().flatMap { UIColor(rgb: UInt32(bitPattern: $0)) }
} else {
self.initialBackgroundColor = nil
}
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationTheme: self.presentationData.theme, presentationStrings: self.presentationData.strings))
self.navigationPresentation = .modal
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBarStyle.style
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
@ -80,10 +104,10 @@ final class ThemeAccentColorController: ViewController {
}
}
if case let .builtin(theme) = themeReference, theme != .dayClassic {
self.navigationItem.titleView = self.segmentedTitleView
if case .background = mode {
self.title = self.presentationData.strings.Wallpaper_Title
} else {
self.title = self.presentationData.strings.Wallpaper_Title
self.navigationItem.titleView = self.segmentedTitleView
}
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: UIView())
}
@ -95,53 +119,75 @@ final class ThemeAccentColorController: ViewController {
override func loadDisplayNode() {
super.loadDisplayNode()
self.displayNode = ThemeAccentColorControllerNode(context: self.context, themeReference: self.themeReference, theme: self.presentationData.theme, dismiss: { [weak self] in
let theme: PresentationTheme
let wallpaper: TelegramWallpaper
if case let .edit(editedTheme, walpaper, _, _) = self.mode {
theme = editedTheme
wallpaper = walpaper ?? editedTheme.chat.defaultWallpaper
} else {
theme = self.presentationData.theme
wallpaper = self.presentationData.chatWallpaper
}
self.displayNode = ThemeAccentColorControllerNode(context: self.context, mode: self.mode, theme: theme, wallpaper: wallpaper, dismiss: { [weak self] in
if let strongSelf = self {
strongSelf.dismiss()
}
}, apply: { [weak self] state in
}, apply: { [weak self] state, serviceBackgroundColor in
if let strongSelf = self {
let context = strongSelf.context
let _ = (updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in
let autoNightModeTriggered = context.sharedContext.currentPresentationData.with { $0 }.autoNightModeTriggered
var currentTheme = current.theme
if autoNightModeTriggered {
currentTheme = current.automaticThemeSwitchSetting.theme
if case let .edit(theme, _, themeReference, completion) = strongSelf.mode {
let updatedTheme: PresentationTheme
if let themeReference = themeReference {
updatedTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: state.accentColor, bubbleColors: state.messagesColors, backgroundColors: state.backgroundColors, serviceBackgroundColor: serviceBackgroundColor) ?? defaultPresentationTheme
} else {
updatedTheme = customizePresentationTheme(theme, editing: false, accentColor: state.accentColor, backgroundColors: state.backgroundColors, bubbleColors: state.messagesColors)
}
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
var themeSpecificAccentColors = current.themeSpecificAccentColors
var themeSpecificBubbleColors = current.themeSpecificBubbleColors
let color = PresentationThemeAccentColor(baseColor: .custom, value: Int32(bitPattern: state.accentColor.rgb))
themeSpecificAccentColors[currentTheme.index] = color
completion(updatedTheme)
var wallpaper = themeSpecificChatWallpapers[currentTheme.index]
if let backgroundColors = state.backgroundColors {
if let bottomColor = backgroundColors.1 {
wallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: bottomColor.rgb))
} else {
wallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb))
strongSelf.dismiss()
} else {
let _ = (updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in
let autoNightModeTriggered = context.sharedContext.currentPresentationData.with { $0 }.autoNightModeTriggered
var currentTheme = current.theme
if autoNightModeTriggered {
currentTheme = current.automaticThemeSwitchSetting.theme
}
}
themeSpecificChatWallpapers[currentTheme.index] = wallpaper
var bubbleColors: PresentationThemeColorPair?
if let messagesColors = state.messagesColors {
if let secondColor = messagesColors.1 {
bubbleColors = PresentationThemeColorPair(color: Int32(bitPattern: messagesColors.0.rgb), optionalColor: Int32(bitPattern: secondColor.rgb))
} else {
bubbleColors = PresentationThemeColorPair(color: Int32(bitPattern: messagesColors.0.rgb), optionalColor: nil)
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
var themeSpecificAccentColors = current.themeSpecificAccentColors
var bubbleColors: (Int32, Int32?)?
if let messagesColors = state.messagesColors {
if let secondColor = messagesColors.1 {
bubbleColors = (Int32(bitPattern: messagesColors.0.rgb), Int32(bitPattern: secondColor.rgb))
} else {
bubbleColors = (Int32(bitPattern: messagesColors.0.rgb), nil)
}
}
}
themeSpecificBubbleColors[currentTheme.index] = bubbleColors
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificBubbleColors: themeSpecificBubbleColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
}) |> deliverOnMainQueue).start(completed: { [weak self] in
if let strongSelf = self {
strongSelf.completion?()
strongSelf.dismiss()
}
})
let color = PresentationThemeAccentColor(baseColor: .custom, accentColor: Int32(bitPattern: state.accentColor.rgb), bubbleColors: bubbleColors)
themeSpecificAccentColors[currentTheme.index] = color
var wallpaper = themeSpecificChatWallpapers[currentTheme.index]
if let backgroundColors = state.backgroundColors {
if let bottomColor = backgroundColors.1 {
wallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings())
} else {
wallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb))
}
}
themeSpecificChatWallpapers[currentTheme.index] = wallpaper
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
}) |> deliverOnMainQueue).start(completed: { [weak self] in
if let strongSelf = self {
strongSelf.completion?()
strongSelf.dismiss()
}
})
}
}
})
self.controllerNode.themeUpdated = { [weak self] theme in
@ -157,49 +203,71 @@ final class ThemeAccentColorController: ViewController {
return
}
let settings = (sharedData.entries[ApplicationSpecificSharedDataKeys.presentationThemeSettings] as? PresentationThemeSettings) ?? PresentationThemeSettings.defaultSettings
let autoNightModeTriggered = strongSelf.presentationData.autoNightModeTriggered
let themeReference: PresentationThemeReference
if autoNightModeTriggered {
themeReference = settings.automaticThemeSwitchSetting.theme
} else {
themeReference = settings.theme
}
let accentColor = settings.themeSpecificAccentColors[themeReference.index]?.color ?? defaultDayAccentColor
let wallpaper: TelegramWallpaper
if let customWallpaper = settings.themeSpecificChatWallpapers[themeReference.index] {
wallpaper = customWallpaper
} else {
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: nil, bubbleColors: nil, serviceBackgroundColor: defaultServiceBackgroundColor) ?? defaultPresentationTheme
wallpaper = theme.chat.defaultWallpaper
}
let accentColor: UIColor
let backgroundColors: (UIColor, UIColor?)?
if let initialBackgroundColor = strongSelf.initialBackgroundColor {
backgroundColors = (initialBackgroundColor, nil)
} else {
if case let .color(color) = wallpaper {
let messageColors: (UIColor, UIColor?)?
var defaultMessagesColor: UIColor?
if let themeReference = strongSelf.mode.themeReference {
accentColor = settings.themeSpecificAccentColors[themeReference.index]?.color ?? defaultDayAccentColor
let wallpaper: TelegramWallpaper
if let customWallpaper = settings.themeSpecificChatWallpapers[themeReference.index] {
wallpaper = customWallpaper
} else {
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: nil, bubbleColors: nil) ?? defaultPresentationTheme
wallpaper = theme.chat.defaultWallpaper
}
if let initialBackgroundColor = strongSelf.initialBackgroundColor {
backgroundColors = (initialBackgroundColor, nil)
} else {
if case let .color(color) = wallpaper {
backgroundColors = (UIColor(rgb: UInt32(bitPattern: color)), nil)
} else if case let .gradient(topColor, bottomColor, _) = wallpaper {
backgroundColors = (UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
} else {
backgroundColors = nil
}
}
if let bubbleColors = settings.themeSpecificAccentColors[themeReference.index]?.customBubbleColors {
if let bottomColor = bubbleColors.1 {
messageColors = (bubbleColors.0, bottomColor)
} else {
messageColors = (bubbleColors.0, nil)
}
} else {
messageColors = nil
}
if strongSelf.mode.themeReference == .builtin(.dayClassic) {
defaultMessagesColor = UIColor(rgb: 0xe1ffc7)
}
} else if case let .edit(theme, wallpaper, _, _) = strongSelf.mode {
accentColor = theme.rootController.navigationBar.accentTextColor
if case let .color(color) = theme.chat.defaultWallpaper {
backgroundColors = (UIColor(rgb: UInt32(bitPattern: color)), nil)
} else if case let .gradient(topColor, bottomColor) = wallpaper {
} else if case let .gradient(topColor, bottomColor, _) = theme.chat.defaultWallpaper {
backgroundColors = (UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
} else {
backgroundColors = nil
}
}
let messageColors: (UIColor, UIColor?)?
if let bubbleColors = settings.themeSpecificBubbleColors[themeReference.index] {
if let bottomColor = bubbleColors.optionalColor {
messageColors = (UIColor(rgb: UInt32(bitPattern: bubbleColors.color)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
let topMessageColor = theme.chat.message.outgoing.bubble.withWallpaper.fill
let bottomMessageColor = theme.chat.message.outgoing.bubble.withWallpaper.gradientFill
if topMessageColor.rgb == bottomMessageColor.rgb {
messageColors = (topMessageColor, nil)
} else {
messageColors = (UIColor(rgb: UInt32(bitPattern: bubbleColors.color)), nil)
messageColors = (topMessageColor, bottomMessageColor)
}
} else {
accentColor = UIColor(rgb: 0x007ee5)
backgroundColors = nil
messageColors = nil
}
let initialState = ThemeColorState(section: strongSelf.section, accentColor: accentColor, backgroundColors: backgroundColors, messagesColors: messageColors)
let initialState = ThemeColorState(section: strongSelf.section, accentColor: accentColor, backgroundColors: backgroundColors, defaultMessagesColor: defaultMessagesColor, messagesColors: messageColors)
strongSelf.controllerNode.updateState({ _ in
return initialState

View file

@ -37,6 +37,7 @@ struct ThemeColorState {
fileprivate var colorPanelCollapsed: Bool
var accentColor: UIColor
var backgroundColors: (UIColor, UIColor?)?
var defaultMessagesColor: UIColor?
var messagesColors: (UIColor, UIColor?)?
init() {
@ -47,11 +48,12 @@ struct ThemeColorState {
self.messagesColors = nil
}
init(section: ThemeColorSection, accentColor: UIColor, backgroundColors: (UIColor, UIColor?)?, messagesColors: (UIColor, UIColor?)?) {
init(section: ThemeColorSection, accentColor: UIColor, backgroundColors: (UIColor, UIColor?)?, defaultMessagesColor: UIColor?, messagesColors: (UIColor, UIColor?)?) {
self.section = section
self.colorPanelCollapsed = false
self.accentColor = accentColor
self.backgroundColors = backgroundColors
self.defaultMessagesColor = defaultMessagesColor
self.messagesColors = messagesColors
}
@ -94,7 +96,7 @@ struct ThemeColorState {
final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate {
private let context: AccountContext
private var theme: PresentationTheme
private let themeReference: PresentationThemeReference
private let mode: ThemeAccentColorControllerMode
private var presentationData: PresentationData
private var state: ThemeColorState
@ -118,6 +120,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
private let colors = Promise<(UIColor, (UIColor, UIColor?)?, (UIColor, UIColor?)?)>()
private let themePromise = Promise<PresentationTheme>()
private var wallpaper: TelegramWallpaper
private var serviceBackgroundColor: UIColor?
private var tapGestureRecognizer: UITapGestureRecognizer?
@ -129,9 +132,9 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
return self.state.backgroundColors == nil && self.chatBackgroundNode.image != nil
}
init(context: AccountContext, themeReference: PresentationThemeReference, theme: PresentationTheme, dismiss: @escaping () -> Void, apply: @escaping (ThemeColorState) -> Void) {
init(context: AccountContext, mode: ThemeAccentColorControllerMode, theme: PresentationTheme, wallpaper: TelegramWallpaper, dismiss: @escaping () -> Void, apply: @escaping (ThemeColorState, UIColor?) -> Void) {
self.context = context
self.themeReference = themeReference
self.mode = mode
self.state = ThemeColorState()
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
@ -160,10 +163,10 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
self.messagesContainerNode.clipsToBounds = true
self.messagesContainerNode.transform = CATransform3DMakeScale(1.0, -1.0, 1.0)
if case .color = self.presentationData.chatWallpaper {
if case .color = wallpaper {
} else {
self.chatBackgroundNode.image = chatControllerBackgroundImage(theme: theme, wallpaper: self.presentationData.chatWallpaper, mediaBox: context.sharedContext.accountManager.mediaBox, knockoutMode: false)
self.chatBackgroundNode.motionEnabled = self.presentationData.chatWallpaper.settings?.motion ?? false
self.chatBackgroundNode.image = chatControllerBackgroundImage(theme: theme, wallpaper: wallpaper, mediaBox: context.sharedContext.accountManager.mediaBox, knockoutMode: false)
self.chatBackgroundNode.motionEnabled = wallpaper.settings?.motion ?? false
}
self.colorPanelNode = WallpaperColorPanelNode(theme: self.theme, strings: self.presentationData.strings)
@ -221,6 +224,8 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
var updated = current
if let firstColor = firstColor {
updated.messagesColors = (firstColor, secondColor)
} else {
updated.messagesColors = nil
}
return updated
})
@ -243,18 +248,18 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
}
self.toolbarNode.done = { [weak self] in
if let strongSelf = self {
apply(strongSelf.state)
apply(strongSelf.state, strongSelf.serviceBackgroundColor)
}
}
self.colorsDisposable = (self.colors.get()
|> deliverOn(Queue.concurrentDefaultQueue())
|> map { accentColor, backgroundColors, messagesColors -> (PresentationTheme, (TelegramWallpaper, UIImage?)) in
|> map { accentColor, backgroundColors, messagesColors -> (PresentationTheme, (TelegramWallpaper, UIImage?), UIColor) in
var wallpaper = context.sharedContext.currentPresentationData.with { $0 }.chatWallpaper
var wallpaperImage: UIImage?
if let backgroundColors = backgroundColors {
if let bottomColor = backgroundColors.1 {
wallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: bottomColor.rgb))
wallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings())
wallpaperImage = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: context.sharedContext.accountManager.mediaBox, knockoutMode: false)
} else {
wallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb))
@ -262,13 +267,20 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
}
let serviceBackgroundColor = serviceColor(for: (wallpaper, wallpaperImage))
let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: accentColor, bubbleColors: messagesColors, serviceBackgroundColor: serviceBackgroundColor, preview: true) ?? defaultPresentationTheme
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
} else if case let .edit(theme, _, _, _) = mode {
updatedTheme = customizePresentationTheme(theme, editing: false, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: messagesColors)
} else {
updatedTheme = theme
}
let _ = PresentationResourcesChat.principalGraphics(mediaBox: context.account.postbox.mediaBox, knockoutWallpaper: context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper, theme: updatedTheme, wallpaper: wallpaper)
let _ = PresentationResourcesChat.principalGraphics(mediaBox: context.account.postbox.mediaBox, knockoutWallpaper: context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper, theme: theme, wallpaper: wallpaper)
return (theme, (wallpaper, wallpaperImage))
return (updatedTheme, (wallpaper, wallpaperImage), serviceBackgroundColor)
}
|> deliverOnMainQueue).start(next: { [weak self] theme, wallpaperAndImage in
|> deliverOnMainQueue).start(next: { [weak self] theme, wallpaperAndImage, serviceBackgroundColor in
guard let strongSelf = self else {
return
}
@ -277,6 +289,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
strongSelf.theme = theme
strongSelf.themeUpdated?(theme)
strongSelf.themePromise.set(.single(theme))
strongSelf.serviceBackgroundColor = serviceBackgroundColor
strongSelf.colorPanelNode.updateTheme(theme)
strongSelf.toolbarNode.updateThemeAndStrings(theme: theme, strings: strongSelf.presentationData.strings)
@ -302,7 +315,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
self.serviceColorDisposable = (self.themePromise.get()
|> mapToSignal { theme -> Signal<UIColor, NoError> in
return chatServiceBackgroundColor(wallpaper: self.presentationData.chatWallpaper, mediaBox: context.account.postbox.mediaBox)
return chatServiceBackgroundColor(wallpaper: wallpaper, mediaBox: context.account.postbox.mediaBox)
}
|> deliverOnMainQueue).start(next: { [weak self] color in
if let strongSelf = self {
@ -377,7 +390,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
secondColor = nil
}
case .messages:
defaultColor = self.state.accentColor ?? .blue
defaultColor = self.state.defaultMessagesColor ?? (self.state.accentColor ?? UIColor(rgb: 0x007e55))
if let messagesColors = self.state.messagesColors {
firstColor = messagesColors.0
secondColor = messagesColors.1

View file

@ -68,7 +68,7 @@ private enum ThemeAutoNightSettingsControllerEntry: ItemListNodeEntry {
case settingInfo(PresentationTheme, String)
case themeHeader(PresentationTheme, String)
case themeItem(PresentationTheme, PresentationStrings, [PresentationThemeReference], PresentationThemeReference, [Int64: PresentationThemeAccentColor], [Int64: PresentationThemeColorPair])
case themeItem(PresentationTheme, PresentationStrings, [PresentationThemeReference], PresentationThemeReference, [Int64: PresentationThemeAccentColor])
var section: ItemListSectionId {
switch self {
@ -186,8 +186,8 @@ private enum ThemeAutoNightSettingsControllerEntry: ItemListNodeEntry {
} else {
return false
}
case let .themeItem(lhsTheme, lhsStrings, lhsThemes, lhsCurrentTheme, lhsThemeAccentColors, lhsThemeBubbleColors):
if case let .themeItem(rhsTheme, rhsStrings, rhsThemes, rhsCurrentTheme, rhsThemeAccentColors, rhsThemeBubbleColors) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsThemes == rhsThemes, lhsCurrentTheme == rhsCurrentTheme, lhsThemeAccentColors == rhsThemeAccentColors, lhsThemeBubbleColors == rhsThemeBubbleColors {
case let .themeItem(lhsTheme, lhsStrings, lhsThemes, lhsCurrentTheme, lhsThemeAccentColors):
if case let .themeItem(rhsTheme, rhsStrings, rhsThemes, rhsCurrentTheme, rhsThemeAccentColors) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsThemes == rhsThemes, lhsCurrentTheme == rhsCurrentTheme, lhsThemeAccentColors == rhsThemeAccentColors {
return true
} else {
return false
@ -244,8 +244,8 @@ private enum ThemeAutoNightSettingsControllerEntry: ItemListNodeEntry {
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
case let .themeHeader(theme, title):
return ItemListSectionHeaderItem(presentationData: presentationData, text: title, sectionId: self.section)
case let .themeItem(theme, strings, themes, currentTheme, themeSpecificAccentColors, themeSpecificBubbleColors):
return ThemeSettingsThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: themes, displayUnsupported: false, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificBubbleColors: themeSpecificBubbleColors, currentTheme: currentTheme, updatedTheme: { theme in
case let .themeItem(theme, strings, themes, currentTheme, themeSpecificAccentColors):
return ThemeSettingsThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: themes, displayUnsupported: false, themeSpecificAccentColors: themeSpecificAccentColors, currentTheme: currentTheme, updatedTheme: { theme in
arguments.updateTheme(theme)
}, contextAction: nil)
}
@ -313,7 +313,7 @@ private func themeAutoNightSettingsControllerEntries(theme: PresentationTheme, s
break
case .system, .timeBased, .brightness:
entries.append(.themeHeader(theme, strings.AutoNightTheme_PreferredTheme))
entries.append(.themeItem(theme, strings, availableThemes, switchSetting.theme, settings.themeSpecificAccentColors, settings.themeSpecificBubbleColors))
entries.append(.themeItem(theme, strings, availableThemes, switchSetting.theme, settings.themeSpecificAccentColors))
}
return entries

View file

@ -143,7 +143,8 @@ final class ThemeColorsGridController: ViewController {
themeReference = settings.theme
}
let controller = ThemeAccentColorController(context: strongSelf.context, themeReference: themeReference, section: .background)
let controller = ThemeAccentColorController(context: strongSelf.context, mode: .background(themeReference: themeReference))
controller.navigationPresentation = .modalInLargeLayout
controller.completion = { [weak self] in
if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController {
let _ = navigationController.popViewController(animated: true)

View file

@ -183,7 +183,7 @@ final class ThemeGridController: ViewController {
let _ = (updatePresentationThemeSettingsInteractively(accountManager: strongSelf.context.sharedContext.accountManager, { current in
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
themeSpecificChatWallpapers[current.theme.index] = nil
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
})).start()
break
}
@ -243,7 +243,7 @@ final class ThemeGridController: ViewController {
}
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
themeSpecificChatWallpapers[current.theme.index] = nil
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: [:], useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: [:], useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
})
}).start()

View file

@ -30,8 +30,8 @@ private func areWallpapersEqual(_ lhs: TelegramWallpaper, _ rhs: TelegramWallpap
} else {
return false
}
case let .gradient(topColor, bottomColor):
if case .gradient(topColor, bottomColor) = rhs {
case let .gradient(topColor, bottomColor, _):
if case .gradient(topColor, bottomColor, _) = rhs {
return true
} else {
return false
@ -109,7 +109,7 @@ private struct ThemeGridControllerEntry: Comparable, Identifiable {
return 0
case let .color(color):
return (Int64(1) << 32) | Int64(bitPattern: UInt64(UInt32(bitPattern: color)))
case let .gradient(topColor, bottomColor):
case let .gradient(topColor, bottomColor, _):
var hash: UInt32 = UInt32(bitPattern: topColor)
hash = hash &* 31 &+ UInt32(bitPattern: bottomColor)
return (Int64(2) << 32) | Int64(hash)

View file

@ -311,7 +311,7 @@ public final class ThemePreviewController: ViewController {
theme = updatedTheme
}
return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
})
}
}

View file

@ -508,7 +508,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
} else {
dateHeaderNode = headerItem.node()
dateHeaderNode.subnodeTransform = CATransform3DMakeScale(-1.0, 1.0, 1.0)
//self.messagesContainerNode.addSubnode(dateHeaderNode)
self.messagesContainerNode.addSubnode(dateHeaderNode)
self.dateHeaderNode = dateHeaderNode
}

View file

@ -10,7 +10,7 @@ import TelegramUIPreferences
import ItemListUI
import PresentationDataUtils
private func generateSwatchImage(theme: PresentationTheme, color: PresentationThemeAccentColor, selected: Bool) -> UIImage? {
private func generateSwatchImage(theme: PresentationTheme, color: PresentationThemeAccentColor, bubbles: (UIColor, UIColor?)?, selected: Bool) -> UIImage? {
return generateImage(CGSize(width: 40.0, height: 40.0), rotatedContext: { size, context in
let bounds = CGRect(origin: CGPoint(), size: size)
context.clear(bounds)
@ -33,8 +33,33 @@ private func generateSwatchImage(theme: PresentationTheme, color: PresentationTh
context.setLineWidth(2.0)
if selected {
context.fillEllipse(in: bounds.insetBy(dx: 4.0, dy: 4.0))
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.strokeEllipse(in: bounds.insetBy(dx: 1.0, dy: 1.0))
context.setFillColor(UIColor.white.cgColor)
let dotSize = CGSize(width: 4.0, height: 4.0)
context.fillEllipse(in: CGRect(origin: CGPoint(x: 11.0, y: 18.0), size: dotSize))
context.fillEllipse(in: CGRect(origin: CGPoint(x: 18.0, y: 18.0), size: dotSize))
context.fillEllipse(in: CGRect(origin: CGPoint(x: 25.0, y: 18.0), size: dotSize))
} else {
context.fillEllipse(in: bounds)
}
@ -139,8 +164,8 @@ private final class ThemeSettingsAccentColorNode : ASDisplayNode {
self.addSubnode(self.iconNode)
}
func setup(theme: PresentationTheme, color: PresentationThemeAccentColor, selected: Bool, action: @escaping () -> Void) {
self.iconNode.image = generateSwatchImage(theme: theme, color: color, selected: selected)
func setup(theme: PresentationTheme, color: PresentationThemeAccentColor, bubbles: (UIColor, UIColor?)?, selected: Bool, action: @escaping () -> Void) {
self.iconNode.image = generateSwatchImage(theme: theme, color: color, bubbles: bubbles, selected: selected)
self.action = {
action()
}
@ -331,9 +356,13 @@ class ThemeSettingsAccentColorItemNode: ListViewItemNode, ItemListItemNode {
} else {
accentColor = PresentationThemeAccentColor(baseColor: color)
}
imageNode.setup(theme: item.theme, color: accentColor, selected: selected, action: { [weak self, weak imageNode] in
item.updated(accentColor)
imageNode.setup(theme: item.theme, color: accentColor, bubbles: accentColor.customBubbleColors, selected: selected, action: { [weak self, weak imageNode] in
if selected {
item.openColorPicker()
} else {
item.updated(accentColor)
}
if let imageNode = imageNode {
self?.scrollToNode(imageNode, animated: true)
}

View file

@ -130,10 +130,10 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
case fontSize(PresentationTheme, PresentationFontSize)
case chatPreview(PresentationTheme, PresentationTheme, TelegramWallpaper, PresentationFontSize, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, [ChatPreviewMessageItem])
case wallpaper(PresentationTheme, String)
case accentColor(PresentationTheme, PresentationThemeReference, String, PresentationThemeAccentColor?)
case accentColor(PresentationTheme, PresentationThemeReference, PresentationThemeAccentColor?)
case autoNightTheme(PresentationTheme, String, String)
case textSize(PresentationTheme, String, String)
case themeItem(PresentationTheme, PresentationStrings, [PresentationThemeReference], PresentationThemeReference, [Int64: PresentationThemeAccentColor], [Int64: PresentationThemeColorPair], PresentationThemeAccentColor?)
case themeItem(PresentationTheme, PresentationStrings, [PresentationThemeReference], PresentationThemeReference, [Int64: PresentationThemeAccentColor], PresentationThemeAccentColor?)
case iconHeader(PresentationTheme, String)
case iconItem(PresentationTheme, PresentationStrings, [PresentationAppIcon], String?)
case otherHeader(PresentationTheme, String)
@ -205,8 +205,8 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
} else {
return false
}
case let .accentColor(lhsTheme, lhsCurrentTheme, lhsText, lhsColor):
if case let .accentColor(rhsTheme, rhsCurrentTheme, rhsText, rhsColor) = rhs, lhsTheme === rhsTheme, lhsCurrentTheme == rhsCurrentTheme, lhsText == rhsText, lhsColor == rhsColor {
case let .accentColor(lhsTheme, lhsCurrentTheme, lhsColor):
if case let .accentColor(rhsTheme, rhsCurrentTheme, rhsColor) = rhs, lhsTheme === rhsTheme, lhsCurrentTheme == rhsCurrentTheme, lhsColor == rhsColor {
return true
} else {
return false
@ -229,8 +229,8 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
} else {
return false
}
case let .themeItem(lhsTheme, lhsStrings, lhsThemes, lhsCurrentTheme, lhsThemeAccentColors, lhsThemeBubbleColors, lhsCurrentColor):
if case let .themeItem(rhsTheme, rhsStrings, rhsThemes, rhsCurrentTheme, rhsThemeAccentColors, rhsThemeBubbleColors, rhsCurrentColor) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsThemes == rhsThemes, lhsCurrentTheme == rhsCurrentTheme, lhsThemeAccentColors == rhsThemeAccentColors, lhsThemeBubbleColors == rhsThemeBubbleColors, lhsCurrentColor == rhsCurrentColor {
case let .themeItem(lhsTheme, lhsStrings, lhsThemes, lhsCurrentTheme, lhsThemeAccentColors, lhsCurrentColor):
if case let .themeItem(rhsTheme, rhsStrings, rhsThemes, rhsCurrentTheme, rhsThemeAccentColors, rhsCurrentColor) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsThemes == rhsThemes, lhsCurrentTheme == rhsCurrentTheme, lhsThemeAccentColors == rhsThemeAccentColors, lhsCurrentColor == rhsCurrentColor {
return true
} else {
return false
@ -305,7 +305,7 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", sectionId: self.section, style: .blocks, action: {
arguments.openWallpaperSettings()
})
case let .accentColor(theme, currentTheme, _, color):
case let .accentColor(theme, currentTheme, color):
var defaultColor = PresentationThemeAccentColor(baseColor: .blue)
var colors = PresentationThemeBaseColor.allCases
if case let .builtin(name) = currentTheme {
@ -338,8 +338,8 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
})
case let .themeListHeader(theme, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .themeItem(theme, strings, themes, currentTheme, themeSpecificAccentColors, themeSpecificBubbleColors, _):
return ThemeSettingsThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: themes, displayUnsupported: true, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificBubbleColors: themeSpecificBubbleColors, currentTheme: currentTheme, updatedTheme: { theme in
case let .themeItem(theme, strings, themes, currentTheme, themeSpecificAccentColors, _):
return ThemeSettingsThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: themes, displayUnsupported: true, themeSpecificAccentColors: themeSpecificAccentColors, currentTheme: currentTheme, updatedTheme: { theme in
if case let .cloud(theme) = theme, theme.theme.file == nil {
if theme.theme.isCreator {
arguments.editTheme(theme)
@ -372,17 +372,17 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
}
}
private func themeSettingsControllerEntries(presentationData: PresentationData, presentationThemeSettings: PresentationThemeSettings, theme: PresentationTheme, themeReference: PresentationThemeReference, themeSpecificAccentColors: [Int64: PresentationThemeAccentColor], themeSpecificBubbleColors: [Int64: PresentationThemeColorPair], availableThemes: [PresentationThemeReference], autoNightSettings: AutomaticThemeSwitchSetting, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, dateTimeFormat: PresentationDateTimeFormat, largeEmoji: Bool, disableAnimations: Bool, availableAppIcons: [PresentationAppIcon], currentAppIconName: String?) -> [ThemeSettingsControllerEntry] {
private func themeSettingsControllerEntries(presentationData: PresentationData, presentationThemeSettings: PresentationThemeSettings, theme: PresentationTheme, themeReference: PresentationThemeReference, themeSpecificAccentColors: [Int64: PresentationThemeAccentColor], availableThemes: [PresentationThemeReference], autoNightSettings: AutomaticThemeSwitchSetting, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, dateTimeFormat: PresentationDateTimeFormat, largeEmoji: Bool, disableAnimations: Bool, availableAppIcons: [PresentationAppIcon], currentAppIconName: String?) -> [ThemeSettingsControllerEntry] {
var entries: [ThemeSettingsControllerEntry] = []
let title = presentationData.autoNightModeTriggered ? strings.Appearance_ColorThemeNight.uppercased() : strings.Appearance_ColorTheme.uppercased()
entries.append(.themeListHeader(presentationData.theme, title))
entries.append(.chatPreview(presentationData.theme, theme, wallpaper, presentationData.fontSize, presentationData.strings, dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (presentationData.strings.Appearance_PreviewReplyAuthor, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText)]))
entries.append(.themeItem(presentationData.theme, presentationData.strings, availableThemes, themeReference, themeSpecificAccentColors, themeSpecificBubbleColors, themeSpecificAccentColors[themeReference.index]))
entries.append(.themeItem(presentationData.theme, presentationData.strings, availableThemes, themeReference, themeSpecificAccentColors, themeSpecificAccentColors[themeReference.index]))
if case let .builtin(theme) = themeReference, theme != .dayClassic {
entries.append(.accentColor(presentationData.theme, themeReference, strings.Appearance_AccentColor, themeSpecificAccentColors[themeReference.index]))
entries.append(.accentColor(presentationData.theme, themeReference, themeSpecificAccentColors[themeReference.index]))
}
entries.append(.wallpaper(presentationData.theme, strings.Settings_ChatBackground))
@ -459,7 +459,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
selectThemeImpl?(theme)
}, selectFontSize: { size in
let _ = updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: size, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: size, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
}).start()
}, openWallpaperSettings: {
pushControllerImpl?(ThemeGridController(context: context))
@ -471,26 +471,24 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
currentTheme = current.automaticThemeSwitchSetting.theme
}
guard let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: currentTheme, accentColor: color.color, bubbleColors: nil, serviceBackgroundColor: defaultServiceBackgroundColor) else {
guard let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: currentTheme, accentColor: color.color, bubbleColors: nil) else {
return current
}
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
var themeSpecificAccentColors = current.themeSpecificAccentColors
var themeSpecificBubbleColors = current.themeSpecificBubbleColors
themeSpecificAccentColors[currentTheme.index] = color
themeSpecificBubbleColors[currentTheme.index] = nil
if let wallpaper = current.themeSpecificChatWallpapers[currentTheme.index], wallpaper.hasWallpaper {
} else {
themeSpecificChatWallpapers[currentTheme.index] = theme.chat.defaultWallpaper
}
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificBubbleColors: themeSpecificBubbleColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
}).start()
}, openAccentColorPicker: { themeReference in
let controller = ThemeAccentColorController(context: context, themeReference: themeReference, section: .accent)
presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
let controller = ThemeAccentColorController(context: context, mode: .colors(themeReference: themeReference))
pushControllerImpl?(controller)
}, openAutoNightTheme: {
pushControllerImpl?(themeAutoNightSettingsController(context: context))
}, openTextSize: {
@ -502,11 +500,11 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
})
}, toggleLargeEmoji: { largeEmoji in
let _ = updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: largeEmoji, disableAnimations: current.disableAnimations)
}).start()
}, disableAnimations: { value in
let _ = updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: value)
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: value)
}).start()
}, selectAppIcon: { name in
currentAppIconName.set(name)
@ -520,15 +518,11 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
})
pushControllerImpl?(controller)
}, contextAction: { isCurrent, reference, node, gesture in
let _ = (context.sharedContext.accountManager.transaction { transaction in
let _ = (context.sharedContext.accountManager.transaction { transaction -> PresentationThemeAccentColor? in
let settings = transaction.getSharedData(ApplicationSpecificSharedDataKeys.presentationThemeSettings) as? PresentationThemeSettings ?? PresentationThemeSettings.defaultSettings
let accentColor = settings.themeSpecificAccentColors[reference.index]?.color
let bubbleColors = settings.themeSpecificBubbleColors[reference.index]?.colors
return (accentColor, bubbleColors)
} |> map { accentColor, bubbleColors in
return makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: reference, accentColor: accentColor, bubbleColors: bubbleColors, serviceBackgroundColor: defaultServiceBackgroundColor)
return settings.themeSpecificAccentColors[reference.index]
} |> map { accentColor in
return makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: reference, accentColor: accentColor?.color, bubbleColors: accentColor?.customBubbleColors)
}
|> deliverOnMainQueue).start(next: { theme in
guard let theme = theme else {
@ -539,22 +533,34 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
let themeController = ThemePreviewController(context: context, previewTheme: theme, source: .settings(reference))
var items: [ContextMenuItem] = []
if !isCurrent {
items.append(.action(ContextMenuActionItem(text: strings.Theme_Context_Apply, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ApplyTheme"), color: theme.contextMenu.primaryColor) }, action: { c, f in
c.dismiss(completion: {
selectThemeImpl?(reference)
})
})))
}
if case let .cloud(theme) = reference {
if theme.theme.isCreator {
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Appearance_EditTheme, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.contextMenu.primaryColor) }, action: { c, f in
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Appearance_EditTheme, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ApplyTheme"), color: theme.contextMenu.primaryColor) }, action: { c, f in
let controller = editThemeController(context: context, mode: .edit(theme), navigateToChat: { peerId in
if let navigationController = getNavigationControllerImpl?() {
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
}
})
c.dismiss(completion: {
pushControllerImpl?(controller)
})
})))
} else {
items.append(.action(ContextMenuActionItem(text: strings.Theme_Context_ChangeColors, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ApplyTheme"), color: theme.contextMenu.primaryColor) }, action: { c, f in
guard let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: reference, accentColor: nil, bubbleColors: nil, backgroundColors: nil, preview: false) else {
return
}
let controller = ThemeAccentColorController(context: context, mode: .edit(theme: theme, wallpaper: nil, defaultThemeReference: nil, completion: { result in
let controller = editThemeController(context: context, mode: .create(result), navigateToChat: { peerId in
if let navigationController = getNavigationControllerImpl?() {
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
}
})
pushControllerImpl?(controller)
}))
c.dismiss(completion: {
pushControllerImpl?(controller)
})
@ -597,6 +603,14 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
presentControllerImpl?(actionSheet, nil)
})
})))
} else {
items.append(.action(ContextMenuActionItem(text: strings.Theme_Context_ChangeColors, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ApplyTheme"), color: theme.contextMenu.primaryColor)
}, action: { c, f in
c.dismiss(completion: {
let controller = ThemeAccentColorController(context: context, mode: .colors(themeReference: reference))
pushControllerImpl?(controller)
})
})))
}
let contextController = ContextController(account: context.account, presentationData: presentationData, source: .controller(ContextControllerContentSourceImpl(controller: themeController, sourceNode: node)), items: .single(items), reactionItems: [], gesture: gesture)
@ -624,7 +638,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
let accentColor = settings.themeSpecificAccentColors[themeReference.index]?.color
let wallpaper = presentationData.chatWallpaper
let rightNavigationButton = ItemListNavigationButton(content: .icon(.action), style: .regular, enabled: true, action: {
let rightNavigationButton = ItemListNavigationButton(content: .icon(.add), style: .regular, enabled: true, action: {
moreImpl?()
})
@ -644,7 +658,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
availableThemes.append(contentsOf: cloudThemes)
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(presentationData.strings.Appearance_Title), leftNavigationButton: nil, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back))
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: themeSettingsControllerEntries(presentationData: presentationData, presentationThemeSettings: settings, theme: theme, themeReference: themeReference, themeSpecificAccentColors: settings.themeSpecificAccentColors, themeSpecificBubbleColors: settings.themeSpecificBubbleColors, availableThemes: availableThemes, autoNightSettings: settings.automaticThemeSwitchSetting, strings: presentationData.strings, wallpaper: wallpaper, fontSize: fontSize, dateTimeFormat: dateTimeFormat, largeEmoji: largeEmoji, disableAnimations: disableAnimations, availableAppIcons: availableAppIcons, currentAppIconName: currentAppIconName), style: .blocks, ensureVisibleItemTag: focusOnItemTag, animateChanges: false)
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: themeSettingsControllerEntries(presentationData: presentationData, presentationThemeSettings: settings, theme: theme, themeReference: themeReference, themeSpecificAccentColors: settings.themeSpecificAccentColors, availableThemes: availableThemes, autoNightSettings: settings.automaticThemeSwitchSetting, strings: presentationData.strings, wallpaper: wallpaper, fontSize: fontSize, dateTimeFormat: dateTimeFormat, largeEmoji: largeEmoji, disableAnimations: disableAnimations, availableAppIcons: availableAppIcons, currentAppIconName: currentAppIconName), style: .blocks, ensureVisibleItemTag: focusOnItemTag, animateChanges: false)
return (controllerState, (listState, arguments))
}
@ -709,7 +723,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
theme = updatedTheme
}
return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
})
})
}).start()
@ -721,12 +735,35 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
items.append(ActionSheetButtonItem(title: presentationData.strings.Appearance_CreateTheme, color: .accent, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
let controller = editThemeController(context: context, mode: .create, navigateToChat: { peerId in
if let navigationController = getNavigationControllerImpl?() {
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
let _ = (context.sharedContext.accountManager.transaction { transaction -> PresentationThemeReference? in
let settings = transaction.getSharedData(ApplicationSpecificSharedDataKeys.presentationThemeSettings) as? PresentationThemeSettings ?? PresentationThemeSettings.defaultSettings
var themeReference: PresentationThemeReference?
let autoNightModeTriggered = context.sharedContext.currentPresentationData.with { $0 }.autoNightModeTriggered
if autoNightModeTriggered {
themeReference = settings.automaticThemeSwitchSetting.theme
} else {
themeReference = settings.theme
}
if let themeReference = themeReference, case .builtin = themeReference {
} else {
themeReference = nil
}
return themeReference
}
|> deliverOnMainQueue).start(next: { themeReference in
let controller = ThemeAccentColorController(context: context, mode: .edit(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper, defaultThemeReference: themeReference, completion: { result in
let controller = editThemeController(context: context, mode: .create(result), navigateToChat: { peerId in
if let navigationController = getNavigationControllerImpl?() {
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
}
})
pushControllerImpl?(controller)
}))
pushControllerImpl?(controller)
})
pushControllerImpl?(controller)
}))
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in

View file

@ -89,20 +89,18 @@ class ThemeSettingsThemeItem: ListViewItem, ItemListItem {
let themes: [PresentationThemeReference]
let displayUnsupported: Bool
let themeSpecificAccentColors: [Int64: PresentationThemeAccentColor]
let themeSpecificBubbleColors: [Int64: PresentationThemeColorPair]
let currentTheme: PresentationThemeReference
let updatedTheme: (PresentationThemeReference) -> Void
let contextAction: ((PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void)?
let tag: ItemListItemTag?
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, sectionId: ItemListSectionId, themes: [PresentationThemeReference], displayUnsupported: Bool, themeSpecificAccentColors: [Int64: PresentationThemeAccentColor], themeSpecificBubbleColors: [Int64: PresentationThemeColorPair], currentTheme: PresentationThemeReference, updatedTheme: @escaping (PresentationThemeReference) -> Void, contextAction: ((PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void)?, tag: ItemListItemTag? = nil) {
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, sectionId: ItemListSectionId, themes: [PresentationThemeReference], displayUnsupported: Bool, themeSpecificAccentColors: [Int64: PresentationThemeAccentColor], currentTheme: PresentationThemeReference, updatedTheme: @escaping (PresentationThemeReference) -> Void, contextAction: ((PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void)?, tag: ItemListItemTag? = nil) {
self.context = context
self.theme = theme
self.strings = strings
self.themes = themes
self.displayUnsupported = displayUnsupported
self.themeSpecificAccentColors = themeSpecificAccentColors
self.themeSpecificBubbleColors = themeSpecificBubbleColors
self.currentTheme = currentTheme
self.updatedTheme = updatedTheme
self.contextAction = contextAction
@ -423,7 +421,7 @@ class ThemeSettingsThemeItemNode: ListViewItemNode, ItemListItemNode {
}
let name = themeDisplayName(strings: item.strings, reference: theme)
imageNode.setup(context: item.context, theme: theme, accentColor: item.themeSpecificAccentColors[theme.index]?.color, bubbleColors: item.themeSpecificBubbleColors[theme.index]?.plainColors, currentTheme: item.theme, title: NSAttributedString(string: name, font: selected ? selectedTextFont : textFont, textColor: selected ? item.theme.list.itemAccentColor : item.theme.list.itemPrimaryTextColor, paragraphAlignment: .center), bordered: true, selected: selected, action: { [weak self, weak imageNode] in
imageNode.setup(context: item.context, theme: theme, accentColor: item.themeSpecificAccentColors[theme.index]?.color, bubbleColors: item.themeSpecificAccentColors[theme.index]?.plainBubbleColors, currentTheme: item.theme, title: NSAttributedString(string: name, font: selected ? selectedTextFont : textFont, textColor: selected ? item.theme.list.itemAccentColor : item.theme.list.itemPrimaryTextColor, paragraphAlignment: .center), bordered: true, selected: selected, action: { [weak self, weak imageNode] in
item.updatedTheme(theme)
if let imageNode = imageNode {
self?.scrollToNode(imageNode, animated: true)

View file

@ -502,6 +502,7 @@ final class WallpaperColorPanelNode: ASDisplayNode {
}
func updateState(_ f: (WallpaperColorPanelNodeState) -> WallpaperColorPanelNodeState, updateLayout: Bool = true, animated: Bool = true) {
var updateLayout = updateLayout
let previousFirstColor = self.state.firstColor
let previousSecondColor = self.state.secondColor
self.state = f(self.state)
@ -527,6 +528,12 @@ final class WallpaperColorPanelNode: ASDisplayNode {
self.secondColorFieldNode.setColor(secondColor, update: false)
}
var firstColorWasRemovable = self.firstColorFieldNode.isRemovable
self.firstColorFieldNode.isRemovable = self.state.secondColor != nil || (self.state.defaultColor != nil && self.state.firstColor != nil)
if firstColorWasRemovable != self.firstColorFieldNode.isRemovable {
updateLayout = true
}
if updateLayout, let size = self.validLayout {
switch self.state.selection {
case .first:

View file

@ -391,7 +391,7 @@ public class WallpaperGalleryController: ViewController {
} else {
themeSpecificChatWallpapers[current.theme.index] = wallpaper
}
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
}) |> deliverOnMainQueue).start(completed: {
self?.dismiss(forceAway: true)
})
@ -810,6 +810,8 @@ public class WallpaperGalleryController: ViewController {
controller = ShareController(context: context, subject: .url("https://t.me/bg/\(slug)\(optionsString)"))
case let .color(color):
controller = ShareController(context: context, subject: .url("https://t.me/bg/\(UIColor(rgb: UInt32(bitPattern: color)).hexString)"))
case let .gradient(topColor, bottomColor, _):
controller = ShareController(context: context, subject:. url("https://t.me/bg/\(UIColor(rgb: UInt32(bitPattern: topColor)).hexString)-\(UIColor(rgb: UInt32(bitPattern: bottomColor)).hexString)"))
default:
break
}

View file

@ -233,13 +233,14 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
actionSignal = .single(defaultAction)
colorSignal = chatServiceBackgroundColor(wallpaper: wallpaper, mediaBox: self.context.account.postbox.mediaBox)
isBlurrable = false
case let .gradient(topColor, bottomColor):
case let .gradient(topColor, bottomColor, _):
displaySize = CGSize(width: 1.0, height: 1.0)
contentSize = displaySize
signal = gradientImage([UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor))])
fetchSignal = .complete()
statusSignal = .single(.Local)
subtitleSignal = .single(nil)
actionSignal = .single(defaultAction)
colorSignal = chatServiceBackgroundColor(wallpaper: wallpaper, mediaBox: self.context.account.postbox.mediaBox)
isBlurrable = false
case let .file(file):
@ -724,9 +725,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
motionAlpha = 1.0
motionFrame = rightButtonFrame
case .gradient:
blurAlpha = 0.0
patternAlpha = 0.0
motionAlpha = 0.0
motionAlpha = 1.0
case let .file(file):
if file.isPattern {
motionAlpha = 1.0

View file

@ -21,7 +21,8 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
private let buttonBackgroundNode: ASImageNode
private let buttonGlossNode: SolidRoundedButtonGlossNode
private let buttonNode: HighlightTrackingButtonNode
private let labelNode: ImmediateTextNode
private let titleNode: ImmediateTextNode
private let subtitleNode: ImmediateTextNode
private let iconNode: ASImageNode
private let buttonHeight: CGFloat
@ -38,6 +39,14 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
}
}
public var subtitle: String? {
didSet {
if let width = self.validLayout {
_ = self.updateLayout(width: width, previousSubtitle: oldValue, transition: .immediate)
}
}
}
public init(title: String? = nil, icon: UIImage? = nil, theme: SolidRoundedButtonTheme, height: CGFloat = 48.0, cornerRadius: CGFloat = 24.0, gloss: Bool = false) {
self.theme = theme
self.buttonHeight = height
@ -54,8 +63,11 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
self.buttonNode = HighlightTrackingButtonNode()
self.labelNode = ImmediateTextNode()
self.labelNode.isUserInteractionEnabled = false
self.titleNode = ImmediateTextNode()
self.titleNode.isUserInteractionEnabled = false
self.subtitleNode = ImmediateTextNode()
self.subtitleNode.isUserInteractionEnabled = false
self.iconNode = ASImageNode()
self.iconNode.displayWithoutProcessing = true
@ -69,7 +81,8 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
self.addSubnode(self.buttonGlossNode)
}
self.addSubnode(self.buttonNode)
self.addSubnode(self.labelNode)
self.addSubnode(self.titleNode)
self.addSubnode(self.subtitleNode)
self.addSubnode(self.iconNode)
self.buttonNode.addTarget(self, action: #selector(self.buttonPressed), forControlEvents: .touchUpInside)
@ -78,15 +91,19 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
if highlighted {
strongSelf.buttonBackgroundNode.layer.removeAnimation(forKey: "opacity")
strongSelf.buttonBackgroundNode.alpha = 0.55
strongSelf.labelNode.layer.removeAnimation(forKey: "opacity")
strongSelf.labelNode.alpha = 0.55
strongSelf.titleNode.layer.removeAnimation(forKey: "opacity")
strongSelf.titleNode.alpha = 0.55
strongSelf.subtitleNode.layer.removeAnimation(forKey: "opacity")
strongSelf.subtitleNode.alpha = 0.55
strongSelf.iconNode.layer.removeAnimation(forKey: "opacity")
strongSelf.iconNode.alpha = 0.55
} else {
strongSelf.buttonBackgroundNode.alpha = 1.0
strongSelf.buttonBackgroundNode.layer.animateAlpha(from: 0.55, to: 1.0, duration: 0.2)
strongSelf.labelNode.alpha = 1.0
strongSelf.labelNode.layer.animateAlpha(from: 0.55, to: 1.0, duration: 0.2)
strongSelf.titleNode.alpha = 1.0
strongSelf.titleNode.layer.animateAlpha(from: 0.55, to: 1.0, duration: 0.2)
strongSelf.subtitleNode.alpha = 1.0
strongSelf.subtitleNode.layer.animateAlpha(from: 0.55, to: 1.0, duration: 0.2)
strongSelf.iconNode.alpha = 1.0
strongSelf.iconNode.layer.animateAlpha(from: 0.55, to: 1.0, duration: 0.2)
}
@ -102,10 +119,15 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
self.buttonBackgroundNode.image = generateStretchableFilledCircleImage(radius: self.buttonCornerRadius, color: theme.backgroundColor)
self.buttonGlossNode.color = theme.foregroundColor
self.labelNode.attributedText = NSAttributedString(string: self.title ?? "", font: Font.semibold(17.0), textColor: theme.foregroundColor)
self.titleNode.attributedText = NSAttributedString(string: self.title ?? "", font: Font.semibold(17.0), textColor: theme.foregroundColor)
self.subtitleNode.attributedText = NSAttributedString(string: self.subtitle ?? "", font: Font.regular(14.0), textColor: theme.foregroundColor)
}
public func updateLayout(width: CGFloat, transition: ContainedViewLayoutTransition) -> CGFloat {
return self.updateLayout(width: width, previousSubtitle: nil, transition: transition)
}
private func updateLayout(width: CGFloat, previousSubtitle: String?, transition: ContainedViewLayoutTransition) -> CGFloat {
self.validLayout = width
let buttonSize = CGSize(width: width, height: self.buttonHeight)
@ -114,16 +136,16 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
transition.updateFrame(node: self.buttonGlossNode, frame: buttonFrame)
transition.updateFrame(node: self.buttonNode, frame: buttonFrame)
if self.title != self.labelNode.attributedText?.string {
self.labelNode.attributedText = NSAttributedString(string: self.title ?? "", font: Font.semibold(17.0), textColor: self.theme.foregroundColor)
if self.title != self.titleNode.attributedText?.string {
self.titleNode.attributedText = NSAttributedString(string: self.title ?? "", font: Font.semibold(17.0), textColor: self.theme.foregroundColor)
}
let iconSize = self.iconNode.image?.size ?? CGSize()
let labelSize = self.labelNode.updateLayout(buttonSize)
let titleSize = self.titleNode.updateLayout(buttonSize)
let iconSpacing: CGFloat = 8.0
var contentWidth: CGFloat = labelSize.width
var contentWidth: CGFloat = titleSize.width
if !iconSize.width.isZero {
contentWidth += iconSize.width + iconSpacing
}
@ -133,8 +155,25 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
nextContentOrigin += iconSize.width + iconSpacing
}
let labelFrame = CGRect(origin: CGPoint(x: buttonFrame.minX + nextContentOrigin, y: buttonFrame.minY + floor((buttonFrame.height - labelSize.height) / 2.0)), size: labelSize)
transition.updateFrame(node: self.labelNode, frame: labelFrame)
let spacingOffset: CGFloat = 9.0
var verticalInset: CGFloat = self.subtitle == nil ? floor((buttonFrame.height - titleSize.height) / 2.0) : floor((buttonFrame.height - titleSize.height) / 2.0) - spacingOffset
let titleFrame = CGRect(origin: CGPoint(x: buttonFrame.minX + nextContentOrigin, y: buttonFrame.minY + verticalInset), size: titleSize)
transition.updateFrame(node: self.titleNode, frame: titleFrame)
if self.subtitle != self.subtitleNode.attributedText?.string {
self.subtitleNode.attributedText = NSAttributedString(string: self.subtitle ?? "", font: Font.regular(14.0), textColor: self.theme.foregroundColor)
}
let subtitleSize = self.subtitleNode.updateLayout(buttonSize)
let subtitleFrame = CGRect(origin: CGPoint(x: buttonFrame.minX + floor((buttonFrame.width - subtitleSize.width) / 2.0), y: buttonFrame.minY + floor((buttonFrame.height - titleSize.height) / 2.0) + spacingOffset + 2.0), size: subtitleSize)
transition.updateFrame(node: self.subtitleNode, frame: subtitleFrame)
if previousSubtitle == nil && self.subtitle != nil {
self.titleNode.layer.animatePosition(from: CGPoint(x: 0.0, y: spacingOffset / 2.0), to: CGPoint(), duration: 0.3, additive: true)
self.subtitleNode.layer.animatePosition(from: CGPoint(x: 0.0, y: -spacingOffset / 2.0), to: CGPoint(), duration: 0.3, additive: true)
self.subtitleNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
}
return buttonSize.height
}
@ -164,7 +203,7 @@ public final class SolidRoundedButtonGlossNode: ASDisplayNode {
}
}
private var progress: CGFloat = 0.0
private var displayLink: CADisplayLink?
private var animator: ConstantDisplayLinkAnimator?
private let buttonCornerRadius: CGFloat
private var gradientColors: NSArray?
@ -177,28 +216,33 @@ public final class SolidRoundedButtonGlossNode: ASDisplayNode {
self.isOpaque = false
self.isLayerBacked = true
class DisplayLinkProxy: NSObject {
weak var target: SolidRoundedButtonGlossNode?
init(target: SolidRoundedButtonGlossNode) {
self.target = target
var previousTime: CFAbsoluteTime?
self.animator = ConstantDisplayLinkAnimator(update: { [weak self] in
guard let strongSelf = self else {
return
}
@objc func displayLinkEvent() {
self.target?.displayLinkEvent()
let currentTime = CFAbsoluteTimeGetCurrent()
if let previousTime = previousTime {
var delta: CGFloat
if strongSelf.progress < 0.05 || strongSelf.progress > 0.95 {
delta = 0.001
} else {
delta = 0.009
}
delta *= CGFloat(currentTime - previousTime) * 60.0
var newProgress = strongSelf.progress + delta
if newProgress > 1.0 {
newProgress = 0.0
}
strongSelf.progress = newProgress
strongSelf.setNeedsDisplay()
}
}
self.displayLink = CADisplayLink(target: DisplayLinkProxy(target: self), selector: #selector(DisplayLinkProxy.displayLinkEvent))
self.displayLink?.isPaused = true
self.displayLink?.add(to: RunLoop.main, forMode: .common)
previousTime = currentTime
})
self.updateGradientColors()
}
deinit {
self.displayLink?.invalidate()
}
private func updateGradientColors() {
let transparentColor = self.color.withAlphaComponent(0.0).cgColor
self.gradientColors = [transparentColor, transparentColor, self.color.withAlphaComponent(0.12).cgColor, transparentColor, transparentColor]
@ -206,27 +250,12 @@ public final class SolidRoundedButtonGlossNode: ASDisplayNode {
override public func willEnterHierarchy() {
super.willEnterHierarchy()
self.displayLink?.isPaused = false
self.animator?.isPaused = false
}
override public func didExitHierarchy() {
super.didExitHierarchy()
self.displayLink?.isPaused = true
}
private func displayLinkEvent() {
let delta: CGFloat
if self.progress < 0.05 || self.progress > 0.95 {
delta = 0.001
} else {
delta = 0.009
}
var newProgress = self.progress + delta
if newProgress > 1.0 {
newProgress = 0.0
}
self.progress = newProgress
self.setNeedsDisplay()
self.animator?.isPaused = true
}
override public func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? {

View file

@ -39,7 +39,7 @@ public struct WallpaperSettings: PostboxCoding, Equatable {
public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
case builtin(WallpaperSettings)
case color(Int32)
case gradient(Int32, Int32)
case gradient(Int32, Int32, WallpaperSettings)
case image([TelegramMediaImageRepresentation], WallpaperSettings)
case file(id: Int64, accessHash: Int64, isCreator: Bool, isDefault: Bool, isPattern: Bool, isDark: Bool, slug: String, file: TelegramMediaFile, settings: WallpaperSettings)
@ -61,7 +61,8 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
self = .color(0xffffff)
}
case 4:
self = .gradient(decoder.decodeInt32ForKey("c1", orElse: 0), decoder.decodeInt32ForKey("c2", orElse: 0))
let settings = decoder.decodeObjectForKey("settings", decoder: { WallpaperSettings(decoder: $0) }) as? WallpaperSettings ?? WallpaperSettings()
self = .gradient(decoder.decodeInt32ForKey("c1", orElse: 0), decoder.decodeInt32ForKey("c2", orElse: 0), settings)
default:
assertionFailure()
self = .color(0xffffff)
@ -85,10 +86,11 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
case let .color(color):
encoder.encodeInt32(1, forKey: "v")
encoder.encodeInt32(color, forKey: "c")
case let .gradient(topColor, bottomColor):
case let .gradient(topColor, bottomColor, settings):
encoder.encodeInt32(4, forKey: "v")
encoder.encodeInt32(topColor, forKey: "c1")
encoder.encodeInt32(bottomColor, forKey: "c2")
encoder.encodeObject(settings, forKey: "settings")
case let .image(representations, settings):
encoder.encodeInt32(2, forKey: "v")
encoder.encodeObjectArray(representations, forKey: "i")
@ -121,8 +123,8 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
} else {
return false
}
case let .gradient(topColor, bottomColor):
if case .gradient(topColor, bottomColor) = rhs {
case let .gradient(topColor, bottomColor, settings):
if case .gradient(topColor, bottomColor, settings) = rhs {
return true
} else {
return false
@ -144,7 +146,7 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
public var settings: WallpaperSettings? {
switch self {
case let .builtin(settings), let .image(_, settings), let .file(_, _, _, _, _, _, _, _, settings):
case let .builtin(settings), let .gradient(_, _, settings), let .image(_, settings), let .file(_, _, _, _, _, _, _, _, settings):
return settings
default:
return nil
@ -157,8 +159,8 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
return .builtin(settings)
case .color:
return self
case .gradient:
return self
case let .gradient(topColor, bottomColor, _):
return .gradient(topColor, bottomColor, settings)
case let .image(representations, _):
return .image(representations, settings)
case let .file(id, accessHash, isCreator, isDefault, isPattern, isDark, slug, file, _):

View file

@ -41,7 +41,7 @@ public func chatControllerBackgroundImage(theme: PresentationTheme?, wallpaper i
context.setFillColor(UIColor(rgb: UInt32(bitPattern: color)).withAlphaComponent(1.0).cgColor)
context.fill(CGRect(origin: CGPoint(), size: size))
})
case let .gradient(topColor, bottomColor):
case let .gradient(topColor, bottomColor, _):
backgroundImage = generateImage(CGSize(width: 1.0, height: 1280.0), rotatedContext: { size, context in
let gradientColors = [UIColor(rgb: UInt32(bitPattern: topColor)).cgColor, UIColor(rgb: UInt32(bitPattern: bottomColor)).cgColor] as CFArray

View file

@ -1,102 +1,234 @@
import Foundation
import UIKit
import TelegramCore
import SyncCore
import TelegramUIPreferences
private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UIColor, UIColor?)?, preview: Bool) -> PresentationTheme {
let destructiveColor: UIColor = UIColor(rgb: 0xeb5545)
let constructiveColor: UIColor = UIColor(rgb: 0x08a723)
let secretColor: UIColor = UIColor(rgb: 0x00b12c)
public let defaultDarkPresentationTheme = makeDefaultDarkPresentationTheme(preview: false)
public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, editing: Bool, accentColor: UIColor?, backgroundColors: (UIColor, UIColor?)?, bubbleColors: (UIColor, UIColor?)?) -> PresentationTheme {
if (theme.referenceTheme != .night) {
return theme
}
var intro = theme.intro
var rootController = theme.rootController
var list = theme.list
var chatList = theme.chatList
var chat = theme.chat
var actionSheet = theme.actionSheet
let badgeFillColor: UIColor
let badgeTextColor: UIColor
let secondaryBadgeTextColor: UIColor
let outgoingBubbleFillColor: UIColor
var outgoingBubbleFillGradientColor: UIColor
let outgoingBubbleHighlightedFillColor: UIColor
let outgoingScamColor: UIColor
var bubbleColors = bubbleColors
var monochrome = false
if bubbleColors == nil, editing {
let accentColor = accentColor ?? UIColor(rgb: 0xffffff)
if accentColor.rgb == 0xffffff {
monochrome = true
bubbleColors = (UIColor(rgb: 0x313131), UIColor(rgb: 0x313131))
} else {
bubbleColors = (accentColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98), accentColor)
}
}
let outgoingPrimaryTextColor: UIColor
let outgoingSecondaryTextColor: UIColor
let outgoingLinkTextColor: UIColor
let outgoingCheckColor: UIColor
var badgeFillColor: UIColor?
var badgeTextColor: UIColor?
var secondaryBadgeTextColor: UIColor?
var accentColor = accentColor
if accentColor.rgb == UIColor.white.rgb && bubbleColors == nil {
badgeFillColor = UIColor(rgb: 0xffffff)
badgeTextColor = UIColor(rgb: 0x000000)
secondaryBadgeTextColor = UIColor(rgb: 0x000000)
outgoingBubbleFillColor = UIColor(rgb: 0x313131)
outgoingBubbleFillGradientColor = outgoingBubbleFillColor
outgoingBubbleHighlightedFillColor = UIColor(rgb: 0x464646)
outgoingScamColor = destructiveColor
outgoingPrimaryTextColor = UIColor(rgb: 0xffffff)
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
outgoingLinkTextColor = UIColor(rgb: 0xffffff)
outgoingCheckColor = UIColor(rgb: 0xffffff, alpha: 0.5)
} else {
badgeFillColor = destructiveColor
badgeTextColor = UIColor(rgb: 0xffffff)
if let bubbleColors = bubbleColors {
outgoingBubbleFillColor = bubbleColors.0
outgoingBubbleFillGradientColor = bubbleColors.1 ?? bubbleColors.0
if let initialAccentColor = accentColor {
if monochrome {
badgeFillColor = UIColor(rgb: 0xffffff)
badgeTextColor = UIColor(rgb: 0x000000)
secondaryBadgeTextColor = UIColor(rgb: 0x000000)
} else {
outgoingBubbleFillColor = accentColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98)
outgoingBubbleFillGradientColor = accentColor
badgeFillColor = UIColor(rgb: 0xeb5545)
badgeTextColor = UIColor(rgb: 0xffffff)
if initialAccentColor.lightness > 0.7 {
secondaryBadgeTextColor = UIColor(rgb: 0x000000)
} else {
secondaryBadgeTextColor = UIColor(rgb: 0xffffff)
let hsb = initialAccentColor.hsb
accentColor = UIColor(hue: hsb.0, saturation: hsb.1, brightness: max(hsb.2, 0.55), alpha: 1.0)
}
}
outgoingBubbleHighlightedFillColor = accentColor.withMultipliedBrightnessBy(1.421)
let outgoingBubbleLightnessColor = outgoingBubbleFillColor.mixedWith(outgoingBubbleFillGradientColor, alpha: 0.5)
if outgoingBubbleLightnessColor.lightness > 0.7 {
outgoingScamColor = UIColor(rgb: 0x000000)
intro = intro.withUpdated(accentTextColor: accentColor, startButtonColor: accentColor)
rootController = rootController.withUpdated(
tabBar: rootController.tabBar.withUpdated(selectedIconColor: accentColor, selectedTextColor: accentColor, badgeBackgroundColor: badgeFillColor, badgeTextColor: badgeTextColor),
navigationBar: rootController.navigationBar.withUpdated(buttonColor: accentColor, accentTextColor: accentColor, badgeBackgroundColor: badgeFillColor, badgeTextColor: badgeTextColor),
navigationSearchBar: rootController.navigationSearchBar.withUpdated(accentColor: accentColor)
)
list = list.withUpdated(
itemAccentColor: accentColor,
itemDisclosureActions: list.itemDisclosureActions.withUpdated(accent: list.itemDisclosureActions.accent.withUpdated(fillColor: accentColor)),
itemCheckColors: list.itemCheckColors.withUpdated(fillColor: accentColor, foregroundColor: secondaryBadgeTextColor),
itemBarChart: list.itemBarChart.withUpdated(color1: accentColor)
)
chatList = chatList.withUpdated(
checkmarkColor: accentColor,
unreadBadgeActiveBackgroundColor: accentColor,
unreadBadgeActiveTextColor: secondaryBadgeTextColor,
verifiedIconFillColor: accentColor,
verifiedIconForegroundColor: badgeTextColor
)
actionSheet = actionSheet.withUpdated(
standardActionTextColor: accentColor,
controlAccentColor: accentColor,
checkContentColor: secondaryBadgeTextColor
)
}
var defaultWallpaper: TelegramWallpaper?
if let backgroundColors = backgroundColors {
if let secondColor = backgroundColors.1 {
defaultWallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: secondColor.rgb), WallpaperSettings())
} else {
defaultWallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb))
}
}
var outgoingBubbleFillColor: UIColor?
var outgoingBubbleFillGradientColor: UIColor?
var outgoingBubbleHighlightedFillColor: UIColor?
var outgoingPrimaryTextColor: UIColor?
var outgoingSecondaryTextColor: UIColor?
var outgoingLinkTextColor: UIColor?
var outgoingScamColor: UIColor?
var outgoingCheckColor: UIColor?
if let bubbleColors = bubbleColors {
outgoingBubbleFillColor = bubbleColors.0
outgoingBubbleFillGradientColor = bubbleColors.1 ?? bubbleColors.0
let lightnessColor = bubbleColors.0.mixedWith(bubbleColors.1 ?? bubbleColors.0, alpha: 0.5)
if lightnessColor.lightness > 0.7 {
outgoingPrimaryTextColor = UIColor(rgb: 0x000000)
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.5)
outgoingLinkTextColor = UIColor(rgb: 0x000000)
outgoingScamColor = UIColor(rgb: 0x000000)
outgoingCheckColor = UIColor(rgb: 0x000000, alpha: 0.5)
} else {
outgoingScamColor = UIColor(rgb: 0xffffff)
outgoingPrimaryTextColor = UIColor(rgb: 0xffffff)
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
outgoingLinkTextColor = UIColor(rgb: 0xffffff)
outgoingScamColor = UIColor(rgb: 0xffffff)
outgoingCheckColor = UIColor(rgb: 0xffffff, alpha: 0.5)
}
if accentColor.lightness > 0.7 {
secondaryBadgeTextColor = UIColor(rgb: 0x000000)
} else {
secondaryBadgeTextColor = UIColor(rgb: 0xffffff)
let accentColorHsb = accentColor.hsb
accentColor = UIColor(hue: accentColorHsb.0, saturation: accentColorHsb.1, brightness: max(accentColorHsb.2, 0.55), alpha: 1.0)
}
}
chat = chat.withUpdated(
defaultWallpaper: defaultWallpaper,
message: chat.message.withUpdated(
incoming: chat.message.incoming.withUpdated(
linkTextColor: accentColor,
linkHighlightColor: accentColor?.withAlphaComponent(0.5),
accentTextColor: accentColor,
accentControlColor: accentColor,
mediaActiveControlColor: accentColor,
mediaInactiveControlColor: accentColor?.withAlphaComponent(0.4),
fileTitleColor: accentColor,
polls: chat.message.incoming.polls.withUpdated(
radioProgress: accentColor,
highlight: accentColor?.withAlphaComponent(0.12),
bar: accentColor
),
textSelectionColor: accentColor?.withAlphaComponent(0.2),
textSelectionKnobColor: accentColor
),
outgoing: chat.message.outgoing.withUpdated(
bubble: chat.message.outgoing.bubble.withUpdated(
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
fill: outgoingBubbleFillColor,
gradientFill: outgoingBubbleFillGradientColor,
highlightedFill: outgoingBubbleFillColor?.withMultipliedBrightnessBy(1.421),
stroke: .clear
),
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
fill: outgoingBubbleFillColor,
gradientFill: outgoingBubbleFillGradientColor,
highlightedFill: outgoingBubbleFillColor?.withMultipliedBrightnessBy(1.421),
stroke: .clear
)
),
primaryTextColor: outgoingPrimaryTextColor,
secondaryTextColor: outgoingSecondaryTextColor,
linkTextColor: outgoingLinkTextColor,
scamColor: outgoingScamColor,
accentTextColor: outgoingPrimaryTextColor,
accentControlColor: outgoingPrimaryTextColor,
mediaActiveControlColor: outgoingPrimaryTextColor,
mediaInactiveControlColor: outgoingSecondaryTextColor,
mediaControlInnerBackgroundColor: outgoingBubbleFillColor,
pendingActivityColor: outgoingSecondaryTextColor,
fileTitleColor: outgoingPrimaryTextColor,
fileDescriptionColor: outgoingSecondaryTextColor,
fileDurationColor: outgoingSecondaryTextColor,
polls: chat.message.outgoing.polls.withUpdated(radioButton: outgoingPrimaryTextColor, radioProgress: outgoingPrimaryTextColor, highlight: outgoingPrimaryTextColor?.withAlphaComponent(0.12), separator: outgoingSecondaryTextColor, bar: outgoingPrimaryTextColor)
),
infoLinkTextColor: accentColor,
outgoingCheckColor: outgoingCheckColor,
selectionControlColors: chat.message.selectionControlColors.withUpdated(fillColor: accentColor, foregroundColor: badgeTextColor)
),
inputPanel: chat.inputPanel.withUpdated(
panelControlAccentColor: accentColor,
actionControlFillColor: accentColor,
actionControlForegroundColor: secondaryBadgeTextColor,
mediaRecordingControl: chat.inputPanel.mediaRecordingControl.withUpdated(
buttonColor: accentColor,
micLevelColor: accentColor?.withAlphaComponent(0.2),
activeIconColor: secondaryBadgeTextColor
)
),
historyNavigation: chat.historyNavigation.withUpdated(
badgeBackgroundColor: accentColor,
badgeStrokeColor: accentColor,
badgeTextColor: badgeTextColor
)
)
return PresentationTheme(
name: theme.name,
referenceTheme: theme.referenceTheme,
overallDarkAppearance: theme.overallDarkAppearance,
intro: intro,
passcode: theme.passcode,
rootController: rootController,
list: list,
chatList: chatList,
chat: chat,
actionSheet: actionSheet,
contextMenu: theme.contextMenu,
inAppNotification: theme.inAppNotification,
preview: theme.preview
)
}
public func makeDefaultDarkPresentationTheme(preview: Bool) -> PresentationTheme {
let rootTabBar = PresentationThemeRootTabBar(
backgroundColor: UIColor(rgb: 0x1c1c1d),
separatorColor: UIColor(rgb: 0x3d3d40),
iconColor: UIColor(rgb: 0x828282),
selectedIconColor: accentColor,
selectedIconColor: UIColor(rgb: 0xffffff),
textColor: UIColor(rgb: 0x828282),
selectedTextColor: accentColor,
badgeBackgroundColor: badgeFillColor,
selectedTextColor: UIColor(rgb: 0xffffff),
badgeBackgroundColor: UIColor(rgb: 0xffffff),
badgeStrokeColor: UIColor(rgb: 0x1c1c1d),
badgeTextColor: badgeTextColor
badgeTextColor: UIColor(rgb: 0x000000)
)
let rootNavigationBar = PresentationThemeRootNavigationBar(
buttonColor: accentColor,
buttonColor: UIColor(rgb: 0xffffff),
disabledButtonColor: UIColor(rgb: 0x525252),
primaryTextColor: .white,
primaryTextColor: UIColor(rgb: 0xffffff),
secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5),
controlColor: UIColor(rgb: 0x767676),
accentTextColor: accentColor,
accentTextColor: UIColor(rgb: 0xffffff),
backgroundColor: UIColor(rgb: 0x1c1c1d),
separatorColor: UIColor(rgb: 0x3d3d40),
badgeBackgroundColor: badgeFillColor,
badgeBackgroundColor: UIColor(rgb: 0xffffff),
badgeStrokeColor: UIColor(rgb: 0x1c1c1d),
badgeTextColor: badgeTextColor,
badgeTextColor: UIColor(rgb: 0x000000),
segmentedBackgroundColor: UIColor(rgb: 0x3a3b3d),
segmentedForegroundColor: UIColor(rgb: 0x6f7075),
segmentedTextColor: UIColor(rgb: 0xffffff),
@ -105,9 +237,9 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
let navigationSearchBar = PresentationThemeNavigationSearchBar(
backgroundColor: UIColor(rgb: 0x1c1c1d),
accentColor: accentColor,
accentColor: UIColor(rgb: 0xffffff),
inputFillColor: UIColor(rgb: 0x0f0f0f),
inputTextColor: .white,
inputTextColor: UIColor(rgb: 0xffffff),
inputPlaceholderTextColor: UIColor(rgb: 0x8f8f8f),
inputIconColor: UIColor(rgb: 0x8f8f8f),
inputClearButtonColor: UIColor(rgb: 0x8f8f8f),
@ -116,10 +248,10 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
let intro = PresentationThemeIntro(
statusBarStyle: .white,
primaryTextColor: .white,
accentTextColor: accentColor,
primaryTextColor: UIColor(rgb: 0xffffff),
accentTextColor: UIColor(rgb: 0xffffff),
disabledTextColor: UIColor(rgb: 0x525252),
startButtonColor: accentColor,
startButtonColor: UIColor(rgb: 0xffffff),
dotColor: UIColor(rgb: 0x5e5e5e)
)
@ -140,8 +272,8 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
frameColor: UIColor(rgb: 0x39393d),
handleColor: UIColor(rgb: 0x121212),
contentColor: UIColor(rgb: 0x67ce67),
positiveColor: constructiveColor,
negativeColor: destructiveColor
positiveColor: UIColor(rgb: 0x08a723),
negativeColor: UIColor(rgb: 0xeb5545)
)
let list = PresentationThemeList(
@ -150,9 +282,9 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
itemPrimaryTextColor: UIColor(rgb: 0xffffff),
itemSecondaryTextColor: UIColor(rgb: 0x98989e),
itemDisabledTextColor: UIColor(rgb: 0x8f8f8f),
itemAccentColor: accentColor,
itemAccentColor: UIColor(rgb: 0xffffff),
itemHighlightedColor: UIColor(rgb: 0x28b772),
itemDestructiveColor: destructiveColor,
itemDestructiveColor: UIColor(rgb: 0xeb5545),
itemPlaceholderTextColor: UIColor(rgb: 0x4d4d4d),
itemBlocksBackgroundColor: UIColor(rgb: 0x1c1c1d),
itemHighlightedBackgroundColor: UIColor(rgb: 0x313135),
@ -166,39 +298,39 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
freeMonoIconColor: UIColor(rgb: 0x8d8e93),
itemSwitchColors: switchColors,
itemDisclosureActions: PresentationThemeItemDisclosureActions(
neutral1: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x666666), foregroundColor: .white),
neutral2: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xcd7800), foregroundColor: .white),
destructive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xc70c0c), foregroundColor: .white),
constructive: PresentationThemeFillForeground(fillColor: constructiveColor, foregroundColor: .white),
accent: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x666666), foregroundColor: .white),
warning: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xcd7800), foregroundColor: .white),
inactive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x666666), foregroundColor: .white)
neutral1: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x666666), foregroundColor: UIColor(rgb: 0xffffff)),
neutral2: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xcd7800), foregroundColor: UIColor(rgb: 0xffffff)),
destructive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xc70c0c), foregroundColor: UIColor(rgb: 0xffffff)),
constructive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x08a723), foregroundColor: UIColor(rgb: 0xffffff)),
accent: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x666666), foregroundColor: UIColor(rgb: 0xffffff)),
warning: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xcd7800), foregroundColor: UIColor(rgb: 0xffffff)),
inactive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x666666), foregroundColor: UIColor(rgb: 0xffffff))
),
itemCheckColors: PresentationThemeFillStrokeForeground(
fillColor: accentColor,
fillColor: UIColor(rgb: 0xffffff),
strokeColor: UIColor(rgb: 0xffffff, alpha: 0.5),
foregroundColor: secondaryBadgeTextColor
foregroundColor: UIColor(rgb: 0x000000)
),
controlSecondaryColor: UIColor(rgb: 0xffffff, alpha: 0.5),
freeInputField: PresentationInputFieldTheme(
backgroundColor: UIColor(rgb: 0xffffff, alpha: 0.5),
strokeColor: UIColor(rgb: 0xffffff, alpha: 0.5),
placeholderColor: UIColor(rgb: 0x4d4d4d),
primaryColor: .white,
primaryColor: UIColor(rgb: 0xffffff),
controlColor: UIColor(rgb: 0x4d4d4d)
),
freePlainInputField: PresentationInputFieldTheme(
backgroundColor: UIColor(rgb: 0xffffff, alpha: 0.5),
strokeColor: UIColor(rgb: 0xffffff, alpha: 0.5),
placeholderColor: UIColor(rgb: 0x4d4d4d),
primaryColor: .white,
primaryColor: UIColor(rgb: 0xffffff),
controlColor: UIColor(rgb: 0x4d4d4d)
),
mediaPlaceholderColor: UIColor(rgb: 0x1c1c1d),
scrollIndicatorColor: UIColor(white: 1.0, alpha: 0.3),
scrollIndicatorColor: UIColor(rgb: 0xffffff, alpha: 0.3),
pageIndicatorInactiveColor: UIColor(white: 1.0, alpha: 0.3),
inputClearButtonColor: UIColor(rgb: 0x8b9197),
itemBarChart: PresentationThemeItemBarChart(color1: accentColor, color2: UIColor(rgb: 0x929196), color3: UIColor(rgb: 0x333333))
itemBarChart: PresentationThemeItemBarChart(color1: UIColor(rgb: 0xffffff), color2: UIColor(rgb: 0x929196), color3: UIColor(rgb: 0x333333))
)
let chatList = PresentationThemeChatList(
@ -209,19 +341,19 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
itemHighlightedBackgroundColor: UIColor(rgb: 0x191919),
itemSelectedBackgroundColor: UIColor(rgb: 0x191919),
titleColor: UIColor(rgb: 0xffffff),
secretTitleColor: secretColor,
dateTextColor: UIColor(rgb: 0x8e8e92),
secretTitleColor: UIColor(rgb: 0x00b12c),
dateTextColor: UIColor(rgb: 0x8d8e93),
authorNameColor: UIColor(rgb: 0xffffff),
messageTextColor: UIColor(rgb: 0x8e8e92),
messageTextColor: UIColor(rgb: 0x8d8e93),
messageHighlightedTextColor: UIColor(rgb: 0xffffff),
messageDraftTextColor: UIColor(rgb: 0xdd4b39),
checkmarkColor: accentColor,
checkmarkColor: UIColor(rgb: 0xffffff),
pendingIndicatorColor: UIColor(rgb: 0xffffff),
failedFillColor: destructiveColor,
failedForegroundColor: .white,
muteIconColor: UIColor(rgb: 0x8e8e92),
unreadBadgeActiveBackgroundColor: accentColor,
unreadBadgeActiveTextColor: secondaryBadgeTextColor,
failedFillColor: UIColor(rgb: 0xeb5545),
failedForegroundColor: UIColor(rgb: 0xffffff),
muteIconColor: UIColor(rgb: 0x8d8e93),
unreadBadgeActiveBackgroundColor: UIColor(rgb: 0xffffff),
unreadBadgeActiveTextColor: UIColor(rgb: 0x000000),
unreadBadgeInactiveBackgroundColor: UIColor(rgb: 0x666666),
unreadBadgeInactiveTextColor:UIColor(rgb: 0x000000),
pinnedBadgeColor: UIColor(rgb: 0x767677),
@ -229,63 +361,63 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
regularSearchBarColor: UIColor(rgb: 0x272728),
sectionHeaderFillColor: UIColor(rgb: 0x1c1c1d),
sectionHeaderTextColor: UIColor(rgb: 0xffffff),
verifiedIconFillColor: accentColor,
verifiedIconForegroundColor: badgeTextColor,
secretIconColor: secretColor,
pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0x72d5fd), bottomColor: UIColor(rgb: 0x2a9ef1)), foregroundColor: .white),
unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0x666666), bottomColor: UIColor(rgb: 0x666666)), foregroundColor: .black),
verifiedIconFillColor: UIColor(rgb: 0xffffff),
verifiedIconForegroundColor: UIColor(rgb: 0x000000),
secretIconColor: UIColor(rgb: 0x00b12c),
pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0x72d5fd), bottomColor: UIColor(rgb: 0x2a9ef1)), foregroundColor: UIColor(rgb: 0xffffff)),
unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0x666666), bottomColor: UIColor(rgb: 0x666666)), foregroundColor: UIColor(rgb: 0x000000)),
onlineDotColor: UIColor(rgb: 0x4cc91f)
)
let message = PresentationThemeChatMessage(
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628))), primaryTextColor: .white, secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: destructiveColor, textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: accentColor, accentControlColor: accentColor, mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.4), mediaControlInnerBackgroundColor: UIColor(rgb: 0x262628), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: accentColor, fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: UIColor(rgb: 0x000000), bar: accentColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor),
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor)), primaryTextColor: outgoingPrimaryTextColor, secondaryTextColor: outgoingSecondaryTextColor, linkTextColor: outgoingLinkTextColor, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: outgoingPrimaryTextColor, accentControlColor: outgoingPrimaryTextColor, mediaActiveControlColor: outgoingPrimaryTextColor, mediaInactiveControlColor: outgoingSecondaryTextColor, mediaControlInnerBackgroundColor: outgoingBubbleFillColor, pendingActivityColor: outgoingSecondaryTextColor, fileTitleColor: outgoingPrimaryTextColor, fileDescriptionColor: outgoingSecondaryTextColor, fileDurationColor: outgoingSecondaryTextColor, mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: outgoingPrimaryTextColor, radioProgress: outgoingPrimaryTextColor, highlight: outgoingPrimaryTextColor.withAlphaComponent(0.12), separator: outgoingSecondaryTextColor, bar: outgoingPrimaryTextColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor.white.withAlphaComponent(0.2), textSelectionKnobColor: UIColor.white),
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628))), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.4), mediaControlInnerBackgroundColor: UIColor(rgb: 0x262628), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff, alpha: 0.12), separator: UIColor(rgb: 0x000000), bar: UIColor(rgb: 0xffffff)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)),
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x313131), gradientFill: UIColor(rgb: 0x313131), highlightedFill: UIColor(rgb: 0x464646), stroke: UIColor(rgb: 0x313131)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x313131), gradientFill: UIColor(rgb: 0x313131), highlightedFill: UIColor(rgb: 0x464646), stroke: UIColor(rgb: 0x313131))), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaControlInnerBackgroundColor: UIColor(rgb: 0x313131), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xffffff), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff).withAlphaComponent(0.12), separator: UIColor(rgb: 0xffffff, alpha: 0.5), bar: UIColor(rgb: 0xffffff)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)),
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f))),
infoPrimaryTextColor: .white,
infoLinkTextColor: accentColor,
outgoingCheckColor: outgoingCheckColor,
infoPrimaryTextColor: UIColor(rgb: 0xffffff),
infoLinkTextColor: UIColor(rgb: 0xffffff),
outgoingCheckColor: UIColor(rgb: 0xffffff, alpha: 0.5),
mediaDateAndStatusFillColor: UIColor(white: 0.0, alpha: 0.5),
mediaDateAndStatusTextColor: .white,
mediaDateAndStatusTextColor: UIColor(rgb: 0xffffff),
shareButtonFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)),
shareButtonStrokeColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0xb2b2b2, alpha: 0.18), withoutWallpaper: UIColor(rgb: 0xb2b2b2, alpha: 0.18)),
shareButtonForegroundColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0xb2b2b2), withoutWallpaper: UIColor(rgb: 0xb2b2b2)),
mediaOverlayControlColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x000000, alpha: 0.6), foregroundColor: .white),
selectionControlColors: PresentationThemeFillStrokeForeground(fillColor: accentColor, strokeColor: .white, foregroundColor: badgeTextColor),
deliveryFailedColors: PresentationThemeFillForeground(fillColor: destructiveColor, foregroundColor: .white),
mediaOverlayControlColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x000000, alpha: 0.6), foregroundColor: UIColor(rgb: 0xffffff)),
selectionControlColors: PresentationThemeFillStrokeForeground(fillColor: UIColor(rgb: 0xffffff), strokeColor: UIColor(rgb: 0xffffff), foregroundColor: UIColor(rgb: 0x000000)),
deliveryFailedColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xeb5545), foregroundColor: UIColor(rgb: 0xffffff)),
mediaHighlightOverlayColor: UIColor(white: 1.0, alpha: 0.6)
)
let serviceMessage = PresentationThemeServiceMessage(
components: PresentationThemeServiceMessageColor(withDefaultWallpaper: PresentationThemeServiceMessageColorComponents(fill: UIColor(rgb: 0x1f1f1f, alpha: 1.0), primaryText: UIColor(rgb: 0xffffff), linkHighlight: UIColor(rgb: 0xffffff, alpha: 0.12), scam: destructiveColor, dateFillStatic: UIColor(rgb: 0x000000, alpha: 0.6), dateFillFloating: UIColor(rgb: 0x000000, alpha: 0.2)), withCustomWallpaper: PresentationThemeServiceMessageColorComponents(fill: UIColor(rgb: 0x1f1f1f, alpha: 1.0), primaryText: .white, linkHighlight: UIColor(rgb: 0xffffff, alpha: 0.12), scam: destructiveColor, dateFillStatic: UIColor(rgb: 0x000000, alpha: 0.6), dateFillFloating: UIColor(rgb: 0x000000, alpha: 0.2))),
components: PresentationThemeServiceMessageColor(withDefaultWallpaper: PresentationThemeServiceMessageColorComponents(fill: UIColor(rgb: 0x1f1f1f, alpha: 1.0), primaryText: UIColor(rgb: 0xffffff), linkHighlight: UIColor(rgb: 0xffffff, alpha: 0.12), scam: UIColor(rgb: 0xeb5545), dateFillStatic: UIColor(rgb: 0x000000, alpha: 0.6), dateFillFloating: UIColor(rgb: 0x000000, alpha: 0.2)), withCustomWallpaper: PresentationThemeServiceMessageColorComponents(fill: UIColor(rgb: 0x1f1f1f, alpha: 1.0), primaryText: UIColor(rgb: 0xffffff), linkHighlight: UIColor(rgb: 0xffffff, alpha: 0.12), scam: UIColor(rgb: 0xeb5545), dateFillStatic: UIColor(rgb: 0x000000, alpha: 0.6), dateFillFloating: UIColor(rgb: 0x000000, alpha: 0.2))),
unreadBarFillColor: UIColor(rgb: 0x1b1b1b),
unreadBarStrokeColor: UIColor(rgb: 0x1b1b1b),
unreadBarTextColor: .white,
dateTextColor: PresentationThemeVariableColor(color: .white)
unreadBarTextColor: UIColor(rgb: 0xffffff),
dateTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))
)
let inputPanelMediaRecordingControl = PresentationThemeChatInputPanelMediaRecordingControl(
buttonColor: accentColor,
micLevelColor: accentColor.withAlphaComponent(0.2),
activeIconColor: secondaryBadgeTextColor
buttonColor: UIColor(rgb: 0xffffff),
micLevelColor: UIColor(rgb: 0xffffff, alpha: 0.2),
activeIconColor: UIColor(rgb: 0x000000)
)
let inputPanel = PresentationThemeChatInputPanel(
panelBackgroundColor: UIColor(rgb: 0x1c1c1d),
panelSeparatorColor: UIColor(rgb: 0x3d3d40),
panelControlAccentColor: accentColor,
panelControlAccentColor: UIColor(rgb: 0xffffff),
panelControlColor: UIColor(rgb: 0x808080),
panelControlDisabledColor: UIColor(rgb: 0x808080, alpha: 0.5),
panelControlDestructiveColor: UIColor(rgb: 0xff3b30),
inputBackgroundColor: UIColor(rgb: 0x060606),
inputStrokeColor: UIColor(rgb: 0x353537),
inputPlaceholderColor: UIColor(rgb: 0x7b7b7b),
inputTextColor: .white,
inputTextColor: UIColor(rgb: 0xffffff),
inputControlColor: UIColor(rgb: 0x7b7b7b),
actionControlFillColor: accentColor,
actionControlForegroundColor: secondaryBadgeTextColor,
primaryTextColor: .white,
actionControlFillColor: UIColor(rgb: 0xffffff),
actionControlForegroundColor: UIColor(rgb: 0x000000),
primaryTextColor: UIColor(rgb: 0xffffff),
secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5),
mediaRecordingDotColor: destructiveColor,
mediaRecordingDotColor: UIColor(rgb: 0xeb5545),
mediaRecordingControl: inputPanelMediaRecordingControl
)
@ -296,9 +428,9 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
stickersBackgroundColor: UIColor(rgb: 0x000000),
stickersSectionTextColor: UIColor(rgb: 0x7b7b7b),
stickersSearchBackgroundColor: UIColor(rgb: 0x1c1c1d),
stickersSearchPlaceholderColor: UIColor(rgb: 0x8e8e92),
stickersSearchPrimaryColor: .white,
stickersSearchControlColor: UIColor(rgb: 0x8e8e92),
stickersSearchPlaceholderColor: UIColor(rgb: 0x8d8e93),
stickersSearchPrimaryColor: UIColor(rgb: 0xffffff),
stickersSearchControlColor: UIColor(rgb: 0x8d8e93),
gifsBackgroundColor: UIColor(rgb: 0x000000)
)
@ -309,16 +441,16 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
buttonStrokeColor: UIColor(rgb: 0x0c0c0c),
buttonHighlightedFillColor: UIColor(rgb: 0x5a5a5a, alpha: 0.7),
buttonHighlightedStrokeColor: UIColor(rgb: 0x0c0c0c),
buttonTextColor: .white
buttonTextColor: UIColor(rgb: 0xffffff)
)
let historyNavigation = PresentationThemeChatHistoryNavigation(
fillColor: UIColor(rgb: 0x1c1c1d),
strokeColor: UIColor(rgb: 0x3d3d40),
foregroundColor: .white,
badgeBackgroundColor: accentColor,
badgeStrokeColor: accentColor,
badgeTextColor: badgeTextColor
foregroundColor: UIColor(rgb: 0xffffff),
badgeBackgroundColor: UIColor(rgb: 0xffffff),
badgeStrokeColor: UIColor(rgb: 0xffffff),
badgeTextColor: UIColor(rgb: 0x000000)
)
let chat = PresentationThemeChat(
@ -339,42 +471,42 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
opaqueItemHighlightedBackgroundColor: UIColor(white: 0.0, alpha: 1.0),
itemHighlightedBackgroundColor: UIColor(rgb: 0x000000, alpha: 0.5),
opaqueItemSeparatorColor: UIColor(rgb: 0x3d3d40),
standardActionTextColor: accentColor,
destructiveActionTextColor: destructiveColor,
standardActionTextColor: UIColor(rgb: 0xffffff),
destructiveActionTextColor: UIColor(rgb: 0xeb5545),
disabledActionTextColor: UIColor(rgb: 0x4d4d4d),
primaryTextColor: .white,
primaryTextColor: UIColor(rgb: 0xffffff),
secondaryTextColor: UIColor(rgb: 0x5e5e5e),
controlAccentColor: accentColor,
controlAccentColor: UIColor(rgb: 0xffffff),
inputBackgroundColor: UIColor(rgb: 0x0f0f0f),
inputHollowBackgroundColor: UIColor(rgb: 0x0f0f0f),
inputBorderColor: UIColor(rgb: 0x0f0f0f),
inputPlaceholderColor: UIColor(rgb: 0x8f8f8f),
inputTextColor: .white,
inputTextColor: UIColor(rgb: 0xffffff),
inputClearButtonColor: UIColor(rgb: 0x8f8f8f),
checkContentColor: secondaryBadgeTextColor
checkContentColor: UIColor(rgb: 0x000000)
)
let contextMenu = PresentationThemeContextMenu(
dimColor: UIColor(rgb: 0x000000, alpha: 0.6),
backgroundColor: UIColor(rgb: 0x252525, alpha: 0.78),
itemSeparatorColor: UIColor(rgb: 0xFFFFFF, alpha: 0.15),
itemSeparatorColor: UIColor(rgb: 0xffffff, alpha: 0.15),
sectionSeparatorColor: UIColor(rgb: 0x000000, alpha: 0.2),
itemBackgroundColor: UIColor(rgb: 0x000000, alpha: 0.0),
itemHighlightedBackgroundColor: UIColor(rgb: 0xFFFFFF, alpha: 0.15),
itemHighlightedBackgroundColor: UIColor(rgb: 0xffffff, alpha: 0.15),
primaryColor: UIColor(rgb: 0xffffff, alpha: 1.0),
secondaryColor: UIColor(rgb: 0xffffff, alpha: 0.8),
destructiveColor: destructiveColor
destructiveColor: UIColor(rgb: 0xeb5545)
)
let inAppNotification = PresentationThemeInAppNotification(
fillColor: UIColor(rgb: 0x1c1c1d),
primaryTextColor: .white,
primaryTextColor: UIColor(rgb: 0xffffff),
expandedNotification: PresentationThemeExpandedNotification(
backgroundType: .dark,
navigationBar: PresentationThemeExpandedNotificationNavigationBar(
backgroundColor: UIColor(rgb: 0x1c1c1d),
primaryTextColor: .white,
controlColor: .white,
primaryTextColor: UIColor(rgb: 0xffffff),
controlColor: UIColor(rgb: 0xffffff),
separatorColor: UIColor(rgb: 0x000000)
)
)
@ -396,10 +528,3 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
preview: preview
)
}
public let defaultDarkPresentationTheme = makeDarkPresentationTheme(accentColor: .white, bubbleColors: nil, preview: false)
public func makeDarkPresentationTheme(accentColor: UIColor?, bubbleColors: (UIColor, UIColor?)?, preview: Bool) -> PresentationTheme {
let accentColor = accentColor ?? .white
return makeDarkPresentationTheme(accentColor: accentColor, bubbleColors: bubbleColors, preview: preview)
}

View file

@ -1,15 +1,440 @@
import Foundation
import UIKit
import TelegramCore
import SyncCore
import TelegramUIPreferences
private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UIColor, UIColor?)?, preview: Bool) -> PresentationTheme {
let destructiveColor: UIColor = UIColor(rgb: 0xff6767)
let constructiveColor: UIColor = UIColor(rgb: 0x08a723)
let secretColor: UIColor = UIColor(rgb: 0x89df9e)
private let defaultDarkTintedAccentColor = UIColor(rgb: 0x2ea6ff)
public let defaultDarkTintedPresentationTheme = makeDefaultDarkTintedPresentationTheme(preview: false)
//public func makeDarkAccentPresentationTheme(accentColor: UIColor?, bubbleColors: (UIColor, UIColor?)?, preview: Bool) -> PresentationTheme {
// var accentColor = accentColor ?? defaultDarkAccentColor
// if accentColor == PresentationThemeBaseColor.blue.color {
// accentColor = defaultDarkAccentColor
// }
// return makeDarkPresentationTheme(accentColor: accentColor, bubbleColors: bubbleColors, preview: preview)
//}
public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme, editing: Bool, accentColor: UIColor?, backgroundColors: (UIColor, UIColor?)?, bubbleColors: (UIColor, UIColor?)?) -> PresentationTheme {
if (theme.referenceTheme != .nightAccent) {
return theme
}
var intro = theme.intro
var passcode = theme.passcode
var rootController = theme.rootController
var list = theme.list
var chatList = theme.chatList
var chat = theme.chat
var actionSheet = theme.actionSheet
var contextMenu = theme.contextMenu
var inAppNotification = theme.inAppNotification
var mainBackgroundColor: UIColor?
var mainSelectionColor: UIColor?
var additionalBackgroundColor: UIColor?
var mainSeparatorColor: UIColor?
var mainForegroundColor: UIColor?
var mainSecondaryColor: UIColor?
var mainSecondaryTextColor: UIColor?
var mainFreeTextColor: UIColor?
var secondaryBadgeTextColor: UIColor
var mainInputColor: UIColor?
var inputBackgroundColor: UIColor?
var buttonStrokeColor: UIColor?
var bubbleColors = bubbleColors
if bubbleColors == nil, editing {
let accentColor = accentColor ?? defaultDarkTintedAccentColor
let bottomColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.731, brightness: 0.59)
let topColor = bottomColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98)
bubbleColors = (topColor, bottomColor)
}
var accentColor = accentColor
let hsb = accentColor.hsb
accentColor = UIColor(hue: hsb.0, saturation: hsb.1, brightness: max(hsb.2, 0.18), alpha: 1.0)
if let initialAccentColor = accentColor {
let hsb = initialAccentColor.hsb
accentColor = UIColor(hue: hsb.0, saturation: hsb.1, brightness: max(hsb.2, 0.18), alpha: 1.0)
if let lightness = accentColor?.lightness, lightness > 0.7 {
secondaryBadgeTextColor = UIColor(rgb: 0x000000)
} else {
secondaryBadgeTextColor = UIColor(rgb: 0xffffff)
}
mainBackgroundColor = accentColor?.withMultiplied(hue: 1.024, saturation: 0.585, brightness: 0.25)
mainSelectionColor = accentColor?.withMultiplied(hue: 1.03, saturation: 0.585, brightness: 0.12)
additionalBackgroundColor = accentColor?.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18)
mainSeparatorColor = accentColor?.withMultiplied(hue: 1.033, saturation: 0.426, brightness: 0.34)
mainForegroundColor = accentColor?.withMultiplied(hue: 0.99, saturation: 0.256, brightness: 0.62)
mainSecondaryColor = accentColor?.withMultiplied(hue: 1.019, saturation: 0.109, brightness: 0.59)
mainSecondaryTextColor = accentColor?.withMultiplied(hue: 0.956, saturation: 0.17, brightness: 1.0)
mainFreeTextColor = accentColor?.withMultiplied(hue: 1.019, saturation: 0.097, brightness: 0.56)
mainInputColor = accentColor?.withMultiplied(hue: 1.029, saturation: 0.609, brightness: 0.19)
inputBackgroundColor = accentColor?.withMultiplied(hue: 1.02, saturation: 0.609, brightness: 0.15)
buttonStrokeColor = accentColor?.withMultiplied(hue: 1.014, saturation: 0.56, brightness: 0.64).withAlphaComponent(0.15)
intro = intro.withUpdated(
accentTextColor: accentColor,
disabledTextColor: accentColor?.withMultiplied(hue: 1.033, saturation: 0.219, brightness: 0.44),
startButtonColor: accentColor,
dotColor: mainSecondaryColor
)
passcode = passcode.withUpdated(backgroundColors: passcode.backgroundColors.withUpdated(topColor: accentColor?.withMultiplied(hue: 1.049, saturation: 0.573, brightness: 0.47), bottomColor: additionalBackgroundColor), buttonColor: mainBackgroundColor)
rootController = rootController.withUpdated(
tabBar: rootController.tabBar.withUpdated(
backgroundColor: mainBackgroundColor,
separatorColor: mainSeparatorColor,
iconColor: mainForegroundColor,
selectedIconColor: accentColor,
textColor: mainForegroundColor,
selectedTextColor: accentColor
),
navigationBar: rootController.navigationBar.withUpdated(
buttonColor: accentColor,
disabledButtonColor: accentColor?.withMultiplied(hue: 1.033, saturation: 0.219, brightness: 0.44),
secondaryTextColor: mainSecondaryColor,
controlColor: mainSecondaryColor,
accentTextColor: accentColor,
backgroundColor: mainBackgroundColor,
separatorColor: mainSeparatorColor,
segmentedBackgroundColor: mainInputColor,
segmentedForegroundColor: mainBackgroundColor,
segmentedDividerColor: mainSecondaryTextColor?.withAlphaComponent(0.5)
),
navigationSearchBar: rootController.navigationSearchBar.withUpdated(
backgroundColor: mainBackgroundColor,
accentColor: accentColor,
inputFillColor: mainInputColor,
inputPlaceholderTextColor: mainSecondaryColor,
inputIconColor: mainSecondaryColor,
inputClearButtonColor: mainSecondaryColor,
separatorColor: additionalBackgroundColor
)
)
list = list.withUpdated(
blocksBackgroundColor: additionalBackgroundColor,
plainBackgroundColor: additionalBackgroundColor,
itemSecondaryTextColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
itemDisabledTextColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
itemAccentColor: accentColor,
itemPlaceholderTextColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
itemBlocksBackgroundColor: mainBackgroundColor,
itemHighlightedBackgroundColor: mainSelectionColor,
itemBlocksSeparatorColor: mainSeparatorColor,
itemPlainSeparatorColor: mainSeparatorColor,
disclosureArrowColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
sectionHeaderTextColor: mainFreeTextColor,
freeTextColor: mainFreeTextColor,
freeMonoIconColor: mainFreeTextColor,
itemSwitchColors: list.itemSwitchColors.withUpdated(
frameColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
contentColor: accentColor
),
itemDisclosureActions: list.itemDisclosureActions.withUpdated(
neutral1: list.itemDisclosureActions.neutral1.withUpdated(fillColor: accentColor),
accent: list.itemDisclosureActions.accent.withUpdated(fillColor: accentColor),
inactive: list.itemDisclosureActions.inactive.withUpdated(fillColor: accentColor?.withMultiplied(hue: 1.029, saturation: 0.609, brightness: 0.3))
),
itemCheckColors: list.itemCheckColors.withUpdated(
fillColor: accentColor,
strokeColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
foregroundColor: secondaryBadgeTextColor
),
controlSecondaryColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
freeInputField: list.freeInputField.withUpdated(
backgroundColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
strokeColor: mainSecondaryTextColor?.withAlphaComponent(0.5)
),
freePlainInputField: list.freePlainInputField.withUpdated(
backgroundColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
strokeColor: mainSecondaryTextColor?.withAlphaComponent(0.5)
),
mediaPlaceholderColor: accentColor?.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23),
pageIndicatorInactiveColor: mainSecondaryTextColor?.withAlphaComponent(0.4),
inputClearButtonColor: mainSecondaryColor,
itemBarChart: list.itemBarChart.withUpdated(
color1: accentColor,
color2: mainSecondaryTextColor?.withAlphaComponent(0.5),
color3: accentColor?.withMultiplied(hue: 1.038, saturation: 0.329, brightness: 0.33)
)
)
chatList = chatList.withUpdated(
backgroundColor: additionalBackgroundColor,
itemSeparatorColor: mainSeparatorColor,
itemBackgroundColor: additionalBackgroundColor,
pinnedItemBackgroundColor: mainBackgroundColor,
itemHighlightedBackgroundColor: mainSelectionColor,
itemSelectedBackgroundColor: mainSelectionColor,
dateTextColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
messageTextColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
checkmarkColor: accentColor,
pendingIndicatorColor: mainSecondaryTextColor?.withAlphaComponent(0.4),
muteIconColor: mainSecondaryTextColor?.withAlphaComponent(0.4),
unreadBadgeActiveBackgroundColor: accentColor,
unreadBadgeActiveTextColor: secondaryBadgeTextColor,
unreadBadgeInactiveBackgroundColor: mainSecondaryTextColor?.withAlphaComponent(0.4),
unreadBadgeInactiveTextColor: additionalBackgroundColor,
pinnedBadgeColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
pinnedSearchBarColor: mainInputColor,
regularSearchBarColor: accentColor?.withMultiplied(hue: 1.029, saturation: 0.609, brightness: 0.12),
sectionHeaderFillColor: mainBackgroundColor,
sectionHeaderTextColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
verifiedIconFillColor: accentColor,
unpinnedArchiveAvatarColor: chatList.unpinnedArchiveAvatarColor.withUpdated(
backgroundColors: chatList.unpinnedArchiveAvatarColor.backgroundColors.withUpdated(
topColor: accentColor?.withMultiplied(hue: 0.985, saturation: 0.268, brightness: 0.47),
bottomColor: accentColor?.withMultiplied(hue: 0.98, saturation: 0.268, brightness: 0.39)
),
foregroundColor: additionalBackgroundColor
)
)
actionSheet = actionSheet.withUpdated(
opaqueItemBackgroundColor: mainBackgroundColor,
itemBackgroundColor: mainBackgroundColor?.withAlphaComponent(0.8),
opaqueItemHighlightedBackgroundColor: mainSelectionColor,
itemHighlightedBackgroundColor: mainSelectionColor?.withAlphaComponent(0.2),
opaqueItemSeparatorColor: additionalBackgroundColor,
standardActionTextColor: accentColor,
controlAccentColor: accentColor,
inputBackgroundColor: mainInputColor,
inputHollowBackgroundColor: mainInputColor,
inputBorderColor: mainInputColor,
inputPlaceholderColor: mainSecondaryColor,
inputClearButtonColor: mainSecondaryColor,
checkContentColor: secondaryBadgeTextColor
)
contextMenu = contextMenu.withUpdated(backgroundColor: mainBackgroundColor?.withAlphaComponent(0.78))
inAppNotification = inAppNotification.withUpdated(
fillColor: mainBackgroundColor,
expandedNotification: inAppNotification.expandedNotification.withUpdated(navigationBar: inAppNotification.expandedNotification.navigationBar.withUpdated(
backgroundColor: mainBackgroundColor,
controlColor: accentColor,
separatorColor: mainSeparatorColor)
)
)
}
var defaultWallpaper: TelegramWallpaper?
if let backgroundColors = backgroundColors {
if let secondColor = backgroundColors.1 {
defaultWallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: secondColor.rgb), WallpaperSettings())
} else {
defaultWallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb))
}
}
var outgoingBubbleFillColor: UIColor?
var outgoingBubbleFillGradientColor: UIColor?
var outgoingBubbleHighlightedFillColor: UIColor?
var outgoingPrimaryTextColor: UIColor?
var outgoingSecondaryTextColor: UIColor?
var outgoingLinkTextColor: UIColor?
var outgoingScamColor: UIColor?
var outgoingCheckColor: UIColor?
var highlightedIncomingBubbleColor: UIColor?
var highlightedOutgoingBubbleColor: UIColor?
if let bubbleColors = bubbleColors {
outgoingBubbleFillColor = bubbleColors.0
outgoingBubbleFillGradientColor = bubbleColors.1 ?? bubbleColors.0
let lightnessColor = bubbleColors.0.mixedWith(bubbleColors.1 ?? bubbleColors.0, alpha: 0.5)
if lightnessColor.lightness > 0.7 {
outgoingPrimaryTextColor = UIColor(rgb: 0x000000)
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.5)
outgoingLinkTextColor = UIColor(rgb: 0x000000)
outgoingScamColor = UIColor(rgb: 0x000000)
outgoingCheckColor = UIColor(rgb: 0x000000, alpha: 0.5)
} else {
outgoingPrimaryTextColor = UIColor(rgb: 0xffffff)
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
outgoingLinkTextColor = UIColor(rgb: 0xffffff)
outgoingScamColor = UIColor(rgb: 0xffffff)
outgoingCheckColor = UIColor(rgb: 0xffffff, alpha: 0.5)
}
highlightedIncomingBubbleColor = accentColor?.withMultiplied(hue: 1.03, saturation: 0.463, brightness: 0.29)
highlightedOutgoingBubbleColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.019, saturation: 0.609, brightness: 0.63)
}
chat = chat.withUpdated(
defaultWallpaper: defaultWallpaper,
message: chat.message.withUpdated(
incoming: chat.message.incoming.withUpdated(
bubble: chat.message.incoming.bubble.withUpdated(
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
fill: mainBackgroundColor,
gradientFill: mainBackgroundColor,
highlightedFill: highlightedIncomingBubbleColor,
stroke: mainBackgroundColor
),
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
fill: mainBackgroundColor,
gradientFill: mainBackgroundColor,
highlightedFill: highlightedIncomingBubbleColor,
stroke: mainBackgroundColor
)
),
secondaryTextColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
linkTextColor: accentColor,
linkHighlightColor: accentColor?.withAlphaComponent(0.5),
accentTextColor: accentColor,
accentControlColor: accentColor,
mediaActiveControlColor: accentColor,
mediaInactiveControlColor: accentColor?.withAlphaComponent(0.5),
mediaControlInnerBackgroundColor: mainBackgroundColor,
pendingActivityColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
fileTitleColor: accentColor,
fileDescriptionColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
fileDurationColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
mediaPlaceholderColor: accentColor?.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23),
polls: chat.message.incoming.polls.withUpdated(
radioButton: accentColor?.withMultiplied(hue: 0.995, saturation: 0.317, brightness: 0.51),
radioProgress: accentColor,
highlight: accentColor?.withAlphaComponent(0.12),
separator: mainSeparatorColor,
bar: accentColor
),
actionButtonsFillColor: chat.message.incoming.actionButtonsFillColor.withUpdated(
withWallpaper: additionalBackgroundColor?.withAlphaComponent(0.5),
withoutWallpaper: additionalBackgroundColor?.withAlphaComponent(0.5)
),
actionButtonsStrokeColor: buttonStrokeColor.flatMap { PresentationThemeVariableColor(color: $0) },
textSelectionColor: accentColor?.withAlphaComponent(0.2),
textSelectionKnobColor: accentColor
),
outgoing: chat.message.outgoing.withUpdated(
bubble: chat.message.outgoing.bubble.withUpdated(
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
fill: outgoingBubbleFillColor,
gradientFill: outgoingBubbleFillGradientColor,
highlightedFill: highlightedOutgoingBubbleColor,
stroke: .clear
),
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
fill: outgoingBubbleFillColor,
gradientFill: outgoingBubbleFillGradientColor,
highlightedFill: highlightedOutgoingBubbleColor,
stroke: .clear
)
),
primaryTextColor: outgoingPrimaryTextColor,
secondaryTextColor: outgoingSecondaryTextColor,
linkTextColor: outgoingLinkTextColor,
scamColor: outgoingScamColor,
accentTextColor: outgoingPrimaryTextColor,
accentControlColor: outgoingPrimaryTextColor,
mediaActiveControlColor: outgoingPrimaryTextColor,
mediaInactiveControlColor: outgoingSecondaryTextColor,
mediaControlInnerBackgroundColor: outgoingBubbleFillColor,
pendingActivityColor: outgoingSecondaryTextColor,
fileTitleColor: outgoingPrimaryTextColor,
fileDescriptionColor: outgoingSecondaryTextColor,
fileDurationColor: outgoingSecondaryTextColor,
mediaPlaceholderColor: accentColor?.withMultiplied(hue: 1.019, saturation: 0.804, brightness: 0.51),
polls: chat.message.outgoing.polls.withUpdated(radioButton: outgoingPrimaryTextColor, radioProgress: outgoingPrimaryTextColor, highlight: outgoingPrimaryTextColor?.withAlphaComponent(0.12), separator: mainSeparatorColor, bar: outgoingPrimaryTextColor),
actionButtonsFillColor: chat.message.outgoing.actionButtonsFillColor.withUpdated(withWallpaper: additionalBackgroundColor?.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor?.withAlphaComponent(0.5)),
actionButtonsStrokeColor: buttonStrokeColor.flatMap { PresentationThemeVariableColor(color: $0) }
),
freeform: chat.message.freeform.withUpdated(
withWallpaper: chat.message.freeform.withWallpaper.withUpdated(
fill: mainBackgroundColor,
highlightedFill: highlightedIncomingBubbleColor,
stroke: mainBackgroundColor
), withoutWallpaper: chat.message.freeform.withoutWallpaper.withUpdated(
fill: mainBackgroundColor,
highlightedFill: highlightedIncomingBubbleColor,
stroke: mainBackgroundColor
)
),
infoLinkTextColor: accentColor,
outgoingCheckColor: outgoingCheckColor,
shareButtonFillColor: additionalBackgroundColor.flatMap { PresentationThemeVariableColor(color: $0.withAlphaComponent(0.5)) },
shareButtonStrokeColor: buttonStrokeColor.flatMap { PresentationThemeVariableColor(color: $0) },
selectionControlColors: chat.message.selectionControlColors.withUpdated(fillColor: accentColor)
),
serviceMessage: chat.serviceMessage.withUpdated(
components: chat.serviceMessage.components.withUpdated(
withDefaultWallpaper: chat.serviceMessage.components.withDefaultWallpaper.withUpdated(
fill: additionalBackgroundColor,
dateFillStatic: additionalBackgroundColor?.withAlphaComponent(0.6),
dateFillFloating: additionalBackgroundColor?.withAlphaComponent(0.2)
),
withCustomWallpaper: chat.serviceMessage.components.withCustomWallpaper.withUpdated(
fill: additionalBackgroundColor,
dateFillStatic: additionalBackgroundColor?.withAlphaComponent(0.6),
dateFillFloating: additionalBackgroundColor?.withAlphaComponent(0.2)
)
),
unreadBarFillColor: mainBackgroundColor,
unreadBarStrokeColor: mainBackgroundColor
),
inputPanel: chat.inputPanel.withUpdated(
panelBackgroundColor: mainBackgroundColor,
panelSeparatorColor: mainSeparatorColor,
panelControlAccentColor: accentColor,
panelControlColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
inputBackgroundColor: inputBackgroundColor,
inputStrokeColor: accentColor?.withMultiplied(hue: 1.038, saturation: 0.463, brightness: 0.26),
inputPlaceholderColor: mainSecondaryTextColor?.withAlphaComponent(0.4),
inputControlColor: mainSecondaryTextColor?.withAlphaComponent(0.4),
actionControlFillColor: accentColor,
mediaRecordingDotColor: accentColor,
mediaRecordingControl: chat.inputPanel.mediaRecordingControl.withUpdated(
buttonColor: accentColor,
micLevelColor: accentColor?.withAlphaComponent(0.2)
)
),
inputMediaPanel: chat.inputMediaPanel.withUpdated(
panelSeparatorColor: mainBackgroundColor,
panelIconColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
panelHighlightedIconBackgroundColor: inputBackgroundColor,
stickersBackgroundColor: additionalBackgroundColor,
stickersSectionTextColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
stickersSearchBackgroundColor: accentColor?.withMultiplied(hue: 1.009, saturation: 0.621, brightness: 0.15),
stickersSearchPlaceholderColor: accentColor?.withMultiplied(hue: 0.99, saturation: 0.243, brightness: 0.59),
stickersSearchControlColor: accentColor?.withMultiplied(hue: 0.99, saturation: 0.243, brightness: 0.59),
gifsBackgroundColor: additionalBackgroundColor
),
inputButtonPanel: chat.inputButtonPanel.withUpdated(
panelSeparatorColor: mainBackgroundColor,
panelBackgroundColor: accentColor?.withMultiplied(hue: 1.048, saturation: 0.378, brightness: 0.13),
buttonFillColor: accentColor?.withMultiplied(hue: 1.0, saturation: 0.085, brightness: 0.38),
buttonStrokeColor: accentColor?.withMultiplied(hue: 1.019, saturation: 0.39, brightness: 0.07),
buttonHighlightedFillColor: accentColor?.withMultiplied(hue: 1.0, saturation: 0.085, brightness: 0.38).withAlphaComponent(0.7),
buttonHighlightedStrokeColor: accentColor?.withMultiplied(hue: 1.019, saturation: 0.39, brightness: 0.07)
),
historyNavigation: chat.historyNavigation.withUpdated(
fillColor: mainBackgroundColor,
strokeColor: mainSeparatorColor,
foregroundColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
badgeBackgroundColor: accentColor,
badgeStrokeColor: accentColor
)
)
return PresentationTheme(
name: theme.name,
referenceTheme: theme.referenceTheme,
overallDarkAppearance: theme.overallDarkAppearance,
intro: intro,
passcode: passcode,
rootController: rootController,
list: list,
chatList: chatList,
chat: chat,
actionSheet: actionSheet,
contextMenu: contextMenu,
inAppNotification: inAppNotification,
preview: theme.preview
)
}
public func makeDefaultDarkTintedPresentationTheme(preview: Bool) -> PresentationTheme {
let accentColor = defaultDarkTintedAccentColor
let secondaryBadgeTextColor: UIColor
let lightness = accentColor.lightness
@ -22,47 +447,21 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
let mainBackgroundColor = accentColor.withMultiplied(hue: 1.024, saturation: 0.585, brightness: 0.25)
let mainSelectionColor = accentColor.withMultiplied(hue: 1.03, saturation: 0.585, brightness: 0.12)
let additionalBackgroundColor = accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18)
let mainSeparatorColor = accentColor.withMultiplied(hue: 1.033, saturation: 0.426, brightness: 0.34)
let mainForegroundColor = accentColor.withMultiplied(hue: 0.99, saturation: 0.256, brightness: 0.62)
let mainSecondaryColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.109, brightness: 0.59)
let mainSecondaryTextColor = accentColor.withMultiplied(hue: 0.956, saturation: 0.17, brightness: 1.0)
let mainFreeTextColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.097, brightness: 0.56)
let outgoingBubbleFillColor: UIColor
let outgoingBubbleFillGradientColor: UIColor
let outgoingBubbleFillGradientColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.731, brightness: 0.59)
let outgoingBubbleFillColor = outgoingBubbleFillGradientColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98)
let outgoingBubbleHighlightedFillColor: UIColor
let outgoingScamColor: UIColor
let outgoingPrimaryTextColor: UIColor
let outgoingSecondaryTextColor: UIColor
let outgoingLinkTextColor: UIColor
let outgoingCheckColor: UIColor
let outgoingScamColor = UIColor(rgb: 0xffffff)
let outgoingPrimaryTextColor = UIColor(rgb: 0xffffff)
let outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
let outgoingLinkTextColor = UIColor(rgb: 0xffffff)
let outgoingCheckColor = UIColor(rgb: 0xffffff, alpha: 0.5)
if let bubbleColors = bubbleColors {
outgoingBubbleFillColor = bubbleColors.0
outgoingBubbleFillGradientColor = bubbleColors.1 ?? bubbleColors.0
} else {
outgoingBubbleFillGradientColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.731, brightness: 0.59)
outgoingBubbleFillColor = outgoingBubbleFillGradientColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98)
}
let outgoingBubbleLightnessColor = outgoingBubbleFillColor.mixedWith(outgoingBubbleFillGradientColor, alpha: 0.5)
if outgoingBubbleLightnessColor.lightness > 0.7 {
outgoingScamColor = UIColor(rgb: 0x000000)
outgoingPrimaryTextColor = UIColor(rgb: 0x000000)
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.5)
outgoingLinkTextColor = UIColor(rgb: 0x000000)
outgoingCheckColor = UIColor(rgb: 0x000000, alpha: 0.5)
} else {
outgoingScamColor = UIColor(rgb: 0xffffff)
outgoingPrimaryTextColor = UIColor(rgb: 0xffffff)
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
outgoingLinkTextColor = UIColor(rgb: 0xffffff)
outgoingCheckColor = UIColor(rgb: 0xffffff, alpha: 0.5)
}
let highlightedIncomingBubbleColor = accentColor.withMultiplied(hue: 1.03, saturation: 0.463, brightness: 0.29)
let highlightedOutgoingBubbleColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.609, brightness: 0.63)
@ -136,8 +535,8 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
frameColor: mainSecondaryTextColor.withAlphaComponent(0.5),
handleColor: UIColor(rgb: 0x121212),
contentColor: accentColor,
positiveColor: constructiveColor,
negativeColor: destructiveColor
positiveColor: UIColor(rgb: 0x08a723),
negativeColor: UIColor(rgb: 0xff6767)
)
let list = PresentationThemeList(
@ -148,7 +547,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
itemDisabledTextColor: mainSecondaryTextColor.withAlphaComponent(0.5),
itemAccentColor: accentColor,
itemHighlightedColor: UIColor(rgb: 0x28b772),
itemDestructiveColor: destructiveColor,
itemDestructiveColor: UIColor(rgb: 0xff6767),
itemPlaceholderTextColor: mainSecondaryTextColor.withAlphaComponent(0.5),
itemBlocksBackgroundColor: mainBackgroundColor,
itemHighlightedBackgroundColor: mainSelectionColor,
@ -157,7 +556,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
disclosureArrowColor: mainSecondaryTextColor.withAlphaComponent(0.5),
sectionHeaderTextColor: mainFreeTextColor,
freeTextColor: mainFreeTextColor,
freeTextErrorColor: destructiveColor,
freeTextErrorColor: UIColor(rgb: 0xff6767),
freeTextSuccessColor: UIColor(rgb: 0x30cf30),
freeMonoIconColor: mainFreeTextColor,
itemSwitchColors: switchColors,
@ -165,7 +564,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
neutral1: PresentationThemeFillForeground(fillColor: accentColor, foregroundColor: .white),
neutral2: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xcd7800), foregroundColor: .white),
destructive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xc70c0c), foregroundColor: .white),
constructive: PresentationThemeFillForeground(fillColor: constructiveColor, foregroundColor: .white),
constructive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x08a723), foregroundColor: .white),
accent: PresentationThemeFillForeground(fillColor: accentColor, foregroundColor: .white),
warning: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xcd7800), foregroundColor: .white),
inactive: PresentationThemeFillForeground(fillColor: accentColor.withMultiplied(hue: 1.029, saturation: 0.609, brightness: 0.3), foregroundColor: .white)
@ -205,7 +604,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
itemHighlightedBackgroundColor: mainSelectionColor,
itemSelectedBackgroundColor: mainSelectionColor,
titleColor: UIColor(rgb: 0xffffff),
secretTitleColor: secretColor,
secretTitleColor: UIColor(rgb: 0x89df9e),
dateTextColor: mainSecondaryTextColor.withAlphaComponent(0.5),
authorNameColor: UIColor(rgb: 0xffffff),
messageTextColor: mainSecondaryTextColor.withAlphaComponent(0.5),
@ -213,7 +612,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
messageDraftTextColor: UIColor(rgb: 0xdd4b39),
checkmarkColor: accentColor,
pendingIndicatorColor: mainSecondaryTextColor.withAlphaComponent(0.4),
failedFillColor: destructiveColor,
failedFillColor: UIColor(rgb: 0xff6767),
failedForegroundColor: .white,
muteIconColor: mainSecondaryTextColor.withAlphaComponent(0.4),
unreadBadgeActiveBackgroundColor: accentColor,
@ -227,7 +626,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
sectionHeaderTextColor: mainSecondaryTextColor.withAlphaComponent(0.5),
verifiedIconFillColor: accentColor,
verifiedIconForegroundColor: .white,
secretIconColor: secretColor,
secretIconColor: UIColor(rgb: 0x89df9e),
pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0x72d5fd), bottomColor: UIColor(rgb: 0x2a9ef1)), foregroundColor: .white),
unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: accentColor.withMultiplied(hue: 0.985, saturation: 0.268, brightness: 0.47), bottomColor: accentColor.withMultiplied(hue: 0.98, saturation: 0.268, brightness: 0.39)), foregroundColor: additionalBackgroundColor),
onlineDotColor: UIColor(rgb: 0x4cc91f)
@ -236,7 +635,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
let buttonStrokeColor = accentColor.withMultiplied(hue: 1.014, saturation: 0.56, brightness: 0.64).withAlphaComponent(0.15)
let message = PresentationThemeChatMessage(
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor)), primaryTextColor: .white, secondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: destructiveColor, textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: accentColor, accentControlColor: accentColor, mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.5), mediaControlInnerBackgroundColor: mainBackgroundColor, pendingActivityColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileTitleColor: accentColor, fileDescriptionColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileDurationColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23), polls: PresentationThemeChatBubblePolls(radioButton: accentColor.withMultiplied(hue: 0.995, saturation: 0.317, brightness: 0.51), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: mainSeparatorColor, bar: accentColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor),
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor)), primaryTextColor: .white, secondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: UIColor(rgb: 0xff6767), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: accentColor, accentControlColor: accentColor, mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.5), mediaControlInnerBackgroundColor: mainBackgroundColor, pendingActivityColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileTitleColor: accentColor, fileDescriptionColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileDurationColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23), polls: PresentationThemeChatBubblePolls(radioButton: accentColor.withMultiplied(hue: 0.995, saturation: 0.317, brightness: 0.51), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: mainSeparatorColor, bar: accentColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor),
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColor)), primaryTextColor: outgoingPrimaryTextColor, secondaryTextColor: outgoingSecondaryTextColor, linkTextColor: outgoingLinkTextColor, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: outgoingPrimaryTextColor, accentControlColor: outgoingPrimaryTextColor, mediaActiveControlColor: outgoingPrimaryTextColor, mediaInactiveControlColor: outgoingSecondaryTextColor, mediaControlInnerBackgroundColor: outgoingBubbleFillColor, pendingActivityColor: outgoingSecondaryTextColor, fileTitleColor: outgoingPrimaryTextColor, fileDescriptionColor: outgoingSecondaryTextColor, fileDurationColor: outgoingSecondaryTextColor, mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.804, brightness: 0.51), polls: PresentationThemeChatBubblePolls(radioButton: outgoingPrimaryTextColor, radioProgress: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0), highlight: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0).withAlphaComponent(0.12), separator: mainSeparatorColor, bar: outgoingPrimaryTextColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: UIColor.white.withAlphaComponent(0.2), textSelectionKnobColor: UIColor.white),
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor)),
infoPrimaryTextColor: UIColor(rgb: 0xffffff),
@ -249,12 +648,12 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
shareButtonForegroundColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2)),
mediaOverlayControlColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x000000, alpha: 0.6), foregroundColor: .white),
selectionControlColors: PresentationThemeFillStrokeForeground(fillColor: accentColor, strokeColor: .white, foregroundColor: .white),
deliveryFailedColors: PresentationThemeFillForeground(fillColor: destructiveColor, foregroundColor: .white),
deliveryFailedColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xff6767), foregroundColor: .white),
mediaHighlightOverlayColor: UIColor(white: 1.0, alpha: 0.6)
)
let serviceMessage = PresentationThemeServiceMessage(
components: PresentationThemeServiceMessageColor(withDefaultWallpaper: PresentationThemeServiceMessageColorComponents(fill: additionalBackgroundColor, primaryText: .white, linkHighlight: UIColor(rgb: 0xffffff, alpha: 0.12), scam: destructiveColor, dateFillStatic: additionalBackgroundColor.withAlphaComponent(0.6), dateFillFloating: additionalBackgroundColor.withAlphaComponent(0.2)), withCustomWallpaper: PresentationThemeServiceMessageColorComponents(fill: additionalBackgroundColor, primaryText: .white, linkHighlight: UIColor(rgb: 0xffffff, alpha: 0.12), scam: destructiveColor, dateFillStatic: additionalBackgroundColor.withAlphaComponent(0.6), dateFillFloating: additionalBackgroundColor.withAlphaComponent(0.2))),
components: PresentationThemeServiceMessageColor(withDefaultWallpaper: PresentationThemeServiceMessageColorComponents(fill: additionalBackgroundColor, primaryText: .white, linkHighlight: UIColor(rgb: 0xffffff, alpha: 0.12), scam: UIColor(rgb: 0xff6767), dateFillStatic: additionalBackgroundColor.withAlphaComponent(0.6), dateFillFloating: additionalBackgroundColor.withAlphaComponent(0.2)), withCustomWallpaper: PresentationThemeServiceMessageColorComponents(fill: additionalBackgroundColor, primaryText: .white, linkHighlight: UIColor(rgb: 0xffffff, alpha: 0.12), scam: UIColor(rgb: 0xff6767), dateFillStatic: additionalBackgroundColor.withAlphaComponent(0.6), dateFillFloating: additionalBackgroundColor.withAlphaComponent(0.2))),
unreadBarFillColor: mainBackgroundColor,
unreadBarStrokeColor: mainBackgroundColor,
unreadBarTextColor: .white,
@ -273,7 +672,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
panelControlAccentColor: accentColor,
panelControlColor: mainSecondaryTextColor.withAlphaComponent(0.5),
panelControlDisabledColor: UIColor(rgb: 0x90979F, alpha: 0.5),
panelControlDestructiveColor: destructiveColor,
panelControlDestructiveColor: UIColor(rgb: 0xff6767),
inputBackgroundColor: inputBackgroundColor,
inputStrokeColor: accentColor.withMultiplied(hue: 1.038, saturation: 0.463, brightness: 0.26),
inputPlaceholderColor: mainSecondaryTextColor.withAlphaComponent(0.4),
@ -338,7 +737,7 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
itemHighlightedBackgroundColor: mainSelectionColor.withAlphaComponent(0.2),
opaqueItemSeparatorColor: additionalBackgroundColor,
standardActionTextColor: accentColor,
destructiveActionTextColor: destructiveColor,
destructiveActionTextColor: UIColor(rgb: 0xff6767),
disabledActionTextColor: UIColor(white: 1.0, alpha: 0.5),
primaryTextColor: .white,
secondaryTextColor: UIColor(white: 1.0, alpha: 0.5),
@ -355,13 +754,13 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
let contextMenu = PresentationThemeContextMenu(
dimColor: UIColor(rgb: 0x000000, alpha: 0.6),
backgroundColor: rootNavigationBar.backgroundColor.withAlphaComponent(0.78),
itemSeparatorColor: UIColor(rgb: 0xFFFFFF, alpha: 0.15),
itemSeparatorColor: UIColor(rgb: 0xffffff, alpha: 0.15),
sectionSeparatorColor: UIColor(rgb: 0x000000, alpha: 0.2),
itemBackgroundColor: UIColor(rgb: 0x000000, alpha: 0.0),
itemHighlightedBackgroundColor: UIColor(rgb: 0xFFFFFF, alpha: 0.15),
itemHighlightedBackgroundColor: UIColor(rgb: 0xffffff, alpha: 0.15),
primaryColor: UIColor(rgb: 0xffffff, alpha: 1.0),
secondaryColor: UIColor(rgb: 0xffffff, alpha: 0.8),
destructiveColor: destructiveColor
destructiveColor: UIColor(rgb: 0xff6767)
)
let inAppNotification = PresentationThemeInAppNotification(
@ -394,14 +793,3 @@ private func makeDarkPresentationTheme(accentColor: UIColor, bubbleColors: (UICo
preview: preview
)
}
public let defaultDarkAccentColor = UIColor(rgb: 0x2ea6ff)
public let defaultDarkAccentPresentationTheme = makeDarkAccentPresentationTheme(accentColor: UIColor(rgb: 0x2ea6ff), bubbleColors: nil, preview: false)
public func makeDarkAccentPresentationTheme(accentColor: UIColor?, bubbleColors: (UIColor, UIColor?)?, preview: Bool) -> PresentationTheme {
var accentColor = accentColor ?? defaultDarkAccentColor
if accentColor == PresentationThemeBaseColor.blue.color {
accentColor = defaultDarkAccentColor
}
return makeDarkPresentationTheme(accentColor: accentColor, bubbleColors: bubbleColors, preview: preview)
}

View file

@ -4,103 +4,265 @@ import TelegramCore
import SyncCore
import TelegramUIPreferences
private func makeDefaultDayPresentationTheme(accentColor: UIColor, bubbleColors: (UIColor, UIColor?)?, serviceBackgroundColor: UIColor, day: Bool, preview: Bool) -> PresentationTheme {
let destructiveColor: UIColor = UIColor(rgb: 0xff3b30)
let constructiveColor: UIColor = UIColor(rgb: 0x00c900)
let secretColor: UIColor = UIColor(rgb: 0x00b12c)
public let defaultServiceBackgroundColor = UIColor(rgb: 0x000000, alpha: 0.3)
public let defaultPresentationTheme = makeDefaultDayPresentationTheme(serviceBackgroundColor: defaultServiceBackgroundColor, day: false, preview: false)
public let defaultDayAccentColor = UIColor(rgb: 0x007ee5)
public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, accentColor: UIColor?, backgroundColors: (UIColor, UIColor?)?, bubbleColors: (UIColor, UIColor?)?, serviceBackgroundColor: UIColor?) -> PresentationTheme {
if (theme.referenceTheme != .day && theme.referenceTheme != .dayClassic) {
return theme
}
let day = theme.referenceTheme == .day
var intro = theme.intro
var rootController = theme.rootController
var list = theme.list
var chatList = theme.chatList
var chat = theme.chat
var actionSheet = theme.actionSheet
var bubbleColors = bubbleColors
if bubbleColors == nil, editing {
if day {
let accentColor = accentColor ?? defaultDayAccentColor
bubbleColors = (accentColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98), accentColor)
} else {
bubbleColors = (UIColor(rgb: 0xe1ffc7), nil)
}
}
var accentColor = accentColor
if let initialAccentColor = accentColor, initialAccentColor.lightness > 0.705 {
let hsb = initialAccentColor.hsb
accentColor = UIColor(hue: hsb.0, saturation: min(1.0, hsb.1 * 1.1), brightness: min(hsb.2, 0.6), alpha: 1.0)
}
let outgoingPrimaryTextColor: UIColor
let outgoingSecondaryTextColor: UIColor
let outgoingLinkTextColor: UIColor
let outgoingCheckColor: UIColor
let outgoingControlColor: UIColor
var outgoingBubbleFillColor: UIColor
var outgoingBubbleFillGradientColor: UIColor
let outgoingBubbleStrokeColor: UIColor
let outgoingSelectionBaseColor: UIColor
outgoingBubbleFillColor = accentColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98)
outgoingBubbleFillGradientColor = accentColor
if let accentColor = accentColor {
intro = intro.withUpdated(accentTextColor: accentColor)
rootController = rootController.withUpdated(
tabBar: rootController.tabBar.withUpdated(selectedIconColor: accentColor, selectedTextColor: accentColor),
navigationBar: rootController.navigationBar.withUpdated(buttonColor: accentColor, accentTextColor: accentColor),
navigationSearchBar: rootController.navigationSearchBar.withUpdated(accentColor: accentColor)
)
list = list.withUpdated(
itemAccentColor: accentColor,
itemDisclosureActions: list.itemDisclosureActions.withUpdated(accent: list.itemDisclosureActions.accent.withUpdated(fillColor: accentColor)),
itemCheckColors: list.itemCheckColors.withUpdated(fillColor: accentColor),
itemBarChart: list.itemBarChart.withUpdated(color1: accentColor)
)
chatList = chatList.withUpdated(
checkmarkColor: day ? accentColor : nil,
unreadBadgeActiveBackgroundColor: accentColor,
verifiedIconFillColor: day ? accentColor : nil
)
actionSheet = actionSheet.withUpdated(
standardActionTextColor: accentColor,
controlAccentColor: accentColor
)
}
var outgoingBubbleFillColor: UIColor?
var outgoingBubbleFillGradientColor: UIColor?
var outgoingBubbleStrokeColor: UIColor?
var outgoingPrimaryTextColor: UIColor?
var outgoingSecondaryTextColor: UIColor?
var outgoingLinkTextColor: UIColor?
var outgoingScamColor: UIColor?
var outgoingAccentTextColor: UIColor?
var outgoingControlColor: UIColor?
var outgoingInactiveControlColor: UIColor?
var outgoingPendingActivityColor: UIColor?
var outgoingFileTitleColor: UIColor?
var outgoingFileDescriptionColor: UIColor?
var outgoingFileDurationColor: UIColor?
var outgoingMediaPlaceholderColor: UIColor?
var outgoingPollsButtonColor: UIColor?
var outgoingPollsProgressColor: UIColor?
var outgoingSelectionColor: UIColor?
var outgoingSelectionBaseColor: UIColor?
var outgoingCheckColor: UIColor?
if let bubbleColors = bubbleColors {
outgoingBubbleFillColor = bubbleColors.0
outgoingBubbleFillGradientColor = bubbleColors.1 ?? bubbleColors.0
}
if accentColor.lightness > 0.705 {
let accentColorHsb = accentColor.hsb
accentColor = UIColor(hue: accentColorHsb.0, saturation: min(1.0, accentColorHsb.1 * 1.1), brightness: min(accentColorHsb.2, 0.6), alpha: 1.0)
}
let outgoingBubbleLightnessColor = outgoingBubbleFillColor.mixedWith(outgoingBubbleFillGradientColor, alpha: 0.5)
if outgoingBubbleLightnessColor.lightness > 0.705 {
outgoingPrimaryTextColor = .black
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.55)
outgoingLinkTextColor = .black
outgoingCheckColor = .black
outgoingControlColor = outgoingPrimaryTextColor
if outgoingBubbleFillColor.distance(to: UIColor.white) < 200 {
outgoingBubbleStrokeColor = UIColor(rgb: 0xc8c7cc)
if day {
outgoingBubbleStrokeColor = .clear
} else {
outgoingBubbleStrokeColor = outgoingBubbleFillColor
outgoingBubbleStrokeColor = UIColor(rgb: 0x86a9c9, alpha: 0.5)
}
let lightnessColor = bubbleColors.0.mixedWith(bubbleColors.1 ?? bubbleColors.0, alpha: 0.5)
if lightnessColor.lightness > 0.705 {
outgoingPrimaryTextColor = UIColor(rgb: 0x000000)
outgoingSecondaryTextColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.344, saturation: 4.554, brightness: 0.549).withAlphaComponent(0.8)
outgoingAccentTextColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.302, saturation: 4.554, brightness: 0.655)
outgoingLinkTextColor = UIColor(rgb: 0x004bad)
outgoingScamColor = UIColor(rgb: 0xff3b30)
outgoingControlColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.283, saturation: 3.176, brightness: 0.765)
outgoingInactiveControlColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.207, saturation: 1.721, brightness: 0.851)
outgoingPendingActivityColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.342, saturation: 2.902, brightness: 0.714)
outgoingFileTitleColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.285, saturation: 2.946, brightness: 0.667)
outgoingFileDescriptionColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.257, saturation: 1.842, brightness: 0.698)
outgoingFileDurationColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.344, saturation: 4.554, brightness: 0.549).withAlphaComponent(0.8)
outgoingMediaPlaceholderColor = outgoingBubbleFillColor?.withMultiplied(hue: 0.998, saturation: 1.129, brightness: 0.949)
outgoingPollsButtonColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.207, saturation: 1.721, brightness: 0.851)
outgoingPollsProgressColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.283, saturation: 3.176, brightness: 0.765)
outgoingSelectionColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.013, saturation: 1.292, brightness: 0.871)
outgoingSelectionBaseColor = outgoingControlColor
outgoingCheckColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.221, saturation: 4.554, brightness: 0.780)
// outgoingPrimaryTextColor = UIColor(rgb: 0x000000)
// outgoingSecondaryTextColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.008, saturation: 5.667, brightness: 0.898)
// outgoingAccentTextColor = outgoingSecondaryTextColor
// outgoingLinkTextColor = UIColor(rgb: 0x004bad)
// outgoingScamColor = UIColor(rgb: 0xff3b30)
// outgoingControlColor = outgoingSecondaryTextColor
// outgoingInactiveControlColor = outgoingSecondaryTextColor
// outgoingPendingActivityColor = outgoingSecondaryTextColor
// outgoingFileTitleColor = outgoingSecondaryTextColor
// outgoingFileDescriptionColor = outgoingSecondaryTextColor
// outgoingFileDurationColor = outgoingSecondaryTextColor
// outgoingMediaPlaceholderColor = outgoingBubbleFillColor?.withMultiplied(hue: 0.998, saturation: 1.129, brightness: 0.949)
// outgoingPollsButtonColor = outgoingSecondaryTextColor?.withAlphaComponent(0.38)
// outgoingPollsProgressColor = outgoingSecondaryTextColor
// outgoingSelectionColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.013, saturation: 1.292, brightness: 0.871)
// outgoingSelectionBaseColor = outgoingControlColor
// outgoingCheckColor = outgoingSecondaryTextColor
if day {
if let distance = outgoingBubbleFillColor?.distance(to: UIColor(rgb: 0xffffff)), distance < 200 {
outgoingBubbleStrokeColor = UIColor(rgb: 0xc8c7cc)
}
}
} else {
outgoingPrimaryTextColor = UIColor(rgb: 0xffffff)
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.65)
outgoingAccentTextColor = outgoingPrimaryTextColor
outgoingLinkTextColor = UIColor(rgb: 0xffffff)
outgoingScamColor = outgoingPrimaryTextColor
outgoingControlColor = outgoingPrimaryTextColor
outgoingInactiveControlColor = outgoingSecondaryTextColor
outgoingPendingActivityColor = outgoingSecondaryTextColor
outgoingFileTitleColor = outgoingPrimaryTextColor
outgoingFileDescriptionColor = outgoingSecondaryTextColor
outgoingFileDurationColor = outgoingSecondaryTextColor
outgoingMediaPlaceholderColor = outgoingBubbleFillColor?.withMultipliedBrightnessBy(0.95)
outgoingPollsButtonColor = outgoingSecondaryTextColor
outgoingPollsProgressColor = outgoingPrimaryTextColor
outgoingSelectionBaseColor = UIColor(rgb: 0xffffff)
outgoingSelectionColor = outgoingSelectionBaseColor?.withAlphaComponent(0.2)
outgoingCheckColor = UIColor(rgb: 0xffffff)
}
outgoingSelectionBaseColor = accentColor
} else {
outgoingPrimaryTextColor = .white
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.65)
outgoingLinkTextColor = .white
outgoingCheckColor = .white
outgoingControlColor = outgoingPrimaryTextColor
outgoingBubbleStrokeColor = outgoingBubbleFillColor
outgoingSelectionBaseColor = .white
}
let rootTabBar = PresentationThemeRootTabBar(
backgroundColor: UIColor(rgb: 0xf7f7f7),
separatorColor: UIColor(rgb: 0xa3a3a3),
iconColor: UIColor(rgb: 0x959595),
selectedIconColor: accentColor,
textColor: UIColor(rgb: 0x959595),
selectedTextColor: accentColor,
badgeBackgroundColor: UIColor(rgb: 0xff3b30),
badgeStrokeColor: UIColor(rgb: 0xff3b30),
badgeTextColor: .white
var defaultWallpaper: TelegramWallpaper?
if let backgroundColors = backgroundColors {
if let secondColor = backgroundColors.1 {
defaultWallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: secondColor.rgb), WallpaperSettings())
} else {
defaultWallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb))
}
}
chat = chat.withUpdated(
defaultWallpaper: defaultWallpaper,
message: chat.message.withUpdated(
incoming: chat.message.incoming.withUpdated(
linkHighlightColor: accentColor?.withAlphaComponent(0.3),
accentTextColor: accentColor,
accentControlColor: accentColor,
mediaActiveControlColor: accentColor,
polls: chat.message.incoming.polls.withUpdated(
radioProgress: accentColor,
highlight: accentColor?.withAlphaComponent(0.12),
bar: accentColor
),
actionButtonsFillColor: serviceBackgroundColor.flatMap { chat.message.incoming.actionButtonsFillColor.withUpdated(withWallpaper: $0) },
actionButtonsTextColor: day ? chat.message.incoming.actionButtonsTextColor.withUpdated(withoutWallpaper: accentColor) : nil,
textSelectionColor: accentColor?.withAlphaComponent(0.2),
textSelectionKnobColor: accentColor
),
outgoing: chat.message.outgoing.withUpdated(
bubble: chat.message.outgoing.bubble.withUpdated(
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
fill: outgoingBubbleFillColor,
gradientFill: outgoingBubbleFillGradientColor,
highlightedFill: outgoingBubbleFillColor?.withMultipliedBrightnessBy(0.7),
stroke: outgoingBubbleStrokeColor
),
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
fill: outgoingBubbleFillColor,
gradientFill: outgoingBubbleFillGradientColor,
highlightedFill: outgoingBubbleFillColor?.withMultipliedBrightnessBy(0.7),
stroke: outgoingBubbleStrokeColor
)
),
primaryTextColor: outgoingPrimaryTextColor,
secondaryTextColor: outgoingSecondaryTextColor,
linkTextColor: outgoingLinkTextColor,
linkHighlightColor: day ? nil : accentColor?.withAlphaComponent(0.3),
scamColor: outgoingScamColor,
accentTextColor: outgoingAccentTextColor,
accentControlColor: outgoingControlColor,
mediaActiveControlColor: outgoingControlColor,
mediaInactiveControlColor: outgoingInactiveControlColor,
mediaControlInnerBackgroundColor: .clear,
pendingActivityColor: outgoingPendingActivityColor,
fileTitleColor: outgoingFileTitleColor,
fileDescriptionColor: outgoingFileDescriptionColor,
fileDurationColor: outgoingFileDurationColor,
mediaPlaceholderColor: day ? accentColor?.withMultipliedBrightnessBy(0.95) : nil,
polls: chat.message.outgoing.polls.withUpdated(radioButton: outgoingPollsButtonColor, radioProgress: outgoingPollsProgressColor, highlight: outgoingPollsProgressColor?.withAlphaComponent(0.12), separator: outgoingPollsButtonColor, bar: outgoingPollsProgressColor),
actionButtonsFillColor: chat.message.outgoing.actionButtonsFillColor.withUpdated(withWallpaper: serviceBackgroundColor),
actionButtonsStrokeColor: day ? chat.message.outgoing.actionButtonsStrokeColor.withUpdated(withoutWallpaper: accentColor) : nil,
actionButtonsTextColor: day ? chat.message.outgoing.actionButtonsTextColor.withUpdated(withoutWallpaper: accentColor) : nil,
textSelectionColor: outgoingSelectionColor,
textSelectionKnobColor: outgoingSelectionBaseColor),
outgoingCheckColor: outgoingCheckColor,
shareButtonFillColor: serviceBackgroundColor.flatMap { chat.message.shareButtonFillColor.withUpdated(withWallpaper: $0) },
shareButtonForegroundColor: chat.message.shareButtonForegroundColor.withUpdated(withoutWallpaper: day ? accentColor : nil),
selectionControlColors: chat.message.selectionControlColors.withUpdated(fillColor: accentColor)),
serviceMessage: serviceBackgroundColor.flatMap {
chat.serviceMessage.withUpdated(components: chat.serviceMessage.components.withUpdated(withCustomWallpaper: chat.serviceMessage.components.withCustomWallpaper.withUpdated(fill: $0, dateFillStatic: $0, dateFillFloating: $0.withAlphaComponent($0.alpha * 0.6667))))
},
inputPanel: chat.inputPanel.withUpdated(
panelControlAccentColor: accentColor,
actionControlFillColor: accentColor,
mediaRecordingControl: chat.inputPanel.mediaRecordingControl.withUpdated(
buttonColor: accentColor,
micLevelColor: accentColor?.withAlphaComponent(0.2)
)
),
historyNavigation: chat.historyNavigation.withUpdated(
badgeBackgroundColor: accentColor,
badgeStrokeColor: accentColor
)
)
let rootNavigationBar = PresentationThemeRootNavigationBar(
buttonColor: accentColor,
disabledButtonColor: UIColor(rgb: 0xd0d0d0),
primaryTextColor: .black,
secondaryTextColor: UIColor(rgb: 0x787878),
controlColor: UIColor(rgb: 0x7e8791),
accentTextColor: accentColor,
backgroundColor: UIColor(rgb: 0xf7f7f7),
separatorColor: UIColor(rgb: 0xb1b1b1),
badgeBackgroundColor: UIColor(rgb: 0xff3b30),
badgeStrokeColor: UIColor(rgb: 0xff3b30),
badgeTextColor: .white,
segmentedBackgroundColor: UIColor(rgb: 0xe9e9e9),
segmentedForegroundColor: UIColor(rgb: 0xf7f7f7),
segmentedTextColor: UIColor(rgb: 0x000000),
segmentedDividerColor: UIColor(rgb: 0xd6d6dc)
)
let navigationSearchBar = PresentationThemeNavigationSearchBar(
backgroundColor: .white,
accentColor: accentColor,
inputFillColor: UIColor(rgb: 0xe9e9e9),
inputTextColor: .black,
inputPlaceholderTextColor: UIColor(rgb: 0x8e8e93),
inputIconColor: UIColor(rgb: 0x8e8e93),
inputClearButtonColor: UIColor(rgb: 0x7b7b81),
separatorColor: UIColor(rgb: 0xb1b1b1)
return PresentationTheme(
name: theme.name,
referenceTheme: theme.referenceTheme,
overallDarkAppearance: theme.overallDarkAppearance,
intro: intro,
passcode: theme.passcode,
rootController: rootController,
list: list,
chatList: chatList,
chat: chat,
actionSheet: actionSheet,
contextMenu: theme.contextMenu,
inAppNotification: theme.inAppNotification,
preview: theme.preview
)
}
public func makeDefaultDayPresentationTheme(serviceBackgroundColor: UIColor?, day: Bool, preview: Bool) -> PresentationTheme {
var serviceBackgroundColor = serviceBackgroundColor ?? defaultServiceBackgroundColor
let intro = PresentationThemeIntro(
statusBarStyle: .black,
primaryTextColor: .black,
accentTextColor: accentColor,
primaryTextColor: UIColor(rgb: 0x000000),
accentTextColor: UIColor(rgb: 0x007ee5),
disabledTextColor: UIColor(rgb: 0xd0d0d0),
startButtonColor: UIColor(rgb: 0x2ca5e0),
dotColor: UIColor(rgb: 0xd9d9d9)
@ -110,7 +272,48 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, bubbleColors:
backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0x46739e), bottomColor: UIColor(rgb: 0x2a5982)),
buttonColor: .clear
)
let rootTabBar = PresentationThemeRootTabBar(
backgroundColor: UIColor(rgb: 0xf7f7f7),
separatorColor: UIColor(rgb: 0xa3a3a3),
iconColor: UIColor(rgb: 0x959595),
selectedIconColor: UIColor(rgb: 0x007ee5),
textColor: UIColor(rgb: 0x959595),
selectedTextColor: UIColor(rgb: 0x007ee5),
badgeBackgroundColor: UIColor(rgb: 0xff3b30),
badgeStrokeColor: UIColor(rgb: 0xff3b30),
badgeTextColor: UIColor(rgb: 0xffffff)
)
let rootNavigationBar = PresentationThemeRootNavigationBar(
buttonColor: UIColor(rgb: 0x007ee5),
disabledButtonColor: UIColor(rgb: 0xd0d0d0),
primaryTextColor: UIColor(rgb: 0x000000),
secondaryTextColor: UIColor(rgb: 0x787878),
controlColor: UIColor(rgb: 0x7e8791),
accentTextColor: UIColor(rgb: 0x007ee5),
backgroundColor: UIColor(rgb: 0xf7f7f7),
separatorColor: UIColor(rgb: 0xb1b1b1),
badgeBackgroundColor: UIColor(rgb: 0xff3b30),
badgeStrokeColor: UIColor(rgb: 0xff3b30),
badgeTextColor: UIColor(rgb: 0xffffff),
segmentedBackgroundColor: UIColor(rgb: 0xe9e9e9),
segmentedForegroundColor: UIColor(rgb: 0xf7f7f7),
segmentedTextColor: UIColor(rgb: 0x000000),
segmentedDividerColor: UIColor(rgb: 0xd6d6dc)
)
let navigationSearchBar = PresentationThemeNavigationSearchBar(
backgroundColor: UIColor(rgb: 0xffffff),
accentColor: UIColor(rgb: 0x007ee5),
inputFillColor: UIColor(rgb: 0xe9e9e9),
inputTextColor: UIColor(rgb: 0x000000),
inputPlaceholderTextColor: UIColor(rgb: 0x8e8e93),
inputIconColor: UIColor(rgb: 0x8e8e93),
inputClearButtonColor: UIColor(rgb: 0x7b7b81),
separatorColor: UIColor(rgb: 0xb1b1b1)
)
let rootController = PresentationThemeRootController(
statusBarStyle: .black,
tabBar: rootTabBar,
@ -123,21 +326,21 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, bubbleColors:
frameColor: UIColor(rgb: 0xe9e9ea),
handleColor: UIColor(rgb: 0xffffff),
contentColor: UIColor(rgb: 0x35c759),
positiveColor: constructiveColor,
negativeColor: destructiveColor
positiveColor: UIColor(rgb: 0x00c900),
negativeColor: UIColor(rgb: 0xff3b30)
)
let list = PresentationThemeList(
blocksBackgroundColor: UIColor(rgb: 0xefeff4),
plainBackgroundColor: .white,
itemPrimaryTextColor: .black,
plainBackgroundColor: UIColor(rgb: 0xffffff),
itemPrimaryTextColor: UIColor(rgb: 0x000000),
itemSecondaryTextColor: UIColor(rgb: 0x8e8e93),
itemDisabledTextColor: UIColor(rgb: 0x8e8e93),
itemAccentColor: accentColor,
itemHighlightedColor: secretColor,
itemDestructiveColor: destructiveColor,
itemAccentColor: UIColor(rgb: 0x007ee5),
itemHighlightedColor: UIColor(rgb: 0x00b12c),
itemDestructiveColor: UIColor(rgb: 0xff3b30),
itemPlaceholderTextColor: UIColor(rgb: 0xc8c8ce),
itemBlocksBackgroundColor: .white,
itemBlocksBackgroundColor: UIColor(rgb: 0xffffff),
itemHighlightedBackgroundColor: UIColor(rgb: 0xe5e5ea),
itemBlocksSeparatorColor: UIColor(rgb: 0xc8c7cc),
itemPlainSeparatorColor: UIColor(rgb: 0xc8c7cc),
@ -149,150 +352,239 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, bubbleColors:
freeMonoIconColor: UIColor(rgb: 0x7e7e87),
itemSwitchColors: switchColors,
itemDisclosureActions: PresentationThemeItemDisclosureActions(
neutral1: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x4892f2), foregroundColor: .white),
neutral2: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xf09a37), foregroundColor: .white),
destructive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xff3824), foregroundColor: .white),
constructive: PresentationThemeFillForeground(fillColor: constructiveColor, foregroundColor: .white),
accent: PresentationThemeFillForeground(fillColor: accentColor, foregroundColor: .white),
warning: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xff9500), foregroundColor: .white),
inactive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xbcbcc3), foregroundColor: .white)
neutral1: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x4892f2), foregroundColor: UIColor(rgb: 0xffffff)),
neutral2: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xf09a37), foregroundColor: UIColor(rgb: 0xffffff)),
destructive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xff3824), foregroundColor: UIColor(rgb: 0xffffff)),
constructive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x00c900), foregroundColor: UIColor(rgb: 0xffffff)),
accent: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x007ee5), foregroundColor: UIColor(rgb: 0xffffff)),
warning: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xff9500), foregroundColor: UIColor(rgb: 0xffffff)),
inactive: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xbcbcc3), foregroundColor: UIColor(rgb: 0xffffff))
),
itemCheckColors: PresentationThemeFillStrokeForeground(
fillColor: accentColor,
fillColor: UIColor(rgb: 0x007ee5),
strokeColor: UIColor(rgb: 0xc7c7cc),
foregroundColor: .white
foregroundColor: UIColor(rgb: 0xffffff)
),
controlSecondaryColor: UIColor(rgb: 0xdedede),
freeInputField: PresentationInputFieldTheme(
backgroundColor: UIColor(rgb: 0xd6d6dc),
strokeColor: UIColor(rgb: 0xd6d6dc),
placeholderColor: UIColor(rgb: 0x96979d),
primaryColor: .black,
primaryColor: UIColor(rgb: 0x000000),
controlColor: UIColor(rgb: 0x96979d)
),
freePlainInputField: PresentationInputFieldTheme(
backgroundColor: UIColor(rgb: 0xe9e9e9),
strokeColor: UIColor(rgb: 0xe9e9e9),
placeholderColor: UIColor(rgb: 0x8E8D92),
primaryColor: .black,
controlColor: UIColor(rgb: 0xBCBCC0)
placeholderColor: UIColor(rgb: 0x8e8d92),
primaryColor: UIColor(rgb: 0x000000),
controlColor: UIColor(rgb: 0xbcbcc0)
),
mediaPlaceholderColor: UIColor(rgb: 0xe4e4e4),
scrollIndicatorColor: UIColor(white: 0.0, alpha: 0.3),
pageIndicatorInactiveColor: UIColor(rgb: 0xe3e3e7),
inputClearButtonColor: UIColor(rgb: 0xcccccc),
itemBarChart: PresentationThemeItemBarChart(color1: accentColor, color2: UIColor(rgb: 0xc8c7cc), color3: UIColor(rgb: 0xf2f1f7))
itemBarChart: PresentationThemeItemBarChart(color1: UIColor(rgb: 0x007ee5), color2: UIColor(rgb: 0xc8c7cc), color3: UIColor(rgb: 0xf2f1f7))
)
let chatList = PresentationThemeChatList(
backgroundColor: .white,
backgroundColor: UIColor(rgb: 0xffffff),
itemSeparatorColor: UIColor(rgb: 0xc8c7cc),
itemBackgroundColor: .white,
itemBackgroundColor: UIColor(rgb: 0xffffff),
pinnedItemBackgroundColor: UIColor(rgb: 0xf7f7f7),
itemHighlightedBackgroundColor: UIColor(rgb: 0xe5e5ea),
itemSelectedBackgroundColor: UIColor(rgb: 0xe9f0fa),
titleColor: .black,
secretTitleColor: secretColor,
titleColor: UIColor(rgb: 0x000000),
secretTitleColor: UIColor(rgb: 0x00b12c),
dateTextColor: UIColor(rgb: 0x8e8e93),
authorNameColor: .black,
authorNameColor: UIColor(rgb: 0x000000),
messageTextColor: UIColor(rgb: 0x8e8e93),
messageHighlightedTextColor: .black,
messageHighlightedTextColor: UIColor(rgb: 0x000000),
messageDraftTextColor: UIColor(rgb: 0xdd4b39),
checkmarkColor: day ? accentColor : UIColor(rgb: 0x21c004),
checkmarkColor: day ? UIColor(rgb: 0x007ee5) : UIColor(rgb: 0x21c004),
pendingIndicatorColor: UIColor(rgb: 0x8e8e93),
failedFillColor: destructiveColor,
failedForegroundColor: .white,
failedFillColor: UIColor(rgb: 0xff3b30),
failedForegroundColor: UIColor(rgb: 0xffffff),
muteIconColor: UIColor(rgb: 0xa7a7ad),
unreadBadgeActiveBackgroundColor: accentColor,
unreadBadgeActiveTextColor: .white,
unreadBadgeActiveBackgroundColor: UIColor(rgb: 0x007ee5),
unreadBadgeActiveTextColor: UIColor(rgb: 0xffffff),
unreadBadgeInactiveBackgroundColor: UIColor(rgb: 0xb6b6bb),
unreadBadgeInactiveTextColor: .white,
unreadBadgeInactiveTextColor: UIColor(rgb: 0xffffff),
pinnedBadgeColor: UIColor(rgb: 0xb6b6bb),
pinnedSearchBarColor: UIColor(rgb: 0xe5e5e5),
regularSearchBarColor: UIColor(rgb: 0xe9e9e9),
sectionHeaderFillColor: UIColor(rgb: 0xf7f7f7),
sectionHeaderTextColor: UIColor(rgb: 0x8e8e93),
verifiedIconFillColor: accentColor,
verifiedIconForegroundColor: .white,
secretIconColor: secretColor,
pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0x72d5fd), bottomColor: UIColor(rgb: 0x2a9ef1)), foregroundColor: .white),
unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0xdedee5), bottomColor: UIColor(rgb: 0xc5c6cc)), foregroundColor: .white),
verifiedIconFillColor: UIColor(rgb: 0x007ee5),
verifiedIconForegroundColor: UIColor(rgb: 0xffffff),
secretIconColor: UIColor(rgb: 0x00b12c),
pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0x72d5fd), bottomColor: UIColor(rgb: 0x2a9ef1)), foregroundColor: UIColor(rgb: 0xffffff)),
unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0xdedee5), bottomColor: UIColor(rgb: 0xc5c6cc)), foregroundColor: UIColor(rgb: 0xffffff)),
onlineDotColor: UIColor(rgb: 0x4cc91f)
)
let message = PresentationThemeChatMessage(
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xd9f4ff), stroke: UIColor(rgb: 0x86A9C9, alpha: 0.5)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xd9f4ff), stroke: UIColor(rgb: 0x86A9C9, alpha: 0.5))), primaryTextColor: .black, secondaryTextColor: UIColor(rgb: 0x525252, alpha: 0.6), linkTextColor: UIColor(rgb: 0x004bad), linkHighlightColor: accentColor.withAlphaComponent(0.3), scamColor: destructiveColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: UIColor(rgb: 0x007ee5), accentControlColor: UIColor(rgb: 0x007ee5), mediaActiveControlColor: UIColor(rgb: 0x007ee5), mediaInactiveControlColor: UIColor(rgb: 0xcacaca), mediaControlInnerBackgroundColor: UIColor(rgb: 0xffffff), pendingActivityColor: UIColor(rgb: 0x525252, alpha: 0.6), fileTitleColor: UIColor(rgb: 0x0b8bed), fileDescriptionColor: UIColor(rgb: 0x999999), fileDurationColor: UIColor(rgb: 0x525252, alpha: 0.6), mediaPlaceholderColor: UIColor(rgb: 0xe8ecf0), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xc8c7cc), radioProgress: UIColor(rgb: 0x007ee5), highlight: UIColor(rgb: 0x007ee5).withAlphaComponent(0.08), separator: UIColor(rgb: 0xc8c7cc), bar: UIColor(rgb: 0x007ee5)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0x596e89, alpha: 0.35)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: .clear), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor),
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xe1ffc7), highlightedFill: UIColor(rgb: 0xc8ffa6), stroke: UIColor(rgb: 0x86a9c9, alpha: 0.5)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xe1ffc7), highlightedFill: UIColor(rgb: 0xc8ffa6), stroke: UIColor(rgb: 0x86a9c9, alpha: 0.5))), primaryTextColor: .black, secondaryTextColor: UIColor(rgb: 0x008c09, alpha: 0.8), linkTextColor: UIColor(rgb: 0x004bad), linkHighlightColor: accentColor.withAlphaComponent(0.3), scamColor: destructiveColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: UIColor(rgb: 0x00a700), accentControlColor: UIColor(rgb: 0x3fc33b), mediaActiveControlColor: UIColor(rgb: 0x3fc33b), mediaInactiveControlColor: UIColor(rgb: 0x93d987), mediaControlInnerBackgroundColor: UIColor(rgb: 0xe1ffc7), pendingActivityColor: UIColor(rgb: 0x42b649), fileTitleColor: UIColor(rgb: 0x3faa3c), fileDescriptionColor: UIColor(rgb: 0x6fb26a), fileDurationColor: UIColor(rgb: 0x008c09, alpha: 0.8), mediaPlaceholderColor: UIColor(rgb: 0xd2f2b6), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x93d987), radioProgress: UIColor(rgb: 0x3fc33b), highlight: UIColor(rgb: 0x3fc33b).withAlphaComponent(0.08), separator: UIColor(rgb: 0x93d987), bar: UIColor(rgb: 0x3fc33b)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0x596e89, alpha: 0.35)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: .clear), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: UIColor(rgb: 0xBBDE9F), textSelectionKnobColor: UIColor(rgb: 0x3FC33B)),
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xd9f4ff), stroke: UIColor(rgb: 0x86A9C9, alpha: 0.5)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xd9f4ff), stroke: UIColor(rgb: 0x86A9C9, alpha: 0.5))),
incoming: PresentationThemePartedColors(
bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xd9f4ff), stroke: UIColor(rgb: 0x86a9c9, alpha: 0.5)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xd9f4ff), stroke: UIColor(rgb: 0x86a9c9, alpha: 0.5))),
primaryTextColor: UIColor(rgb: 0x000000),
secondaryTextColor: UIColor(rgb: 0x525252, alpha: 0.6),
linkTextColor: UIColor(rgb: 0x004bad),
linkHighlightColor: UIColor(rgb: 0x007ee5).withAlphaComponent(0.3),
scamColor: UIColor(rgb: 0xff3b30),
textHighlightColor: UIColor(rgb: 0xffe438),
accentTextColor: UIColor(rgb: 0x007ee5),
accentControlColor: UIColor(rgb: 0x007ee5),
mediaActiveControlColor: UIColor(rgb: 0x007ee5),
mediaInactiveControlColor: UIColor(rgb: 0xcacaca),
mediaControlInnerBackgroundColor: UIColor(rgb: 0xffffff),
pendingActivityColor: UIColor(rgb: 0x525252, alpha: 0.6),
fileTitleColor: UIColor(rgb: 0x0b8bed),
fileDescriptionColor: UIColor(rgb: 0x999999),
fileDurationColor: UIColor(rgb: 0x525252, alpha: 0.6),
mediaPlaceholderColor: UIColor(rgb: 0xe8ecf0),
polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xc8c7cc), radioProgress: UIColor(rgb: 0x007ee5), highlight: UIColor(rgb: 0x007ee5, alpha: 0.08), separator: UIColor(rgb: 0xc8c7cc), bar: UIColor(rgb: 0x007ee5)),
actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0x596e89, alpha: 0.35)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: .clear),
actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0x007ee5, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0x007ee5)),
outgoing: PresentationThemePartedColors(
bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xe1ffc7), highlightedFill: UIColor(rgb: 0xc8ffa6), stroke: UIColor(rgb: 0x86a9c9, alpha: 0.5)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xe1ffc7), highlightedFill: UIColor(rgb: 0xc8ffa6), stroke: UIColor(rgb: 0x86a9c9, alpha: 0.5))),
primaryTextColor: UIColor(rgb: 0x000000),
secondaryTextColor: UIColor(rgb: 0x008c09, alpha: 0.8),
linkTextColor: UIColor(rgb: 0x004bad),
linkHighlightColor: UIColor(rgb: 0x007ee5).withAlphaComponent(0.3),
scamColor: UIColor(rgb: 0xff3b30),
textHighlightColor: UIColor(rgb: 0xffe438),
accentTextColor: UIColor(rgb: 0x00a700),
accentControlColor: UIColor(rgb: 0x3fc33b),
mediaActiveControlColor: UIColor(rgb: 0x3fc33b),
mediaInactiveControlColor: UIColor(rgb: 0x93d987),
mediaControlInnerBackgroundColor: UIColor(rgb: 0xe1ffc7),
pendingActivityColor: UIColor(rgb: 0x42b649),
fileTitleColor: UIColor(rgb: 0x3faa3c),
fileDescriptionColor: UIColor(rgb: 0x6fb26a),
fileDurationColor: UIColor(rgb: 0x008c09, alpha: 0.8),
mediaPlaceholderColor: UIColor(rgb: 0xd2f2b6),
polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x93d987), radioProgress: UIColor(rgb: 0x3fc33b), highlight: UIColor(rgb: 0x3fc33b).withAlphaComponent(0.08), separator: UIColor(rgb: 0x93d987), bar: UIColor(rgb: 0x3fc33b)),
actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0x596e89, alpha: 0.35)),
actionButtonsStrokeColor: PresentationThemeVariableColor(color: .clear),
actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)),
textSelectionColor: UIColor(rgb: 0xbbde9f),
textSelectionKnobColor: UIColor(rgb: 0x3fc33b)),
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xd9f4ff), stroke: UIColor(rgb: 0x86a9c9, alpha: 0.5)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xd9f4ff), stroke: UIColor(rgb: 0x86a9c9, alpha: 0.5))),
infoPrimaryTextColor: UIColor(rgb: 0x000000),
infoLinkTextColor: UIColor(rgb: 0x004bad),
outgoingCheckColor: UIColor(rgb: 0x19c700),
mediaDateAndStatusFillColor: UIColor(white: 0.0, alpha: 0.5),
mediaDateAndStatusTextColor: .white,
mediaDateAndStatusTextColor: UIColor(rgb: 0xffffff),
shareButtonFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0x748391, alpha: 0.45)),
shareButtonStrokeColor: PresentationThemeVariableColor(withWallpaper: .clear, withoutWallpaper: .clear),
shareButtonForegroundColor: PresentationThemeVariableColor(withWallpaper: .white, withoutWallpaper: .white),
mediaOverlayControlColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x000000, alpha: 0.6), foregroundColor: .white),
selectionControlColors: PresentationThemeFillStrokeForeground(fillColor: accentColor, strokeColor: UIColor(rgb: 0xc7c7cc), foregroundColor: .white),
deliveryFailedColors: PresentationThemeFillForeground(fillColor: destructiveColor, foregroundColor: .white),
shareButtonForegroundColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0xffffff), withoutWallpaper: UIColor(rgb: 0xffffff)),
mediaOverlayControlColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x000000, alpha: 0.6), foregroundColor: UIColor(rgb: 0xffffff)),
selectionControlColors: PresentationThemeFillStrokeForeground(fillColor: UIColor(rgb: 0x007ee5), strokeColor: UIColor(rgb: 0xc7c7cc), foregroundColor: UIColor(rgb: 0xffffff)),
deliveryFailedColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xff3b30), foregroundColor: UIColor(rgb: 0xffffff)),
mediaHighlightOverlayColor: UIColor(white: 1.0, alpha: 0.6)
)
let messageDay = PresentationThemeChatMessage(
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xdadade), stroke: UIColor(rgb: 0xffffff)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xf1f1f4), highlightedFill: UIColor(rgb: 0xdadade), stroke: UIColor(rgb: 0xf1f1f4))), primaryTextColor: .black, secondaryTextColor: UIColor(rgb: 0x525252, alpha: 0.6), linkTextColor: UIColor(rgb: 0x004bad), linkHighlightColor: accentColor.withAlphaComponent(0.3), scamColor: destructiveColor, textHighlightColor: UIColor(rgb: 0xffc738), accentTextColor: accentColor, accentControlColor: accentColor, mediaActiveControlColor: accentColor, mediaInactiveControlColor: UIColor(rgb: 0xcacaca), mediaControlInnerBackgroundColor: UIColor(rgb: 0xffffff), pendingActivityColor: UIColor(rgb: 0x525252, alpha: 0.6), fileTitleColor: accentColor, fileDescriptionColor: UIColor(rgb: 0x999999), fileDurationColor: UIColor(rgb: 0x525252, alpha: 0.6), mediaPlaceholderColor: UIColor(rgb: 0xffffff).withMultipliedBrightnessBy(0.95), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xc8c7cc), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: UIColor(rgb: 0xc8c7cc), bar: accentColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0xffffff, alpha: 0.8)), actionButtonsStrokeColor: PresentationThemeVariableColor(withWallpaper: .clear, withoutWallpaper: accentColor), actionButtonsTextColor: PresentationThemeVariableColor(withWallpaper: .white, withoutWallpaper: accentColor), textSelectionColor: accentColor.withAlphaComponent(0.3), textSelectionKnobColor: accentColor),
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: outgoingBubbleFillColor.withMultipliedBrightnessBy(0.7), stroke: outgoingBubbleFillColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: outgoingBubbleFillColor.withMultipliedBrightnessBy(0.7), stroke: outgoingBubbleStrokeColor)), primaryTextColor: outgoingPrimaryTextColor, secondaryTextColor: outgoingSecondaryTextColor, linkTextColor: outgoingLinkTextColor, linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.3), scamColor: outgoingPrimaryTextColor, textHighlightColor: UIColor(rgb: 0xffc738), accentTextColor: outgoingPrimaryTextColor, accentControlColor: outgoingPrimaryTextColor, mediaActiveControlColor: outgoingPrimaryTextColor, mediaInactiveControlColor: outgoingSecondaryTextColor, mediaControlInnerBackgroundColor: .clear, pendingActivityColor: outgoingSecondaryTextColor, fileTitleColor: outgoingPrimaryTextColor, fileDescriptionColor: outgoingSecondaryTextColor, fileDurationColor: outgoingSecondaryTextColor, mediaPlaceholderColor: accentColor.withMultipliedBrightnessBy(0.95), polls: PresentationThemeChatBubblePolls(radioButton: outgoingSecondaryTextColor, radioProgress: outgoingPrimaryTextColor, highlight: outgoingPrimaryTextColor.withAlphaComponent(0.12), separator: outgoingSecondaryTextColor, bar: outgoingPrimaryTextColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0xffffff, alpha: 0.8)), actionButtonsStrokeColor: PresentationThemeVariableColor(withWallpaper: .clear, withoutWallpaper: accentColor), actionButtonsTextColor: PresentationThemeVariableColor(withWallpaper: .white, withoutWallpaper: accentColor), textSelectionColor: outgoingSelectionBaseColor.withAlphaComponent(0.2), textSelectionKnobColor: outgoingSelectionBaseColor),
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xE5E5EA), highlightedFill: UIColor(rgb: 0xDADADE), stroke: UIColor(rgb: 0xE5E5EA)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xE5E5EA), highlightedFill: UIColor(rgb: 0xdadade), stroke: UIColor(rgb: 0xE5E5EA))),
incoming: PresentationThemePartedColors(
bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xffffff), highlightedFill: UIColor(rgb: 0xdadade), stroke: UIColor(rgb: 0xffffff)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xf1f1f4), highlightedFill: UIColor(rgb: 0xdadade), stroke: UIColor(rgb: 0xf1f1f4))),
primaryTextColor: UIColor(rgb: 0x000000),
secondaryTextColor: UIColor(rgb: 0x525252, alpha: 0.6),
linkTextColor: UIColor(rgb: 0x004bad),
linkHighlightColor: UIColor(rgb: 0x007ee5, alpha: 0.3),
scamColor: UIColor(rgb: 0xff3b30),
textHighlightColor: UIColor(rgb: 0xffc738),
accentTextColor: UIColor(rgb: 0x007ee5),
accentControlColor: UIColor(rgb: 0x007ee5),
mediaActiveControlColor: UIColor(rgb: 0x007ee5),
mediaInactiveControlColor: UIColor(rgb: 0xcacaca),
mediaControlInnerBackgroundColor: UIColor(rgb: 0xffffff),
pendingActivityColor: UIColor(rgb: 0x525252, alpha: 0.6),
fileTitleColor: UIColor(rgb: 0x007ee5),
fileDescriptionColor: UIColor(rgb: 0x999999),
fileDurationColor: UIColor(rgb: 0x525252, alpha: 0.6),
mediaPlaceholderColor: UIColor(rgb: 0xffffff).withMultipliedBrightnessBy(0.95),
polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xc8c7cc), radioProgress: UIColor(rgb: 0x007ee5), highlight: UIColor(rgb: 0x007ee5, alpha: 0.12), separator: UIColor(rgb: 0xc8c7cc), bar: UIColor(rgb: 0x007ee5)),
actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0xffffff, alpha: 0.8)),
actionButtonsStrokeColor: PresentationThemeVariableColor(withWallpaper: .clear, withoutWallpaper: UIColor(rgb: 0x007ee5)),
actionButtonsTextColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0xffffff), withoutWallpaper: UIColor(rgb: 0x007ee5)),
textSelectionColor: UIColor(rgb: 0x007ee5, alpha: 0.3),
textSelectionKnobColor: UIColor(rgb: 0x007ee5)),
outgoing: PresentationThemePartedColors(
bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x57b2e0), gradientFill: UIColor(rgb: 0x007ee5), highlightedFill: UIColor(rgb: 0x57b2e0).withMultipliedBrightnessBy(0.7), stroke: .clear), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x57b2e0), gradientFill: UIColor(rgb: 0x007ee5), highlightedFill: UIColor(rgb: 0x57b2e0).withMultipliedBrightnessBy(0.7), stroke: .clear)),
primaryTextColor: UIColor(rgb: 0xffffff),
secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.65),
linkTextColor: UIColor(rgb: 0xffffff),
linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.3),
scamColor: UIColor(rgb: 0xffffff),
textHighlightColor: UIColor(rgb: 0xffc738),
accentTextColor: UIColor(rgb: 0xffffff),
accentControlColor: UIColor(rgb: 0xffffff),
mediaActiveControlColor: UIColor(rgb: 0xffffff),
mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.65),
mediaControlInnerBackgroundColor: .clear,
pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.65),
fileTitleColor: UIColor(rgb: 0xffffff),
fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.65),
fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.65),
mediaPlaceholderColor: UIColor(rgb: 0x0077d9),
polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xffffff, alpha: 0.65), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff, alpha: 0.12), separator: UIColor(rgb: 0xffffff, alpha: 0.65), bar: UIColor(rgb: 0xffffff)),
actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0xffffff, alpha: 0.8)),
actionButtonsStrokeColor: PresentationThemeVariableColor(withWallpaper: .clear, withoutWallpaper: UIColor(rgb: 0x007ee5)),
actionButtonsTextColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0xffffff), withoutWallpaper: UIColor(rgb: 0x007ee5)),
textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2),
textSelectionKnobColor: UIColor(rgb: 0xffffff)),
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xe5e5ea), highlightedFill: UIColor(rgb: 0xdadade), stroke: UIColor(rgb: 0xe5e5ea)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0xe5e5ea), highlightedFill: UIColor(rgb: 0xdadade), stroke: UIColor(rgb: 0xe5e5ea))),
infoPrimaryTextColor: UIColor(rgb: 0x000000),
infoLinkTextColor: UIColor(rgb: 0x004bad),
outgoingCheckColor: outgoingCheckColor,
outgoingCheckColor: UIColor(rgb: 0xffffff),
mediaDateAndStatusFillColor: UIColor(rgb: 0x000000, alpha: 0.5),
mediaDateAndStatusTextColor: .white,
mediaDateAndStatusTextColor: UIColor(rgb: 0xffffff),
shareButtonFillColor: PresentationThemeVariableColor(withWallpaper: serviceBackgroundColor, withoutWallpaper: UIColor(rgb: 0xffffff, alpha: 0.8)),
shareButtonStrokeColor: PresentationThemeVariableColor(withWallpaper: .clear, withoutWallpaper: UIColor(rgb: 0xe5e5ea)),
shareButtonForegroundColor: PresentationThemeVariableColor(withWallpaper: .white, withoutWallpaper: accentColor),
mediaOverlayControlColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x000000, alpha: 0.6), foregroundColor: .white),
selectionControlColors: PresentationThemeFillStrokeForeground(fillColor: accentColor, strokeColor: UIColor(rgb: 0xc7c7cc), foregroundColor: .white),
deliveryFailedColors: PresentationThemeFillForeground(fillColor: destructiveColor, foregroundColor: .white),
shareButtonForegroundColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0xffffff), withoutWallpaper: UIColor(rgb: 0x007ee5)),
mediaOverlayControlColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0x000000, alpha: 0.6), foregroundColor: UIColor(rgb: 0xffffff)),
selectionControlColors: PresentationThemeFillStrokeForeground(fillColor: UIColor(rgb: 0x007ee5), strokeColor: UIColor(rgb: 0xc7c7cc), foregroundColor: UIColor(rgb: 0xffffff)),
deliveryFailedColors: PresentationThemeFillForeground(fillColor: UIColor(rgb: 0xff3b30), foregroundColor: UIColor(rgb: 0xffffff)),
mediaHighlightOverlayColor: UIColor(rgb: 0xffffff, alpha: 0.6)
)
let serviceMessage = PresentationThemeServiceMessage(
components: PresentationThemeServiceMessageColor(withDefaultWallpaper: PresentationThemeServiceMessageColorComponents(fill: UIColor(rgb: 0x748391, alpha: 0.45), primaryText: .white, linkHighlight: UIColor(rgb: 0x748391, alpha: 0.25), scam: .white, dateFillStatic: UIColor(rgb: 0x748391, alpha: 0.45), dateFillFloating: UIColor(rgb: 0x939fab, alpha: 0.5)), withCustomWallpaper: PresentationThemeServiceMessageColorComponents(fill: serviceBackgroundColor, primaryText: .white, linkHighlight: UIColor(rgb: 0x748391, alpha: 0.25), scam: .white, dateFillStatic: serviceBackgroundColor, dateFillFloating: serviceBackgroundColor.withAlphaComponent(serviceBackgroundColor.alpha * 0.6667))),
components: PresentationThemeServiceMessageColor(withDefaultWallpaper: PresentationThemeServiceMessageColorComponents(fill: UIColor(rgb: 0x748391, alpha: 0.45), primaryText: UIColor(rgb: 0xffffff), linkHighlight: UIColor(rgb: 0x748391, alpha: 0.25), scam: UIColor(rgb: 0xffffff), dateFillStatic: UIColor(rgb: 0x748391, alpha: 0.45), dateFillFloating: UIColor(rgb: 0x939fab, alpha: 0.5)), withCustomWallpaper: PresentationThemeServiceMessageColorComponents(fill: serviceBackgroundColor, primaryText: UIColor(rgb: 0xffffff), linkHighlight: UIColor(rgb: 0x748391, alpha: 0.25), scam: UIColor(rgb: 0xffffff), dateFillStatic: serviceBackgroundColor, dateFillFloating: serviceBackgroundColor.withAlphaComponent(serviceBackgroundColor.alpha * 0.6667))),
unreadBarFillColor: UIColor(white: 1.0, alpha: 0.9),
unreadBarStrokeColor: UIColor(white: 0.0, alpha: 0.2),
unreadBarTextColor: UIColor(rgb: 0x86868d),
dateTextColor: PresentationThemeVariableColor(color: .white)
dateTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))
)
let serviceMessageDay = PresentationThemeServiceMessage(
components: PresentationThemeServiceMessageColor(withDefaultWallpaper: PresentationThemeServiceMessageColorComponents(fill: UIColor(rgb: 0xffffff, alpha: 0.8), primaryText: UIColor(rgb: 0x8d8e93), linkHighlight: UIColor(rgb: 0x748391, alpha: 0.25), scam: destructiveColor, dateFillStatic: UIColor(rgb: 0xffffff, alpha: 0.8), dateFillFloating: UIColor(rgb: 0xffffff, alpha: 0.8)), withCustomWallpaper: PresentationThemeServiceMessageColorComponents(fill: serviceBackgroundColor, primaryText: .white, linkHighlight: UIColor(rgb: 0x748391, alpha: 0.25), scam: destructiveColor, dateFillStatic: serviceBackgroundColor, dateFillFloating: serviceBackgroundColor.withAlphaComponent(serviceBackgroundColor.alpha * 0.6667))),
components: PresentationThemeServiceMessageColor(withDefaultWallpaper: PresentationThemeServiceMessageColorComponents(fill: UIColor(rgb: 0xffffff, alpha: 0.8), primaryText: UIColor(rgb: 0x8d8e93), linkHighlight: UIColor(rgb: 0x748391, alpha: 0.25), scam: UIColor(rgb: 0xff3b30), dateFillStatic: UIColor(rgb: 0xffffff, alpha: 0.8), dateFillFloating: UIColor(rgb: 0xffffff, alpha: 0.8)), withCustomWallpaper: PresentationThemeServiceMessageColorComponents(fill: serviceBackgroundColor, primaryText: UIColor(rgb: 0xffffff), linkHighlight: UIColor(rgb: 0x748391, alpha: 0.25), scam: UIColor(rgb: 0xff3b30), dateFillStatic: serviceBackgroundColor, dateFillFloating: serviceBackgroundColor.withAlphaComponent(serviceBackgroundColor.alpha * 0.6667))),
unreadBarFillColor: UIColor(rgb: 0xffffff),
unreadBarStrokeColor: UIColor(rgb: 0xffffff),
unreadBarTextColor: UIColor(rgb: 0x8d8e93),
dateTextColor: PresentationThemeVariableColor(withWallpaper: .white, withoutWallpaper: UIColor(rgb: 0x8d8e93))
dateTextColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0xffffff), withoutWallpaper: UIColor(rgb: 0x8d8e93))
)
let inputPanelMediaRecordingControl = PresentationThemeChatInputPanelMediaRecordingControl(
buttonColor: accentColor,
micLevelColor: accentColor.withAlphaComponent(0.2),
activeIconColor: .white
buttonColor: UIColor(rgb: 0x007ee5),
micLevelColor: UIColor(rgb: 0x007ee5, alpha: 0.2),
activeIconColor: UIColor(rgb: 0xffffff)
)
let inputPanel = PresentationThemeChatInputPanel(
panelBackgroundColor: UIColor(rgb: 0xf7f7f7),
panelSeparatorColor: UIColor(rgb: 0xb2b2b2),
panelControlAccentColor: accentColor,
panelControlAccentColor: UIColor(rgb: 0x007ee5),
panelControlColor: UIColor(rgb: 0x858e99),
panelControlDisabledColor: UIColor(rgb: 0x727b87, alpha: 0.5),
panelControlDestructiveColor: UIColor(rgb: 0xff3b30),
inputBackgroundColor: UIColor(rgb: 0xffffff),
inputStrokeColor: UIColor(rgb: 0xd9dcdf),
inputPlaceholderColor: UIColor(rgb: 0xbebec0),
inputTextColor: .black,
inputTextColor: UIColor(rgb: 0x000000),
inputControlColor: UIColor(rgb: 0xa0a7b0),
actionControlFillColor: accentColor,
actionControlForegroundColor: .white,
primaryTextColor: .black,
actionControlFillColor: UIColor(rgb: 0x007ee5),
actionControlForegroundColor: UIColor(rgb: 0xffffff),
primaryTextColor: UIColor(rgb: 0x000000),
secondaryTextColor: UIColor(rgb: 0x8e8e93),
mediaRecordingDotColor: UIColor(rgb: 0xed2521),
mediaRecordingControl: inputPanelMediaRecordingControl
@ -306,28 +598,28 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, bubbleColors:
stickersSectionTextColor: UIColor(rgb: 0x9099a2),
stickersSearchBackgroundColor: UIColor(rgb: 0xd9dbe1),
stickersSearchPlaceholderColor: UIColor(rgb: 0x8e8e93),
stickersSearchPrimaryColor: .black,
stickersSearchPrimaryColor: UIColor(rgb: 0x000000),
stickersSearchControlColor: UIColor(rgb: 0x8e8e93),
gifsBackgroundColor: .white
gifsBackgroundColor: UIColor(rgb: 0xffffff)
)
let inputButtonPanel = PresentationThemeInputButtonPanel(
panelSeparatorColor: UIColor(rgb: 0xbec2c6),
panelBackgroundColor: UIColor(rgb: 0xdee2e6),
buttonFillColor: .white,
buttonFillColor: UIColor(rgb: 0xffffff),
buttonStrokeColor: UIColor(rgb: 0xc3c7c9),
buttonHighlightedFillColor: UIColor(rgb: 0xa8b3c0),
buttonHighlightedStrokeColor: UIColor(rgb: 0xc3c7c9),
buttonTextColor: .black
buttonTextColor: UIColor(rgb: 0x000000)
)
let historyNavigation = PresentationThemeChatHistoryNavigation(
fillColor: UIColor(rgb: 0xf7f7f7),
strokeColor: UIColor(rgb: 0xb1b1b1),
foregroundColor: UIColor(rgb: 0x88888d),
badgeBackgroundColor: accentColor,
badgeStrokeColor: accentColor,
badgeTextColor: .white
badgeBackgroundColor: UIColor(rgb: 0x007ee5),
badgeStrokeColor: UIColor(rgb: 0x007ee5),
badgeTextColor: UIColor(rgb: 0xffffff)
)
let chat = PresentationThemeChat(
@ -343,24 +635,24 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, bubbleColors:
let actionSheet = PresentationThemeActionSheet(
dimColor: UIColor(white: 0.0, alpha: 0.4),
backgroundType: .light,
opaqueItemBackgroundColor: .white,
opaqueItemBackgroundColor: UIColor(rgb: 0xffffff),
itemBackgroundColor: UIColor(white: 1.0, alpha: 0.87),
opaqueItemHighlightedBackgroundColor: UIColor(white: 0.9, alpha: 1.0),
itemHighlightedBackgroundColor: UIColor(white: 0.9, alpha: 0.7),
opaqueItemSeparatorColor: UIColor(white: 0.9, alpha: 1.0),
standardActionTextColor: accentColor,
destructiveActionTextColor: destructiveColor,
standardActionTextColor: UIColor(rgb: 0x007ee5),
destructiveActionTextColor: UIColor(rgb: 0xff3b30),
disabledActionTextColor: UIColor(rgb: 0xb3b3b3),
primaryTextColor: .black,
primaryTextColor: UIColor(rgb: 0x000000),
secondaryTextColor: UIColor(rgb: 0x5e5e5e),
controlAccentColor: accentColor,
controlAccentColor: UIColor(rgb: 0x007ee5),
inputBackgroundColor: UIColor(rgb: 0xe9e9e9),
inputHollowBackgroundColor: .white,
inputHollowBackgroundColor: UIColor(rgb: 0xffffff),
inputBorderColor: UIColor(rgb: 0xe4e4e6),
inputPlaceholderColor: UIColor(rgb: 0x8E8D92),
inputTextColor: .black,
inputClearButtonColor: UIColor(rgb: 0xBCBCC0),
checkContentColor: .white
inputPlaceholderColor: UIColor(rgb: 0x8e8d92),
inputTextColor: UIColor(rgb: 0x000000),
inputClearButtonColor: UIColor(rgb: 0xbcbcc0),
checkContentColor: UIColor(rgb: 0xffffff)
)
let contextMenu = PresentationThemeContextMenu(
@ -372,17 +664,17 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, bubbleColors:
itemHighlightedBackgroundColor: UIColor(rgb: 0x3c3c43, alpha: 0.2),
primaryColor: UIColor(rgb: 0x000000, alpha: 1.0),
secondaryColor: UIColor(rgb: 0x000000, alpha: 0.8),
destructiveColor: destructiveColor
destructiveColor: UIColor(rgb: 0xff3b30)
)
let inAppNotification = PresentationThemeInAppNotification(
fillColor: .white,
primaryTextColor: .black,
fillColor: UIColor(rgb: 0xffffff),
primaryTextColor: UIColor(rgb: 0x000000),
expandedNotification: PresentationThemeExpandedNotification(
backgroundType: .light,
navigationBar: PresentationThemeExpandedNotificationNavigationBar(
backgroundColor: .white,
primaryTextColor: .black,
backgroundColor: UIColor(rgb: 0xffffff),
primaryTextColor: UIColor(rgb: 0x000000),
controlColor: UIColor(rgb: 0x7e8791),
separatorColor: UIColor(rgb: 0xb1b1b1)
)
@ -405,13 +697,3 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, bubbleColors:
preview: preview
)
}
public let defaultPresentationTheme = makeDefaultDayPresentationTheme(accentColor: UIColor(rgb: 0x007ee5), bubbleColors: nil, serviceBackgroundColor: defaultServiceBackgroundColor, day: false, preview: false)
public let defaultDayAccentColor = UIColor(rgb: 0x007ee5)
public let defaultServiceBackgroundColor = UIColor(rgb: 0x000000, alpha: 0.3)
public func makeDefaultDayPresentationTheme(accentColor: UIColor? = nil, bubbleColors: (UIColor, UIColor?)?, serviceBackgroundColor: UIColor, day: Bool, preview: Bool) -> PresentationTheme {
let accentColor = accentColor ?? defaultDayAccentColor
return makeDefaultDayPresentationTheme(accentColor: accentColor, bubbleColors: bubbleColors, serviceBackgroundColor: serviceBackgroundColor, day: day, preview: preview)
}

View file

@ -3,35 +3,52 @@ import UIKit
import Postbox
import TelegramUIPreferences
public func makeDefaultPresentationTheme(reference: PresentationBuiltinThemeReference, accentColor: UIColor?, bubbleColors: (UIColor, UIColor?)?, serviceBackgroundColor: UIColor, preview: Bool = false) -> PresentationTheme {
public func makeDefaultPresentationTheme(reference: PresentationBuiltinThemeReference, serviceBackgroundColor: UIColor?, preview: Bool = false) -> PresentationTheme {
let theme: PresentationTheme
switch reference {
case .dayClassic:
theme = makeDefaultDayPresentationTheme(bubbleColors: nil, serviceBackgroundColor: serviceBackgroundColor, day: false, preview: preview)
case .night:
theme = makeDarkPresentationTheme(accentColor: accentColor, bubbleColors: bubbleColors, preview: preview)
case .nightAccent:
theme = makeDarkAccentPresentationTheme(accentColor: accentColor, bubbleColors: bubbleColors, preview: preview)
theme = makeDefaultDayPresentationTheme(serviceBackgroundColor: serviceBackgroundColor, day: false, preview: preview)
case .day:
theme = makeDefaultDayPresentationTheme(accentColor: accentColor, bubbleColors: bubbleColors, serviceBackgroundColor: serviceBackgroundColor, day: true, preview: preview)
theme = makeDefaultDayPresentationTheme(serviceBackgroundColor: serviceBackgroundColor, day: true, preview: preview)
case .night:
theme = makeDefaultDarkPresentationTheme(preview: preview)
case .nightAccent:
theme = makeDefaultDarkTintedPresentationTheme(preview: preview)
}
return theme
}
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, accentColor: UIColor?, bubbleColors: (UIColor, UIColor?)?, serviceBackgroundColor: UIColor, preview: Bool = false) -> PresentationTheme? {
public func customizePresentationTheme(_ theme: PresentationTheme, editing: Bool, accentColor: UIColor?, backgroundColors: (UIColor, UIColor?)?, bubbleColors: (UIColor, UIColor?)?) -> PresentationTheme {
if accentColor == nil && bubbleColors == nil && backgroundColors == nil {
return theme
}
switch theme.referenceTheme {
case .day, .dayClassic:
return customizeDefaultDayTheme(theme: theme, editing: editing, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, serviceBackgroundColor: nil)
case .night:
return customizeDefaultDarkPresentationTheme(theme: theme, editing: editing, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors)
case .nightAccent:
return customizeDefaultDarkTintedPresentationTheme(theme: theme, editing: editing, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors)
}
return theme
}
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, accentColor: UIColor?, bubbleColors: (UIColor, UIColor?)?, backgroundColors: (UIColor, UIColor?)? = nil, serviceBackgroundColor: UIColor? = nil, preview: Bool = false) -> PresentationTheme? {
let theme: PresentationTheme
switch themeReference {
case let .builtin(reference):
theme = makeDefaultPresentationTheme(reference: reference, accentColor: accentColor, bubbleColors: bubbleColors, serviceBackgroundColor: serviceBackgroundColor, preview: preview)
let defaultTheme = makeDefaultPresentationTheme(reference: reference, serviceBackgroundColor: serviceBackgroundColor, preview: preview)
theme = customizePresentationTheme(defaultTheme, editing: true, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors)
case let .local(info):
if let path = mediaBox.completedResourcePath(info.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead), let loadedTheme = makePresentationTheme(data: data, resolvedWallpaper: info.resolvedWallpaper) {
theme = loadedTheme
theme = customizePresentationTheme(loadedTheme, editing: false, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors)
} else {
return nil
}
case let .cloud(info):
if let file = info.theme.file, let path = mediaBox.completedResourcePath(file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead), let loadedTheme = makePresentationTheme(data: data, resolvedWallpaper: info.resolvedWallpaper) {
theme = loadedTheme
theme = customizePresentationTheme(loadedTheme, editing: false, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors)
} else {
return nil
}

View file

@ -240,9 +240,9 @@ public func currentPresentationDataAndSettings(accountManager: AccountManager, s
}
let effectiveAccentColor = themeSettings.themeSpecificAccentColors[effectiveTheme.index]?.color
let effectiveBubbleColors = themeSettings.themeSpecificBubbleColors[effectiveTheme.index]?.colors
let effectiveBubbleColors = themeSettings.themeSpecificAccentColors[effectiveTheme.index]?.customBubbleColors
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveAccentColor, bubbleColors: effectiveBubbleColors, serviceBackgroundColor: defaultServiceBackgroundColor) ?? defaultPresentationTheme
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveAccentColor, bubbleColors: effectiveBubbleColors) ?? defaultPresentationTheme
let effectiveChatWallpaper: TelegramWallpaper = themeSettings.themeSpecificChatWallpapers[effectiveTheme.index] ?? theme.chat.defaultWallpaper
let dateTimeFormat = currentDateTimeFormat()
@ -387,7 +387,7 @@ public func serviceColor(for wallpaper: (TelegramWallpaper, UIImage?)) -> UIColo
return UIColor(rgb: 0x748391, alpha: 0.45)
case let .color(color):
return serviceColor(with: UIColor(rgb: UInt32(bitPattern: color)))
case let .gradient(topColor, bottomColor):
case let .gradient(topColor, bottomColor, _):
let mixedColor = UIColor(rgb: UInt32(bitPattern: topColor)).mixedWith(UIColor(rgb: UInt32(bitPattern: bottomColor)), alpha: 0.5)
return serviceColor(with: mixedColor)
case .image:
@ -432,7 +432,7 @@ public func chatServiceBackgroundColor(wallpaper: TelegramWallpaper, mediaBox: M
return .single(UIColor(rgb: 0x748391, alpha: 0.45))
case let .color(color):
return .single(serviceColor(with: UIColor(rgb: UInt32(bitPattern: color))))
case let .gradient(topColor, bottomColor):
case let .gradient(topColor, bottomColor, _):
let mixedColor = UIColor(rgb: UInt32(bitPattern: topColor)).mixedWith(UIColor(rgb: UInt32(bitPattern: bottomColor)), alpha: 0.5)
return .single(serviceColor(with: mixedColor))
case let .image(representations, _):
@ -497,7 +497,7 @@ public func updatedPresentationData(accountManager: AccountManager, applicationI
if let themeSpecificWallpaper = themeSettings.themeSpecificChatWallpapers[themeSettings.theme.index] {
currentWallpaper = themeSpecificWallpaper
} else {
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: themeSettings.theme, accentColor: nil, bubbleColors: nil, serviceBackgroundColor: defaultServiceBackgroundColor) ?? defaultPresentationTheme
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: themeSettings.theme, accentColor: nil, bubbleColors: nil) ?? defaultPresentationTheme
currentWallpaper = theme.chat.defaultWallpaper
}
@ -524,7 +524,7 @@ public func updatedPresentationData(accountManager: AccountManager, applicationI
}
let effectiveAccentColor = themeSettings.themeSpecificAccentColors[effectiveTheme.index]?.color
let effectiveBubbleColors = themeSettings.themeSpecificBubbleColors[effectiveTheme.index]?.colors
let effectiveBubbleColors = themeSettings.themeSpecificAccentColors[effectiveTheme.index]?.customBubbleColors
let themeValue = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveAccentColor, bubbleColors: effectiveBubbleColors, serviceBackgroundColor: serviceBackgroundColor) ?? defaultPresentationTheme

View file

@ -17,6 +17,10 @@ public final class PresentationThemeGradientColors {
public var colors: (UIColor, UIColor) {
return (self.topColor, self.bottomColor)
}
public func withUpdated(topColor: UIColor? = nil, bottomColor: UIColor? = nil) -> PresentationThemeGradientColors {
return PresentationThemeGradientColors(topColor: topColor ?? self.topColor, bottomColor: bottomColor ?? self.bottomColor)
}
}
public final class PresentationThemeIntro {
@ -35,6 +39,10 @@ public final class PresentationThemeIntro {
self.startButtonColor = startButtonColor
self.dotColor = dotColor
}
public func withUpdated(statusBarStyle: PresentationThemeStatusBarStyle? = nil, primaryTextColor: UIColor? = nil, accentTextColor: UIColor? = nil, disabledTextColor: UIColor? = nil, startButtonColor: UIColor? = nil, dotColor: UIColor? = nil) -> PresentationThemeIntro {
return PresentationThemeIntro(statusBarStyle: statusBarStyle ?? self.statusBarStyle, primaryTextColor: primaryTextColor ?? self.primaryTextColor, accentTextColor: accentTextColor ?? self.accentTextColor, disabledTextColor: disabledTextColor ?? self.disabledTextColor, startButtonColor: startButtonColor ?? self.startButtonColor, dotColor: dotColor ?? self.dotColor)
}
}
public final class PresentationThemePasscode {
@ -45,6 +53,10 @@ public final class PresentationThemePasscode {
self.backgroundColors = backgroundColors
self.buttonColor = buttonColor
}
public func withUpdated(backgroundColors: PresentationThemeGradientColors? = nil, buttonColor: UIColor? = nil) -> PresentationThemePasscode {
return PresentationThemePasscode(backgroundColors: backgroundColors ?? self.backgroundColors, buttonColor: buttonColor ?? self.buttonColor)
}
}
public final class PresentationThemeRootTabBar {
@ -69,6 +81,10 @@ public final class PresentationThemeRootTabBar {
self.badgeStrokeColor = badgeStrokeColor
self.badgeTextColor = badgeTextColor
}
public func withUpdated(backgroundColor: UIColor? = nil, separatorColor: UIColor? = nil, iconColor: UIColor? = nil, selectedIconColor: UIColor? = nil, textColor: UIColor? = nil, selectedTextColor: UIColor? = nil, badgeBackgroundColor: UIColor? = nil, badgeStrokeColor: UIColor? = nil, badgeTextColor: UIColor? = nil) -> PresentationThemeRootTabBar {
return PresentationThemeRootTabBar(backgroundColor: backgroundColor ?? self.backgroundColor, separatorColor: separatorColor ?? self.separatorColor, iconColor: iconColor ?? self.iconColor, selectedIconColor: selectedIconColor ?? self.selectedIconColor, textColor: textColor ?? self.textColor, selectedTextColor: selectedTextColor ?? self.selectedTextColor, badgeBackgroundColor: badgeBackgroundColor ?? self.badgeBackgroundColor, badgeStrokeColor: badgeStrokeColor ?? self.badgeStrokeColor, badgeTextColor: badgeTextColor ?? self.badgeTextColor)
}
}
public enum PresentationThemeStatusBarStyle: Int32 {
@ -128,6 +144,10 @@ public final class PresentationThemeRootNavigationBar {
self.segmentedTextColor = segmentedTextColor
self.segmentedDividerColor = segmentedDividerColor
}
public func withUpdated(buttonColor: UIColor? = nil, disabledButtonColor: UIColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, controlColor: UIColor? = nil, accentTextColor: UIColor? = nil, backgroundColor: UIColor? = nil, separatorColor: UIColor? = nil, badgeBackgroundColor: UIColor? = nil, badgeStrokeColor: UIColor? = nil, badgeTextColor: UIColor? = nil, segmentedBackgroundColor: UIColor? = nil, segmentedForegroundColor: UIColor? = nil, segmentedTextColor: UIColor? = nil, segmentedDividerColor: UIColor? = nil) -> PresentationThemeRootNavigationBar {
return PresentationThemeRootNavigationBar(buttonColor: buttonColor ?? self.buttonColor, disabledButtonColor: disabledButtonColor ?? self.disabledButtonColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, controlColor: controlColor ?? self.controlColor, accentTextColor: accentTextColor ?? self.accentTextColor, backgroundColor: backgroundColor ?? self.backgroundColor, separatorColor: separatorColor ?? self.separatorColor, badgeBackgroundColor: badgeBackgroundColor ?? self.badgeBackgroundColor, badgeStrokeColor: badgeStrokeColor ?? self.badgeStrokeColor, badgeTextColor: badgeTextColor ?? self.badgeTextColor, segmentedBackgroundColor: segmentedBackgroundColor ?? self.segmentedBackgroundColor, segmentedForegroundColor: segmentedForegroundColor ?? self.segmentedForegroundColor, segmentedTextColor: segmentedTextColor ?? self.segmentedTextColor, segmentedDividerColor: segmentedDividerColor ?? self.segmentedDividerColor)
}
}
public final class PresentationThemeNavigationSearchBar {
@ -150,6 +170,10 @@ public final class PresentationThemeNavigationSearchBar {
self.inputClearButtonColor = inputClearButtonColor
self.separatorColor = separatorColor
}
public func withUpdated(backgroundColor: UIColor? = nil, accentColor: UIColor? = nil, inputFillColor: UIColor? = nil, inputTextColor: UIColor? = nil, inputPlaceholderTextColor: UIColor? = nil, inputIconColor: UIColor? = nil, inputClearButtonColor: UIColor? = nil, separatorColor: UIColor? = nil) -> PresentationThemeNavigationSearchBar {
return PresentationThemeNavigationSearchBar(backgroundColor: backgroundColor ?? self.backgroundColor, accentColor: accentColor ?? self.accentColor, inputFillColor: inputFillColor ?? self.inputFillColor, inputTextColor: inputTextColor ?? self.inputTextColor, inputPlaceholderTextColor: inputPlaceholderTextColor ?? self.inputPlaceholderTextColor, inputIconColor: inputIconColor ?? self.inputIconColor, inputClearButtonColor: inputClearButtonColor ?? self.inputClearButtonColor, separatorColor: separatorColor ?? self.separatorColor)
}
}
public final class PresentationThemeRootController {
@ -166,6 +190,10 @@ public final class PresentationThemeRootController {
self.navigationSearchBar = navigationSearchBar
self.keyboardColor = keyboardColor
}
public func withUpdated(statusBarStyle: PresentationThemeStatusBarStyle? = nil, tabBar: PresentationThemeRootTabBar? = nil, navigationBar: PresentationThemeRootNavigationBar? = nil, navigationSearchBar: PresentationThemeNavigationSearchBar? = nil, keyboardColor: PresentationThemeKeyboardColor? = nil) -> PresentationThemeRootController {
return PresentationThemeRootController(statusBarStyle: statusBarStyle ?? self.statusBarStyle, tabBar: tabBar ?? self.tabBar, navigationBar: navigationBar ?? self.navigationBar, navigationSearchBar: navigationSearchBar ?? self.navigationSearchBar, keyboardColor: keyboardColor ?? self.keyboardColor)
}
}
public enum PresentationThemeActionSheetBackgroundType: Int32 {
@ -217,6 +245,10 @@ public final class PresentationThemeActionSheet {
self.inputClearButtonColor = inputClearButtonColor
self.checkContentColor = checkContentColor
}
public func withUpdated(dimColor: UIColor? = nil, backgroundType: PresentationThemeActionSheetBackgroundType? = nil, opaqueItemBackgroundColor: UIColor? = nil, itemBackgroundColor: UIColor? = nil, opaqueItemHighlightedBackgroundColor: UIColor? = nil, itemHighlightedBackgroundColor: UIColor? = nil, opaqueItemSeparatorColor: UIColor? = nil, standardActionTextColor: UIColor? = nil, destructiveActionTextColor: UIColor? = nil, disabledActionTextColor: UIColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, controlAccentColor: UIColor? = nil, inputBackgroundColor: UIColor? = nil, inputHollowBackgroundColor: UIColor? = nil, inputBorderColor: UIColor? = nil, inputPlaceholderColor: UIColor? = nil, inputTextColor: UIColor? = nil, inputClearButtonColor: UIColor? = nil, checkContentColor: UIColor? = nil) -> PresentationThemeActionSheet {
return PresentationThemeActionSheet(dimColor: dimColor ?? self.dimColor, backgroundType: backgroundType ?? self.backgroundType, opaqueItemBackgroundColor: opaqueItemBackgroundColor ?? self.opaqueItemBackgroundColor, itemBackgroundColor: itemBackgroundColor ?? self.itemBackgroundColor, opaqueItemHighlightedBackgroundColor: opaqueItemHighlightedBackgroundColor ?? self.opaqueItemHighlightedBackgroundColor, itemHighlightedBackgroundColor: itemHighlightedBackgroundColor ?? self.itemHighlightedBackgroundColor, opaqueItemSeparatorColor: opaqueItemSeparatorColor ?? self.opaqueItemSeparatorColor, standardActionTextColor: standardActionTextColor ?? self.standardActionTextColor, destructiveActionTextColor: destructiveActionTextColor ?? self.destructiveActionTextColor, disabledActionTextColor: disabledActionTextColor ?? self.disabledActionTextColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, controlAccentColor: controlAccentColor ?? self.controlAccentColor, inputBackgroundColor: inputBackgroundColor ?? self.inputBackgroundColor, inputHollowBackgroundColor: inputHollowBackgroundColor ?? self.inputHollowBackgroundColor, inputBorderColor: inputBorderColor ?? self.inputBorderColor, inputPlaceholderColor: inputPlaceholderColor ?? self.inputPlaceholderColor, inputTextColor: inputTextColor ?? self.inputTextColor, inputClearButtonColor: inputClearButtonColor ?? self.inputClearButtonColor, checkContentColor: checkContentColor ?? self.checkContentColor)
}
}
public final class PresentationThemeContextMenu {
@ -241,6 +273,10 @@ public final class PresentationThemeContextMenu {
self.secondaryColor = secondaryColor
self.destructiveColor = destructiveColor
}
public func withUpdated(dimColor: UIColor? = nil, backgroundColor: UIColor? = nil, itemSeparatorColor: UIColor? = nil, sectionSeparatorColor: UIColor? = nil, itemBackgroundColor: UIColor? = nil, itemHighlightedBackgroundColor: UIColor? = nil, primaryColor: UIColor? = nil, secondaryColor: UIColor? = nil, destructiveColor: UIColor? = nil) -> PresentationThemeContextMenu {
return PresentationThemeContextMenu(dimColor: dimColor ?? self.dimColor, backgroundColor: backgroundColor ?? self.backgroundColor, itemSeparatorColor: itemSeparatorColor ?? self.itemSeparatorColor, sectionSeparatorColor: sectionSeparatorColor ?? self.sectionSeparatorColor, itemBackgroundColor: itemBackgroundColor ?? self.itemBackgroundColor, itemHighlightedBackgroundColor: itemHighlightedBackgroundColor ?? self.itemHighlightedBackgroundColor, primaryColor: primaryColor ?? self.primaryColor, secondaryColor: secondaryColor ?? self.secondaryColor, destructiveColor: destructiveColor ?? self.destructiveColor)
}
}
public final class PresentationThemeSwitch {
@ -257,6 +293,10 @@ public final class PresentationThemeSwitch {
self.positiveColor = positiveColor
self.negativeColor = negativeColor
}
public func withUpdated(frameColor: UIColor? = nil, handleColor: UIColor? = nil, contentColor: UIColor? = nil, positiveColor: UIColor? = nil, negativeColor: UIColor? = nil) -> PresentationThemeSwitch {
return PresentationThemeSwitch(frameColor: frameColor ?? self.frameColor, handleColor: handleColor ?? self.handleColor, contentColor: contentColor ?? self.contentColor, positiveColor: positiveColor ?? self.positiveColor, negativeColor: negativeColor ?? self.negativeColor)
}
}
public final class PresentationThemeFillForeground {
@ -267,6 +307,10 @@ public final class PresentationThemeFillForeground {
self.fillColor = fillColor
self.foregroundColor = foregroundColor
}
public func withUpdated(fillColor: UIColor? = nil, foregroundColor: UIColor? = nil) -> PresentationThemeFillForeground {
return PresentationThemeFillForeground(fillColor: fillColor ?? self.fillColor, foregroundColor: foregroundColor ?? self.foregroundColor)
}
}
public final class PresentationThemeItemDisclosureActions {
@ -287,6 +331,10 @@ public final class PresentationThemeItemDisclosureActions {
self.warning = warning
self.inactive = inactive
}
public func withUpdated(neutral1: PresentationThemeFillForeground? = nil, neutral2: PresentationThemeFillForeground? = nil, destructive: PresentationThemeFillForeground? = nil, constructive: PresentationThemeFillForeground? = nil, accent: PresentationThemeFillForeground? = nil, warning: PresentationThemeFillForeground? = nil, inactive: PresentationThemeFillForeground? = nil) -> PresentationThemeItemDisclosureActions {
return PresentationThemeItemDisclosureActions(neutral1: neutral1 ?? self.neutral1, neutral2: neutral2 ?? self.neutral2, destructive: destructive ?? self.destructive, constructive: constructive ?? self.constructive, accent: accent ?? self.accent, warning: warning ?? self.warning, inactive: inactive ?? self.inactive)
}
}
public final class PresentationThemeItemBarChart {
@ -299,6 +347,10 @@ public final class PresentationThemeItemBarChart {
self.color2 = color2
self.color3 = color3
}
public func withUpdated(color1: UIColor? = nil, color2: UIColor? = nil, color3: UIColor? = nil) -> PresentationThemeItemBarChart {
return PresentationThemeItemBarChart(color1: color1 ?? self.color1, color2: color2 ?? self.color2, color3: color3 ?? self.color3)
}
}
public final class PresentationThemeFillStrokeForeground {
@ -311,6 +363,10 @@ public final class PresentationThemeFillStrokeForeground {
self.strokeColor = strokeColor
self.foregroundColor = foregroundColor
}
public func withUpdated(fillColor: UIColor? = nil, strokeColor: UIColor? = nil, foregroundColor: UIColor? = nil) -> PresentationThemeFillStrokeForeground {
return PresentationThemeFillStrokeForeground(fillColor: fillColor ?? self.fillColor, strokeColor: strokeColor ?? self.strokeColor, foregroundColor: foregroundColor ?? self.foregroundColor)
}
}
public final class PresentationInputFieldTheme {
@ -327,6 +383,10 @@ public final class PresentationInputFieldTheme {
self.primaryColor = primaryColor
self.controlColor = controlColor
}
public func withUpdated(backgroundColor: UIColor? = nil, strokeColor: UIColor? = nil, placeholderColor: UIColor? = nil, primaryColor: UIColor? = nil, controlColor: UIColor? = nil) -> PresentationInputFieldTheme {
return PresentationInputFieldTheme(backgroundColor: backgroundColor ?? self.backgroundColor, strokeColor: strokeColor ?? self.strokeColor, placeholderColor: placeholderColor ?? self.placeholderColor, primaryColor: primaryColor ?? self.primaryColor, controlColor: controlColor ?? self.controlColor)
}
}
public final class PresentationThemeList {
@ -393,6 +453,10 @@ public final class PresentationThemeList {
self.inputClearButtonColor = inputClearButtonColor
self.itemBarChart = itemBarChart
}
public func withUpdated(blocksBackgroundColor: UIColor? = nil, plainBackgroundColor: UIColor? = nil, itemPrimaryTextColor: UIColor? = nil, itemSecondaryTextColor: UIColor? = nil, itemDisabledTextColor: UIColor? = nil, itemAccentColor: UIColor? = nil, itemHighlightedColor: UIColor? = nil, itemDestructiveColor: UIColor? = nil, itemPlaceholderTextColor: UIColor? = nil, itemBlocksBackgroundColor: UIColor? = nil, itemHighlightedBackgroundColor: UIColor? = nil, itemBlocksSeparatorColor: UIColor? = nil, itemPlainSeparatorColor: UIColor? = nil, disclosureArrowColor: UIColor? = nil, sectionHeaderTextColor: UIColor? = nil, freeTextColor: UIColor? = nil, freeTextErrorColor: UIColor? = nil, freeTextSuccessColor: UIColor? = nil, freeMonoIconColor: UIColor? = nil, itemSwitchColors: PresentationThemeSwitch? = nil, itemDisclosureActions: PresentationThemeItemDisclosureActions? = nil, itemCheckColors: PresentationThemeFillStrokeForeground? = nil, controlSecondaryColor: UIColor? = nil, freeInputField: PresentationInputFieldTheme? = nil, freePlainInputField: PresentationInputFieldTheme? = nil, mediaPlaceholderColor: UIColor? = nil, scrollIndicatorColor: UIColor? = nil, pageIndicatorInactiveColor: UIColor? = nil, inputClearButtonColor: UIColor? = nil, itemBarChart: PresentationThemeItemBarChart? = nil) -> PresentationThemeList {
return PresentationThemeList(blocksBackgroundColor: blocksBackgroundColor ?? self.blocksBackgroundColor, plainBackgroundColor: plainBackgroundColor ?? self.plainBackgroundColor, itemPrimaryTextColor: itemPrimaryTextColor ?? self.itemPrimaryTextColor, itemSecondaryTextColor: itemSecondaryTextColor ?? self.itemSecondaryTextColor, itemDisabledTextColor: itemDisabledTextColor ?? self.itemDisabledTextColor, itemAccentColor: itemAccentColor ?? self.itemAccentColor, itemHighlightedColor: itemHighlightedColor ?? self.itemHighlightedColor, itemDestructiveColor: itemDestructiveColor ?? self.itemDestructiveColor, itemPlaceholderTextColor: itemPlaceholderTextColor ?? self.itemPlaceholderTextColor, itemBlocksBackgroundColor: itemBlocksBackgroundColor ?? self.itemBlocksBackgroundColor, itemHighlightedBackgroundColor: itemHighlightedBackgroundColor ?? self.itemHighlightedBackgroundColor, itemBlocksSeparatorColor: itemBlocksSeparatorColor ?? self.itemBlocksSeparatorColor, itemPlainSeparatorColor: itemPlainSeparatorColor ?? self.itemPlainSeparatorColor, disclosureArrowColor: disclosureArrowColor ?? self.disclosureArrowColor, sectionHeaderTextColor: sectionHeaderTextColor ?? self.sectionHeaderTextColor, freeTextColor: freeTextColor ?? self.freeTextColor, freeTextErrorColor: freeTextErrorColor ?? self.freeTextErrorColor, freeTextSuccessColor: freeTextSuccessColor ?? self.freeTextSuccessColor, freeMonoIconColor: freeMonoIconColor ?? self.freeMonoIconColor, itemSwitchColors: itemSwitchColors ?? self.itemSwitchColors, itemDisclosureActions: itemDisclosureActions ?? self.itemDisclosureActions, itemCheckColors: itemCheckColors ?? self.itemCheckColors, controlSecondaryColor: controlSecondaryColor ?? self.controlSecondaryColor, freeInputField: freeInputField ?? self.freeInputField, freePlainInputField: freePlainInputField ?? self.freePlainInputField, mediaPlaceholderColor: mediaPlaceholderColor ?? self.mediaPlaceholderColor, scrollIndicatorColor: scrollIndicatorColor ?? self.scrollIndicatorColor, pageIndicatorInactiveColor: pageIndicatorInactiveColor ?? self.pageIndicatorInactiveColor, inputClearButtonColor: inputClearButtonColor ?? self.inputClearButtonColor, itemBarChart: itemBarChart ?? self.itemBarChart)
}
}
public final class PresentationThemeArchiveAvatarColors {
@ -403,6 +467,10 @@ public final class PresentationThemeArchiveAvatarColors {
self.backgroundColors = backgroundColors
self.foregroundColor = foregroundColor
}
public func withUpdated(backgroundColors: PresentationThemeGradientColors? = nil, foregroundColor: UIColor? = nil) -> PresentationThemeArchiveAvatarColors {
return PresentationThemeArchiveAvatarColors(backgroundColors: backgroundColors ?? self.backgroundColors, foregroundColor: foregroundColor ?? self.foregroundColor)
}
}
public final class PresentationThemeChatList {
@ -475,6 +543,10 @@ public final class PresentationThemeChatList {
self.unpinnedArchiveAvatarColor = unpinnedArchiveAvatarColor
self.onlineDotColor = onlineDotColor
}
public func withUpdated(backgroundColor: UIColor? = nil, itemSeparatorColor: UIColor? = nil, itemBackgroundColor: UIColor? = nil, pinnedItemBackgroundColor: UIColor? = nil, itemHighlightedBackgroundColor: UIColor? = nil, itemSelectedBackgroundColor: UIColor? = nil, titleColor: UIColor? = nil, secretTitleColor: UIColor? = nil, dateTextColor: UIColor? = nil, authorNameColor: UIColor? = nil, messageTextColor: UIColor? = nil, messageHighlightedTextColor: UIColor? = nil, messageDraftTextColor: UIColor? = nil, checkmarkColor: UIColor? = nil, pendingIndicatorColor: UIColor? = nil, failedFillColor: UIColor? = nil, failedForegroundColor: UIColor? = nil, muteIconColor: UIColor? = nil, unreadBadgeActiveBackgroundColor: UIColor? = nil, unreadBadgeActiveTextColor: UIColor? = nil, unreadBadgeInactiveBackgroundColor: UIColor? = nil, unreadBadgeInactiveTextColor: UIColor? = nil, pinnedBadgeColor: UIColor? = nil, pinnedSearchBarColor: UIColor? = nil, regularSearchBarColor: UIColor? = nil, sectionHeaderFillColor: UIColor? = nil, sectionHeaderTextColor: UIColor? = nil, verifiedIconFillColor: UIColor? = nil, verifiedIconForegroundColor: UIColor? = nil, secretIconColor: UIColor? = nil, pinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors? = nil, unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors? = nil, onlineDotColor: UIColor? = nil) -> PresentationThemeChatList {
return PresentationThemeChatList(backgroundColor: backgroundColor ?? self.backgroundColor, itemSeparatorColor: itemSeparatorColor ?? self.itemSeparatorColor, itemBackgroundColor: itemBackgroundColor ?? self.itemBackgroundColor, pinnedItemBackgroundColor: pinnedItemBackgroundColor ?? self.pinnedItemBackgroundColor, itemHighlightedBackgroundColor: itemHighlightedBackgroundColor ?? self.itemHighlightedBackgroundColor, itemSelectedBackgroundColor: itemSelectedBackgroundColor ?? self.itemSelectedBackgroundColor, titleColor: titleColor ?? self.titleColor, secretTitleColor: secretTitleColor ?? self.secretTitleColor, dateTextColor: dateTextColor ?? self.dateTextColor, authorNameColor: authorNameColor ?? self.authorNameColor, messageTextColor: messageTextColor ?? self.messageTextColor, messageHighlightedTextColor: messageHighlightedTextColor ?? self.messageHighlightedTextColor, messageDraftTextColor: messageDraftTextColor ?? self.messageDraftTextColor, checkmarkColor: checkmarkColor ?? self.checkmarkColor, pendingIndicatorColor: pendingIndicatorColor ?? self.pendingIndicatorColor, failedFillColor: failedFillColor ?? self.failedFillColor, failedForegroundColor: failedForegroundColor ?? self.failedForegroundColor, muteIconColor: muteIconColor ?? self.muteIconColor, unreadBadgeActiveBackgroundColor: unreadBadgeActiveBackgroundColor ?? self.unreadBadgeActiveBackgroundColor, unreadBadgeActiveTextColor: unreadBadgeActiveTextColor ?? self.unreadBadgeActiveTextColor, unreadBadgeInactiveBackgroundColor: unreadBadgeInactiveBackgroundColor ?? self.unreadBadgeInactiveBackgroundColor, unreadBadgeInactiveTextColor: unreadBadgeInactiveTextColor ?? self.unreadBadgeInactiveTextColor, pinnedBadgeColor: pinnedBadgeColor ?? self.pinnedBadgeColor, pinnedSearchBarColor: pinnedSearchBarColor ?? self.pinnedSearchBarColor, regularSearchBarColor: regularSearchBarColor ?? self.regularSearchBarColor, sectionHeaderFillColor: sectionHeaderFillColor ?? self.sectionHeaderFillColor, sectionHeaderTextColor: sectionHeaderTextColor ?? self.sectionHeaderTextColor, verifiedIconFillColor: verifiedIconFillColor ?? self.verifiedIconFillColor, verifiedIconForegroundColor: verifiedIconForegroundColor ?? self.verifiedIconForegroundColor, secretIconColor: secretIconColor ?? self.secretIconColor, pinnedArchiveAvatarColor: pinnedArchiveAvatarColor ?? self.pinnedArchiveAvatarColor, unpinnedArchiveAvatarColor: unpinnedArchiveAvatarColor ?? self.unpinnedArchiveAvatarColor, onlineDotColor: onlineDotColor ?? self.onlineDotColor)
}
}
public final class PresentationThemeBubbleColorComponents {
@ -489,6 +561,10 @@ public final class PresentationThemeBubbleColorComponents {
self.highlightedFill = highlightedFill
self.stroke = stroke
}
public func withUpdated(fill: UIColor? = nil, gradientFill: UIColor? = nil, highlightedFill: UIColor? = nil, stroke: UIColor? = nil) -> PresentationThemeBubbleColorComponents {
return PresentationThemeBubbleColorComponents(fill: fill ?? self.fill, gradientFill: gradientFill ?? self.gradientFill, highlightedFill: highlightedFill ?? self.highlightedFill, stroke: stroke ?? self.stroke)
}
}
public final class PresentationThemeBubbleColor {
@ -499,6 +575,10 @@ public final class PresentationThemeBubbleColor {
self.withWallpaper = withWallpaper
self.withoutWallpaper = withoutWallpaper
}
public func withUpdated(withWallpaper: PresentationThemeBubbleColorComponents? = nil, withoutWallpaper: PresentationThemeBubbleColorComponents? = nil) -> PresentationThemeBubbleColor {
return PresentationThemeBubbleColor(withWallpaper: withWallpaper ?? self.withWallpaper, withoutWallpaper: withoutWallpaper ?? self.withoutWallpaper)
}
}
public final class PresentationThemeVariableColor {
@ -514,6 +594,10 @@ public final class PresentationThemeVariableColor {
self.withWallpaper = color
self.withoutWallpaper = color
}
public func withUpdated(withWallpaper: UIColor? = nil, withoutWallpaper: UIColor? = nil) -> PresentationThemeVariableColor {
return PresentationThemeVariableColor(withWallpaper: withWallpaper ?? self.withWallpaper, withoutWallpaper: withoutWallpaper ?? self.withoutWallpaper)
}
}
public func bubbleColorComponents(theme: PresentationTheme, incoming: Bool, wallpaper: Bool) -> PresentationThemeBubbleColorComponents {
@ -555,6 +639,10 @@ public final class PresentationThemeChatBubblePolls {
self.separator = separator
self.bar = bar
}
public func withUpdated(radioButton: UIColor? = nil, radioProgress: UIColor? = nil, highlight: UIColor? = nil, separator: UIColor? = nil, bar: UIColor? = nil) -> PresentationThemeChatBubblePolls {
return PresentationThemeChatBubblePolls(radioButton: radioButton ?? self.radioButton, radioProgress: radioProgress ?? self.radioProgress, highlight: highlight ?? self.highlight, separator: separator ?? self.separator, bar: bar ?? self.bar)
}
}
public final class PresentationThemePartedColors {
@ -607,52 +695,50 @@ public final class PresentationThemePartedColors {
self.textSelectionColor = textSelectionColor
self.textSelectionKnobColor = textSelectionKnobColor
}
public func withUpdated(bubble: PresentationThemeBubbleColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, linkTextColor: UIColor? = nil, linkHighlightColor: UIColor? = nil, scamColor: UIColor? = nil, textHighlightColor: UIColor? = nil, accentTextColor: UIColor? = nil, accentControlColor: UIColor? = nil, mediaActiveControlColor: UIColor? = nil, mediaInactiveControlColor: UIColor? = nil, mediaControlInnerBackgroundColor: UIColor? = nil, pendingActivityColor: UIColor? = nil, fileTitleColor: UIColor? = nil, fileDescriptionColor: UIColor? = nil, fileDurationColor: UIColor? = nil, mediaPlaceholderColor: UIColor? = nil, polls: PresentationThemeChatBubblePolls? = nil, actionButtonsFillColor: PresentationThemeVariableColor? = nil, actionButtonsStrokeColor: PresentationThemeVariableColor? = nil, actionButtonsTextColor: PresentationThemeVariableColor? = nil, textSelectionColor: UIColor? = nil, textSelectionKnobColor: UIColor? = nil) -> PresentationThemePartedColors {
return PresentationThemePartedColors(bubble: bubble ?? self.bubble, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, linkTextColor: linkTextColor ?? self.linkTextColor, linkHighlightColor: linkHighlightColor ?? self.linkHighlightColor, scamColor: scamColor ?? self.scamColor, textHighlightColor: textHighlightColor ?? self.textHighlightColor, accentTextColor: accentTextColor ?? self.accentTextColor, accentControlColor: accentControlColor ?? self.accentControlColor, mediaActiveControlColor: mediaActiveControlColor ?? self.mediaActiveControlColor, mediaInactiveControlColor: mediaInactiveControlColor ?? self.mediaInactiveControlColor, mediaControlInnerBackgroundColor: mediaControlInnerBackgroundColor ?? self.mediaControlInnerBackgroundColor, pendingActivityColor: pendingActivityColor ?? self.pendingActivityColor, fileTitleColor: fileTitleColor ?? self.fileTitleColor, fileDescriptionColor: fileDescriptionColor ?? self.fileDescriptionColor, fileDurationColor: fileDurationColor ?? self.fileDurationColor, mediaPlaceholderColor: mediaPlaceholderColor ?? self.mediaPlaceholderColor, polls: polls ?? self.polls, actionButtonsFillColor: actionButtonsFillColor ?? self.actionButtonsFillColor, actionButtonsStrokeColor: actionButtonsStrokeColor ?? self.actionButtonsStrokeColor, actionButtonsTextColor: actionButtonsTextColor ?? self.actionButtonsTextColor, textSelectionColor: textSelectionColor ?? self.textSelectionColor, textSelectionKnobColor: textSelectionKnobColor ?? self.textSelectionKnobColor)
}
}
public final class PresentationThemeChatMessage {
public let incoming: PresentationThemePartedColors
public let outgoing: PresentationThemePartedColors
public let freeform: PresentationThemeBubbleColor
public let infoPrimaryTextColor: UIColor
public let infoLinkTextColor: UIColor
public let outgoingCheckColor: UIColor
public let mediaDateAndStatusFillColor: UIColor
public let mediaDateAndStatusTextColor: UIColor
public let shareButtonFillColor: PresentationThemeVariableColor
public let shareButtonStrokeColor: PresentationThemeVariableColor
public let shareButtonForegroundColor: PresentationThemeVariableColor
public let mediaOverlayControlColors: PresentationThemeFillForeground
public let selectionControlColors: PresentationThemeFillStrokeForeground
public let deliveryFailedColors: PresentationThemeFillForeground
public let mediaHighlightOverlayColor: UIColor
public init(incoming: PresentationThemePartedColors, outgoing: PresentationThemePartedColors, freeform: PresentationThemeBubbleColor, infoPrimaryTextColor: UIColor, infoLinkTextColor: UIColor, outgoingCheckColor: UIColor, mediaDateAndStatusFillColor: UIColor, mediaDateAndStatusTextColor: UIColor, shareButtonFillColor: PresentationThemeVariableColor, shareButtonStrokeColor: PresentationThemeVariableColor, shareButtonForegroundColor: PresentationThemeVariableColor, mediaOverlayControlColors: PresentationThemeFillForeground, selectionControlColors: PresentationThemeFillStrokeForeground, deliveryFailedColors: PresentationThemeFillForeground, mediaHighlightOverlayColor: UIColor) {
self.incoming = incoming
self.outgoing = outgoing
self.freeform = freeform
self.infoPrimaryTextColor = infoPrimaryTextColor
self.infoLinkTextColor = infoLinkTextColor
self.outgoingCheckColor = outgoingCheckColor
self.mediaDateAndStatusFillColor = mediaDateAndStatusFillColor
self.mediaDateAndStatusTextColor = mediaDateAndStatusTextColor
self.shareButtonFillColor = shareButtonFillColor
self.shareButtonStrokeColor = shareButtonStrokeColor
self.shareButtonForegroundColor = shareButtonForegroundColor
self.mediaOverlayControlColors = mediaOverlayControlColors
self.selectionControlColors = selectionControlColors
self.deliveryFailedColors = deliveryFailedColors
self.mediaHighlightOverlayColor = mediaHighlightOverlayColor
}
public func withUpdated(incoming: PresentationThemePartedColors? = nil, outgoing: PresentationThemePartedColors? = nil, freeform: PresentationThemeBubbleColor? = nil, infoPrimaryTextColor: UIColor? = nil, infoLinkTextColor: UIColor? = nil, outgoingCheckColor: UIColor? = nil, mediaDateAndStatusFillColor: UIColor? = nil, mediaDateAndStatusTextColor: UIColor? = nil, shareButtonFillColor: PresentationThemeVariableColor? = nil, shareButtonStrokeColor: PresentationThemeVariableColor? = nil, shareButtonForegroundColor: PresentationThemeVariableColor? = nil, mediaOverlayControlColors: PresentationThemeFillForeground? = nil, selectionControlColors: PresentationThemeFillStrokeForeground? = nil, deliveryFailedColors: PresentationThemeFillForeground? = nil, mediaHighlightOverlayColor: UIColor? = nil) -> PresentationThemeChatMessage {
return PresentationThemeChatMessage(incoming: incoming ?? self.incoming, outgoing: outgoing ?? self.outgoing, freeform: freeform ?? self.freeform, infoPrimaryTextColor: infoPrimaryTextColor ?? self.infoPrimaryTextColor, infoLinkTextColor: infoLinkTextColor ?? self.infoLinkTextColor, outgoingCheckColor: outgoingCheckColor ?? self.outgoingCheckColor, mediaDateAndStatusFillColor: mediaDateAndStatusFillColor ?? self.mediaDateAndStatusFillColor, mediaDateAndStatusTextColor: mediaDateAndStatusTextColor ?? self.mediaDateAndStatusTextColor, shareButtonFillColor: shareButtonFillColor ?? self.shareButtonFillColor, shareButtonStrokeColor: shareButtonStrokeColor ?? self.shareButtonStrokeColor, shareButtonForegroundColor: shareButtonForegroundColor ?? self.shareButtonForegroundColor, mediaOverlayControlColors: mediaOverlayControlColors ?? self.mediaOverlayControlColors, selectionControlColors: selectionControlColors ?? self.selectionControlColors, deliveryFailedColors: deliveryFailedColors ?? self.deliveryFailedColors, mediaHighlightOverlayColor: mediaHighlightOverlayColor ?? self.mediaHighlightOverlayColor)
}
}
public final class PresentationThemeServiceMessageColorComponents {
@ -672,6 +758,10 @@ public final class PresentationThemeServiceMessageColorComponents {
self.dateFillStatic = dateFillStatic
self.dateFillFloating = dateFillFloating
}
public func withUpdated(fill: UIColor? = nil, primaryText: UIColor? = nil, linkHighlight: UIColor? = nil, scam: UIColor? = nil, dateFillStatic: UIColor? = nil, dateFillFloating: UIColor? = nil) -> PresentationThemeServiceMessageColorComponents {
return PresentationThemeServiceMessageColorComponents(fill: fill ?? self.fill, primaryText: primaryText ?? self.primaryText, linkHighlight: linkHighlight ?? self.linkHighlight, scam: scam ?? self.scam, dateFillStatic: dateFillStatic ?? self.dateFillStatic, dateFillFloating: dateFillFloating ?? self.dateFillFloating)
}
}
public func serviceMessageColorComponents(theme: PresentationTheme, wallpaper: TelegramWallpaper) -> PresentationThemeServiceMessageColorComponents {
@ -699,15 +789,17 @@ public final class PresentationThemeServiceMessageColor {
self.withDefaultWallpaper = withDefaultWallpaper
self.withCustomWallpaper = withCustomWallpaper
}
public func withUpdated(withDefaultWallpaper: PresentationThemeServiceMessageColorComponents? = nil, withCustomWallpaper: PresentationThemeServiceMessageColorComponents? = nil) -> PresentationThemeServiceMessageColor {
return PresentationThemeServiceMessageColor(withDefaultWallpaper: withDefaultWallpaper ?? self.withDefaultWallpaper, withCustomWallpaper: withCustomWallpaper ?? self.withCustomWallpaper)
}
}
public final class PresentationThemeServiceMessage {
public let components: PresentationThemeServiceMessageColor
public let unreadBarFillColor: UIColor
public let unreadBarStrokeColor: UIColor
public let unreadBarTextColor: UIColor
public let dateTextColor: PresentationThemeVariableColor
public init(components: PresentationThemeServiceMessageColor, unreadBarFillColor: UIColor, unreadBarStrokeColor: UIColor, unreadBarTextColor: UIColor, dateTextColor: PresentationThemeVariableColor) {
@ -717,6 +809,10 @@ public final class PresentationThemeServiceMessage {
self.unreadBarTextColor = unreadBarTextColor
self.dateTextColor = dateTextColor
}
public func withUpdated(components: PresentationThemeServiceMessageColor? = nil, unreadBarFillColor: UIColor? = nil, unreadBarStrokeColor: UIColor? = nil, unreadBarTextColor: UIColor? = nil, dateTextColor: PresentationThemeVariableColor? = nil) -> PresentationThemeServiceMessage {
return PresentationThemeServiceMessage(components: components ?? self.components, unreadBarFillColor: unreadBarFillColor ?? self.unreadBarFillColor, unreadBarStrokeColor: unreadBarStrokeColor ?? self.unreadBarStrokeColor, unreadBarTextColor: unreadBarTextColor ?? self.unreadBarTextColor, dateTextColor: dateTextColor ?? self.dateTextColor)
}
}
public enum PresentationThemeKeyboardColor: Int32 {
@ -743,6 +839,10 @@ public final class PresentationThemeChatInputPanelMediaRecordingControl {
self.micLevelColor = micLevelColor
self.activeIconColor = activeIconColor
}
public func withUpdated(buttonColor: UIColor? = nil, micLevelColor: UIColor? = nil, activeIconColor: UIColor? = nil) -> PresentationThemeChatInputPanelMediaRecordingControl {
return PresentationThemeChatInputPanelMediaRecordingControl(buttonColor: buttonColor ?? self.buttonColor, micLevelColor: micLevelColor ?? self.micLevelColor, activeIconColor: activeIconColor ?? self.activeIconColor)
}
}
public final class PresentationThemeChatInputPanel {
@ -783,6 +883,10 @@ public final class PresentationThemeChatInputPanel {
self.mediaRecordingDotColor = mediaRecordingDotColor
self.mediaRecordingControl = mediaRecordingControl
}
public func withUpdated(panelBackgroundColor: UIColor? = nil, panelSeparatorColor: UIColor? = nil, panelControlAccentColor: UIColor? = nil, panelControlColor: UIColor? = nil, panelControlDisabledColor: UIColor? = nil, panelControlDestructiveColor: UIColor? = nil, inputBackgroundColor: UIColor? = nil, inputStrokeColor: UIColor? = nil, inputPlaceholderColor: UIColor? = nil, inputTextColor: UIColor? = nil, inputControlColor: UIColor? = nil, actionControlFillColor: UIColor? = nil, actionControlForegroundColor: UIColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, mediaRecordingDotColor: UIColor? = nil, mediaRecordingControl: PresentationThemeChatInputPanelMediaRecordingControl? = nil) -> PresentationThemeChatInputPanel {
return PresentationThemeChatInputPanel(panelBackgroundColor: panelBackgroundColor ?? self.panelBackgroundColor, panelSeparatorColor: panelSeparatorColor ?? self.panelSeparatorColor, panelControlAccentColor: panelControlAccentColor ?? self.panelControlAccentColor, panelControlColor: panelControlColor ?? self.panelControlColor, panelControlDisabledColor: panelControlDisabledColor ?? self.panelControlDisabledColor, panelControlDestructiveColor: panelControlDestructiveColor ?? self.panelControlDestructiveColor, inputBackgroundColor: inputBackgroundColor ?? self.inputBackgroundColor, inputStrokeColor: inputStrokeColor ?? self.inputStrokeColor, inputPlaceholderColor: inputPlaceholderColor ?? self.inputPlaceholderColor, inputTextColor: inputTextColor ?? self.inputTextColor, inputControlColor: inputControlColor ?? self.inputControlColor, actionControlFillColor: actionControlFillColor ?? self.actionControlFillColor, actionControlForegroundColor: actionControlForegroundColor ?? self.actionControlForegroundColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, mediaRecordingDotColor: mediaRecordingDotColor ?? self.mediaRecordingDotColor, mediaRecordingControl: mediaRecordingControl ?? self.mediaRecordingControl)
}
}
public final class PresentationThemeInputMediaPanel {
@ -809,6 +913,10 @@ public final class PresentationThemeInputMediaPanel {
self.stickersSearchControlColor = stickersSearchControlColor
self.gifsBackgroundColor = gifsBackgroundColor
}
public func withUpdated(panelSeparatorColor: UIColor? = nil, panelIconColor: UIColor? = nil, panelHighlightedIconBackgroundColor: UIColor? = nil, stickersBackgroundColor: UIColor? = nil, stickersSectionTextColor: UIColor? = nil, stickersSearchBackgroundColor: UIColor? = nil, stickersSearchPlaceholderColor: UIColor? = nil, stickersSearchPrimaryColor: UIColor? = nil, stickersSearchControlColor: UIColor? = nil, gifsBackgroundColor: UIColor? = nil) -> PresentationThemeInputMediaPanel {
return PresentationThemeInputMediaPanel(panelSeparatorColor: panelSeparatorColor ?? self.panelSeparatorColor, panelIconColor: panelIconColor ?? self.panelIconColor, panelHighlightedIconBackgroundColor: panelHighlightedIconBackgroundColor ?? self.panelHighlightedIconBackgroundColor, stickersBackgroundColor: stickersBackgroundColor ?? self.stickersBackgroundColor, stickersSectionTextColor: stickersSectionTextColor ?? self.stickersSectionTextColor, stickersSearchBackgroundColor: stickersSearchBackgroundColor ?? self.stickersSearchBackgroundColor, stickersSearchPlaceholderColor: stickersSearchPlaceholderColor ?? self.stickersSearchPlaceholderColor, stickersSearchPrimaryColor: stickersSearchPrimaryColor ?? self.stickersSearchPrimaryColor, stickersSearchControlColor: stickersSearchControlColor ?? self.stickersSearchControlColor, gifsBackgroundColor: gifsBackgroundColor ?? self.gifsBackgroundColor)
}
}
public final class PresentationThemeInputButtonPanel {
@ -829,6 +937,10 @@ public final class PresentationThemeInputButtonPanel {
self.buttonHighlightedStrokeColor = buttonHighlightedStrokeColor
self.buttonTextColor = buttonTextColor
}
public func withUpdated(panelSeparatorColor: UIColor? = nil, panelBackgroundColor: UIColor? = nil, buttonFillColor: UIColor? = nil, buttonStrokeColor: UIColor? = nil, buttonHighlightedFillColor: UIColor? = nil, buttonHighlightedStrokeColor: UIColor? = nil, buttonTextColor: UIColor? = nil) -> PresentationThemeInputButtonPanel {
return PresentationThemeInputButtonPanel(panelSeparatorColor: panelSeparatorColor ?? self.panelSeparatorColor, panelBackgroundColor: panelBackgroundColor ?? self.panelBackgroundColor, buttonFillColor: buttonFillColor ?? self.buttonFillColor, buttonStrokeColor: buttonStrokeColor ?? self.buttonStrokeColor, buttonHighlightedFillColor: buttonHighlightedFillColor ?? self.buttonHighlightedFillColor, buttonHighlightedStrokeColor: buttonHighlightedStrokeColor ?? self.buttonHighlightedStrokeColor, buttonTextColor: buttonTextColor ?? self.buttonTextColor)
}
}
public final class PresentationThemeChatHistoryNavigation {
@ -847,6 +959,10 @@ public final class PresentationThemeChatHistoryNavigation {
self.badgeStrokeColor = badgeStrokeColor
self.badgeTextColor = badgeTextColor
}
public func withUpdated(fillColor: UIColor? = nil, strokeColor: UIColor? = nil, foregroundColor: UIColor? = nil, badgeBackgroundColor: UIColor? = nil, badgeStrokeColor: UIColor? = nil, badgeTextColor: UIColor? = nil) -> PresentationThemeChatHistoryNavigation {
return PresentationThemeChatHistoryNavigation(fillColor: fillColor ?? self.fillColor, strokeColor: strokeColor ?? self.strokeColor, foregroundColor: foregroundColor ?? self.foregroundColor, badgeBackgroundColor: badgeBackgroundColor ?? self.badgeBackgroundColor, badgeStrokeColor: badgeStrokeColor ?? self.badgeStrokeColor, badgeTextColor: badgeTextColor ?? self.badgeTextColor)
}
}
public final class PresentationThemeChat {
@ -868,8 +984,8 @@ public final class PresentationThemeChat {
self.historyNavigation = historyNavigation
}
public func withUpdatedDefaultWallpaper(_ defaultWallpaper: TelegramWallpaper?) -> PresentationThemeChat {
return PresentationThemeChat(defaultWallpaper: defaultWallpaper ?? self.defaultWallpaper, message: self.message, serviceMessage: self.serviceMessage, inputPanel: self.inputPanel, inputMediaPanel: self.inputMediaPanel, inputButtonPanel: self.inputButtonPanel, historyNavigation: self.historyNavigation)
public func withUpdated(defaultWallpaper: TelegramWallpaper? = nil, message: PresentationThemeChatMessage? = nil, serviceMessage: PresentationThemeServiceMessage? = nil, inputPanel: PresentationThemeChatInputPanel? = nil, inputMediaPanel: PresentationThemeInputMediaPanel? = nil, inputButtonPanel: PresentationThemeInputButtonPanel? = nil, historyNavigation: PresentationThemeChatHistoryNavigation? = nil) -> PresentationThemeChat {
return PresentationThemeChat(defaultWallpaper: defaultWallpaper ?? self.defaultWallpaper, message: message ?? self.message, serviceMessage: serviceMessage ?? self.serviceMessage, inputPanel: inputPanel ?? self.inputPanel, inputMediaPanel: inputMediaPanel ?? self.inputMediaPanel, inputButtonPanel: inputButtonPanel ?? self.inputButtonPanel, historyNavigation: historyNavigation ?? self.historyNavigation)
}
}
@ -890,6 +1006,10 @@ public final class PresentationThemeExpandedNotificationNavigationBar {
self.controlColor = controlColor
self.separatorColor = separatorColor
}
public func withUpdated(backgroundColor: UIColor? = nil, primaryTextColor: UIColor? = nil, controlColor: UIColor? = nil, separatorColor: UIColor? = nil) -> PresentationThemeExpandedNotificationNavigationBar {
return PresentationThemeExpandedNotificationNavigationBar(backgroundColor: backgroundColor ?? self.backgroundColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, controlColor: controlColor ?? self.controlColor, separatorColor: separatorColor ?? self.separatorColor)
}
}
public final class PresentationThemeExpandedNotification {
@ -900,6 +1020,10 @@ public final class PresentationThemeExpandedNotification {
self.backgroundType = backgroundType
self.navigationBar = navigationBar
}
public func withUpdated(backgroundType: PresentationThemeExpandedNotificationBackgroundType? = nil, navigationBar: PresentationThemeExpandedNotificationNavigationBar? = nil) -> PresentationThemeExpandedNotification {
return PresentationThemeExpandedNotification(backgroundType: backgroundType ?? self.backgroundType, navigationBar: navigationBar ?? self.navigationBar)
}
}
public final class PresentationThemeInAppNotification {
@ -913,6 +1037,10 @@ public final class PresentationThemeInAppNotification {
self.primaryTextColor = primaryTextColor
self.expandedNotification = expandedNotification
}
public func withUpdated(fillColor: UIColor? = nil, primaryTextColor: UIColor? = nil, expandedNotification: PresentationThemeExpandedNotification? = nil) -> PresentationThemeInAppNotification {
return PresentationThemeInAppNotification(fillColor: fillColor ?? self.fillColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, expandedNotification: expandedNotification ?? self.expandedNotification)
}
}
public enum PresentationThemeBuiltinName {
@ -1034,6 +1162,6 @@ public final class PresentationTheme: Equatable {
break
}
}
return PresentationTheme(name: name.flatMap(PresentationThemeName.custom) ?? .custom(self.name.string), referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat.withUpdatedDefaultWallpaper(defaultWallpaper), actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification)
return PresentationTheme(name: name.flatMap(PresentationThemeName.custom) ?? .custom(self.name.string), referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat.withUpdated(defaultWallpaper: defaultWallpaper), actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification)
}
}

View file

@ -43,14 +43,22 @@ extension TelegramWallpaper: Codable {
self = .color(Int32(bitPattern: color.rgb))
} else {
let components = value.components(separatedBy: " ")
if components.count == 2 && [6,7].contains(components[0].count) && [6,7].contains(components[1].count), let topColor = UIColor(hexString: components[0]), let bottomColor = UIColor(hexString: components[1]) {
self = .gradient(Int32(bitPattern: topColor.rgb), Int32(bitPattern: bottomColor.rgb))
var blur = false
var motion = false
if components.contains("motion") {
motion = true
}
if components.contains("blur") {
blur = true
}
if components.count >= 2 && components.count <= 4 && [6,7].contains(components[0].count) && !["motion", "blur"].contains(components[0]) && [6,7].contains(components[1].count) && !["motion", "blur"].contains(components[1]), let topColor = UIColor(hexString: components[0]), let bottomColor = UIColor(hexString: components[1]) {
self = .gradient(Int32(bitPattern: topColor.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings(blur: blur, motion: motion))
} else {
var slug: String?
var color: Int32?
var intensity: Int32?
var blur = false
var motion = false
if !components.isEmpty {
slug = components[0]
}
@ -64,12 +72,6 @@ extension TelegramWallpaper: Codable {
intensity = 50
}
}
if components.contains("motion") {
motion = true
}
if components.contains("blur") {
blur = true
}
if let slug = slug {
self = .file(id: 0, accessHash: 0, isCreator: false, isDefault: false, isPattern: color != nil, isDark: false, slug: slug, file: TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], immediateThumbnailData: nil, mimeType: "", size: nil, attributes: []), settings: WallpaperSettings(blur: blur, motion: motion, color: color, intensity: intensity))
} else {
@ -90,8 +92,17 @@ extension TelegramWallpaper: Codable {
try container.encode("builtin")
case let .color(color):
try container.encode(String(format: "%06x", color))
case let .gradient(topColor, bottomColor):
try container.encode(String(format: "%06x", topColor) + " " + String(format: "%06x", bottomColor))
case let .gradient(topColor, bottomColor, settings):
var components: [String] = []
components.append(String(format: "%06x", topColor))
components.append(String(format: "%06x", bottomColor))
if settings.motion {
components.append("motion")
}
if settings.blur {
components.append("blur")
}
try container.encode(components.joined(separator: " "))
case let .file(file):
var components: [String] = []
components.append(file.slug)
@ -1622,7 +1633,7 @@ extension PresentationBuiltinThemeReference: Codable {
self = .day
case "classic":
self = .dayClassic
case "nightTinted":
case "nighttinted":
self = .nightAccent
case "night":
self = .night
@ -1642,7 +1653,7 @@ extension PresentationBuiltinThemeReference: Codable {
case .dayClassic:
try container.encode("classic")
case .nightAccent:
try container.encode("nightTinted")
try container.encode("nighttinted")
case .night:
try container.encode("night")
}
@ -1675,8 +1686,8 @@ extension PresentationTheme: Codable {
}
if let decoder = decoder as? PresentationThemeDecoding {
let serviceBackgroundColor = decoder.serviceBackgroundColor ?? .black
decoder.referenceTheme = makeDefaultPresentationTheme(reference: referenceTheme, accentColor: nil, bubbleColors: nil, serviceBackgroundColor: serviceBackgroundColor)
let serviceBackgroundColor = decoder.serviceBackgroundColor ?? defaultServiceBackgroundColor
decoder.referenceTheme = makeDefaultPresentationTheme(reference: referenceTheme, serviceBackgroundColor: serviceBackgroundColor)
}
self.init(name: (try? values.decode(PresentationThemeName.self, forKey: .name)) ?? .custom("Untitled"),

View file

@ -2038,10 +2038,9 @@ final class SharedApplicationContext {
var carPlayOptions = options
carPlayOptions.insert(.allowInCarPlay)
//if #available(iOS 13.2, *) {
// carPlayOptions.insert(.allowAnnouncement)
//}
if #available(iOS 13.2, *) {
carPlayOptions.insert(.allowAnnouncement)
}
unknownMessageCategory = UNNotificationCategory(identifier: "unknown", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: hiddenContentString, options: options)
replyMessageCategory = UNNotificationCategory(identifier: "withReply", actions: [reply], intentIdentifiers: [INSearchForMessagesIntentIdentifier], hiddenPreviewsBodyPlaceholder: hiddenContentString, options: carPlayOptions)

View file

@ -210,6 +210,15 @@ final class ChatMessageDateHeaderNode: ListViewItemHeaderNode {
self.setNeedsLayout()
}
func updateBackgroundColor(_ color: UIColor) {
let chatDateSize: CGFloat = 20.0
self.backgroundNode.image = generateImage(CGSize(width: chatDateSize, height: chatDateSize), contextGenerator: { size, context -> Void in
context.clear(CGRect(origin: CGPoint(), size: size))
context.setFillColor(color.cgColor)
context.fillEllipse(in: CGRect(origin: CGPoint(), size: size))
})!.stretchableImage(withLeftCapWidth: Int(chatDateSize) / 2, topCapHeight: Int(chatDateSize) / 2)
}
override func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat) {
let chatDateSize: CGFloat = 20.0
let chatDateInset: CGFloat = 6.0

View file

@ -322,7 +322,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
} else {
unboundSize = CGSize(width: 54.0, height: 54.0)
}
case .color:
case .color, .gradient:
unboundSize = CGSize(width: 128.0, height: 128.0)
}
} else {
@ -585,6 +585,8 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
}
case let .color(color):
return solidColorImage(color)
case let .gradient(topColor, bottomColor):
return gradientImage([topColor, bottomColor])
}
}
@ -637,7 +639,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|> map { resourceStatus -> (MediaResourceStatus, MediaResourceStatus?) in
return (resourceStatus, nil)
}
case .color:
case .color, .gradient:
updatedStatusSignal = .single((.Local, nil))
}
}

View file

@ -108,9 +108,10 @@ final class ChatMessageNotificationItemNode: NotificationItemNode {
}
let presentationData = item.context.sharedContext.currentPresentationData.with { $0 }
var isReminder = false
var isScheduled = false
var title: String?
if let firstMessage = item.messages.first, let peer = messageMainPeer(firstMessage) {
var overrideImage: AvatarNodeImageOverride?
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
title = peer.displayTitle(strings: item.strings, displayOrder: item.nameDisplayOrder)
} else if let author = firstMessage.author {
@ -137,14 +138,11 @@ final class ChatMessageNotificationItemNode: NotificationItemNode {
if let text = title, firstMessage.flags.contains(.WasScheduled) {
if let author = firstMessage.author, author.id == peer.id, author.id == item.context.account.peerId {
title = presentationData.strings.ScheduledMessages_ReminderNotification
overrideImage = .savedMessagesIcon
isReminder = true
} else {
title = "📅 \(text)"
isScheduled = true
}
}
self.avatarNode.setPeer(account: item.context.account, theme: presentationData.theme, peer: peer, overrideImage: overrideImage, emptyColor: presentationData.theme.list.mediaPlaceholderColor)
}
var titleIcon: UIImage?
@ -194,7 +192,9 @@ final class ChatMessageNotificationItemNode: NotificationItemNode {
if let author = item.messages[0].author, displayAuthor {
let rawText = presentationData.strings.PUSH_CHAT_MESSAGE_FWDS(Int32(item.messages.count), peer.displayTitle(strings: item.strings, displayOrder: item.nameDisplayOrder), author.compactDisplayTitle, Int32(item.messages.count))
if let index = rawText.firstIndex(of: "|") {
title = String(rawText[rawText.startIndex ..< index])
if !isReminder {
title = String(rawText[rawText.startIndex ..< index])
}
messageText = String(rawText[rawText.index(after: index)...])
} else {
title = nil
@ -304,6 +304,15 @@ final class ChatMessageNotificationItemNode: NotificationItemNode {
messageText = ""
}
if isReminder {
title = presentationData.strings.ScheduledMessages_ReminderNotification
if let firstMessage = item.messages.first, let peer = messageMainPeer(firstMessage) {
self.avatarNode.setPeer(account: item.context.account, theme: presentationData.theme, peer: peer, overrideImage: .savedMessagesIcon, emptyColor: presentationData.theme.list.mediaPlaceholderColor)
}
} else if isScheduled, let currentTitle = title {
title = "📅 \(currentTitle)"
}
messageText = messageText.replacingOccurrences(of: "\n\n", with: " ")
self.titleAttributedText = NSAttributedString(string: title ?? "", font: compact ? Font.semibold(15.0) : Font.semibold(16.0), textColor: presentationData.theme.inAppNotification.primaryTextColor)

View file

@ -278,12 +278,22 @@ final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContentNode {
mediaAndFlags = (image, flags)
}
} else if let type = webpage.type {
if type == "telegram_backgroud" {
if let text = webpage.text, let colorCodeRange = text.range(of: "#") {
let colorCode = String(text[colorCodeRange.upperBound...])
if colorCode.rangeOfCharacter(from: CharacterSet(charactersIn: "0123456789abcdefABCDEF").inverted) == nil, let color = UIColor(hexString: colorCode) {
let media = WallpaperPreviewMedia(content: .color(color))
mediaAndFlags = (media, ChatMessageAttachedContentNodeMediaFlags())
if type == "telegram_background" {
if let text = webpage.text {
let colorCodeRange = text.range(of: "#")
if colorCodeRange != nil {
let components = text.replacingOccurrences(of: "#", with: "").components(separatedBy: "-")
if components.count == 2, let topColorCode = components.first, let bottomColorCode = components.last {
if let topColor = UIColor(hexString: topColorCode), let bottomColor = UIColor(hexString: bottomColorCode) {
let media = WallpaperPreviewMedia(content: .gradient(topColor, bottomColor))
mediaAndFlags = (media, ChatMessageAttachedContentNodeMediaFlags())
}
} else if components.count == 1, let colorCode = components.first {
if let color = UIColor(hexString: colorCode) {
let media = WallpaperPreviewMedia(content: .color(color))
mediaAndFlags = (media, ChatMessageAttachedContentNodeMediaFlags())
}
}
}
}
} else if type == "telegram_theme" {

View file

@ -482,6 +482,8 @@ func openChatWallpaper(context: AccountContext, message: Message, present: @esca
source = .slug(slug, content.file, options, color, intensity, message)
case let .color(color):
source = .wallpaper(.color(Int32(color.rgb)), nil, nil, nil, message)
case let .gradient(topColor, bottomColor):
source = .wallpaper(.gradient(Int32(topColor.rgb), Int32(bottomColor.rgb), WallpaperSettings()), nil, nil, nil, message)
}
let controller = WallpaperGalleryController(context: context, source: source)

View file

@ -225,6 +225,8 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
present(controller!, nil)
case let .color(color):
signal = .single(.color(Int32(color.rgb)))
case let .gradient(topColor, bottomColor):
signal = .single(.gradient(Int32(topColor.rgb), Int32(bottomColor.rgb), WallpaperSettings()))
}
let _ = (signal

View file

@ -543,6 +543,8 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
parameter = value
} else if queryItem.name == "color" {
parameter = value
} else if queryItem.name == "gradient" {
parameter = value
} else if queryItem.name == "mode" {
mode = "?mode=\(value)"
}

View file

@ -139,7 +139,7 @@ final class ThemeUpdateManagerImpl: ThemeUpdateManager {
theme = updatedTheme
}
return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
})
}).start()
}

View file

@ -7,6 +7,7 @@ import SyncCore
enum WallpaperPreviewMediaContent: Equatable {
case file(TelegramMediaFile, UIColor?, Bool, Bool)
case color(UIColor)
case gradient(UIColor, UIColor)
}
final class WallpaperPreviewMedia: Media {

View file

@ -127,7 +127,7 @@ final class WallpaperUploadManagerImpl: WallpaperUploadManager {
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
themeSpecificChatWallpapers[current.theme.index] = updatedWallpaper
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificBubbleColors: current.themeSpecificBubbleColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
})).start()
}
}

View file

@ -347,82 +347,91 @@ public enum PresentationThemeBaseColor: Int32, CaseIterable {
}
}
public struct PresentationThemeColorPair: PostboxCoding, Equatable {
public var color: Int32
public var optionalColor: Int32?
public init(color: Int32, optionalColor: Int32?) {
self.color = color
self.optionalColor = optionalColor
}
public init(decoder: PostboxDecoder) {
self.color = decoder.decodeInt32ForKey("t", orElse: 0)
self.optionalColor = decoder.decodeOptionalInt32ForKey("b")
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeInt32(self.color, forKey: "t")
if let bottomColor = self.optionalColor {
encoder.encodeInt32(bottomColor, forKey: "b")
} else {
encoder.encodeNil(forKey: "b")
}
}
public var colors: (UIColor, UIColor?) {
if let bottomColor = self.optionalColor {
return (UIColor(rgb: UInt32(bitPattern: self.color)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
} else {
return (UIColor(rgb: UInt32(bitPattern: self.color)), nil)
}
}
public var plainColors: (UIColor, UIColor) {
if let bottomColor = self.optionalColor {
return (UIColor(rgb: UInt32(bitPattern: self.color)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
} else {
return (UIColor(rgb: UInt32(bitPattern: self.color)), UIColor(rgb: UInt32(bitPattern: self.color)))
}
}
}
public struct PresentationThemeAccentColor: PostboxCoding, Equatable {
public var baseColor: PresentationThemeBaseColor
public var value: Int32?
public static func == (lhs: PresentationThemeAccentColor, rhs: PresentationThemeAccentColor) -> Bool {
return lhs.baseColor == rhs.baseColor && lhs.accentColor == rhs.accentColor && lhs.bubbleColors?.0 == rhs.bubbleColors?.0 && lhs.bubbleColors?.1 == rhs.bubbleColors?.1
}
public init(baseColor: PresentationThemeBaseColor, value: Int32? = nil) {
public var baseColor: PresentationThemeBaseColor
public var accentColor: Int32?
public var bubbleColors: (Int32, Int32?)?
public init(baseColor: PresentationThemeBaseColor, accentColor: Int32? = nil, bubbleColors: (Int32, Int32?)? = nil) {
self.baseColor = baseColor
self.value = value
self.accentColor = accentColor
self.bubbleColors = bubbleColors
}
public init(decoder: PostboxDecoder) {
self.baseColor = PresentationThemeBaseColor(rawValue: decoder.decodeInt32ForKey("b", orElse: 0)) ?? .blue
self.value = decoder.decodeOptionalInt32ForKey("c")
self.accentColor = decoder.decodeOptionalInt32ForKey("c")
if let bubbleTopColor = decoder.decodeOptionalInt32ForKey("bt") {
if let bubbleBottomColor = decoder.decodeOptionalInt32ForKey("bb") {
self.bubbleColors = (bubbleTopColor, bubbleBottomColor)
} else {
self.bubbleColors = (bubbleTopColor, nil)
}
} else {
self.bubbleColors = nil
}
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeInt32(self.baseColor.rawValue, forKey: "b")
if let value = self.value {
if let value = self.accentColor {
encoder.encodeInt32(value, forKey: "c")
} else {
encoder.encodeNil(forKey: "c")
}
if let bubbleColors = self.bubbleColors {
encoder.encodeInt32(bubbleColors.0, forKey: "bt")
if let bubbleBottomColor = bubbleColors.1 {
encoder.encodeInt32(bubbleBottomColor, forKey: "bb")
} else {
encoder.encodeNil(forKey: "bb")
}
} else {
encoder.encodeNil(forKey: "bt")
encoder.encodeNil(forKey: "bb")
}
}
public var color: UIColor {
if let value = self.value {
if let value = self.accentColor {
return UIColor(rgb: UInt32(bitPattern: value))
} else {
return self.baseColor.color
}
}
public var customBubbleColors: (UIColor, UIColor?)? {
if let bubbleColors = self.bubbleColors {
if let bottomColor = bubbleColors.1 {
return (UIColor(rgb: UInt32(bitPattern: bubbleColors.0)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
} else {
return (UIColor(rgb: UInt32(bitPattern: bubbleColors.0)), nil)
}
} else {
return nil
}
}
public var plainBubbleColors: (UIColor, UIColor)? {
if let bubbleColors = self.bubbleColors {
if let bottomColor = bubbleColors.1 {
return (UIColor(rgb: UInt32(bitPattern: bubbleColors.0)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
} else {
return (UIColor(rgb: UInt32(bitPattern: bubbleColors.0)), UIColor(rgb: UInt32(bitPattern: bubbleColors.0)))
}
} else {
return nil
}
}
}
public struct PresentationThemeSettings: PreferencesEntry {
public var theme: PresentationThemeReference
public var themeSpecificAccentColors: [Int64: PresentationThemeAccentColor]
public var themeSpecificBubbleColors: [Int64: PresentationThemeColorPair]
public var themeSpecificChatWallpapers: [Int64: TelegramWallpaper]
public var useSystemFont: Bool
public var fontSize: PresentationFontSize
@ -466,13 +475,12 @@ public struct PresentationThemeSettings: PreferencesEntry {
}
public static var defaultSettings: PresentationThemeSettings {
return PresentationThemeSettings(theme: .builtin(.dayClassic), themeSpecificAccentColors: [:], themeSpecificBubbleColors: [:], themeSpecificChatWallpapers: [:], useSystemFont: true, fontSize: .regular, automaticThemeSwitchSetting: AutomaticThemeSwitchSetting(trigger: .system, theme: .builtin(.night)), largeEmoji: true, disableAnimations: true)
return PresentationThemeSettings(theme: .builtin(.dayClassic), themeSpecificAccentColors: [:], themeSpecificChatWallpapers: [:], useSystemFont: true, fontSize: .regular, automaticThemeSwitchSetting: AutomaticThemeSwitchSetting(trigger: .system, theme: .builtin(.night)), largeEmoji: true, disableAnimations: true)
}
public init(theme: PresentationThemeReference, themeSpecificAccentColors: [Int64: PresentationThemeAccentColor], themeSpecificBubbleColors: [Int64: PresentationThemeColorPair], themeSpecificChatWallpapers: [Int64: TelegramWallpaper], useSystemFont: Bool, fontSize: PresentationFontSize, automaticThemeSwitchSetting: AutomaticThemeSwitchSetting, largeEmoji: Bool, disableAnimations: Bool) {
public init(theme: PresentationThemeReference, themeSpecificAccentColors: [Int64: PresentationThemeAccentColor], themeSpecificChatWallpapers: [Int64: TelegramWallpaper], useSystemFont: Bool, fontSize: PresentationFontSize, automaticThemeSwitchSetting: AutomaticThemeSwitchSetting, largeEmoji: Bool, disableAnimations: Bool) {
self.theme = theme
self.themeSpecificAccentColors = themeSpecificAccentColors
self.themeSpecificBubbleColors = themeSpecificBubbleColors
self.themeSpecificChatWallpapers = themeSpecificChatWallpapers
self.useSystemFont = useSystemFont
self.fontSize = fontSize
@ -496,12 +504,6 @@ public struct PresentationThemeSettings: PreferencesEntry {
return PresentationThemeAccentColor(decoder: decoder)
})
self.themeSpecificBubbleColors = decoder.decodeObjectDictionaryForKey("themeSpecificBubbleColors", keyDecoder: { decoder in
return decoder.decodeInt64ForKey("k", orElse: 0)
}, valueDecoder: { decoder in
return PresentationThemeColorPair(decoder: decoder)
})
self.useSystemFont = decoder.decodeInt32ForKey("useSystemFont", orElse: 1) != 0
self.fontSize = PresentationFontSize(rawValue: decoder.decodeInt32ForKey("f", orElse: PresentationFontSize.regular.rawValue)) ?? .regular
self.automaticThemeSwitchSetting = (decoder.decodeObjectForKey("automaticThemeSwitchSetting", decoder: { AutomaticThemeSwitchSetting(decoder: $0) }) as? AutomaticThemeSwitchSetting) ?? AutomaticThemeSwitchSetting(trigger: .system, theme: .builtin(.night))
@ -514,9 +516,6 @@ public struct PresentationThemeSettings: PreferencesEntry {
encoder.encodeObjectDictionary(self.themeSpecificAccentColors, forKey: "themeSpecificAccentColors", keyEncoder: { key, encoder in
encoder.encodeInt64(key, forKey: "k")
})
encoder.encodeObjectDictionary(self.themeSpecificBubbleColors, forKey: "themeSpecificBubbleColors", keyEncoder: { key, encoder in
encoder.encodeInt64(key, forKey: "k")
})
encoder.encodeObjectDictionary(self.themeSpecificChatWallpapers, forKey: "themeSpecificChatWallpapers", keyEncoder: { key, encoder in
encoder.encodeInt64(key, forKey: "k")
})
@ -536,7 +535,7 @@ public struct PresentationThemeSettings: PreferencesEntry {
}
public static func ==(lhs: PresentationThemeSettings, rhs: PresentationThemeSettings) -> Bool {
return lhs.theme == rhs.theme && lhs.themeSpecificAccentColors == rhs.themeSpecificAccentColors && lhs.themeSpecificBubbleColors == rhs.themeSpecificBubbleColors && lhs.themeSpecificChatWallpapers == rhs.themeSpecificChatWallpapers && lhs.useSystemFont == rhs.useSystemFont && lhs.fontSize == rhs.fontSize && lhs.automaticThemeSwitchSetting == rhs.automaticThemeSwitchSetting && lhs.largeEmoji == rhs.largeEmoji && lhs.disableAnimations == rhs.disableAnimations
return lhs.theme == rhs.theme && lhs.themeSpecificAccentColors == rhs.themeSpecificAccentColors && lhs.themeSpecificChatWallpapers == rhs.themeSpecificChatWallpapers && lhs.useSystemFont == rhs.useSystemFont && lhs.fontSize == rhs.fontSize && lhs.automaticThemeSwitchSetting == rhs.automaticThemeSwitchSetting && lhs.largeEmoji == rhs.largeEmoji && lhs.disableAnimations == rhs.disableAnimations
}
}

View file

@ -176,6 +176,13 @@ public func parseInternalUrl(query: String) -> ParsedInternalUrl? {
let parameter: WallpaperUrlParameter
if component.count == 6, component.rangeOfCharacter(from: CharacterSet(charactersIn: "0123456789abcdefABCDEF").inverted) == nil, let color = UIColor(hexString: component) {
parameter = .color(color)
} else if component.count == 13, component.rangeOfCharacter(from: CharacterSet(charactersIn: "0123456789abcdefABCDEF-").inverted) == nil {
let components = component.components(separatedBy: "-")
if components.count == 2, let topColor = UIColor(hexString: components[0]), let bottomColor = UIColor(hexString: components[1]) {
parameter = .gradient(topColor, bottomColor)
} else {
return nil
}
} else {
var options: WallpaperPresentationOptions = []
var intensity: Int32?

View file

@ -693,7 +693,7 @@ public func drawThemeImage(context c: CGContext, theme: PresentationTheme, wallp
case let .color(color):
c.setFillColor(UIColor(rgb: UInt32(bitPattern: color)).cgColor)
c.fill(drawingRect)
case let .gradient(topColor, bottomColor):
case let .gradient(topColor, bottomColor, _):
let gradientColors = [UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor))].map { $0.cgColor } as CFArray
var locations: [CGFloat] = [0.0, 1.0]
let colorSpace = CGColorSpaceCreateDeviceRGB()
@ -1049,7 +1049,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
backgroundColor = (UIColor(rgb: 0xd6e2ee), nil)
case let .color(color):
backgroundColor = (UIColor(rgb: UInt32(bitPattern: color)), nil)
case let .gradient(topColor, bottomColor):
case let .gradient(topColor, bottomColor, _):
backgroundColor = (UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
case .image:
backgroundColor = (.black, nil)