diff --git a/DesignKit/Source/Colors.swift b/DesignKit/Source/Colors.swift index fc96f3608..e7a77c7cb 100644 --- a/DesignKit/Source/Colors.swift +++ b/DesignKit/Source/Colors.swift @@ -16,53 +16,60 @@ 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 -@objc public protocol Colors { +public protocol Colors { /// - Focused/Active states /// - CTAs - var accent: UIColor { get } + var accent: DesignKitColorType { get } /// - Error messages /// - Content requiring user attention /// - Notification, alerts - var alert: UIColor { get } + var alert: DesignKitColorType { get } /// - Text /// - Icons - var primaryContent: UIColor { get } + var primaryContent: DesignKitColorType { get } /// - Text /// - Icons - var secondaryContent: UIColor { get } + var secondaryContent: DesignKitColorType { get } /// - Text /// - Icons - var tertiaryContent: UIColor { get } + var tertiaryContent: DesignKitColorType { get } /// - Text /// - Icons - var quarterlyContent: UIColor { get } + var quarterlyContent: DesignKitColorType { get } /// - Text /// - Icons - var quinaryContent: UIColor { get } + var quinaryContent: DesignKitColorType { get } /// Separating line - var separator: UIColor { get } + var separator: DesignKitColorType { get } // Cards, tiles - var tile: UIColor { get } + var tile: DesignKitColorType { get } /// Top navigation background on iOS - var navigation: UIColor { get } + var navigation: DesignKitColorType { get } /// Background UI color - var background: UIColor { get } + var background: DesignKitColorType { get } /// - Names in chat timeline /// - Avatars default states that include first name letter - var namesAndAvatars: [UIColor] { get } + var namesAndAvatars: [DesignKitColorType] { get } } diff --git a/DesignKit/Source/Fonts.swift b/DesignKit/Source/Fonts.swift index 1cce963ed..3efe73c84 100644 --- a/DesignKit/Source/Fonts.swift +++ b/DesignKit/Source/Fonts.swift @@ -15,69 +15,77 @@ // 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 -@objc public protocol Fonts { +public protocol Fonts { /// The font for large titles. - var largeTitle: UIFont { get } + var largeTitle: DesignKitFontType { get } /// `largeTitle` with a Bold weight. - var largeTitleB: UIFont { get } + var largeTitleB: DesignKitFontType { get } /// The font for first-level hierarchical headings. - var title1: UIFont { get } + var title1: DesignKitFontType { get } /// `title1` with a Bold weight. - var title1B: UIFont { get } + var title1B: DesignKitFontType { get } /// The font for second-level hierarchical headings. - var title2: UIFont { get } + var title2: DesignKitFontType { get } /// `title2` with a Bold weight. - var title2B: UIFont { get } + var title2B: DesignKitFontType { get } /// The font for third-level hierarchical headings. - var title3: UIFont { get } + var title3: DesignKitFontType { get } /// `title3` with a Semi Bold weight. - var title3SB: UIFont { get } + var title3SB: DesignKitFontType { get } /// The font for headings. - var headline: UIFont { get } + var headline: DesignKitFontType { get } /// The font for subheadings. - var subheadline: UIFont { get } + var subheadline: DesignKitFontType { get } /// The font for body text. - var body: UIFont { get } + var body: DesignKitFontType { get } /// `body` with a Semi Bold weight. - var bodySB: UIFont { get } + var bodySB: DesignKitFontType { get } /// The font for callouts. - var callout: UIFont { get } + var callout: DesignKitFontType { get } /// `callout` with a Semi Bold weight. - var calloutSB: UIFont { get } + var calloutSB: DesignKitFontType { get } /// The font for footnotes. - var footnote: UIFont { get } + var footnote: DesignKitFontType { get } /// `footnote` with a Semi Bold weight. - var footnoteSB: UIFont { get } + var footnoteSB: DesignKitFontType { get } /// The font for standard captions. - var caption1: UIFont { get } + var caption1: DesignKitFontType { get } /// `caption1` with a Semi Bold weight. - var caption1SB: UIFont { get } + var caption1SB: DesignKitFontType { get } /// The font for alternate captions. - var caption2: UIFont { get } + var caption2: DesignKitFontType { get } /// `caption2` with a Semi Bold weight. - var caption2SB: UIFont { get } + var caption2SB: DesignKitFontType { get } } diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index 8c9bfe199..1f1564dea 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -5143,13 +5143,13 @@ 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 { +// 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 - } +// } return String(format: format, locale: locale, arguments: args) } diff --git a/Riot/Modules/Common/Avatar/AvatarInputOption.swift b/Riot/Modules/Common/Avatar/AvatarInputOption.swift new file mode 100644 index 000000000..cebe9f948 --- /dev/null +++ b/Riot/Modules/Common/Avatar/AvatarInputOption.swift @@ -0,0 +1,22 @@ +// +// 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 + +enum AvatarInputOption { + case swiftUI(AvatarInputType) + case uiKit(AvatarViewDataProtocol) +} diff --git a/Riot/Modules/Common/Avatar/ViewModel/AvatarService.swift b/Riot/Modules/Common/Avatar/AvatarService.swift similarity index 93% rename from Riot/Modules/Common/Avatar/ViewModel/AvatarService.swift rename to Riot/Modules/Common/Avatar/AvatarService.swift index b9f6c4113..1e73834e7 100644 --- a/Riot/Modules/Common/Avatar/ViewModel/AvatarService.swift +++ b/Riot/Modules/Common/Avatar/AvatarService.swift @@ -19,14 +19,6 @@ import MatrixSDK import Combine import DesignKit -/** - Provides a simple api to retrieve and cache avatar images - */ -protocol AvatarServiceType { - @available(iOS 14.0, *) - func avatarImage(mxContentUri: String, avatarSize: AvatarSize) -> Future -} - enum AvatarServiceError: Error { case pathNotfound case loadingImageFailed(Error?) diff --git a/Riot/Modules/Common/Avatar/UIKit/AvatarView.swift b/Riot/Modules/Common/Avatar/AvatarView.swift similarity index 100% rename from Riot/Modules/Common/Avatar/UIKit/AvatarView.swift rename to Riot/Modules/Common/Avatar/AvatarView.swift diff --git a/Riot/Modules/Common/Avatar/AvatarViewDataProtocol.swift b/Riot/Modules/Common/Avatar/AvatarViewDataProtocol.swift index b63721ae4..9291723ad 100644 --- a/Riot/Modules/Common/Avatar/AvatarViewDataProtocol.swift +++ b/Riot/Modules/Common/Avatar/AvatarViewDataProtocol.swift @@ -17,7 +17,7 @@ import Foundation /// AvatarViewDataProtocol describe a view data that should be given to an AvatarView sublcass -protocol AvatarViewDataProtocol { +protocol AvatarViewDataProtocol: AvatarType { /// Matrix item identifier (user id or room id) var matrixItemId: String { get } diff --git a/Riot/Modules/Settings/Notifications/MXPushRuleMatching.swift b/Riot/Modules/Settings/Notifications/MXPushRuleMatching.swift new file mode 100644 index 000000000..113cb6c6d --- /dev/null +++ b/Riot/Modules/Settings/Notifications/MXPushRuleMatching.swift @@ -0,0 +1,84 @@ +// +// 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 + + +fileprivate extension MXPushRule { + + /* + Given a rule, check it match the actions in the static definition. + */ + private func maches(targetRule: NotificationStandardActions?) -> Bool { + guard let targetRule = targetRule else { + return false + } + if !enabled && targetRule == .disabled { + return true + } + + if enabled, + let actions = targetRule.actions, + highlight == actions.highlight, + sound == actions.sound, + notify == actions.notify, + dontNotify == !actions.notify { + return true + } + return false + } + + 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) + } + return match + } + } + + var highlight: Bool { + guard let action = getAction(actionType: MXPushRuleActionTypeSetTweak, tweakType: "highlight") else { + return false + } + if let highlight = action.parameters["value"] as? Bool { + return highlight + } + return true + } + + var sound: String? { + guard let action = getAction(actionType: MXPushRuleActionTypeSetTweak, tweakType: "sound") else { + return nil + } + return action.parameters["value"] as? String + } + + var notify: Bool { + return getAction(actionType: MXPushRuleActionTypeNotify) != nil + } + + var dontNotify: Bool { + return getAction(actionType: MXPushRuleActionTypeDontNotify) != nil + } +} diff --git a/Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsService.swift b/Riot/Modules/Settings/Notifications/NotificationSettingsService.swift similarity index 76% rename from Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsService.swift rename to Riot/Modules/Settings/Notifications/NotificationSettingsService.swift index 21447bbe5..7fd3ff42b 100644 --- a/Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsService.swift +++ b/Riot/Modules/Settings/Notifications/NotificationSettingsService.swift @@ -17,45 +17,6 @@ import Foundation import Combine -/** - A service for changing notification settings and keywords - */ -@available(iOS 14.0, *) -protocol NotificationSettingsServiceType { - /** - Publisher of all push rules. - */ - var rulesPublisher: AnyPublisher<[MXPushRule], Never> { get } - /** - Publisher of content rules. - */ - var contentRulesPublisher: AnyPublisher<[MXPushRule], Never> { get } - /** - Adds a keyword. - - - Parameters: - - keyword: The keyword to add. - - enabled: Whether the keyword should be added in the enabled or disabled state. - */ - func add(keyword: String, enabled: Bool) - /** - Removes a keyword. - - - Parameters: - - keyword: The keyword to remove. - */ - func remove(keyword: String) - /** - Updates the push rule actions. - - - Parameters: - - ruleId: The id of the rule. - - enabled: Whether the rule should be enabled or disabled. - - actions: The actions to update with. - */ - func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?) -} - @available(iOS 14.0, *) class NotificationSettingsService: NotificationSettingsServiceType { diff --git a/Riot/Modules/Common/ActivityIndicator/SwiftUI/ActivityIndicator.swift b/Riot/ModulesSwiftUI/Common/ActivityIndicator/ActivityIndicator.swift similarity index 100% rename from Riot/Modules/Common/ActivityIndicator/SwiftUI/ActivityIndicator.swift rename to Riot/ModulesSwiftUI/Common/ActivityIndicator/ActivityIndicator.swift diff --git a/Riot/Modules/Common/ActivityIndicator/SwiftUI/ActivityIndicatorModifier.swift b/Riot/ModulesSwiftUI/Common/ActivityIndicator/ActivityIndicatorModifier.swift similarity index 100% rename from Riot/Modules/Common/ActivityIndicator/SwiftUI/ActivityIndicatorModifier.swift rename to Riot/ModulesSwiftUI/Common/ActivityIndicator/ActivityIndicatorModifier.swift diff --git a/Riot/Modules/Common/Avatar/Mock/MockAvatarInput.swift b/Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarInput.swift similarity index 100% rename from Riot/Modules/Common/Avatar/Mock/MockAvatarInput.swift rename to Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarInput.swift diff --git a/Riot/Modules/Common/Avatar/Mock/MockAvatarService.swift b/Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarService.swift similarity index 98% rename from Riot/Modules/Common/Avatar/Mock/MockAvatarService.swift rename to Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarService.swift index f47e12c99..0ee87d429 100644 --- a/Riot/Modules/Common/Avatar/Mock/MockAvatarService.swift +++ b/Riot/ModulesSwiftUI/Common/Avatar/Mock/MockAvatarService.swift @@ -17,6 +17,7 @@ import Foundation import Combine import DesignKit +import UIKit @available(iOS 14.0, *) class MockAvatarService: AvatarServiceType { diff --git a/Riot/Modules/Common/Avatar/AvatarInputType.swift b/Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarInputType.swift similarity index 87% rename from Riot/Modules/Common/Avatar/AvatarInputType.swift rename to Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarInputType.swift index 26383a3e2..160cd2e53 100644 --- a/Riot/Modules/Common/Avatar/AvatarInputType.swift +++ b/Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarInputType.swift @@ -16,7 +16,7 @@ import Foundation -protocol AvatarInputType { +protocol AvatarInputType: AvatarType { var mxContentUri: String? { get } var matrixItemId: String { get } var displayName: String? { get } @@ -27,8 +27,3 @@ struct AvatarInput: AvatarInputType { var matrixItemId: String let displayName: String? } - -enum AvatarInputOption { - case swiftUI(AvatarInputType) - case uiKit(AvatarViewDataProtocol) -} diff --git a/Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarType.swift b/Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarType.swift new file mode 100644 index 000000000..75c673907 --- /dev/null +++ b/Riot/ModulesSwiftUI/Common/Avatar/Model/AvatarType.swift @@ -0,0 +1,19 @@ +// +// 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 + +protocol AvatarType { } diff --git a/Riot/Modules/Common/Avatar/SwiftUI/AvatarImage.swift b/Riot/ModulesSwiftUI/Common/Avatar/View/AvatarImage.swift similarity index 100% rename from Riot/Modules/Common/Avatar/SwiftUI/AvatarImage.swift rename to Riot/ModulesSwiftUI/Common/Avatar/View/AvatarImage.swift diff --git a/Riot/Modules/Common/SwiftUI/VectorContentView.swift b/Riot/ModulesSwiftUI/Common/Bridging/VectorContentView.swift similarity index 100% rename from Riot/Modules/Common/SwiftUI/VectorContentView.swift rename to Riot/ModulesSwiftUI/Common/Bridging/VectorContentView.swift diff --git a/Riot/Modules/Common/SwiftUI/DependencyContainer.swift b/Riot/ModulesSwiftUI/Common/DependencyInjection/DependencyContainer.swift similarity index 100% rename from Riot/Modules/Common/SwiftUI/DependencyContainer.swift rename to Riot/ModulesSwiftUI/Common/DependencyInjection/DependencyContainer.swift diff --git a/Riot/Modules/Common/SwiftUI/DependencyContainerKey.swift b/Riot/ModulesSwiftUI/Common/DependencyInjection/DependencyContainerKey.swift similarity index 100% rename from Riot/Modules/Common/SwiftUI/DependencyContainerKey.swift rename to Riot/ModulesSwiftUI/Common/DependencyInjection/DependencyContainerKey.swift diff --git a/Riot/Modules/Common/SwiftUI/Inject.swift b/Riot/ModulesSwiftUI/Common/DependencyInjection/Inject.swift similarity index 100% rename from Riot/Modules/Common/SwiftUI/Inject.swift rename to Riot/ModulesSwiftUI/Common/DependencyInjection/Inject.swift diff --git a/Riot/Modules/Common/SwiftUI/Injectable.swift b/Riot/ModulesSwiftUI/Common/DependencyInjection/Injectable.swift similarity index 100% rename from Riot/Modules/Common/SwiftUI/Injectable.swift rename to Riot/ModulesSwiftUI/Common/DependencyInjection/Injectable.swift diff --git a/Riot/Modules/Common/SwiftUI/InjectableObject.swift b/Riot/ModulesSwiftUI/Common/DependencyInjection/InjectableObject.swift similarity index 100% rename from Riot/Modules/Common/SwiftUI/InjectableObject.swift rename to Riot/ModulesSwiftUI/Common/DependencyInjection/InjectableObject.swift diff --git a/Riot/Managers/Theme/SwiftUI/ThemeKey.swift b/Riot/ModulesSwiftUI/Common/Theme/ThemeKey.swift similarity index 100% rename from Riot/Managers/Theme/SwiftUI/ThemeKey.swift rename to Riot/ModulesSwiftUI/Common/Theme/ThemeKey.swift diff --git a/Riot/Managers/Theme/SwiftUI/ThemeObserver.swift b/Riot/ModulesSwiftUI/Common/Theme/ThemeObserver.swift similarity index 92% rename from Riot/Managers/Theme/SwiftUI/ThemeObserver.swift rename to Riot/ModulesSwiftUI/Common/Theme/ThemeObserver.swift index bc985581c..30f659454 100644 --- a/Riot/Managers/Theme/SwiftUI/ThemeObserver.swift +++ b/Riot/ModulesSwiftUI/Common/Theme/ThemeObserver.swift @@ -29,3 +29,8 @@ class ThemeObserver: ObservableObject { } @Published var theme: Theme = ThemeService.shared().theme } + + +class ThemePublisher: ObservableObject { + static let shared = ThemePublisher() +} diff --git a/Riot/Modules/Common/SwiftUI/ViewFrameReader.swift b/Riot/ModulesSwiftUI/Common/ViewFrameReader/ViewFrameReader.swift similarity index 100% rename from Riot/Modules/Common/SwiftUI/ViewFrameReader.swift rename to Riot/ModulesSwiftUI/Common/ViewFrameReader/ViewFrameReader.swift diff --git a/Riot/ModulesSwiftUI/Common/ViewModel/AvatarServiceType.swift b/Riot/ModulesSwiftUI/Common/ViewModel/AvatarServiceType.swift new file mode 100644 index 000000000..6025a002d --- /dev/null +++ b/Riot/ModulesSwiftUI/Common/ViewModel/AvatarServiceType.swift @@ -0,0 +1,28 @@ +// +// 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 +import Combine +import UIKit + +/** + Provides a simple api to retrieve and cache avatar images + */ +protocol AvatarServiceType { + @available(iOS 14.0, *) + func avatarImage(mxContentUri: String, avatarSize: AvatarSize) -> Future +} diff --git a/Riot/Modules/Common/Avatar/ViewModel/AvatarViewModel.swift b/Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewModel.swift similarity index 96% rename from Riot/Modules/Common/Avatar/ViewModel/AvatarViewModel.swift rename to Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewModel.swift index d46fb5125..6ac6613ff 100644 --- a/Riot/Modules/Common/Avatar/ViewModel/AvatarViewModel.swift +++ b/Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewModel.swift @@ -47,7 +47,7 @@ class AvatarViewModel: InjectableObject, ObservableObject { avatarService.avatarImage(mxContentUri: mxContentUri, avatarSize: avatarSize) .sink { completion in guard case let .failure(error) = completion else { return } - MXLog.error("[AvatarService] Failed to retrieve avatar: \(error)") +// MXLog.error("[AvatarService] Failed to retrieve avatar: \(error)") // TODO: Report non-fatal error when we have Sentry or similar. } receiveValue: { image in self.viewState = .avatar(image) diff --git a/Riot/Modules/Common/Avatar/ViewModel/AvatarViewState.swift b/Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewState.swift similarity index 98% rename from Riot/Modules/Common/Avatar/ViewModel/AvatarViewState.swift rename to Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewState.swift index 2a4894eb6..adf5b3614 100644 --- a/Riot/Modules/Common/Avatar/ViewModel/AvatarViewState.swift +++ b/Riot/ModulesSwiftUI/Common/ViewModel/AvatarViewState.swift @@ -15,7 +15,7 @@ // import Foundation - +import UIKit enum AvatarViewState { case empty case placeholder(String, Int) diff --git a/Riot/Modules/Room/NotificationSettings/Mock/MockRoomNotificationSettingsService.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/Mock/MockRoomNotificationSettingsService.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/Mock/MockRoomNotificationSettingsService.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/Mock/MockRoomNotificationSettingsService.swift diff --git a/Riot/Modules/Room/NotificationSettings/RoomNotificationState.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/Model/RoomNotificationState.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/RoomNotificationState.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/Model/RoomNotificationState.swift diff --git a/Riot/Modules/Room/NotificationSettings/SwiftUI/FormItemButtonStyle.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormItemButtonStyle.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/SwiftUI/FormItemButtonStyle.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormItemButtonStyle.swift diff --git a/Riot/Modules/Room/NotificationSettings/SwiftUI/FormPickerItem.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormPickerItem.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/SwiftUI/FormPickerItem.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormPickerItem.swift diff --git a/Riot/Modules/Room/NotificationSettings/SwiftUI/FormSectionFooter.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionFooter.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/SwiftUI/FormSectionFooter.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionFooter.swift diff --git a/Riot/Modules/Room/NotificationSettings/SwiftUI/FormSectionHeader.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionHeader.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/SwiftUI/FormSectionHeader.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/View/FormSectionHeader.swift diff --git a/Riot/Modules/Room/NotificationSettings/SwiftUI/RoomNotificationSettings.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettings.swift similarity index 98% rename from Riot/Modules/Room/NotificationSettings/SwiftUI/RoomNotificationSettings.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettings.swift index fb9fea8f3..3a40a7b1a 100644 --- a/Riot/Modules/Room/NotificationSettings/SwiftUI/RoomNotificationSettings.swift +++ b/Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettings.swift @@ -75,7 +75,7 @@ struct RoomNotificationSettings_Previews: PreviewProvider { static let mockViewModel = RoomNotificationSettingsSwiftUIViewModel( roomNotificationService: MockRoomNotificationSettingsService.example, - avatarData: .swiftUI(MockAvatarInput.example), + avatarData: MockAvatarInput.example, displayName: MockAvatarInput.example.displayName, roomEncrypted: true ) diff --git a/Riot/Modules/Room/NotificationSettings/SwiftUI/RoomNotificationSettingsHeader.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettingsHeader.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/SwiftUI/RoomNotificationSettingsHeader.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/View/RoomNotificationSettingsHeader.swift diff --git a/Riot/Modules/Room/NotificationSettings/SwiftUI/VectorForm.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/View/VectorForm.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/SwiftUI/VectorForm.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/View/VectorForm.swift diff --git a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsSerivceType.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSerivceType.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsSerivceType.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSerivceType.swift diff --git a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsSwiftUIViewModel.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSwiftUIViewModel.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsSwiftUIViewModel.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsSwiftUIViewModel.swift diff --git a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewAction.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewAction.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewAction.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewAction.swift diff --git a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewModel.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModel.swift similarity index 98% rename from Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewModel.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModel.swift index a9bde874e..8ac02df4e 100644 --- a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewModel.swift +++ b/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModel.swift @@ -55,7 +55,7 @@ class RoomNotificationSettingsViewModel: RoomNotificationSettingsViewModelType { convenience init( roomNotificationService: RoomNotificationSettingsServiceType, - avatarData: AvatarInputOption?, + avatarData: AvatarType?, displayName: String?, roomEncrypted: Bool ) { diff --git a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewModelType.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModelType.swift similarity index 100% rename from Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewModelType.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewModelType.swift diff --git a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewStateType.swift b/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewStateType.swift similarity index 95% rename from Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewStateType.swift rename to Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewStateType.swift index 82f3019bb..495b1c4a7 100644 --- a/Riot/Modules/Room/NotificationSettings/RoomNotificationSettingsViewStateType.swift +++ b/Riot/ModulesSwiftUI/Room/NotificationSettings/ViewModel/RoomNotificationSettingsViewStateType.swift @@ -23,7 +23,7 @@ struct RoomNotificationSettingsViewState: RoomNotificationSettingsViewStateType let roomEncrypted: Bool var saving: Bool var notificationState: RoomNotificationState - var avatarData: AvatarInputOption? + var avatarData: AvatarType? var displayName: String? } @@ -42,7 +42,7 @@ protocol RoomNotificationSettingsViewStateType { var roomEncrypted: Bool { get } var notificationOptions: [RoomNotificationState] { get } var notificationState: RoomNotificationState { get } - var avatarData: AvatarInputOption? { get } + var avatarData: AvatarType? { get } var displayName: String? { get } } diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationPusRule.swift b/Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationPusRule.swift new file mode 100644 index 000000000..869ed2f23 --- /dev/null +++ b/Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationPusRule.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 + +struct MockNotificationPushRule: NotificationPushRule { + var ruleId: String + var enabled: Bool + func matches(standardActions: NotificationStandardActions?) -> Bool { + return false + } +} diff --git a/Riot/Modules/Settings/Notifications/Mock/MockNotificationSettingsService.swift b/Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationSettingsService.swift similarity index 84% rename from Riot/Modules/Settings/Notifications/Mock/MockNotificationSettingsService.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationSettingsService.swift index 028f3059b..1089b5693 100644 --- a/Riot/Modules/Settings/Notifications/Mock/MockNotificationSettingsService.swift +++ b/Riot/ModulesSwiftUI/Settings/Notifications/Mock/MockNotificationSettingsService.swift @@ -22,10 +22,10 @@ class MockNotificationSettingsService: NotificationSettingsServiceType, Observab static let example = MockNotificationSettingsService() @Published var keywords = Set() - @Published var rules = [MXPushRule]() - @Published var contentRules = [MXPushRule]() + @Published var rules = [NotificationPushRule]() + @Published var contentRules = [NotificationPushRule]() - var contentRulesPublisher: AnyPublisher<[MXPushRule], Never> { + var contentRulesPublisher: AnyPublisher<[NotificationPushRule], Never> { $contentRules.eraseToAnyPublisher() } @@ -33,7 +33,7 @@ class MockNotificationSettingsService: NotificationSettingsServiceType, Observab $keywords.eraseToAnyPublisher() } - var rulesPublisher: AnyPublisher<[MXPushRule], Never> { + var rulesPublisher: AnyPublisher<[NotificationPushRule], Never> { $rules.eraseToAnyPublisher() } diff --git a/Riot/Modules/Settings/Notifications/Model/NotificationActions.swift b/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationActions.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/Model/NotificationActions.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationActions.swift diff --git a/Riot/Modules/Settings/Notifications/Model/NotificationIndex.swift b/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationIndex.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/Model/NotificationIndex.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationIndex.swift diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRule.swift b/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRule.swift new file mode 100644 index 000000000..fd9cb88e1 --- /dev/null +++ b/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRule.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 + +protocol NotificationPushRule { + var ruleId: String { get } + var enabled: Bool { get } + func matches(standardActions: NotificationStandardActions?) -> Bool +} diff --git a/Riot/Modules/Settings/Notifications/Model/NotificationPushRuleIds.swift b/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRuleIds.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/Model/NotificationPushRuleIds.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationPushRuleIds.swift diff --git a/Riot/Modules/Settings/Notifications/Model/NotificationSettingsScreen.swift b/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationSettingsScreen.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/Model/NotificationSettingsScreen.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationSettingsScreen.swift diff --git a/Riot/Modules/Settings/Notifications/Model/StandardActions.swift b/Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationStandardActions.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/Model/StandardActions.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/Model/NotificationStandardActions.swift diff --git a/Riot/Modules/Settings/Notifications/Model/PushRuleDefinitions.swift b/Riot/ModulesSwiftUI/Settings/Notifications/Model/PushRuleDefinitions.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/Model/PushRuleDefinitions.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/Model/PushRuleDefinitions.swift diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/BorderedInputFieldStyle.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/BorderedInputFieldStyle.swift similarity index 98% rename from Riot/Modules/Settings/Notifications/SwiftUI/BorderedInputFieldStyle.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/BorderedInputFieldStyle.swift index f2041fb17..f11bf90d4 100644 --- a/Riot/Modules/Settings/Notifications/SwiftUI/BorderedInputFieldStyle.swift +++ b/Riot/ModulesSwiftUI/Settings/Notifications/View/BorderedInputFieldStyle.swift @@ -56,7 +56,7 @@ struct BorderedInputFieldStyle: TextFieldStyle { } private var backgroundColor: Color { - if !isEnabled && (theme is DarkTheme) { + if !isEnabled && (theme.identifier == ThemeIdentifier.dark.rawValue) { return Color(theme.colors.quinaryContent) } return Color(theme.colors.background) diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/Chip.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/Chip.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/SwiftUI/Chip.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/Chip.swift diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/Chips.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/Chips.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/SwiftUI/Chips.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/Chips.swift diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/ChipsInput.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/ChipsInput.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/SwiftUI/ChipsInput.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/ChipsInput.swift diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/DefaultNotificationSettings.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/DefaultNotificationSettings.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/SwiftUI/DefaultNotificationSettings.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/DefaultNotificationSettings.swift diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/FormInputFieldStyle.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/FormInputFieldStyle.swift similarity index 97% rename from Riot/Modules/Settings/Notifications/SwiftUI/FormInputFieldStyle.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/FormInputFieldStyle.swift index ae69d4b8b..76e7457fb 100644 --- a/Riot/Modules/Settings/Notifications/SwiftUI/FormInputFieldStyle.swift +++ b/Riot/ModulesSwiftUI/Settings/Notifications/View/FormInputFieldStyle.swift @@ -34,7 +34,7 @@ struct FormInputFieldStyle: TextFieldStyle { } private var backgroundColor: Color { - if !isEnabled && (theme is DarkTheme) { + if !isEnabled && (theme.identifier == ThemeIdentifier.dark.rawValue) { return Color(theme.colors.quinaryContent) } return Color(theme.colors.background) diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/MentionsAndKeywordNotificationSettings.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/SwiftUI/MentionsAndKeywordNotificationSettings.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/NotificationSettings.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/NotificationSettings.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/SwiftUI/NotificationSettings.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/NotificationSettings.swift diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/NotificationSettingsKeywords.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/NotificationSettingsKeywords.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/SwiftUI/NotificationSettingsKeywords.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/NotificationSettingsKeywords.swift diff --git a/Riot/Modules/Settings/Notifications/SwiftUI/OtherNotificationSettings.swift b/Riot/ModulesSwiftUI/Settings/Notifications/View/OtherNotificationSettings.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/SwiftUI/OtherNotificationSettings.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/View/OtherNotificationSettings.swift diff --git a/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsServiceType.swift b/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsServiceType.swift new file mode 100644 index 000000000..c11994ef6 --- /dev/null +++ b/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsServiceType.swift @@ -0,0 +1,57 @@ +// +// 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 + +/** + A service for changing notification settings and keywords + */ +@available(iOS 14.0, *) +protocol NotificationSettingsServiceType { + /** + Publisher of all push rules. + */ + var rulesPublisher: AnyPublisher<[NotificationPushRule], Never> { get } + /** + Publisher of content rules. + */ + var contentRulesPublisher: AnyPublisher<[NotificationPushRule], Never> { get } + /** + Adds a keyword. + + - Parameters: + - keyword: The keyword to add. + - enabled: Whether the keyword should be added in the enabled or disabled state. + */ + func add(keyword: String, enabled: Bool) + /** + Removes a keyword. + + - Parameters: + - keyword: The keyword to remove. + */ + func remove(keyword: String) + /** + Updates the push rule actions. + + - Parameters: + - ruleId: The id of the rule. + - enabled: Whether the rule should be enabled or disabled. + - actions: The actions to update with. + */ + func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?) +} diff --git a/Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift b/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift similarity index 77% rename from Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift index e25ce237d..15d4724af 100644 --- a/Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift +++ b/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift @@ -155,7 +155,7 @@ final class NotificationSettingsViewModel: NotificationSettingsViewModelType, Ob } // MARK: - Private - private func rulesUpdated(newRules: [MXPushRule]) { + private func rulesUpdated(newRules: [NotificationPushRule]) { for rule in newRules { guard let ruleId = NotificationPushRuleId(rawValue: rule.ruleId), ruleIds.contains(ruleId) else { continue } @@ -174,11 +174,11 @@ final class NotificationSettingsViewModel: NotificationSettingsViewModelType, Ob Matcing is done by comparing the rule against the static definitions for that rule. The same logic is used on android. */ - private func isChecked(rule: MXPushRule) -> Bool { + private func isChecked(rule: NotificationPushRule) -> Bool { guard let ruleId = NotificationPushRuleId(rawValue: rule.ruleId) else { return false } let firstIndex = NotificationIndex.allCases.first { nextIndex in - return ruleMaches(rule: rule, targetRule: ruleId.standardActions(for: nextIndex)) + return rule.matches(standardActions: ruleId.standardActions(for: nextIndex)) } guard let index = firstIndex else { @@ -187,69 +187,5 @@ final class NotificationSettingsViewModel: NotificationSettingsViewModelType, Ob return index.enabled } - /* - Given a rule, check it match the actions in the static definition. - */ - private func ruleMaches(rule: MXPushRule, targetRule: NotificationStandardActions?) -> Bool { - guard let targetRule = targetRule else { - return false - } - if !rule.enabled && targetRule == .disabled { - return true - } - - if rule.enabled, - let actions = targetRule.actions, - rule.highlight == actions.highlight, - rule.sound == actions.sound, - rule.notify == actions.notify, - rule.dontNotify == !actions.notify { - return true - } - return false - } - -} -fileprivate extension MXPushRule { - 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) - } - return match - } - } - - var highlight: Bool { - guard let action = getAction(actionType: MXPushRuleActionTypeSetTweak, tweakType: "highlight") else { - return false - } - if let highlight = action.parameters["value"] as? Bool { - return highlight - } - return true - } - - var sound: String? { - guard let action = getAction(actionType: MXPushRuleActionTypeSetTweak, tweakType: "sound") else { - return nil - } - return action.parameters["value"] as? String - } - - var notify: Bool { - return getAction(actionType: MXPushRuleActionTypeNotify) != nil - } - - var dontNotify: Bool { - return getAction(actionType: MXPushRuleActionTypeDontNotify) != nil - } } diff --git a/Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModelType.swift b/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewModelType.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModelType.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewModelType.swift diff --git a/Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewState.swift b/Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewState.swift similarity index 100% rename from Riot/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewState.swift rename to Riot/ModulesSwiftUI/Settings/Notifications/ViewModel/NotificationSettingsViewState.swift diff --git a/Riot/target.yml b/Riot/target.yml index 4a23200e4..f7e279df1 100644 --- a/Riot/target.yml +++ b/Riot/target.yml @@ -26,6 +26,18 @@ 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 @@ -35,6 +47,7 @@ targets: - target: SiriIntents - target: RiotNSE - target: DesignKit + - target: RiotSwiftUI configFiles: Debug: Debug.xcconfig