From 2851e167ff876c6fe2f9857598321793a873f970 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Mon, 24 Jul 2023 15:03:35 +1000 Subject: [PATCH] WIP: add message failing status --- .../MessageInfoView.swift | 72 +++++++++++++------ .../Shared Models/MessageViewModel.swift | 1 + .../SessionCarouselView+SwiftUI.swift | 1 + 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/Session/Media Viewing & Editing/MessageInfoView.swift b/Session/Media Viewing & Editing/MessageInfoView.swift index 379ee9aa6..bdde363f6 100644 --- a/Session/Media Viewing & Editing/MessageInfoView.swift +++ b/Session/Media Viewing & Editing/MessageInfoView.swift @@ -53,6 +53,23 @@ struct MessageInfoView: View { ) } + if [.failed, .failedToSync].contains(messageViewModel.state) { + let (image, statusText, tintColor) = messageViewModel.state.statusIconInfo( + variant: messageViewModel.variant, + hasAtLeastOneReadReceipt: messageViewModel.hasAtLeastOneReadReceipt + ) + + HStack { + if let image: UIImage = image { + Image(uiImage: image) + } + + if let statusText: String = statusText { + Text(statusText) + } + } + } + // TODO: Attachment carousel view SessionCarouselView_SwiftUI(contentInfos: [.orange, .gray, .blue, .yellow]) .frame( @@ -306,31 +323,40 @@ struct MessageInfoView: View { } struct MessageInfoView_Previews: PreviewProvider { + static var messageViewModel: MessageViewModel { + let result = MessageViewModel( + threadId: "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg", + threadVariant: .contact, + threadHasDisappearingMessagesEnabled: false, + threadOpenGroupServer: nil, + threadOpenGroupPublicKey: nil, + threadContactNameInternal: "Test", + timestampMs: SnodeAPI.currentOffsetTimestampMs(), + receivedAtTimestampMs: SnodeAPI.currentOffsetTimestampMs(), + authorId: "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg", + authorNameInternal: "Test", + body: "Test Message", + expiresStartedAtMs: nil, + expiresInSeconds: nil, + state: .failed, + isSenderOpenGroupModerator: false, + currentUserProfile: Profile.fetchOrCreateCurrentUser(), + quote: nil, + quoteAttachment: nil, + linkPreview: nil, + linkPreviewAttachment: nil, + attachments: nil + ) + + return result + } + + static var actions: [ContextMenuVC.Action] = [] + static var previews: some View { MessageInfoView( - actions: [], - messageViewModel: MessageViewModel( - threadId: "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg", - threadVariant: .contact, - threadHasDisappearingMessagesEnabled: false, - threadOpenGroupServer: nil, - threadOpenGroupPublicKey: nil, - threadContactNameInternal: "Test", - timestampMs: SnodeAPI.currentOffsetTimestampMs(), - receivedAtTimestampMs: SnodeAPI.currentOffsetTimestampMs(), - authorId: "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg", - authorNameInternal: "Test", - body: "Test Message", - expiresStartedAtMs: nil, - expiresInSeconds: nil, - isSenderOpenGroupModerator: false, - currentUserProfile: Profile.fetchOrCreateCurrentUser(), - quote: nil, - quoteAttachment: nil, - linkPreview: nil, - linkPreviewAttachment: nil, - attachments: nil - ) + actions: actions, + messageViewModel: messageViewModel ) } } diff --git a/SessionMessagingKit/Shared Models/MessageViewModel.swift b/SessionMessagingKit/Shared Models/MessageViewModel.swift index 735d971a1..45ab2326a 100644 --- a/SessionMessagingKit/Shared Models/MessageViewModel.swift +++ b/SessionMessagingKit/Shared Models/MessageViewModel.swift @@ -624,6 +624,7 @@ public extension MessageViewModel { body: String?, expiresStartedAtMs: Double?, expiresInSeconds: TimeInterval?, + state: RecipientState.State = .sending, isSenderOpenGroupModerator: Bool, currentUserProfile: Profile, quote: Quote?, diff --git a/SessionUIKit/Components/SessionCarouselView+SwiftUI.swift b/SessionUIKit/Components/SessionCarouselView+SwiftUI.swift index 5558592b9..d6315a9e3 100644 --- a/SessionUIKit/Components/SessionCarouselView+SwiftUI.swift +++ b/SessionUIKit/Components/SessionCarouselView+SwiftUI.swift @@ -66,6 +66,7 @@ struct ArrowView: View { } } label: { Image(systemName: imageName) + .font(.system(size: 20)) .foregroundColor(.white) .frame(width: 30, height: 30) }