Files
element-x-ios/ElementX/Sources/Screens/MultiAccountAnnouncementScreen/View/MultiAccountAnnouncementScreen.swift
T
Mauro 60c11c8172 Add the multi-account announcement screen (#6263)
* Add the multi-account announcement screen

A self-sizing bottom sheet telling users they can now add multiple accounts, matching the designs. Close and Add account both report back to the coordinator; nothing presents it yet.

* Use the Localazy strings for the multi-account announcement

The copy now lives in Localazy as screen.multi_account_announcement.*, named after the screen rather than the room list.

* Apply review suggestions to the multi-account announcement

- Use an ElementNavigationStack with a toolbar close button, like RedactConfirmationView, instead of an overlaid glass button.

* Remove the large text preview from the multi-account announcement

Other sheets built the same way don't snapshot Dynamic Type sizes, and the iOS 26 bar material it would show isn't rendered in snapshots.

* Use TitleAndIcon for the multi-account announcement

TitleAndIcon now takes an attributed subtitle (#6274), so the sheet no longer needs to rebuild its layout by hand. The snapshots are unchanged.
2026-10-05 18:03:19 +02:00

72 lines
2.3 KiB
Swift

//
// Copyright 2026 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 Compound
import SwiftUI
struct MultiAccountAnnouncementScreen: View {
let context: MultiAccountAnnouncementScreenViewModel.Context
@State private var contentHeight: CGFloat = .zero
@State private var buttonHeight: CGFloat = .zero
private let topPadding: CGFloat = 44 // For the navigation bar
var body: some View {
ElementNavigationStack {
ScrollView {
content
.readHeight($contentHeight)
}
.scrollBounceBehavior(.basedOnSize)
.backportSafeAreaBar(edge: .bottom, spacing: 0) {
addAccountButton
.readHeight($buttonHeight)
}
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarButton(role: .close) { context.send(viewAction: .close) }
}
}
}
.presentationDetents([.height(contentHeight + buttonHeight + topPadding)])
.presentationDragIndicator(.hidden)
.presentationBackground(.compound.bgCanvasDefault)
}
private var content: some View {
TitleAndIcon(title: L10n.screenMultiAccountAnnouncementTitle,
subtitle: context.viewState.description,
icon: \.userProfileSolid,
iconStyle: .defaultSolid)
.frame(maxWidth: .infinity)
.padding(.horizontal, 24)
.padding(.top, 16)
.padding(.bottom, 24)
}
private var addAccountButton: some View {
Button {
context.send(viewAction: .addAccount)
} label: {
Label(L10n.screenMultiAccountAnnouncementAction, icon: \.plus)
}
.buttonStyle(.compound(.primary))
.padding(16)
}
}
// MARK: - Previews
struct MultiAccountAnnouncementScreen_Previews: PreviewProvider, TestablePreview {
static let viewModel = MultiAccountAnnouncementScreenViewModel()
static var previews: some View {
MultiAccountAnnouncementScreen(context: viewModel.context)
.previewDisplayName("Default")
}
}