diff --git a/.gitignore b/.gitignore
index 05465bd32..695d4cd61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@ DerivedData
out/
.vscode/
vendor/
+.DS_Store
# CocoaPods
#
diff --git a/DesignKit/Source/ColorValues.swift b/DesignKit/Source/ColorValues.swift
new file mode 100644
index 000000000..5694a5503
--- /dev/null
+++ b/DesignKit/Source/ColorValues.swift
@@ -0,0 +1,50 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+import UIKit
+
+/**
+ Struct for holding colour values for a particular theme.
+ */
+public struct ColorValues: Colors {
+
+ public let accent: UIColor
+
+ public let alert: UIColor
+
+ public let primaryContent: UIColor
+
+ public let secondaryContent: UIColor
+
+ public let tertiaryContent: UIColor
+
+ public let quarterlyContent: UIColor
+
+ public let quinaryContent: UIColor
+
+ public let separator: UIColor
+
+ public let system: UIColor
+
+ public let tile: UIColor
+
+ public let navigation: UIColor
+
+ public let background: UIColor
+
+ public let namesAndAvatars: [UIColor]
+}
diff --git a/DesignKit/Source/Colors.swift b/DesignKit/Source/Colors.swift
index e7a77c7cb..1161d48f8 100644
--- a/DesignKit/Source/Colors.swift
+++ b/DesignKit/Source/Colors.swift
@@ -18,58 +18,56 @@ import Foundation
import UIKit
import SwiftUI
-public protocol DesignKitColorType { }
-
-extension UIColor: DesignKitColorType { }
-
-extension Color : DesignKitColorType { }
-
/// Colors at https://www.figma.com/file/X4XTH9iS2KGJ2wFKDqkyed/Compound?node-id=1255%3A1104
public protocol Colors {
+ associatedtype ColorType
+
/// - Focused/Active states
/// - CTAs
- var accent: DesignKitColorType { get }
+ var accent: ColorType { get }
/// - Error messages
/// - Content requiring user attention
/// - Notification, alerts
- var alert: DesignKitColorType { get }
+ var alert: ColorType { get }
/// - Text
/// - Icons
- var primaryContent: DesignKitColorType { get }
+ var primaryContent: ColorType { get }
/// - Text
/// - Icons
- var secondaryContent: DesignKitColorType { get }
+ var secondaryContent: ColorType { get }
/// - Text
/// - Icons
- var tertiaryContent: DesignKitColorType { get }
+ var tertiaryContent: ColorType { get }
/// - Text
/// - Icons
- var quarterlyContent: DesignKitColorType { get }
+ var quarterlyContent: ColorType { get }
- /// - Text
- /// - Icons
- var quinaryContent: DesignKitColorType { get }
+ /// - separating lines and other UI components
+ var quinaryContent: ColorType { get }
+
+ /// - System-based areas and backgrounds
+ var system: ColorType { get }
/// Separating line
- var separator: DesignKitColorType { get }
+ var separator: ColorType { get }
// Cards, tiles
- var tile: DesignKitColorType { get }
+ var tile: ColorType { get }
/// Top navigation background on iOS
- var navigation: DesignKitColorType { get }
+ var navigation: ColorType { get }
/// Background UI color
- var background: DesignKitColorType { get }
+ var background: ColorType { get }
/// - Names in chat timeline
/// - Avatars default states that include first name letter
- var namesAndAvatars: [DesignKitColorType] { get }
+ var namesAndAvatars: [ColorType] { get }
}
diff --git a/DesignKit/Source/ColorsSwiftUI.swift b/DesignKit/Source/ColorsSwiftUI.swift
new file mode 100644
index 000000000..701aee537
--- /dev/null
+++ b/DesignKit/Source/ColorsSwiftUI.swift
@@ -0,0 +1,67 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+import SwiftUI
+
+/**
+ Struct for holding colors for use in SwiftUI.
+ */
+@available(iOS 14.0, *)
+public struct ColorSwiftUI: Colors {
+
+ public let accent: Color
+
+ public let alert: Color
+
+ public let primaryContent: Color
+
+ public let secondaryContent: Color
+
+ public let tertiaryContent: Color
+
+ public let quarterlyContent: Color
+
+ public let quinaryContent: Color
+
+ public let separator: Color
+
+ public var system: Color
+
+ public let tile: Color
+
+ public let navigation: Color
+
+ public let background: Color
+
+ public let namesAndAvatars: [Color]
+
+ init(values: ColorValues) {
+ accent = Color(values.accent)
+ alert = Color(values.alert)
+ primaryContent = Color(values.primaryContent)
+ secondaryContent = Color(values.secondaryContent)
+ tertiaryContent = Color(values.tertiaryContent)
+ quarterlyContent = Color(values.quarterlyContent)
+ quinaryContent = Color(values.quinaryContent)
+ separator = Color(values.separator)
+ system = Color(values.system)
+ tile = Color(values.tile)
+ navigation = Color(values.navigation)
+ background = Color(values.background)
+ namesAndAvatars = values.namesAndAvatars.map({ Color($0) })
+ }
+}
diff --git a/DesignKit/Source/ColorsUIkit.swift b/DesignKit/Source/ColorsUIkit.swift
new file mode 100644
index 000000000..47c6b38a9
--- /dev/null
+++ b/DesignKit/Source/ColorsUIkit.swift
@@ -0,0 +1,67 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+import UIKit
+
+/**
+ ObjC class for holding colors for use in UIKit.
+ */
+@objcMembers public class ColorsUIKit: NSObject {
+
+ public let accent: UIColor
+
+ public let alert: UIColor
+
+ public let primaryContent: UIColor
+
+ public let secondaryContent: UIColor
+
+ public let tertiaryContent: UIColor
+
+ public let quarterlyContent: UIColor
+
+ public let quinaryContent: UIColor
+
+ public let separator: UIColor
+
+ public let system: UIColor
+
+ public let tile: UIColor
+
+ public let navigation: UIColor
+
+ public let background: UIColor
+
+ public let namesAndAvatars: [UIColor]
+
+ init(values: ColorValues) {
+ accent = values.accent
+ alert = values.alert
+ primaryContent = values.primaryContent
+ secondaryContent = values.secondaryContent
+ tertiaryContent = values.tertiaryContent
+ quarterlyContent = values.quarterlyContent
+ quinaryContent = values.quinaryContent
+ separator = values.separator
+ system = values.system
+ tile = values.tile
+ navigation = values.navigation
+ background = values.background
+ namesAndAvatars = values.namesAndAvatars
+ }
+}
+
diff --git a/DesignKit/Source/Fonts.swift b/DesignKit/Source/Fonts.swift
index 3efe73c84..7f5d68b79 100644
--- a/DesignKit/Source/Fonts.swift
+++ b/DesignKit/Source/Fonts.swift
@@ -17,75 +17,70 @@
import UIKit
import SwiftUI
-public protocol DesignKitFontType { }
-
-extension UIFont: DesignKitFontType { }
-
-extension Font : DesignKitFontType { }
-
-
/// Describe fonts used in the application.
/// Font names are based on Element typograhy https://www.figma.com/file/X4XTH9iS2KGJ2wFKDqkyed/Compound?node-id=1362%3A0 which is based on Apple font text styles (UIFont.TextStyle): https://developer.apple.com/documentation/uikit/uifonttextstyle
/// Create a custom TextStyle enum (like DesignKit.Fonts.TextStyle) is also a possiblity
public protocol Fonts {
+ associatedtype FontType
+
/// The font for large titles.
- var largeTitle: DesignKitFontType { get }
+ var largeTitle: FontType { get }
/// `largeTitle` with a Bold weight.
- var largeTitleB: DesignKitFontType { get }
+ var largeTitleB: FontType { get }
/// The font for first-level hierarchical headings.
- var title1: DesignKitFontType { get }
+ var title1: FontType { get }
/// `title1` with a Bold weight.
- var title1B: DesignKitFontType { get }
+ var title1B: FontType { get }
/// The font for second-level hierarchical headings.
- var title2: DesignKitFontType { get }
+ var title2: FontType { get }
/// `title2` with a Bold weight.
- var title2B: DesignKitFontType { get }
+ var title2B: FontType { get }
/// The font for third-level hierarchical headings.
- var title3: DesignKitFontType { get }
+ var title3: FontType { get }
/// `title3` with a Semi Bold weight.
- var title3SB: DesignKitFontType { get }
+ var title3SB: FontType { get }
/// The font for headings.
- var headline: DesignKitFontType { get }
+ var headline: FontType { get }
/// The font for subheadings.
- var subheadline: DesignKitFontType { get }
+ var subheadline: FontType { get }
/// The font for body text.
- var body: DesignKitFontType { get }
+ var body: FontType { get }
/// `body` with a Semi Bold weight.
- var bodySB: DesignKitFontType { get }
+ var bodySB: FontType { get }
/// The font for callouts.
- var callout: DesignKitFontType { get }
+ var callout: FontType { get }
/// `callout` with a Semi Bold weight.
- var calloutSB: DesignKitFontType { get }
+ var calloutSB: FontType { get }
/// The font for footnotes.
- var footnote: DesignKitFontType { get }
+ var footnote: FontType { get }
/// `footnote` with a Semi Bold weight.
- var footnoteSB: DesignKitFontType { get }
+ var footnoteSB: FontType { get }
/// The font for standard captions.
- var caption1: DesignKitFontType { get }
+ var caption1: FontType { get }
/// `caption1` with a Semi Bold weight.
- var caption1SB: DesignKitFontType { get }
+ var caption1SB: FontType { get }
/// The font for alternate captions.
- var caption2: DesignKitFontType { get }
+ var caption2: FontType { get }
/// `caption2` with a Semi Bold weight.
- var caption2SB: DesignKitFontType { get }
+ var caption2SB: FontType { get }
}
diff --git a/DesignKit/Source/FontsSwiftUI.swift b/DesignKit/Source/FontsSwiftUI.swift
new file mode 100644
index 000000000..223936286
--- /dev/null
+++ b/DesignKit/Source/FontsSwiftUI.swift
@@ -0,0 +1,88 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+import SwiftUI
+
+/**
+ Struct for holding fonts for use in SwiftUI.
+ */
+@available(iOS 14.0, *)
+public struct FontSwiftUI: Fonts {
+ public var largeTitle: Font
+
+ public var largeTitleB: Font
+
+ public var title1: Font
+
+ public var title1B: Font
+
+ public var title2: Font
+
+ public var title2B: Font
+
+ public var title3: Font
+
+ public var title3SB: Font
+
+ public var headline: Font
+
+ public var subheadline: Font
+
+ public var body: Font
+
+ public var bodySB: Font
+
+ public var callout: Font
+
+ public var calloutSB: Font
+
+ public var footnote: Font
+
+ public var footnoteSB: Font
+
+ public var caption1: Font
+
+ public var caption1SB: Font
+
+ public var caption2: Font
+
+ public var caption2SB: Font
+
+ public init(values: ElementFonts) {
+ self.largeTitle = Font(values.largeTitle)
+ self.largeTitleB = Font(values.largeTitleB)
+ self.title1 = Font(values.title1)
+ self.title1B = Font(values.title1B)
+ self.title2 = Font(values.title2)
+ self.title2B = Font(values.title2B)
+ self.title3 = Font(values.title3)
+ self.title3SB = Font(values.title3SB)
+ self.headline = Font(values.headline)
+ self.subheadline = Font(values.subheadline)
+ self.body = Font(values.body)
+ self.bodySB = Font(values.bodySB)
+ self.callout = Font(values.callout)
+ self.calloutSB = Font(values.calloutSB)
+ self.footnote = Font(values.footnote)
+ self.footnoteSB = Font(values.footnoteSB)
+ self.caption1 = Font(values.caption1)
+ self.caption1SB = Font(values.caption1SB)
+ self.caption2 = Font(values.caption2)
+ self.caption2SB = Font(values.caption2SB)
+ }
+}
+
diff --git a/DesignKit/Source/FontsUIkit.swift b/DesignKit/Source/FontsUIkit.swift
new file mode 100644
index 000000000..b39f15f1b
--- /dev/null
+++ b/DesignKit/Source/FontsUIkit.swift
@@ -0,0 +1,87 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+import UIKit
+
+/**
+ ObjC class for holding fonts for use in UIKit.
+ */
+@objc public class FontsUIKit: NSObject, Fonts {
+
+ public var largeTitle: UIFont
+
+ public var largeTitleB: UIFont
+
+ public var title1: UIFont
+
+ public var title1B: UIFont
+
+ public var title2: UIFont
+
+ public var title2B: UIFont
+
+ public var title3: UIFont
+
+ public var title3SB: UIFont
+
+ public var headline: UIFont
+
+ public var subheadline: UIFont
+
+ public var body: UIFont
+
+ public var bodySB: UIFont
+
+ public var callout: UIFont
+
+ public var calloutSB: UIFont
+
+ public var footnote: UIFont
+
+ public var footnoteSB: UIFont
+
+ public var caption1: UIFont
+
+ public var caption1SB: UIFont
+
+ public var caption2: UIFont
+
+ public var caption2SB: UIFont
+
+ public init(values: ElementFonts) {
+ self.largeTitle = values.largeTitle
+ self.largeTitleB = values.largeTitleB
+ self.title1 = values.title1
+ self.title1B = values.title1B
+ self.title2 = values.title2
+ self.title2B = values.title2B
+ self.title3 = values.title3
+ self.title3SB = values.title3SB
+ self.headline = values.headline
+ self.subheadline = values.subheadline
+ self.body = values.body
+ self.bodySB = values.bodySB
+ self.callout = values.callout
+ self.calloutSB = values.calloutSB
+ self.footnote = values.footnote
+ self.footnoteSB = values.footnoteSB
+ self.caption1 = values.caption1
+ self.caption1SB = values.caption1SB
+ self.caption2 = values.caption2
+ self.caption2SB = values.caption2SB
+ }
+}
diff --git a/DesignKit/Source/ThemeV2.swift b/DesignKit/Source/ThemeV2.swift
index 785639861..f04138faf 100644
--- a/DesignKit/Source/ThemeV2.swift
+++ b/DesignKit/Source/ThemeV2.swift
@@ -21,11 +21,23 @@ import UIKit
@objc public protocol ThemeV2 {
/// Colors object
- var colors: Colors { get }
+ var colors: ColorsUIKit { get }
/// Fonts object
- var fonts: Fonts { get }
+ var fonts: FontsUIKit { get }
+
+ /// may contain more design components in future, like icons, audio files etc.
+}
+
+/// Theme v2 for SwiftUI.
+@available(iOS 14.0, *)
+public protocol ThemeSwiftUIType {
+
+ /// Colors object
+ var colors: ColorSwiftUI { get }
+
+ /// Fonts object
+ var fonts: FontSwiftUI { get }
/// may contain more design components in future, like icons, audio files etc.
-
}
diff --git a/DesignKit/Variants/Colors/Dark/DarkColors.swift b/DesignKit/Variants/Colors/Dark/DarkColors.swift
index 39a3b0893..b6b0ba5ed 100644
--- a/DesignKit/Variants/Colors/Dark/DarkColors.swift
+++ b/DesignKit/Variants/Colors/Dark/DarkColors.swift
@@ -16,43 +16,36 @@
import Foundation
import UIKit
+import SwiftUI
-/// Dark theme colors. Will be a struct when things are more Swifty.
-public class DarkColors: Colors {
-
- public let accent: UIColor = UIColor(rgb: 0x0DBD8B)
-
- public let alert: UIColor = UIColor(rgb: 0xFF4B55)
-
- public let primaryContent: UIColor = UIColor(rgb: 0xFFFFFF)
-
- public let secondaryContent: UIColor = UIColor(rgb: 0xA9B2BC)
-
- public let tertiaryContent: UIColor = UIColor(rgb: 0x8E99A4)
-
- public let quarterlyContent: UIColor = UIColor(rgb: 0x6F7882)
-
- public let quinaryContent: UIColor = UIColor(rgb: 0x394049)
-
- public let separator: UIColor = UIColor(rgb: 0x21262C)
-
- public let tile: UIColor = UIColor(rgb: 0x394049)
-
- public let navigation: UIColor = UIColor(rgb: 0x21262C)
-
- public let background: UIColor = UIColor(rgb: 0x15191E)
-
- public let namesAndAvatars: [UIColor] = [
- UIColor(rgb: 0x368BD6),
- UIColor(rgb: 0xAC3BA8),
- UIColor(rgb: 0x03B381),
- UIColor(rgb: 0xE64F7A),
- UIColor(rgb: 0xFF812D),
- UIColor(rgb: 0x2DC2C5),
- UIColor(rgb: 0x5C56F5),
- UIColor(rgb: 0x74D12C)
- ]
-
- public init() {}
+/// Dark theme colors.
+public class DarkColors {
+ private static let values = ColorValues(
+ accent: UIColor(rgb:0x0DBD8B),
+ alert: UIColor(rgb:0xFF4B55),
+ primaryContent: UIColor(rgb:0xFFFFFF),
+ secondaryContent: UIColor(rgb:0xA9B2BC),
+ tertiaryContent: UIColor(rgb:0x8E99A4),
+ quarterlyContent: UIColor(rgb:0x6F7882),
+ quinaryContent: UIColor(rgb:0x394049),
+ separator: UIColor(rgb:0x21262C),
+ system: UIColor(rgb:0x21262C),
+ tile: UIColor(rgb:0x394049),
+ navigation: UIColor(rgb:0x21262C),
+ background: UIColor(rgb:0x15191E),
+ namesAndAvatars: [
+ UIColor(rgb:0x368BD6),
+ UIColor(rgb:0xAC3BA8),
+ UIColor(rgb:0x03B381),
+ UIColor(rgb:0xE64F7A),
+ UIColor(rgb:0xFF812D),
+ UIColor(rgb:0x2DC2C5),
+ UIColor(rgb:0x5C56F5),
+ UIColor(rgb:0x74D12C)
+ ]
+ )
+ public static var uiKit = ColorsUIKit(values: values)
+ @available(iOS 14.0, *)
+ public static var swiftUI = ColorSwiftUI(values: values)
}
diff --git a/DesignKit/Variants/Colors/Light/LightColors.swift b/DesignKit/Variants/Colors/Light/LightColors.swift
index 53a9566e2..2e7d8147a 100644
--- a/DesignKit/Variants/Colors/Light/LightColors.swift
+++ b/DesignKit/Variants/Colors/Light/LightColors.swift
@@ -16,43 +16,42 @@
import Foundation
import UIKit
+import SwiftUI
-/// Light theme colors. Will be a struct when things are more Swifty.
-public class LightColors: Colors {
-
- public let accent: UIColor = UIColor(rgb: 0x0DBD8B)
-
- public let alert: UIColor = UIColor(rgb: 0xFF4B55)
-
- public let primaryContent: UIColor = UIColor(rgb: 0x17191C)
-
- public let secondaryContent: UIColor = UIColor(rgb: 0x737D8C)
-
- public let tertiaryContent: UIColor = UIColor(rgb: 0x8D97A5)
-
- public let quarterlyContent: UIColor = UIColor(rgb: 0xC1C6CD)
-
- public let quinaryContent: UIColor = UIColor(rgb: 0xE3E8F0)
- public let separator: UIColor = UIColor(rgb: 0xE3E8F0)
-
- public let tile: UIColor = UIColor(rgb: 0xF3F8FD)
-
- public let navigation: UIColor = UIColor(rgb: 0xF4F6FA)
-
- public let background: UIColor = UIColor(rgb: 0xFFFFFF)
-
- public let namesAndAvatars: [UIColor] = [
- UIColor(rgb: 0x368BD6),
- UIColor(rgb: 0xAC3BA8),
- UIColor(rgb: 0x03B381),
- UIColor(rgb: 0xE64F7A),
- UIColor(rgb: 0xFF812D),
- UIColor(rgb: 0x2DC2C5),
- UIColor(rgb: 0x5C56F5),
- UIColor(rgb: 0x74D12C)
- ]
-
- public init() {}
+/// Light theme colors.
+public class LightColors {
+ private static let values = ColorValues(
+ accent: UIColor(rgb:0x0DBD8B),
+ alert: UIColor(rgb:0xFF4B55),
+ primaryContent: UIColor(rgb:0x17191C),
+ secondaryContent: UIColor(rgb:0x737D8C),
+ tertiaryContent: UIColor(rgb:0x8D97A5),
+ quarterlyContent: UIColor(rgb:0xC1C6CD),
+ quinaryContent: UIColor(rgb:0xE3E8F0),
+ separator: UIColor(rgb:0xE3E8F0),
+ system: UIColor(rgb:0xF4F6FA),
+ tile: UIColor(rgb:0xF3F8FD),
+ navigation: UIColor(rgb:0xF4F6FA),
+ background: UIColor(rgb:0xFFFFFF),
+ namesAndAvatars: [
+ UIColor(rgb:0x368BD6),
+ UIColor(rgb:0xAC3BA8),
+ UIColor(rgb:0x03B381),
+ UIColor(rgb:0xE64F7A),
+ UIColor(rgb:0xFF812D),
+ UIColor(rgb:0x2DC2C5),
+ UIColor(rgb:0x5C56F5),
+ UIColor(rgb:0x74D12C)
+ ]
+ )
+ public static var uiKit = ColorsUIKit(values: values)
+ @available(iOS 14.0, *)
+ public static var swiftUI = ColorSwiftUI(values: values)
}
+
+
+
+
+
diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift
index 1f1564dea..d0ec69c4f 100644
--- a/Riot/Generated/Strings.swift
+++ b/Riot/Generated/Strings.swift
@@ -5143,13 +5143,11 @@ extension VectorL10n {
static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "")
let locale: Locale
-// if let localeIdentifier = Bundle.mxk_language() {
-// locale = Locale(identifier: localeIdentifier)
-// } else if let fallbackLocaleIdentifier = Bundle.mxk_fallbackLanguage() {
-// locale = Locale(identifier: fallbackLocaleIdentifier)
-// } else {
- locale = Locale.current
-// }
+ if let providedLocale = LocaleProvider.locale {
+ locale = providedLocale
+ } else {
+ locale = Locale.current
+ }
return String(format: format, locale: locale, arguments: args)
}
diff --git a/Riot/Managers/Locale/LocaleProvider.swift b/Riot/Managers/Locale/LocaleProvider.swift
new file mode 100644
index 000000000..de5e6f746
--- /dev/null
+++ b/Riot/Managers/Locale/LocaleProvider.swift
@@ -0,0 +1,31 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+
+/**
+ Provides the locale logic for Riot app based on mx languages.
+ */
+class LocaleProvider: LocaleProviderType {
+ static var locale: Locale? {
+ if let localeIdentifier = Bundle.mxk_language() {
+ return Locale(identifier: localeIdentifier)
+ } else if let fallbackLocaleIdentifier = Bundle.mxk_fallbackLanguage() {
+ return Locale(identifier: fallbackLocaleIdentifier)
+ }
+ return nil
+ }
+}
diff --git a/Riot/Managers/Locale/LocaleProviderType.swift b/Riot/Managers/Locale/LocaleProviderType.swift
new file mode 100644
index 000000000..ea2d6c847
--- /dev/null
+++ b/Riot/Managers/Locale/LocaleProviderType.swift
@@ -0,0 +1,24 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+
+/**
+ Used to provide an application/target specific locale.
+ */
+protocol LocaleProviderType {
+ static var locale: Locale? { get }
+}
diff --git a/Riot/Managers/Theme/Themes/DarkTheme.swift b/Riot/Managers/Theme/Themes/DarkTheme.swift
index 7ce49c214..f1ef31000 100644
--- a/Riot/Managers/Theme/Themes/DarkTheme.swift
+++ b/Riot/Managers/Theme/Themes/DarkTheme.swift
@@ -142,12 +142,8 @@ class DarkTheme: NSObject, Theme {
}
/// MARK: - Theme v2
+ var colors: ColorsUIKit = DarkColors.uiKit
- lazy var colors: Colors = {
- return DarkColors()
- }()
+ var fonts: FontsUIKit = FontsUIKit(values: ElementFonts())
- lazy var fonts: Fonts = {
- return ElementFonts()
- }()
}
diff --git a/Riot/Managers/Theme/Themes/DefaultTheme.swift b/Riot/Managers/Theme/Themes/DefaultTheme.swift
index 770f33a90..65df6047b 100644
--- a/Riot/Managers/Theme/Themes/DefaultTheme.swift
+++ b/Riot/Managers/Theme/Themes/DefaultTheme.swift
@@ -149,12 +149,7 @@ class DefaultTheme: NSObject, Theme {
}
/// MARK: - Theme v2
+ var colors: ColorsUIKit = LightColors.uiKit
- lazy var colors: Colors = {
- return LightColors()
- }()
-
- lazy var fonts: Fonts = {
- return ElementFonts()
- }()
+ var fonts: FontsUIKit = FontsUIKit(values: ElementFonts())
}
diff --git a/Riot/Modules/Application/AppCoordinator.swift b/Riot/Modules/Application/AppCoordinator.swift
index 8a1949f75..12cc4e3f3 100755
--- a/Riot/Modules/Application/AppCoordinator.swift
+++ b/Riot/Modules/Application/AppCoordinator.swift
@@ -103,6 +103,18 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
private func setupTheme() {
ThemeService.shared().themeId = RiotSettings.shared.userInterfaceTheme
+ if #available(iOS 14.0, *) {
+ guard let themeId = ThemeService.shared().themeIdentifier else {
+ MXLog.error("[AppCoordinator] No theme id found to update ThemePublisher")
+ return
+ }
+ ThemePublisher.configure(themeId: themeId)
+ let themeIdPublisher = NotificationCenter.default.publisher(for: Notification.Name.themeServiceDidChangeTheme)
+ .compactMap({ _ in ThemeService.shared().themeIdentifier })
+ .eraseToAnyPublisher()
+
+ ThemePublisher.shared.republish(themeIdPublisher: themeIdPublisher)
+ }
}
private func showAuthentication() {
diff --git a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsCoordinator.swift b/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsCoordinator.swift
index 9b64c258d..fca84e95a 100644
--- a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsCoordinator.swift
+++ b/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsCoordinator.swift
@@ -39,24 +39,23 @@ final class RoomNotificationSettingsCoordinator: RoomNotificationSettingsCoordin
init(room: MXRoom, presentedModally: Bool = true) {
let roomNotificationService = RoomNotificationSettingsService(room: room)
- let avatarData: AvatarInputOption?
+ let avatarData: AvatarType?
let showAvatar = presentedModally
if #available(iOS 14.0.0, *) {
- avatarData = showAvatar ? .swiftUI(AvatarInput(
+ avatarData = showAvatar ? AvatarInput(
mxContentUri: room.summary.avatar,
matrixItemId: room.roomId,
displayName: room.summary.displayname
- )) : nil
+ ) : nil
} else {
- avatarData = showAvatar ? .uiKit(RoomAvatarViewData(
+ avatarData = showAvatar ? RoomAvatarViewData(
roomId: room.roomId,
displayName: room.summary.displayname,
avatarUrl: room.summary.avatar,
mediaManager: room.mxSession.mediaManager
- )) : nil
+ ) : nil
}
-
let viewModel: RoomNotificationSettingsViewModel
let viewController: UIViewController
if #available(iOS 14.0.0, *) {
diff --git a/Riot/Modules/Room/NotificationSettings/UIKit/RoomNotificationSettingsViewController.swift b/Riot/Modules/Room/NotificationSettings/UIKit/RoomNotificationSettingsViewController.swift
index d9135c0c7..87445c38e 100644
--- a/Riot/Modules/Room/NotificationSettings/UIKit/RoomNotificationSettingsViewController.swift
+++ b/Riot/Modules/Room/NotificationSettings/UIKit/RoomNotificationSettingsViewController.swift
@@ -144,7 +144,7 @@ final class RoomNotificationSettingsViewController: UIViewController {
activityPresenter.removeCurrentActivityIndicator(animated: true)
}
self.viewState = viewState
- if case let .uiKit(avatarData) = viewState.avatarData {
+ if let avatarData = viewState.avatarData as? AvatarViewDataProtocol {
mainTableView.tableHeaderView = avatarView
avatarView.configure(viewData: avatarData)
avatarView.update(theme: theme)
diff --git a/Riot/Modules/Settings/Notifications/MXPushRuleMatching.swift b/Riot/Modules/Settings/Notifications/MXPushRuleMatching.swift
index 113cb6c6d..340f24e26 100644
--- a/Riot/Modules/Settings/Notifications/MXPushRuleMatching.swift
+++ b/Riot/Modules/Settings/Notifications/MXPushRuleMatching.swift
@@ -15,23 +15,26 @@
//
import Foundation
+import DesignKit
-
-fileprivate extension MXPushRule {
+/**
+ Conformance of MXPushRule to the abstraction `NotificationPushRule` for use in `NotificationSettingsViewModel`.
+ */
+extension MXPushRule: NotificationPushRule {
/*
Given a rule, check it match the actions in the static definition.
*/
- private func maches(targetRule: NotificationStandardActions?) -> Bool {
- guard let targetRule = targetRule else {
+ func matches(standardActions: NotificationStandardActions?) -> Bool {
+ guard let standardActions = standardActions else {
return false
}
- if !enabled && targetRule == .disabled {
+ if !enabled && standardActions == .disabled {
return true
}
if enabled,
- let actions = targetRule.actions,
+ let actions = standardActions.actions,
highlight == actions.highlight,
sound == actions.sound,
notify == actions.notify,
@@ -41,14 +44,13 @@ fileprivate extension MXPushRule {
return false
}
- func getAction(actionType: MXPushRuleActionType, tweakType: String? = nil) -> MXPushRuleAction? {
+ private func getAction(actionType: MXPushRuleActionType, tweakType: String? = nil) -> MXPushRuleAction? {
guard let actions = actions as? [MXPushRuleAction] else {
return nil
}
return actions.first { action in
var match = action.actionType == actionType
- MXLog.debug("action \(action)")
if let tweakType = tweakType,
let actionTweak = action.parameters?["set_tweak"] as? String {
match = match && (tweakType == actionTweak)
diff --git a/Riot/Modules/Settings/Notifications/NotificationSettingsService.swift b/Riot/Modules/Settings/Notifications/NotificationSettingsService.swift
index 7fd3ff42b..515c79545 100644
--- a/Riot/Modules/Settings/Notifications/NotificationSettingsService.swift
+++ b/Riot/Modules/Settings/Notifications/NotificationSettingsService.swift
@@ -26,12 +26,12 @@ class NotificationSettingsService: NotificationSettingsServiceType {
@Published private var contentRules = [MXPushRule]()
@Published private var rules = [MXPushRule]()
- var rulesPublisher: AnyPublisher<[MXPushRule], Never> {
- $rules.eraseToAnyPublisher()
+ var rulesPublisher: AnyPublisher<[NotificationPushRule], Never> {
+ $rules.map({ $0.map({ $0 as NotificationPushRule }) }).eraseToAnyPublisher()
}
- var contentRulesPublisher: AnyPublisher<[MXPushRule], Never> {
- $contentRules.eraseToAnyPublisher()
+ var contentRulesPublisher: AnyPublisher<[NotificationPushRule], Never> {
+ $contentRules.map({ $0.map({ $0 as NotificationPushRule }) }).eraseToAnyPublisher()
}
init(session: MXSession) {
diff --git a/Riot/target.yml b/Riot/target.yml
index f7e279df1..5693b5716 100644
--- a/Riot/target.yml
+++ b/Riot/target.yml
@@ -26,18 +26,6 @@ schemes:
- RiotTests
targets:
- RiotSwiftUI:
- type: framework
- platform: iOS
- dependencies:
- - target: DesignKit
- sources:
- - path: ModulesSwiftUI
- - path: Generated/Strings.swift
- - path: Generated/Images.swift
- - path: Managers/Theme/Theme.swift
- - path: Managers/Theme/ThemeIdentifier.swift
- - path: Categories/UIColor.swift
Riot:
type: application
platform: iOS
@@ -47,7 +35,6 @@ targets:
- target: SiriIntents
- target: RiotNSE
- target: DesignKit
- - target: RiotSwiftUI
configFiles:
Debug: Debug.xcconfig
@@ -64,6 +51,10 @@ targets:
script: "\"${PODS_ROOT}/SwiftGen/bin/swiftgen\" config run --config \"Tools/SwiftGen/swiftgen-config.yml\"\n"
sources:
+ - path: ../RiotSwiftUI/Modules
+ # Riot will provide it's own LocaleProviderType so exclude.
+ excludes:
+ - "Common/Locale/LocaleProvider.swift"
- path: ../Tools
excludes:
- "Logs"
diff --git a/RiotNSE/target.yml b/RiotNSE/target.yml
index edfbb540a..529fda313 100644
--- a/RiotNSE/target.yml
+++ b/RiotNSE/target.yml
@@ -48,6 +48,8 @@ targets:
- path: ../Riot/Modules/SetPinCode/SetupBiometrics/BiometricsAuthenticationPresenter.swift
- path: ../Riot/Categories/UNUserNotificationCenter.swift
- path: ../Riot/Managers/KeyValueStorage/KeyValueStore.swift
+ - path: ../Riot/Managers/Locale/LocaleProvider.swift
+ - path: ../Riot/Managers/Locale/LocaleProviderType.swift
- path: ../Riot/Managers/EncryptionKeyManager/EncryptionKeyManager.swift
- path: ../Riot/Categories/Bundle.swift
- path: ../Riot/Generated/Strings.swift
diff --git a/RiotSwiftUI/Common.xcconfig b/RiotSwiftUI/Common.xcconfig
new file mode 100644
index 000000000..e7cb586cf
--- /dev/null
+++ b/RiotSwiftUI/Common.xcconfig
@@ -0,0 +1,28 @@
+//
+// Copyright 2021 Vector Creations Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// Configuration settings file format documentation can be found at:
+// https://help.apple.com/xcode/#/dev745c5c974
+
+#include "Config/AppIdentifiers.xcconfig"
+#include "Config/AppVersion.xcconfig"
+
+PRODUCT_NAME = RiotSwiftUI
+PRODUCT_BUNDLE_IDENTIFIER = $(BASE_BUNDLE_IDENTIFIER).riotswiftui
+
+INFOPLIST_FILE = RiotSwiftUI/Info.plist
+
+SKIP_INSTALL = YES
diff --git a/RiotSwiftUI/Debug.xcconfig b/RiotSwiftUI/Debug.xcconfig
new file mode 100644
index 000000000..11a7288a4
--- /dev/null
+++ b/RiotSwiftUI/Debug.xcconfig
@@ -0,0 +1,20 @@
+//
+// Copyright 2021 Vector Creations Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// Configuration settings file format documentation can be found at:
+// https://help.apple.com/xcode/#/dev745c5c974
+
+#include "Common.xcconfig"
diff --git a/RiotSwiftUI/Info.plist b/RiotSwiftUI/Info.plist
new file mode 100644
index 000000000..c0701c6d7
--- /dev/null
+++ b/RiotSwiftUI/Info.plist
@@ -0,0 +1,22 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ $(DEVELOPMENT_LANGUAGE)
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ $(PRODUCT_BUNDLE_PACKAGE_TYPE)
+ CFBundleShortVersionString
+ $(MARKETING_VERSION)
+ CFBundleVersion
+ $(CURRENT_PROJECT_VERSION)
+
+
diff --git a/Riot/ModulesSwiftUI/Common/ActivityIndicator/ActivityIndicator.swift b/RiotSwiftUI/Modules/Common/ActivityIndicator/ActivityIndicator.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/ActivityIndicator/ActivityIndicator.swift
rename to RiotSwiftUI/Modules/Common/ActivityIndicator/ActivityIndicator.swift
diff --git a/Riot/ModulesSwiftUI/Common/ActivityIndicator/ActivityIndicatorModifier.swift b/RiotSwiftUI/Modules/Common/ActivityIndicator/ActivityIndicatorModifier.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/ActivityIndicator/ActivityIndicatorModifier.swift
rename to RiotSwiftUI/Modules/Common/ActivityIndicator/ActivityIndicatorModifier.swift
diff --git a/Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarInput.swift b/RiotSwiftUI/Modules/Common/Avatar/Mock/MockAvatarInput.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarInput.swift
rename to RiotSwiftUI/Modules/Common/Avatar/Mock/MockAvatarInput.swift
diff --git a/Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarService.swift b/RiotSwiftUI/Modules/Common/Avatar/Mock/MockAvatarService.swift
similarity index 92%
rename from Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarService.swift
rename to RiotSwiftUI/Modules/Common/Avatar/Mock/MockAvatarService.swift
index 0ee87d429..92b31af71 100644
--- a/Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarService.swift
+++ b/RiotSwiftUI/Modules/Common/Avatar/Mock/MockAvatarService.swift
@@ -24,7 +24,7 @@ class MockAvatarService: AvatarServiceType {
static let example: AvatarServiceType = MockAvatarService()
func avatarImage(mxContentUri: String, avatarSize: AvatarSize) -> Future {
Future { promise in
- promise(.success(Asset.Images.appSymbol.image))
+ promise(.success(Asset.Images.appSymbol.image))
}
}
}
diff --git a/Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarInputType.swift b/RiotSwiftUI/Modules/Common/Avatar/Model/AvatarInputType.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarInputType.swift
rename to RiotSwiftUI/Modules/Common/Avatar/Model/AvatarInputType.swift
diff --git a/Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarType.swift b/RiotSwiftUI/Modules/Common/Avatar/Model/AvatarType.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarType.swift
rename to RiotSwiftUI/Modules/Common/Avatar/Model/AvatarType.swift
diff --git a/Riot/ModulesSwiftUI/Common/Avatar/View/AvatarImage.swift b/RiotSwiftUI/Modules/Common/Avatar/View/AvatarImage.swift
similarity index 94%
rename from Riot/ModulesSwiftUI/Common/Avatar/View/AvatarImage.swift
rename to RiotSwiftUI/Modules/Common/Avatar/View/AvatarImage.swift
index 3aedff02d..4594b9ff6 100644
--- a/Riot/ModulesSwiftUI/Common/Avatar/View/AvatarImage.swift
+++ b/RiotSwiftUI/Modules/Common/Avatar/View/AvatarImage.swift
@@ -20,7 +20,7 @@ import DesignKit
@available(iOS 14.0, *)
struct AvatarImage: View {
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
@Environment(\.dependencies) var dependencies: DependencyContainer
@StateObject var viewModel = AvatarViewModel()
@@ -39,7 +39,7 @@ struct AvatarImage: View {
.padding(4)
.frame(width: CGFloat(size.rawValue), height: CGFloat(size.rawValue))
.foregroundColor(.white)
- .background(Color(theme.avatarColors[colorIndex]))
+ .background(theme.colors.namesAndAvatars[colorIndex])
.clipShape(Circle())
// Make the text resizable (i.e. Make it large and then allow it to scale down)
.font(.system(size: 200))
@@ -57,7 +57,7 @@ struct AvatarImage: View {
mxContentUri: mxContentUri,
matrixItemId: matrixItemId,
displayName: displayName,
- colorCount: theme.avatarColors.count,
+ colorCount: theme.colors.namesAndAvatars.count,
avatarSize: size
)
}
diff --git a/Riot/ModulesSwiftUI/Common/ViewModel/AvatarServiceType.swift b/RiotSwiftUI/Modules/Common/Avatar/ViewModel/AvatarServiceType.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/ViewModel/AvatarServiceType.swift
rename to RiotSwiftUI/Modules/Common/Avatar/ViewModel/AvatarServiceType.swift
diff --git a/Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewModel.swift b/RiotSwiftUI/Modules/Common/Avatar/ViewModel/AvatarViewModel.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewModel.swift
rename to RiotSwiftUI/Modules/Common/Avatar/ViewModel/AvatarViewModel.swift
diff --git a/Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewState.swift b/RiotSwiftUI/Modules/Common/Avatar/ViewModel/AvatarViewState.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewState.swift
rename to RiotSwiftUI/Modules/Common/Avatar/ViewModel/AvatarViewState.swift
diff --git a/Riot/ModulesSwiftUI/Common/Bridging/VectorContentView.swift b/RiotSwiftUI/Modules/Common/Bridging/VectorContentView.swift
similarity index 83%
rename from Riot/ModulesSwiftUI/Common/Bridging/VectorContentView.swift
rename to RiotSwiftUI/Modules/Common/Bridging/VectorContentView.swift
index 2b85aa7cf..9dac8ec08 100644
--- a/Riot/ModulesSwiftUI/Common/Bridging/VectorContentView.swift
+++ b/RiotSwiftUI/Modules/Common/Bridging/VectorContentView.swift
@@ -23,17 +23,17 @@ import SwiftUI
@available(iOS 14.0, *)
struct VectorContentModifier: ViewModifier {
- @StateObject private var themeObserver = ThemeObserver.shared
+ @ObservedObject private var themePublisher = ThemePublisher.shared
func body(content: Content) -> some View {
content
- .theme(themeObserver.theme)
+ .theme(themePublisher.theme)
}
}
@available(iOS 14.0, *)
extension View {
- func vectorContent() -> some View {
- self.modifier(VectorContentModifier())
- }
+ func vectorContent() -> some View {
+ self.modifier(VectorContentModifier())
+ }
}
diff --git a/Riot/ModulesSwiftUI/Common/DependencyInjection/DependencyContainer.swift b/RiotSwiftUI/Modules/Common/DependencyInjection/DependencyContainer.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/DependencyInjection/DependencyContainer.swift
rename to RiotSwiftUI/Modules/Common/DependencyInjection/DependencyContainer.swift
diff --git a/Riot/ModulesSwiftUI/Common/DependencyInjection/DependencyContainerKey.swift b/RiotSwiftUI/Modules/Common/DependencyInjection/DependencyContainerKey.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/DependencyInjection/DependencyContainerKey.swift
rename to RiotSwiftUI/Modules/Common/DependencyInjection/DependencyContainerKey.swift
diff --git a/Riot/ModulesSwiftUI/Common/DependencyInjection/Inject.swift b/RiotSwiftUI/Modules/Common/DependencyInjection/Inject.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/DependencyInjection/Inject.swift
rename to RiotSwiftUI/Modules/Common/DependencyInjection/Inject.swift
diff --git a/Riot/ModulesSwiftUI/Common/DependencyInjection/Injectable.swift b/RiotSwiftUI/Modules/Common/DependencyInjection/Injectable.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/DependencyInjection/Injectable.swift
rename to RiotSwiftUI/Modules/Common/DependencyInjection/Injectable.swift
diff --git a/Riot/ModulesSwiftUI/Common/DependencyInjection/InjectableObject.swift b/RiotSwiftUI/Modules/Common/DependencyInjection/InjectableObject.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/DependencyInjection/InjectableObject.swift
rename to RiotSwiftUI/Modules/Common/DependencyInjection/InjectableObject.swift
diff --git a/Riot/Categories/Combine/Publisher.swift b/RiotSwiftUI/Modules/Common/Extensions/Publisher.swift
similarity index 100%
rename from Riot/Categories/Combine/Publisher.swift
rename to RiotSwiftUI/Modules/Common/Extensions/Publisher.swift
diff --git a/Riot/Modules/Common/Avatar/AvatarInputOption.swift b/RiotSwiftUI/Modules/Common/Locale/LocaleProvider.swift
similarity index 85%
rename from Riot/Modules/Common/Avatar/AvatarInputOption.swift
rename to RiotSwiftUI/Modules/Common/Locale/LocaleProvider.swift
index cebe9f948..a1ba74921 100644
--- a/Riot/Modules/Common/Avatar/AvatarInputOption.swift
+++ b/RiotSwiftUI/Modules/Common/Locale/LocaleProvider.swift
@@ -16,7 +16,8 @@
import Foundation
-enum AvatarInputOption {
- case swiftUI(AvatarInputType)
- case uiKit(AvatarViewDataProtocol)
+class LocaleProvider: LocaleProviderType {
+ static var locale: Locale? {
+ return nil
+ }
}
diff --git a/Riot/ModulesSwiftUI/Common/Theme/ThemeObserver.swift b/RiotSwiftUI/Modules/Common/Theme/ThemeIdentifierExtensions.swift
similarity index 59%
rename from Riot/ModulesSwiftUI/Common/Theme/ThemeObserver.swift
rename to RiotSwiftUI/Modules/Common/Theme/ThemeIdentifierExtensions.swift
index 30f659454..f9e6530ed 100644
--- a/Riot/ModulesSwiftUI/Common/Theme/ThemeObserver.swift
+++ b/RiotSwiftUI/Modules/Common/Theme/ThemeIdentifierExtensions.swift
@@ -15,22 +15,21 @@
//
import Foundation
-import Combine
+import DesignKit
+/**
+ Extension to `ThemeIdentifier` for getting the SwiftUI theme.
+ */
@available(iOS 14.0, *)
-class ThemeObserver: ObservableObject {
-
- static let shared = ThemeObserver()
-
- init() {
- NotificationCenter.default.publisher(for: NSNotification.Name.themeServiceDidChangeTheme).map { _ in
- ThemeService.shared().theme
- }.assign(to: &$theme)
+extension ThemeIdentifier {
+ fileprivate static let defaultTheme = DefaultThemeSwiftUI()
+ fileprivate static let darkTheme = DarkThemeSwiftUI()
+ public var themeSwiftUI: ThemeSwiftUI {
+ switch self {
+ case .light:
+ return Self.defaultTheme
+ case .dark, .black:
+ return Self.darkTheme
+ }
}
- @Published var theme: Theme = ThemeService.shared().theme
-}
-
-
-class ThemePublisher: ObservableObject {
- static let shared = ThemePublisher()
}
diff --git a/Riot/ModulesSwiftUI/Common/Theme/ThemeKey.swift b/RiotSwiftUI/Modules/Common/Theme/ThemeKey.swift
similarity index 85%
rename from Riot/ModulesSwiftUI/Common/Theme/ThemeKey.swift
rename to RiotSwiftUI/Modules/Common/Theme/ThemeKey.swift
index c948ea9f3..f1ea41cea 100644
--- a/Riot/ModulesSwiftUI/Common/Theme/ThemeKey.swift
+++ b/RiotSwiftUI/Modules/Common/Theme/ThemeKey.swift
@@ -16,14 +16,16 @@
import Foundation
import SwiftUI
+import DesignKit
+@available(iOS 14.0, *)
private struct ThemeKey: EnvironmentKey {
- static let defaultValue = ThemeService.shared().theme
+ static let defaultValue = ThemePublisher.shared.theme
}
@available(iOS 14.0, *)
extension EnvironmentValues {
- var theme: Theme {
+ var theme: ThemeSwiftUI {
get { self[ThemeKey.self] }
set { self[ThemeKey.self] = newValue }
}
@@ -36,7 +38,7 @@ extension EnvironmentValues {
*/
@available(iOS 14.0, *)
extension View {
- func theme(_ theme: Theme) -> some View {
+ func theme(_ theme: ThemeSwiftUI) -> some View {
environment(\.theme, theme)
}
}
@@ -49,7 +51,6 @@ extension View {
@available(iOS 14.0, *)
extension View {
func theme(_ themeId: ThemeIdentifier) -> some View {
- let theme = ThemeService.shared().theme(withThemeId: themeId.rawValue)
- return environment(\.theme, theme)
+ return environment(\.theme, themeId.themeSwiftUI)
}
}
diff --git a/RiotSwiftUI/Modules/Common/Theme/ThemePublisher.swift b/RiotSwiftUI/Modules/Common/Theme/ThemePublisher.swift
new file mode 100644
index 000000000..c52f5337a
--- /dev/null
+++ b/RiotSwiftUI/Modules/Common/Theme/ThemePublisher.swift
@@ -0,0 +1,51 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+import Combine
+
+/**
+ 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 calss on the `ThemeService`.
+ */
+@available(iOS 14.0, *)
+class ThemePublisher: ObservableObject {
+
+ private static var _shared: ThemePublisher? = nil
+ static var shared: ThemePublisher {
+ if _shared == nil {
+ configure(themeId: .light)
+ }
+ return _shared!
+ }
+
+ @Published private(set) var theme: ThemeSwiftUI
+
+ static func configure(themeId: ThemeIdentifier) {
+ _shared = ThemePublisher(themeId: .light)
+ }
+
+ init(themeId: ThemeIdentifier) {
+ _theme = Published.init(initialValue: themeId.themeSwiftUI)
+ }
+
+ func republish(themeIdPublisher: AnyPublisher) {
+ themeIdPublisher
+ .map(\.themeSwiftUI)
+ .assign(to: &$theme)
+ }
+}
diff --git a/RiotSwiftUI/Modules/Common/Theme/ThemeSwiftUI.swift b/RiotSwiftUI/Modules/Common/Theme/ThemeSwiftUI.swift
new file mode 100644
index 000000000..3f633a5e8
--- /dev/null
+++ b/RiotSwiftUI/Modules/Common/Theme/ThemeSwiftUI.swift
@@ -0,0 +1,23 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+import DesignKit
+
+@available(iOS 14.0, *)
+protocol ThemeSwiftUI: ThemeSwiftUIType {
+ var identifier: ThemeIdentifier { get }
+}
diff --git a/RiotSwiftUI/Modules/Common/Theme/Themes/DarkThemeSwiftUI.swift b/RiotSwiftUI/Modules/Common/Theme/Themes/DarkThemeSwiftUI.swift
new file mode 100644
index 000000000..778809553
--- /dev/null
+++ b/RiotSwiftUI/Modules/Common/Theme/Themes/DarkThemeSwiftUI.swift
@@ -0,0 +1,25 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+import DesignKit
+
+@available(iOS 14.0, *)
+struct DarkThemeSwiftUI: ThemeSwiftUI {
+ var identifier: ThemeIdentifier = .dark
+ var colors: ColorSwiftUI = DarkColors.swiftUI
+ var fonts: FontSwiftUI = FontSwiftUI(values: ElementFonts())
+}
diff --git a/RiotSwiftUI/Modules/Common/Theme/Themes/DefaultThemeSwiftUI.swift b/RiotSwiftUI/Modules/Common/Theme/Themes/DefaultThemeSwiftUI.swift
new file mode 100644
index 000000000..a7e5e9909
--- /dev/null
+++ b/RiotSwiftUI/Modules/Common/Theme/Themes/DefaultThemeSwiftUI.swift
@@ -0,0 +1,25 @@
+//
+// Copyright 2021 New Vector Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+import Foundation
+import DesignKit
+
+@available(iOS 14.0, *)
+struct DefaultThemeSwiftUI: ThemeSwiftUI {
+ var identifier: ThemeIdentifier = .light
+ var colors: ColorSwiftUI = LightColors.swiftUI
+ var fonts: FontSwiftUI = FontSwiftUI(values: ElementFonts())
+}
diff --git a/Riot/ModulesSwiftUI/Common/ViewFrameReader/ViewFrameReader.swift b/RiotSwiftUI/Modules/Common/ViewFrameReader/ViewFrameReader.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Common/ViewFrameReader/ViewFrameReader.swift
rename to RiotSwiftUI/Modules/Common/ViewFrameReader/ViewFrameReader.swift
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/Mock/MockRoomNotificationSettingsService.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/Mock/MockRoomNotificationSettingsService.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/Mock/MockRoomNotificationSettingsService.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/Mock/MockRoomNotificationSettingsService.swift
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/Model/RoomNotificationState.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/Model/RoomNotificationState.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/Model/RoomNotificationState.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/Model/RoomNotificationState.swift
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormItemButtonStyle.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormItemButtonStyle.swift
similarity index 75%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormItemButtonStyle.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/View/FormItemButtonStyle.swift
index efc401b25..326f3fb85 100644
--- a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormItemButtonStyle.swift
+++ b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormItemButtonStyle.swift
@@ -19,11 +19,11 @@ import SwiftUI
@available(iOS 14.0, *)
struct FormItemButtonStyle: ButtonStyle {
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
- .background(configuration.isPressed ? Color(theme.selectedBackgroundColor) : Color(theme.backgroundColor))
- .foregroundColor(Color(theme.textPrimaryColor))
- .font(Font(theme.fonts.body))
+ .background(configuration.isPressed ? theme.colors.system : theme.colors.background)
+ .foregroundColor(theme.colors.primaryContent)
+ .font(theme.fonts.body)
}
}
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormPickerItem.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormPickerItem.swift
similarity index 93%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormPickerItem.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/View/FormPickerItem.swift
index c0f183991..7c12de11b 100644
--- a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormPickerItem.swift
+++ b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormPickerItem.swift
@@ -21,7 +21,7 @@ struct FormPickerItem: View {
typealias TapCallback = () -> Void
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
var title: String
var selected: Bool
@@ -38,7 +38,7 @@ struct FormPickerItem: View {
Spacer()
if selected {
Image("checkmark")
- .foregroundColor(Color(theme.tintColor))
+ .foregroundColor(theme.colors.accent)
}
}
.padding(.trailing)
@@ -55,6 +55,7 @@ struct FormPickerItem: View {
@available(iOS 14.0, *)
struct FormPickerItem_Previews: PreviewProvider {
+
static let items = ["Item 1", "Item 2", "Item 3"]
static var selected: String = items[0]
static var previews: some View {
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionFooter.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionFooter.swift
similarity index 90%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionFooter.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionFooter.swift
index 3e23534e9..190a397f6 100644
--- a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionFooter.swift
+++ b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionFooter.swift
@@ -19,16 +19,16 @@ import SwiftUI
@available(iOS 14.0, *)
struct FormSectionFooter: View {
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
var text: String
var body: some View {
Text(text)
- .foregroundColor(Color(theme.textSecondaryColor))
+ .foregroundColor(theme.colors.secondaryContent)
.padding(.top)
.padding(.leading)
.padding(.trailing)
- .font(Font(theme.fonts.callout))
+ .font(theme.fonts.callout)
}
}
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionHeader.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionHeader.swift
similarity index 90%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionHeader.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionHeader.swift
index 1c8845b54..54bd4def2 100644
--- a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionHeader.swift
+++ b/RiotSwiftUI/Modules/Room/NotificationSettings/View/FormSectionHeader.swift
@@ -19,16 +19,16 @@ import SwiftUI
@available(iOS 14.0, *)
struct FormSectionHeader: View {
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
var text: String
var body: some View {
Text(text)
- .foregroundColor(Color(theme.textSecondaryColor))
+ .foregroundColor(theme.colors.secondaryContent)
.padding(.top, 32)
.padding(.leading)
.padding(.bottom, 8)
- .font(Font(theme.fonts.subheadline))
+ .font(theme.fonts.subheadline)
.textCase(.uppercase)
.frame(maxWidth: .infinity, alignment: .leading)
}
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettings.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/View/RoomNotificationSettings.swift
similarity index 97%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettings.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/View/RoomNotificationSettings.swift
index 3a40a7b1a..9490635b7 100644
--- a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettings.swift
+++ b/RiotSwiftUI/Modules/Room/NotificationSettings/View/RoomNotificationSettings.swift
@@ -41,7 +41,7 @@ struct RoomNotificationSettings: View {
var body: some View {
VectorForm {
- if case let .swiftUI(avatarData) = viewModel.viewState.avatarData {
+ if let avatarData = viewModel.viewState.avatarData as? AvatarInputType {
RoomNotificationSettingsHeader(
avatarData: avatarData,
displayName: viewModel.viewState.displayName
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettingsHeader.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/View/RoomNotificationSettingsHeader.swift
similarity index 89%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettingsHeader.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/View/RoomNotificationSettingsHeader.swift
index 9a8e00294..80af68030 100644
--- a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettingsHeader.swift
+++ b/RiotSwiftUI/Modules/Room/NotificationSettings/View/RoomNotificationSettingsHeader.swift
@@ -19,7 +19,7 @@ import SwiftUI
@available(iOS 14.0, *)
struct RoomNotificationSettingsHeader: View {
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
var avatarData: AvatarInputType
var displayName: String?
@@ -30,8 +30,8 @@ struct RoomNotificationSettingsHeader: View {
AvatarImage(avatarData: avatarData, size: .xxLarge)
if let displayName = displayName {
Text(displayName)
- .font(Font(theme.fonts.title3SB))
- .foregroundColor(Color(theme.textPrimaryColor))
+ .font(theme.fonts.title3SB)
+ .foregroundColor(theme.colors.primaryContent)
.textCase(nil)
}
}
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/VectorForm.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/View/VectorForm.swift
similarity index 95%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/View/VectorForm.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/View/VectorForm.swift
index 25dc2ee23..10271ec14 100644
--- a/Riot/ModulesSwiftUI/Room/NotificationSettings/View/VectorForm.swift
+++ b/RiotSwiftUI/Modules/Room/NotificationSettings/View/VectorForm.swift
@@ -19,7 +19,7 @@ import SwiftUI
@available(iOS 14.0, *)
struct VectorForm: View {
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
var content: () -> Content
init(@ViewBuilder content: @escaping () -> Content) {
@@ -37,7 +37,7 @@ struct VectorForm: View {
maxHeight: .infinity,
alignment: .top
)
- .background(Color(theme.baseColor))
+ .background(theme.colors.system)
.edgesIgnoringSafeArea(.bottom)
}
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSerivceType.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSerivceType.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSerivceType.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSerivceType.swift
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSwiftUIViewModel.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSwiftUIViewModel.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSwiftUIViewModel.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSwiftUIViewModel.swift
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewAction.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewAction.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewAction.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewAction.swift
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModel.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModel.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModel.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModel.swift
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModelType.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModelType.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModelType.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModelType.swift
diff --git a/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewStateType.swift b/RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewStateType.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewStateType.swift
rename to RiotSwiftUI/Modules/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewStateType.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationPusRule.swift b/RiotSwiftUI/Modules/Settings/Notifications/Mock/MockNotificationPusRule.swift
similarity index 97%
rename from Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationPusRule.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/Mock/MockNotificationPusRule.swift
index 869ed2f23..98ae66306 100644
--- a/Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationPusRule.swift
+++ b/RiotSwiftUI/Modules/Settings/Notifications/Mock/MockNotificationPusRule.swift
@@ -17,7 +17,7 @@
import Foundation
struct MockNotificationPushRule: NotificationPushRule {
- var ruleId: String
+ var ruleId: String!
var enabled: Bool
func matches(standardActions: NotificationStandardActions?) -> Bool {
return false
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationSettingsService.swift b/RiotSwiftUI/Modules/Settings/Notifications/Mock/MockNotificationSettingsService.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationSettingsService.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/Mock/MockNotificationSettingsService.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationActions.swift b/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationActions.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationActions.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationActions.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationIndex.swift b/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationIndex.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationIndex.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationIndex.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRule.swift b/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationPushRule.swift
similarity index 95%
rename from Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRule.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationPushRule.swift
index fd9cb88e1..781870168 100644
--- a/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRule.swift
+++ b/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationPushRule.swift
@@ -17,7 +17,7 @@
import Foundation
protocol NotificationPushRule {
- var ruleId: String { get }
+ var ruleId: String! { get }
var enabled: Bool { get }
func matches(standardActions: NotificationStandardActions?) -> Bool
}
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRuleIds.swift b/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationPushRuleIds.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRuleIds.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationPushRuleIds.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationSettingsScreen.swift b/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationSettingsScreen.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationSettingsScreen.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationSettingsScreen.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationStandardActions.swift b/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationStandardActions.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationStandardActions.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationStandardActions.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Model/PushRuleDefinitions.swift b/RiotSwiftUI/Modules/Settings/Notifications/Model/PushRuleDefinitions.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/Model/PushRuleDefinitions.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/Model/PushRuleDefinitions.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/BorderedInputFieldStyle.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/BorderedInputFieldStyle.swift
similarity index 86%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/BorderedInputFieldStyle.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/BorderedInputFieldStyle.swift
index f11bf90d4..24fcc06f1 100644
--- a/Riot/ModulesSwiftUI/Settings/Notifications/View/BorderedInputFieldStyle.swift
+++ b/RiotSwiftUI/Modules/Settings/Notifications/View/BorderedInputFieldStyle.swift
@@ -24,7 +24,7 @@ import SwiftUI
@available(iOS 14.0, *)
struct BorderedInputFieldStyle: TextFieldStyle {
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
@Environment(\.isEnabled) var isEnabled: Bool
var isEditing: Bool = false
@@ -32,34 +32,34 @@ struct BorderedInputFieldStyle: TextFieldStyle {
private var borderColor: Color {
if !isEnabled {
- return Color(theme.colors.quinaryContent)
+ return theme.colors.quinaryContent
} else if isError {
- return Color(theme.colors.alert)
+ return theme.colors.alert
} else if isEditing {
- return Color(theme.colors.accent)
+ return theme.colors.accent
}
- return Color(theme.colors.quarterlyContent)
+ return theme.colors.quarterlyContent
}
private var accentColor: Color {
if isError {
- return Color(theme.colors.alert)
+ return theme.colors.alert
}
- return Color(theme.colors.accent)
+ return theme.colors.accent
}
private var textColor: Color {
if !isEnabled {
- return Color(theme.colors.quarterlyContent)
+ return theme.colors.quarterlyContent
}
- return Color(theme.colors.primaryContent)
+ return theme.colors.primaryContent
}
private var backgroundColor: Color {
- if !isEnabled && (theme.identifier == ThemeIdentifier.dark.rawValue) {
- return Color(theme.colors.quinaryContent)
+ if !isEnabled && (theme.identifier == ThemeIdentifier.dark) {
+ return theme.colors.quinaryContent
}
- return Color(theme.colors.background)
+ return theme.colors.background
}
private var borderWidth: CGFloat {
@@ -69,7 +69,7 @@ struct BorderedInputFieldStyle: TextFieldStyle {
func _body(configuration: TextField<_Label>) -> some View {
let rect = RoundedRectangle(cornerRadius: 8)
return configuration
- .font(Font(theme.fonts.callout))
+ .font(theme.fonts.callout)
.foregroundColor(textColor)
.accentColor(accentColor)
.frame(height: 48)
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/Chip.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/Chip.swift
similarity index 88%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/Chip.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/Chip.swift
index 675f17726..5ec26ef70 100644
--- a/Riot/ModulesSwiftUI/Settings/Notifications/View/Chip.swift
+++ b/RiotSwiftUI/Modules/Settings/Notifications/View/Chip.swift
@@ -23,21 +23,21 @@ import SwiftUI
struct Chip: View {
@Environment(\.isEnabled) var isEnabled
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
let title: String
let onDelete: () -> Void
var backgroundColor: Color {
if !isEnabled {
- return Color(theme.colors.quinaryContent)
+ return theme.colors.quinaryContent
}
- return Color(theme.colors.accent)
+ return theme.colors.accent
}
var foregroundColor: Color {
if !isEnabled {
- return Color(theme.colors.tertiaryContent)
+ return theme.colors.tertiaryContent
}
return Color.white
}
@@ -45,7 +45,7 @@ struct Chip: View {
var body: some View {
HStack {
Text(title)
- .font(Font(theme.fonts.body))
+ .font(theme.fonts.body)
.lineLimit(1)
Button(action: onDelete) {
Image(systemName: "xmark.circle.fill")
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/Chips.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/Chips.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/Chips.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/Chips.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/ChipsInput.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/ChipsInput.swift
similarity index 97%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/ChipsInput.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/ChipsInput.swift
index b3339612e..7d969403c 100644
--- a/Riot/ModulesSwiftUI/Settings/Notifications/View/ChipsInput.swift
+++ b/RiotSwiftUI/Modules/Settings/Notifications/View/ChipsInput.swift
@@ -24,7 +24,7 @@ import SwiftUI
@available(iOS 14.0, *)
struct ChipsInput: View {
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
@Environment(\.isEnabled) var isEnabled
@State private var chipText: String = ""
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/DefaultNotificationSettings.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/DefaultNotificationSettings.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/DefaultNotificationSettings.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/DefaultNotificationSettings.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/FormInputFieldStyle.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/FormInputFieldStyle.swift
similarity index 86%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/FormInputFieldStyle.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/FormInputFieldStyle.swift
index 76e7457fb..cc10f9591 100644
--- a/Riot/ModulesSwiftUI/Settings/Notifications/View/FormInputFieldStyle.swift
+++ b/RiotSwiftUI/Modules/Settings/Notifications/View/FormInputFieldStyle.swift
@@ -23,26 +23,26 @@ import SwiftUI
@available(iOS 14.0, *)
struct FormInputFieldStyle: TextFieldStyle {
- @Environment(\.theme) var theme: Theme
+ @Environment(\.theme) var theme: ThemeSwiftUI
@Environment(\.isEnabled) var isEnabled
private var textColor: Color {
if !isEnabled {
- return Color(theme.colors.quarterlyContent)
+ return theme.colors.quarterlyContent
}
- return Color(theme.colors.primaryContent)
+ return theme.colors.primaryContent
}
private var backgroundColor: Color {
- if !isEnabled && (theme.identifier == ThemeIdentifier.dark.rawValue) {
- return Color(theme.colors.quinaryContent)
+ if !isEnabled && theme.identifier == .dark {
+ return theme.colors.quinaryContent
}
- return Color(theme.colors.background)
+ return theme.colors.background
}
func _body(configuration: TextField<_Label>) -> some View {
configuration
- .font(Font(theme.fonts.callout))
+ .font(theme.fonts.callout)
.foregroundColor(textColor)
.frame(minHeight: 48)
.padding(.horizontal)
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/NotificationSettings.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/NotificationSettings.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/NotificationSettings.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/NotificationSettings.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/NotificationSettingsKeywords.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/NotificationSettingsKeywords.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/NotificationSettingsKeywords.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/NotificationSettingsKeywords.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/View/OtherNotificationSettings.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/OtherNotificationSettings.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/View/OtherNotificationSettings.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/View/OtherNotificationSettings.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsServiceType.swift b/RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsServiceType.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsServiceType.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsServiceType.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift b/RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewModelType.swift b/RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModelType.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewModelType.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModelType.swift
diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewState.swift b/RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewState.swift
similarity index 100%
rename from Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewState.swift
rename to RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewState.swift
diff --git a/RiotSwiftUI/Release.xcconfig b/RiotSwiftUI/Release.xcconfig
new file mode 100644
index 000000000..11a7288a4
--- /dev/null
+++ b/RiotSwiftUI/Release.xcconfig
@@ -0,0 +1,20 @@
+//
+// Copyright 2021 Vector Creations Ltd
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// Configuration settings file format documentation can be found at:
+// https://help.apple.com/xcode/#/dev745c5c974
+
+#include "Common.xcconfig"
diff --git a/RiotSwiftUI/target.yml b/RiotSwiftUI/target.yml
new file mode 100644
index 000000000..e0bbf2ccb
--- /dev/null
+++ b/RiotSwiftUI/target.yml
@@ -0,0 +1,40 @@
+name: RiotSwiftUI
+
+schemes:
+ RiotSwiftUI:
+ analyze:
+ config: Debug
+ archive:
+ config: Release
+ build:
+ targets:
+ RiotSwiftUI:
+ - running
+ - profiling
+ - analyzing
+ - archiving
+ profile:
+ config: Release
+ run:
+ config: Debug
+ disableMainThreadChecker: true
+
+targets:
+ RiotSwiftUI:
+ type: framework
+ platform: iOS
+ dependencies:
+ - target: DesignKit
+ sources:
+ - path: .
+ - path: ../Riot/Generated/Strings.swift
+ - path: ../Riot/Generated/Images.swift
+ - path: ../Riot/Managers/Theme/ThemeIdentifier.swift
+ - path: ../Riot/Managers/Locale/LocaleProviderType.swift
+ - path: ../Riot/Assets/en.lproj/Vector.strings
+ buildPhase: resources
+ - path: ../Riot/Assets/Images.xcassets
+ buildPhase: resources
+ configFiles:
+ Debug: Debug.xcconfig
+ Release: Release.xcconfig
diff --git a/Tools/SwiftGen/Templates/Strings/flat-swift4-vector.stencil b/Tools/SwiftGen/Templates/Strings/flat-swift4-vector.stencil
index 39863d194..e40884364 100644
--- a/Tools/SwiftGen/Templates/Strings/flat-swift4-vector.stencil
+++ b/Tools/SwiftGen/Templates/Strings/flat-swift4-vector.stencil
@@ -66,12 +66,10 @@ extension {{enumName}} {
let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "")
let locale: Locale
- if let localeIdentifier = Bundle.mxk_language() {
- locale = Locale(identifier: localeIdentifier)
- } else if let fallbackLocaleIdentifier = Bundle.mxk_fallbackLanguage() {
- locale = Locale(identifier: fallbackLocaleIdentifier)
+ if let providedLocale = LocaleProvider.locale {
+ locale = providedLocale
} else {
- locale = Locale.current
+ locale = Locale.current
}
return String(format: format, locale: locale, arguments: args)
@@ -81,4 +79,4 @@ extension {{enumName}} {
private final class BundleToken {}
{% else %}
// No string found
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/project.yml b/project.yml
index 6ec582e47..3f825be46 100644
--- a/project.yml
+++ b/project.yml
@@ -32,3 +32,4 @@ include:
- path: SiriIntents/target.yml
- path: RiotNSE/target.yml
- path: DesignKit/target.yml
+ - path: RiotSwiftUI/target.yml