Skip to content

Commit

Permalink
share single media item
Browse files Browse the repository at this point in the history
  • Loading branch information
HemantKArya committed Apr 2, 2024
1 parent 093e800 commit f3d4d94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions lib/screens/widgets/more_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:Bloomee/screens/widgets/song_card_widget.dart';
import 'package:Bloomee/services/db/GlobalDB.dart';
import 'package:Bloomee/services/db/cubit/bloomee_db_cubit.dart';
import 'package:Bloomee/theme_data/default.dart';
import 'package:Bloomee/utils/file_manager.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down Expand Up @@ -165,11 +166,13 @@ void showMoreBottomSheet(
fontSize: 17,
fontWeight: FontWeight.w400),
),
onTap: () {
onTap: () async {
Navigator.pop(context);
Share.share(
"Check out this song on Bloomee\n${song.title} by ${song.artist}\n${song.extras?['perma_url']}",
);
SnackbarService.showMessage(
"Preparing ${song.title} for share.");
final tmpPath = await BloomeeFileManager.exportMediaItem(
MediaItem2MediaItemDB(song));
tmpPath != null ? Share.shareXFiles([XFile(tmpPath)]) : null;
},
),
ListTile(
Expand Down
5 changes: 3 additions & 2 deletions lib/utils/file_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class BloomeeFileManager {
// export media item to json file
try {
final Map<String, dynamic> mediaItemMap = mediaItemDB.toMap();
await writeToJSON('${mediaItemDB.title}_BloomeeSong.blm', mediaItemMap);
final path = await writeToJSON(
'${mediaItemDB.title}_BloomeeSong.blm', mediaItemMap);
log("Media item exported successfully", name: "FileManager");
return '${mediaItemDB.title}_BloomeeSong.blm';
return path;
} catch (e) {
log("Error exporting media item: $e", name: "FileManager");
return null;
Expand Down

0 comments on commit f3d4d94

Please sign in to comment.