Space Settings: Leave Room (#4700)

* Implementation for all navigations inside the space settings aside the left space action

# Conflicts:
#	ElementX/Sources/FlowCoordinators/SpaceSettingsFlowCoordinator.swift

* refactored the leave space view to use its own view model

# Conflicts:
#	ElementX.xcodeproj/project.pbxproj

* implemented the leave space view model also in the settings screen, and corrected some tests

* reusing the details coordinator for the space settings screen

* leave space from settings implemented

* fix project

* minor pr fixes

* code improvements
This commit is contained in:
Mauro
2025-11-07 12:11:21 +01:00
committed by GitHub
parent 8974a4584a
commit 096e2d1713
22 changed files with 407 additions and 277 deletions
@@ -1,76 +0,0 @@
//
// Copyright 2025 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Combine
import SwiftUI
struct SpaceSettingsScreenCoordinatorParameters {
let roomProxy: JoinedRoomProxyProtocol
let userSession: UserSessionProtocol
let analyticsService: AnalyticsService
let userIndicator: UserIndicatorControllerProtocol
let notificationSettingsProxy: NotificationSettingsProxyProtocol
let attributedStringBuilder: AttributedStringBuilderProtocol
let appSettings: AppSettings
}
enum SpaceSettingsScreenCoordinatorAction {
case presentEditDetailsScreen
case presentSecurityAndPrivacyScreen
case presentMembersListScreen
case presentRolesAndPermissionsScreen
}
final class SpaceSettingsScreenCoordinator: CoordinatorProtocol {
private let viewModel: RoomDetailsScreenViewModelProtocol
private var cancellables = Set<AnyCancellable>()
private let actionsSubject: PassthroughSubject<SpaceSettingsScreenCoordinatorAction, Never> = .init()
var actionsPublisher: AnyPublisher<SpaceSettingsScreenCoordinatorAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
init(parameters: SpaceSettingsScreenCoordinatorParameters) {
viewModel = RoomDetailsScreenViewModel(roomProxy: parameters.roomProxy,
userSession: parameters.userSession,
analyticsService: parameters.analyticsService,
userIndicatorController: parameters.userIndicator,
notificationSettingsProxy: parameters.notificationSettingsProxy,
attributedStringBuilder: parameters.attributedStringBuilder,
appSettings: parameters.appSettings)
}
func start() {
viewModel.actions.sink { [weak self] action in
MXLog.info("Coordinator: received view model action: \(action)")
guard let self else { return }
switch action {
case .requestNotificationSettingsPresentation, .requestRecipientDetailsPresentation, .requestInvitePeoplePresentation, .requestPollsHistoryPresentation,
.startCall, .displayPinnedEventsTimeline, .displayMediaEventsTimeline, .displayKnockingRequests,
.displayReportRoom, .transferOwnership:
break // Not handled in this context
case .requestEditDetailsPresentation:
actionsSubject.send(.presentEditDetailsScreen)
case .displaySecurityAndPrivacy:
actionsSubject.send(.presentSecurityAndPrivacyScreen)
case .requestMemberDetailsPresentation:
actionsSubject.send(.presentMembersListScreen)
case .requestRolesAndPermissionsPresentation:
actionsSubject.send(.presentRolesAndPermissionsScreen)
case .leftRoom:
break // TODO:
}
}
.store(in: &cancellables)
}
func toPresentable() -> AnyView {
AnyView(SpaceSettingsScreen(context: viewModel.context))
}
}
@@ -22,6 +22,9 @@ struct SpaceSettingsScreen: View {
}
.compoundList()
.navigationTitle(L10n.commonSettings)
.sheet(item: $context.leaveSpaceViewModel) { viewModel in
LeaveSpaceView(context: viewModel.context)
}
}
private var editSection: some View {