mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 13:38:21 +00:00
Theme fixes
This commit is contained in:
parent
406103e32d
commit
41eaa42cc2
@ -314,13 +314,18 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll
|
|||||||
var dismissInputImpl: (() -> Void)?
|
var dismissInputImpl: (() -> Void)?
|
||||||
var errorImpl: ((EditThemeEntryTag) -> Void)?
|
var errorImpl: ((EditThemeEntryTag) -> Void)?
|
||||||
|
|
||||||
|
var generalThemeReference: PresentationThemeReference?
|
||||||
|
if case let .edit(cloudTheme) = mode {
|
||||||
|
generalThemeReference = PresentationThemeReference.cloud(cloudTheme).generalThemeReference
|
||||||
|
}
|
||||||
|
|
||||||
let arguments = EditThemeControllerArguments(context: context, updateState: { f in
|
let arguments = EditThemeControllerArguments(context: context, updateState: { f in
|
||||||
updateState(f)
|
updateState(f)
|
||||||
}, openColors: {
|
}, openColors: {
|
||||||
let _ = (combineLatest(queue: Queue.mainQueue(), previewThemePromise.get(), settingsPromise.get())
|
let _ = (combineLatest(queue: Queue.mainQueue(), previewThemePromise.get(), settingsPromise.get())
|
||||||
|> take(1)).start(next: { theme, previousSettings in
|
|> take(1)).start(next: { theme, previousSettings in
|
||||||
var controllerDismissImpl: (() -> Void)?
|
var controllerDismissImpl: (() -> Void)?
|
||||||
let controller = ThemeAccentColorController(context: context, mode: .edit(theme: theme, wallpaper: nil, generalThemeReference: nil, defaultThemeReference: nil, create: false, completion: { updatedTheme, settings in
|
let controller = ThemeAccentColorController(context: context, mode: .edit(theme: theme, wallpaper: nil, generalThemeReference: generalThemeReference, defaultThemeReference: nil, create: false, completion: { updatedTheme, settings in
|
||||||
updateState { current in
|
updateState { current in
|
||||||
var state = current
|
var state = current
|
||||||
previewThemePromise.set(.single(updatedTheme))
|
previewThemePromise.set(.single(updatedTheme))
|
||||||
|
|||||||
@ -376,8 +376,6 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
var defaultMessagesColor: UIColor?
|
var defaultMessagesColor: UIColor?
|
||||||
var rotation: Int32 = 0
|
var rotation: Int32 = 0
|
||||||
|
|
||||||
var ignoreDefaultWallpaper = false
|
|
||||||
|
|
||||||
func extractWallpaperParameters(_ wallpaper: TelegramWallpaper?) {
|
func extractWallpaperParameters(_ wallpaper: TelegramWallpaper?) {
|
||||||
guard let wallpaper = wallpaper else {
|
guard let wallpaper = wallpaper else {
|
||||||
return
|
return
|
||||||
@ -439,29 +437,20 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
} else if let customWallpaper = settings.themeSpecificChatWallpapers[themeReference.index] {
|
} else if let customWallpaper = settings.themeSpecificChatWallpapers[themeReference.index] {
|
||||||
wallpaper = customWallpaper
|
wallpaper = customWallpaper
|
||||||
} else {
|
} else {
|
||||||
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: nil, wallpaper: themeSpecificAccentColor?.wallpaper) ?? defaultPresentationTheme
|
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: themeSpecificAccentColor?.color, wallpaper: themeSpecificAccentColor?.wallpaper) ?? defaultPresentationTheme
|
||||||
if case let .builtin(themeName) = themeReference {
|
|
||||||
if case .dayClassic = themeName, settings.themeSpecificAccentColors[coloredThemeIndex(reference: themeReference, accentColor: themeSpecificAccentColor)] != nil {
|
|
||||||
ignoreDefaultWallpaper = true
|
|
||||||
} else if case .nightAccent = themeName {
|
|
||||||
ignoreDefaultWallpaper = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wallpaper = theme.chat.defaultWallpaper
|
wallpaper = theme.chat.defaultWallpaper
|
||||||
}
|
}
|
||||||
|
|
||||||
extractBuiltinWallpaper(wallpaper)
|
extractBuiltinWallpaper(wallpaper)
|
||||||
|
|
||||||
if !wallpaper.isColorOrGradient && !ignoreDefaultWallpaper {
|
if !wallpaper.isColorOrGradient {
|
||||||
initialWallpaper = wallpaper
|
initialWallpaper = wallpaper
|
||||||
}
|
}
|
||||||
|
|
||||||
if let initialBackgroundColor = strongSelf.initialBackgroundColor {
|
if let initialBackgroundColor = strongSelf.initialBackgroundColor {
|
||||||
backgroundColors = (initialBackgroundColor, nil)
|
backgroundColors = (initialBackgroundColor, nil)
|
||||||
} else if !ignoreDefaultWallpaper {
|
|
||||||
extractWallpaperParameters(wallpaper)
|
|
||||||
} else {
|
} else {
|
||||||
backgroundColors = nil
|
extractWallpaperParameters(wallpaper)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let bubbleColors = settings.themeSpecificAccentColors[themeReference.index]?.customBubbleColors {
|
if let bubbleColors = settings.themeSpecificAccentColors[themeReference.index]?.customBubbleColors {
|
||||||
@ -513,28 +502,19 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
wallpaper = customWallpaper
|
wallpaper = customWallpaper
|
||||||
} else {
|
} else {
|
||||||
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: nil, wallpaper: themeSpecificAccentColor?.wallpaper) ?? defaultPresentationTheme
|
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: nil, wallpaper: themeSpecificAccentColor?.wallpaper) ?? defaultPresentationTheme
|
||||||
if case let .builtin(themeName) = themeReference {
|
|
||||||
if case .dayClassic = themeName, settings.themeSpecificAccentColors[coloredThemeIndex(reference: themeReference, accentColor: themeSpecificAccentColor)] != nil {
|
|
||||||
ignoreDefaultWallpaper = true
|
|
||||||
} else if case .nightAccent = themeName {
|
|
||||||
ignoreDefaultWallpaper = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wallpaper = theme.chat.defaultWallpaper
|
wallpaper = theme.chat.defaultWallpaper
|
||||||
}
|
}
|
||||||
|
|
||||||
extractBuiltinWallpaper(wallpaper)
|
extractBuiltinWallpaper(wallpaper)
|
||||||
|
|
||||||
if !wallpaper.isColorOrGradient && !ignoreDefaultWallpaper {
|
if !wallpaper.isColorOrGradient {
|
||||||
initialWallpaper = wallpaper
|
initialWallpaper = wallpaper
|
||||||
}
|
}
|
||||||
|
|
||||||
if let initialBackgroundColor = strongSelf.initialBackgroundColor {
|
if let initialBackgroundColor = strongSelf.initialBackgroundColor {
|
||||||
backgroundColors = (initialBackgroundColor, nil)
|
backgroundColors = (initialBackgroundColor, nil)
|
||||||
} else if !ignoreDefaultWallpaper {
|
|
||||||
extractWallpaperParameters(wallpaper)
|
|
||||||
} else {
|
} else {
|
||||||
backgroundColors = nil
|
extractWallpaperParameters(wallpaper)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let bubbleColors = settings.themeSpecificAccentColors[themeReference.index]?.customBubbleColors {
|
if let bubbleColors = settings.themeSpecificAccentColors[themeReference.index]?.customBubbleColors {
|
||||||
|
|||||||
@ -1261,24 +1261,11 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
|||||||
return themeReference
|
return themeReference
|
||||||
}
|
}
|
||||||
|> deliverOnMainQueue).start(next: { themeReference in
|
|> deliverOnMainQueue).start(next: { themeReference in
|
||||||
let controller = ThemeAccentColorController(context: context, mode: .edit(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper, generalThemeReference: themeReference.generalThemeReference, defaultThemeReference: themeReference, create: true, completion: { result, settings in
|
let controller = editThemeController(context: context, mode: .create(nil, nil), navigateToChat: { peerId in
|
||||||
let controller = editThemeController(context: context, mode: .create(result, settings), navigateToChat: { peerId in
|
if let navigationController = getNavigationControllerImpl?() {
|
||||||
if let navigationController = getNavigationControllerImpl?() {
|
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
|
||||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
updateControllersImpl?({ controllers in
|
|
||||||
var controllers = controllers
|
|
||||||
controllers = controllers.filter { controller in
|
|
||||||
if controller is ThemeAccentColorController {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
controllers.append(controller)
|
|
||||||
return controllers
|
|
||||||
})
|
|
||||||
}))
|
|
||||||
pushControllerImpl?(controller)
|
pushControllerImpl?(controller)
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
|||||||
@ -609,12 +609,12 @@ class ThemeSettingsThemeItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
|
|
||||||
var entries: [ThemeSettingsThemeEntry] = []
|
var entries: [ThemeSettingsThemeEntry] = []
|
||||||
var index: Int = 0
|
var index: Int = 0
|
||||||
for var theme in item.themes {
|
for var theme in item.themes.prefix(1) {
|
||||||
if !item.displayUnsupported, case let .cloud(theme) = theme, theme.theme.file == nil {
|
if !item.displayUnsupported, case let .cloud(theme) = theme, theme.theme.file == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
let title = themeDisplayName(strings: item.strings, reference: theme)
|
let title = themeDisplayName(strings: item.strings, reference: theme)
|
||||||
var accentColor = item.themeSpecificAccentColors[theme.index]
|
var accentColor = item.themeSpecificAccentColors[theme.generalThemeReference.index]
|
||||||
if let customThemeIndex = accentColor?.themeIndex {
|
if let customThemeIndex = accentColor?.themeIndex {
|
||||||
if let customTheme = themes[customThemeIndex] {
|
if let customTheme = themes[customThemeIndex] {
|
||||||
theme = customTheme
|
theme = customTheme
|
||||||
|
|||||||
@ -1155,6 +1155,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
|||||||
} else {
|
} else {
|
||||||
var resource: MediaResource?
|
var resource: MediaResource?
|
||||||
var reference: MediaResourceReference?
|
var reference: MediaResourceReference?
|
||||||
|
var defaultWallpaper: TelegramWallpaper?
|
||||||
if case let .local(theme) = theme {
|
if case let .local(theme) = theme {
|
||||||
reference = .standalone(resource: theme.resource)
|
reference = .standalone(resource: theme.resource)
|
||||||
} else if case let .cloud(theme) = theme, let resource = theme.theme.file?.resource {
|
} else if case let .cloud(theme) = theme, let resource = theme.theme.file?.resource {
|
||||||
@ -1188,7 +1189,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
|||||||
if let theme = theme {
|
if let theme = theme {
|
||||||
var wallpaperSignal: Signal<((UIColor, UIColor?), (UIColor, UIColor), (UIColor, UIColor), UIImage?, Int32?), NoError> = .complete()
|
var wallpaperSignal: Signal<((UIColor, UIColor?), (UIColor, UIColor), (UIColor, UIColor), UIImage?, Int32?), NoError> = .complete()
|
||||||
var rotation: Int32?
|
var rotation: Int32?
|
||||||
let backgroundColor: (UIColor, UIColor?)
|
var backgroundColor: (UIColor, UIColor?)
|
||||||
let incomingColor = (theme.chat.message.incoming.bubble.withoutWallpaper.fill, theme.chat.message.incoming.bubble.withoutWallpaper.gradientFill)
|
let incomingColor = (theme.chat.message.incoming.bubble.withoutWallpaper.fill, theme.chat.message.incoming.bubble.withoutWallpaper.gradientFill)
|
||||||
let outgoingColor = (theme.chat.message.outgoing.bubble.withoutWallpaper.fill, theme.chat.message.outgoing.bubble.withoutWallpaper.gradientFill)
|
let outgoingColor = (theme.chat.message.outgoing.bubble.withoutWallpaper.fill, theme.chat.message.outgoing.bubble.withoutWallpaper.gradientFill)
|
||||||
switch theme.chat.defaultWallpaper {
|
switch theme.chat.defaultWallpaper {
|
||||||
@ -1203,7 +1204,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
|||||||
backgroundColor = (.black, nil)
|
backgroundColor = (.black, nil)
|
||||||
case let .file(file):
|
case let .file(file):
|
||||||
rotation = file.settings.rotation
|
rotation = file.settings.rotation
|
||||||
if theme.chat.defaultWallpaper.isPattern, let color = file.settings.color {
|
if let color = file.settings.color {
|
||||||
backgroundColor = (UIColor(rgb: color), file.settings.bottomColor.flatMap { UIColor(rgb: $0) })
|
backgroundColor = (UIColor(rgb: color), file.settings.bottomColor.flatMap { UIColor(rgb: $0) })
|
||||||
} else {
|
} else {
|
||||||
backgroundColor = (theme.chatList.backgroundColor, nil)
|
backgroundColor = (theme.chatList.backgroundColor, nil)
|
||||||
@ -1211,6 +1212,11 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
|||||||
wallpaperSignal = cachedWallpaper(account: account, slug: file.slug, settings: file.settings)
|
wallpaperSignal = cachedWallpaper(account: account, slug: file.slug, settings: file.settings)
|
||||||
|> mapToSignal { wallpaper in
|
|> mapToSignal { wallpaper in
|
||||||
if let wallpaper = wallpaper, case let .file(file) = wallpaper.wallpaper {
|
if let wallpaper = wallpaper, case let .file(file) = wallpaper.wallpaper {
|
||||||
|
var effectiveBackgroundColor = backgroundColor
|
||||||
|
if let color = file.settings.color {
|
||||||
|
effectiveBackgroundColor = (UIColor(rgb: color), file.settings.bottomColor.flatMap { UIColor(rgb: $0) })
|
||||||
|
}
|
||||||
|
|
||||||
var convertedRepresentations: [ImageRepresentationWithReference] = []
|
var convertedRepresentations: [ImageRepresentationWithReference] = []
|
||||||
convertedRepresentations.append(ImageRepresentationWithReference(representation: TelegramMediaImageRepresentation(dimensions: PixelDimensions(width: 100, height: 100), resource: file.file.resource), reference: .media(media: .standalone(media: file.file), resource: file.file.resource)))
|
convertedRepresentations.append(ImageRepresentationWithReference(representation: TelegramMediaImageRepresentation(dimensions: PixelDimensions(width: 100, height: 100), resource: file.file.resource), reference: .media(media: .standalone(media: file.file), resource: file.file.resource)))
|
||||||
return wallpaperDatas(account: account, accountManager: accountManager, fileReference: .standalone(media: file.file), representations: convertedRepresentations, alwaysShowThumbnailFirst: false, thumbnail: false, onlyFullSize: true, autoFetchFullSize: true, synchronousLoad: false)
|
return wallpaperDatas(account: account, accountManager: accountManager, fileReference: .standalone(media: file.file), representations: convertedRepresentations, alwaysShowThumbnailFirst: false, thumbnail: false, onlyFullSize: true, autoFetchFullSize: true, synchronousLoad: false)
|
||||||
@ -1225,7 +1231,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
|||||||
if let color = file.settings.color, let intensity = file.settings.intensity {
|
if let color = file.settings.color, let intensity = file.settings.intensity {
|
||||||
return accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(color: color, bottomColor: file.settings.bottomColor, intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true)
|
return accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedPatternWallpaperRepresentation(color: color, bottomColor: file.settings.bottomColor, intensity: intensity, rotation: file.settings.rotation), complete: true, fetch: true)
|
||||||
|> mapToSignal { _ in
|
|> mapToSignal { _ in
|
||||||
return .complete()
|
return .single((effectiveBackgroundColor, incomingColor, outgoingColor, nil, rotation))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return .complete()
|
return .complete()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user