From 25e4a1e86df170f4e020aa368f2e3b537e56d647 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Wed, 25 Jan 2023 10:18:02 +0000 Subject: [PATCH] ios: fix layout of voice message (#1836) * ios: fix layout of voice message * fix layout * prevent translations --- .../Views/Chat/ChatItem/CIVoiceView.swift | 56 +++++++++++-------- .../ComposeMessage/ComposeVoiceView.swift | 6 +- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/apps/ios/Shared/Views/Chat/ChatItem/CIVoiceView.swift b/apps/ios/Shared/Views/Chat/ChatItem/CIVoiceView.swift index fef3c59375..18e0f3ff75 100644 --- a/apps/ios/Shared/Views/Chat/ChatItem/CIVoiceView.swift +++ b/apps/ios/Shared/Views/Chat/ChatItem/CIVoiceView.swift @@ -17,25 +17,28 @@ struct CIVoiceView: View { @State var playbackTime: TimeInterval? var body: some View { - VStack ( - alignment: chatItem.chatDir.sent ? .trailing : .leading, - spacing: 6 - ) { - HStack { - if chatItem.chatDir.sent { - playerTime() - .frame(width: 50, alignment: .leading) - player() - } else { - player() - playerTime() - .frame(width: 50, alignment: .leading) + Group { + if chatItem.chatDir.sent { + VStack (alignment: .trailing, spacing: 6) { + HStack { + playerTime() + player() + } + .frame(alignment: .trailing) + metaView().padding(.trailing, 10) + } + } else { + VStack (alignment: .leading, spacing: 6) { + HStack { + player() + playerTime() + } + .frame(alignment: .leading) + metaView().padding(.leading, -6) } } - CIMetaView(chatItem: chatItem) - .padding(.leading, chatItem.chatDir.sent ? 0 : 12) - .padding(.trailing, chatItem.chatDir.sent ? 12 : 0) } + .padding([.top, .horizontal], 4) .padding(.bottom, 8) } @@ -58,6 +61,10 @@ struct CIVoiceView: View { ) .foregroundColor(.secondary) } + + private func metaView() -> some View { + CIMetaView(chatItem: chatItem) + } } struct VoiceMessagePlayerTime: View { @@ -66,13 +73,16 @@ struct VoiceMessagePlayerTime: View { @Binding var playbackTime: TimeInterval? var body: some View { - switch playbackState { - case .noPlayback: - Text(voiceMessageTime(recordingTime)) - case .playing: - Text(voiceMessageTime_(playbackTime)) - case .paused: - Text(voiceMessageTime_(playbackTime)) + ZStack(alignment: .leading) { + Text(String("66:66")).foregroundColor(.clear) + switch playbackState { + case .noPlayback: + Text(voiceMessageTime(recordingTime)) + case .playing: + Text(voiceMessageTime_(playbackTime)) + case .paused: + Text(voiceMessageTime_(playbackTime)) + } } } } diff --git a/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeVoiceView.swift b/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeVoiceView.swift index 77310240b4..ee2fa29fd3 100644 --- a/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeVoiceView.swift +++ b/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeVoiceView.swift @@ -16,13 +16,11 @@ enum VoiceMessagePlaybackState { } func voiceMessageTime(_ time: TimeInterval) -> String { - let min = Int(time / 60) - let sec = Int(time.truncatingRemainder(dividingBy: 60)) - return String(format: "%02d:%02d", min, sec) + durationText(Int(time)) } func voiceMessageTime_(_ time: TimeInterval?) -> String { - return voiceMessageTime(time ?? TimeInterval(0)) + durationText(Int(time ?? 0)) } struct ComposeVoiceView: View {