mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-03-27 09:16:28 +00:00
Cloud themes improvements
This commit is contained in:
@@ -83,12 +83,6 @@ public struct ContainerViewLayout: Equatable {
|
||||
public extension ContainerViewLayout {
|
||||
func insets(options: ContainerViewLayoutInsetOptions) -> UIEdgeInsets {
|
||||
var insets = self.intrinsicInsets
|
||||
if self.inSlideOver {
|
||||
let onScreenNavigationHeight = self.deviceMetrics.onScreenNavigationHeight(inLandscape: false) ?? 0.0
|
||||
if insets.bottom > 0.0 && abs(insets.bottom - onScreenNavigationHeight) < 0.1 {
|
||||
insets.bottom = 0.0
|
||||
}
|
||||
}
|
||||
if let statusBarHeight = self.statusBarHeight, options.contains(.statusBar) {
|
||||
insets.top += statusBarHeight
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import TelegramStringFormatting
|
||||
import AccountContext
|
||||
import DeviceLocationManager
|
||||
import Geocoding
|
||||
import WallpaperResources
|
||||
|
||||
private enum TriggerMode {
|
||||
case none
|
||||
@@ -497,11 +498,33 @@ public func themeAutoNightSettingsController(context: AccountContext) -> ViewCon
|
||||
}
|
||||
}))
|
||||
}, updateTheme: { theme in
|
||||
updateSettings { settings in
|
||||
var settings = settings
|
||||
settings.theme = theme
|
||||
return settings
|
||||
let presentationTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: theme, accentColor: nil, serviceBackgroundColor: .black, baseColor: nil)
|
||||
|
||||
let resolvedWallpaper: Signal<TelegramWallpaper?, NoError>
|
||||
if case let .file(file) = presentationTheme.chat.defaultWallpaper, file.id == 0 {
|
||||
resolvedWallpaper = cachedWallpaper(account: context.account, slug: file.slug, settings: file.settings)
|
||||
|> map { wallpaper -> TelegramWallpaper? in
|
||||
return wallpaper?.wallpaper
|
||||
}
|
||||
} else {
|
||||
resolvedWallpaper = .single(nil)
|
||||
}
|
||||
|
||||
let _ = (resolvedWallpaper
|
||||
|> mapToSignal { resolvedWallpaper -> Signal<Void, NoError> in
|
||||
var updatedTheme = theme
|
||||
if case let .cloud(info) = theme {
|
||||
updatedTheme = .cloud(PresentationCloudTheme(theme: info.theme, resolvedWallpaper: resolvedWallpaper))
|
||||
}
|
||||
|
||||
updateSettings { settings in
|
||||
var settings = settings
|
||||
settings.theme = updatedTheme
|
||||
return settings
|
||||
}
|
||||
|
||||
return .complete()
|
||||
}).start()
|
||||
})
|
||||
|
||||
let cloudThemes = Promise<[TelegramTheme]>()
|
||||
|
||||
@@ -320,7 +320,6 @@ private extension UIColor {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func generateThemeName(accentColor: UIColor) -> String {
|
||||
var nearest: (color: UInt32, distance: Int32)?
|
||||
for (color, _) in colors {
|
||||
@@ -338,11 +337,7 @@ func generateThemeName(accentColor: UIColor) -> String {
|
||||
if arc4random() % 2 == 0 {
|
||||
return "\(adjectives[Int(arc4random()) % adjectives.count].capitalized) \(colorName)"
|
||||
} else {
|
||||
if false, arc4random() % 3 == 0 {
|
||||
return "\(adjectives[Int(arc4random()) % adjectives.count].capitalized) \(colorName) \(subjectives[Int(arc4random()) % subjectives.count].capitalized)"
|
||||
} else {
|
||||
return "\(colorName) \(subjectives[Int(arc4random()) % subjectives.count].capitalized)"
|
||||
}
|
||||
return "\(colorName) \(subjectives[Int(arc4random()) % subjectives.count].capitalized)"
|
||||
}
|
||||
} else {
|
||||
return ""
|
||||
|
||||
@@ -66,8 +66,8 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
||||
self.separatorNode.backgroundColor = theme.rootController.tabBar.separatorColor
|
||||
self.topSeparatorNode.backgroundColor = theme.rootController.tabBar.separatorColor
|
||||
|
||||
self.cancelButton.setTitle(strings.Common_Cancel, with: Font.regular(17.0), with: theme.rootController.navigationBar.primaryTextColor, for: [])
|
||||
self.doneButton.setTitle(strings.Wallpaper_Set, with: Font.regular(17.0), with: theme.rootController.navigationBar.primaryTextColor, for: [])
|
||||
self.cancelButton.setTitle(strings.Common_Cancel, with: Font.regular(17.0), with: theme.list.itemPrimaryTextColor, for: [])
|
||||
self.doneButton.setTitle(strings.Wallpaper_Set, with: Font.regular(17.0), with: theme.list.itemPrimaryTextColor, for: [])
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
|
||||
@@ -455,7 +455,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder {
|
||||
|
||||
if let (item, previousItem, nextItem, order, type, _) = self.playlistStateAndType, !mediaAccessoryPanelHidden {
|
||||
let panelHeight = MediaNavigationAccessoryHeaderNode.minimizedHeight
|
||||
let panelFrame = CGRect(origin: CGPoint(x: 0.0, y: navigationHeight.isZero ? -panelHeight : (navigationHeight + additionalHeight + UIScreenPixel)), size: CGSize(width: layout.size.width, height: panelHeight))
|
||||
let panelFrame = CGRect(origin: CGPoint(x: 0.0, y: navigationHeight.isZero ? -panelHeight : (navigationHeight + additionalHeight)), size: CGSize(width: layout.size.width, height: panelHeight))
|
||||
if let (mediaAccessoryPanel, mediaType) = self.mediaAccessoryPanel, mediaType == type {
|
||||
transition.updateFrame(layer: mediaAccessoryPanel.layer, frame: panelFrame)
|
||||
mediaAccessoryPanel.updateLayout(size: panelFrame.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: transition)
|
||||
@@ -615,7 +615,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder {
|
||||
if let dismissingPanel = self.dismissingPanel {
|
||||
self.displayNode.insertSubnode(mediaAccessoryPanel, aboveSubnode: dismissingPanel)
|
||||
} else if let navigationBar = self.navigationBar {
|
||||
self.displayNode.insertSubnode(mediaAccessoryPanel, aboveSubnode: navigationBar)
|
||||
self.displayNode.insertSubnode(mediaAccessoryPanel, belowSubnode: navigationBar)
|
||||
} else {
|
||||
self.displayNode.addSubnode(mediaAccessoryPanel)
|
||||
}
|
||||
|
||||
@@ -294,8 +294,8 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, serviceBackgr
|
||||
)
|
||||
|
||||
let historyNavigation = PresentationThemeChatHistoryNavigation(
|
||||
fillColor: .white,
|
||||
strokeColor: UIColor(rgb: 0x000000, alpha: 0.15),
|
||||
fillColor: UIColor(rgb: 0xf7f7f7),
|
||||
strokeColor: UIColor(rgb: 0xb1b1b1),
|
||||
foregroundColor: UIColor(rgb: 0x88888d),
|
||||
badgeBackgroundColor: accentColor,
|
||||
badgeStrokeColor: accentColor,
|
||||
|
||||
@@ -145,8 +145,8 @@ final class ChatInfoTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
let panelHeight: CGFloat = 55.0
|
||||
|
||||
if themeUpdated {
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
||||
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.chat.historyNavigation.strokeColor
|
||||
}
|
||||
|
||||
let updatedButtons: [ChatInfoTitleButton]
|
||||
|
||||
@@ -110,8 +110,8 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
self.theme = interfaceState.theme
|
||||
self.closeButton.setImage(PresentationResourcesChat.chatInputPanelCloseIconImage(interfaceState.theme), for: [])
|
||||
self.lineNode.image = PresentationResourcesChat.chatInputPanelVerticalSeparatorLineImage(interfaceState.theme)
|
||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
||||
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.chat.historyNavigation.strokeColor
|
||||
}
|
||||
|
||||
var messageUpdated = false
|
||||
|
||||
@@ -92,8 +92,8 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
self.theme = interfaceState.theme
|
||||
|
||||
self.closeButton.setImage(PresentationResourcesChat.chatInputPanelEncircledCloseIconImage(interfaceState.theme), for: [])
|
||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
||||
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.chat.historyNavigation.strokeColor
|
||||
}
|
||||
|
||||
let panelHeight: CGFloat = 40.0
|
||||
|
||||
@@ -34,8 +34,8 @@ final class ChatRequestInProgressTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
if interfaceState.theme !== self.theme {
|
||||
self.theme = interfaceState.theme
|
||||
|
||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
||||
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.chat.historyNavigation.strokeColor
|
||||
}
|
||||
|
||||
let panelHeight: CGFloat = 40.0
|
||||
|
||||
@@ -42,8 +42,8 @@ final class ChatToastAlertPanelNode: ChatTitleAccessoryPanelNode {
|
||||
let panelHeight: CGFloat = 40.0
|
||||
|
||||
self.textColor = interfaceState.theme.rootController.navigationBar.primaryTextColor
|
||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
||||
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||
self.separatorNode.backgroundColor = interfaceState.theme.chat.historyNavigation.strokeColor
|
||||
|
||||
transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: panelHeight - UIScreenPixel), size: CGSize(width: width, height: UIScreenPixel)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user