Configured and applied SwiftFormat

This commit is contained in:
Stefan Ceriu
2022-09-27 10:17:22 +03:00
committed by Stefan Ceriu
parent ff2e6ddfa7
commit 43c28d23b7
663 changed files with 2329 additions and 2840 deletions
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,8 +14,8 @@
// limitations under the License.
//
import Foundation
import DesignKit
import Foundation
extension ThemeIdentifier {
fileprivate static let defaultTheme = DefaultThemeSwiftUI()
+12 -12
View File
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,35 +14,35 @@
// limitations under the License.
//
import DesignKit
import Foundation
import SwiftUI
import DesignKit
private struct ThemeKey: EnvironmentKey {
static let defaultValue = ThemePublisher.shared.theme
}
extension EnvironmentValues {
var theme: ThemeSwiftUI {
get { self[ThemeKey.self] }
set { self[ThemeKey.self] = newValue }
}
var theme: ThemeSwiftUI {
get { self[ThemeKey.self] }
set { self[ThemeKey.self] = newValue }
}
}
extension View {
/// A theme modifier for setting the theme for this view and all its descendants in the hierarchy.
/// - Parameter theme: A theme to be set as the environment value.
/// - Returns: The target view with the theme applied.
func theme(_ theme: ThemeSwiftUI) -> some View {
environment(\.theme, theme)
}
func theme(_ theme: ThemeSwiftUI) -> some View {
environment(\.theme, theme)
}
}
extension View {
/// A theme modifier for setting the theme by id for this view and all its descendants in the hierarchy.
/// - Parameter themeId: ThemeIdentifier of a theme to be set as the environment value.
/// - Returns: The target view with the theme applied.
func theme(_ themeId: ThemeIdentifier) -> some View {
return environment(\.theme, themeId.themeSwiftUI)
}
func theme(_ themeId: ThemeIdentifier) -> some View {
environment(\.theme, themeId.themeSwiftUI)
}
}
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,21 +14,20 @@
// limitations under the License.
//
import Foundation
import Combine
import Foundation
/// Provides the theme and theme updates to SwiftUI.
///
/// Replaces the old ThemeObserver. Riot app can push updates to this class
/// removing the dependency of this class on the `ThemeService`.
class ThemePublisher: ObservableObject {
private static var _shared: ThemePublisher? = nil
private static var _shared: ThemePublisher?
static var shared: ThemePublisher {
if _shared == nil {
configure(themeId: .light)
}
return _shared!
if _shared == nil {
configure(themeId: .light)
}
return _shared!
}
@Published private(set) var theme: ThemeSwiftUI
@@ -38,7 +37,7 @@ class ThemePublisher: ObservableObject {
}
init(themeId: ThemeIdentifier) {
_theme = Published.init(initialValue: themeId.themeSwiftUI)
_theme = Published(initialValue: themeId.themeSwiftUI)
}
func republish(themeIdPublisher: AnyPublisher<ThemeIdentifier, Never>) {
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,8 +14,8 @@
// limitations under the License.
//
import Foundation
import DesignKit
import Foundation
protocol ThemeSwiftUI: ThemeSwiftUIType {
var identifier: ThemeIdentifier { get }
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,6 @@ import Foundation
import SwiftUI
extension ThemeSwiftUI {
/// Get the stable display user color based on userId.
/// - Parameter userId: The user id used to hash.
/// - Returns: The SwiftUI color for the associated userId.
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,12 +14,12 @@
// limitations under the License.
//
import Foundation
import DesignKit
import Foundation
struct DarkThemeSwiftUI: ThemeSwiftUI {
var identifier: ThemeIdentifier = .dark
let isDark: Bool = true
let isDark = true
var colors: ColorSwiftUI = DarkColors.swiftUI
var fonts: FontSwiftUI = FontSwiftUI(values: ElementFonts())
var fonts = FontSwiftUI(values: ElementFonts())
}
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,12 +14,12 @@
// limitations under the License.
//
import Foundation
import DesignKit
import Foundation
struct DefaultThemeSwiftUI: ThemeSwiftUI {
var identifier: ThemeIdentifier = .light
let isDark: Bool = false
let isDark = false
var colors: ColorSwiftUI = LightColors.swiftUI
var fonts: FontSwiftUI = FontSwiftUI(values: ElementFonts())
var fonts = FontSwiftUI(values: ElementFonts())
}