mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Various Improvements
This commit is contained in:
@@ -18,7 +18,7 @@ import UndoUI
|
||||
import TelegramNotices
|
||||
|
||||
public enum ThemePreviewSource {
|
||||
case settings(PresentationThemeReference, TelegramWallpaper?)
|
||||
case settings(PresentationThemeReference, TelegramWallpaper?, Bool)
|
||||
case theme(TelegramTheme)
|
||||
case slug(String, TelegramMediaFile)
|
||||
case themeSettings(String, TelegramThemeSettings)
|
||||
@@ -106,15 +106,19 @@ public final class ThemePreviewController: ViewController {
|
||||
}
|
||||
))
|
||||
hasInstallsCount = true
|
||||
case let .settings(themeReference, _):
|
||||
case let .settings(themeReference, _, _):
|
||||
if case let .cloud(theme) = themeReference {
|
||||
self.theme.set(getTheme(account: context.account, slug: theme.theme.slug)
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<TelegramTheme?, NoError> in
|
||||
return .single(nil)
|
||||
})
|
||||
themeName = theme.theme.title
|
||||
hasInstallsCount = true
|
||||
if let emoticon = theme.theme.emoticon{
|
||||
themeName = emoticon
|
||||
} else {
|
||||
themeName = theme.theme.title
|
||||
hasInstallsCount = true
|
||||
}
|
||||
} else {
|
||||
self.theme.set(.single(nil))
|
||||
themeName = previewTheme.name.string
|
||||
@@ -145,7 +149,7 @@ public final class ThemePreviewController: ViewController {
|
||||
|> deliverOnMainQueue).start(next: { [weak self] theme, presentationTheme in
|
||||
if let strongSelf = self, let theme = theme {
|
||||
let titleView = CounterContollerTitleView(theme: strongSelf.previewTheme)
|
||||
titleView.title = CounterContollerTitle(title: themeName, counter: strongSelf.presentationData.strings.Theme_UsersCount(max(1, theme.installCount ?? 0)))
|
||||
titleView.title = CounterContollerTitle(title: themeName, counter: hasInstallsCount ? strongSelf.presentationData.strings.Theme_UsersCount(max(1, theme.installCount ?? 0)) : "")
|
||||
strongSelf.navigationItem.titleView = titleView
|
||||
strongSelf.navigationBar?.updatePresentationData(NavigationBarPresentationData(presentationTheme: presentationTheme, presentationStrings: strongSelf.presentationData.strings))
|
||||
}
|
||||
@@ -184,13 +188,14 @@ public final class ThemePreviewController: ViewController {
|
||||
super.loadDisplayNode()
|
||||
|
||||
var isPreview = false
|
||||
if case .settings = self.source {
|
||||
isPreview = true
|
||||
}
|
||||
|
||||
var forceReady = false
|
||||
var initialWallpaper: TelegramWallpaper?
|
||||
if case let .settings(_, currentWallpaper) = self.source, let wallpaper = currentWallpaper {
|
||||
initialWallpaper = wallpaper
|
||||
if case let .settings(_, currentWallpaper, preview) = self.source {
|
||||
isPreview = preview
|
||||
forceReady = true
|
||||
if let wallpaper = currentWallpaper {
|
||||
initialWallpaper = wallpaper
|
||||
}
|
||||
}
|
||||
|
||||
self.displayNode = ThemePreviewControllerNode(context: self.context, previewTheme: self.previewTheme, initialWallpaper: initialWallpaper, dismiss: { [weak self] in
|
||||
@@ -201,7 +206,7 @@ public final class ThemePreviewController: ViewController {
|
||||
if let strongSelf = self {
|
||||
strongSelf.apply()
|
||||
}
|
||||
}, isPreview: isPreview, ready: self._ready)
|
||||
}, isPreview: isPreview, forceReady: forceReady, ready: self._ready)
|
||||
self.displayNodeDidLoad()
|
||||
|
||||
let previewTheme = self.previewTheme
|
||||
@@ -227,7 +232,7 @@ public final class ThemePreviewController: ViewController {
|
||||
let disposable = self.applyDisposable
|
||||
|
||||
switch self.source {
|
||||
case let .settings(reference, _):
|
||||
case let .settings(reference, _, _):
|
||||
theme = .single(reference)
|
||||
case .theme, .slug, .themeSettings:
|
||||
theme = combineLatest(self.theme.get() |> take(1), wallpaperPromise.get() |> take(1))
|
||||
@@ -380,7 +385,7 @@ public final class ThemePreviewController: ViewController {
|
||||
}
|
||||
|
||||
var themeSpecificAccentColors = updatedSettings.themeSpecificAccentColors
|
||||
if case let .cloud(info) = updatedTheme, let settings = info.theme.settings {
|
||||
if case let .cloud(info) = updatedTheme, let settings = info.theme.settings?.first {
|
||||
let baseThemeReference = PresentationThemeReference.builtin(PresentationBuiltinThemeReference(baseTheme: settings.baseTheme))
|
||||
themeSpecificAccentColors[baseThemeReference.index] = PresentationThemeAccentColor(themeIndex: updatedTheme.index)
|
||||
}
|
||||
@@ -421,7 +426,9 @@ public final class ThemePreviewController: ViewController {
|
||||
|> deliverOnMainQueue).start(next: { [weak self] previousDefaultTheme in
|
||||
if let strongSelf = self, let layout = strongSelf.validLayout {
|
||||
Queue.mainQueue().after(0.3) {
|
||||
if layout.size.width >= 375.0 {
|
||||
if case .settings = strongSelf.source {
|
||||
|
||||
} else if layout.size.width >= 375.0 {
|
||||
let navigationController = strongSelf.navigationController as? NavigationController
|
||||
if let (previousDefaultTheme, previousAccentColor, autoNightMode, theme, _) = previousDefaultTheme {
|
||||
let _ = (ApplicationSpecificNotice.getThemeChangeTip(accountManager: strongSelf.context.sharedContext.accountManager)
|
||||
|
||||
Reference in New Issue
Block a user