From 057c9117c804b7928537faace646db0e3dec7d7e Mon Sep 17 00:00:00 2001 From: Lucas Delanier Date: Fri, 28 Oct 2022 01:35:22 +0200 Subject: [PATCH] link view modele profil page and discovery --- .../lib/controller/controller.dart | 35 +++ Sources/dafl_project_flutter/lib/main.dart | 4 + .../lib/model/conversation.dart | 21 ++ .../lib/model/message.dart | 11 + .../dafl_project_flutter/lib/model/music.dart | 19 ++ .../dafl_project_flutter/lib/model/user.dart | 67 +++++ .../lib/model/user_creator.dart | 8 + .../lib/views/pages/main/p_conversation.dart | 132 +++++----- .../lib/views/pages/main/p_main.dart | 2 +- .../lib/views/pages/main/w_discovery.dart | 238 ++++++------------ .../lib/views/pages/main/w_profile.dart | 27 +- .../lib/views/pages/main/w_settings.dart | 26 +- .../lib/views/pages/main/w_spot.dart | 8 +- .../lib/views/pages/sign_in/p_sign_in.dart | 22 +- .../lib/views/pages/sign_up/p_sign_up.dart | 33 ++- 15 files changed, 410 insertions(+), 243 deletions(-) create mode 100644 Sources/dafl_project_flutter/lib/controller/controller.dart create mode 100644 Sources/dafl_project_flutter/lib/model/conversation.dart create mode 100644 Sources/dafl_project_flutter/lib/model/message.dart create mode 100644 Sources/dafl_project_flutter/lib/model/music.dart create mode 100644 Sources/dafl_project_flutter/lib/model/user.dart create mode 100644 Sources/dafl_project_flutter/lib/model/user_creator.dart diff --git a/Sources/dafl_project_flutter/lib/controller/controller.dart b/Sources/dafl_project_flutter/lib/controller/controller.dart new file mode 100644 index 0000000..23864bd --- /dev/null +++ b/Sources/dafl_project_flutter/lib/controller/controller.dart @@ -0,0 +1,35 @@ +import '../model/user.dart'; + + +class Controller{ + static Controller? _this; + + User currentUser = User(null, null); + + factory Controller(){ + if (_this == null) _this = Controller._(); + return _this!; + } + + Controller._(); + + void save(User userToSave){ + } + + void load(String username, String password) async{ + } + + User createUser(String username, String password){ + return User(username, password); + } + + void changeCurrentUser(User user){ + this.currentUser = user; + } + + void changeUsernameCourant(String newName){ + if(newName !=null){ + this.currentUser?.usernameDafl = newName; + } + } +} diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index 2ab1678..351df2e 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -9,17 +9,21 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:rive/rive.dart'; +import '../controller/controller.dart'; void main() { + MyApp mainApp = MyApp(); runApp(MyApp()); } class MyApp extends StatelessWidget { + Controller controller = Controller(); // This widget is the root of your application. @override Widget build(BuildContext context){ + Paint.enableDithering = true; SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); return ChangeNotifierProvider( create: (context) => CardProvider(), diff --git a/Sources/dafl_project_flutter/lib/model/conversation.dart b/Sources/dafl_project_flutter/lib/model/conversation.dart new file mode 100644 index 0000000..09f38cf --- /dev/null +++ b/Sources/dafl_project_flutter/lib/model/conversation.dart @@ -0,0 +1,21 @@ +import 'message.dart'; +import 'user.dart'; + +class Conversation{ + User firstUser; + User secondUser; + List messages=[]; + + Conversation(this.firstUser,this.secondUser); + + void addMessage(User sender,String content){ + messages.add(Message(sender, content)); + } + + void displayMessages(){ + print("-----Conversation entre $firstUser et $secondUser-----"); + for (var element in messages) { + print(element); + } + } +} \ No newline at end of file diff --git a/Sources/dafl_project_flutter/lib/model/message.dart b/Sources/dafl_project_flutter/lib/model/message.dart new file mode 100644 index 0000000..2fe88a8 --- /dev/null +++ b/Sources/dafl_project_flutter/lib/model/message.dart @@ -0,0 +1,11 @@ +import 'user.dart'; + +class Message{ + User sender; + String content; + + Message(this.sender,this.content); + + @override + String toString() => "$sender : $content"; +} \ No newline at end of file diff --git a/Sources/dafl_project_flutter/lib/model/music.dart b/Sources/dafl_project_flutter/lib/model/music.dart new file mode 100644 index 0000000..fd16a4e --- /dev/null +++ b/Sources/dafl_project_flutter/lib/model/music.dart @@ -0,0 +1,19 @@ +class Music{ + String? name; + String? artist; + String? linkCover; + + Music(this.name, this.artist, this.linkCover); + + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Music && + runtimeType == other.runtimeType && + name == other.name && + artist == other.artist; + + @override + int get hashCode => name.hashCode ^ artist.hashCode; +} \ No newline at end of file diff --git a/Sources/dafl_project_flutter/lib/model/user.dart b/Sources/dafl_project_flutter/lib/model/user.dart new file mode 100644 index 0000000..1e0cab2 --- /dev/null +++ b/Sources/dafl_project_flutter/lib/model/user.dart @@ -0,0 +1,67 @@ +import 'package:dafl_project_flutter/main.dart'; + +import 'conversation.dart'; +import 'music.dart'; + +class User{ + //attributes from DAFL + int? idDafl; + String? usernameDafl; + String? passwDafl; + //attributes to link with API + String? usernameAPI; + String? passwAPI; + + //constructors + User(this.usernameDafl, this.passwDafl); + + User.name(this.usernameDafl); + + User.fromDatabase(this.idDafl, this.usernameDafl); + + + //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')]; + Map conversations={}; + + void addDiscovery(Music newmusic){ + if(MyApp().controller.currentUser?.Discovery == null){ + + } + else{ + MyApp().controller.currentUser?.Discovery?.add(newmusic); + } + + + } + + void like(User liked){ + likedUsers.add(liked); + Conversation? conv = liked.conversations[this]; + if(conv==null) { + conversations[liked]= Conversation(this, liked); + } else { + conversations[liked]= conv; + } + } + + void chat(User recipient,String content){ + Conversation? conv = conversations[recipient]; + if(conv != null) conv.addMessage(this, content); + } + + void displayConversations(){ + conversations.forEach((k,v) => v.displayMessages()); + } + + @override + String toString() => "$usernameDafl ($idDafl)"; +} \ No newline at end of file diff --git a/Sources/dafl_project_flutter/lib/model/user_creator.dart b/Sources/dafl_project_flutter/lib/model/user_creator.dart new file mode 100644 index 0000000..07029e6 --- /dev/null +++ b/Sources/dafl_project_flutter/lib/model/user_creator.dart @@ -0,0 +1,8 @@ +import 'user.dart'; + +class UserCreator{ + + User? createUser(int id, String username){ + + } +} \ No newline at end of file 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 e2d6e3c..26a1614 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 @@ -15,35 +15,47 @@ class _ConversationPageState extends State { double height = MediaQuery.of(context).size.height; double width = MediaQuery.of(context).size.width; return Scaffold( + extendBodyBehindAppBar: true, resizeToAvoidBottomInset: true, - backgroundColor: Color(0xFF141414), appBar: AppBar( - toolbarHeight: 100, - title: Row( - children: [ - Container( - height: 60, - width: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(40), - color: Colors.blue, + flexibleSpace: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.black, Colors.transparent], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ) + + ), + ), + toolbarHeight: 70, + title: Container( + child: Row( + children: [ + Container( + padding: EdgeInsets.fromLTRB(0, 10, 0, 0), + height: 40, + width: 40, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(40), + color: Colors.blue, + ), ), - ), - SizedBox(width: 20,), - Text("Max"), + SizedBox(width: 20,), + Text("Max"), - ], + ], + ), ), - backgroundColor: Color(0xFF141414), + backgroundColor: Colors.transparent, elevation: 0, ), body: SingleChildScrollView( - child: Column( - children: [ + child: Container( color: Color(0xFF141414), - height: height*0.76, + height: height*0.92, width: double.infinity, child: ListView( scrollDirection: Axis.vertical, @@ -58,50 +70,58 @@ class _ConversationPageState extends State { ), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, + ), + bottomSheet: BottomAppBar( + color: Color(0xFF141414), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - height: height*0.08, + children: [ + Container( + height: height*0.08, + color: Colors.transparent, + width: width*0.8, + child: Container( + margin: EdgeInsets.fromLTRB(20, 10, 0, 10), + decoration: BoxDecoration( + border: Border.all( + width: 1, + color: Color(0xFF2F2F2F), + ), + borderRadius: BorderRadius.circular(100), color: Color(0xFF141414), - width: width*0.8, - child: Container( - margin: EdgeInsets.fromLTRB(20, 10, 0, 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100), - color: Colors.white, + ), + child: Padding( + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + child: TextField( + style: TextStyle(color: Colors.white), + decoration: InputDecoration( + hintStyle: TextStyle(color: Colors.white), + border: InputBorder.none, + hintText: "Envoyer un message...", ), - child: Padding( - padding: EdgeInsets.fromLTRB(10, 0, 10, 0), - child: TextField( - decoration: InputDecoration( - border: InputBorder.none, - hintText: "Envoyer un message..." - ), - cursorColor: Colors.purple, - textAlign: TextAlign.left, - ), - ), + cursorColor: Colors.purple, + textAlign: TextAlign.left, ), ), - Container( - width: 40, - height: 40, - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100), - color: Colors.blue, - ), - child: Icon(Icons.send, size: 20, color: Colors.white,), - ) - ], + ), ), + Container( + width: 40, + height: 40, + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + color: Colors.blue, + ), + child: Icon(Icons.send, size: 20, color: Colors.white,), + ) ], ), ), + ); } @@ -121,8 +141,8 @@ class _ConversationPageState extends State { color: Color(0xFF191919), ), child: Padding( - padding: EdgeInsets.fromLTRB(20, 20, 20, 20), - child: Text(message,style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 19, fontWeight: FontWeight.w400), + padding: EdgeInsets.fromLTRB(15, 15, 15, 15), + child: Text(message,style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 15, fontWeight: FontWeight.w400), )), ); } @@ -139,8 +159,8 @@ class _ConversationPageState extends State { color: Color(0xFF2F2F2F), ), child: Padding( - padding: EdgeInsets.fromLTRB(20, 20, 20, 20), - child: Text(message,style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 19, fontWeight: FontWeight.w400), + padding: EdgeInsets.fromLTRB(15, 15, 15, 15), + child: Text(message,style: TextStyle(fontFamily: 'DMSans', color: Colors.white ,fontSize: 15, fontWeight: FontWeight.w400), )), ); } 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 616f9b8..4a3244c 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 @@ -19,7 +19,7 @@ class _MainPageState extends State { int get index => _index; final screens = [ ProfilWidget(), - DiscoveryWidget(), + new DiscoveryWidget(), SpotsWidget(), Center(child: Text('Tops'),), MessagesWidget(), 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 e06afd6..94c2534 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 @@ -1,6 +1,11 @@ +import 'dart:math'; + +import 'package:dafl_project_flutter/main.dart'; import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:flutter/material.dart'; +import '../../../model/music.dart'; + class DiscoveryWidget extends StatefulWidget { const DiscoveryWidget({Key? key}) : super(key: key); @@ -16,11 +21,12 @@ class _DiscoveryWidgetState extends State { return Container( color: Color(0xFF141414), - child: Padding(padding: EdgeInsets.fromLTRB(30, 50, 30, 0), + child: Padding(padding: EdgeInsets.fromLTRB(0, 50, 0, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( + padding: EdgeInsets.fromLTRB(30, 0, 30, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -37,173 +43,89 @@ class _DiscoveryWidgetState extends State { ), ), Expanded( - child: ListView( - - children: [ - SizedBox(height: 40,), - Container( - margin: EdgeInsets.fromLTRB(0, 10, 0, 0), - child: Column( - children: [ - - Container( - margin: EdgeInsets.fromLTRB(0, 5, 0, 0), - width: double.infinity, - child: Row( - children: [ - Container( - height: 60, - width: 60, - decoration: BoxDecoration( - border: Border.all(width: 0, color: Colors.grey.withOpacity(0)), - 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'), - ),), - Container( - margin: EdgeInsets.fromLTRB(20, 0, 0, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text('IVERSON',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 20, fontWeight: FontWeight.w800),), - Text('Laylow',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(0.6) ,fontSize: 16, fontWeight: FontWeight.w400),), - - ], - ),), - ], - ), - ), - + child: DiscoveryList(), + ) + ], + ),), + ); + } +} - ], - ) - ), - Container( - margin: EdgeInsets.fromLTRB(0, 10, 0, 0), - child: Column( - children: [ - - Container( - margin: EdgeInsets.fromLTRB(0, 5, 0, 0), - width: double.infinity, - child: Row( - children: [ - Container( - height: 60, - width: 60, - decoration: BoxDecoration( - border: Border.all(width: 0, color: Colors.grey.withOpacity(0)), - 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'), - ),), - Container( - margin: EdgeInsets.fromLTRB(20, 0, 0, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text('IVERSON',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 20, fontWeight: FontWeight.w800),), - Text('Laylow',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(0.6) ,fontSize: 16, fontWeight: FontWeight.w400),), - - ], - ),), - ], - ), - ), +class DiscoveryList extends StatefulWidget { + const DiscoveryList({Key? key}) : super(key: key); + @override + State createState() => _DiscoveryListState(); +} - ], - ) - ), - Container( - margin: EdgeInsets.fromLTRB(0, 10, 0, 0), - child: Column( - children: [ - - Container( - margin: EdgeInsets.fromLTRB(0, 5, 0, 0), - width: double.infinity, - child: Row( - children: [ - Container( - height: 60, - width: 60, - decoration: BoxDecoration( - border: Border.all(width: 0, color: Colors.grey.withOpacity(0)), - 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'), - ),), - Container( - margin: EdgeInsets.fromLTRB(20, 0, 0, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text('IVERSON',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 20, fontWeight: FontWeight.w800),), - Text('Laylow',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(0.6) ,fontSize: 16, fontWeight: FontWeight.w400),), - - ], - ),), - ], - ), - ), +class _DiscoveryListState extends State { + late GlobalKey refreshKey; + @override + void initState() { + print('testttt'); + refreshKey = GlobalKey(); + refreshList(); + super.initState(); + } + Future refreshList() async { + await Future.delayed(Duration(seconds: 1)); + setState(() { + MyApp().controller.currentUser.Discovery; + print('test'); + }); + return null; + } + Widget build(BuildContext context) { + return RefreshIndicator(child: ListView.builder( + itemCount: MyApp().controller.currentUser.Discovery.length ?? 0, + itemBuilder: (context, index){ + int itemCount = MyApp().controller.currentUser.Discovery.length ?? 0; + int reversedIndex = itemCount - 1 - index; + return Container( + margin: EdgeInsets.fromLTRB(0, 10, 0, 0), + padding: EdgeInsets.fromLTRB(30, 0, 30, 0), + child: Column( + children: [ - ], - ) - ), Container( - margin: EdgeInsets.fromLTRB(0, 10, 0, 0), - child: Column( - children: [ - - Container( - margin: EdgeInsets.fromLTRB(0, 5, 0, 0), - width: double.infinity, - child: Row( - children: [ - Container( - height: 60, - width: 60, - decoration: BoxDecoration( - border: Border.all(width: 0, color: Colors.grey.withOpacity(0)), - 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'), - ),), - Container( - margin: EdgeInsets.fromLTRB(20, 0, 0, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text('IVERSON',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 20, fontWeight: FontWeight.w800),), - Text('Laylow',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(0.6) ,fontSize: 16, fontWeight: FontWeight.w400),), - - ], - ),), - ], - ), + margin: EdgeInsets.fromLTRB(0, 5, 0, 0), + width: double.infinity, + child: Row( + children: [ + Container( + height: 60, + width: 60, + decoration: BoxDecoration( + border: Border.all(width: 0, color: Colors.grey.withOpacity(0)), + 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'), + ),), + Container( + margin: EdgeInsets.fromLTRB(20, 0, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text(MyApp().controller.currentUser.Discovery[reversedIndex].name ?? '',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 20, fontWeight: FontWeight.w800),), + Text('Laylow',style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(0.6) ,fontSize: 16, fontWeight: FontWeight.w400),), + + ], + ),), + ], + ), ), ], - ), - ), - ], - ),), - ); + ) + + ); + } + ), onRefresh: () async { + refreshList(); + }, key: refreshKey,); } } 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 bec4151..8c18487 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,3 +1,5 @@ +import 'package:dafl_project_flutter/main.dart'; + import './w_settings.dart'; import './w_spot.dart'; import 'package:flutter/material.dart'; @@ -43,14 +45,32 @@ class MainPageProfil extends StatelessWidget { style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600, color: Colors.white),), ), Container( - margin: EdgeInsets.fromLTRB(0, 10, 0, 40), + margin: EdgeInsets.fromLTRB(0, 10, 0, 10), height: height*0.14, width: height*0.14, decoration: BoxDecoration( borderRadius: BorderRadius.circular(100.0), color: Colors.blue,border: Border.all(width: 6.0, color: Colors.white), + boxShadow: [ + BoxShadow( + offset: Offset(0, 0), + spreadRadius: 5, + blurRadius:10, + color: Color.fromRGBO(0, 0, 0, 1), + ), + ], ), + child: Center( + child: Text(MyApp().controller.currentUser?.usernameDafl![0] ?? '', + style: TextStyle(color: Colors.white ,fontSize: 60, fontWeight: FontWeight.w500), + textAlign: TextAlign.center, + ), + ), + ), + Text(MyApp().controller.currentUser?.usernameDafl ?? '', + style: TextStyle(color: Colors.white ,fontSize: 17, fontWeight: FontWeight.w400), + textAlign: TextAlign.center, ), Container( height: 55, @@ -59,7 +79,7 @@ class MainPageProfil extends StatelessWidget { borderRadius: BorderRadius.circular(10.0), color: Colors.transparent, ), - margin: EdgeInsets.fromLTRB(30, 0, 30, 0), + margin: EdgeInsets.fromLTRB(30, 40, 30, 0), child: SizedBox( height: 55, width: double.infinity, @@ -187,7 +207,7 @@ class MainPageProfil extends StatelessWidget { borderRadius: BorderRadius.circular(10.0), color: Colors.transparent, ), - margin: EdgeInsets.fromLTRB(30, 0, 30, height*0.04), + margin: EdgeInsets.fromLTRB(30, 0, 30,0), child: SizedBox( height: 55, width: double.infinity, @@ -215,6 +235,7 @@ class MainPageProfil extends StatelessWidget { ) ),), ), + Spacer(), ], ), ), diff --git a/Sources/dafl_project_flutter/lib/views/pages/main/w_settings.dart b/Sources/dafl_project_flutter/lib/views/pages/main/w_settings.dart index 40f2bc7..2717b96 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/main/w_settings.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/main/w_settings.dart @@ -1,4 +1,6 @@ +import 'package:dafl_project_flutter/main.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; class SettingsWidget extends StatefulWidget { const SettingsWidget({Key? key}) : super(key: key); @@ -8,6 +10,8 @@ class SettingsWidget extends StatefulWidget { } class _SettingsWidgetState extends State { + final userNameTextField = TextEditingController(text: MyApp().controller.currentUser?.usernameDafl); + final passwordTextField = TextEditingController(text: MyApp().controller.currentUser?.passwDafl); @override Widget build(BuildContext context) { double height = MediaQuery.of(context).size.height; @@ -54,6 +58,7 @@ class _SettingsWidgetState extends State { SizedBox( width: 230, child: TextField( + controller: userNameTextField, style: TextStyle(color: Colors.white), decoration: InputDecoration( hintStyle: Theme.of(context).textTheme.caption?.copyWith( @@ -67,9 +72,15 @@ class _SettingsWidgetState extends State { ), ), Spacer(), - Padding(padding: EdgeInsets.fromLTRB(0, 0, 20, 0), + GestureDetector( + onTap: () { + SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); + MyApp().controller.changeUsernameCourant(userNameTextField.text); + }, + child: Padding(padding: EdgeInsets.fromLTRB(0, 0, 20, 0), child: Text('modifier', - style: TextStyle( color: Colors.blue, fontSize: 17),),), + style: TextStyle( color: Colors.blue, fontSize: 17),),),) + ], ), @@ -100,6 +111,7 @@ class _SettingsWidgetState extends State { SizedBox( width: 230, child: TextField( + controller: passwordTextField, obscureText: true, style: TextStyle(color: Colors.white), decoration: InputDecoration( @@ -114,9 +126,13 @@ class _SettingsWidgetState extends State { ), ), Spacer(), - Padding(padding: EdgeInsets.fromLTRB(0, 0, 20, 0), - child: Text('modifier', - style: TextStyle( color: Colors.blue, fontSize: 17),),), + GestureDetector( + onTap: () { + }, + child: Padding(padding: EdgeInsets.fromLTRB(0, 0, 20, 0), + child: Text('modifier', + style: TextStyle( color: Colors.blue, fontSize: 17),),), + ), ], ), 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 a3f34ad..48ee24f 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 @@ -1,4 +1,7 @@ import 'dart:ui'; +import 'package:dafl_project_flutter/views/pages/main/w_discovery.dart'; + +import '../../../model/music.dart'; import './w_card.dart'; import 'package:flutter/material.dart'; import 'package:flutter/src/painting/gradient.dart' as gradiant; @@ -94,6 +97,7 @@ 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(); }, @@ -145,12 +149,12 @@ class _SpotsWidgetState extends State { IgnorePointer(child: Container(height: 200, decoration: BoxDecoration( gradient: gradiant.LinearGradient( - colors: [Colors.black, Colors.transparent], + colors: [Colors.black.withOpacity(0.95),Colors.black.withOpacity(0.84),Colors.black.withOpacity(0.66),Colors.black.withOpacity(0.41),Colors.black.withOpacity(0)], begin: Alignment.topCenter, end: Alignment.bottomCenter, ) - ),),), + ),),), Padding(padding: EdgeInsets.fromLTRB(20, 60, 0, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/Sources/dafl_project_flutter/lib/views/pages/sign_in/p_sign_in.dart b/Sources/dafl_project_flutter/lib/views/pages/sign_in/p_sign_in.dart index 78fac5e..d646b4d 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/sign_in/p_sign_in.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/sign_in/p_sign_in.dart @@ -16,6 +16,8 @@ class _SignInPageState extends State { @override bool isChecked = false; + final userNameTextField = TextEditingController(); + final passwordTextField = TextEditingController(); Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, @@ -68,6 +70,7 @@ class _SignInPageState extends State { ), Padding(padding: EdgeInsets.fromLTRB(50, 0, 20, 0), child: TextField( + controller: userNameTextField, decoration: InputDecoration( border: InputBorder.none, ), @@ -111,6 +114,7 @@ class _SignInPageState extends State { ),Padding(padding: EdgeInsets.fromLTRB(50, 0, 20, 0), child: TextField( + controller: passwordTextField, obscureText: true, decoration: InputDecoration( border: InputBorder.none, @@ -165,12 +169,18 @@ class _SignInPageState extends State { highlightColor: Colors.grey.shade100, splashColor: Color(0xFF406DE1), onTap: (){ - Navigator.of(context).push( - PageTransition( - type: PageTransitionType.fade, - childCurrent: widget, - child: Splash()), - ); + if(passwordTextField.text != "" && userNameTextField.text != ""){ + MyApp().controller.changeCurrentUser(MyApp().controller.createUser(userNameTextField.text, passwordTextField.text)); + Navigator.of(context).push( + PageTransition( + type: PageTransitionType.fade, + childCurrent: widget, + child: Splash()), + ); + } + else{ + print('probleme connexion'); + } }, child:Ink( child: Align( diff --git a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart index 276bd32..152a11b 100644 --- a/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart +++ b/Sources/dafl_project_flutter/lib/views/pages/sign_up/p_sign_up.dart @@ -1,7 +1,9 @@ +import 'package:dafl_project_flutter/main.dart'; import 'package:flutter/material.dart'; import 'package:page_transition/page_transition.dart'; import '../home/p_home.dart'; import '../sign_in/p_sign_in.dart'; +import '../../../controller/controller.dart'; class SignUpPage extends StatefulWidget { const SignUpPage({Key? key}) : super(key: key); @@ -15,8 +17,10 @@ class _SignUpPageState extends State { Color boxColor = Colors.white; bool isHovering = false; @override - TextEditingController passwordconfirm = new TextEditingController(); bool isChecked = false; + final userNameTextField = TextEditingController(); + final passwordTextField = TextEditingController(); + final passwordConfirmTextField = TextEditingController(); Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, @@ -69,6 +73,7 @@ class _SignUpPageState extends State { ), Padding(padding: EdgeInsets.fromLTRB(50, 0, 20, 0), child: TextField( + controller: userNameTextField, decoration: InputDecoration( border: InputBorder.none, ), @@ -112,6 +117,7 @@ class _SignUpPageState extends State { ),Padding(padding: EdgeInsets.fromLTRB(50, 0, 20, 0), child: TextField( + controller: passwordTextField, obscureText: true, decoration: InputDecoration( border: InputBorder.none, @@ -157,7 +163,7 @@ class _SignUpPageState extends State { ),Padding(padding: EdgeInsets.fromLTRB(50, 0, 20, 0), child: TextField( obscureText: true, - controller: passwordconfirm, + controller: passwordConfirmTextField, decoration: InputDecoration( border: InputBorder.none, ), @@ -231,17 +237,20 @@ class _SignUpPageState extends State { highlightColor: Colors.grey.shade100, splashColor: Color(0xFF406DE1), onTap: (){ - setState(() { - boxColor = Colors.blue; - }); - Navigator.of(context).push( + if(passwordConfirmTextField.text == passwordTextField.text && userNameTextField.text != null){ + MyApp().controller.createUser(userNameTextField.text, passwordConfirmTextField.text); + Navigator.of(context).push( PageTransition( - duration: Duration(milliseconds: 300), - reverseDuration: Duration(milliseconds: 300), - type: PageTransitionType.leftToRightJoined, - childCurrent: widget, - child: HomePage()), - ); + duration: Duration(milliseconds: 300), + reverseDuration: Duration(milliseconds: 300), + type: PageTransitionType.leftToRightJoined, + childCurrent: widget, + child: HomePage()),); + } + else{ + print('Null'); + } + }, child:Ink( child: Align(