mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Fix: do not hide keyboard when recording a voice message (#1958)
This commit is contained in:
parent
c6e4dc2a37
commit
c020ba2d85
@ -106,6 +106,15 @@ struct ComposerToolbarViewState: BindableState {
|
||||
}
|
||||
return composerEmpty
|
||||
}
|
||||
|
||||
var isVoiceMessageModeActivated: Bool {
|
||||
switch composerMode {
|
||||
case .recordVoiceMessage, .previewVoiceMessage:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ComposerToolbarViewStateBindings {
|
||||
|
@ -230,7 +230,6 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
|
||||
case .default:
|
||||
break
|
||||
case .recordVoiceMessage(let audioRecorderState):
|
||||
state.bindings.composerFocused = false
|
||||
state.audioRecorderState = audioRecorderState
|
||||
case .previewVoiceMessage(let audioPlayerState, _, _):
|
||||
state.audioPlayerState = audioPlayerState
|
||||
|
@ -73,7 +73,7 @@ struct ComposerToolbar: View {
|
||||
}
|
||||
|
||||
private var topBar: some View {
|
||||
HStack(alignment: .bottom, spacing: 5) {
|
||||
topBarLayout {
|
||||
mainTopBarContent
|
||||
|
||||
if !context.composerActionsEnabled {
|
||||
@ -106,19 +106,14 @@ struct ComposerToolbar: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var topBarLayout: some Layout {
|
||||
HStackLayout(alignment: .bottom, spacing: 5)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var mainTopBarContent: some View {
|
||||
switch context.viewState.composerMode {
|
||||
case .recordVoiceMessage(let state) where context.viewState.enableVoiceMessageComposer:
|
||||
VoiceMessageRecordingComposer(recorderState: state)
|
||||
.padding(.leading, 12)
|
||||
case .previewVoiceMessage(let state, let waveform, let isUploading) where context.viewState.enableVoiceMessageComposer:
|
||||
Group {
|
||||
voiceMessageTrashButton
|
||||
voiceMessagePreviewComposer(audioPlayerState: state, waveform: waveform)
|
||||
}
|
||||
.disabled(isUploading)
|
||||
default:
|
||||
ZStack {
|
||||
topBarLayout {
|
||||
if !context.composerActionsEnabled {
|
||||
RoomAttachmentPicker(context: context)
|
||||
}
|
||||
@ -131,6 +126,12 @@ struct ComposerToolbar: View {
|
||||
.padding(.leading, context.composerActionsEnabled ? 7 : 0)
|
||||
.padding(.trailing, context.composerActionsEnabled ? 4 : 0)
|
||||
}
|
||||
.opacity(context.viewState.isVoiceMessageModeActivated ? 0 : 1)
|
||||
|
||||
if context.viewState.isVoiceMessageModeActivated {
|
||||
voiceMessageContent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var closeRTEButton: some View {
|
||||
@ -237,6 +238,24 @@ struct ComposerToolbar: View {
|
||||
|
||||
// MARK: - Voice message
|
||||
|
||||
@ViewBuilder
|
||||
private var voiceMessageContent: some View {
|
||||
// Display the voice message composer above to keep the focus and keep the keyboard open if it's already open.
|
||||
switch context.viewState.composerMode {
|
||||
case .recordVoiceMessage(let state) where context.viewState.enableVoiceMessageComposer:
|
||||
VoiceMessageRecordingComposer(recorderState: state)
|
||||
.padding(.leading, 12)
|
||||
case .previewVoiceMessage(let state, let waveform, let isUploading) where context.viewState.enableVoiceMessageComposer:
|
||||
topBarLayout {
|
||||
voiceMessageTrashButton
|
||||
voiceMessagePreviewComposer(audioPlayerState: state, waveform: waveform)
|
||||
}
|
||||
.disabled(isUploading)
|
||||
default:
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
private var voiceMessageRecordingButton: some View {
|
||||
VoiceMessageRecordingButton {
|
||||
showVoiceMessageRecordingTooltip = false
|
||||
|
BIN
UnitTests/__Snapshots__/PreviewTests/test_composerToolbar.Voice-Message.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_composerToolbar.Voice-Message.png
(Stored with Git LFS)
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user