From 35232657e5b20ce7c3f8e65ce8affc54b4c45248 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Thu, 17 Nov 2022 20:15:46 +0100 Subject: [PATCH] Add the current Music from near User in discovery (wrong list for now) --- .idea/libraries/Dart_Packages.xml | 328 +++++++++--------- .idea/libraries/Dart_SDK.xml | 38 +- .../dafl_project_flutter/lib/model/user.dart | 48 ++- .../lib/views/pages/main/p_main.dart | 5 +- 4 files changed, 207 insertions(+), 212 deletions(-) diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index 9c93a4a..0568fe9 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -5,662 +5,662 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index cb79f3d..3dbed52 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/model/user.dart b/Sources/dafl_project_flutter/lib/model/user.dart index b79c2e6..a449729 100644 --- a/Sources/dafl_project_flutter/lib/model/user.dart +++ b/Sources/dafl_project_flutter/lib/model/user.dart @@ -73,48 +73,44 @@ class User { _id = await MyApp.api.getCurrentlyPlayingTrack(); track = await MyApp.api.getTrackInfo(_id); } on ApiException { - // TODO : add notification to show that an error occured + // TODO : add notification to show that an error occurred } } - static List listspots (){ + void listspots (){ Future? rep; - List tracklist = []; - int i=0; - String listOfTrack=""; + int i; rep = Location.sendCurrentLocation(); - List> futuretracklist = []; - List> trackid = []; + List> futureMusicList = []; + List> musicId = []; rep.then((String result) { - listOfTrack = result; List tab = result.split(","); - for (i = 0; i < tab.length; i++) { - trackid.add(tab[i].split("-")); - } - for (i = 0; i < trackid.length; i++) { - futuretracklist.add(MyApp.api.getTrackInfo(trackid[i][1])); - } - for (i = 0; i < futuretracklist.length; i++) { - futuretracklist[i].then((Track t) { - tracklist.add(t); - if (i + 1 == futuretracklist.length) { - return tracklist; + if (tab.isEmpty!=true) { + for (i = 0; i < tab.length; i++) { + musicId.add(tab[i].split("-")); + } + /* + for (i = 0; i < musicId.length; i++) { + // futuretracklist.add(MyApp.api.getTrackInfo(trackid[i][1])); + } + futureMusicList[i].then((Music m) { + for (i = 0; i < futureMusicList.length; i++) { + discovery.add(m); } }); + + */ // EN COMMENTAIRE PARCE QUE ERREUR SINON VU QUE J'AI PAS MUSIC POUR L'INSTANT } - }); - return []; + }); } - static List getListSpots(){ - List listTrack =[]; + void getListSpots(){ if (test==0){ test=1; - listTrack = listspots(); + listspots(); }else{ - timer = Timer.periodic(const Duration(seconds: 10), (Timer t) => listTrack=listspots()); + timer = Timer.periodic(const Duration(seconds: 72), (Timer t) => listspots()); } - return listTrack; } @override diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/p_main.dart b/Sources/dafl_project_flutter/lib/views/pages/main/p_main.dart index b336882..326e293 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/p_main.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/p_main.dart @@ -1,5 +1,5 @@ +import 'package:dafl_project_flutter/main.dart'; import 'package:flutter/material.dart'; -import '../../../api/track.dart'; import '../../../presentation/custom_icons_icons.dart'; import './w_settings.dart'; import './w_spot.dart'; @@ -7,7 +7,6 @@ import './w_discovery.dart'; import './w_profile.dart'; import './w_messages.dart'; import 'w_top.dart'; -import '../../../model/user.dart'; @@ -33,7 +32,7 @@ class _MainPageState extends State { @override Widget build(BuildContext context) { - List spots = User.getListSpots(); + MyApp.controller.currentUser.getListSpots(); double height = MediaQuery.of(context).size.height; return Scaffold( resizeToAvoidBottomInset: false,