Skip to content

Commit

Permalink
added custom file support for playlist sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
HemantKArya committed Mar 29, 2024
1 parent bc2b82a commit cbbc604
Show file tree
Hide file tree
Showing 20 changed files with 659 additions and 232 deletions.
1 change: 1 addition & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class androidx.lifecycle.DefaultLifecycleObserver
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
Expand Down
18 changes: 18 additions & 0 deletions lib/blocs/library/cubit/library_items_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,22 @@ class LibraryItemsCubit extends Cubit<LibraryItemsState> {
"Removed ${mediaItem.title} from ${mediaPlaylistDB.playlistName}");
}
}

Future<List<MediaItemModel>?> getPlaylist(String playlistName) async {
try {
final playlistDB = mediaPlaylistsDB
.firstWhere((element) => element.playlistName == playlistName);
final _playlist = await BloomeeDBService.getPlaylistItems(playlistDB);

if (_playlist != null) {
final mediaItems =
_playlist.map((e) => MediaItemDB2MediaItem(e)).toList();
return mediaItems;
}
} catch (e) {
log("Error in getting playlist: $e", name: "libItemCubit");
return null;
}
return null;
}
}
7 changes: 4 additions & 3 deletions lib/routes_and_consts/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ class GlobalRoutes {
GoRoute(
name: GlobalStrConsts.playlistView,
// parentNavigatorKey: globalRouterKey,
path: '/PlaylistView/:playlistName',
builder: (context, state) => PlaylistView(
playListName: state.pathParameters['playlistName'] ?? "none"),
path: '/PlaylistView',
builder: (context, state) {
return PlaylistView();
},
),
GoRoute(
path: '/AddToPlaylist',
Expand Down
48 changes: 36 additions & 12 deletions lib/screens/screen/audioPlayer_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,29 @@ class _AudioPlayerViewState extends State<AudioPlayerView> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
onTap: () => musicPlayer.rewind(),
child: const Icon(
IconButton(
padding: const EdgeInsets.all(5),
constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize: MaterialTapTargetSize
.shrinkWrap, // the '2023' part
),
onPressed: () => musicPlayer.rewind(),
icon: const Icon(
MingCute.refresh_4_line,
color: Default_Theme.primaryColor1,
size: 40,
),
),
InkWell(
onTap: () => musicPlayer.skipToPrevious(),
child: const Icon(
IconButton(
padding: const EdgeInsets.all(5),
constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize: MaterialTapTargetSize
.shrinkWrap, // the '2023' part
),
onPressed: () => musicPlayer.skipToPrevious(),
icon: const Icon(
MingCute.skip_previous_fill,
color: Default_Theme.primaryColor1,
size: 40,
Expand Down Expand Up @@ -354,21 +366,33 @@ class _AudioPlayerViewState extends State<AudioPlayerView> {
);
});
}),
InkWell(
onTap: () => musicPlayer.skipToNext(),
child: const Icon(
IconButton(
padding: const EdgeInsets.all(5),
constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize: MaterialTapTargetSize
.shrinkWrap, // the '2023' part
),
onPressed: () => musicPlayer.skipToNext(),
icon: const Icon(
MingCute.skip_forward_fill,
color: Default_Theme.primaryColor1,
size: 40,
),
),
InkWell(
child: const Icon(
IconButton(
padding: const EdgeInsets.all(5),
constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize: MaterialTapTargetSize
.shrinkWrap, // the '2023' part
),
icon: const Icon(
MingCute.external_link_line,
color: Default_Theme.primaryColor1,
size: 40,
),
onTap: () {
onPressed: () {
launchUrlString(context
.read<BloomeePlayerCubit>()
.bloomeePlayer
Expand Down
2 changes: 0 additions & 2 deletions lib/screens/screen/chart/chart_view.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:Bloomee/blocs/explore/cubit/explore_cubits.dart';
import 'package:Bloomee/model/chart_model.dart';
import 'package:Bloomee/services/db/bloomee_db_service.dart';
import 'package:flutter/material.dart';
import 'package:Bloomee/screens/widgets/chart_list_tile.dart';
import 'package:Bloomee/theme_data/default.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class ChartScreen extends StatefulWidget {
// ChartCubit? chartCubit;
Expand Down
62 changes: 35 additions & 27 deletions lib/screens/screen/explore_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:Bloomee/blocs/explore/cubit/explore_cubits.dart';
import 'package:Bloomee/blocs/mediaPlayer/bloomee_player_cubit.dart';
import 'package:Bloomee/model/MediaPlaylistModel.dart';
import 'package:Bloomee/routes_and_consts/global_str_consts.dart';
import 'package:Bloomee/screens/widgets/chart_list_tile.dart';
import 'package:Bloomee/screens/widgets/more_bottom_sheet.dart';
Expand Down Expand Up @@ -162,41 +161,50 @@ class _ExploreScreenState extends State<ExploreScreen> {
style: Default_Theme.primaryTextStyle.merge(const TextStyle(
fontSize: 34, color: Default_Theme.primaryColor1))),
const Spacer(),
Padding(
padding: const EdgeInsets.only(right: 10),
child: InkWell(
splashColor: Colors.transparent,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const NotificationView()));
},
child: const Icon(MingCute.notification_line,
color: Default_Theme.primaryColor1, size: 30.0),
IconButton(
padding: const EdgeInsets.all(5),
constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize:
MaterialTapTargetSize.shrinkWrap, // the '2023' part
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const NotificationView()));
},
icon: const Icon(MingCute.notification_line,
color: Default_Theme.primaryColor1, size: 30.0),
),
Padding(
padding: const EdgeInsets.only(right: 10),
child: InkWell(
splashColor: Colors.transparent,
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => const TimerView()));
},
child: const Icon(MingCute.stopwatch_line,
color: Default_Theme.primaryColor1, size: 30.0),
IconButton(
padding: EdgeInsets.all(5),
constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize:
MaterialTapTargetSize.shrinkWrap, // the '2023' part
),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => const TimerView()));
},
icon: const Icon(MingCute.stopwatch_line,
color: Default_Theme.primaryColor1, size: 30.0),
),
InkWell(
splashColor: Colors.transparent,
onTap: () {
IconButton(
padding: EdgeInsets.all(5),
constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize:
MaterialTapTargetSize.shrinkWrap, // the '2023' part
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SettingsView()));
},
child: const Icon(MingCute.settings_3_line,
icon: const Icon(MingCute.settings_3_line,
color: Default_Theme.primaryColor1, size: 30.0)),
],
),
Expand Down
115 changes: 56 additions & 59 deletions lib/screens/screen/library_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:Bloomee/screens/screen/library_views/cubit/current_playlist_cubit.dart';
import 'package:Bloomee/screens/screen/library_views/more_opts_sheet.dart';
import 'package:Bloomee/screens/widgets/sign_board_widget.dart';
import 'package:Bloomee/utils/load_Image.dart';
import 'package:flutter/material.dart';
Expand All @@ -7,7 +9,6 @@ import 'package:Bloomee/blocs/library/cubit/library_items_cubit.dart';
import 'package:Bloomee/routes_and_consts/global_str_consts.dart';
import 'package:Bloomee/screens/widgets/createPlaylist_bottomsheet.dart';
import 'package:Bloomee/screens/widgets/smallPlaylistCard_widget.dart';
import 'package:Bloomee/services/db/GlobalDB.dart';
import 'package:Bloomee/theme_data/default.dart';
import 'package:icons_plus/icons_plus.dart';

Expand Down Expand Up @@ -65,22 +66,34 @@ class LibraryScreen extends StatelessWidget {
style: Default_Theme.primaryTextStyle.merge(const TextStyle(
fontSize: 34, color: Default_Theme.primaryColor1))),
const Spacer(),
InkWell(
onTap: () {
createPlaylistBottomSheet(context);
},
child: const Icon(MingCute.add_fill,
size: 25, color: Default_Theme.primaryColor1),
),
InkWell(
onTap: () {
context.pushNamed(GlobalStrConsts.ImportMediaFromPlatforms);
},
child: const Padding(
padding: EdgeInsets.only(left: 10),
child: Icon(FontAwesome.file_import_solid,
size: 25, color: Default_Theme.primaryColor1),
),
ButtonBar(
buttonPadding: const EdgeInsets.all(0),
children: [
IconButton(
padding: const EdgeInsets.all(5),
constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize:
MaterialTapTargetSize.shrinkWrap, // the '2023' part
),
onPressed: () {
createPlaylistBottomSheet(context);
},
icon: const Icon(MingCute.add_fill,
size: 25, color: Default_Theme.primaryColor1)),
IconButton(
padding: const EdgeInsets.all(5),
constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize:
MaterialTapTargetSize.shrinkWrap, // the '2023' part
),
onPressed: () {
context.pushNamed(GlobalStrConsts.ImportMediaFromPlatforms);
},
icon: const Icon(FontAwesome.file_import_solid,
size: 25, color: Default_Theme.primaryColor1))
],
),
],
),
Expand All @@ -89,8 +102,8 @@ class LibraryScreen extends StatelessWidget {
}

class ListOfPlaylists extends StatefulWidget {
LibraryItemsState state;
ListOfPlaylists({super.key, required this.state});
final LibraryItemsState state;
const ListOfPlaylists({super.key, required this.state});

@override
State<ListOfPlaylists> createState() => _ListOfPlaylistsState();
Expand All @@ -109,47 +122,31 @@ class _ListOfPlaylistsState extends State<ListOfPlaylists> {
return const SizedBox();
} else {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Dismissible(
key: ValueKey(widget.state.playlists[index].playlistName),
background: Container(
color: Colors.red,
child: const Row(
children: [
Padding(
padding: EdgeInsets.only(left: 20),
child: Icon(
MingCute.delete_3_line,
color: Colors.white,
size: 30,
),
),
Spacer(),
],
),
),
direction: DismissDirection.startToEnd,
onDismissed: (DismissDirection direction) {
context.read<LibraryItemsCubit>().removePlaylist(
MediaPlaylistDB(
playlistName:
widget.state.playlists[index].playlistName));
setState(() {
widget.state.playlists.removeAt(index);
});
padding: const EdgeInsets.only(
bottom: 8,
),
child: InkWell(
splashColor: Default_Theme.accentColor1.withOpacity(0.2),
hoverColor: Default_Theme.accentColor2.withOpacity(0.1),
highlightColor: Default_Theme.accentColor2.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
onLongPress: () {
showPlaylistOptsSheet(
context, widget.state.playlists[index].playlistName);
},
child: InkWell(
onTap: () => context
.pushNamed(GlobalStrConsts.playlistView, pathParameters: {
"playlistName": widget.state.playlists[index].playlistName
}),
child: SmallPlaylistCard(
playListTitle: widget.state.playlists[index].playlistName,
coverArt: loadImageCached(
widget.state.playlists[index].coverImgUrl.toString()),
playListsubTitle:
widget.state.playlists[index].subTitle ?? "Unknown"),
),
onTap: () {
context.read<CurrentPlaylistCubit>().setupPlaylist(
widget.state.playlists[index].playlistName);
context.pushNamed(
GlobalStrConsts.playlistView,
);
},
child: SmallPlaylistCard(
playListTitle: widget.state.playlists[index].playlistName,
coverArt: loadImageCached(
widget.state.playlists[index].coverImgUrl.toString()),
playListsubTitle:
widget.state.playlists[index].subTitle ?? "Unknown"),
),
);
}
Expand Down
Loading

0 comments on commit cbbc604

Please sign in to comment.