mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
Voice broadcast connection error handling while recording (#7282)
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Copyright 2023 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct VoiceBroadcastRecorderConnectionErrorView: View {
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
// MARK: Public
|
||||
|
||||
var action: (() -> Void)?
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
HStack(spacing: 0) {
|
||||
Image(uiImage: Asset.Images.errorIcon.image)
|
||||
.frame(width: 40, height: 40)
|
||||
Text(VectorL10n.voiceBroadcastRecorderConnectionError)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(theme.fonts.caption1)
|
||||
.foregroundColor(theme.colors.alert)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
struct VoiceBroadcastRecorderConnectionErrorView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VoiceBroadcastRecorderConnectionErrorView()
|
||||
}
|
||||
}
|
||||
+43
-37
@@ -26,7 +26,7 @@ struct VoiceBroadcastRecorderView: View {
|
||||
@State private var showingStopAlert = false
|
||||
|
||||
private var backgroundColor: Color {
|
||||
if viewModel.viewState.recordingState != .paused {
|
||||
if viewModel.viewState.recordingState != .paused, viewModel.viewState.recordingState != .error {
|
||||
return theme.colors.alert
|
||||
}
|
||||
return theme.colors.quarterlyContent
|
||||
@@ -78,47 +78,53 @@ struct VoiceBroadcastRecorderView: View {
|
||||
.accessibilityIdentifier("liveButton")
|
||||
}
|
||||
|
||||
HStack(alignment: .top, spacing: 34.0) {
|
||||
Button {
|
||||
switch viewModel.viewState.recordingState {
|
||||
case .started, .resumed:
|
||||
viewModel.send(viewAction: .pause)
|
||||
case .stopped:
|
||||
viewModel.send(viewAction: .start)
|
||||
case .paused:
|
||||
viewModel.send(viewAction: .resume)
|
||||
if viewModel.viewState.recordingState == .error {
|
||||
VoiceBroadcastRecorderConnectionErrorView()
|
||||
} else {
|
||||
HStack(alignment: .top, spacing: 34.0) {
|
||||
Button {
|
||||
switch viewModel.viewState.recordingState {
|
||||
case .started, .resumed:
|
||||
viewModel.send(viewAction: .pause)
|
||||
case .stopped:
|
||||
viewModel.send(viewAction: .start)
|
||||
case .paused:
|
||||
viewModel.send(viewAction: .resume)
|
||||
case .error:
|
||||
break
|
||||
}
|
||||
} label: {
|
||||
if viewModel.viewState.recordingState == .started || viewModel.viewState.recordingState == .resumed {
|
||||
Image("voice_broadcast_record_pause")
|
||||
.renderingMode(.original)
|
||||
} else {
|
||||
Image("voice_broadcast_record")
|
||||
.renderingMode(.original)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
if viewModel.viewState.recordingState == .started || viewModel.viewState.recordingState == .resumed {
|
||||
Image("voice_broadcast_record_pause")
|
||||
.renderingMode(.original)
|
||||
} else {
|
||||
Image("voice_broadcast_record")
|
||||
.accessibilityIdentifier("recordButton")
|
||||
|
||||
Button {
|
||||
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))
|
||||
}
|
||||
.accessibilityIdentifier("recordButton")
|
||||
|
||||
Button {
|
||||
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))
|
||||
.padding(EdgeInsets(top: 10.0, leading: 0.0, bottom: 10.0, trailing: 0.0))
|
||||
}
|
||||
.padding(EdgeInsets(top: 10.0, leading: 0.0, bottom: 10.0, trailing: 0.0))
|
||||
}
|
||||
.padding(EdgeInsets(top: 12.0, leading: 4.0, bottom: 12.0, trailing: 4.0))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user