mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Final changes for Room Moderation (#2576)
* Add confirmation that the user would like to discard unsaved changes. * Update string on permissions screen. * Fix UI tests and update snapshots. * Fix integration tests. * Run periphery for Moderation feature.
This commit is contained in:
+4
@@ -43,6 +43,8 @@ struct RoomChangePermissionsScreenViewStateBindings: BindableState {
|
||||
}
|
||||
|
||||
enum RoomChangePermissionsScreenAlertType {
|
||||
/// A confirmation that the user would like to discard any unsaved changes.
|
||||
case discardChanges
|
||||
/// The generic error message.
|
||||
case generic
|
||||
}
|
||||
@@ -50,6 +52,8 @@ enum RoomChangePermissionsScreenAlertType {
|
||||
enum RoomChangePermissionsScreenViewAction {
|
||||
/// Save the permissions.
|
||||
case save
|
||||
/// Discard any changes and hide the screen.
|
||||
case cancel
|
||||
}
|
||||
|
||||
extension RoomChangePermissionsScreenViewState {
|
||||
|
||||
+10
@@ -49,6 +49,8 @@ class RoomChangePermissionsScreenViewModel: RoomChangePermissionsScreenViewModel
|
||||
switch viewAction {
|
||||
case .save:
|
||||
Task { await save() }
|
||||
case .cancel:
|
||||
confirmDiscardChanges()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +85,14 @@ class RoomChangePermissionsScreenViewModel: RoomChangePermissionsScreenViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private func confirmDiscardChanges() {
|
||||
state.bindings.alertInfo = AlertInfo(id: .discardChanges,
|
||||
title: L10n.screenRoomChangeRoleUnsavedChangesTitle,
|
||||
message: L10n.screenRoomChangeRoleUnsavedChangesDescription,
|
||||
primaryButton: .init(title: L10n.actionSave) { Task { await self.save() } },
|
||||
secondaryButton: .init(title: L10n.actionDiscard, role: .cancel) { self.actionsSubject.send(.complete) })
|
||||
}
|
||||
|
||||
// MARK: Loading indicator
|
||||
|
||||
private static let indicatorID = "SavingRoomPermissions"
|
||||
|
||||
+9
@@ -35,6 +35,7 @@ struct RoomChangePermissionsScreen: View {
|
||||
.compoundList()
|
||||
.navigationTitle(context.viewState.title)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarBackButtonHidden(context.viewState.hasChanges)
|
||||
.toolbar { toolbar }
|
||||
.alert(item: $context.alertInfo)
|
||||
}
|
||||
@@ -47,6 +48,14 @@ struct RoomChangePermissionsScreen: View {
|
||||
}
|
||||
.disabled(!context.viewState.hasChanges)
|
||||
}
|
||||
|
||||
if context.viewState.hasChanges {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button(L10n.actionCancel) {
|
||||
context.send(viewAction: .cancel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user