mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
Update RiotSwiftUI symbols to triple slash documentation style with function annotations.
This commit is contained in:
@@ -16,10 +16,8 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
A visual cue to user that something is in progress.
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
/// A visual cue to user that something is in progress.
|
||||
struct ActivityIndicator: View {
|
||||
|
||||
private enum Constants {
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
A modifier for showing the activity indcator centered over a view.
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
/// A modifier for showing the activity indicator centered over a view.
|
||||
struct ActivityIndicatorModifier: ViewModifier {
|
||||
var show: Bool
|
||||
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
A protocol that any class or struct can conform to
|
||||
so that it can easily produce avatar data.
|
||||
E.g. MXRoom, MxUser can conform to this making it
|
||||
easy to grab the avatar data for display.
|
||||
*/
|
||||
/// A protocol that any class or struct can conform to
|
||||
/// so that it can easily produce avatar data.
|
||||
///
|
||||
/// E.g. MXRoom, MxUser can conform to this making it
|
||||
/// easy to grab the avatar data for display.
|
||||
protocol Avatarable: AvatarInputProtocol { }
|
||||
extension Avatarable {
|
||||
var avatarData: AvatarInput {
|
||||
|
||||
@@ -41,14 +41,13 @@ class AvatarService: AvatarServiceProtocol {
|
||||
self.mediaManager = mediaManager
|
||||
}
|
||||
|
||||
/**
|
||||
Given an mxContentUri, this function returns a Future of UIImage.
|
||||
If possible it will retrieve the image from network or cache, otherwise it will error.
|
||||
|
||||
- Parameter mxContentUri: matrix uri of the avatar to fetch
|
||||
- Parameter avatarSize: The size of avatar to retrieve as defined in the DesignKit spec.
|
||||
- Returns: A Future of UIImage that returns an error if it fails to fetch the image
|
||||
*/
|
||||
/// Given an mxContentUri, this function returns a Future of UIImage.
|
||||
///
|
||||
/// If possible it will retrieve the image from network or cache, otherwise it will error.
|
||||
/// - Parameters:
|
||||
/// - mxContentUri: matrix uri of the avatar to fetch
|
||||
/// - avatarSize: The size of avatar to retrieve as defined in the DesignKit spec.
|
||||
/// - Returns: A Future of UIImage that returns an error if it fails to fetch the image.
|
||||
@available(iOS 14.0, *)
|
||||
func avatarImage(mxContentUri: String, avatarSize: AvatarSize) -> Future<UIImage, Error> {
|
||||
|
||||
|
||||
@@ -19,9 +19,8 @@ import DesignKit
|
||||
import Combine
|
||||
import UIKit
|
||||
|
||||
/**
|
||||
Provides a simple api to retrieve and cache avatar images
|
||||
*/
|
||||
|
||||
/// Provides a simple api to retrieve and cache avatar images
|
||||
protocol AvatarServiceProtocol {
|
||||
@available(iOS 14.0, *)
|
||||
func avatarImage(mxContentUri: String, avatarSize: AvatarSize) -> Future<UIImage, Error>
|
||||
|
||||
@@ -18,11 +18,8 @@ import Foundation
|
||||
import Combine
|
||||
import DesignKit
|
||||
|
||||
/**
|
||||
Simple ViewModel that supports loading an avatar image of a particular size
|
||||
as specified in DesignKit and delivering the UIImage to the UI if possible.
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
/// Simple ViewModel that supports loading an avatar image
|
||||
class AvatarViewModel: InjectableObject, ObservableObject {
|
||||
|
||||
@Inject var avatarService: AvatarServiceProtocol
|
||||
@@ -31,6 +28,13 @@ class AvatarViewModel: InjectableObject, ObservableObject {
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
/// Load an avatar
|
||||
/// - Parameters:
|
||||
/// - mxContentUri: The matrix content URI of the avatar.
|
||||
/// - matrixItemId: The id of the matrix item represented by the avatar.
|
||||
/// - displayName: Display name of the avatar.
|
||||
/// - colorCount: The count of total avatar colors used to generate the stable color index.
|
||||
/// - avatarSize: The size of the avatar to fetch (as defined within DesignKit).
|
||||
func loadAvatar(
|
||||
mxContentUri: String?,
|
||||
matrixItemId: String,
|
||||
@@ -54,9 +58,9 @@ class AvatarViewModel: InjectableObject, ObservableObject {
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
/**
|
||||
Get the first character of a string capialized or else an empty string.
|
||||
*/
|
||||
/// Get the first character of a string capialized or else an empty string.
|
||||
/// - Parameter string: The input string to get the capitalized letter from.
|
||||
/// - Returns: The capitalized first letter.
|
||||
private func firstCharacterCapitalized(_ string: String?) -> String {
|
||||
guard let character = string?.first else {
|
||||
return ""
|
||||
@@ -64,10 +68,13 @@ class AvatarViewModel: InjectableObject, ObservableObject {
|
||||
return String(character).capitalized
|
||||
}
|
||||
|
||||
/**
|
||||
Provides the same color each time for a specified matrixId.
|
||||
Same algorithm as in AvatarGenerator.
|
||||
*/
|
||||
/// Provides the same color each time for a specified matrixId
|
||||
///
|
||||
/// Same algorithm as in AvatarGenerator.
|
||||
/// - Parameters:
|
||||
/// - matrixItemId: the matrix id used as input to create the stable index.
|
||||
/// - colorCount: The number of total colors we want to index in to.
|
||||
/// - Returns: The stable index.
|
||||
private func stableColorIndex(matrixItemId: String, colorCount: Int) -> Int {
|
||||
// Sum all characters
|
||||
let sum = matrixItemId.utf8
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
A Modifier to be called from the top-most SwiftUI view before being added to a HostViewController
|
||||
Provides any app level configuration the SwiftUI hierarchy might need (E.g. to monitor theme changes).
|
||||
*/
|
||||
/// A Modifier to be called from the top-most SwiftUI view before being added to a HostViewController.
|
||||
///
|
||||
/// Provides any app level configuration the SwiftUI hierarchy might need (E.g. to monitor theme changes).
|
||||
@available(iOS 14.0, *)
|
||||
struct VectorContentModifier: ViewModifier {
|
||||
|
||||
|
||||
@@ -16,19 +16,18 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
Used for storing and resolving dependencies at runtime.
|
||||
*/
|
||||
/// Used for storing and resolving dependencies at runtime.
|
||||
struct DependencyContainer {
|
||||
|
||||
// Stores the dependencies with type information removed.
|
||||
private var dependencyStore: [String: Any] = [:]
|
||||
|
||||
/**
|
||||
Resolve a dependency by type.
|
||||
Given a particlar `Type` (Inferred from return type),
|
||||
generate a key and retrieve from storage.
|
||||
*/
|
||||
/// Resolve a dependency by type.
|
||||
///
|
||||
/// Given a particular `Type` (Inferred from return type),
|
||||
/// generate a key and retrieve from storage.
|
||||
///
|
||||
/// - Returns: The resolved dependency.
|
||||
func resolve<T>() -> T {
|
||||
let key = String(describing: T.self)
|
||||
guard let t = dependencyStore[key] as? T else {
|
||||
@@ -37,10 +36,10 @@ struct DependencyContainer {
|
||||
return t
|
||||
}
|
||||
|
||||
/**
|
||||
Register a dependency.
|
||||
Given a dependency, generate a key from it's `Type` and save in storage.
|
||||
*/
|
||||
/// Register a dependency.
|
||||
///
|
||||
/// Given a dependency, generate a key from it's `Type` and save in storage.
|
||||
/// - Parameter dependency: The dependency to register.
|
||||
mutating func register<T>(dependency: T) {
|
||||
let key = String(describing: T.self)
|
||||
dependencyStore[key] = dependency
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
An Environment Key for retrieving runtime dependencies to be injected into `ObservableObjects`
|
||||
that are owned by a View (i.e. `@StateObject`'s, such as ViewModels owned by the View).
|
||||
*/
|
||||
/// An Environment Key for retrieving runtime dependencies.
|
||||
///
|
||||
/// Dependencies are to be injected into `ObservableObjects`
|
||||
/// that are owned by a View (i.e. `@StateObject`'s, such as ViewModels owned by the View).
|
||||
private struct DependencyContainerKey: EnvironmentKey {
|
||||
static let defaultValue = DependencyContainer()
|
||||
}
|
||||
@@ -36,12 +36,13 @@ extension EnvironmentValues {
|
||||
@available(iOS 14.0, *)
|
||||
extension View {
|
||||
|
||||
/**
|
||||
A modifier for adding a dependency to the SwiftUI view hierarchy's dependency container.
|
||||
Important: When adding a dependency to cast it to the type in which it will be injected.
|
||||
So if adding `MockDependency` but type at injection is `Dependency` remember to cast
|
||||
to `Dependency` first.
|
||||
*/
|
||||
/// A modifier for adding a dependency to the SwiftUI view hierarchy's dependency container.
|
||||
///
|
||||
/// Important: When adding a dependency to cast it to the type in which it will be injected.
|
||||
/// So if adding `MockDependency` but type at injection is `Dependency` remember to cast
|
||||
/// to `Dependency` first.
|
||||
/// - Parameter dependency: The dependency to add.
|
||||
/// - Returns: The wrapped view that now includes the dependency.
|
||||
func addDependency<T>(_ dependency: T) -> some View {
|
||||
transformEnvironment(\.dependencies) { container in
|
||||
container.register(dependency: dependency)
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
A property wrapped used to inject from the dependency
|
||||
container on the instance to instance properties.
|
||||
E.g. ```@Inject var someClass: SomeClass```
|
||||
*/
|
||||
/// A property wrapped used to inject from the dependency container on the instance, to instance properties.
|
||||
///
|
||||
/// ```
|
||||
/// @Inject var someClass: SomeClass
|
||||
/// ```
|
||||
@propertyWrapper struct Inject<Value> {
|
||||
|
||||
static subscript<T: Injectable>(
|
||||
|
||||
@@ -16,18 +16,16 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
A protocol for classes that can be injected with a dependency container
|
||||
*/
|
||||
/// A protocol for classes that can be injected with a dependency container
|
||||
protocol Injectable: AnyObject {
|
||||
var dependencies: DependencyContainer! { get set }
|
||||
}
|
||||
|
||||
|
||||
extension Injectable {
|
||||
/**
|
||||
Used to inject the dependency container into an Injectable.
|
||||
*/
|
||||
|
||||
/// Used to inject the dependency container into an Injectable.
|
||||
/// - Parameter dependencies: The `DependencyContainer` to inject.
|
||||
func inject(dependencies: DependencyContainer) {
|
||||
self.dependencies = dependencies
|
||||
}
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
Class that can be extended and supports
|
||||
injection and the `@Inject` property wrapper.
|
||||
*/
|
||||
/// Class that can be extended that supports injection and the `@Inject` property wrapper.
|
||||
open class InjectableObject: Injectable {
|
||||
var dependencies: DependencyContainer!
|
||||
}
|
||||
|
||||
@@ -17,13 +17,11 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
/**
|
||||
Sams as `assign(to:on:)` but maintains a weak reference to object(Useful in cases where you want to pass self and not cause a retain cycle.)
|
||||
- SeeAlso:
|
||||
[assign(to:on:)](https://developer.apple.com/documentation/combine/just/assign(to:on:))
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
extension Publisher where Failure == Never {
|
||||
/// Sams as `assign(to:on:)` but maintains a weak reference to object
|
||||
///
|
||||
/// Useful in cases where you want to pass self and not cause a retain cycle.
|
||||
func weakAssign<T: AnyObject>(
|
||||
to keyPath: ReferenceWritableKeyPath<T, Output>,
|
||||
on object: T
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
A logger protocol that enables confirming types
|
||||
to be used with UILog.
|
||||
*/
|
||||
/// A logger protocol that enables conforming types to be used with UILog.
|
||||
protocol LoggerProtocol {
|
||||
static func verbose(_ message: @autoclosure () -> Any, _ file: String, _ function: String, line: Int, context: Any?)
|
||||
static func debug(_ message: @autoclosure () -> Any, _ file: String, _ function: String, line: Int, context: Any?)
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
A logger for logging to `print`.
|
||||
For use with UILog.
|
||||
*/
|
||||
/// A logger for logging to `print`.
|
||||
///
|
||||
/// For use with UILog.
|
||||
class PrintLogger: LoggerProtocol {
|
||||
static func verbose(_ message: @autoclosure () -> Any, _ file: String = #file, _ function: String = #function, line: Int = #line, context: Any? = nil) {
|
||||
print(message())
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
/*
|
||||
A logger for use in different application targets that can be configured
|
||||
at runtime with a suitable logger.
|
||||
*/
|
||||
|
||||
/// A logger for use in different application targets.
|
||||
///
|
||||
/// It can be configured at runtime with a suitable logger.
|
||||
class UILog: LoggerProtocol {
|
||||
|
||||
static var _logger: LoggerProtocol.Type?
|
||||
|
||||
@@ -17,16 +17,19 @@
|
||||
import XCTest
|
||||
import Combine
|
||||
|
||||
/**
|
||||
XCTest utility to wait for results from publishers, so that the output can be used for assertions.
|
||||
|
||||
```
|
||||
let collectedEvents = somePublisher.collect(3).first()
|
||||
XCTAssertEqual(try xcAwait(collectedEvents), [expected, values, here])
|
||||
```
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
extension XCTestCase {
|
||||
/// XCTest utility to wait for results from publishers, so that the output can be used for assertions.
|
||||
///
|
||||
/// ```
|
||||
/// let collectedEvents = somePublisher.collect(3).first()
|
||||
/// XCTAssertEqual(try xcAwait(collectedEvents), [expected, values, here])
|
||||
/// ```
|
||||
/// - Parameters:
|
||||
/// - publisher: The publisher to wait on.
|
||||
/// - timeout: A timeout after which we give up.
|
||||
/// - Throws: If it can't get the unwrapped result.
|
||||
/// - Returns: The unwrapped result.
|
||||
func xcAwait<T: Publisher>(
|
||||
_ publisher: T,
|
||||
timeout: TimeInterval = 10
|
||||
|
||||
@@ -17,13 +17,11 @@
|
||||
import Foundation
|
||||
import DesignKit
|
||||
|
||||
/**
|
||||
Extension to `ThemeIdentifier` for getting the SwiftUI theme.
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
extension ThemeIdentifier {
|
||||
fileprivate static let defaultTheme = DefaultThemeSwiftUI()
|
||||
fileprivate static let darkTheme = DarkThemeSwiftUI()
|
||||
/// Extension to `ThemeIdentifier` for getting the SwiftUI theme.
|
||||
public var themeSwiftUI: ThemeSwiftUI {
|
||||
switch self {
|
||||
case .light:
|
||||
|
||||
@@ -31,25 +31,21 @@ extension EnvironmentValues {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
A theme modifier for setting the theme for this view and all its descendants in the hierarchy.
|
||||
- Parameters:
|
||||
- theme: a Theme to be set as the environment value.
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
extension View {
|
||||
/// A theme modifier for setting the theme for this view and all its descendants in the hierarchy.
|
||||
/// - Parameter theme: A theme to be set as the environment value.
|
||||
/// - Returns: The target view with the theme applied.
|
||||
func theme(_ theme: ThemeSwiftUI) -> some View {
|
||||
environment(\.theme, theme)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
A theme modifier for setting the theme by id for this view and all its descendants in the hierarchy.
|
||||
- Parameters:
|
||||
- themeId: ThemeIdentifier of a theme to be set as the environment value.
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
extension View {
|
||||
/// A theme modifier for setting the theme by id for this view and all its descendants in the hierarchy.
|
||||
/// - Parameter themeId: ThemeIdentifier of a theme to be set as the environment value.
|
||||
/// - Returns: The target view with the theme applied.
|
||||
func theme(_ themeId: ThemeIdentifier) -> some View {
|
||||
return environment(\.theme, themeId.themeSwiftUI)
|
||||
}
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
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 class on the `ThemeService`.
|
||||
*/
|
||||
/// Provides the theme and theme updates to SwiftUI.
|
||||
///
|
||||
/// Replaces the old ThemeObserver. Riot app can push updates to this class
|
||||
/// removing the dependency of this class on the `ThemeService`.
|
||||
@available(iOS 14.0, *)
|
||||
class ThemePublisher: ObservableObject {
|
||||
|
||||
|
||||
@@ -17,18 +17,15 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
Used to calculate the frame of a view. Useful in situations as with `ZStack` where
|
||||
you might want to layout views using alignment guides.
|
||||
Example usage:
|
||||
```
|
||||
@State private var frame: CGRect = CGRect.zero
|
||||
...
|
||||
SomeView()
|
||||
.background(ViewFrameReader(frame: $frame))
|
||||
|
||||
```
|
||||
*/
|
||||
/// Used to calculate the frame of a view.
|
||||
///
|
||||
/// Useful in situations as with `ZStack` where you might want to layout views using alignment guides.
|
||||
/// ```
|
||||
/// @State private var frame: CGRect = CGRect.zero
|
||||
/// ...
|
||||
/// SomeView()
|
||||
/// .background(ViewFrameReader(frame: $frame))
|
||||
/// ```
|
||||
@available(iOS 14.0, *)
|
||||
struct ViewFrameReader: View {
|
||||
@Binding var frame: CGRect
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
import Foundation
|
||||
import DesignKit
|
||||
|
||||
/**
|
||||
Conformance of MXPushRule to the abstraction `NotificationPushRule` for use in `NotificationSettingsViewModel`.
|
||||
*/
|
||||
// Conformance of MXPushRule to the abstraction `NotificationPushRule` for use in `NotificationSettingsViewModel`.
|
||||
extension MXPushRule: NotificationPushRuleType {
|
||||
|
||||
/*
|
||||
Given a rule, check it match the actions in the static definition.
|
||||
*/
|
||||
/// Given a rule, check it match the actions in the static definition.
|
||||
/// - Parameter standardActions: The standard actions to match against.
|
||||
/// - Returns: Wether `this` rule matches the standard actions.
|
||||
func matches(standardActions: NotificationStandardActions?) -> Bool {
|
||||
guard let standardActions = standardActions else {
|
||||
return false
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
The actions defined on a push rule, used in the static push rule definitions.
|
||||
*/
|
||||
/// The actions defined on a push rule, used in the static push rule definitions.
|
||||
struct NotificationActions {
|
||||
let notify: Bool
|
||||
let highlight: Bool
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
Index that determines the state of the push setting.
|
||||
Silent case is un-unsed on iOS but keeping in for consistency of
|
||||
definition across the platforms.
|
||||
*/
|
||||
/// Index that determines the state of the push setting.
|
||||
///
|
||||
/// Silent case is un-used on iOS but keeping in for consistency of
|
||||
/// definition across the platforms.
|
||||
enum NotificationIndex {
|
||||
case off
|
||||
case silent
|
||||
@@ -30,16 +29,14 @@ enum NotificationIndex {
|
||||
extension NotificationIndex: CaseIterable { }
|
||||
|
||||
extension NotificationIndex {
|
||||
/**
|
||||
Used to map the on/off checkmarks to an index used in the static push rule definitions.
|
||||
*/
|
||||
/// Used to map the on/off checkmarks to an index used in the static push rule definitions.
|
||||
/// - Parameter enabled: Enabled/Disabled state.
|
||||
/// - Returns: The associated NotificationIndex
|
||||
static func index(when enabled: Bool) -> NotificationIndex {
|
||||
return enabled ? .noisy : .off
|
||||
}
|
||||
|
||||
/**
|
||||
Used to map from the checked state back to the index.
|
||||
*/
|
||||
/// Used to map from the checked state back to the index.
|
||||
var enabled: Bool {
|
||||
return self != .off
|
||||
}
|
||||
|
||||
@@ -18,10 +18,11 @@ import Foundation
|
||||
|
||||
|
||||
extension NotificationPushRuleId {
|
||||
/**
|
||||
A static definition of the push rule actions.
|
||||
It is defined similarly across Web and Android.
|
||||
*/
|
||||
/// A static definition of the push rule actions.
|
||||
///
|
||||
/// It is defined similarly across Web and Android.
|
||||
/// - Parameter index: The notification index for which to get the actions for.
|
||||
/// - Returns: The associated `NotificationStandardActions`.
|
||||
func standardActions(for index: NotificationIndex) -> NotificationStandardActions? {
|
||||
switch self {
|
||||
case .containDisplayName:
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
The push rule ids used in notification settings and the static rule definitions.
|
||||
*/
|
||||
/// The push rule ids used in notification settings and the static rule definitions.
|
||||
enum NotificationPushRuleId: String {
|
||||
case suppressBots = ".m.rule.suppress_notices"
|
||||
case inviteMe = ".m.rule.invite_for_me"
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
The notification settings screen definitions, used when calling the coordinator.
|
||||
*/
|
||||
/// The notification settings screen definitions, used when calling the coordinator.
|
||||
@objc enum NotificationSettingsScreen: Int {
|
||||
case defaultNotifications
|
||||
case mentionsAndKeywords
|
||||
@@ -32,9 +30,7 @@ extension NotificationSettingsScreen: Identifiable {
|
||||
}
|
||||
|
||||
extension NotificationSettingsScreen {
|
||||
/**
|
||||
Defines which rules are handled by each of the screens.
|
||||
*/
|
||||
/// Defines which rules are handled by each of the screens.
|
||||
var pushRules: [NotificationPushRuleId] {
|
||||
switch self {
|
||||
case .defaultNotifications:
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
A static definition of the different actions that can be defined on push rules.
|
||||
It is defined similarly across Web and Android.
|
||||
*/
|
||||
/// A static definition of the different actions that can be defined on push rules.
|
||||
///
|
||||
/// It is defined similarly across Web and Android.
|
||||
enum NotificationStandardActions {
|
||||
case notify
|
||||
case notifyDefaultSound
|
||||
|
||||
@@ -17,41 +17,29 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
/**
|
||||
A service for changing notification settings and keywords
|
||||
*/
|
||||
/// A service for changing notification settings and keywords
|
||||
@available(iOS 14.0, *)
|
||||
protocol NotificationSettingsServiceType {
|
||||
/**
|
||||
Publisher of all push rules.
|
||||
*/
|
||||
/// Publisher of all push rules.
|
||||
var rulesPublisher: AnyPublisher<[NotificationPushRuleType], Never> { get }
|
||||
/**
|
||||
Publisher of content rules.
|
||||
*/
|
||||
|
||||
/// Publisher of content rules.
|
||||
var contentRulesPublisher: AnyPublisher<[NotificationPushRuleType], Never> { get }
|
||||
/**
|
||||
Adds a keyword.
|
||||
|
||||
- Parameters:
|
||||
- keyword: The keyword to add.
|
||||
- enabled: Whether the keyword should be added in the enabled or disabled state.
|
||||
*/
|
||||
|
||||
/// 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.
|
||||
*/
|
||||
|
||||
/// Removes a keyword.
|
||||
/// - Parameter 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.
|
||||
*/
|
||||
|
||||
/// 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?)
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
A bordered style of text input as defined in:
|
||||
https://www.figma.com/file/X4XTH9iS2KGJ2wFKDqkyed/Compound?node-id=2039%3A26415
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
/// A bordered style of text input
|
||||
///
|
||||
/// As defined in:
|
||||
/// https://www.figma.com/file/X4XTH9iS2KGJ2wFKDqkyed/Compound?node-id=2039%3A26415
|
||||
struct BorderedInputFieldStyle: TextFieldStyle {
|
||||
|
||||
@Environment(\.theme) var theme: ThemeSwiftUI
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
A single rounded rect chip to be rendered within `Chips` collection
|
||||
*/
|
||||
|
||||
/// A single rounded rect chip to be rendered within `Chips` collection
|
||||
@available(iOS 14.0, *)
|
||||
struct Chip: View {
|
||||
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
Renders multiple chips in a flow layout.
|
||||
*/
|
||||
/// Renders multiple chips in a flow layout.
|
||||
@available(iOS 14.0, *)
|
||||
struct Chips: View {
|
||||
|
||||
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
|
||||
/**
|
||||
Renders an input field and a collection of chips
|
||||
with callbacks for addition and deletion.
|
||||
*/
|
||||
/// Renders an input field and a collection of chips.
|
||||
@available(iOS 14.0, *)
|
||||
struct ChipsInput: View {
|
||||
|
||||
@@ -29,7 +25,6 @@ struct ChipsInput: View {
|
||||
|
||||
@State private var chipText: String = ""
|
||||
|
||||
|
||||
let titles: [String]
|
||||
let didAddChip: (String) -> Void
|
||||
let didDeleteChip: (String) -> Void
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
An input field for forms.
|
||||
*/
|
||||
/// An input field style for forms.
|
||||
@available(iOS 14.0, *)
|
||||
struct FormInputFieldStyle: TextFieldStyle {
|
||||
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
Renders the push rule settings that can be enabled/disable.
|
||||
Also renders an optional bottom section
|
||||
(used in the case of keywords, for the keyword chips and input).
|
||||
*/
|
||||
/// Renders the push rule settings that can be enabled/disable.
|
||||
///
|
||||
/// Also renders an optional bottom section.
|
||||
/// Used in the case of keywords, for the keyword chips and input.
|
||||
@available(iOS 14.0, *)
|
||||
struct NotificationSettings<BottomSection: View>: View {
|
||||
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
Renders the keywords input, driven by 'NotificationSettingsViewModel'.
|
||||
*/
|
||||
/// Renders the keywords input, driven by 'NotificationSettingsViewModel'.
|
||||
@available(iOS 14.0, *)
|
||||
struct NotificationSettingsKeywords: View {
|
||||
@ObservedObject var viewModel: NotificationSettingsViewModel
|
||||
|
||||
@@ -168,12 +168,13 @@ final class NotificationSettingsViewModel: NotificationSettingsViewModelType, Ob
|
||||
self.viewState.selectionState[.keywords] = anyEnabled
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Given a push rule check which index/checked state it matches.
|
||||
Matcing is done by comparing the rule against the static definitions for that rule.
|
||||
The same logic is used on android.
|
||||
*/
|
||||
|
||||
/// Given a push rule check which index/checked state it matches.
|
||||
///
|
||||
/// Matching is done by comparing the rule against the static definitions for that rule.
|
||||
/// The same logic is used on android.
|
||||
/// - Parameter rule: The push rule type to check.
|
||||
/// - Returns: Wether it should be displayed as checked or not checked.
|
||||
private func isChecked(rule: NotificationPushRuleType) -> Bool {
|
||||
guard let ruleId = NotificationPushRuleId(rawValue: rule.ruleId) else { return false }
|
||||
|
||||
|
||||
@@ -64,16 +64,18 @@ class TemplateUserProfileViewModel: ObservableObject, TemplateUserProfileViewMod
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
/**
|
||||
Send state actions to mutate the state.
|
||||
*/
|
||||
/// Send state actions to mutate the state.
|
||||
/// - Parameter action: The `TemplateUserProfileStateAction` to trigger the state change.
|
||||
private func dispatch(action: TemplateUserProfileStateAction) {
|
||||
Self.reducer(state: &self.viewState, action: action)
|
||||
}
|
||||
|
||||
/**
|
||||
A redux style reducer, all modifications to state happen here. Receives a state and a state action and produces a new state.
|
||||
*/
|
||||
|
||||
/// A redux style reducer
|
||||
///
|
||||
/// All modifications to state happen here.
|
||||
/// - Parameters:
|
||||
/// - state: The `inout` state to be modified,
|
||||
/// - action: The action that defines which state modification should take place.
|
||||
private static func reducer(state: inout TemplateUserProfileViewState, action: TemplateUserProfileStateAction) {
|
||||
switch action {
|
||||
case .updatePresence(let presence):
|
||||
|
||||
@@ -15,11 +15,9 @@
|
||||
//
|
||||
import SwiftUI
|
||||
|
||||
/**
|
||||
RiotSwiftUI screens rendered for UI Tests.
|
||||
*/
|
||||
@available(iOS 14.0, *)
|
||||
@main
|
||||
/// RiotSwiftUI screens rendered for UI Tests.
|
||||
struct RiotSwiftUIApp: App {
|
||||
init() {
|
||||
UILog.configure(logger: PrintLogger.self)
|
||||
|
||||
Reference in New Issue
Block a user