From a3bfdc3c59f5b339e9b23edd2ab7eb74b0fb1f16 Mon Sep 17 00:00:00 2001 From: Elena Willen Date: Tue, 9 Jul 2024 16:26:53 +0200 Subject: [PATCH] feat: Display ActivityView() --- .../Actions/ActionsPanelViewModifier.swift | 15 ++++++++++++++- MailCore/Cache/Actions/ActionOrigin.swift | 11 ++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Mail/Views/Bottom sheets/Actions/ActionsPanelViewModifier.swift b/Mail/Views/Bottom sheets/Actions/ActionsPanelViewModifier.swift index 622b860ff..a714c6a57 100644 --- a/Mail/Views/Bottom sheets/Actions/ActionsPanelViewModifier.swift +++ b/Mail/Views/Bottom sheets/Actions/ActionsPanelViewModifier.swift @@ -45,6 +45,7 @@ struct ActionsPanelViewModifier: ViewModifier { @ModalState private var reportedForPhishingMessage: Message? @ModalState private var messagesToMove: [Message]? @ModalState private var flushAlert: FlushAlertState? + @ModalState private var shareMailLink: ShareMailLinkResult? @Binding var messages: [Message]? let originFolder: Folder? @@ -60,7 +61,8 @@ struct ActionsPanelViewModifier: ViewModifier { nearestMessagesToMoveSheet: $messagesToMove, nearestReportJunkMessageActionsPanel: $reportForJunkMessage, nearestReportedForPhishingMessageAlert: $reportedForPhishingMessage, - nearestReportedForDisplayProblemMessageAlert: $reportedForDisplayProblemMessage + nearestReportedForDisplayProblemMessageAlert: $reportedForDisplayProblemMessage, + nearestShareMailLinkPanel: $shareMailLink ) } @@ -89,5 +91,16 @@ struct ActionsPanelViewModifier: ViewModifier { .customAlert(item: $flushAlert) { item in FlushFolderAlertView(flushAlert: item, folder: originFolder) } + .sheet(item: $shareMailLink) { shareMailLinkResult in + if #available(iOS 16.0, *) { + ActivityView(activityItems: [shareMailLinkResult.url]) + .ignoresSafeArea(edges: [.bottom]) + .presentationDetents([.medium, .large]) + } else { + ActivityView(activityItems: [shareMailLinkResult.url]) + .ignoresSafeArea(edges: [.bottom]) + .backport.presentationDetents([.medium, .large]) + } + } } } diff --git a/MailCore/Cache/Actions/ActionOrigin.swift b/MailCore/Cache/Actions/ActionOrigin.swift index d9574393d..029b1d74d 100644 --- a/MailCore/Cache/Actions/ActionOrigin.swift +++ b/MailCore/Cache/Actions/ActionOrigin.swift @@ -42,6 +42,7 @@ public struct ActionOrigin { private(set) var nearestReportJunkMessageActionsPanel: Binding? private(set) var nearestReportedForPhishingMessageAlert: Binding? private(set) var nearestReportedForDisplayProblemMessageAlert: Binding? + private(set) var nearestShareMailLinkPanel: Binding? init( type: ActionOriginType, @@ -51,7 +52,8 @@ public struct ActionOrigin { nearestMessagesToMoveSheet: Binding<[Message]?>? = nil, nearestReportJunkMessageActionsPanel: Binding? = nil, nearestReportedForPhishingMessageAlert: Binding? = nil, - nearestReportedForDisplayProblemMessageAlert: Binding? = nil + nearestReportedForDisplayProblemMessageAlert: Binding? = nil, + nearestShareMailLinkPanel: Binding? = nil ) { self.type = type frozenFolder = folder?.freezeIfNeeded() @@ -61,6 +63,7 @@ public struct ActionOrigin { self.nearestReportJunkMessageActionsPanel = nearestReportJunkMessageActionsPanel self.nearestReportedForPhishingMessageAlert = nearestReportedForPhishingMessageAlert self.nearestReportedForDisplayProblemMessageAlert = nearestReportedForDisplayProblemMessageAlert + self.nearestShareMailLinkPanel = nearestShareMailLinkPanel } public static func toolbar(originFolder: Folder? = nil, @@ -74,7 +77,8 @@ public struct ActionOrigin { nearestMessagesToMoveSheet: Binding<[Message]?>? = nil, nearestReportJunkMessageActionsPanel: Binding? = nil, nearestReportedForPhishingMessageAlert: Binding? = nil, - nearestReportedForDisplayProblemMessageAlert: Binding? = nil) -> ActionOrigin { + nearestReportedForDisplayProblemMessageAlert: Binding? = nil, + nearestShareMailLinkPanel: Binding? = nil) -> ActionOrigin { return ActionOrigin( type: .floatingPanel(source: source), folder: originFolder, @@ -82,7 +86,8 @@ public struct ActionOrigin { nearestMessagesToMoveSheet: nearestMessagesToMoveSheet, nearestReportJunkMessageActionsPanel: nearestReportJunkMessageActionsPanel, nearestReportedForPhishingMessageAlert: nearestReportedForPhishingMessageAlert, - nearestReportedForDisplayProblemMessageAlert: nearestReportedForDisplayProblemMessageAlert + nearestReportedForDisplayProblemMessageAlert: nearestReportedForDisplayProblemMessageAlert, + nearestShareMailLinkPanel: nearestShareMailLinkPanel ) }