Fix laggy color picker close #1082

This commit is contained in:
Thomas Ricouard 2023-03-03 07:24:00 +01:00
parent 1ea8af4445
commit 10eeb39241
19 changed files with 51 additions and 3 deletions

View File

@ -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")
}

View File

@ -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" = "Медыястыль статусу";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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" = "メディアスタイル";

View File

@ -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" = "글 미디어 크기";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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" = "Стиль медія статуса";

View File

@ -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" = "导航栏排列";