Update RiotSwiftUI symbols to triple slash documentation style with function annotations.

This commit is contained in:
David Langley
2021-09-13 11:36:33 +01:00
parent 25ee913ddd
commit 2d2c67a402
39 changed files with 184 additions and 240 deletions
@@ -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 }