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
@@ -40,7 +40,7 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
init(parameters: SettingsScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = SettingsScreenViewModel(withUserSession: parameters.userSession)
viewModel = SettingsScreenViewModel(userSession: parameters.userSession, appSettings: ServiceLocator.shared.settings)
viewModel.callback = { [weak self] action in
guard let self else { return }
@@ -72,7 +72,8 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
// MARK: - Private
private func presentAnalyticsScreen() {
let coordinator = AnalyticsSettingsScreenCoordinator()
let coordinator = AnalyticsSettingsScreenCoordinator(parameters: .init(appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics))
parameters.navigationStackCoordinator?.push(coordinator)
}
@@ -21,12 +21,15 @@ typealias SettingsScreenViewModelType = StateStoreViewModel<SettingsScreenViewSt
class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewModelProtocol {
private let userSession: UserSessionProtocol
private let appSettings: AppSettings
var callback: ((SettingsScreenViewModelAction) -> Void)?
init(withUserSession userSession: UserSessionProtocol) {
init(userSession: UserSessionProtocol, appSettings: AppSettings) {
self.userSession = userSession
let bindings = SettingsScreenViewStateBindings(timelineStyle: ServiceLocator.shared.settings.timelineStyle)
self.appSettings = appSettings
let bindings = SettingsScreenViewStateBindings(timelineStyle: appSettings.timelineStyle)
var showSessionVerificationSection = false
if let sessionVerificationController = userSession.sessionVerificationController {
@@ -37,10 +40,10 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
deviceID: userSession.deviceID,
userID: userSession.userID,
showSessionVerificationSection: showSessionVerificationSection,
showDeveloperOptions: ServiceLocator.shared.settings.canShowDeveloperOptions),
showDeveloperOptions: appSettings.canShowDeveloperOptions),
imageProvider: userSession.mediaProvider)
ServiceLocator.shared.settings.$timelineStyle
appSettings.$timelineStyle
.weakAssign(to: \.state.bindings.timelineStyle, on: self)
.store(in: &cancellables)
@@ -88,7 +91,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
case .sessionVerification:
callback?(.sessionVerification)
case .changedTimelineStyle:
ServiceLocator.shared.settings.timelineStyle = state.bindings.timelineStyle
appSettings.timelineStyle = state.bindings.timelineStyle
case .developerOptions:
callback?(.developerOptions)
}
@@ -194,7 +194,8 @@ struct SettingsScreen_Previews: PreviewProvider {
static let viewModel = {
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "@userid:example.com"),
mediaProvider: MockMediaProvider())
return SettingsScreenViewModel(withUserSession: userSession)
return SettingsScreenViewModel(userSession: userSession,
appSettings: ServiceLocator.shared.settings)
}()
static var previews: some View {