Chat-specific theme improvements

This commit is contained in:
Ilya Laktyushin
2021-08-22 23:59:27 +03:00
parent 2e8af64182
commit a43d164359
2 changed files with 64 additions and 45 deletions

View File

@@ -3783,19 +3783,27 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
themeEmoticon = nil
}
}
var isDarkAppearance = presentationData.theme.overallDarkAppearance
if let darkAppearancePreview = darkAppearancePreview {
isDarkAppearance = darkAppearancePreview
}
var presentationData = presentationData
if let themeEmoticon = themeEmoticon, let theme = chatThemes.first(where: { $0.emoji == themeEmoticon }) {
var isDarkAppearance = presentationData.theme.overallDarkAppearance
if let darkAppearancePreview = darkAppearancePreview {
isDarkAppearance = darkAppearancePreview
}
let customTheme = isDarkAppearance ? theme.darkTheme : theme.theme
if let settings = customTheme.settings, let theme = makePresentationTheme(settings: settings) {
presentationData = presentationData.withUpdated(theme: theme)
presentationData = presentationData.withUpdated(chatWallpaper: theme.chat.defaultWallpaper)
}
} else if let darkAppearancePreview = darkAppearancePreview {
let lightTheme: PresentationTheme
let darkTheme: PresentationTheme
if presentationData.theme.overallDarkAppearance {
darkTheme = presentationData.theme
} else {
lightTheme = presentationData.theme
}
}
strongSelf.presentationData = presentationData
@@ -12942,6 +12950,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
strongSelf.themeDarkAppearancePreviewPromise.set(dark)
}
}, completion: { [weak self] emoticon in
strongSelf.presentCrossfadeSnapshot()
strongSelf.themeDarkAppearancePreviewPromise.set(nil)
let _ = context.engine.themes.setChatTheme(peerId: peerId, emoji: emoticon).start(completed: { [weak self] in
if let strongSelf = self {