Files
element-x-ios/ElementX/Sources/Other/UserIndicator/UserIndicatorToastView.swift
T
Mauro d3604e8115 Announce toasts with VoiceOver (#6250)
* Announce toasts with VoiceOver

Toasts are posted from a separate overlay window and never take
VoiceOver focus, so their text was never spoken. UserIndicatorController
now posts a high priority announcement with the title whenever a toast
with readable text is submitted, including re-submissions of an already
visible toast with the same ID. Modal indicators are not announced.

* Remove empty-title toast announcement check

Co-authored-by: Velin92 <34335419+Velin92@users.noreply.github.com>

* Hide toasts from VoiceOver

The toast title is now announced by UserIndicatorController when the
toast is submitted, so letting VoiceOver also focus the toast itself
would only read the same text twice.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-10-02 12:29:18 +02:00

61 lines
2.1 KiB
Swift

//
// Copyright 2025 Element Creations Ltd.
// Copyright 2022-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 UserIndicatorToastView: View {
let indicator: UserIndicator
var body: some View {
HStack(spacing: 4) {
if case .indeterminate = indicator.progress {
ProgressView()
.controlSize(.small)
.tint(.compound.iconPrimary)
}
if let icon = indicator.icon {
CompoundIcon(icon, size: .small, relativeTo: .compound.bodyMD)
.foregroundColor(.compound.iconPrimary)
}
Text(indicator.title)
.font(.compound.bodyMD)
.foregroundColor(.compound.textPrimary)
}
.id(indicator.id)
.padding(.horizontal, 12.0)
.padding(.vertical, 10.0)
.background(Color.compound.bgSubtlePrimary)
.clipShape(RoundedCornerShape(radius: 24.0, corners: .allCorners))
.shadow(color: .black.opacity(0.1), radius: 6.0, y: 4.0)
.accessibilityHidden(true)
.transition(toastTransition)
}
private var toastTransition: AnyTransition {
AnyTransition
.asymmetric(insertion: .move(edge: .top),
removal: .move(edge: .bottom))
.combined(with: .opacity)
}
}
struct UserIndicatorToastView_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
VStack(spacing: 30) {
UserIndicatorToastView(indicator: UserIndicator(title: "Successfully logged in",
icon: \.check))
UserIndicatorToastView(indicator: UserIndicator(title: "Toast without icon"))
UserIndicatorToastView(indicator: UserIndicator(type: .toast(progress: .indeterminate),
title: "Syncing"))
}
}
}