From b89c7e4f31b54236c6e91fccfde38ec902ab8a32 Mon Sep 17 00:00:00 2001 From: Yesterday17 Date: Sun, 11 Aug 2024 15:37:35 +0800 Subject: [PATCH] feat: add share file in mobile playing page --- lib/ui/page/playing/playing_mobile_widgets.dart | 12 ++++++++++++ lib/utils/share.dart | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/ui/page/playing/playing_mobile_widgets.dart b/lib/ui/page/playing/playing_mobile_widgets.dart index 2f84df4..2243e62 100644 --- a/lib/ui/page/playing/playing_mobile_widgets.dart +++ b/lib/ui/page/playing/playing_mobile_widgets.dart @@ -106,6 +106,18 @@ class PlayingScreenMobileBottomBar extends ConsumerWidget { ); }, ), + MenuItemButton( + leadingIcon: const Icon(Icons.file_copy), + child: const Text('[DEV] Export file'), + onPressed: () { + final track = player.playing.source!.track; + final box = context.findRenderObject() as RenderBox?; + shareTrackFile( + track, + box!.localToGlobal(Offset.zero) & box.size, + ); + }, + ), ], child: const Icon(Icons.more_vert_rounded), ), diff --git a/lib/utils/share.dart b/lib/utils/share.dart index 321bfc2..00f9536 100644 --- a/lib/utils/share.dart +++ b/lib/utils/share.dart @@ -25,3 +25,12 @@ void shareTrackInfo(TrackInfoWithAlbum track, Rect? sharePositionOrigin, sharePositionOrigin: sharePositionOrigin, ); } + +void shareTrackFile(TrackInfoWithAlbum track, Rect? sharePositionOrigin) { + final id = track.id; + Share.shareXFiles( + [XFile(getAudioCachePath(id))], + subject: 'Audio File', + sharePositionOrigin: sharePositionOrigin, + ); +}