From 83834a9c29a6f966fceffd187fad1b52c12a835e Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 20 Mar 2019 19:01:24 +0400 Subject: [PATCH] UI fixes --- TelegramUI/CachedFaqInstantPage.swift | 10 ------- .../DataAndStorageSettingsController.swift | 2 +- TelegramUI/NotificationsAndSounds.swift | 10 +++---- TelegramUI/PrivacyAndSecurityController.swift | 2 +- TelegramUI/SettingsSearchItem.swift | 28 ++++++++++++++++++- TelegramUI/ThemeSettingsController.swift | 6 ++-- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/TelegramUI/CachedFaqInstantPage.swift b/TelegramUI/CachedFaqInstantPage.swift index 0275510554..5c73a938a0 100644 --- a/TelegramUI/CachedFaqInstantPage.swift +++ b/TelegramUI/CachedFaqInstantPage.swift @@ -76,7 +76,6 @@ func faqSearchableItems(context: AccountContext) -> Signal<[SettingsSearchableIt if case let .Loaded(content) = webPage.content, let instantPage = content.instantPage { var processingQuestions = false var currentSection: String? - var currentAnchor: String? outer: for block in instantPage.blocks { if !processingQuestions { switch block { @@ -84,15 +83,6 @@ func faqSearchableItems(context: AccountContext) -> Signal<[SettingsSearchableIt if results.isEmpty { processingQuestions = true } -// case let .anchor(anchor): -// currentAnchor = anchor -// case let .header(text): -// if let anchor = currentAnchor { -// results.append(SettingsSearchableItem(id: .faq(nextIndex), title: text.plainText, alternate: [], icon: .faq, breadcrumbs: [strings.SettingsSearch_FAQ], present: { context, _, present in -// present(.push, InstantPageController(context: context, webPage: webPage, sourcePeerType: .channel, anchor: anchor)) -// })) -// nextIndex += 1 -// } default: break } diff --git a/TelegramUI/DataAndStorageSettingsController.swift b/TelegramUI/DataAndStorageSettingsController.swift index 045abb72f7..67c5a5b3f4 100644 --- a/TelegramUI/DataAndStorageSettingsController.swift +++ b/TelegramUI/DataAndStorageSettingsController.swift @@ -413,7 +413,7 @@ private func dataAndStorageControllerEntries(state: DataAndStorageControllerStat entries.append(.storageUsage(presentationData.theme, presentationData.strings.ChatSettings_Cache)) entries.append(.networkUsage(presentationData.theme, presentationData.strings.NetworkUsageSettings_Title)) - entries.append(.automaticDownloadHeader(presentationData.theme, presentationData.strings.ChatSettings_AutoDownloadTitle)) + entries.append(.automaticDownloadHeader(presentationData.theme, presentationData.strings.ChatSettings_AutoDownloadTitle.uppercased())) entries.append(.automaticDownloadCellular(presentationData.theme, presentationData.strings.ChatSettings_AutoDownloadUsingCellular, stringForAutoDownloadSetting(strings: presentationData.strings, decimalSeparator: presentationData.dateTimeFormat.decimalSeparator, settings: data.automaticMediaDownloadSettings, connectionType: .cellular))) entries.append(.automaticDownloadWifi(presentationData.theme, presentationData.strings.ChatSettings_AutoDownloadUsingWiFi, stringForAutoDownloadSetting(strings: presentationData.strings, decimalSeparator: presentationData.dateTimeFormat.decimalSeparator, settings: data.automaticMediaDownloadSettings, connectionType: .wifi))) diff --git a/TelegramUI/NotificationsAndSounds.swift b/TelegramUI/NotificationsAndSounds.swift index 02c699cbe9..ee1414b268 100644 --- a/TelegramUI/NotificationsAndSounds.swift +++ b/TelegramUI/NotificationsAndSounds.swift @@ -740,7 +740,7 @@ private func notificationsAndSoundsEntries(authorizationStatus: AccessType, warn } } - entries.append(.messageHeader(presentationData.theme, presentationData.strings.Notifications_MessageNotifications)) + entries.append(.messageHeader(presentationData.theme, presentationData.strings.Notifications_MessageNotifications.uppercased())) entries.append(.messageAlerts(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsAlert, globalSettings.privateChats.enabled)) entries.append(.messagePreviews(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsPreview, globalSettings.privateChats.displayPreviews)) entries.append(.messageSound(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsSound, localizedPeerNotificationSoundString(strings: presentationData.strings, sound: filteredGlobalSound(globalSettings.privateChats.sound)), filteredGlobalSound(globalSettings.privateChats.sound))) @@ -751,7 +751,7 @@ private func notificationsAndSoundsEntries(authorizationStatus: AccessType, warn entries.append(.messageNotice(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsHelp)) } - entries.append(.groupHeader(presentationData.theme, presentationData.strings.Notifications_GroupNotifications)) + entries.append(.groupHeader(presentationData.theme, presentationData.strings.Notifications_GroupNotifications.uppercased())) entries.append(.groupAlerts(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsAlert, globalSettings.groupChats.enabled)) entries.append(.groupPreviews(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsPreview, globalSettings.groupChats.displayPreviews)) entries.append(.groupSound(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsSound, localizedPeerNotificationSoundString(strings: presentationData.strings, sound: filteredGlobalSound(globalSettings.groupChats.sound)), filteredGlobalSound(globalSettings.groupChats.sound))) @@ -762,7 +762,7 @@ private func notificationsAndSoundsEntries(authorizationStatus: AccessType, warn entries.append(.groupNotice(presentationData.theme, presentationData.strings.Notifications_GroupNotificationsHelp)) } - entries.append(.channelHeader(presentationData.theme, presentationData.strings.Notifications_ChannelNotifications)) + entries.append(.channelHeader(presentationData.theme, presentationData.strings.Notifications_ChannelNotifications.uppercased())) entries.append(.channelAlerts(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsAlert, globalSettings.channels.enabled)) entries.append(.channelPreviews(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsPreview, globalSettings.channels.displayPreviews)) entries.append(.channelSound(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsSound, localizedPeerNotificationSoundString(strings: presentationData.strings, sound: filteredGlobalSound(globalSettings.channels.sound)), filteredGlobalSound(globalSettings.channels.sound))) @@ -773,7 +773,7 @@ private func notificationsAndSoundsEntries(authorizationStatus: AccessType, warn entries.append(.channelNotice(presentationData.theme, presentationData.strings.Notifications_ChannelNotificationsHelp)) } - entries.append(.inAppHeader(presentationData.theme, presentationData.strings.Notifications_InAppNotifications)) + entries.append(.inAppHeader(presentationData.theme, presentationData.strings.Notifications_InAppNotifications.uppercased())) entries.append(.inAppSounds(presentationData.theme, presentationData.strings.Notifications_InAppNotificationsSounds, inAppSettings.playSounds)) entries.append(.inAppVibrate(presentationData.theme, presentationData.strings.Notifications_InAppNotificationsVibrate, inAppSettings.vibrate)) entries.append(.inAppPreviews(presentationData.theme, presentationData.strings.Notifications_InAppNotificationsPreview, inAppSettings.displayPreviews)) @@ -781,7 +781,7 @@ private func notificationsAndSoundsEntries(authorizationStatus: AccessType, warn entries.append(.displayNamesOnLockscreen(presentationData.theme, presentationData.strings.Notifications_DisplayNamesOnLockScreen, inAppSettings.displayNameOnLockscreen)) entries.append(.displayNamesOnLockscreenInfo(presentationData.theme, presentationData.strings.Notifications_DisplayNamesOnLockScreenInfoWithLink)) - entries.append(.badgeHeader(presentationData.theme, presentationData.strings.Notifications_Badge)) + entries.append(.badgeHeader(presentationData.theme, presentationData.strings.Notifications_Badge.uppercased())) entries.append(.unreadCountStyle(presentationData.theme, presentationData.strings.Notifications_Badge_IncludeMutedChats, inAppSettings.totalUnreadCountDisplayStyle == .raw)) entries.append(.includePublicGroups(presentationData.theme, presentationData.strings.Notifications_Badge_IncludePublicGroups, inAppSettings.totalUnreadCountIncludeTags.contains(.publicGroups))) entries.append(.includeChannels(presentationData.theme, presentationData.strings.Notifications_Badge_IncludeChannels, inAppSettings.totalUnreadCountIncludeTags.contains(.channels))) diff --git a/TelegramUI/PrivacyAndSecurityController.swift b/TelegramUI/PrivacyAndSecurityController.swift index dfaf0d62e6..582c446a3a 100644 --- a/TelegramUI/PrivacyAndSecurityController.swift +++ b/TelegramUI/PrivacyAndSecurityController.swift @@ -363,7 +363,7 @@ private func privacyAndSecurityControllerEntries(presentationData: PresentationD } entries.append(.twoStepVerification(presentationData.theme, presentationData.strings.PrivacySettings_TwoStepAuth)) entries.append(.activeSessions(presentationData.theme, presentationData.strings.PrivacySettings_AuthSessions)) - entries.append(.accountHeader(presentationData.theme, presentationData.strings.PrivacySettings_DeleteAccountTitle)) + entries.append(.accountHeader(presentationData.theme, presentationData.strings.PrivacySettings_DeleteAccountTitle.uppercased())) if let privacySettings = privacySettings { let value: Int32 if let updatingAccountTimeoutValue = state.updatingAccountTimeoutValue { diff --git a/TelegramUI/SettingsSearchItem.swift b/TelegramUI/SettingsSearchItem.swift index 1ea66e3b45..8c94c932bd 100644 --- a/TelegramUI/SettingsSearchItem.swift +++ b/TelegramUI/SettingsSearchItem.swift @@ -369,7 +369,33 @@ private final class SettingsSearchContainerNode: SearchDisplayControllerContentN self.recentListNode.isHidden = false - let recentSearchItems = combineLatest(searchableItems.get(), settingsSearchRecentItems(postbox: context.account.postbox) |> take(1)) + let previousRecentlySearchedItemOrder = Atomic<[SettingsSearchableItemId]>(value: []) + let fixedRecentlySearchedItems = settingsSearchRecentItems(postbox: context.account.postbox) + |> map { recentIds -> [SettingsSearchableItemId] in + var result: [SettingsSearchableItemId] = [] + let _ = previousRecentlySearchedItemOrder.modify { current in + var updated: [SettingsSearchableItemId] = [] + for id in current { + inner: for recentId in recentIds { + if recentId == id { + updated.append(id) + result.append(recentId) + break inner + } + } + } + for recentId in recentIds.reversed() { + if !updated.contains(recentId) { + updated.insert(recentId, at: 0) + result.insert(recentId, at: 0) + } + } + return updated + } + return result + } + + let recentSearchItems = combineLatest(searchableItems.get(), fixedRecentlySearchedItems) |> map { searchableItems, recentItems -> [SettingsSearchableItem] in let searchableItemsMap = searchableItems.reduce([SettingsSearchableItemId : SettingsSearchableItem]()) { (map, item) -> [SettingsSearchableItemId: SettingsSearchableItem] in var map = map diff --git a/TelegramUI/ThemeSettingsController.swift b/TelegramUI/ThemeSettingsController.swift index 12c29ed9fa..4af1db031f 100644 --- a/TelegramUI/ThemeSettingsController.swift +++ b/TelegramUI/ThemeSettingsController.swift @@ -227,7 +227,7 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry { private func themeSettingsControllerEntries(presentationData: PresentationData, theme: PresentationTheme, themeAccentColor: Int32?, autoNightSettings: AutomaticThemeSwitchSetting, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, dateTimeFormat: PresentationDateTimeFormat, disableAnimations: Bool) -> [ThemeSettingsControllerEntry] { var entries: [ThemeSettingsControllerEntry] = [] - entries.append(.fontSizeHeader(presentationData.theme, strings.Appearance_TextSize)) + entries.append(.fontSizeHeader(presentationData.theme, strings.Appearance_TextSize.uppercased())) entries.append(.fontSize(presentationData.theme, fontSize)) entries.append(.chatPreviewHeader(presentationData.theme, strings.Appearance_Preview)) entries.append(.chatPreview(presentationData.theme, theme, wallpaper, fontSize, presentationData.strings, dateTimeFormat, presentationData.nameDisplayOrder)) @@ -248,13 +248,13 @@ private func themeSettingsControllerEntries(presentationData: PresentationData, entries.append(.autoNightTheme(presentationData.theme, strings.Appearance_AutoNightTheme, title)) } - entries.append(.themeListHeader(presentationData.theme, strings.Appearance_ColorTheme)) + entries.append(.themeListHeader(presentationData.theme, strings.Appearance_ColorTheme.uppercased())) entries.append(.themeItem(presentationData.theme, strings.Appearance_ThemeDayClassic, theme.name == .builtin(.dayClassic), 0)) entries.append(.themeItem(presentationData.theme, strings.Appearance_ThemeDay, theme.name == .builtin(.day), 1)) entries.append(.themeItem(presentationData.theme, strings.Appearance_ThemeNight, theme.name == .builtin(.nightGrayscale), 2)) entries.append(.themeItem(presentationData.theme, strings.Appearance_ThemeNightBlue, theme.name == .builtin(.nightAccent), 3)) - entries.append(.animationsHeader(presentationData.theme, strings.Appearance_Animations)) + entries.append(.animationsHeader(presentationData.theme, strings.Appearance_Animations.uppercased())) entries.append(.animations(presentationData.theme, strings.Appearance_ReduceMotion, disableAnimations)) entries.append(.animationsInfo(presentationData.theme, strings.Appearance_ReduceMotionInfo))