mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 00:52:43 +02:00
Configured and applied SwiftFormat
This commit is contained in:
committed by
Stefan Ceriu
parent
ff2e6ddfa7
commit
43c28d23b7
+2
-3
@@ -14,15 +14,14 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import CommonKit
|
||||
import SwiftUI
|
||||
|
||||
struct TemplateUserProfileCoordinatorParameters {
|
||||
let session: MXSession
|
||||
}
|
||||
|
||||
final class TemplateUserProfileCoordinator: Coordinator, Presentable {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -68,7 +67,7 @@ final class TemplateUserProfileCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
return self.templateUserProfileHostingController
|
||||
templateUserProfileHostingController
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -35,12 +35,12 @@ enum MockTemplateUserProfileScreenState: MockScreenState, CaseIterable {
|
||||
static var allCases: [MockTemplateUserProfileScreenState] {
|
||||
// Each of the presence statuses
|
||||
TemplateUserProfilePresence.allCases.map(MockTemplateUserProfileScreenState.presence)
|
||||
// A long display name
|
||||
+ [.longDisplayName("Somebody with a super long name we would like to test")]
|
||||
// A long display name
|
||||
+ [.longDisplayName("Somebody with a super long name we would like to test")]
|
||||
}
|
||||
|
||||
/// Generate the view struct for the screen state.
|
||||
var screenView: ([Any], AnyView) {
|
||||
var screenView: ([Any], AnyView) {
|
||||
let service: MockTemplateUserProfileService
|
||||
switch self {
|
||||
case .presence(let presence):
|
||||
|
||||
+5
-7
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,11 +14,10 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
class TemplateUserProfileService: TemplateUserProfileServiceProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -46,8 +45,8 @@ class TemplateUserProfileService: TemplateUserProfileServiceProtocol {
|
||||
|
||||
init(session: MXSession) {
|
||||
self.session = session
|
||||
self.presenceSubject = CurrentValueSubject(TemplateUserProfilePresence(mxPresence: session.myUser.presence))
|
||||
self.listenerReference = setupPresenceListener()
|
||||
presenceSubject = CurrentValueSubject(TemplateUserProfilePresence(mxPresence: session.myUser.presence))
|
||||
listenerReference = setupPresenceListener()
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -70,8 +69,7 @@ class TemplateUserProfileService: TemplateUserProfileServiceProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate extension TemplateUserProfilePresence {
|
||||
|
||||
private extension TemplateUserProfilePresence {
|
||||
init(mxPresence: MXPresence) {
|
||||
switch mxPresence {
|
||||
case .online:
|
||||
|
||||
+8
-10
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
class MockTemplateUserProfileService: TemplateUserProfileServiceProtocol {
|
||||
var presenceSubject: CurrentValueSubject<TemplateUserProfilePresence, Never>
|
||||
@@ -23,19 +23,17 @@ class MockTemplateUserProfileService: TemplateUserProfileServiceProtocol {
|
||||
let userId: String
|
||||
let displayName: String?
|
||||
let avatarUrl: String?
|
||||
init(
|
||||
userId: String = "@alice:matrix.org",
|
||||
displayName: String? = "Alice",
|
||||
avatarUrl: String? = "mxc://matrix.org/VyNYAgahaiAzUoOeZETtQ",
|
||||
presence: TemplateUserProfilePresence = .offline
|
||||
) {
|
||||
init(userId: String = "@alice:matrix.org",
|
||||
displayName: String? = "Alice",
|
||||
avatarUrl: String? = "mxc://matrix.org/VyNYAgahaiAzUoOeZETtQ",
|
||||
presence: TemplateUserProfilePresence = .offline) {
|
||||
self.userId = userId
|
||||
self.displayName = displayName
|
||||
self.avatarUrl = avatarUrl
|
||||
self.presenceSubject = CurrentValueSubject<TemplateUserProfilePresence, Never>(presence)
|
||||
presenceSubject = CurrentValueSubject<TemplateUserProfilePresence, Never>(presence)
|
||||
}
|
||||
|
||||
func simulateUpdate(presence: TemplateUserProfilePresence) {
|
||||
self.presenceSubject.value = presence
|
||||
presenceSubject.value = presence
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
protocol TemplateUserProfileServiceProtocol: Avatarable {
|
||||
var userId: String { get }
|
||||
@@ -30,6 +30,7 @@ extension TemplateUserProfileServiceProtocol {
|
||||
var mxContentUri: String? {
|
||||
avatarUrl
|
||||
}
|
||||
|
||||
var matrixItemId: String {
|
||||
userId
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
+5
-6
@@ -14,15 +14,14 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
typealias TemplateUserProfileViewModelType = StateStoreViewModel<TemplateUserProfileViewState,
|
||||
Never,
|
||||
TemplateUserProfileViewAction>
|
||||
Never,
|
||||
TemplateUserProfileViewAction>
|
||||
|
||||
class TemplateUserProfileViewModel: TemplateUserProfileViewModelType, TemplateUserProfileViewModelProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -36,7 +35,7 @@ class TemplateUserProfileViewModel: TemplateUserProfileViewModelType, TemplateUs
|
||||
// MARK: - Setup
|
||||
|
||||
static func makeTemplateUserProfileViewModel(templateUserProfileService: TemplateUserProfileServiceProtocol) -> TemplateUserProfileViewModelProtocol {
|
||||
return TemplateUserProfileViewModel(templateUserProfileService: templateUserProfileService)
|
||||
TemplateUserProfileViewModel(templateUserProfileService: templateUserProfileService)
|
||||
}
|
||||
|
||||
private init(templateUserProfileService: TemplateUserProfileServiceProtocol) {
|
||||
@@ -46,7 +45,7 @@ class TemplateUserProfileViewModel: TemplateUserProfileViewModelType, TemplateUs
|
||||
}
|
||||
|
||||
private static func defaultState(templateUserProfileService: TemplateUserProfileServiceProtocol) -> TemplateUserProfileViewState {
|
||||
return TemplateUserProfileViewState(
|
||||
TemplateUserProfileViewState(
|
||||
avatar: templateUserProfileService.avatarData,
|
||||
displayName: templateUserProfileService.displayName,
|
||||
presence: templateUserProfileService.presenceSubject.value,
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,7 +17,6 @@
|
||||
import Foundation
|
||||
|
||||
protocol TemplateUserProfileViewModelProtocol {
|
||||
|
||||
var completion: ((TemplateUserProfileViewModelResult) -> Void)? { get set }
|
||||
static func makeTemplateUserProfileViewModel(templateUserProfileService: TemplateUserProfileServiceProtocol) -> TemplateUserProfileViewModelProtocol
|
||||
var context: TemplateUserProfileViewModelType.Context { get }
|
||||
|
||||
+1
-2
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import RiotSwiftUI
|
||||
import XCTest
|
||||
|
||||
class TemplateUserProfileUITests: MockScreenTestCase {
|
||||
func testTemplateUserProfilePresenceIdle() {
|
||||
@@ -53,5 +53,4 @@ class TemplateUserProfileUITests: MockScreenTestCase {
|
||||
XCTAssert(displayNameText.exists)
|
||||
XCTAssertEqual(displayNameText.label, name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Combine
|
||||
import XCTest
|
||||
|
||||
@testable import RiotSwiftUI
|
||||
|
||||
@@ -24,6 +24,7 @@ class TemplateUserProfileViewModelTests: XCTestCase {
|
||||
static let presenceInitialValue: TemplateUserProfilePresence = .offline
|
||||
static let displayName = "Alice"
|
||||
}
|
||||
|
||||
var service: MockTemplateUserProfileService!
|
||||
var viewModel: TemplateUserProfileViewModelProtocol!
|
||||
var context: TemplateUserProfileViewModelType.Context!
|
||||
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,7 +17,6 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TemplateUserProfile: View {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -36,7 +35,7 @@ struct TemplateUserProfile: View {
|
||||
presence: viewModel.viewState.presence
|
||||
)
|
||||
Divider()
|
||||
HStack{
|
||||
HStack {
|
||||
Text("Counter: \(viewModel.viewState.count)")
|
||||
.font(theme.fonts.title2)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
|
||||
+5
-4
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,13 +17,14 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TemplateUserProfileHeader: View {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
// MARK: Public
|
||||
|
||||
let avatar: AvatarInputProtocol?
|
||||
let displayName: String?
|
||||
let presence: TemplateUserProfilePresence
|
||||
@@ -32,9 +33,9 @@ struct TemplateUserProfileHeader: View {
|
||||
VStack {
|
||||
if let avatar = avatar {
|
||||
AvatarImage(avatarData: avatar, size: .xxLarge)
|
||||
.padding(.vertical)
|
||||
.padding(.vertical)
|
||||
}
|
||||
VStack(spacing: 8){
|
||||
VStack(spacing: 8) {
|
||||
Text(displayName ?? "")
|
||||
.font(theme.fonts.title3)
|
||||
.accessibility(identifier: "displayNameText")
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,10 +17,10 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TemplateUserProfilePresenceView: View {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Public
|
||||
|
||||
let presence: TemplateUserProfilePresence
|
||||
|
||||
var body: some View {
|
||||
@@ -54,7 +54,7 @@ struct TemplateUserProfilePresenceView: View {
|
||||
|
||||
struct TemplateUserProfilePresenceView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack(alignment:.leading){
|
||||
VStack(alignment: .leading) {
|
||||
Text("Presence")
|
||||
ForEach(TemplateUserProfilePresence.allCases) { presence in
|
||||
TemplateUserProfilePresenceView(presence: presence)
|
||||
|
||||
Reference in New Issue
Block a user