generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
21 changed files
with
216 additions
and
54 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
ElementX/Sources/Screens/StartChatScreen/View/SendInviteConfirmationView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// | ||
// Copyright 2025 New Vector Ltd. | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
// Please see LICENSE files in the repository root for full details. | ||
// | ||
|
||
import Compound | ||
import SwiftUI | ||
|
||
struct SendInviteConfirmationView: View { | ||
let userToInvite: UserProfileProxy | ||
let mediaProvider: MediaProviderProtocol? | ||
let onInvite: () -> Void | ||
|
||
@Environment(\.dismiss) private var dismiss | ||
|
||
@State private var sheetHeight: CGFloat = .zero | ||
private let topPadding: CGFloat = 24 | ||
|
||
private var subtitle: String { | ||
if let displayName = userToInvite.displayName { | ||
L10n.screenBottomSheetCreateDmMessage(displayName, userToInvite.userID) | ||
} else { | ||
L10n.screenBottomSheetCreateDmMessageNoDisplayname(userToInvite.userID) | ||
} | ||
} | ||
|
||
var body: some View { | ||
ScrollView { | ||
VStack(spacing: 40) { | ||
header | ||
actions | ||
} | ||
.readHeight($sheetHeight) | ||
} | ||
.scrollBounceBehavior(.basedOnSize) | ||
.padding(.top, topPadding) // For the drag indicator | ||
.presentationDetents([.height(sheetHeight + topPadding)]) | ||
.presentationDragIndicator(.visible) | ||
.presentationBackground(.compound.bgCanvasDefault) | ||
} | ||
|
||
private var header: some View { | ||
VStack(spacing: 16) { | ||
LoadableAvatarImage(url: userToInvite.avatarURL, | ||
name: userToInvite.displayName, | ||
contentID: userToInvite.userID, | ||
avatarSize: .user(on: .sendInviteConfirmation), | ||
mediaProvider: mediaProvider) | ||
VStack(spacing: 8) { | ||
Text(L10n.screenBottomSheetCreateDmTitle) | ||
.multilineTextAlignment(.center) | ||
.font(.compound.headingMDBold) | ||
.foregroundStyle(.compound.textPrimary) | ||
Text(subtitle) | ||
.multilineTextAlignment(.center) | ||
.font(.compound.bodyMD) | ||
.foregroundStyle(.compound.textSecondary) | ||
} | ||
} | ||
.padding(.horizontal, 24) | ||
} | ||
|
||
private var actions: some View { | ||
VStack(spacing: 16) { | ||
Button { | ||
dismiss() | ||
onInvite() | ||
} label: { | ||
Label(L10n.screenBottomSheetCreateDmConfirmationButtonTitle, | ||
icon: \.userAdd, | ||
iconSize: .medium, | ||
relativeTo: .compound.bodyLGSemibold) | ||
} | ||
.buttonStyle(.compound(.primary)) | ||
|
||
Button { | ||
dismiss() | ||
} label: { | ||
Text(L10n.actionCancel) | ||
.padding(.vertical, 14) | ||
} | ||
.buttonStyle(.compound(.plain)) | ||
} | ||
.padding(.horizontal, 16) | ||
} | ||
} | ||
|
||
struct SendInviteConfirmationView_Previews: PreviewProvider, TestablePreview { | ||
static var previews: some View { | ||
SendInviteConfirmationView(userToInvite: .mockBob, | ||
mediaProvider: nil) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.