Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmitrevski committed Dec 19, 2023
1 parent 65970c0 commit 8fd872a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extension MessageComposerViewModel: AudioRecordingDelegate {
)
if self.recordingState == .stopped {
self.pendingAudioRecording = recording
self.audioRecordingInfo.waveform = waveform
} else {
self.addedVoiceRecordings.append(recording)
self.recordingState = .initial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct VoiceRecordingView: View {
@Injected(\.images) var images

@State var isPlaying: Bool = false
@State var loading: Bool = false
@State var rate: AudioPlaybackRate = .normal
@ObservedObject var handler: VoiceRecordingHandler

Expand Down Expand Up @@ -102,6 +103,10 @@ struct VoiceRecordingView: View {
.foregroundColor(.primary)
.modifier(ShadowViewModifier(firstRadius: 2, firstY: 4))
})
.opacity(loading ? 0 : 1)
.overlay(
loading ? ProgressView() : nil
)

VStack(alignment: .leading, spacing: 4) {
Text(
Expand Down Expand Up @@ -162,6 +167,12 @@ struct VoiceRecordingView: View {
}
.onReceive(handler.$context, perform: { value in
guard value.assetLocation == addedVoiceRecording.url else { return }
if value.state == .loading {
loading = true
return
} else if loading {
loading = false
}
if value.state == .stopped || value.state == .paused {
isPlaying = false
} else if value.state == .playing {
Expand Down

0 comments on commit 8fd872a

Please sign in to comment.