From d91fd27260269e8951f10ee198b88fdb98d1a38c Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Mon, 31 Jul 2023 13:31:46 +1000 Subject: [PATCH] WIP: link real data to swiftui message info screen --- .../Context Menu/ContextMenuVC+Action.swift | 11 ++++--- .../ConversationVC+Interaction.swift | 30 ++++++++++++++----- .../MessageInfoView.swift | 8 ++--- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Session/Conversations/Context Menu/ContextMenuVC+Action.swift b/Session/Conversations/Context Menu/ContextMenuVC+Action.swift index dfe03e928..aadc69fe9 100644 --- a/Session/Conversations/Context Menu/ContextMenuVC+Action.swift +++ b/Session/Conversations/Context Menu/ContextMenuVC+Action.swift @@ -154,6 +154,7 @@ extension ContextMenuVC { currentUserBlinded25PublicKey: String?, currentUserIsOpenGroupModerator: Bool, currentThreadIsMessageRequest: Bool, + forMessageInfoScreen: Bool, delegate: ContextMenuActionDelegate? ) -> [Action]? { switch cellViewModel.variant { @@ -225,11 +226,9 @@ extension ContextMenuVC { on: cellViewModel.threadOpenGroupServer ) } - return !currentThreadIsMessageRequest + return !currentThreadIsMessageRequest && !forMessageInfoScreen }() - let shouldShowInfo: Bool = (cellViewModel.attachments?.isEmpty == false) - let generatedActions: [Action] = [ (canRetry ? Action.retry(cellViewModel, delegate) : nil), (viewModelCanReply(cellViewModel) ? Action.reply(cellViewModel, delegate) : nil), @@ -239,15 +238,15 @@ extension ContextMenuVC { (canDelete ? Action.delete(cellViewModel, delegate) : nil), (canBan ? Action.ban(cellViewModel, delegate) : nil), (canBan ? Action.banAndDeleteAllMessages(cellViewModel, delegate) : nil), - (shouldShowInfo ? Action.info(cellViewModel, delegate) : nil), + (forMessageInfoScreen ? nil : Action.info(cellViewModel, delegate)), ] .appending(contentsOf: (shouldShowEmojiActions ? recentEmojis : []).map { Action.react(cellViewModel, $0, delegate) }) - .appending(Action.emojiPlusButton(cellViewModel, delegate)) + .appending(forMessageInfoScreen ? nil : Action.emojiPlusButton(cellViewModel, delegate)) .compactMap { $0 } guard !generatedActions.isEmpty else { return [] } - return generatedActions.appending(Action.dismiss(delegate)) + return generatedActions.appending(forMessageInfoScreen ? nil : Action.dismiss(delegate)) } } diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index e7a3889a8..b52c62ea7 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -11,6 +11,7 @@ import SessionUIKit import SessionMessagingKit import SessionUtilitiesKit import SignalUtilitiesKit +import SwiftUI extension ConversationVC: InputViewDelegate, @@ -758,6 +759,7 @@ extension ConversationVC: on: self.viewModel.threadData.openGroupServer ), currentThreadIsMessageRequest: (self.viewModel.threadData.threadIsMessageRequest == true), + forMessageInfoScreen: false, delegate: self ) else { return } @@ -1608,14 +1610,26 @@ extension ConversationVC: // MARK: - ContextMenuActionDelegate func info(_ cellViewModel: MessageViewModel) { - let mediaInfoVC = MediaInfoVC( - attachments: (cellViewModel.attachments ?? []), - isOutgoing: (cellViewModel.variant == .standardOutgoing), - threadId: self.viewModel.threadData.threadId, - threadVariant: self.viewModel.threadData.threadVariant, - interactionId: cellViewModel.id - ) - navigationController?.pushViewController(mediaInfoVC, animated: true) + let actions: [ContextMenuVC.Action] = ContextMenuVC.actions( + for: cellViewModel, + recentEmojis: [], + currentUserPublicKey: self.viewModel.threadData.currentUserPublicKey, + currentUserBlinded15PublicKey: self.viewModel.threadData.currentUserBlinded15PublicKey, + currentUserBlinded25PublicKey: self.viewModel.threadData.currentUserBlinded25PublicKey, + currentUserIsOpenGroupModerator: OpenGroupManager.isUserModeratorOrAdmin( + self.viewModel.threadData.currentUserPublicKey, + for: self.viewModel.threadData.openGroupRoomToken, + on: self.viewModel.threadData.openGroupServer + ), + currentThreadIsMessageRequest: (self.viewModel.threadData.threadIsMessageRequest == true), + forMessageInfoScreen: true, + delegate: self + ) ?? [] + + let messageInfoView = MessageInfoView(actions: actions, messageViewModel: cellViewModel) + let hostingViewController = UIHostingController(rootView: messageInfoView) + hostingViewController.title = "message_info_title".localized() + navigationController?.pushViewController(hostingViewController, animated: true) } func retry(_ cellViewModel: MessageViewModel) { diff --git a/Session/Media Viewing & Editing/MessageInfoView.swift b/Session/Media Viewing & Editing/MessageInfoView.swift index 9776c44b9..0ec99cdaa 100644 --- a/Session/Media Viewing & Editing/MessageInfoView.swift +++ b/Session/Media Viewing & Editing/MessageInfoView.swift @@ -16,9 +16,9 @@ struct MessageInfoView: View { NavigationView { ZStack (alignment: .topLeading) { if #available(iOS 14.0, *) { - Color.black.ignoresSafeArea() + ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea() } else { - Color.black + ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary) } ScrollView(.vertical, showsIndicators: false) { @@ -373,10 +373,6 @@ struct MessageInfoView: View { } } } - .navigationBarTitle( - "Message Info", - displayMode: .inline - ) } } }