Removed unused swipe gesture (+3 squashed commits)

Squashed commits:
[d64bb3bb] Stop using the ServiceLocator directly in the ScreenTrackerViewModifier
[37c46ab9] Rename Analytics to AnalyticsService
[8852a371] #920 - Cleanup ServiceLocator usages
This commit is contained in:
Stefan Ceriu
2023-06-23 09:56:22 +03:00
committed by Stefan Ceriu
parent b4cd58b209
commit e6711a0236
104 changed files with 720 additions and 366 deletions
@@ -27,17 +27,22 @@ enum MockServerSelectionScreenState: CaseIterable {
switch self {
case .matrix:
return ServerSelectionScreenViewModel(homeserverAddress: "https://matrix.org",
slidingSyncLearnMoreURL: ServiceLocator.shared.settings.slidingSyncLearnMoreURL,
isModallyPresented: true)
case .emptyAddress:
return ServerSelectionScreenViewModel(homeserverAddress: "",
slidingSyncLearnMoreURL: ServiceLocator.shared.settings.slidingSyncLearnMoreURL,
isModallyPresented: true)
case .invalidAddress:
let viewModel = ServerSelectionScreenViewModel(homeserverAddress: "thisisbad",
slidingSyncLearnMoreURL: ServiceLocator.shared.settings.slidingSyncLearnMoreURL,
isModallyPresented: true)
viewModel.displayError(.footerMessage(L10n.errorUnknown))
return viewModel
case .nonModal:
return ServerSelectionScreenViewModel(homeserverAddress: "https://matrix.org",
slidingSyncLearnMoreURL: ServiceLocator.shared.settings.slidingSyncLearnMoreURL,
isModallyPresented: false)
}
}
@@ -40,6 +40,7 @@ final class ServerSelectionScreenCoordinator: CoordinatorProtocol {
init(parameters: ServerSelectionScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = ServerSelectionScreenViewModel(homeserverAddress: parameters.authenticationService.homeserver.value.address,
slidingSyncLearnMoreURL: ServiceLocator.shared.settings.slidingSyncLearnMoreURL,
isModallyPresented: parameters.isModallyPresented)
userIndicatorController = parameters.userIndicatorController
}
@@ -25,14 +25,7 @@ enum ServerSelectionScreenViewModelAction {
struct ServerSelectionScreenViewState: BindableState {
/// The message to be shown in the text field footer when no error has occurred.
private let regularFooterMessage = {
let linkPlaceholder = "{link}"
var message = AttributedString(L10n.screenChangeServerFormNotice(linkPlaceholder))
message.replace(linkPlaceholder,
with: L10n.actionLearnMore,
asLinkTo: ServiceLocator.shared.settings.slidingSyncLearnMoreURL)
return message
}()
private let regularFooterMessage: AttributedString
/// View state that can be bound to from SwiftUI.
var bindings: ServerSelectionScreenBindings
@@ -60,6 +53,19 @@ struct ServerSelectionScreenViewState: BindableState {
var hasValidationError: Bool {
bindings.homeserverAddress.isEmpty || isShowingFooterError
}
init(slidingSyncLearnMoreURL: URL, bindings: ServerSelectionScreenBindings, footerErrorMessage: String? = nil, isModallyPresented: Bool) {
self.bindings = bindings
self.footerErrorMessage = footerErrorMessage
self.isModallyPresented = isModallyPresented
let linkPlaceholder = "{link}"
var message = AttributedString(L10n.screenChangeServerFormNotice(linkPlaceholder))
message.replace(linkPlaceholder,
with: L10n.actionLearnMore,
asLinkTo: slidingSyncLearnMoreURL)
regularFooterMessage = message
}
}
struct ServerSelectionScreenBindings {
@@ -19,12 +19,16 @@ import SwiftUI
typealias ServerSelectionScreenViewModelType = StateStoreViewModel<ServerSelectionScreenViewState, ServerSelectionScreenViewAction>
class ServerSelectionScreenViewModel: ServerSelectionScreenViewModelType, ServerSelectionScreenViewModelProtocol {
private let slidingSyncLearnMoreURL: URL
var callback: (@MainActor (ServerSelectionScreenViewModelAction) -> Void)?
init(homeserverAddress: String, isModallyPresented: Bool) {
init(homeserverAddress: String, slidingSyncLearnMoreURL: URL, isModallyPresented: Bool) {
self.slidingSyncLearnMoreURL = slidingSyncLearnMoreURL
let bindings = ServerSelectionScreenBindings(homeserverAddress: homeserverAddress)
super.init(initialViewState: ServerSelectionScreenViewState(bindings: bindings,
super.init(initialViewState: ServerSelectionScreenViewState(slidingSyncLearnMoreURL: slidingSyncLearnMoreURL,
bindings: bindings,
isModallyPresented: isModallyPresented))
}
@@ -46,7 +50,7 @@ class ServerSelectionScreenViewModel: ServerSelectionScreenViewModelType, Server
state.footerErrorMessage = message
}
case .slidingSyncAlert:
let openURL = { UIApplication.shared.open(ServiceLocator.shared.settings.slidingSyncLearnMoreURL) }
let openURL = { UIApplication.shared.open(self.slidingSyncLearnMoreURL) }
state.bindings.alertInfo = AlertInfo(id: .slidingSyncAlert,
title: L10n.commonServerNotSupported,
message: L10n.screenChangeServerErrorNoSlidingSyncMessage,