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 886bb98eb1
commit 3d65fbd48f
39 changed files with 184 additions and 240 deletions
@@ -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