From 63640c8c2a6a3f8e3918c69ed04df6b6c59909b7 Mon Sep 17 00:00:00 2001 From: Lucas Delanier Date: Fri, 28 Oct 2022 18:00:48 +0200 Subject: [PATCH] mise a jour binding discovery --- Sources/dafl_project_flutter/lib/main.dart | 55 +++++++++++-------- .../dafl_project_flutter/lib/model/music.dart | 6 +- .../dafl_project_flutter/lib/model/user.dart | 18 +++--- .../lib/views/pages/main/p_conversation.dart | 12 +--- .../lib/views/pages/main/w_discovery.dart | 2 +- .../lib/views/pages/main/w_profile.dart | 2 + .../lib/views/pages/main/w_spot.dart | 13 ++--- 7 files changed, 54 insertions(+), 54 deletions(-) diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index 351df2e..28acecc 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -10,6 +10,8 @@ import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:rive/rive.dart'; import '../controller/controller.dart'; +import '../model/music.dart'; +import 'model/music.dart'; void main() { MyApp mainApp = MyApp(); @@ -39,13 +41,13 @@ class MyApp extends StatelessWidget { enum CardStatus { like, disLike, discovery, message} class CardProvider extends ChangeNotifier{ - List _urlImages = []; + List _spotsList = []; bool _isDragging = false; double _angle = 0; Offset _position = Offset.zero; Size _screenSize = Size.zero; - List get urlImages => _urlImages; + List get spotsList => _spotsList; bool get isDragging => _isDragging; Offset get position => _position; double get angle => _angle; @@ -55,16 +57,7 @@ class CardProvider extends ChangeNotifier{ } void resetUsers() { - _urlImages = [ - 'https://khaligidilit.com/assets/images/cover-LAI%CC%88LA-Khali.jpeg', - 'https://m.media-amazon.com/images/I/61aUOMzwS8L._SL1440_.jpg', - 'https://pbs.twimg.com/media/ExJ-My-XMAE3Ko2.jpg', - 'https://cdns-images.dzcdn.net/images/cover/2818a661c6d533155ce6dffc256b1f51/500x500.jpg', - 'https://cdns-images.dzcdn.net/images/cover/b351f0e935c9c3901f8d893b92ab952a/500x500.jpg', - 'https://cdns-images.dzcdn.net/images/cover/65147b581f2ace9e0f0723ee76e70fda/500x500.jpg', - 'https://cdns-images.dzcdn.net/images/cover/173b96be8ac025fb9578b0139010bc80/500x500.jpg', - 'https://cdns-images.dzcdn.net/images/cover/17a9747927ac3e5ea56f92f635d9180c/500x500.jpg', - ].reversed.toList(); + _spotsList = MyApp().controller.currentUser.Spots; notifyListeners(); } @@ -170,20 +163,34 @@ class CardProvider extends ChangeNotifier{ void discovery() { Vibration.vibrate(duration: 20, amplitude: 60); - print("discovery"); _angle = 0; _position -= Offset(0, -_screenSize.height); _discovery_card(); - Fluttertoast.showToast( - msg: 'Ajouté', - toastLength: Toast.LENGTH_SHORT, - gravity: ToastGravity.TOP, - timeInSecForIosWeb: 2, - backgroundColor: Colors.deepPurple, - textColor: Colors.white - ); + print("discovery"); + if(MyApp().controller.currentUser.Discovery.contains(MyApp().controller.currentUser.Spots.last)){ + MyApp().controller.currentUser.Discovery.remove(MyApp().controller.currentUser.Spots.last); + Fluttertoast.showToast( + msg: 'Supprimer', + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.TOP, + timeInSecForIosWeb: 2, + backgroundColor: Colors.red, + textColor: Colors.white + ); + } + else{ + MyApp().controller.currentUser.addDiscovery(MyApp().controller.currentUser.Spots.last); + Fluttertoast.showToast( + msg: 'Ajouté', + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.TOP, + timeInSecForIosWeb: 2, + backgroundColor: Colors.deepPurple, + textColor: Colors.white + ); + notifyListeners(); + } - notifyListeners(); } void message(context) { @@ -314,10 +321,10 @@ class CardProvider extends ChangeNotifier{ } Future _nextCard() async { - if ( _urlImages.isEmpty) return; + if ( _spotsList.isEmpty) return; await Future.delayed(Duration(milliseconds: 200)); - _urlImages.removeLast(); + _spotsList.removeLast(); resetPosition(); } diff --git a/Sources/dafl_project_flutter/lib/model/music.dart b/Sources/dafl_project_flutter/lib/model/music.dart index fd16a4e..74bb1ab 100644 --- a/Sources/dafl_project_flutter/lib/model/music.dart +++ b/Sources/dafl_project_flutter/lib/model/music.dart @@ -1,7 +1,7 @@ class Music{ - String? name; - String? artist; - String? linkCover; + String name; + String artist; + String linkCover; Music(this.name, this.artist, this.linkCover); diff --git a/Sources/dafl_project_flutter/lib/model/user.dart b/Sources/dafl_project_flutter/lib/model/user.dart index 1e0cab2..b39ed09 100644 --- a/Sources/dafl_project_flutter/lib/model/user.dart +++ b/Sources/dafl_project_flutter/lib/model/user.dart @@ -22,14 +22,16 @@ class User{ //lists Set likedUsers={}; - List Discovery=[ - Music('Couleurs','Khali','https://www.goutemesdisques.com/uploads/tx_gmdchron/pi1/L_Etrange_Histoire_de_Mr_Anderson.jpg'), - Music('Couleurs','Khali','https://www.goutemesdisques.com/uploads/tx_gmdchron/pi1/L_Etrange_Histoire_de_Mr_Anderson.jpg'), - Music('Couleurs','Khali','https://www.goutemesdisques.com/uploads/tx_gmdchron/pi1/L_Etrange_Histoire_de_Mr_Anderson.jpg'), - Music('Couleurs','Khali','https://www.goutemesdisques.com/uploads/tx_gmdchron/pi1/L_Etrange_Histoire_de_Mr_Anderson.jpg'), - Music('Couleurs','Khali','https://www.goutemesdisques.com/uploads/tx_gmdchron/pi1/L_Etrange_Histoire_de_Mr_Anderson.jpg'), - Music('Couleurs','Khali','https://www.goutemesdisques.com/uploads/tx_gmdchron/pi1/L_Etrange_Histoire_de_Mr_Anderson.jpg'), - Music('Couleurs','Khali','https://www.goutemesdisques.com/uploads/tx_gmdchron/pi1/L_Etrange_Histoire_de_Mr_Anderson.jpg')]; + List Discovery=[]; + + List Spots=[ + Music('Couleurs','Khali','https://khaligidilit.com/assets/images/cover-LAI%CC%88LA-Khali.jpeg'), + Music("J'suis PNL",'PNL','https://m.media-amazon.com/images/I/61aUOMzwS8L._SL1440_.jpg'), + Music('Sundance','Nepal','https://pbs.twimg.com/media/ExJ-My-XMAE3Ko2.jpg'), + Music('Eternelle 2','So La Lune','https://cdns-images.dzcdn.net/images/cover/2818a661c6d533155ce6dffc256b1f51/500x500.jpg'), + Music('M.I.L.S 3','Ninho','https://cdns-images.dzcdn.net/images/cover/b351f0e935c9c3901f8d893b92ab952a/500x500.jpg'), + Music('Deux frères','PNL','https://cdns-images.dzcdn.net/images/cover/65147b581f2ace9e0f0723ee76e70fda/500x500.jpg'), + Music('Paradis','Sopico','https://cdns-images.dzcdn.net/images/cover/17a9747927ac3e5ea56f92f635d9180c/500x500.jpg')].reversed.toList(); Map conversations={}; void addDiscovery(Music newmusic){ 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 26a1614..81be0e6 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 @@ -18,16 +18,7 @@ class _ConversationPageState extends State { extendBodyBehindAppBar: true, resizeToAvoidBottomInset: true, appBar: AppBar( - flexibleSpace: Container( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.black, Colors.transparent], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - ) - - ), - ), + backgroundColor: Color(0xFF141414), toolbarHeight: 70, title: Container( child: Row( @@ -48,7 +39,6 @@ class _ConversationPageState extends State { ), ), - backgroundColor: Colors.transparent, elevation: 0, ), body: SingleChildScrollView( 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 94c2534..3a08e32 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 @@ -101,7 +101,7 @@ class _DiscoveryListState extends State { borderRadius: BorderRadius.all(Radius.circular(10)), ), child: Container( - child: FadeInImage.assetNetwork(placeholder: "assets/images/loadingPlaceholder.gif", image: 'https://www.goutemesdisques.com/uploads/tx_gmdchron/pi1/L_Etrange_Histoire_de_Mr_Anderson.jpg'), + child: FadeInImage.assetNetwork(placeholder: "assets/images/loadingPlaceholder.gif", image: MyApp().controller.currentUser.Discovery[reversedIndex].linkCover), ),), Container( margin: EdgeInsets.fromLTRB(20, 0, 0, 0), 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 8c18487..7139a32 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,5 +1,7 @@ import 'package:dafl_project_flutter/main.dart'; +import '../../../main.dart'; +import '../../../main.dart'; import './w_settings.dart'; import './w_spot.dart'; import 'package:flutter/material.dart'; 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 48ee24f..92cebf1 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 @@ -41,8 +41,8 @@ class _SpotsWidgetState extends State { child: Container( decoration: BoxDecoration( image: DecorationImage( - image: NetworkImage(provider.urlImages.isEmpty != true - ?provider.urlImages.last + image: NetworkImage(provider.spotsList.isEmpty != true + ?provider.spotsList.last.linkCover :"https://i.imgur.com/Uovh293.png"), fit: BoxFit.cover, @@ -97,7 +97,6 @@ class _SpotsWidgetState extends State { ), GestureDetector( onTap: () { - MyApp().controller.currentUser.addDiscovery(Music('e','Khali','https://www.goutemesdisques.com/uploads/tx_gmdchron/pi1/L_Etrange_Histoire_de_Mr_Anderson.jpg')); final provider = Provider.of(context, listen: false); provider.discovery(); }, @@ -159,8 +158,8 @@ class _SpotsWidgetState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('COULEURS',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 20, fontWeight: FontWeight.w800),), - Text('Khali',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 17, fontWeight: FontWeight.w200),), + Text(MyApp().controller.currentUser.Spots.last.name ?? '',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 20, fontWeight: FontWeight.w800),), + Text(MyApp().controller.currentUser.Spots.last.artist ?? '',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 17, fontWeight: FontWeight.w200),), ], ),), ], @@ -171,12 +170,12 @@ class _SpotsWidgetState extends State { Widget buildCards() { final provider = Provider.of(context); - final urlImages = provider.urlImages; + final urlImages = provider.spotsList; return Stack( children: urlImages .map((urlImage) => CardWidget( - urlImage: urlImage, + urlImage: urlImage.linkCover, isFront: urlImages.last == urlImage, )) .toList(),