mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +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 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
|
||||
updateState(f)
|
||||
}, openColors: {
|
||||
let _ = (combineLatest(queue: Queue.mainQueue(), previewThemePromise.get(), settingsPromise.get())
|
||||
|> take(1)).start(next: { theme, previousSettings in
|
||||
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
|
||||
var state = current
|
||||
previewThemePromise.set(.single(updatedTheme))
|
||||
|
||||
@ -376,8 +376,6 @@ final class ThemeAccentColorController: ViewController {
|
||||
var defaultMessagesColor: UIColor?
|
||||
var rotation: Int32 = 0
|
||||
|
||||
var ignoreDefaultWallpaper = false
|
||||
|
||||
func extractWallpaperParameters(_ wallpaper: TelegramWallpaper?) {
|
||||
guard let wallpaper = wallpaper else {
|
||||
return
|
||||
@ -439,29 +437,20 @@ final class ThemeAccentColorController: ViewController {
|
||||
} else if let customWallpaper = settings.themeSpecificChatWallpapers[themeReference.index] {
|
||||
wallpaper = customWallpaper
|
||||
} else {
|
||||
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
|
||||
}
|
||||
}
|
||||
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: themeSpecificAccentColor?.color, wallpaper: themeSpecificAccentColor?.wallpaper) ?? defaultPresentationTheme
|
||||
wallpaper = theme.chat.defaultWallpaper
|
||||
}
|
||||
|
||||
extractBuiltinWallpaper(wallpaper)
|
||||
|
||||
if !wallpaper.isColorOrGradient && !ignoreDefaultWallpaper {
|
||||
if !wallpaper.isColorOrGradient {
|
||||
initialWallpaper = wallpaper
|
||||
}
|
||||
|
||||
if let initialBackgroundColor = strongSelf.initialBackgroundColor {
|
||||
backgroundColors = (initialBackgroundColor, nil)
|
||||
} else if !ignoreDefaultWallpaper {
|
||||
extractWallpaperParameters(wallpaper)
|
||||
} else {
|
||||
backgroundColors = nil
|
||||
extractWallpaperParameters(wallpaper)
|
||||
}
|
||||
|
||||
if let bubbleColors = settings.themeSpecificAccentColors[themeReference.index]?.customBubbleColors {
|
||||
@ -513,28 +502,19 @@ final class ThemeAccentColorController: ViewController {
|
||||
wallpaper = customWallpaper
|
||||
} else {
|
||||
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
|
||||
}
|
||||
|
||||
extractBuiltinWallpaper(wallpaper)
|
||||
|
||||
if !wallpaper.isColorOrGradient && !ignoreDefaultWallpaper {
|
||||
if !wallpaper.isColorOrGradient {
|
||||
initialWallpaper = wallpaper
|
||||
}
|
||||
|
||||
if let initialBackgroundColor = strongSelf.initialBackgroundColor {
|
||||
backgroundColors = (initialBackgroundColor, nil)
|
||||
} else if !ignoreDefaultWallpaper {
|
||||
extractWallpaperParameters(wallpaper)
|
||||
} else {
|
||||
backgroundColors = nil
|
||||
extractWallpaperParameters(wallpaper)
|
||||
}
|
||||
|
||||
if let bubbleColors = settings.themeSpecificAccentColors[themeReference.index]?.customBubbleColors {
|
||||
|
||||
@ -1261,24 +1261,11 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
||||
return themeReference
|
||||
}
|
||||
|> 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(result, settings), navigateToChat: { peerId in
|
||||
if let navigationController = getNavigationControllerImpl?() {
|
||||
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
|
||||
})
|
||||
}))
|
||||
let controller = editThemeController(context: context, mode: .create(nil, nil), navigateToChat: { peerId in
|
||||
if let navigationController = getNavigationControllerImpl?() {
|
||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
|
||||
}
|
||||
})
|
||||
pushControllerImpl?(controller)
|
||||
})
|
||||
}))
|
||||
|
||||
@ -609,12 +609,12 @@ class ThemeSettingsThemeItemNode: ListViewItemNode, ItemListItemNode {
|
||||
|
||||
var entries: [ThemeSettingsThemeEntry] = []
|
||||
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 {
|
||||
continue
|
||||
}
|
||||
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 customTheme = themes[customThemeIndex] {
|
||||
theme = customTheme
|
||||
|
||||
@ -1155,6 +1155,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
||||
} else {
|
||||
var resource: MediaResource?
|
||||
var reference: MediaResourceReference?
|
||||
var defaultWallpaper: TelegramWallpaper?
|
||||
if case let .local(theme) = theme {
|
||||
reference = .standalone(resource: theme.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 {
|
||||
var wallpaperSignal: Signal<((UIColor, UIColor?), (UIColor, UIColor), (UIColor, UIColor), UIImage?, Int32?), NoError> = .complete()
|
||||
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 outgoingColor = (theme.chat.message.outgoing.bubble.withoutWallpaper.fill, theme.chat.message.outgoing.bubble.withoutWallpaper.gradientFill)
|
||||
switch theme.chat.defaultWallpaper {
|
||||
@ -1203,7 +1204,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
||||
backgroundColor = (.black, nil)
|
||||
case let .file(file):
|
||||
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) })
|
||||
} else {
|
||||
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)
|
||||
|> mapToSignal { wallpaper in
|
||||
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] = []
|
||||
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)
|
||||
@ -1225,7 +1231,7 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
||||
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)
|
||||
|> mapToSignal { _ in
|
||||
return .complete()
|
||||
return .single((effectiveBackgroundColor, incomingColor, outgoingColor, nil, rotation))
|
||||
}
|
||||
} else {
|
||||
return .complete()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user