mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Contextual menu for rooms (#842)
* Add room contextual menu * Add room context menu view actions * Add navigation to room’s detail * Show leave alert in HomeScreen * Implement leave logic * Refine leave navigation for iPad * Optimize leave from homescreen * Refactor roomSettings -> roomDetails * Refactor room for id mock * Add UTs * Cleanup * Fix alert presentation in RoomDetailsScreenViewModel * Fix animation flag
This commit is contained in:
@@ -59,6 +59,19 @@ struct HomeScreen: View {
|
||||
.redacted(reason: .placeholder)
|
||||
} else {
|
||||
HomeScreenRoomCell(room: room, context: context)
|
||||
.contextMenu {
|
||||
Button {
|
||||
context.send(viewAction: .showRoomDetails(roomIdentifier: room.id))
|
||||
} label: {
|
||||
Label(L10n.commonSettings, systemImage: "gearshape")
|
||||
}
|
||||
|
||||
Button(role: .destructive) {
|
||||
context.send(viewAction: .leaveRoom(roomIdentifier: room.id))
|
||||
} label: {
|
||||
Label(L10n.actionLeaveRoom, systemImage: "rectangle.portrait.and.arrow.right")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,6 +110,9 @@ struct HomeScreen: View {
|
||||
.animation(.elementDefault, value: context.viewState.showSessionVerificationBanner)
|
||||
.animation(.elementDefault, value: context.viewState.roomListMode)
|
||||
.alert(item: $context.alertInfo) { $0.alert }
|
||||
.alert(item: $context.leaveRoomAlertItem,
|
||||
actions: leaveRoomAlertActions,
|
||||
message: leaveRoomAlertMessage)
|
||||
.navigationTitle(L10n.screenRoomlistMainSpaceTitle)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
@@ -238,6 +254,18 @@ struct HomeScreen: View {
|
||||
// This will be deduped and throttled on the view model layer
|
||||
context.send(viewAction: .updateVisibleItemRange(range: lowerBound..<upperBound, isScrolling: scrollViewAdapter.isScrolling.value))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func leaveRoomAlertActions(_ item: LeaveRoomAlertItem) -> some View {
|
||||
Button(item.cancelTitle, role: .cancel) { }
|
||||
Button(item.confirmationTitle, role: .destructive) {
|
||||
context.send(viewAction: .confirmLeaveRoom(roomIdentifier: item.roomId))
|
||||
}
|
||||
}
|
||||
|
||||
private func leaveRoomAlertMessage(_ item: LeaveRoomAlertItem) -> some View {
|
||||
Text(item.subtitle)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
Reference in New Issue
Block a user