WIP: link real data to swiftui message info screen

This commit is contained in:
Ryan Zhao 2023-07-31 13:31:46 +10:00
parent 3ccf5995f2
commit d91fd27260
3 changed files with 29 additions and 20 deletions

View File

@ -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))
}
}

View File

@ -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) {

View File

@ -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
)
}
}
}