diff --git a/Sources/dafl_project_flutter/lib/controller/controller.dart b/Sources/dafl_project_flutter/lib/controller/controller.dart index a59fce3..9e73a5d 100644 --- a/Sources/dafl_project_flutter/lib/controller/controller.dart +++ b/Sources/dafl_project_flutter/lib/controller/controller.dart @@ -2,7 +2,7 @@ import 'dart:convert'; import 'package:dafl_project_flutter/model/music.dart'; import 'package:dafl_project_flutter/services/api/api_spotify.dart'; import 'package:dafl_project_flutter/services/database/database_service.dart'; -import 'package:dafl_project_flutter/services/position/area.dart'; +import 'package:dafl_project_flutter/services/position/location.dart'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart' as http; import '../model/spot.dart'; @@ -11,8 +11,9 @@ import '../model/user.dart'; class Controller { ApiSpotify _api = ApiSpotify(); late User _currentUser; - Area _area = Area(); - DataBaseService _dataBaseService = DataBaseService(); + final Location _location = Location(); + final DataBaseService _dataBaseService = DataBaseService(); + bool sortChoice = false; //false = sort by name ; true = sort by date late BuildContext navigatorKey; @@ -50,13 +51,11 @@ class Controller { } List getSpots() { - return _area.spots; + return _location.spots; } - Future> getArea() async { - await _area.sendCurrentLocation(); - await _area.getData(); - return _area.spots; + getLocation() async { + await _location.sendCurrentLocation(); } playTrack(String id) { @@ -76,7 +75,6 @@ class Controller { _api.requests.addToPlaylist(id); } - // DATABASE void save(User userToSave) { _dataBaseService.save(userToSave); @@ -98,12 +96,8 @@ class Controller { return await _dataBaseService.searchUser(username); } - - - - - Future sendEmail( - User reporter, User reported, String reason, String message) async { + Future sendEmail(String reporterId, String reportedId, String reason, + String message) async { const serviceId = 'service_dzyndyb'; const templateId = 'template_idgriw2'; const userId = 'hy7HxL5QGV6gpdqry'; @@ -119,13 +113,12 @@ class Controller { 'template_id': templateId, 'user_id': userId, 'template_params': { - 'from_name': reporter.usernameDafl, - 'to_name': reported.usernameDafl, + 'from_name': reporterId, + 'to_name': reportedId, 'reason': reason, 'message': message, }, }), ); } - */ } diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index b78e806..d7b1dad 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -46,14 +46,11 @@ class MyApp extends StatelessWidget { enum CardStatus { like, disLike, discovery, message } class CardProvider extends ChangeNotifier { - final List _spotsList = MyApp.controller.getSpots(); bool _isDragging = false; double _angle = 0; Offset _position = Offset.zero; Size _screenSize = Size.zero; - List get spotsList => _spotsList; - bool get isDragging => _isDragging; Offset get position => _position; @@ -373,14 +370,15 @@ class CardProvider extends ChangeNotifier { } Future _nextCard() async { - dev.log(_spotsList.length.toString()); - if (_spotsList.isEmpty) { + List spots = MyApp.controller.getSpots(); + dev.log(spots.length.toString()); + if (spots.isEmpty) { dev.log('dernier'); return; } else { await Future.delayed(const Duration(milliseconds: 200)); - dev.log(_spotsList.last.music.name); - _spotsList.removeLast(); + dev.log(spots.last.music.name); + spots.removeLast(); resetPosition(); } } diff --git a/Sources/dafl_project_flutter/lib/model/message.dart b/Sources/dafl_project_flutter/lib/model/message.dart index 65ee12f..878df70 100644 --- a/Sources/dafl_project_flutter/lib/model/message.dart +++ b/Sources/dafl_project_flutter/lib/model/message.dart @@ -1,8 +1,8 @@ import 'user.dart'; class Message { - User sender; + String senderId; String content; - Message(this.sender, this.content); + Message(this.senderId, this.content); } diff --git a/Sources/dafl_project_flutter/lib/services/database/database_user_modifier.dart b/Sources/dafl_project_flutter/lib/services/database/database_user_modifier.dart index 0234c71..cdea142 100644 --- a/Sources/dafl_project_flutter/lib/services/database/database_user_modifier.dart +++ b/Sources/dafl_project_flutter/lib/services/database/database_user_modifier.dart @@ -1,8 +1,15 @@ - - import 'package:dafl_project_flutter/services/database/user_modifier.dart'; -class DatabaseUserModifier implements UserModifier{ - - -} \ No newline at end of file +class DatabaseUserModifier implements UserModifier { + @override + changeCurrentPassword(String userToModify, String newPass) { + // TODO: implement changeCurrentPassword + throw UnimplementedError(); + } + + @override + changeUsername(String userToModify, String newName) { + // TODO: implement changeUsername + throw UnimplementedError(); + } +} diff --git a/Sources/dafl_project_flutter/lib/services/position/area.dart b/Sources/dafl_project_flutter/lib/services/position/area.dart deleted file mode 100644 index 6fc1f55..0000000 --- a/Sources/dafl_project_flutter/lib/services/position/area.dart +++ /dev/null @@ -1,57 +0,0 @@ -import 'package:geolocator/geolocator.dart'; -import 'package:http/http.dart' as http; -import 'dart:convert'; -import 'dart:async'; -import '../main.dart'; - -class Location { - static Future> sendCurrentLocation() async { - - Uri uri = Uri.parse("https://codefirst.iut.uca.fr/containers/php_script-dorianhodin/insertAndMakeListUser.php"); - Map spot = {}; - LocationPermission permission; - - permission = await Geolocator.checkPermission(); - - if (permission == LocationPermission.denied) { - - permission = await Geolocator.requestPermission(); - - if (permission == LocationPermission.deniedForever) { - - return Future.error('Location Not Available'); - - } - } - - String actualUser = MyApp.controller.currentUser.usernameDafl; - String actualSong = await MyApp.api.getCurrentlyPlayingTrack(); - Position current = await Geolocator.getCurrentPosition(); - - http.Response response = await http.post(uri, body: { - "id": actualUser.toString(), - "latitude": current.latitude.toString(), - "longitude": current.longitude.toString(), - "idMusic": actualSong.toString(), - }); - - var data = jsonDecode(response.body); - - if (data == 2){ - - return Future.error("Failed to connect, connection timeout"); - - }else if (data == 3) { - - return Future.error("POST method failed"); - - }else{ - - data.forEach((s) => spot.putIfAbsent(s['user'], () => s['music'])); - return spot; - - } - } -} - - diff --git a/Sources/dafl_project_flutter/lib/services/position/location.dart b/Sources/dafl_project_flutter/lib/services/position/location.dart index fa96c57..563b11e 100644 --- a/Sources/dafl_project_flutter/lib/services/position/location.dart +++ b/Sources/dafl_project_flutter/lib/services/position/location.dart @@ -1 +1,55 @@ -class Location {} +import 'package:dafl_project_flutter/model/spot.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:http/http.dart' as http; +import 'dart:convert'; +import 'dart:async'; +import '../../main.dart'; + +class Location { + final Map _spots = {}; + + List get spots { + List spots = []; + _spots.forEach((key, value) { + spots.add(Spot(key, value)); + }); + return spots; + } + + sendCurrentLocation() async { + Uri uri = Uri.parse( + "https://codefirst.iut.uca.fr/containers/php_script-dorianhodin/insertAndMakeListUser.php"); + LocationPermission permission; + + permission = await Geolocator.checkPermission(); + + if (permission == LocationPermission.denied) { + permission = await Geolocator.requestPermission(); + + if (permission == LocationPermission.deniedForever) { + //TODO : handle this case + } + } + + String actualUser = MyApp.controller.getIdDafl().toString(); + String actualSong = MyApp.controller.getCurrentMusic(); + Position current = await Geolocator.getCurrentPosition(); + + http.Response response = await http.post(uri, body: { + "id": actualUser, + "latitude": current.latitude.toString(), + "longitude": current.longitude.toString(), + "idMusic": actualSong, + }); + + var data = jsonDecode(response.body); + + if (data == 2) { + return Future.error("Failed to connect, connection timeout"); + } else if (data == 3) { + return Future.error("POST method failed"); + } else { + data.forEach((s) => _spots.putIfAbsent(s['user'], () => s['music'])); + } + } +} diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/p_conversation.dart b/Sources/dafl_project_flutter/lib/views/pages/main/p_conversation.dart index 6667407..ef6d849 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/p_conversation.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/p_conversation.dart @@ -12,7 +12,7 @@ class ConversationPage extends StatefulWidget { } class _ConversationPageState extends State { - User destinataire = User("test1", '1234'); + String destinataire = 'test'; List messages = []; bool isNull = true; @@ -20,13 +20,13 @@ class _ConversationPageState extends State { void sendMessage(String content) { setState(() { - messages - .add(messageWidget(Message(MyApp.controller.currentUser, content))); + messages.add(messageWidget( + Message(MyApp.controller.getIdDafl().toString(), content))); }); } Widget messageWidget(Message message) { - if (message.sender != MyApp.controller.currentUser) { + if (message.senderId != MyApp.controller.getIdDafl().toString()) { return Align( alignment: Alignment.centerLeft, child: Container( @@ -374,8 +374,11 @@ class _ConversationPageState extends State { height: 70, child: ElevatedButton( onPressed: () { - MyApp.controller.sendEmail(MyApp.controller.currentUser, - destinataire, currentValue, messageTextField.text); + MyApp.controller.sendEmail( + MyApp.controller.getIdDafl().toString(), + destinataire, + currentValue, + messageTextField.text); Navigator.pop(context); }, style: ElevatedButton.styleFrom( diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart b/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart index eb10007..81f6c7d 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/w_discovery.dart @@ -39,17 +39,17 @@ class _DiscoveryWidgetState extends State { ), OutlinedButton( onPressed: () { - MyApp.controller.currentUser.sortChoise = - !MyApp.controller.currentUser.sortChoise; + MyApp.controller.sortChoice = + !MyApp.controller.sortChoice; rebuildAllChildren(context); setState(() {}); }, style: OutlinedButton.styleFrom( + foregroundColor: Colors.grey, shadowColor: Colors.black, - shape: CircleBorder(), - padding: EdgeInsets.all(24), - primary: Colors.grey), - child: MyApp.controller.currentUser.sortChoise + shape: const CircleBorder(), + padding: const EdgeInsets.all(24)), + child: MyApp.controller.sortChoice ? Image.asset( 'assets/images/date_sort_icon.png', height: 25, @@ -70,7 +70,7 @@ class _DiscoveryWidgetState extends State { ), ), Expanded( - child: MyApp.controller.currentUser.discovery.isEmpty + child: MyApp.controller.getDiscoveries().isEmpty ? Center( child: Image.asset( 'assets/images/EmptyDiscovery-Hint.png', @@ -119,7 +119,7 @@ class _DiscoveryListState extends State { @override Widget build(BuildContext context) { var listDiscoveries = MyApp.controller.getDiscoveries(); - if (MyApp.controller.currentUser.sortChoise) { + if (MyApp.controller.sortChoice) { listDiscoveries.sort((a, b) { return a.date.compareTo(b.date); }); 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 55baa53..f91b958 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 @@ -1,8 +1,5 @@ - - import 'package:text_scroll/text_scroll.dart'; import 'package:scroll_loop_auto_scroll/scroll_loop_auto_scroll.dart'; - import '../../../main.dart'; import '../../../model/music.dart'; import './w_settings.dart'; @@ -32,19 +29,18 @@ class MainPageProfil extends StatefulWidget { } class _MainPageProfilState extends State { - String? username = MyApp.controller.currentUser.usernameDafl; - late Future data; - - Future getdata() async { - return MyApp.api.getTrackInfo( await MyApp.api.getCurrentlyPlayingTrack()); + String username = MyApp.controller.getIdDafl().toString(); + late Future data; + Future getData() async { + return await MyApp.controller + .getCompleteMusic(MyApp.controller.getCurrentMusic()); } @override - initState() { + initState() async { super.initState(); - username = MyApp.controller.currentUser.usernameDafl; - MyApp.controller.currentUser.actualiseCurrentMusic(); + username = MyApp.controller.getIdDafl().toString(); } @override @@ -86,14 +82,14 @@ class _MainPageProfilState extends State { ], ), child: Center( - child: Text(username![0], + child: Text(username[0], style: const TextStyle( color: Colors.white, fontSize: 60, fontWeight: FontWeight.w500), textAlign: TextAlign.center))), Text( - username!, + username, style: const TextStyle( color: Colors.white, fontSize: 17, @@ -236,122 +232,138 @@ class _MainPageProfilState extends State { ], ), 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.center, - children: [ - Container( - margin: const EdgeInsets.fromLTRB(15, 0, 0, 0), - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: Image.network(snapshot.data!['cover'], + 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.center, + children: [ + Container( + margin: + const EdgeInsets.fromLTRB(15, 0, 0, 0), + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.network( + snapshot.data!.linkCover, height: 90, width: 90, - ))), - Container( - margin: const EdgeInsets.fromLTRB(12, 20, 0, 0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - snapshot.data!['name'].length > 22? - SizedBox(width: 220, - child: ScrollLoopAutoScroll( - delayAfterScrollInput: Duration(seconds: 1), - delay: Duration(seconds: 1), - child: Text( - snapshot.data!['name'], - style: TextStyle(fontSize: 20, - color: Colors.white, - fontWeight: FontWeight.bold), + ))), + Container( + margin: + const EdgeInsets.fromLTRB(12, 20, 0, 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + snapshot.data!.name.length > 22 + ? SizedBox( + width: 220, + child: ScrollLoopAutoScroll( + delayAfterScrollInput: + const Duration(seconds: 1), + delay: + const Duration(seconds: 1), + duration: const Duration( + seconds: 100), + scrollDirection: + Axis.horizontal, + child: Text( + snapshot.data!.name, + style: const TextStyle( + fontSize: 20, + color: Colors.white, + fontWeight: + FontWeight.bold), + ), + ), + ) + : Text( + snapshot.data!.name, + style: const TextStyle( + fontSize: 20, + color: Colors.white, + fontWeight: FontWeight.bold), + ), + Text( + snapshot.data!.artist, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Colors.grey), ), - duration: Duration(seconds: 100), - scrollDirection: Axis.horizontal, - ),) - :Text( - snapshot.data!['name'], - style: TextStyle(fontSize: 20, - color: Colors.white, - fontWeight: FontWeight.bold), - ), - - - 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), + ], + ), + ) + ], + ), + ); + } 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), + const SizedBox( + height: 10, ), - ), - ], - ), - ) - ], - ), - ); - } - - }) - , + Container( + width: 100, + height: 20, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(5.0), + color: Colors.grey.withOpacity(0.4), + ), + ), + ], + ), + ) + ], + ), + ); + } + }), ], ), ), @@ -382,7 +394,7 @@ class _MainPageProfilState extends State { builder: (context) => const SettingsWidget())) .then((value) => setState(() { username = - MyApp.controller.currentUser.usernameDafl; + MyApp.controller.getIdDafl().toString(); })); }, child: Row( @@ -418,5 +430,4 @@ class _MainPageProfilState extends State { ), ); } - } diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/w_spot.dart b/Sources/dafl_project_flutter/lib/views/pages/main/w_spot.dart index b02575d..f582fad 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/w_spot.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/w_spot.dart @@ -31,11 +31,9 @@ class _SpotsWidgetState extends State { child: Container( decoration: BoxDecoration( image: DecorationImage( - image: NetworkImage( - MyApp.controller.currentUser.spots.isEmpty - ? "https://i.imgur.com/Uovh293.png" - : MyApp.controller.currentUser.spots.last.music - .linkCover), + image: NetworkImage(MyApp.controller.getSpots().isEmpty + ? "https://i.imgur.com/Uovh293.png" + : MyApp.controller.getSpots().last.music.linkCover), fit: BoxFit.cover, ), ), @@ -49,32 +47,31 @@ class _SpotsWidgetState extends State { ), ), Align( - alignment: FractionalOffset.bottomCenter, - child: MyApp.controller.currentUser.spots.isEmpty - ? const Center( - child: SizedBox( - width: 300, - height: 300, - child: riv.RiveAnimation.asset( - 'assets/images/search_spot_animation.riv'), - ), - ) - : OpenContainer( - closedColor: Colors.transparent, - closedElevation: 0, - transitionDuration: const Duration(milliseconds: 400), - closedBuilder: (context, openWidget) { - return const PreviewInfoWidget(); - }, - openBuilder: (context, closeWidget) { - return const DisplayInfoWidget(); - }, - ), + alignment: FractionalOffset.bottomCenter, + child: MyApp.controller.getSpots().isEmpty + ? Container() + : OpenContainer( + closedColor: Colors.transparent, + closedElevation: 0, + transitionDuration: const Duration(milliseconds: 400), + closedBuilder: (context, openWidget) { + return const PreviewInfoWidget(); + }, + openBuilder: (context, closeWidget) { + return const DisplayInfoWidget(); + })), + const Center( + child: SizedBox( + width: 300, + height: 300, + child: riv.RiveAnimation.asset( + 'assets/images/search_spot_animation.riv'), + ), ), Positioned( top: height * 0.68, width: width, - child: MyApp.controller.currentUser.spots.isEmpty + child: MyApp.controller.getSpots().isEmpty ? Container() : Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -165,68 +162,77 @@ class _SpotsWidgetState extends State { )), ), ), - MyApp.controller.currentUser.spots.isEmpty? - SafeArea(child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - MyApp.controller.currentUser.spots.isEmpty? - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text( - 'Quelques instants...', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.w500, - fontSize: 25), - ), - const Padding(padding: EdgeInsets.fromLTRB(0, 5, 0, 0)), - Text( - 'Nous cherchons des profils a vous proposer.', - style: TextStyle( - color: Colors.grey.withOpacity(0.4), fontSize: 15), - ), - ], - ) : - Container(), - - ] - ) - ),): - Padding( - padding: const EdgeInsets.fromLTRB(20, 60, 0, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(MyApp.controller.currentUser.spots.last.music.name, - style: TextStyle( - fontFamily: 'DMSans', - color: Colors.white.withOpacity(1), - fontSize: 20, - fontWeight: FontWeight.w800), - ), - Text(MyApp.controller.currentUser.spots.last.music.artist, - style: TextStyle( - fontFamily: 'DMSans', - color: Colors.white.withOpacity(1), - fontSize: 17, - fontWeight: FontWeight.w200), + MyApp.controller.getSpots().isEmpty + ? SafeArea( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + MyApp.controller.getSpots().isEmpty + ? Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + const Text( + 'Quelques instants...', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w500, + fontSize: 25), + ), + const Padding( + padding: + EdgeInsets.fromLTRB(0, 5, 0, 0)), + Text( + 'Nous cherchons des profils a vous proposer.', + style: TextStyle( + color: Colors.grey.withOpacity(0.4), + fontSize: 15), + ), + ], + ) + : Container(), + ])), + ) + : Padding( + padding: const EdgeInsets.fromLTRB(20, 60, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + MyApp.controller.getSpots().isEmpty + ? '' + : MyApp.controller.getSpots().last.music.name, + style: TextStyle( + fontFamily: 'DMSans', + color: Colors.white.withOpacity(1), + fontSize: 20, + fontWeight: FontWeight.w800), + ), + Text( + MyApp.controller.getSpots().isEmpty + ? '' + : MyApp.controller.getSpots().last.music.artist, + style: TextStyle( + fontFamily: 'DMSans', + color: Colors.white.withOpacity(1), + fontSize: 17, + fontWeight: FontWeight.w200), + ), + ], + ), ), - ], - ), - ), Positioned( top: 115, right: 0, child: GestureDetector( onTap: () { - MyApp.api.playTrack( - MyApp.controller.currentUser.spots.last.music.id); + MyApp.controller + .playTrack(MyApp.controller.getSpots().last.music.id); }, child: SizedBox( height: 40, - child: !MyApp.controller.currentUser.spots.isEmpty + child: MyApp.controller.getSpots().isEmpty ? Image.asset("assets/images/play_spotify_button.png") : Container(), ), @@ -238,7 +244,7 @@ class _SpotsWidgetState extends State { Widget buildCards() { final provider = Provider.of(context); - final urlImages = provider.spotsList; + final urlImages = MyApp.controller.getSpots(); return Stack( children: urlImages diff --git a/Sources/dafl_project_flutter/pubspec.lock b/Sources/dafl_project_flutter/pubspec.lock index 3799d6e..b8a2dcf 100644 --- a/Sources/dafl_project_flutter/pubspec.lock +++ b/Sources/dafl_project_flutter/pubspec.lock @@ -558,6 +558,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.1" + time: + dependency: transitive + description: + name: time + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" typed_data: dependency: transitive description: