mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Cloud themes improvements
This commit is contained in:
@@ -83,12 +83,6 @@ public struct ContainerViewLayout: Equatable {
|
|||||||
public extension ContainerViewLayout {
|
public extension ContainerViewLayout {
|
||||||
func insets(options: ContainerViewLayoutInsetOptions) -> UIEdgeInsets {
|
func insets(options: ContainerViewLayoutInsetOptions) -> UIEdgeInsets {
|
||||||
var insets = self.intrinsicInsets
|
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) {
|
if let statusBarHeight = self.statusBarHeight, options.contains(.statusBar) {
|
||||||
insets.top += statusBarHeight
|
insets.top += statusBarHeight
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import TelegramStringFormatting
|
|||||||
import AccountContext
|
import AccountContext
|
||||||
import DeviceLocationManager
|
import DeviceLocationManager
|
||||||
import Geocoding
|
import Geocoding
|
||||||
|
import WallpaperResources
|
||||||
|
|
||||||
private enum TriggerMode {
|
private enum TriggerMode {
|
||||||
case none
|
case none
|
||||||
@@ -497,11 +498,33 @@ public func themeAutoNightSettingsController(context: AccountContext) -> ViewCon
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}, updateTheme: { theme in
|
}, updateTheme: { theme in
|
||||||
updateSettings { settings in
|
let presentationTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: theme, accentColor: nil, serviceBackgroundColor: .black, baseColor: nil)
|
||||||
var settings = settings
|
|
||||||
settings.theme = theme
|
let resolvedWallpaper: Signal<TelegramWallpaper?, NoError>
|
||||||
return settings
|
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]>()
|
let cloudThemes = Promise<[TelegramTheme]>()
|
||||||
|
|||||||
@@ -320,7 +320,6 @@ private extension UIColor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func generateThemeName(accentColor: UIColor) -> String {
|
func generateThemeName(accentColor: UIColor) -> String {
|
||||||
var nearest: (color: UInt32, distance: Int32)?
|
var nearest: (color: UInt32, distance: Int32)?
|
||||||
for (color, _) in colors {
|
for (color, _) in colors {
|
||||||
@@ -338,11 +337,7 @@ func generateThemeName(accentColor: UIColor) -> String {
|
|||||||
if arc4random() % 2 == 0 {
|
if arc4random() % 2 == 0 {
|
||||||
return "\(adjectives[Int(arc4random()) % adjectives.count].capitalized) \(colorName)"
|
return "\(adjectives[Int(arc4random()) % adjectives.count].capitalized) \(colorName)"
|
||||||
} else {
|
} else {
|
||||||
if false, arc4random() % 3 == 0 {
|
return "\(colorName) \(subjectives[Int(arc4random()) % subjectives.count].capitalized)"
|
||||||
return "\(adjectives[Int(arc4random()) % adjectives.count].capitalized) \(colorName) \(subjectives[Int(arc4random()) % subjectives.count].capitalized)"
|
|
||||||
} else {
|
|
||||||
return "\(colorName) \(subjectives[Int(arc4random()) % subjectives.count].capitalized)"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
|||||||
self.separatorNode.backgroundColor = theme.rootController.tabBar.separatorColor
|
self.separatorNode.backgroundColor = theme.rootController.tabBar.separatorColor
|
||||||
self.topSeparatorNode.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.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.rootController.navigationBar.primaryTextColor, 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) {
|
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 {
|
if let (item, previousItem, nextItem, order, type, _) = self.playlistStateAndType, !mediaAccessoryPanelHidden {
|
||||||
let panelHeight = MediaNavigationAccessoryHeaderNode.minimizedHeight
|
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 {
|
if let (mediaAccessoryPanel, mediaType) = self.mediaAccessoryPanel, mediaType == type {
|
||||||
transition.updateFrame(layer: mediaAccessoryPanel.layer, frame: panelFrame)
|
transition.updateFrame(layer: mediaAccessoryPanel.layer, frame: panelFrame)
|
||||||
mediaAccessoryPanel.updateLayout(size: panelFrame.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: transition)
|
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 {
|
if let dismissingPanel = self.dismissingPanel {
|
||||||
self.displayNode.insertSubnode(mediaAccessoryPanel, aboveSubnode: dismissingPanel)
|
self.displayNode.insertSubnode(mediaAccessoryPanel, aboveSubnode: dismissingPanel)
|
||||||
} else if let navigationBar = self.navigationBar {
|
} else if let navigationBar = self.navigationBar {
|
||||||
self.displayNode.insertSubnode(mediaAccessoryPanel, aboveSubnode: navigationBar)
|
self.displayNode.insertSubnode(mediaAccessoryPanel, belowSubnode: navigationBar)
|
||||||
} else {
|
} else {
|
||||||
self.displayNode.addSubnode(mediaAccessoryPanel)
|
self.displayNode.addSubnode(mediaAccessoryPanel)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,8 +294,8 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, serviceBackgr
|
|||||||
)
|
)
|
||||||
|
|
||||||
let historyNavigation = PresentationThemeChatHistoryNavigation(
|
let historyNavigation = PresentationThemeChatHistoryNavigation(
|
||||||
fillColor: .white,
|
fillColor: UIColor(rgb: 0xf7f7f7),
|
||||||
strokeColor: UIColor(rgb: 0x000000, alpha: 0.15),
|
strokeColor: UIColor(rgb: 0xb1b1b1),
|
||||||
foregroundColor: UIColor(rgb: 0x88888d),
|
foregroundColor: UIColor(rgb: 0x88888d),
|
||||||
badgeBackgroundColor: accentColor,
|
badgeBackgroundColor: accentColor,
|
||||||
badgeStrokeColor: accentColor,
|
badgeStrokeColor: accentColor,
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ final class ChatInfoTitlePanelNode: ChatTitleAccessoryPanelNode {
|
|||||||
let panelHeight: CGFloat = 55.0
|
let panelHeight: CGFloat = 55.0
|
||||||
|
|
||||||
if themeUpdated {
|
if themeUpdated {
|
||||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
self.separatorNode.backgroundColor = interfaceState.theme.chat.historyNavigation.strokeColor
|
||||||
}
|
}
|
||||||
|
|
||||||
let updatedButtons: [ChatInfoTitleButton]
|
let updatedButtons: [ChatInfoTitleButton]
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
|
|||||||
self.theme = interfaceState.theme
|
self.theme = interfaceState.theme
|
||||||
self.closeButton.setImage(PresentationResourcesChat.chatInputPanelCloseIconImage(interfaceState.theme), for: [])
|
self.closeButton.setImage(PresentationResourcesChat.chatInputPanelCloseIconImage(interfaceState.theme), for: [])
|
||||||
self.lineNode.image = PresentationResourcesChat.chatInputPanelVerticalSeparatorLineImage(interfaceState.theme)
|
self.lineNode.image = PresentationResourcesChat.chatInputPanelVerticalSeparatorLineImage(interfaceState.theme)
|
||||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
self.separatorNode.backgroundColor = interfaceState.theme.chat.historyNavigation.strokeColor
|
||||||
}
|
}
|
||||||
|
|
||||||
var messageUpdated = false
|
var messageUpdated = false
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
|
|||||||
self.theme = interfaceState.theme
|
self.theme = interfaceState.theme
|
||||||
|
|
||||||
self.closeButton.setImage(PresentationResourcesChat.chatInputPanelEncircledCloseIconImage(interfaceState.theme), for: [])
|
self.closeButton.setImage(PresentationResourcesChat.chatInputPanelEncircledCloseIconImage(interfaceState.theme), for: [])
|
||||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
self.separatorNode.backgroundColor = interfaceState.theme.chat.historyNavigation.strokeColor
|
||||||
}
|
}
|
||||||
|
|
||||||
let panelHeight: CGFloat = 40.0
|
let panelHeight: CGFloat = 40.0
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ final class ChatRequestInProgressTitlePanelNode: ChatTitleAccessoryPanelNode {
|
|||||||
if interfaceState.theme !== self.theme {
|
if interfaceState.theme !== self.theme {
|
||||||
self.theme = interfaceState.theme
|
self.theme = interfaceState.theme
|
||||||
|
|
||||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
self.separatorNode.backgroundColor = interfaceState.theme.chat.historyNavigation.strokeColor
|
||||||
}
|
}
|
||||||
|
|
||||||
let panelHeight: CGFloat = 40.0
|
let panelHeight: CGFloat = 40.0
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ final class ChatToastAlertPanelNode: ChatTitleAccessoryPanelNode {
|
|||||||
let panelHeight: CGFloat = 40.0
|
let panelHeight: CGFloat = 40.0
|
||||||
|
|
||||||
self.textColor = interfaceState.theme.rootController.navigationBar.primaryTextColor
|
self.textColor = interfaceState.theme.rootController.navigationBar.primaryTextColor
|
||||||
self.backgroundColor = interfaceState.theme.rootController.navigationBar.backgroundColor
|
self.backgroundColor = interfaceState.theme.chat.historyNavigation.fillColor
|
||||||
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
|
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)))
|
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