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
@@ -26,7 +26,6 @@ enum RoomAccessCoordinatorCoordinatorAction {
@objcMembers
final class RoomAccessCoordinator: Coordinator {
// MARK: - Properties
// MARK: Private
@@ -35,7 +34,7 @@ final class RoomAccessCoordinator: Coordinator {
private var upgradedRoomId: String?
private var navigationRouter: NavigationRouterType {
return self.parameters.navigationRouter
parameters.navigationRouter
}
// MARK: Public
@@ -58,32 +57,31 @@ final class RoomAccessCoordinator: Coordinator {
init(parameters: RoomAccessCoordinatorParameters) {
self.parameters = parameters
}
}
// MARK: - Public
func start() {
MXLog.debug("[RoomAccessCoordinator] did start.")
let rootCoordinator = self.createRoomAccessTypeCoordinator()
let rootCoordinator = createRoomAccessTypeCoordinator()
rootCoordinator.start()
self.add(childCoordinator: rootCoordinator)
self.accessCoordinator = rootCoordinator
add(childCoordinator: rootCoordinator)
accessCoordinator = rootCoordinator
if self.navigationRouter.modules.isEmpty == false {
self.navigationRouter.push(rootCoordinator, animated: true, popCompletion: { [weak self] in
if navigationRouter.modules.isEmpty == false {
navigationRouter.push(rootCoordinator, animated: true, popCompletion: { [weak self] in
self?.remove(childCoordinator: rootCoordinator)
})
} else {
self.navigationRouter.setRootModule(rootCoordinator) { [weak self] in
navigationRouter.setRootModule(rootCoordinator) { [weak self] in
self?.remove(childCoordinator: rootCoordinator)
}
}
}
func toPresentable() -> UIViewController {
return self.navigationRouter.toPresentable()
navigationRouter.toPresentable()
}
// MARK: - Private
@@ -91,7 +89,7 @@ final class RoomAccessCoordinator: Coordinator {
func pushScreen(with coordinator: Coordinator & Presentable) {
add(childCoordinator: coordinator)
self.navigationRouter.push(coordinator, animated: true, popCompletion: { [weak self] in
navigationRouter.push(coordinator, animated: true, popCompletion: { [weak self] in
self?.remove(childCoordinator: coordinator)
})
@@ -103,13 +101,13 @@ final class RoomAccessCoordinator: Coordinator {
coordinator.toPresentable().modalPresentationStyle = .overFullScreen
coordinator.toPresentable().modalTransitionStyle = .crossDissolve
self.navigationRouter.present(coordinator, animated: true)
navigationRouter.present(coordinator, animated: true)
coordinator.start()
}
private func createRoomAccessTypeCoordinator() -> RoomAccessTypeChooserCoordinator {
let coordinator: RoomAccessTypeChooserCoordinator = RoomAccessTypeChooserCoordinator(parameters: RoomAccessTypeChooserCoordinatorParameters(roomId: parameters.room.roomId, allowsRoomUpgrade: parameters.allowsRoomUpgrade, session: parameters.room.mxSession))
let coordinator = RoomAccessTypeChooserCoordinator(parameters: RoomAccessTypeChooserCoordinatorParameters(roomId: parameters.room.roomId, allowsRoomUpgrade: parameters.allowsRoomUpgrade, session: parameters.room.mxSession))
coordinator.callback = { [weak self] result in
guard let self = self else { return }
@@ -132,7 +130,8 @@ final class RoomAccessCoordinator: Coordinator {
let paramaters = MatrixItemChooserCoordinatorParameters(
session: parameters.room.mxSession,
viewProvider: RoomRestrictedAccessSpaceChooserViewProvider(navTitle: VectorL10n.roomAccessSettingsScreenNavTitle),
itemsProcessor: RoomRestrictedAccessSpaceChooserItemsProcessor(roomId: roomId, session: parameters.room.mxSession))
itemsProcessor: RoomRestrictedAccessSpaceChooserItemsProcessor(roomId: roomId, session: parameters.room.mxSession)
)
let coordinator = MatrixItemChooserCoordinator(parameters: paramaters)
coordinator.completion = { [weak self] result in
guard let self = self else { return }
@@ -154,7 +153,8 @@ final class RoomAccessCoordinator: Coordinator {
session: parameters.room.mxSession,
roomId: roomId,
parentSpaceId: parameters.parentSpaceId,
versionOverride: versionOverride)
versionOverride: versionOverride
)
let coordinator = RoomUpgradeCoordinator(parameters: paramaters)
coordinator.completion = { [weak self] result in
@@ -1,4 +1,5 @@
//
import MatrixSDK
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +15,6 @@
// limitations under the License.
//
import UIKit
import MatrixSDK
@objc protocol RoomAccessCoordinatorBridgePresenterDelegate {
func roomAccessCoordinatorBridgePresenterDelegate(_ coordinatorBridgePresenter: RoomAccessCoordinatorBridgePresenter, didCancelRoomWithId roomId: String)
@@ -27,7 +27,6 @@ import MatrixSDK
/// Each bridge should be removed once the underlying Coordinator has been integrated by another Coordinator.
@objcMembers
final class RoomAccessCoordinatorBridgePresenter: NSObject {
// MARK: - Properties
// MARK: Private
@@ -82,7 +81,7 @@ final class RoomAccessCoordinatorBridgePresenter: NSObject {
}
func dismiss(animated: Bool, completion: (() -> Void)?) {
guard let coordinator = self.coordinator else {
guard let coordinator = coordinator else {
return
}
coordinator.toPresentable().dismiss(animated: animated) {
@@ -98,13 +97,11 @@ final class RoomAccessCoordinatorBridgePresenter: NSObject {
// MARK: - UIAdaptivePresentationControllerDelegate
extension RoomAccessCoordinatorBridgePresenter: UIAdaptivePresentationControllerDelegate {
func roomNotificationSettingsCoordinatorDidComplete(_ presentationController: UIPresentationController) {
if let roomId = self.coordinator?.currentRoomId {
self.delegate?.roomAccessCoordinatorBridgePresenterDelegate(self, didCancelRoomWithId: roomId)
if let roomId = coordinator?.currentRoomId {
delegate?.roomAccessCoordinatorBridgePresenterDelegate(self, didCancelRoomWithId: roomId)
} else {
self.delegate?.roomAccessCoordinatorBridgePresenterDelegate(self, didCancelRoomWithId: self.room.roomId)
delegate?.roomAccessCoordinatorBridgePresenterDelegate(self, didCancelRoomWithId: room.roomId)
}
}
}
@@ -20,7 +20,6 @@ import Foundation
/// RoomAccessCoordinator input parameters
struct RoomAccessCoordinatorParameters {
/// The Matrix room
let room: MXRoom
@@ -23,7 +23,6 @@ struct RoomAccessTypeChooserCoordinatorParameters {
}
final class RoomAccessTypeChooserCoordinator: Coordinator, Presentable {
// MARK: - Properties
// MARK: Private
@@ -70,10 +69,10 @@ final class RoomAccessTypeChooserCoordinator: Coordinator, Presentable {
}
func toPresentable() -> UIViewController {
return self.roomAccessTypeChooserHostingController
roomAccessTypeChooserHostingController
}
func handleRoomUpgradeResult(_ result: RoomUpgradeCoordinatorResult) {
self.roomAccessTypeChooserViewModel.handleRoomUpgradeResult(result)
roomAccessTypeChooserViewModel.handleRoomUpgradeResult(result)
}
}
@@ -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
import SwiftUI
/// Using an enum for the screen allows you define the different state cases with
/// the relevant associated data for each case.
enum MockRoomAccessTypeChooserScreenState: MockScreenState, CaseIterable {
@@ -42,7 +41,7 @@ enum MockRoomAccessTypeChooserScreenState: MockScreenState, CaseIterable {
service = MockRoomAccessTypeChooserService(accessItems: [
RoomAccessTypeChooserAccessItem(id: .private, isSelected: true, title: VectorL10n.private, detail: VectorL10n.roomAccessSettingsScreenPrivateMessage, badgeText: nil),
RoomAccessTypeChooserAccessItem(id: .restricted, isSelected: false, title: VectorL10n.createRoomTypeRestricted, detail: VectorL10n.roomAccessSettingsScreenRestrictedMessage, badgeText: VectorL10n.roomAccessSettingsScreenUpgradeRequired),
RoomAccessTypeChooserAccessItem(id: .public, isSelected: false, title: VectorL10n.public, detail: VectorL10n.roomAccessSettingsScreenPublicMessage, badgeText: nil),
RoomAccessTypeChooserAccessItem(id: .public, isSelected: false, title: VectorL10n.public, detail: VectorL10n.roomAccessSettingsScreenPublicMessage, badgeText: nil)
])
}
let viewModel = RoomAccessTypeChooserViewModel(roomAccessTypeChooserService: service)
@@ -1,4 +1,4 @@
//
//
// 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");
@@ -14,14 +14,13 @@
// limitations under the License.
//
import SwiftUI
import Combine
import SwiftUI
typealias RoomAccessTypeChooserViewModelType = StateStoreViewModel<RoomAccessTypeChooserViewState,
RoomAccessTypeChooserStateAction,
RoomAccessTypeChooserViewAction>
RoomAccessTypeChooserStateAction,
RoomAccessTypeChooserViewAction>
class RoomAccessTypeChooserViewModel: RoomAccessTypeChooserViewModelType, RoomAccessTypeChooserViewModelProtocol {
// MARK: - Properties
// MARK: Private
@@ -43,7 +42,8 @@ class RoomAccessTypeChooserViewModel: RoomAccessTypeChooserViewModelType, RoomAc
private static func defaultState(roomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol) -> RoomAccessTypeChooserViewState {
let bindings = RoomAccessTypeChooserViewModelBindings(
showUpgradeRoomAlert: roomAccessTypeChooserService.roomUpgradeRequiredSubject.value,
waitingMessage: roomAccessTypeChooserService.waitingMessageSubject.value, isLoading: roomAccessTypeChooserService.waitingMessageSubject.value != nil)
waitingMessage: roomAccessTypeChooserService.waitingMessageSubject.value, isLoading: roomAccessTypeChooserService.waitingMessageSubject.value != nil
)
return RoomAccessTypeChooserViewState(accessItems: roomAccessTypeChooserService.accessItemsSubject.value, bindings: bindings)
}
@@ -130,7 +130,7 @@ class RoomAccessTypeChooserViewModel: RoomAccessTypeChooserViewModelType, RoomAc
private func didSelect(accessType: RoomAccessTypeChooserAccessType) {
roomAccessTypeChooserService.updateSelection(with: accessType)
if accessType == .restricted && !roomAccessTypeChooserService.roomUpgradeRequiredSubject.value {
if accessType == .restricted, !roomAccessTypeChooserService.roomUpgradeRequiredSubject.value {
callback?(.spaceSelection(roomAccessTypeChooserService.currentRoomId, .restricted))
}
}
@@ -1,4 +1,4 @@
//
//
// 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");
@@ -14,12 +14,11 @@
// limitations under the License.
//
import Foundation
import Combine
import Foundation
import MatrixSDK
class RoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
// MARK: - Properties
// MARK: Private
@@ -40,6 +39,7 @@ class RoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
accessItemsSubject.send(accessItems)
}
}
private(set) var selectedType: RoomAccessTypeChooserAccessType = .private {
didSet {
for (index, item) in accessItems.enumerated() {
@@ -48,6 +48,7 @@ class RoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
accessItemsSubject.send(accessItems)
}
}
private var roomJoinRule: MXRoomJoinRule = .private
private var currentOperation: MXHTTPOperation?
@@ -67,8 +68,8 @@ class RoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
self.roomId = roomId
self.allowsRoomUpgrade = allowsRoomUpgrade
self.session = session
self.currentRoomId = roomId
self.versionOverride = session.homeserverCapabilitiesService.versionOverrideForFeature(.restricted)
currentRoomId = roomId
versionOverride = session.homeserverCapabilitiesService.versionOverrideForFeature(.restricted)
roomUpgradeRequiredSubject = CurrentValueSubject(false)
waitingMessageSubject = CurrentValueSubject(nil)
@@ -92,7 +93,7 @@ class RoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
self.selectedType = selectedType
if selectedType == .restricted {
if roomUpgradeRequired && roomUpgradeRequiredSubject.value == false {
if roomUpgradeRequired, roomUpgradeRequiredSubject.value == false {
roomUpgradeRequiredSubject.send(true)
}
}
@@ -108,14 +109,14 @@ class RoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
let _joinRule: MXRoomJoinRule?
switch self.selectedType {
switch selectedType {
case .private:
_joinRule = .invite
case .public:
_joinRule = .public
case .restricted:
_joinRule = nil
if roomUpgradeRequired && roomUpgradeRequiredSubject.value == false {
if roomUpgradeRequired, roomUpgradeRequiredSubject.value == false {
roomUpgradeRequiredSubject.send(true)
} else {
completion()
@@ -123,7 +124,7 @@ class RoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
}
if let joinRule = _joinRule {
self.waitingMessageSubject.send(VectorL10n.roomAccessSettingsScreenSettingRoomAccess)
waitingMessageSubject.send(VectorL10n.roomAccessSettingsScreenSettingRoomAccess)
room.setJoinRule(joinRule) { [weak self] response in
guard let self = self else { return }
@@ -140,7 +141,7 @@ class RoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
}
func updateRoomId(with roomId: String) {
self.currentRoomId = roomId
currentRoomId = roomId
readRoomState()
}
@@ -148,17 +149,17 @@ class RoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
private func setupAccessItems() {
guard let spaceService = session.spaceService, let ancestors = spaceService.ancestorsPerRoomId[currentRoomId], !ancestors.isEmpty, allowsRoomUpgrade || !roomUpgradeRequired else {
self.accessItems = [
accessItems = [
RoomAccessTypeChooserAccessItem(id: .private, isSelected: false, title: VectorL10n.private, detail: VectorL10n.roomAccessSettingsScreenPrivateMessage, badgeText: nil),
RoomAccessTypeChooserAccessItem(id: .public, isSelected: false, title: VectorL10n.public, detail: VectorL10n.roomAccessSettingsScreenPublicMessage, badgeText: nil),
RoomAccessTypeChooserAccessItem(id: .public, isSelected: false, title: VectorL10n.public, detail: VectorL10n.roomAccessSettingsScreenPublicMessage, badgeText: nil)
]
return
}
self.accessItems = [
accessItems = [
RoomAccessTypeChooserAccessItem(id: .private, isSelected: false, title: VectorL10n.private, detail: VectorL10n.roomAccessSettingsScreenPrivateMessage, badgeText: nil),
RoomAccessTypeChooserAccessItem(id: .restricted, isSelected: false, title: VectorL10n.createRoomTypeRestricted, detail: VectorL10n.roomAccessSettingsScreenRestrictedMessage, badgeText: roomUpgradeRequired ? VectorL10n.roomAccessSettingsScreenUpgradeRequired : VectorL10n.roomAccessSettingsScreenEditSpaces),
RoomAccessTypeChooserAccessItem(id: .public, isSelected: false, title: VectorL10n.public, detail: VectorL10n.roomAccessSettingsScreenPublicMessage, badgeText: nil),
RoomAccessTypeChooserAccessItem(id: .public, isSelected: false, title: VectorL10n.public, detail: VectorL10n.roomAccessSettingsScreenPublicMessage, badgeText: nil)
]
accessItemsSubject.send(accessItems)
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,15 +14,14 @@
// limitations under the License.
//
import Foundation
import Combine
import Foundation
class MockRoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
static let mockAccessItems: [RoomAccessTypeChooserAccessItem] = [
RoomAccessTypeChooserAccessItem(id: .private, isSelected: true, title: VectorL10n.private, detail: VectorL10n.roomAccessSettingsScreenPrivateMessage, badgeText: nil),
RoomAccessTypeChooserAccessItem(id: .restricted, isSelected: false, title: VectorL10n.createRoomTypeRestricted, detail: VectorL10n.roomAccessSettingsScreenRestrictedMessage, badgeText: VectorL10n.roomAccessSettingsScreenUpgradeRequired),
RoomAccessTypeChooserAccessItem(id: .public, isSelected: false, title: VectorL10n.public, detail: VectorL10n.roomAccessSettingsScreenPublicMessage, badgeText: nil),
RoomAccessTypeChooserAccessItem(id: .public, isSelected: false, title: VectorL10n.public, detail: VectorL10n.roomAccessSettingsScreenPublicMessage, badgeText: nil)
]
private(set) var accessItemsSubject: CurrentValueSubject<[RoomAccessTypeChooserAccessItem], Never>
@@ -31,9 +30,9 @@ class MockRoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
private(set) var errorSubject: CurrentValueSubject<Error?, Never>
private(set) var selectedType: RoomAccessTypeChooserAccessType = .private
var currentRoomId: String = "!aaabaa:matrix.org"
var currentRoomId = "!aaabaa:matrix.org"
var versionOverride: String? {
return "9"
"9"
}
init(accessItems: [RoomAccessTypeChooserAccessItem] = mockAccessItems) {
@@ -44,18 +43,14 @@ class MockRoomAccessTypeChooserService: RoomAccessTypeChooserServiceProtocol {
}
func simulateUpdate(accessItems: [RoomAccessTypeChooserAccessItem]) {
self.accessItemsSubject.send(accessItems)
accessItemsSubject.send(accessItems)
}
func updateSelection(with selectedType: RoomAccessTypeChooserAccessType) {
}
func updateSelection(with selectedType: RoomAccessTypeChooserAccessType) { }
func updateRoomId(with roomId: String) {
currentRoomId = roomId
}
func applySelection(completion: @escaping () -> Void) {
}
func applySelection(completion: @escaping () -> Void) { }
}
@@ -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 RoomAccessTypeChooserServiceProtocol {
var accessItemsSubject: CurrentValueSubject<[RoomAccessTypeChooserAccessItem], Never> { get }
@@ -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 RiotSwiftUI
import XCTest
class RoomAccessTypeChooserUITests: MockScreenTestCase {
// Tests to be implemented.
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,11 +14,9 @@
// limitations under the License.
//
import XCTest
import Combine
import XCTest
@testable import RiotSwiftUI
class RoomAccessTypeChooserViewModelTests: XCTestCase {
}
class RoomAccessTypeChooserViewModelTests: XCTestCase { }
@@ -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 RoomAccessTypeChooser: View {
// MARK: - Properties
// MARK: Private
@@ -55,7 +54,7 @@ struct RoomAccessTypeChooser: View {
@ViewBuilder
private var listContent: some View {
ScrollView{
ScrollView {
VStack(alignment: .leading) {
Text(VectorL10n.roomAccessSettingsScreenTitle)
.foregroundColor(theme.colors.primaryContent)
@@ -84,7 +83,6 @@ struct RoomAccessTypeChooser: View {
// MARK: - Previews
struct RoomAccessTypeChooser_Previews: PreviewProvider {
static let stateRenderer = MockRoomAccessTypeChooserScreenState.stateRenderer
static var previews: some View {
stateRenderer.screenGroup(addNavigation: true)
@@ -17,7 +17,6 @@
import SwiftUI
struct RoomAccessTypeChooserRow: View {
// MARK: - Properties
// MARK: Private
@@ -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
class RoomRestrictedAccessSpaceChooserViewProvider: MatrixItemChooserCoordinatorViewProvider {
private let navTitle: String?
init(navTitle: String?) {
@@ -25,6 +24,6 @@ class RoomRestrictedAccessSpaceChooserViewProvider: MatrixItemChooserCoordinator
}
func view(with viewModel: MatrixItemChooserViewModelType.Context) -> AnyView {
return AnyView(RoomRestrictedAccessSpaceChooserSelector(viewModel: viewModel, navTitle: navTitle))
AnyView(RoomRestrictedAccessSpaceChooserSelector(viewModel: viewModel, navTitle: navTitle))
}
}
@@ -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
class RoomRestrictedAccessSpaceChooserItemsProcessor: MatrixItemChooserProcessorProtocol {
// MARK: Private
private let roomId: String
@@ -28,7 +27,7 @@ class RoomRestrictedAccessSpaceChooserItemsProcessor: MatrixItemChooserProcessor
init(roomId: String, session: MXSession) {
self.roomId = roomId
self.session = session
self.dataSource = MatrixItemChooserRoomRestrictedAllowedParentsDataSource(roomId: roomId)
dataSource = MatrixItemChooserRoomRestrictedAllowedParentsDataSource(roomId: roomId)
}
// MARK: MatrixItemChooserSelectionProcessorProtocol
@@ -50,7 +49,7 @@ class RoomRestrictedAccessSpaceChooserItemsProcessor: MatrixItemChooserProcessor
}
}
func isItemIncluded(_ item: (MatrixListItemData)) -> Bool {
return true
func isItemIncluded(_ item: MatrixListItemData) -> Bool {
true
}
}
@@ -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 RoomRestrictedAccessSpaceChooserSelector: View {
// MARK: Properties
@ObservedObject var viewModel: MatrixItemChooserViewModel.Context
@@ -51,5 +50,4 @@ struct RoomRestrictedAccessSpaceChooserSelector: View {
}
}
}
}