-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Favourite Section to save songs in favourites playlist
- Loading branch information
1 parent
0cb825c
commit f0ce8c5
Showing
13 changed files
with
326 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'dart:collection'; | ||
import 'dart:convert'; | ||
import 'dart:developer'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/src/widgets/container.dart'; | ||
import 'package:flutter/src/widgets/framework.dart'; | ||
import 'package:hive_flutter/hive_flutter.dart'; | ||
import 'package:vibe_music/Models/Track.dart'; | ||
import 'package:vibe_music/widgets/TrackTile.dart'; | ||
|
||
class FavouriteScreen extends StatelessWidget { | ||
const FavouriteScreen({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
backgroundColor: Colors.transparent, | ||
elevation: 0, | ||
title: const Text("My Favorites"), | ||
centerTitle: true, | ||
), | ||
body: ValueListenableBuilder( | ||
valueListenable: Hive.box('myfavourites').listenable(), | ||
builder: (BuildContext context, Box box, child) { | ||
List favourites = box.values.toList(); | ||
favourites.sort((a, b) => a['timeStamp'].compareTo(b['timeStamp'])); | ||
if (favourites.isEmpty) { | ||
return Center( | ||
child: Text( | ||
"Nothing Here", | ||
style: Theme.of(context).primaryTextTheme.bodyLarge, | ||
), | ||
); | ||
} | ||
return ListView( | ||
children: favourites.map((track) { | ||
Map<String, dynamic> newMap = jsonDecode(jsonEncode(track)); | ||
return TrackTile(track: newMap); | ||
}).toList(), | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.