push back to previous screen when tapping actions in message info screen

This commit is contained in:
ryanzhao 2023-08-04 12:01:30 +10:00
parent 1a9e2a51b4
commit 8d4049f0da
2 changed files with 27 additions and 5 deletions

View File

@ -1645,10 +1645,12 @@ extension ConversationVC:
using: dependencies
) ?? []
let messageInfoView = MessageInfoView(actions: actions, messageViewModel: cellViewModel)
let hostingViewController = UIHostingController(rootView: messageInfoView)
hostingViewController.title = "message_info_title".localized()
navigationController?.pushViewController(hostingViewController, animated: true)
let messageInfoViewController = MessageInfoViewController(
actions: actions,
messageViewModel: cellViewModel
)
messageInfoViewController.title = "message_info_title".localized()
navigationController?.pushViewController(messageInfoViewController, animated: true)
}
func retry(_ cellViewModel: MessageViewModel, using dependencies: Dependencies) {

View File

@ -381,7 +381,7 @@ struct MessageInfoView: View {
.frame(width: .infinity, height: 60)
.onTapGesture {
actions[index].work()
dismiss()
dismiss?()
}
if index < (actions.count - 1) {
@ -444,6 +444,26 @@ struct InfoBlock<Content>: View where Content: View {
}
}
final class MessageInfoViewController: UIHostingController<MessageInfoView> {
init(actions: [ContextMenuVC.Action], messageViewModel: MessageViewModel) {
let messageInfoView = MessageInfoView(
actions: actions,
messageViewModel: messageViewModel
)
super.init(rootView: messageInfoView)
rootView.dismiss = dismiss
}
@MainActor required dynamic init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func dismiss() {
self.navigationController?.popViewController(animated: true)
}
}
struct MessageInfoView_Previews: PreviewProvider {
static var messageViewModel: MessageViewModel {
let result = MessageViewModel(