stay connected! display info when empty collection song and possibility to delete song from collection in the list when logpress
continuous-integration/drone/push Build is passing Details

NEW_STAY_CONNECTED_LDE
Lucas Delanier 2 years ago
parent 1ac6d85f59
commit e776abfeab

@ -387,34 +387,6 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="flutter_blurhash">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_blurhash-0.7.0/lib" />
</list>
</value>
</entry>
<entry key="flutter_cache_manager">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_cache_manager-3.3.1/lib" />
</list>
</value>
</entry>
<entry key="flutter_blurhash">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_blurhash-0.7.0/lib" />
</list>
</value>
</entry>
<entry key="flutter_cache_manager">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_cache_manager-3.3.1/lib" />
</list>
</value>
</entry>
<entry key="flutter_countdown_timer"> <entry key="flutter_countdown_timer">
<value> <value>
<list> <list>
@ -611,132 +583,6 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="google_identity_services_web">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_identity_services_web-0.2.1/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in-6.1.4/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_android">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_android-6.1.18/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_ios">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_ios-5.6.2/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_platform_interface">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_platform_interface-2.4.1/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_web">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_web-0.12.0+2/lib" />
</list>
</value>
</entry>
<entry key="google_identity_services_web">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_identity_services_web-0.2.1/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in-6.1.4/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_android">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_android-6.1.18/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_ios">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_ios-5.6.2/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_platform_interface">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_platform_interface-2.4.1/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_web">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_web-0.12.0+2/lib" />
</list>
</value>
</entry>
<entry key="google_identity_services_web">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_identity_services_web-0.2.1/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in-6.1.4/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_android">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_android-6.1.18/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_ios">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_ios-5.6.2/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_platform_interface">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_platform_interface-2.4.1/lib" />
</list>
</value>
</entry>
<entry key="google_sign_in_web">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/google_sign_in_web-0.12.0+2/lib" />
</list>
</value>
</entry>
<entry key="gradiantbutton"> <entry key="gradiantbutton">
<value> <value>
<list> <list>
@ -905,20 +751,6 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="octo_image">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/octo_image-1.0.2/lib" />
</list>
</value>
</entry>
<entry key="octo_image">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/octo_image-1.0.2/lib" />
</list>
</value>
</entry>
<entry key="path"> <entry key="path">
<value> <value>
<list> <list>
@ -1017,41 +849,6 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="quiver">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/quiver-3.2.1/lib" />
</list>
</value>
</entry>
<entry key="rxdart">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/rxdart-0.27.7/lib" />
</list>
</value>
</entry>
<entry key="quiver">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/quiver-3.2.1/lib" />
</list>
</value>
</entry>
<entry key="rxdart">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/rxdart-0.27.7/lib" />
</list>
</value>
</entry>
<entry key="quiver">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/quiver-3.2.1/lib" />
</list>
</value>
</entry>
<entry key="rxdart"> <entry key="rxdart">
<value> <value>
<list> <list>
@ -1101,34 +898,6 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="sqflite">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/sqflite-2.3.0/lib" />
</list>
</value>
</entry>
<entry key="sqflite_common">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/sqflite_common-2.5.0/lib" />
</list>
</value>
</entry>
<entry key="sqflite">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/sqflite-2.3.0/lib" />
</list>
</value>
</entry>
<entry key="sqflite_common">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/sqflite_common-2.5.0/lib" />
</list>
</value>
</entry>
<entry key="stack_trace"> <entry key="stack_trace">
<value> <value>
<list> <list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

@ -57,26 +57,10 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
late StreamSubscription<User?> user; late StreamSubscription<User?> user;
Stream<userJustMusic.User?> userCurrent = Stream.empty();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
checkSignIn();
}
Future<userJustMusic.User?> checkSignIn() async {
user = FirebaseAuth.instance.authStateChanges().listen((user) async {
if (user == null) {
print('User is currently signed out!');
return null;
} else {
MyApp.userViewModel.userCurrent = (await (MyApp.userViewModel.getUser(user.uid)))!;
userCurrent = Stream.value(MyApp.userViewModel.userCurrent);
print('User is signed in!');
}
});
return null;
} }
@override @override
@ -94,6 +78,47 @@ class _MyAppState extends State<MyApp> {
return ScreenUtilInit( return ScreenUtilInit(
useInheritedMediaQuery: true, useInheritedMediaQuery: true,
builder: (context, child) { builder: (context, child) {
return StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (ConnectionState.waiting == snapshot.connectionState) {
return const CupertinoActivityIndicator();
}
if (snapshot.hasData) {
return FutureBuilder<userJustMusic.User?>(
future: MyApp.userViewModel.getUser(snapshot.data!.uid),
builder: (context, userSnapshot) {
if (userSnapshot.connectionState == ConnectionState.waiting) {
return const CupertinoActivityIndicator();
} else {
if (userSnapshot.hasData) {
MyApp.userViewModel.userCurrent = userSnapshot.data!;
return MaterialApp(
routes: {
'/welcome': (context) => const WellcomeScreen(),
'/feed': (context) => const FeedScreen(),
'/login': (context) => const LoginScreen(),
'/register': (context) => const RegistrationScreen(),
'/post': (context) => const PostScreen(),
'/profile': (context) => const ProfileScreen(),
'/explanation': (context) => const ExplanationsScreen(),
'/addFriend': (context) => const AddFriendScreen(),
'/launchingRocket': (context) => const LaunchingRocketScreen(),
'/verifyEmail': (context) => const VerifyEmailScreen(),
'/forgetPassword': (context) => const ForgetPasswordScreen(),
},
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: FeedScreen());
} else {
return const Text('User data not found');
}
}
},
);
} else {
return MaterialApp( return MaterialApp(
routes: { routes: {
'/welcome': (context) => const WellcomeScreen(), '/welcome': (context) => const WellcomeScreen(),
@ -113,6 +138,8 @@ class _MyAppState extends State<MyApp> {
primarySwatch: Colors.blue, primarySwatch: Colors.blue,
), ),
home: WellcomeScreen()); home: WellcomeScreen());
}
});
}, },
designSize: Size(390, 844), designSize: Size(390, 844),
); );

@ -27,18 +27,14 @@ class _LoginScreenState extends State<LoginScreen> {
handleLogin() async { handleLogin() async {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
try { try {
await MyApp.userViewModel await MyApp.userViewModel.login(_userMailTextField.text, _passwordTextField.text);
.login(_userMailTextField.text, _passwordTextField.text);
Navigator.pushNamed(context, '/feed'); Navigator.pushNamed(context, '/feed');
} catch (e) { } catch (e) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text( content: Text(
e.toString(), e.toString(),
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h),
color: Colors.white,
fontWeight: FontWeight.w400,
fontSize: 20.h),
), ),
backgroundColor: Colors.red, backgroundColor: Colors.red,
), ),
@ -79,25 +75,19 @@ class _LoginScreenState extends State<LoginScreen> {
child: Form( child: Form(
key: _formKey, key: _formKey,
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.center,
CrossAxisAlignment.center,
children: [ children: [
Flexible( Flexible(
flex: 4, flex: 4,
child: Padding( child: Padding(
padding: EdgeInsets.only(bottom: 60), padding: EdgeInsets.only(bottom: 60),
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.end,
MainAxisAlignment.end,
children: [ children: [
Text( Text(
"Te revoilà!", "Te revoilà!",
style: style: GoogleFonts.plusJakartaSans(
GoogleFonts.plusJakartaSans( color: Colors.white, fontWeight: FontWeight.w600, fontSize: 38.h),
color: Colors.white,
fontWeight:
FontWeight.w600,
fontSize: 38.h),
), ),
SizedBox( SizedBox(
height: 10, height: 10,
@ -106,12 +96,8 @@ class _LoginScreenState extends State<LoginScreen> {
width: 230.w, width: 230.w,
child: Text( child: Text(
"Bon retour parmis nous tu nous as manqué!", "Bon retour parmis nous tu nous as manqué!",
style: GoogleFonts style: GoogleFonts.plusJakartaSans(
.plusJakartaSans( color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h),
color: Colors.white,
fontWeight:
FontWeight.w400,
fontSize: 20.h),
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
), ),
@ -122,51 +108,33 @@ class _LoginScreenState extends State<LoginScreen> {
Expanded( Expanded(
flex: 5, flex: 5,
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.end,
CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [ children: [
TextFormField( TextFormField(
controller: _userMailTextField, controller: _userMailTextField,
keyboardAppearance: keyboardAppearance: Brightness.dark,
Brightness.dark,
validator: (value) { validator: (value) {
if (value == null || if (value == null || value.isEmpty) {
value.isEmpty) {
return 'entrez un email valide'; return 'entrez un email valide';
} }
return null; return null;
}, },
cursorColor: primaryColor, cursorColor: primaryColor,
keyboardType: keyboardType: TextInputType.emailAddress,
TextInputType.emailAddress, style: GoogleFonts.plusJakartaSans(color: primaryColor),
style:
GoogleFonts.plusJakartaSans(
color: primaryColor),
decoration: InputDecoration( decoration: InputDecoration(
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderSide: BorderSide( borderSide: BorderSide(width: 1, color: strokeTextField),
width: 1, borderRadius: BorderRadius.all(Radius.circular(10))),
color: prefix: const Padding(padding: EdgeInsets.only(left: 20.0)),
strokeTextField), suffix: const Padding(padding: EdgeInsets.only(left: 20.0)),
borderRadius: BorderRadius.all(
Radius.circular(10))),
prefix: const Padding(
padding: EdgeInsets.only(
left: 20.0)),
suffix: const Padding(
padding: EdgeInsets.only(
left: 20.0)),
fillColor: bgTextField, fillColor: bgTextField,
filled: true, filled: true,
errorStyle: TextStyle( errorStyle: TextStyle(fontSize: 9, height: 0.3),
fontSize: 9, height: 0.3), focusColor: Color.fromRGBO(255, 255, 255, 0.30),
focusColor: Color.fromRGBO(
255, 255, 255, 0.30),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderSide: borderSide: BorderSide(width: 1, color: strokeTextField),
BorderSide(width: 1, color: strokeTextField),
borderRadius: BorderRadius.all(Radius.circular(10))), borderRadius: BorderRadius.all(Radius.circular(10))),
hintText: 'Email', hintText: 'Email',
hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField)), hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField)),
@ -176,55 +144,31 @@ class _LoginScreenState extends State<LoginScreen> {
), ),
TextFormField( TextFormField(
controller: _passwordTextField, controller: _passwordTextField,
keyboardAppearance: keyboardAppearance: Brightness.dark,
Brightness.dark,
obscureText: passenable, obscureText: passenable,
validator: (value) { validator: (value) {
if (value == null || if (value == null || value.isEmpty) {
value.isEmpty) {
return 'entrez un mot de passe valide'; return 'entrez un mot de passe valide';
} }
return null; return null;
}, },
cursorColor: primaryColor, cursorColor: primaryColor,
style: style: GoogleFonts.plusJakartaSans(color: primaryColor),
GoogleFonts.plusJakartaSans(
color: primaryColor),
decoration: InputDecoration( decoration: InputDecoration(
focusedBorder: focusedBorder: OutlineInputBorder(
OutlineInputBorder( borderSide: BorderSide(width: 1, color: strokeTextField),
borderSide: BorderSide( borderRadius: BorderRadius.all(Radius.circular(10))),
width: 1,
color:
strokeTextField),
borderRadius:
BorderRadius.all(
Radius.circular(
10))),
fillColor: bgTextField, fillColor: bgTextField,
filled: true, filled: true,
focusColor: Color.fromRGBO( focusColor: Color.fromRGBO(255, 255, 255, 0.30),
255, 255, 255, 0.30), enabledBorder: OutlineInputBorder(
enabledBorder: borderSide: BorderSide(width: 1, color: strokeTextField),
OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10))),
borderSide: BorderSide(
width: 1,
color:
strokeTextField),
borderRadius:
BorderRadius.all(
Radius.circular(
10))),
hintText: 'Mot de passe', hintText: 'Mot de passe',
hintStyle: hintStyle: GoogleFonts.plusJakartaSans(color: strokeTextField),
GoogleFonts.plusJakartaSans( prefix: const Padding(padding: EdgeInsets.only(left: 20.0)),
color: strokeTextField),
prefix: const Padding(
padding: EdgeInsets.only(
left: 20.0)),
suffixIcon: Container( suffixIcon: Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(right: 10),
right: 10),
margin: EdgeInsets.all(5), margin: EdgeInsets.all(5),
height: 3, height: 3,
child: InkWell( child: InkWell(
@ -238,38 +182,28 @@ class _LoginScreenState extends State<LoginScreen> {
}); });
}, },
// Image tapped // Image tapped
splashColor: splashColor: Colors.white10,
Colors.white10,
// Splash color over image // Splash color over image
child: Image( child: Image(
image: passenable image: passenable
? AssetImage( ? AssetImage("assets/images/show_icon.png")
"assets/images/show_icon.png") : AssetImage("assets/images/hide_icon.png"),
: AssetImage(
"assets/images/hide_icon.png"),
height: 2, height: 2,
), ),
)), )),
errorStyle: TextStyle( errorStyle: TextStyle(fontSize: 9, height: 0.3),
fontSize: 9, height: 0.3),
), ),
), ),
GestureDetector( GestureDetector(
behavior: behavior: HitTestBehavior.translucent,
HitTestBehavior.translucent,
onTap: () { onTap: () {
Navigator.pushNamed( Navigator.pushNamed(context, '/forgetPassword');
context, '/forgetPassword');
}, },
child: Padding( child: Padding(
padding: padding: EdgeInsets.only(top: 10),
EdgeInsets.only(top: 10),
child: Text( child: Text(
"Mot de passe oublié?", "Mot de passe oublié?",
style: GoogleFonts style: GoogleFonts.plusJakartaSans(color: Colors.white),
.plusJakartaSans(
color:
Colors.white),
), ),
)), )),
SizedBox( SizedBox(
@ -283,40 +217,27 @@ class _LoginScreenState extends State<LoginScreen> {
)), )),
Align( Align(
child: GestureDetector( child: GestureDetector(
behavior: behavior: HitTestBehavior.translucent,
HitTestBehavior.translucent,
onTap: () { onTap: () {
Navigator.pushNamed( Navigator.pushNamed(context, '/register');
context, '/register');
}, },
child: Padding( child: Padding(
padding: padding: EdgeInsets.only(top: 20),
EdgeInsets.only(top: 20),
child: RichText( child: RichText(
textAlign: TextAlign.center, textAlign: TextAlign.center,
text: TextSpan( text: TextSpan(
text: text: 'Pas encore inscrit?',
'Pas encore inscrit?', style: GoogleFonts.plusJakartaSans(
style: GoogleFonts color: Colors.white,
.plusJakartaSans( fontWeight: FontWeight.w400,
color:
Colors.white,
fontWeight:
FontWeight
.w400,
fontSize: 15), fontSize: 15),
children: <TextSpan>[ children: <TextSpan>[
TextSpan( TextSpan(
text: " Sinscire", text: " Sinscire",
style: GoogleFonts style: GoogleFonts.plusJakartaSans(
.plusJakartaSans( fontSize: 15,
fontSize: fontWeight: FontWeight.w400,
15, color: primaryColor)),
fontWeight:
FontWeight
.w400,
color:
primaryColor)),
], ],
), ),
), ),
@ -331,59 +252,51 @@ class _LoginScreenState extends State<LoginScreen> {
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 20), padding: EdgeInsets.only(top: 20),
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.start,
MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [ children: [
ConstrainedBox( ConstrainedBox(
constraints: BoxConstraints( constraints: BoxConstraints(maxWidth: 600),
maxWidth: 600),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceEvenly,
MainAxisAlignment
.spaceEvenly,
children: [ children: [
Expanded( Expanded(
child: Container( child: Container(
color: color: Color(0xFF3D3D3D),
Color(0xFF3D3D3D),
height: 1, height: 1,
), ),
), ),
Padding( Padding(
padding: const EdgeInsets padding: const EdgeInsets.only(
.only( left: defaultPadding, right: defaultPadding),
left:
defaultPadding,
right:
defaultPadding),
child: Text( child: Text(
'Ou', 'Ou',
style: GoogleFonts style: GoogleFonts.plusJakartaSans(
.plusJakartaSans( color: Colors.white, fontWeight: FontWeight.bold),
color: Colors
.white,
fontWeight:
FontWeight
.bold),
), ),
), ),
Expanded( Expanded(
child: Container( child: Container(
height: 1, height: 1,
color: color: Color(0xFF3D3D3D),
Color(0xFF3D3D3D),
)), )),
], ],
), ),
), ),
SizedBox( SizedBox(height: defaultPadding),
height: defaultPadding), ConstrainedBox(
SignInButton( constraints: BoxConstraints(maxWidth: 540),
child: SizedBox(
width: 300.sp,
height: 50,
child: SignInButton(
Buttons.Google, Buttons.Google,
text: "Login with Google", text: "Login with Google",
onPressed: signInWithGoogle, onPressed: signInWithGoogle,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
),
),
), ),
], ],
), ),

@ -269,6 +269,28 @@ class _SearchSongScreenState extends State<SearchSongScreen> {
future: _fetchSavedSong(), future: _fetchSavedSong(),
builder: (BuildContext context, AsyncSnapshot<List<Music>> snapshot) { builder: (BuildContext context, AsyncSnapshot<List<Music>> snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
if (snapshot.data?.length == 0) {
return Container(
width: double.infinity,
height: double.infinity,
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Votre collection est vide.",
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w800, fontSize: 18),
),
),
Image.asset(
"assets/images/empty_collection.png",
width: 300,
)
],
),
);
} else {
return ListView.builder( return ListView.builder(
physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast), physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast),
controller: _scrollController, controller: _scrollController,
@ -277,7 +299,47 @@ class _SearchSongScreenState extends State<SearchSongScreen> {
if (playingIndex == index) { if (playingIndex == index) {
return InkWell( return InkWell(
onTap: () { onTap: () {
widget.callback(filteredData[index]); widget.callback((snapshot.data?[index])!);
},
onLongPress: () {
showCupertinoModalPopup<void>(
context: context,
builder: (BuildContext context) => CupertinoAlertDialog(
title: const Text('Supprimer la musique'),
content: Text(
'Etes-vous sur de vouloir supprimer ${(snapshot.data?[index])!.title} de votre collection?'),
actions: <CupertinoDialogAction>[
CupertinoDialogAction(
/// This parameter indicates this action is the default,
/// and turns the action's text to bold text.
isDefaultAction: true,
onPressed: () {
Navigator.pop(context);
},
child: const Text('Annuler'),
),
CupertinoDialogAction(
/// This parameter indicates the action would perform
/// a destructive action such as deletion, and turns
/// the action's text color to red.
isDestructiveAction: true,
onPressed: () async {
Navigator.pop(context);
await MyApp.musicViewModel
.addOrDeleteFavoriteMusic((snapshot.data?[index])!.id);
MyApp.userViewModel.userCurrent.musics_likes
.remove((snapshot.data?[index])!.id);
MyApp.audioPlayer.release();
setState(() {
playingIndex = null;
});
},
child: const Text('Supprimer'),
),
],
),
);
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
@ -293,6 +355,42 @@ class _SearchSongScreenState extends State<SearchSongScreen> {
onTap: () { onTap: () {
widget.callback((snapshot.data?[index])!); widget.callback((snapshot.data?[index])!);
}, },
onLongPress: () {
showCupertinoModalPopup<void>(
context: context,
builder: (BuildContext context) => CupertinoAlertDialog(
title: const Text('Supprimer la musique'),
content: Text(
'Etes-vous sur de vouloir supprimer ${(snapshot.data?[index])!.title} de votre collection?'),
actions: <CupertinoDialogAction>[
CupertinoDialogAction(
/// This parameter indicates this action is the default,
/// and turns the action's text to bold text.
isDefaultAction: true,
onPressed: () {
Navigator.pop(context);
},
child: const Text('Annuler'),
),
CupertinoDialogAction(
/// This parameter indicates the action would perform
/// a destructive action such as deletion, and turns
/// the action's text color to red.
isDestructiveAction: true,
onPressed: () async {
Navigator.pop(context);
await MyApp.musicViewModel
.addOrDeleteFavoriteMusic((snapshot.data?[index])!.id);
MyApp.userViewModel.userCurrent.musics_likes
.remove((snapshot.data?[index])!.id);
setState(() {});
},
child: const Text('Supprimer'),
),
],
),
);
},
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
child: MusicListComponent( child: MusicListComponent(
@ -303,6 +401,7 @@ class _SearchSongScreenState extends State<SearchSongScreen> {
), ),
)); ));
}); });
}
} else { } else {
return CupertinoActivityIndicator(); return CupertinoActivityIndicator();
} }

Loading…
Cancel
Save