Prompt the user before ending a voice broadcast

This commit is contained in:
Philippe Loriaux
2022-12-01 16:36:04 +01:00
parent 89f703cf2f
commit a1314aeb5e
3 changed files with 27 additions and 1 deletions
@@ -23,6 +23,8 @@ struct VoiceBroadcastRecorderView: View {
@Environment(\.theme) private var theme: ThemeSwiftUI
@State private var showingStopAlert = false
private var backgroundColor: Color {
if viewModel.viewState.recordingState != .paused {
return theme.colors.alert
@@ -97,11 +99,20 @@ struct VoiceBroadcastRecorderView: View {
.accessibilityIdentifier("recordButton")
Button {
viewModel.send(viewAction: .stop)
showingStopAlert = true
} label: {
Image("voice_broadcast_stop")
.renderingMode(.original)
}
.alert(isPresented:$showingStopAlert) {
Alert(title: Text(VectorL10n.voiceBroadcastStopAlertTitle),
message: Text(VectorL10n.voiceBroadcastStopAlertDescription),
primaryButton: .cancel(),
secondaryButton: .default(Text(VectorL10n.voiceBroadcastStopAlertAgreeButton),
action: {
viewModel.send(viewAction: .stop)
}))
}
.accessibilityIdentifier("stopButton")
.disabled(viewModel.viewState.recordingState == .stopped)
.mask(Color.black.opacity(viewModel.viewState.recordingState == .stopped ? 0.3 : 1.0))