mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-11-03 14:17:19 +01:00
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.8 KiB
Swift
49 lines
1.8 KiB
Swift
import SwiftSignalKit
|
|
import TelegramPresentationData
|
|
|
|
private func themeWithDefaultAccent(_ theme: PresentationTheme) -> PresentationTheme {
|
|
let defaultTheme: PresentationTheme
|
|
switch theme.referenceTheme {
|
|
case .day, .dayClassic:
|
|
defaultTheme = defaultPresentationTheme
|
|
case .night:
|
|
defaultTheme = defaultDarkColorPresentationTheme
|
|
case .nightAccent:
|
|
return defaultDarkTintedPresentationTheme
|
|
}
|
|
|
|
let updatedTheme = customizePresentationTheme(
|
|
theme,
|
|
editing: false,
|
|
accentColor: defaultTheme.list.itemAccentColor,
|
|
outgoingAccentColor: nil,
|
|
backgroundColors: [],
|
|
bubbleColors: [],
|
|
animateBubbleColors: theme.chat.animateMessageColors,
|
|
wallpaper: theme.chat.defaultWallpaper
|
|
)
|
|
updatedTheme.forceSync = theme.forceSync
|
|
updatedTheme.starGift = theme.starGift
|
|
return updatedTheme
|
|
}
|
|
|
|
public func presentationDataWithDefaultAccent(
|
|
_ presentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)
|
|
) -> (initial: PresentationData, signal: Signal<PresentationData, NoError>) {
|
|
let initialTheme = themeWithDefaultAccent(presentationData.initial.theme)
|
|
let cachedTheme = Atomic(value: (source: presentationData.initial.theme, resolved: initialTheme))
|
|
|
|
return (
|
|
initial: presentationData.initial.withUpdated(theme: initialTheme),
|
|
signal: presentationData.signal |> map { presentationData in
|
|
let theme = cachedTheme.modify { current in
|
|
if current.source === presentationData.theme {
|
|
return current
|
|
}
|
|
return (source: presentationData.theme, resolved: themeWithDefaultAccent(presentationData.theme))
|
|
}.resolved
|
|
return presentationData.withUpdated(theme: theme)
|
|
}
|
|
)
|
|
}
|