Fixes #2083 - Expose options for overriding the system appearance in the advanced settings menu

This commit is contained in:
Stefan Ceriu
2023-11-15 10:48:00 +02:00
committed by Stefan Ceriu
parent 4b3a373782
commit eb6f7e0409
11 changed files with 106 additions and 22 deletions
@@ -167,6 +167,14 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
AnyView(
navigationRootCoordinator.toPresentable()
.environment(\.analyticsService, ServiceLocator.shared.analytics)
.onReceive(appSettings.$appAppearance) { [weak self] appAppearance in
guard let self else { return }
windowManager.windows.forEach { window in
// Unfortunately .preferredColorScheme doesn't propagate properly throughout the app when changed
window.overrideUserInterfaceStyle = appAppearance.interfaceStyle
}
}
)
}
@@ -36,6 +36,7 @@ final class AppSettings {
case otlpTracingEnabled
case viewSourceEnabled
case richTextEditorEnabled
case appAppearance
case elementCallBaseURL
case elementCallEncryptionEnabled
@@ -123,6 +124,9 @@ final class AppSettings {
// A URL where users can go read more about the chat backup.
let chatBackupDetailsURL: URL = "https://element.io/help#encryption5"
@UserPreference(key: UserDefaultsKeys.appAppearance, defaultValue: .system, storageType: .userDefaults(store))
var appAppearance: AppAppearance
// MARK: - Security
/// The app must be locked with a PIN code as part of the authentication flow.
@@ -36,6 +36,10 @@ class WindowManager {
/// A secondary window that can be presented instead of the main/overlay window combo.
private(set) var alternateWindow: UIWindow!
var windows: [UIWindow] {
[mainWindow, overlayWindow, alternateWindow]
}
/// Configures the window manager to operate on the supplied scene.
func configure(with windowScene: UIWindowScene) {
mainWindow = windowScene.keyWindow