From 641d4b9ca0640cfdcc76ca6bd9950d7add0025ac Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 28 Oct 2021 20:49:51 +0400 Subject: [PATCH 1/2] Various Fixes --- .../ItemListRecentSessionItem.swift | 2 +- .../Recent Sessions/ItemListWebsiteItem.swift | 2 +- .../Sources/ThemeCarouselItem.swift | 2 +- .../Sources/ThemePickerController.swift | 89 ++++++++++++------- .../Themes/ThemePreviewController.swift | 16 +++- .../Themes/ThemeSettingsAccentColorItem.swift | 2 +- .../Themes/ThemeSettingsController.swift | 34 +++---- .../Themes/ThemeSettingsThemeItem.swift | 2 +- .../Sources/PresentationData.swift | 9 +- .../Sources/PresentationThemeSettings.swift | 2 +- 10 files changed, 106 insertions(+), 54 deletions(-) diff --git a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListRecentSessionItem.swift b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListRecentSessionItem.swift index 19bde0ce95..13a660b11c 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListRecentSessionItem.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListRecentSessionItem.swift @@ -501,7 +501,7 @@ class ItemListRecentSessionItemNode: ItemListRevealOptionsItemNode { transition.updateFrame(node: strongSelf.appNode, frame: CGRect(origin: CGPoint(x: leftInset + revealOffset + editingOffset, y: strongSelf.titleNode.frame.maxY + titleSpacing), size: appLayout.size)) transition.updateFrame(node: strongSelf.locationNode, frame: CGRect(origin: CGPoint(x: leftInset + revealOffset + editingOffset, y: strongSelf.appNode.frame.maxY + textSpacing), size: locationLayout.size)) - strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight))) + strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight))) strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset) diff --git a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListWebsiteItem.swift b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListWebsiteItem.swift index fa3c120856..92ac294641 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListWebsiteItem.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/Recent Sessions/ItemListWebsiteItem.swift @@ -401,7 +401,7 @@ class ItemListWebsiteItemNode: ItemListRevealOptionsItemNode { transition.updateFrame(node: strongSelf.appNode, frame: CGRect(origin: CGPoint(x: leftInset + revealOffset + editingOffset, y: 30.0), size: appLayout.size)) transition.updateFrame(node: strongSelf.locationNode, frame: CGRect(origin: CGPoint(x: leftInset + revealOffset + editingOffset, y: 50.0), size: locationLayout.size)) - strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight))) + strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight))) strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset) diff --git a/submodules/SettingsUI/Sources/ThemeCarouselItem.swift b/submodules/SettingsUI/Sources/ThemeCarouselItem.swift index 95dfce81c4..679738786d 100644 --- a/submodules/SettingsUI/Sources/ThemeCarouselItem.swift +++ b/submodules/SettingsUI/Sources/ThemeCarouselItem.swift @@ -781,7 +781,7 @@ class ThemeCarouselThemeItemNode: ListViewItemNode, ItemListItemNode { strongSelf.tapping = true strongSelf.item?.updatedTheme(themeReference) let _ = ensureThemeVisible(listNode: strongSelf.listNode, themeReference: themeReference, animated: true) - Queue.mainQueue().after(0.2) { + Queue.mainQueue().after(0.4) { strongSelf.tapping = false } } diff --git a/submodules/SettingsUI/Sources/ThemePickerController.swift b/submodules/SettingsUI/Sources/ThemePickerController.swift index 2945b3efd3..de54b71df1 100644 --- a/submodules/SettingsUI/Sources/ThemePickerController.swift +++ b/submodules/SettingsUI/Sources/ThemePickerController.swift @@ -22,8 +22,8 @@ import AnimationUI private final class ThemePickerControllerArguments { let context: AccountContext - let selectTheme: (TelegramBaseTheme?, PresentationThemeReference) -> Void - let previewTheme: (PresentationThemeReference, Bool) -> Void + let selectTheme: (TelegramBaseTheme?, PresentationThemeReference, Bool) -> Void + let previewTheme: (PresentationThemeReference, Bool, Bool) -> Void let selectAccentColor: (TelegramBaseTheme?, PresentationThemeAccentColor?) -> Void let openAccentColorPicker: (PresentationThemeReference, Bool) -> Void let editTheme: (PresentationCloudTheme) -> Void @@ -32,7 +32,7 @@ private final class ThemePickerControllerArguments { let themeContextAction: (Bool, PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void let colorContextAction: (Bool, PresentationThemeReference, ThemeSettingsColorOption?, ASDisplayNode, ContextGesture?) -> Void - init(context: AccountContext, selectTheme: @escaping (TelegramBaseTheme?, PresentationThemeReference) -> Void, previewTheme: @escaping (PresentationThemeReference, Bool) -> Void, selectAccentColor: @escaping (TelegramBaseTheme?, PresentationThemeAccentColor?) -> Void, openAccentColorPicker: @escaping (PresentationThemeReference, Bool) -> Void, editTheme: @escaping (PresentationCloudTheme) -> Void, editCurrentTheme: @escaping () -> Void, createNewTheme: @escaping () -> Void, themeContextAction: @escaping (Bool, PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void, colorContextAction: @escaping (Bool, PresentationThemeReference, ThemeSettingsColorOption?, ASDisplayNode, ContextGesture?) -> Void) { + init(context: AccountContext, selectTheme: @escaping (TelegramBaseTheme?, PresentationThemeReference, Bool) -> Void, previewTheme: @escaping (PresentationThemeReference, Bool, Bool) -> Void, selectAccentColor: @escaping (TelegramBaseTheme?, PresentationThemeAccentColor?) -> Void, openAccentColorPicker: @escaping (PresentationThemeReference, Bool) -> Void, editTheme: @escaping (PresentationCloudTheme) -> Void, editCurrentTheme: @escaping () -> Void, createNewTheme: @escaping () -> Void, themeContextAction: @escaping (Bool, PresentationThemeReference, ASDisplayNode, ContextGesture?) -> Void, colorContextAction: @escaping (Bool, PresentationThemeReference, ThemeSettingsColorOption?, ASDisplayNode, ContextGesture?) -> Void) { self.context = context self.selectTheme = selectTheme self.previewTheme = previewTheme @@ -158,7 +158,7 @@ private enum ThemePickerControllerEntry: ItemListNodeEntry { return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) case let .themes(theme, strings, themes, currentTheme, nightMode, animatedEmojiStickers): return ThemeGridThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: themes, animatedEmojiStickers: animatedEmojiStickers, themeSpecificAccentColors: [:], themeSpecificChatWallpapers: [:], nightMode: nightMode, currentTheme: currentTheme, updatedTheme: { theme in - arguments.previewTheme(theme, nightMode) + arguments.previewTheme(theme, nightMode, true) }, contextAction: { theme, node, gesture in arguments.themeContextAction(false, theme, node, gesture) }, tag: nil) @@ -167,13 +167,13 @@ private enum ThemePickerControllerEntry: ItemListNodeEntry { case let .chatPreview(theme, wallpaper, fontSize, chatBubbleCorners, strings, dateTimeFormat, nameDisplayOrder, items): return ThemeSettingsChatPreviewItem(context: arguments.context, theme: theme, componentTheme: theme, strings: strings, sectionId: self.section, fontSize: fontSize, chatBubbleCorners: chatBubbleCorners, wallpaper: wallpaper, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, messageItems: items) case let .theme(theme, strings, themes, allThemes, currentTheme, themeSpecificAccentColors, themeSpecificChatWallpapers, _, themePreferredBaseTheme): - return ThemeSettingsThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: themes, allThemes: allThemes, displayUnsupported: true, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, themePreferredBaseTheme: themePreferredBaseTheme, currentTheme: currentTheme, updatedTheme: { theme in + return ThemeSettingsThemeItem(context: arguments.context, theme: theme, strings: strings, sectionId: self.section, themes: themes, allThemes: allThemes, displayUnsupported: true, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, themePreferredBaseTheme: themePreferredBaseTheme, currentTheme: currentTheme, updatedTheme: { theme in if case let .cloud(theme) = theme, theme.theme.file == nil && theme.theme.settings == nil { if theme.theme.isCreator { arguments.editTheme(theme) } } else { - arguments.selectTheme(nil, theme) + arguments.selectTheme(nil, theme, false) } }, contextAction: { theme, node, gesture in arguments.themeContextAction(theme.index == currentTheme.index, theme, node, gesture) @@ -260,7 +260,7 @@ private enum ThemePickerControllerEntry: ItemListNodeEntry { case let .accentColor(color): arguments.selectAccentColor(baseTheme, color) case let .theme(theme): - arguments.selectTheme(baseTheme, theme) + arguments.selectTheme(baseTheme, theme, false) } } else { arguments.selectAccentColor(nil, nil) @@ -358,7 +358,7 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme var getNavigationControllerImpl: (() -> NavigationController?)? var presentCrossfadeControllerImpl: ((Bool) -> Void)? - var selectThemeImpl: ((TelegramBaseTheme?, PresentationThemeReference) -> Void)? + var selectThemeImpl: ((TelegramBaseTheme?, PresentationThemeReference, Bool) -> Void)? var selectAccentColorImpl: ((TelegramBaseTheme?, PresentationThemeAccentColor?) -> Void)? var openAccentColorPickerImpl: ((PresentationThemeReference, Bool) -> Void)? @@ -393,11 +393,16 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme let nightModePreviewPromise = ValuePromise(false) - let arguments = ThemePickerControllerArguments(context: context, selectTheme: { baseTheme, theme in - selectThemeImpl?(baseTheme, theme) - }, previewTheme: { themeReference, nightMode in + let arguments = ThemePickerControllerArguments(context: context, selectTheme: { baseTheme, theme, preset in + selectThemeImpl?(baseTheme, theme, preset) + }, previewTheme: { themeReference, nightMode, custom in if let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, baseTheme: nightMode ? .night : .classic ) { let controller = ThemePreviewController(context: context, previewTheme: theme, source: .settings(themeReference, nil, false)) + if custom { + controller.customApply = { + selectThemeImpl?(nil, themeReference, true) + } + } pushControllerImpl?(controller) } }, selectAccentColor: { currentBaseTheme, accentColor in @@ -610,7 +615,7 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme } else { newTheme = .builtin(.nightAccent) } - selectThemeImpl?(nil, newTheme) + selectThemeImpl?(nil, newTheme, false) } } @@ -848,7 +853,7 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme let previousThemeIndex = themes.prefix(upTo: currentThemeIndex).reversed().firstIndex(where: { $0.file != nil }) if let previousThemeIndex = previousThemeIndex { let theme = themes[themes.index(before: previousThemeIndex.base)] - selectThemeImpl?(nil, .cloud(PresentationCloudTheme(theme: theme, resolvedWallpaper: nil, creatorAccountId: theme.isCreator ? context.account.id : nil))) + selectThemeImpl?(nil, .cloud(PresentationCloudTheme(theme: theme, resolvedWallpaper: nil, creatorAccountId: theme.isCreator ? context.account.id : nil)), false) } else { if settings.baseTheme == .night { selectAccentColorImpl?(nil, PresentationThemeAccentColor(baseColor: .blue)) @@ -887,27 +892,49 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme var presentationData = presentationData if nightModePreview { let preferredBaseTheme: TelegramBaseTheme = .night - if let darkTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: settings.automaticThemeSwitchSetting.theme, baseTheme: preferredBaseTheme) { - presentationData = presentationData.withUpdated(theme: darkTheme) + + let automaticTheme = settings.automaticThemeSwitchSetting.theme + var effectiveColors = settings.themeSpecificAccentColors[automaticTheme.index] + if automaticTheme == .builtin(.night) && effectiveColors == nil { + effectiveColors = PresentationThemeAccentColor(baseColor: .blue) } + let themeSpecificWallpaper = (settings.themeSpecificChatWallpapers[coloredThemeIndex(reference: automaticTheme, accentColor: effectiveColors)] ?? settings.themeSpecificChatWallpapers[automaticTheme.index]) + + let darkTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: automaticTheme, baseTheme: preferredBaseTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors ?? [], wallpaper: effectiveColors?.wallpaper, baseColor: effectiveColors?.baseColor, serviceBackgroundColor: defaultServiceBackgroundColor) ?? defaultPresentationTheme + var darkWallpaper = presentationData.chatWallpaper + if let themeSpecificWallpaper = themeSpecificWallpaper { + darkWallpaper = themeSpecificWallpaper + } else { + switch darkWallpaper { + case .builtin, .color, .gradient: + darkWallpaper = darkTheme.chat.defaultWallpaper + case .file: + if darkWallpaper.isPattern { + darkWallpaper = darkTheme.chat.defaultWallpaper + } + default: + break + } + } + + presentationData = presentationData.withUpdated(theme: darkTheme).withUpdated(chatWallpaper: darkWallpaper) } - let themeReference: PresentationThemeReference -// if presentationData.autoNightModeTriggered { -// if case .emoticon = settings.theme { -// themeReference = settings.theme -// } else { -// themeReference = settings.automaticThemeSwitchSetting.theme -// } -// } else { - themeReference = settings.theme -// } + var themeReference = settings.theme + if presentationData.autoNightModeTriggered { + themeReference = settings.automaticThemeSwitchSetting.theme + } - let rightNavigationButton = ItemListNavigationButton(content: .node(switchNode), style: .regular, enabled: true, action: { [weak switchNode] in - nightModePreviewPromise.set(!nightModePreview) - switchNode?.play(isDark: presentationData.theme.overallDarkAppearance, theme: presentationData.theme) - presentCrossfadeControllerImpl?(false) - }) + let rightNavigationButton: ItemListNavigationButton? + if !presentationData.autoNightModeTriggered { + rightNavigationButton = ItemListNavigationButton(content: .node(switchNode), style: .regular, enabled: true, action: { [weak switchNode] in + nightModePreviewPromise.set(!nightModePreview) + switchNode?.play(isDark: presentationData.theme.overallDarkAppearance, theme: presentationData.theme) + presentCrossfadeControllerImpl?(false) + }) + } else { + rightNavigationButton = nil + } var defaultThemes: [PresentationThemeReference] = [] if presentationData.autoNightModeTriggered { @@ -1027,7 +1054,7 @@ public func themePickerController(context: AccountContext, focusOnItemTag: Theme context.sharedContext.presentGlobalController(crossfadeController, nil) } } - selectThemeImpl = { baseTheme, theme in + selectThemeImpl = { baseTheme, theme, preset in guard let presentationTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: theme) else { return } diff --git a/submodules/SettingsUI/Sources/Themes/ThemePreviewController.swift b/submodules/SettingsUI/Sources/Themes/ThemePreviewController.swift index 1b3332187a..8307d58d62 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemePreviewController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemePreviewController.swift @@ -50,6 +50,8 @@ public final class ThemePreviewController: ViewController { private var disposable: Disposable? private var applyDisposable = MetaDisposable() + + var customApply: (() -> Void)? public init(context: AccountContext, previewTheme: PresentationTheme, source: ThemePreviewSource) { self.context = context @@ -121,7 +123,11 @@ public final class ThemePreviewController: ViewController { } } else { self.theme.set(.single(nil)) - themeName = previewTheme.name.string + if [.builtin(.dayClassic), .builtin(.night)].contains(themeReference) { + themeName = "🏠" + } else { + themeName = previewTheme.name.string + } } default: self.theme.set(.single(nil)) @@ -223,6 +229,14 @@ public final class ThemePreviewController: ViewController { } private func apply() { + if let customApply = self.customApply { + customApply() + Queue.mainQueue().after(0.2) { + self.dismiss() + } + return + } + let previewTheme = self.previewTheme let theme: Signal let context = self.context diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsAccentColorItem.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsAccentColorItem.swift index 0fbc2a98f6..1dc1b53017 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsAccentColorItem.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsAccentColorItem.swift @@ -916,7 +916,7 @@ class ThemeSettingsAccentColorItemNode: ListViewItemNode, ItemListItemNode { } else { strongSelf.tapping = true item.updated(color) - Queue.mainQueue().after(0.2) { + Queue.mainQueue().after(0.4) { strongSelf.tapping = false } } diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift index d1a9760e22..ea87ede402 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift @@ -341,7 +341,7 @@ private func themeSettingsControllerEntries(presentationData: PresentationData, entries.append(.themeListHeader(presentationData.theme, title)) entries.append(.chatPreview(presentationData.theme, presentationData.chatWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (presentationData.strings.Appearance_PreviewReplyAuthor, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText)])) - entries.append(.themes(presentationData.theme, presentationData.strings, chatThemes, themeReference, presentationThemeSettings.automaticThemeSwitchSetting.force, animatedEmojiStickers)) + entries.append(.themes(presentationData.theme, presentationData.strings, chatThemes, themeReference, presentationThemeSettings.automaticThemeSwitchSetting.force || presentationData.autoNightModeTriggered, animatedEmojiStickers)) entries.append(.chatTheme(presentationData.theme, strings.Settings_ChatThemes)) entries.append(.wallpaper(presentationData.theme, strings.Settings_ChatBackground)) @@ -1102,27 +1102,31 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting if case let .cloud(info) = updatedTheme, info.theme.settings?.contains(where: { $0.baseTheme == .night || $0.baseTheme == .tinted }) ?? false { updatedAutomaticThemeSwitchSetting.theme = updatedTheme + } else if autoNightModeTriggered { + var updatedThemeSpecificAccentColors = current.themeSpecificAccentColors + if let baseThemeIndex = baseThemeIndex { + updatedThemeSpecificAccentColors[baseThemeIndex] = PresentationThemeAccentColor(themeIndex: updatedTheme.index) + } + + if autoNightModeTriggered { + var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting + updatedAutomaticThemeSwitchSetting.theme = updatedTheme + + return current.withUpdatedAutomaticThemeSwitchSetting(updatedAutomaticThemeSwitchSetting).withUpdatedThemeSpecificAccentColors(updatedThemeSpecificAccentColors) + } else { + return current.withUpdatedTheme(updatedTheme).withUpdatedThemeSpecificAccentColors(updatedThemeSpecificAccentColors) + } } else if case let .builtin(theme) = updatedTheme { if [.day, .dayClassic].contains(theme) { - updatedAutomaticThemeSwitchSetting.theme = .builtin(.night) + if updatedAutomaticThemeSwitchSetting.theme.emoticon != nil || [.builtin(.dayClassic), .builtin(.day)].contains(updatedAutomaticThemeSwitchSetting.theme.generalThemeReference) { + updatedAutomaticThemeSwitchSetting.theme = .builtin(.night) + } } else { updatedAutomaticThemeSwitchSetting.theme = updatedTheme } } return current.withUpdatedTheme(updatedTheme).withUpdatedAutomaticThemeSwitchSetting(updatedAutomaticThemeSwitchSetting) -// var updatedThemeSpecificAccentColors = current.themeSpecificAccentColors -// if let baseThemeIndex = baseThemeIndex { -// updatedThemeSpecificAccentColors[baseThemeIndex] = PresentationThemeAccentColor(themeIndex: updatedTheme.index) -// } -// -// if autoNightModeTriggered { -// var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting -// updatedAutomaticThemeSwitchSetting.theme = updatedTheme -// -// return current.withUpdatedAutomaticThemeSwitchSetting(updatedAutomaticThemeSwitchSetting).withUpdatedThemeSpecificAccentColors(updatedThemeSpecificAccentColors) -// } else { -// return current.withUpdatedTheme(updatedTheme).withUpdatedThemeSpecificAccentColors(updatedThemeSpecificAccentColors) -// } + }).start() return currentThemeBaseIndex != updatedThemeBaseIndex diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsThemeItem.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsThemeItem.swift index 40350414ea..ac13f94e09 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsThemeItem.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsThemeItem.swift @@ -655,7 +655,7 @@ class ThemeSettingsThemeItemNode: ListViewItemNode, ItemListItemNode { strongSelf.tapping = true strongSelf.item?.updatedTheme(themeReference) let _ = ensureThemeVisible(listNode: strongSelf.listNode, themeReference: themeReference, animated: true) - Queue.mainQueue().after(0.2) { + Queue.mainQueue().after(0.4) { strongSelf.tapping = false } } diff --git a/submodules/TelegramPresentationData/Sources/PresentationData.swift b/submodules/TelegramPresentationData/Sources/PresentationData.swift index 618e60d1b4..d008b0e1eb 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationData.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationData.swift @@ -398,7 +398,9 @@ public func automaticThemeShouldSwitchNow(settings: AutomaticThemeSwitchSetting, } private func automaticThemeShouldSwitch(_ settings: AutomaticThemeSwitchSetting, systemUserInterfaceStyle: WindowUserInterfaceStyle) -> Signal { - if case .explicitNone = settings.trigger { + if settings.force { + return .single(true) + } else if case .explicitNone = settings.trigger { return .single(false) } else { return Signal { subscriber in @@ -616,6 +618,11 @@ public func updatedPresentationData(accountManager: AccountManager Date: Thu, 28 Oct 2021 22:01:41 +0400 Subject: [PATCH 2/2] Various Fixes --- .../ItemListUI/Sources/Items/ItemListSwitchItem.swift | 2 +- .../Sources/Text Size/TextSizeSelectionItem.swift | 1 + .../Sources/Themes/ThemeSettingsFontSizeItem.swift | 1 + .../TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift | 8 ++++---- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/submodules/ItemListUI/Sources/Items/ItemListSwitchItem.swift b/submodules/ItemListUI/Sources/Items/ItemListSwitchItem.swift index f2cbe56f0f..f2d6144816 100644 --- a/submodules/ItemListUI/Sources/Items/ItemListSwitchItem.swift +++ b/submodules/ItemListUI/Sources/Items/ItemListSwitchItem.swift @@ -236,7 +236,6 @@ public class ItemListSwitchItemNode: ListViewItemNode, ItemListItemNode { if !item.enabled { if currentDisabledOverlayNode == nil { currentDisabledOverlayNode = ASDisplayNode() - currentDisabledOverlayNode?.backgroundColor = itemBackgroundColor.withAlphaComponent(0.6) } } else { currentDisabledOverlayNode = nil @@ -278,6 +277,7 @@ public class ItemListSwitchItemNode: ListViewItemNode, ItemListItemNode { } else { transition.updateFrame(node: currentDisabledOverlayNode, frame: CGRect(origin: CGPoint(), size: CGSize(width: layout.contentSize.width, height: layout.contentSize.height - separatorHeight))) } + currentDisabledOverlayNode.backgroundColor = itemBackgroundColor.withAlphaComponent(0.6) } else if let disabledOverlayNode = strongSelf.disabledOverlayNode { transition.updateAlpha(node: disabledOverlayNode, alpha: 0.0, completion: { [weak disabledOverlayNode] _ in disabledOverlayNode?.removeFromSupernode() diff --git a/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionItem.swift b/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionItem.swift index e11d1b0a1e..a279d1cb8c 100644 --- a/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionItem.swift +++ b/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionItem.swift @@ -133,6 +133,7 @@ class BubbleSettingsRadiusItemNode: ListViewItemNode, ItemListItemNode { sliderView.maximumValue = 4.0 sliderView.startValue = 0.0 sliderView.positionsCount = 5 + sliderView.useLinesForPositions = true sliderView.disablesInteractiveTransitionGestureRecognizer = true if let item = self.item, let params = self.layoutParams { sliderView.isUserInteractionEnabled = item.enabled diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsFontSizeItem.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsFontSizeItem.swift index 17e2b12ea4..03682cadfc 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsFontSizeItem.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsFontSizeItem.swift @@ -131,6 +131,7 @@ class ThemeSettingsFontSizeItemNode: ListViewItemNode, ItemListItemNode { sliderView.maximumValue = 6.0 sliderView.startValue = 0.0 sliderView.positionsCount = 7 + sliderView.useLinesForPositions = true sliderView.disablesInteractiveTransitionGestureRecognizer = true if let item = self.item, let params = self.layoutParams { sliderView.isUserInteractionEnabled = item.enabled diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index 1a3c444876..cbd2869fa1 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -2089,7 +2089,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { } } if self.isSettings { - titleString = NSAttributedString(string: title, font: Font.semibold(26.0), textColor: presentationData.theme.list.itemPrimaryTextColor) + titleString = NSAttributedString(string: title, font: Font.medium(29.0), textColor: presentationData.theme.list.itemPrimaryTextColor) smallTitleString = NSAttributedString(string: title, font: Font.semibold(28.0), textColor: .white) } else { titleString = NSAttributedString(string: title, font: Font.semibold(24.0), textColor: presentationData.theme.list.itemPrimaryTextColor) @@ -2200,7 +2200,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { let minTitleSize = CGSize(width: titleSize.width * 0.7, height: titleSize.height * 0.7) let minTitleFrame: CGRect if self.isSettings { - minTitleFrame = CGRect(origin: CGPoint(x: 16.0, y: expandedAvatarHeight - 58.0 + (subtitleSize.height.isZero ? 10.0 : 0.0)), size: minTitleSize) + minTitleFrame = CGRect(origin: CGPoint(x: 16.0, y: expandedAvatarHeight - 58.0 - UIScreenPixel + (subtitleSize.height.isZero ? 10.0 : 0.0)), size: minTitleSize) } else { minTitleFrame = CGRect(origin: CGPoint(x: 16.0, y: expandedAvatarHeight - expandedAvatarControlsHeight + 9.0 + (subtitleSize.height.isZero ? 10.0 : 0.0)), size: minTitleSize) } @@ -2214,7 +2214,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { } else { titleFrame = CGRect(origin: CGPoint(x: floor((width - titleSize.width) / 2.0), y: avatarFrame.maxY + 7.0 + (subtitleSize.height.isZero ? 11.0 : 0.0)), size: titleSize) if self.isSettings { - titleFrame = titleFrame.offsetBy(dx: 0.0, dy: 13.0) + titleFrame = titleFrame.offsetBy(dx: 0.0, dy: 11.0) } let totalSubtitleWidth = subtitleSize.width + usernameSpacing + usernameSize.width twoLineInfo = false @@ -2236,7 +2236,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { let titleOffset = -min(titleCollapseOffset, contentOffset) let titleCollapseFraction = max(0.0, min(1.0, contentOffset / titleCollapseOffset)) - let titleMinScale: CGFloat = 0.7 + let titleMinScale: CGFloat = self.isSettings ? 0.6 : 0.7 let subtitleMinScale: CGFloat = 0.8 let avatarMinScale: CGFloat = 0.7