Résolution d'erreurs

remotes/origin/database-api-implementation
Félix MIELCAREK 2 years ago committed by felixmielcarek
parent 7b3b514770
commit e049a265cd

@ -2,7 +2,7 @@ import 'dart:convert';
import 'package:dafl_project_flutter/model/music.dart'; import 'package:dafl_project_flutter/model/music.dart';
import 'package:dafl_project_flutter/services/api/api_spotify.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/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:flutter/cupertino.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import '../model/spot.dart'; import '../model/spot.dart';
@ -11,8 +11,9 @@ import '../model/user.dart';
class Controller { class Controller {
ApiSpotify _api = ApiSpotify(); ApiSpotify _api = ApiSpotify();
late User _currentUser; late User _currentUser;
Area _area = Area(); final Location _location = Location();
DataBaseService _dataBaseService = DataBaseService(); final DataBaseService _dataBaseService = DataBaseService();
bool sortChoice = false; //false = sort by name ; true = sort by date
late BuildContext navigatorKey; late BuildContext navigatorKey;
@ -50,13 +51,11 @@ class Controller {
} }
List<Spot> getSpots() { List<Spot> getSpots() {
return _area.spots; return _location.spots;
} }
Future<List<Spot>> getArea() async { getLocation() async {
await _area.sendCurrentLocation(); await _location.sendCurrentLocation();
await _area.getData();
return _area.spots;
} }
playTrack(String id) { playTrack(String id) {
@ -76,7 +75,6 @@ class Controller {
_api.requests.addToPlaylist(id); _api.requests.addToPlaylist(id);
} }
// DATABASE // DATABASE
void save(User userToSave) { void save(User userToSave) {
_dataBaseService.save(userToSave); _dataBaseService.save(userToSave);
@ -98,12 +96,8 @@ class Controller {
return await _dataBaseService.searchUser(username); return await _dataBaseService.searchUser(username);
} }
Future sendEmail(String reporterId, String reportedId, String reason,
String message) async {
Future sendEmail(
User reporter, User reported, String reason, String message) async {
const serviceId = 'service_dzyndyb'; const serviceId = 'service_dzyndyb';
const templateId = 'template_idgriw2'; const templateId = 'template_idgriw2';
const userId = 'hy7HxL5QGV6gpdqry'; const userId = 'hy7HxL5QGV6gpdqry';
@ -119,13 +113,12 @@ class Controller {
'template_id': templateId, 'template_id': templateId,
'user_id': userId, 'user_id': userId,
'template_params': { 'template_params': {
'from_name': reporter.usernameDafl, 'from_name': reporterId,
'to_name': reported.usernameDafl, 'to_name': reportedId,
'reason': reason, 'reason': reason,
'message': message, 'message': message,
}, },
}), }),
); );
} }
*/
} }

@ -46,14 +46,11 @@ class MyApp extends StatelessWidget {
enum CardStatus { like, disLike, discovery, message } enum CardStatus { like, disLike, discovery, message }
class CardProvider extends ChangeNotifier { class CardProvider extends ChangeNotifier {
final List<Spot> _spotsList = MyApp.controller.getSpots();
bool _isDragging = false; bool _isDragging = false;
double _angle = 0; double _angle = 0;
Offset _position = Offset.zero; Offset _position = Offset.zero;
Size _screenSize = Size.zero; Size _screenSize = Size.zero;
List<Spot> get spotsList => _spotsList;
bool get isDragging => _isDragging; bool get isDragging => _isDragging;
Offset get position => _position; Offset get position => _position;
@ -373,14 +370,15 @@ class CardProvider extends ChangeNotifier {
} }
Future _nextCard() async { Future _nextCard() async {
dev.log(_spotsList.length.toString()); List<Spot> spots = MyApp.controller.getSpots();
if (_spotsList.isEmpty) { dev.log(spots.length.toString());
if (spots.isEmpty) {
dev.log('dernier'); dev.log('dernier');
return; return;
} else { } else {
await Future.delayed(const Duration(milliseconds: 200)); await Future.delayed(const Duration(milliseconds: 200));
dev.log(_spotsList.last.music.name); dev.log(spots.last.music.name);
_spotsList.removeLast(); spots.removeLast();
resetPosition(); resetPosition();
} }
} }

@ -1,8 +1,8 @@
import 'user.dart'; import 'user.dart';
class Message { class Message {
User sender; String senderId;
String content; String content;
Message(this.sender, this.content); Message(this.senderId, this.content);
} }

@ -1,8 +1,15 @@
import 'package:dafl_project_flutter/services/database/user_modifier.dart'; import 'package:dafl_project_flutter/services/database/user_modifier.dart';
class DatabaseUserModifier implements UserModifier{ 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();
}
}

@ -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<Map<String, dynamic>> sendCurrentLocation() async {
Uri uri = Uri.parse("https://codefirst.iut.uca.fr/containers/php_script-dorianhodin/insertAndMakeListUser.php");
Map<String, dynamic> 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;
}
}
}

@ -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<Spot> get spots {
List<Spot> 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']));
}
}
}

@ -12,7 +12,7 @@ class ConversationPage extends StatefulWidget {
} }
class _ConversationPageState extends State<ConversationPage> { class _ConversationPageState extends State<ConversationPage> {
User destinataire = User("test1", '1234'); String destinataire = 'test';
List<Widget> messages = []; List<Widget> messages = [];
bool isNull = true; bool isNull = true;
@ -20,13 +20,13 @@ class _ConversationPageState extends State<ConversationPage> {
void sendMessage(String content) { void sendMessage(String content) {
setState(() { setState(() {
messages messages.add(messageWidget(
.add(messageWidget(Message(MyApp.controller.currentUser, content))); Message(MyApp.controller.getIdDafl().toString(), content)));
}); });
} }
Widget messageWidget(Message message) { Widget messageWidget(Message message) {
if (message.sender != MyApp.controller.currentUser) { if (message.senderId != MyApp.controller.getIdDafl().toString()) {
return Align( return Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Container( child: Container(
@ -374,8 +374,11 @@ class _ConversationPageState extends State<ConversationPage> {
height: 70, height: 70,
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
MyApp.controller.sendEmail(MyApp.controller.currentUser, MyApp.controller.sendEmail(
destinataire, currentValue, messageTextField.text); MyApp.controller.getIdDafl().toString(),
destinataire,
currentValue,
messageTextField.text);
Navigator.pop(context); Navigator.pop(context);
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(

@ -39,17 +39,17 @@ class _DiscoveryWidgetState extends State<DiscoveryWidget> {
), ),
OutlinedButton( OutlinedButton(
onPressed: () { onPressed: () {
MyApp.controller.currentUser.sortChoise = MyApp.controller.sortChoice =
!MyApp.controller.currentUser.sortChoise; !MyApp.controller.sortChoice;
rebuildAllChildren(context); rebuildAllChildren(context);
setState(() {}); setState(() {});
}, },
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
foregroundColor: Colors.grey,
shadowColor: Colors.black, shadowColor: Colors.black,
shape: CircleBorder(), shape: const CircleBorder(),
padding: EdgeInsets.all(24), padding: const EdgeInsets.all(24)),
primary: Colors.grey), child: MyApp.controller.sortChoice
child: MyApp.controller.currentUser.sortChoise
? Image.asset( ? Image.asset(
'assets/images/date_sort_icon.png', 'assets/images/date_sort_icon.png',
height: 25, height: 25,
@ -70,7 +70,7 @@ class _DiscoveryWidgetState extends State<DiscoveryWidget> {
), ),
), ),
Expanded( Expanded(
child: MyApp.controller.currentUser.discovery.isEmpty child: MyApp.controller.getDiscoveries().isEmpty
? Center( ? Center(
child: Image.asset( child: Image.asset(
'assets/images/EmptyDiscovery-Hint.png', 'assets/images/EmptyDiscovery-Hint.png',
@ -119,7 +119,7 @@ class _DiscoveryListState extends State<DiscoveryList> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var listDiscoveries = MyApp.controller.getDiscoveries(); var listDiscoveries = MyApp.controller.getDiscoveries();
if (MyApp.controller.currentUser.sortChoise) { if (MyApp.controller.sortChoice) {
listDiscoveries.sort((a, b) { listDiscoveries.sort((a, b) {
return a.date.compareTo(b.date); return a.date.compareTo(b.date);
}); });

@ -1,8 +1,5 @@
import 'package:text_scroll/text_scroll.dart'; import 'package:text_scroll/text_scroll.dart';
import 'package:scroll_loop_auto_scroll/scroll_loop_auto_scroll.dart'; import 'package:scroll_loop_auto_scroll/scroll_loop_auto_scroll.dart';
import '../../../main.dart'; import '../../../main.dart';
import '../../../model/music.dart'; import '../../../model/music.dart';
import './w_settings.dart'; import './w_settings.dart';
@ -32,19 +29,18 @@ class MainPageProfil extends StatefulWidget {
} }
class _MainPageProfilState extends State<MainPageProfil> { class _MainPageProfilState extends State<MainPageProfil> {
String? username = MyApp.controller.currentUser.usernameDafl; String username = MyApp.controller.getIdDafl().toString();
late Future<Map> data; late Future<Music> data;
Future<Map> getdata() async {
return MyApp.api.getTrackInfo( await MyApp.api.getCurrentlyPlayingTrack());
Future<Music> getData() async {
return await MyApp.controller
.getCompleteMusic(MyApp.controller.getCurrentMusic());
} }
@override @override
initState() { initState() async {
super.initState(); super.initState();
username = MyApp.controller.currentUser.usernameDafl; username = MyApp.controller.getIdDafl().toString();
MyApp.controller.currentUser.actualiseCurrentMusic();
} }
@override @override
@ -86,14 +82,14 @@ class _MainPageProfilState extends State<MainPageProfil> {
], ],
), ),
child: Center( child: Center(
child: Text(username![0], child: Text(username[0],
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 60, fontSize: 60,
fontWeight: FontWeight.w500), fontWeight: FontWeight.w500),
textAlign: TextAlign.center))), textAlign: TextAlign.center))),
Text( Text(
username!, username,
style: const TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 17, fontSize: 17,
@ -236,122 +232,138 @@ class _MainPageProfilState extends State<MainPageProfil> {
], ],
), ),
FutureBuilder( FutureBuilder(
future: getdata(), future: getData(),
builder: (context, snapshot){ builder: (context, snapshot) {
if(snapshot.connectionState == ConnectionState.done){ if (snapshot.connectionState == ConnectionState.done) {
return Container( return Container(
margin: const EdgeInsets.fromLTRB(0, 10, 0, 0), margin: const EdgeInsets.fromLTRB(0, 10, 0, 0),
height: height * 0.14, height: height * 0.14,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(15.0),
color: const Color(0xFFD9D9D9).withOpacity(0.08), color: const Color(0xFFD9D9D9).withOpacity(0.08),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Container(
margin: const EdgeInsets.fromLTRB(15, 0, 0, 0), margin:
child: ClipRRect( const EdgeInsets.fromLTRB(15, 0, 0, 0),
borderRadius: BorderRadius.circular(10), child: ClipRRect(
child: Image.network(snapshot.data!['cover'], borderRadius: BorderRadius.circular(10),
child: Image.network(
snapshot.data!.linkCover,
height: 90, height: 90,
width: 90, width: 90,
))), ))),
Container( Container(
margin: const EdgeInsets.fromLTRB(12, 20, 0, 0), margin:
child: Column( const EdgeInsets.fromLTRB(12, 20, 0, 0),
mainAxisAlignment: MainAxisAlignment.start, child: Column(
crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ crossAxisAlignment:
snapshot.data!['name'].length > 22? CrossAxisAlignment.start,
SizedBox(width: 220, children: [
child: ScrollLoopAutoScroll( snapshot.data!.name.length > 22
delayAfterScrollInput: Duration(seconds: 1), ? SizedBox(
delay: Duration(seconds: 1), width: 220,
child: Text( child: ScrollLoopAutoScroll(
snapshot.data!['name'], delayAfterScrollInput:
style: TextStyle(fontSize: 20, const Duration(seconds: 1),
color: Colors.white, delay:
fontWeight: FontWeight.bold), 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, } else {
fontWeight: FontWeight.bold), return Container(
), margin: const EdgeInsets.fromLTRB(0, 10, 0, 0),
height: height * 0.14,
decoration: BoxDecoration(
Text( borderRadius: BorderRadius.circular(15.0),
snapshot.data!['artist'], color: const Color(0xFFD9D9D9).withOpacity(0.08),
style: const TextStyle( ),
fontSize: 16, child: Row(
fontWeight: FontWeight.w400, mainAxisAlignment: MainAxisAlignment.start,
color: Colors.grey), 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",
else{ height: 90,
return Container( width: 90))),
margin: const EdgeInsets.fromLTRB(0, 10, 0, 0), Container(
height: height * 0.14, margin:
decoration: BoxDecoration( const EdgeInsets.fromLTRB(12, 20, 0, 0),
borderRadius: BorderRadius.circular(15.0), child: Column(
color: const Color(0xFFD9D9D9).withOpacity(0.08), mainAxisAlignment: MainAxisAlignment.start,
), crossAxisAlignment:
child: Row( CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, children: [
crossAxisAlignment: CrossAxisAlignment.center, Container(
children: [ width: 150,
Container( height: 20,
margin: const EdgeInsets.fromLTRB(15, 0, 0, 0), decoration: BoxDecoration(
child: ClipRRect( borderRadius:
borderRadius: BorderRadius.circular(10), BorderRadius.circular(5.0),
child: Image.asset("assets/images/loadingPlaceholder.gif", color: Colors.grey.withOpacity(0.7),
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),
), ),
), const SizedBox(
SizedBox(height: 10,), height: 10,
Container(
width: 100,
height: 20,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: Colors.grey.withOpacity(0.4),
), ),
), 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<MainPageProfil> {
builder: (context) => const SettingsWidget())) builder: (context) => const SettingsWidget()))
.then((value) => setState(() { .then((value) => setState(() {
username = username =
MyApp.controller.currentUser.usernameDafl; MyApp.controller.getIdDafl().toString();
})); }));
}, },
child: Row( child: Row(
@ -418,5 +430,4 @@ class _MainPageProfilState extends State<MainPageProfil> {
), ),
); );
} }
} }

@ -31,11 +31,9 @@ class _SpotsWidgetState extends State<SpotsWidget> {
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: NetworkImage( image: NetworkImage(MyApp.controller.getSpots().isEmpty
MyApp.controller.currentUser.spots.isEmpty ? "https://i.imgur.com/Uovh293.png"
? "https://i.imgur.com/Uovh293.png" : MyApp.controller.getSpots().last.music.linkCover),
: MyApp.controller.currentUser.spots.last.music
.linkCover),
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
@ -49,32 +47,31 @@ class _SpotsWidgetState extends State<SpotsWidget> {
), ),
), ),
Align( Align(
alignment: FractionalOffset.bottomCenter, alignment: FractionalOffset.bottomCenter,
child: MyApp.controller.currentUser.spots.isEmpty child: MyApp.controller.getSpots().isEmpty
? const Center( ? Container()
child: SizedBox( : OpenContainer(
width: 300, closedColor: Colors.transparent,
height: 300, closedElevation: 0,
child: riv.RiveAnimation.asset( transitionDuration: const Duration(milliseconds: 400),
'assets/images/search_spot_animation.riv'), closedBuilder: (context, openWidget) {
), return const PreviewInfoWidget();
) },
: OpenContainer( openBuilder: (context, closeWidget) {
closedColor: Colors.transparent, return const DisplayInfoWidget();
closedElevation: 0, })),
transitionDuration: const Duration(milliseconds: 400), const Center(
closedBuilder: (context, openWidget) { child: SizedBox(
return const PreviewInfoWidget(); width: 300,
}, height: 300,
openBuilder: (context, closeWidget) { child: riv.RiveAnimation.asset(
return const DisplayInfoWidget(); 'assets/images/search_spot_animation.riv'),
}, ),
),
), ),
Positioned( Positioned(
top: height * 0.68, top: height * 0.68,
width: width, width: width,
child: MyApp.controller.currentUser.spots.isEmpty child: MyApp.controller.getSpots().isEmpty
? Container() ? Container()
: Row( : Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@ -165,68 +162,77 @@ class _SpotsWidgetState extends State<SpotsWidget> {
)), )),
), ),
), ),
MyApp.controller.currentUser.spots.isEmpty? MyApp.controller.getSpots().isEmpty
SafeArea(child: Center( ? SafeArea(
child: Column( child: Center(
mainAxisAlignment: MainAxisAlignment.start, child: Column(
children: [ mainAxisAlignment: MainAxisAlignment.start,
MyApp.controller.currentUser.spots.isEmpty? children: [
Column( MyApp.controller.getSpots().isEmpty
crossAxisAlignment: CrossAxisAlignment.start, ? Column(
children: [ crossAxisAlignment:
const Text( CrossAxisAlignment.start,
'Quelques instants...', children: [
style: TextStyle( const Text(
color: Colors.white, 'Quelques instants...',
fontWeight: FontWeight.w500, style: TextStyle(
fontSize: 25), color: Colors.white,
), fontWeight: FontWeight.w500,
const Padding(padding: EdgeInsets.fromLTRB(0, 5, 0, 0)), fontSize: 25),
Text( ),
'Nous cherchons des profils a vous proposer.', const Padding(
style: TextStyle( padding:
color: Colors.grey.withOpacity(0.4), fontSize: 15), EdgeInsets.fromLTRB(0, 5, 0, 0)),
), Text(
], 'Nous cherchons des profils a vous proposer.',
) : style: TextStyle(
Container(), color: Colors.grey.withOpacity(0.4),
fontSize: 15),
] ),
) ],
),): )
Padding( : Container(),
padding: const EdgeInsets.fromLTRB(20, 60, 0, 0), ])),
child: Column( )
crossAxisAlignment: CrossAxisAlignment.start, : Padding(
children: [ padding: const EdgeInsets.fromLTRB(20, 60, 0, 0),
Text(MyApp.controller.currentUser.spots.last.music.name, child: Column(
style: TextStyle( crossAxisAlignment: CrossAxisAlignment.start,
fontFamily: 'DMSans', children: [
color: Colors.white.withOpacity(1), Text(
fontSize: 20, MyApp.controller.getSpots().isEmpty
fontWeight: FontWeight.w800), ? ''
), : MyApp.controller.getSpots().last.music.name,
Text(MyApp.controller.currentUser.spots.last.music.artist, style: TextStyle(
style: TextStyle( fontFamily: 'DMSans',
fontFamily: 'DMSans', color: Colors.white.withOpacity(1),
color: Colors.white.withOpacity(1), fontSize: 20,
fontSize: 17, fontWeight: FontWeight.w800),
fontWeight: FontWeight.w200), ),
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( Positioned(
top: 115, top: 115,
right: 0, right: 0,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
MyApp.api.playTrack( MyApp.controller
MyApp.controller.currentUser.spots.last.music.id); .playTrack(MyApp.controller.getSpots().last.music.id);
}, },
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: !MyApp.controller.currentUser.spots.isEmpty child: MyApp.controller.getSpots().isEmpty
? Image.asset("assets/images/play_spotify_button.png") ? Image.asset("assets/images/play_spotify_button.png")
: Container(), : Container(),
), ),
@ -238,7 +244,7 @@ class _SpotsWidgetState extends State<SpotsWidget> {
Widget buildCards() { Widget buildCards() {
final provider = Provider.of<CardProvider>(context); final provider = Provider.of<CardProvider>(context);
final urlImages = provider.spotsList; final urlImages = MyApp.controller.getSpots();
return Stack( return Stack(
children: urlImages children: urlImages

@ -558,6 +558,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.1" version: "0.1.1"
time:
dependency: transitive
description:
name: time
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:

Loading…
Cancel
Save