Configured and applied SwiftFormat

This commit is contained in:
Stefan Ceriu
2022-09-27 10:17:22 +03:00
committed by Stefan Ceriu
parent ff2e6ddfa7
commit 43c28d23b7
663 changed files with 2329 additions and 2840 deletions
@@ -17,11 +17,10 @@
*/
import Foundation
import UIKit
import SwiftUI
import UIKit
final class SpaceCreationEmailInvitesCoordinator: Coordinator, Presentable {
// MARK: - Properties
// MARK: Private
@@ -75,7 +74,7 @@ final class SpaceCreationEmailInvitesCoordinator: Coordinator, Presentable {
}
func toPresentable() -> UIViewController {
return self.spaceCreationEmailInvitesHostingController
spaceCreationEmailInvitesHostingController
}
// MARK: - Identity service
@@ -90,34 +89,34 @@ final class SpaceCreationEmailInvitesCoordinator: Coordinator, Presentable {
let presenter = ServiceTermsModalCoordinatorBridgePresenter(session: parameters.session, baseUrl: baseUrl, serviceType: MXServiceTypeIdentityService, accessToken: accessToken)
presenter.delegate = self
presenter.present(from: self.toPresentable(), animated: true)
presenter.present(from: toPresentable(), animated: true)
serviceTermsModalCoordinatorBridgePresenter = presenter
}
private func showIdentityServiceFailure(_ error: Error?) {
let alertController = UIAlertController(title: VectorL10n.findYourContactsIdentityServiceError, message: nil, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: VectorL10n.ok, style: .default, handler: nil))
self.toPresentable().present(alertController, animated: true, completion: nil);
toPresentable().present(alertController, animated: true, completion: nil)
}
}
extension SpaceCreationEmailInvitesCoordinator: ServiceTermsModalCoordinatorBridgePresenterDelegate {
func serviceTermsModalCoordinatorBridgePresenterDelegateDidAccept(_ coordinatorBridgePresenter: ServiceTermsModalCoordinatorBridgePresenter) {
coordinatorBridgePresenter.dismiss(animated: true) {
self.serviceTermsModalCoordinatorBridgePresenter = nil;
self.serviceTermsModalCoordinatorBridgePresenter = nil
self.callback?(.done)
}
}
func serviceTermsModalCoordinatorBridgePresenterDelegateDidDecline(_ coordinatorBridgePresenter: ServiceTermsModalCoordinatorBridgePresenter, session: MXSession) {
coordinatorBridgePresenter.dismiss(animated: true) {
self.serviceTermsModalCoordinatorBridgePresenter = nil;
self.serviceTermsModalCoordinatorBridgePresenter = nil
}
}
func serviceTermsModalCoordinatorBridgePresenterDelegateDidClose(_ coordinatorBridgePresenter: ServiceTermsModalCoordinatorBridgePresenter) {
coordinatorBridgePresenter.dismiss(animated: true) {
self.serviceTermsModalCoordinatorBridgePresenter = nil;
self.serviceTermsModalCoordinatorBridgePresenter = nil
}
}
}
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,11 +16,10 @@
// limitations under the License.
//
import Foundation
import Combine
import Foundation
class SpaceCreationEmailInvitesService: SpaceCreationEmailInvitesServiceProtocol {
private let session: MXSession
private(set) var isLoadingSubject: CurrentValueSubject<Bool, Never>
@@ -37,12 +36,12 @@ class SpaceCreationEmailInvitesService: SpaceCreationEmailInvitesServiceProtocol
}
func validate(_ emailAddresses: [String]) -> [Bool] {
return emailAddresses.map { $0.isEmpty || MXTools.isEmailAddress($0) }
emailAddresses.map { $0.isEmpty || MXTools.isEmailAddress($0) }
}
func prepareIdentityService(prepared: ((String?, String?) -> Void)?, failure: ((Error?) -> Void)?) {
isLoadingSubject.send(true)
session.prepareIdentityServiceForTerms(withDefault: RiotSettings.shared.identityServerUrlString) { [weak self] session, baseURL, accessToken in
session.prepareIdentityServiceForTerms(withDefault: RiotSettings.shared.identityServerUrlString) { [weak self] _, baseURL, accessToken in
self?.isLoadingSubject.send(false)
prepared?(baseURL, accessToken)
} failure: { [weak self] error in
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,7 +41,7 @@ enum MockSpaceCreationEmailInvitesScreenState: MockScreenState, CaseIterable {
}
/// Generate the view struct for the screen state.
var screenView: ([Any], AnyView) {
var screenView: ([Any], AnyView) {
let creationParams = SpaceCreationParameters()
let service: MockSpaceCreationEmailInvitesService
switch self {
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +16,8 @@
// limitations under the License.
//
import Foundation
import Combine
import Foundation
class MockSpaceCreationEmailInvitesService: SpaceCreationEmailInvitesServiceProtocol {
var isLoadingSubject: CurrentValueSubject<Bool, Never>
@@ -25,16 +25,16 @@ class MockSpaceCreationEmailInvitesService: SpaceCreationEmailInvitesServiceProt
private let defaultValidation: Bool
var isIdentityServiceReady: Bool {
return true
true
}
init(defaultValidation: Bool, isLoading: Bool) {
self.defaultValidation = defaultValidation
self.isLoadingSubject = CurrentValueSubject(isLoading)
isLoadingSubject = CurrentValueSubject(isLoading)
}
func validate(_ emailAddresses: [String]) -> [Bool] {
return emailAddresses.map { _ in defaultValidation }
emailAddresses.map { _ in defaultValidation }
}
func prepareIdentityService(prepared: ((String?, String?) -> Void)?, failure: ((Error?) -> Void)?) {
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +16,8 @@
// limitations under the License.
//
import Foundation
import Combine
import Foundation
protocol SpaceCreationEmailInvitesServiceProtocol {
var isIdentityServiceReady: Bool { get }
@@ -16,8 +16,8 @@
// limitations under the License.
//
import XCTest
import RiotSwiftUI
import XCTest
class SpaceCreationEmailInvitesUITests: MockScreenTestCase {
func testDefaultEmailValues() {
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +16,8 @@
// limitations under the License.
//
import XCTest
import Combine
import XCTest
@testable import RiotSwiftUI
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,6 @@
import SwiftUI
struct SpaceCreationEmailInvites: View {
// MARK: - Properties
@ObservedObject var viewModel: SpaceCreationEmailInvitesViewModel.Context
@@ -85,7 +84,7 @@ struct SpaceCreationEmailInvites: View {
private var formView: some View {
VStack {
VStack(spacing: 20) {
ForEach(viewModel.emailInvites.indices) { index in
ForEach(viewModel.emailInvites.indices, id: \.self) { index in
RoundedBorderTextField(title: VectorL10n.spacesCreationEmailInvitesEmailTitle, placeHolder: VectorL10n.spacesCreationEmailInvitesEmailTitle, text: $viewModel.emailInvites[index], footerText: viewModel.viewState.emailAddressesValid[index] ? nil : VectorL10n.authInvalidEmail, isError: !viewModel.viewState.emailAddressesValid[index], configuration: UIKitTextInputConfiguration(keyboardType: .emailAddress, returnKeyType: index < viewModel.emailInvites.endIndex - 1 ? .next : .done, autocapitalizationType: .none, autocorrectionType: .no))
.accessibility(identifier: "emailTextField")
}
@@ -16,14 +16,13 @@
// limitations under the License.
//
import SwiftUI
import Combine
import SwiftUI
typealias SpaceCreationEmailInvitesViewModelType = StateStoreViewModel<SpaceCreationEmailInvitesViewState,
SpaceCreationEmailInvitesStateAction,
SpaceCreationEmailInvitesViewAction>
SpaceCreationEmailInvitesStateAction,
SpaceCreationEmailInvitesViewAction>
class SpaceCreationEmailInvitesViewModel: SpaceCreationEmailInvitesViewModelType, SpaceCreationEmailInvitesViewModelProtocol {
// MARK: - Properties
// MARK: Private
@@ -86,14 +85,14 @@ class SpaceCreationEmailInvitesViewModel: SpaceCreationEmailInvitesViewModelType
}
private func done() {
self.creationParameters.emailInvites = self.context.emailInvites
self.creationParameters.inviteType = .email
let emailAddressesValidity = service.validate(self.context.emailInvites)
creationParameters.emailInvites = context.emailInvites
creationParameters.inviteType = .email
let emailAddressesValidity = service.validate(context.emailInvites)
dispatch(action: .updateEmailValidity(emailAddressesValidity))
if self.context.emailInvites.reduce(true, { $0 && $1.isEmpty }) {
if context.emailInvites.reduce(true, { $0 && $1.isEmpty }) {
completion?(.done)
} else if emailAddressesValidity.reduce(true, { $0 && $1}) {
} else if emailAddressesValidity.reduce(true, { $0 && $1 }) {
if service.isIdentityServiceReady {
completion?(.done)
} else {
@@ -1,6 +1,6 @@
// File created from SimpleUserProfileExample
// $ createScreen.sh Spaces/SpaceCreation/SpaceCreationEmailInvites SpaceCreationEmailInvites
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,6 @@
import Foundation
protocol SpaceCreationEmailInvitesViewModelProtocol {
var completion: ((SpaceCreationEmailInvitesViewModelResult) -> Void)? { get set }
var context: SpaceCreationEmailInvitesViewModelType.Context { get }
}