From 886d5fbe2ccb761dde8f76fbe1f8a0ffe4b1a631 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 24 Aug 2022 22:18:01 +0800 Subject: [PATCH] Add a share button for exporting MP3s, mostly useful for debugging --- .../App/Views/AudioPlayer/MiniPlayer.swift | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift index b413c200b..b66552bc9 100644 --- a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift @@ -88,6 +88,26 @@ public struct MiniPlayer: View { .padding(.top, 8) .frame(maxWidth: .infinity, alignment: .leading) + Button( + action: { + let shareActivity = UIActivityViewController(activityItems: [self.audioSession.localAudioUrl], applicationActivities: nil) + if let vc = UIApplication.shared.windows.first?.rootViewController { + shareActivity.popoverPresentationController?.sourceView = vc.view + // Setup share activity position on screen on bottom center + shareActivity.popoverPresentationController?.sourceRect = CGRect(x: UIScreen.main.bounds.width / 2, y: UIScreen.main.bounds.height, width: 0, height: 0) + shareActivity.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.down + vc.present(shareActivity, animated: true, completion: nil) + } + }, + label: { + Image(systemName: "square.and.arrow.up") + .font(.appCallout) + .tint(.appGrayText) + } + ) + .padding(.top, 8) + .frame(maxWidth: .infinity, alignment: .trailing) + Capsule() .fill(.gray) .frame(width: 60, height: 4)