From 10eeb3924171c183afbf1b036904db079bedbb30 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Fri, 3 Mar 2023 07:24:00 +0100 Subject: [PATCH] Fix laggy color picker close #1082 --- .../Tabs/Settings/DisplaySettingsView.swift | 36 +++++++++++++++++-- .../Localization/be.lproj/Localizable.strings | 1 + .../Localization/ca.lproj/Localizable.strings | 1 + .../Localization/de.lproj/Localizable.strings | 1 + .../en-GB.lproj/Localizable.strings | 1 + .../Localization/en.lproj/Localizable.strings | 1 + .../Localization/es.lproj/Localizable.strings | 1 + .../Localization/eu.lproj/Localizable.strings | 1 + .../Localization/fr.lproj/Localizable.strings | 1 + .../Localization/it.lproj/Localizable.strings | 1 + .../Localization/ja.lproj/Localizable.strings | 1 + .../Localization/ko.lproj/Localizable.strings | 1 + .../Localization/nb.lproj/Localizable.strings | 1 + .../Localization/nl.lproj/Localizable.strings | 1 + .../Localization/pl.lproj/Localizable.strings | 1 + .../pt-BR.lproj/Localizable.strings | 1 + .../Localization/tr.lproj/Localizable.strings | 1 + .../Localization/uk.lproj/Localizable.strings | 1 + .../zh-Hans.lproj/Localizable.strings | 1 + 19 files changed, 51 insertions(+), 3 deletions(-) diff --git a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift index 3dbf4c37..a0063608 100644 --- a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift @@ -13,6 +13,12 @@ struct DisplaySettingsView: View { @EnvironmentObject private var userPreferences: UserPreferences @State private var isFontSelectorPresented = false + + @State private var didChangeColors = false + @State private var localTintColor = Theme.shared.tintColor + @State private var localPrimaryBackgroundColor = Theme.shared.primaryBackgroundColor + @State private var localSecondaryBackgroundColor = Theme.shared.secondaryBackgroundColor + private var previewStatusViewModel = StatusRowViewModel(status: Status.placeholder(forSettings: true, language: "la"), client: Client(server: ""), routerPath: RouterPath()) // translate from latin button @@ -27,12 +33,31 @@ struct DisplaySettingsView: View { Toggle("settings.display.theme.systemColor", isOn: $theme.followSystemColorScheme) themeSelectorButton Group { - ColorPicker("settings.display.theme.tint", selection: $theme.tintColor) - ColorPicker("settings.display.theme.background", selection: $theme.primaryBackgroundColor) - ColorPicker("settings.display.theme.secondary-background", selection: $theme.secondaryBackgroundColor) + ColorPicker("settings.display.theme.tint", selection: $localTintColor) + ColorPicker("settings.display.theme.background", selection: $localPrimaryBackgroundColor) + ColorPicker("settings.display.theme.secondary-background", selection: $localSecondaryBackgroundColor) } .disabled(theme.followSystemColorScheme) .opacity(theme.followSystemColorScheme ? 0.5 : 1.0) + .onChange(of: localTintColor) { _ in + didChangeColors = true + } + .onChange(of: localSecondaryBackgroundColor) { _ in + didChangeColors = true + } + .onChange(of: localPrimaryBackgroundColor) { _ in + didChangeColors = true + } + if didChangeColors { + Button { + didChangeColors = false + theme.tintColor = localTintColor + theme.primaryBackgroundColor = localPrimaryBackgroundColor + theme.secondaryBackgroundColor = localSecondaryBackgroundColor + } label: { + Text("settings.display.colors.apply") + } + } } header: { Text("settings.display.section.theme") } footer: { @@ -131,6 +156,11 @@ struct DisplaySettingsView: View { theme.avatarShape = .rounded theme.avatarPosition = .top theme.statusActionsDisplay = .full + + localTintColor = theme.tintColor + localPrimaryBackgroundColor = theme.primaryBackgroundColor + localSecondaryBackgroundColor = theme.secondaryBackgroundColor + } label: { Text("settings.display.restore") } diff --git a/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings index 3dde5616..ca8c580b 100644 --- a/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings @@ -83,6 +83,7 @@ "settings.display.restore" = "Аднавіць па змаўчанні"; "settings.display.section.display" = "Дысплэй"; "settings.display.section.theme" = "Тэма"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Уласныя колеры можна ўсталяваць толькі ў тым выпадку, калі адключана сістэмная каляровая схема"; "settings.display.status.action-buttons" = "Кнопкі дзеянняў стану"; "settings.display.status.media-style" = "Медыястыль статусу"; diff --git a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings index cdc76d72..138ce863 100644 --- a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings @@ -78,6 +78,7 @@ "settings.display.restore" = "Restableix els valors per defecte"; "settings.display.section.display" = "Aparença"; "settings.display.section.theme" = "Tema"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Els colors personalitzats només es poden establir si la sincronització amb els colors del sistema està desactivada"; "settings.display.status.action-buttons" = "Botons d'acció"; "settings.display.status.media-style" = "Estil del contingut multimèdia"; diff --git a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings index 8338d393..1895607b 100644 --- a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "Standard wiederherstellen"; "settings.display.section.display" = "Anzeigen"; "settings.display.section.theme" = "Design"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Eigene Farben können nur eingestellt werden, wenn die Systemeinstellung nicht verwendet wird."; "settings.display.status.action-buttons" = "Status Aktions-Buttons"; "settings.display.status.media-style" = "Status Medien"; diff --git a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings index 672d0d17..95ee57f9 100644 --- a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings @@ -83,6 +83,7 @@ "settings.display.restore" = "Restore Defaults"; "settings.display.section.display" = "Display"; "settings.display.section.theme" = "Theme"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Custom colours can only be set if match system colour scheme is disabled"; "settings.display.status.action-buttons" = "Status Action Buttons"; "settings.display.status.media-style" = "Status Media Style"; diff --git a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings index 07f99a55..623b8c22 100644 --- a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings @@ -83,6 +83,7 @@ "settings.display.restore" = "Restore Defaults"; "settings.display.section.display" = "Display"; "settings.display.section.theme" = "Theme"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Custom colors can only be set if match system color scheme is disabled"; "settings.display.status.action-buttons" = "Status Action Buttons"; "settings.display.status.media-style" = "Status Media Style"; diff --git a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings index 28caf35a..a9e6a424 100644 --- a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "Restaurar ajustes predeterminados"; "settings.display.section.display" = "Apariencia"; "settings.display.section.theme" = "Tema"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Solo se pueden usar los colores personalizados si la opción de 'sistema de coincidencia' está desactivada"; "settings.display.status.action-buttons" = "Botones de acción"; "settings.display.status.media-style" = "Estilo del contenido multimedia"; diff --git a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings index e7810e31..2db5f08c 100644 --- a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "Berrezarri defektuzkoa"; "settings.display.section.display" = "Pantaila"; "settings.display.section.theme" = "Itxura"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Norberaren koloreak aukeratzeko sistemak darabiltzan koloreen aukera ezgaitu behar da"; "settings.display.status.action-buttons" = "Bidalketen ekintza botoiak"; "settings.display.status.media-style" = "Bidalketen multimediaren itxura"; diff --git a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings index fda15d6d..ee10cdb3 100644 --- a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "Restaurer les valeurs par défaut"; "settings.display.section.display" = "Affichage"; "settings.display.section.theme" = "Thème"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Les couleurs personnalisées ne peuvent être définies que si le schéma de couleur système est désactivé"; "settings.display.status.action-buttons" = "Boutons d'action de statut"; "settings.display.status.media-style" = "Style de média de statut"; diff --git a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings index 9cd6d269..58babed0 100644 --- a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "Ripristina i valori predefiniti"; "settings.display.section.display" = "Visualizzazione"; "settings.display.section.theme" = "Tema"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "I colori personalizzati possono essere impostati solo se i colori di sistema sono disabilitati"; "settings.display.status.action-buttons" = "Bottoni di azione"; "settings.display.status.media-style" = "Stile dei media"; diff --git a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings index d063ff6f..469c3741 100644 --- a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings @@ -83,6 +83,7 @@ "settings.display.restore" = "デフォルトに戻す"; "settings.display.section.display" = "表示"; "settings.display.section.theme" = "テーマ"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "カスタムカラーはシステム配色との一致が無効の場合のみ設定可能です"; "settings.display.status.action-buttons" = "アクションボタン"; "settings.display.status.media-style" = "メディアスタイル"; diff --git a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings index aef16e7f..59bc642a 100644 --- a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "초기 설정으로 되돌리기"; "settings.display.section.display" = "화면"; "settings.display.section.theme" = "테마"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "시스템 설정에 맞춤 옵션이 꺼져 있을 때만 색상을 직접 고를 수 있습니다."; "settings.display.status.action-buttons" = "글 동작 버튼"; "settings.display.status.media-style" = "글 미디어 크기"; diff --git a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings index 52b1a6b2..a3568397 100644 --- a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings @@ -83,6 +83,7 @@ "settings.display.restore" = "Gjenopprett standardinnstillinger"; "settings.display.section.display" = "Visning"; "settings.display.section.theme" = "Tema"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Egendefinerte farger kan bare angis hvis «Match system» er deaktivert"; "settings.display.status.action-buttons" = "Status handlingsknapper"; "settings.display.status.media-style" = "Status mediestil"; diff --git a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings index 38d23dba..e7ef9cae 100644 --- a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "Stel opnieuw in"; "settings.display.section.display" = "Weergave"; "settings.display.section.theme" = "Thema"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Kleuren kunnen alleen worden ingesteld als het kleurenschema niet automatisch het kleurenschema van het systeem volgt"; "settings.display.status.action-buttons" = "Actieknoppen"; "settings.display.status.media-style" = "Mediastijl"; diff --git a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings index 3136449c..bcebb146 100644 --- a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "Przywróć ustawienia domyślne"; "settings.display.section.display" = "Ekran"; "settings.display.section.theme" = "Motyw"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Kolory niestandardowe można ustawić tylko wtedy, gdy wyłączona jest opcja dopasowania schematu kolorów systemu."; "settings.display.status.action-buttons" = "Przyciski akcji"; "settings.display.status.media-style" = "Treści multimedialne"; diff --git a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings index 235b544e..f629b37a 100644 --- a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "Restaurar padrões"; "settings.display.section.display" = "Exibir"; "settings.display.section.theme" = "Tema"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Cores customizadas só podem ser definidas se o Padrão do Sistema estiver desabilitado"; "settings.display.status.action-buttons" = "Botões de ação de status"; "settings.display.status.media-style" = "Estilo de mídia de status"; diff --git a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings index c73953db..2802e7c4 100644 --- a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "Varsayılan Ayarlara Geri Döndür"; "settings.display.section.display" = "Gösterim"; "settings.display.section.theme" = "Tema"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Custom colors can only be set if match system color scheme is disabled"; "settings.display.status.action-buttons" = "Durum Aksiyon Butonları"; "settings.display.status.media-style" = "Durum Medya Stili"; diff --git a/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings index ff52a609..08bc6629 100644 --- a/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings @@ -83,6 +83,7 @@ "settings.display.restore" = "Відновити налаштування"; "settings.display.section.display" = "Відображення"; "settings.display.section.theme" = "Тема"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "Власна кольорова схема може бути встановлена лише якщо відключено Відповідати системній темі"; "settings.display.status.action-buttons" = "Кнопки дій статуса"; "settings.display.status.media-style" = "Стиль медія статуса"; diff --git a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings index f557ce9e..12a9909d 100644 --- a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings @@ -79,6 +79,7 @@ "settings.display.restore" = "恢复默认设置"; "settings.display.section.display" = "显示"; "settings.display.section.theme" = "主题"; +"settings.display.colors.apply" = "Apply custom colors"; "settings.display.section.theme.footer" = "只有在“匹配系统”关闭时才能设置自定义颜色"; "settings.display.status.action-buttons" = "导航栏样式"; "settings.display.status.media-style" = "导航栏排列";