Bottom Sheet to confirm DM creation (#3739)

* created the view to hold the bottom sheet

* added the sheet to the start chat screen

* switched the alert with the bottom sheet

in the room member details

* add a small delay to not always show the loader

* suggested PR changes

* pr suggestions and updated tests
This commit is contained in:
Mauro
2025-02-05 13:28:00 +01:00
committed by GitHub
parent 42257a18db
commit 921d1c627d
21 changed files with 216 additions and 54 deletions
@@ -36,6 +36,7 @@ struct UserProfileScreenViewState: BindableState {
struct UserProfileScreenViewStateBindings {
var alertInfo: AlertInfo<UserProfileScreenAlertType>?
var inviteConfirmationUser: UserProfileProxy?
/// A media item that will be previewed with QuickLook.
var mediaPreviewItem: MediaPreviewItem?
@@ -44,6 +45,7 @@ struct UserProfileScreenViewStateBindings {
enum UserProfileScreenViewAction {
case displayAvatar(URL)
case openDirectChat
case createDirectChat
case startCall(roomID: String)
case dismiss
}
@@ -51,5 +53,4 @@ enum UserProfileScreenViewAction {
enum UserProfileScreenAlertType: Hashable {
case failedOpeningDirectChat
case unknown
case createDirectChatConfirmation
}
@@ -62,6 +62,8 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
Task { await displayFullScreenAvatar(url) }
case .openDirectChat:
Task { await openDirectChat() }
case .createDirectChat:
Task { await createDirectChat() }
case .startCall(let roomID):
actionsSubject.send(.startCall(roomID: roomID))
case .dismiss:
@@ -121,12 +123,7 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
if let roomID {
actionsSubject.send(.openDirectChat(roomID: roomID))
} else {
let string = userProfile.displayName ?? userProfile.userID
state.bindings.alertInfo = .init(id: .createDirectChatConfirmation,
title: L10n.screenRoomMemberDetailsAlertCreateDmTitle,
message: L10n.screenRoomMemberDetailsAlertCreateDmMessage(string),
primaryButton: .init(title: L10n.screenRoomMemberDetailsAlertCreateDmConfirmationTitle) { [weak self] in Task { await self?.createDirectChat() }},
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
state.bindings.inviteConfirmationUser = userProfile
}
case .failure:
state.bindings.alertInfo = .init(id: .failedOpeningDirectChat)
@@ -22,6 +22,12 @@ struct UserProfileScreen: View {
.navigationBarTitleDisplayMode(.inline)
.toolbar { toolbar }
.alert(item: $context.alertInfo)
.sheet(item: $context.inviteConfirmationUser) { user in
SendInviteConfirmationView(userToInvite: user,
mediaProvider: context.mediaProvider) {
context.send(viewAction: .createDirectChat)
}
}
.track(screen: .User)
.interactiveQuickLook(item: $context.mediaPreviewItem, allowEditing: false)
}