From 0329a582d03c608554a35dda106b6de6a727f945 Mon Sep 17 00:00:00 2001 From: delanierlucas Date: Tue, 29 Nov 2022 08:38:52 +0100 Subject: [PATCH] futur builder on current music --- .idea/libraries/Dart_Packages.xml | 692 ------------------ .idea/libraries/Dart_SDK.xml | 38 +- .../lib/views/pages/main/w_profile.dart | 149 ++-- 3 files changed, 123 insertions(+), 756 deletions(-) delete mode 100644 .idea/libraries/Dart_Packages.xml diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml deleted file mode 100644 index f8237c9..0000000 --- a/.idea/libraries/Dart_Packages.xml +++ /dev/null @@ -1,692 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index cb79f3d..b6e6985 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/w_profile.dart b/Sources/dafl_project_flutter/lib/views/pages/main/w_profile.dart index 71bb08e..a8e0184 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/w_profile.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/w_profile.dart @@ -28,14 +28,18 @@ class MainPageProfil extends StatefulWidget { class _MainPageProfilState extends State { String? username = MyApp.controller.currentUser.usernameDafl; - late Music currentmusic; + late Future data; + + Future getdata() async { + return MyApp.api.getTrackInfo( await MyApp.api.getCurrentlyPlayingTrack()); + + } @override initState() { super.initState(); username = MyApp.controller.currentUser.usernameDafl; MyApp.controller.currentUser.actualiseCurrentMusic(); - currentmusic = MyApp.controller.currentUser.currentMusic; } @override @@ -226,53 +230,108 @@ class _MainPageProfilState extends State { ), ], ), - Container( - margin: const EdgeInsets.fromLTRB(0, 10, 0, 0), - height: height * 0.14, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15.0), - color: const Color(0xFFD9D9D9).withOpacity(0.08), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - margin: const EdgeInsets.fromLTRB(15, 0, 0, 0), - child: ClipRRect( - borderRadius: BorderRadius.circular(15), - child: FadeInImage.assetNetwork( - height: 90, - width: 90, - placeholder: - "assets/images/loadingPlaceholder.gif", - image: currentmusic.linkCover))), - Container( - margin: const EdgeInsets.fromLTRB(12, 20, 0, 0), - child: Column( + FutureBuilder( + future: getdata(), + builder: (context, snapshot){ + if(snapshot.connectionState == ConnectionState.done){ + return Container( + margin: const EdgeInsets.fromLTRB(0, 10, 0, 0), + height: height * 0.14, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15.0), + color: const Color(0xFFD9D9D9).withOpacity(0.08), + ), + child: Row( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text( - currentmusic.name, - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.w500, - color: Colors.white), - ), - Text( - currentmusic.artist, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w400, - color: Colors.grey), - ), + Container( + margin: const EdgeInsets.fromLTRB(15, 0, 0, 0), + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.network(snapshot.data!['cover'], + height: 90, + width: 90, + ))), + Container( + margin: const EdgeInsets.fromLTRB(12, 20, 0, 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + snapshot.data!['name'], + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w500, + color: Colors.white), + ), + Text( + snapshot.data!['artist'], + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Colors.grey), + ), + ], + ), + ) ], ), - ) - ], - ), - ), + ); + } + else{ + return Container( + margin: const EdgeInsets.fromLTRB(0, 10, 0, 0), + height: height * 0.14, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15.0), + color: const Color(0xFFD9D9D9).withOpacity(0.08), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + margin: const EdgeInsets.fromLTRB(15, 0, 0, 0), + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.asset("assets/images/loadingPlaceholder.gif", + height: 90, + width: 90))), + Container( + margin: const EdgeInsets.fromLTRB(12, 20, 0, 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 150, + height: 20, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.grey.withOpacity(0.7), + ), + ), + SizedBox(height: 10,), + Container( + width: 100, + height: 20, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.grey.withOpacity(0.4), + ), + ), + ], + ), + ) + ], + ), + ); + } + + }) + , ], ), ),