diff --git a/flutter/lib/Screens/Index/components/Messager.dart b/flutter/lib/Screens/Index/components/Messager.dart new file mode 100644 index 0000000000000000000000000000000000000000..cfaa5e5bacf1bb0e1f1eed37ff4fe65726af8d6b --- /dev/null +++ b/flutter/lib/Screens/Index/components/Messager.dart @@ -0,0 +1,250 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:flutter_auth/Screens/Index/components/background.dart'; +import 'package:http/http.dart' as http; +import 'package:flutter_auth/components/rounded_button.dart'; +import 'package:flutter_auth/components/rounded_input_field.dart'; + +import 'package:flutter_auth/Screens/Model/message.dart'; +import 'package:flutter_auth/Screens/Model/room.dart'; +import 'package:flutter_auth/Screens/Login/components/body.dart' as log; +import'package:flutter_auth/Screens/staticvar.dart' as staticvar; + +//http://localhost:3000/messages +class Messager extends StatefulWidget { + MessagerState createState() { + return new MessagerState(); + } + } + class MessagerState extends State<Messager>{ + String message; + String userAdd; + final fieldText = TextEditingController(); + + void clearText() { + fieldText.clear(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body : + Background(child: + SingleChildScrollView(child : Column( + mainAxisAlignment: MainAxisAlignment.center, + children: <Widget>[ + Container( + height: MediaQuery.of(context).size.height-100, + width: MediaQuery.of(context).size.width, + child: + + FutureBuilder<List<Messages>>( + future: _fetchMessage(), + builder: (context, snapshot) { + if (snapshot.hasData) { + + List<Messages> data = snapshot.data; + return _MessagesListView(data); + } else if (snapshot.hasError) { + return Text("${snapshot.error}"); + } + return CircularProgressIndicator(); + }, + )), + Container( + color: Colors.deepPurpleAccent, + height : 100, + width: MediaQuery.of(context).size.width, + child : Row( + mainAxisAlignment: MainAxisAlignment.center, + children: <Widget>[ + Container( + width: MediaQuery.of(context).size.width - 100, + child: TextField( + decoration: InputDecoration( + hintText: "message", + ), + controller: fieldText, + onChanged: (value) { + this.message = value; + }, + ), + ), + Column( + children: <Widget>[ + IconButton( + icon:const Icon(Icons.send), + onPressed: () { + sendMessage(this.message); + clearText(); + + this.setState(() { + + }); + + } + ), + + IconButton( + icon:const Icon(Icons.add), + onPressed: () { + showDialog(context: context, builder: (BuildContext context){ + return AlertDialog( + content: Form( + child: Column( + children: [RoundedInputField( + hintText: "username", + onChanged: (value) { + this.userAdd = value; + // this.userAdd.add("60cdd40349b0620034df5a4a"); + }, + ), + RoundedButton( + text: "add user", + press: () async { + + var res = await addUser(this.userAdd); + print(res); + print(staticvar.response[staticvar.selectedroom]["_id"]); + if(res == 200) { + setState(() { + print(res); + }); + } + }, + ), + ]))); + }); + + }), + ]), + + ] + ), + ), + ]), + ), + )); + } + + Future<int> sendMessage(message) async { + String token = staticvar.token ; + final http.Response response = await http.post( + 'http://163.172.178.146:3000/messages', + + headers: <String, String>{ + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Bearer $token', + }, + body: jsonEncode(<String, String>{ + 'body': message, + 'roomId' : staticvar.response[staticvar.selectedroom]["_id"], + }), + ); + return response.statusCode; + + } + + + + + Future<int> addUser(user) async { + String token = staticvar.token ; + final http.Response response = await http.put("http://163.172.178.146:3000/rooms/"+ staticvar.response[staticvar.selectedroom]["_id"], + + headers: <String, String>{ + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Bearer $token', + }, + body: jsonEncode(<String, dynamic>{ + "users" : [staticvar.loggedUser['id'], user], + "name" : staticvar.response[staticvar.selectedroom]["name"], + "description":staticvar.response[staticvar.selectedroom]["description"], + + + }), + ); + return response.statusCode; + + } + + + +//http://163.172.178.146:3000/rooms + Future<List<Messages>> _fetchMessage() async { + final MessagesListAPIUrl = "http://163.172.178.146:3000/rooms/" + staticvar.response[staticvar.selectedroom]["_id"] + "/messages" ; + String token = staticvar.token ; + final response = await http.get(MessagesListAPIUrl, + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Bearer $token', + + }); + print("message"); + print(response.statusCode ); + + if (response.statusCode == 200) { + List jsonResponse = json.decode(response.body); + // print(jsonResponse); + return jsonResponse.map((data) => new Messages.fromJson(data)).toList(); + } else { + throw Exception('Failed to load message from API'); + } + } + + ListView _MessagesListView(data) { + return ListView.builder( + shrinkWrap: true, + itemCount: data.length, + itemBuilder: (context, index) => new Column( + children: <Widget>[ + new Divider( + height: 10.0, + ), + new ListTile( + leading: new CircleAvatar( + foregroundColor: Theme.of(context).primaryColor, + backgroundColor: Colors.grey, + // backgroundImage: new NetworkImage(dummyData[i].avatarUrl), + ), + + + title: new Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: <Widget>[ + new Text( + data[index].author["username"], + style: new TextStyle(fontWeight: FontWeight.bold), + ), + new Text( + data[index].date, + style: new TextStyle(color: Colors.grey, fontSize: 14.0), + ), + ], + ), + subtitle: new Container( + padding: const EdgeInsets.only(top: 5.0), + child: new Text( + data[index].body, + style: new TextStyle(color: Colors.grey, fontSize: 15.0), + ), + ), + ) + + ], + ), + + + + + + ); + } + +} + diff --git a/flutter/lib/Screens/Index/components/Profil.dart b/flutter/lib/Screens/Index/components/Profil.dart index ee5ea18cef341943714e08ce38c9769e3dd33e5d..7416e29a72ba8285c3d72f680b21a18dbed077c3 100644 --- a/flutter/lib/Screens/Index/components/Profil.dart +++ b/flutter/lib/Screens/Index/components/Profil.dart @@ -20,7 +20,7 @@ class Profil extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( - "Modifier votre profil " + staticvar.username, + "Modifiez votre profil " + staticvar.loggedUser['username'], style: TextStyle(fontWeight: FontWeight.bold), ), ], diff --git a/flutter/lib/Screens/Index/components/RoomContainer.dart b/flutter/lib/Screens/Index/components/RoomContainer.dart new file mode 100644 index 0000000000000000000000000000000000000000..169e1c13c96e959a3e823cc3960398b3eb0b894c --- /dev/null +++ b/flutter/lib/Screens/Index/components/RoomContainer.dart @@ -0,0 +1,141 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:flutter_auth/components/rounded_button.dart'; + +import 'package:flutter_auth/Screens/Model/message.dart'; +import 'package:flutter_auth/Screens/Model/room.dart'; +import 'package:flutter_auth/Screens/Login/components/body.dart' as log; +import'package:flutter_auth/Screens/staticvar.dart' as staticvar; +import 'package:flutter_auth/Screens/Index/components/chat.dart'; +import 'package:flutter_auth/components/rounded_input_field.dart'; + +//http://localhost:3000/messages +class RoomContainer extends StatefulWidget { + RoomContainerState createState() { + return new RoomContainerState(); + } +} +class RoomContainerState extends State<RoomContainer> { + + String RoomName; + String RoomDesc; + int code; + String popuptext; + @override + Widget build(BuildContext context) { + return new Container( + child : Column(children: <Widget>[ + + IconButton( + icon:const Icon(Icons.add), + onPressed: (){ + showDialog(context: context, builder: (BuildContext context){ + return AlertDialog( + content: Form( + child: Column( + children: [ + RoundedInputField( + hintText: "name", + onChanged: (value) { + this.RoomName = value; + }, + + ), + RoundedInputField( + hintText: "description", + onChanged: (value) { + this.RoomDesc = value; + }, + + ), + RoundedButton( + text: "create", + press: () async { + var res = await createRoom( this.RoomDesc, this.RoomName); + if(res == 200) { + Navigator.pop(context); + setState(() { + }); + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) { + // if (true) { + // return RoomContainer(); + // } + // }, + // ), + // ); + } + + + }, + ), + ], + ), + + ), + ); + + }); + + + }, + ), + Expanded(child:MessagesListView() ) + , + ])); + + } + + + //'http://10.0.2.2:3000/rooms', + Future<int> createRoom(desc,name) async { + String token = staticvar.token ; + final http.Response response = await http.post( + 'http://163.172.178.146:3000/rooms', + + headers: <String, String>{ + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Bearer $token', + }, + body: jsonEncode(<String, String>{ + 'name': name, + 'description': desc, + }), + ); + return response.statusCode; + + } + Widget _buildPopupDialogUserAlreadyRegistered(BuildContext context) { + return new AlertDialog( + title: const Text('Alerte'), + content: new Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: <Widget>[ + Text(this.popuptext), + ], + ), + actions: <Widget>[ + new FlatButton( + onPressed: () { + Navigator.of(context).pop(); + }, + textColor: Theme.of(context).primaryColor, + child: const Text('Close'), + ), + ], + ); + } + + + + + +} + diff --git a/flutter/lib/Screens/Index/components/TabBarDemo.dart b/flutter/lib/Screens/Index/components/TabBarDemo.dart index 8bc95afa4575844a421b288d78fe7a8eeebfdbce..4638201e94d569ebdd1650efed6bc5555b1c0f39 100644 --- a/flutter/lib/Screens/Index/components/TabBarDemo.dart +++ b/flutter/lib/Screens/Index/components/TabBarDemo.dart @@ -3,6 +3,9 @@ import 'package:flutter_auth/Screens/Index/components/background.dart'; import 'package:flutter_auth/Screens/Index/components/body.dart'; import 'package:flutter_auth/Screens/Index/components/Profil.dart'; import 'package:flutter_auth/Screens/Index/components/chat.dart'; +import 'package:flutter_auth/Screens/Index/components/RoomContainer.dart'; +import 'package:flutter_auth/Screens/Model/room.dart'; +import 'package:flutter_auth/Screens/Index/components/Messager.dart'; class TabBarDemo extends StatelessWidget { @override @@ -17,6 +20,7 @@ class TabBarDemo extends StatelessWidget { Tab(text: "Accueil"), Tab(text: "Message"), Tab(text: "Profil"), + ], ), title: Text('Se Déconnecter'), @@ -24,7 +28,7 @@ class TabBarDemo extends StatelessWidget { body: TabBarView( children: [ Body(), - MessagesListView(), + RoomContainer(), Profil(), ], ), diff --git a/flutter/lib/Screens/Index/components/body.dart b/flutter/lib/Screens/Index/components/body.dart index a42ccca425eb1fbe1aaf1d248d419cd20927bac4..583a66888c9b397ee0795134bbd7a4b12ef76010 100644 --- a/flutter/lib/Screens/Index/components/body.dart +++ b/flutter/lib/Screens/Index/components/body.dart @@ -20,7 +20,7 @@ class Body extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( - "Bienvenue sur la page d'accueil de l'application " + staticvar.username, + "Bienvenue sur la page d'accueil de l'application " + staticvar.loggedUser['username'], style: TextStyle(fontWeight: FontWeight.bold), ), diff --git a/flutter/lib/Screens/Index/components/chat.dart b/flutter/lib/Screens/Index/components/chat.dart index bc6d5e63df91c802ed0b05bd76881570e35ba0b3..26baaecec3c27dad5ca2259370cdc72d56987c44 100644 --- a/flutter/lib/Screens/Index/components/chat.dart +++ b/flutter/lib/Screens/Index/components/chat.dart @@ -3,21 +3,34 @@ import 'dart:convert'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; - +import 'package:flutter_auth/components/rounded_button.dart'; +import 'package:flutter_auth/Screens/Login/login_screen.dart'; +import 'package:flutter_auth/Screens/Index/components/Messager.dart'; import 'package:flutter_auth/Screens/Model/message.dart'; +import 'package:flutter_auth/Screens/Model/room.dart'; import 'package:flutter_auth/Screens/Login/components/body.dart' as log; import'package:flutter_auth/Screens/staticvar.dart' as staticvar; +//http://localhost:3000/messages +class MessagesListView extends StatefulWidget { + MessagesListViewState createState() { + return new MessagesListViewState(); + } +} +class MessagesListViewState extends State<MessagesListView> { + // List response ; + // int selected; + + Map<String, dynamic> room; + // Map<String, dynamic> use = (json.decode(response.body)["user"]); -class MessagesListView extends StatelessWidget { @override Widget build(BuildContext context) { - return FutureBuilder<List<Messages>>( - future: _fetchMessages(), + return FutureBuilder<List<Room>>( + future: _fetchRoom(), builder: (context, snapshot) { if (snapshot.hasData) { - - List<Messages> data = snapshot.data; + List<Room> data = snapshot.data; return _MessagesListView(data); } else if (snapshot.hasError) { return Text("${snapshot.error}"); @@ -26,9 +39,25 @@ class MessagesListView extends StatelessWidget { }, ); } + Future<int> deleteRoom(select) async { + String token = staticvar.token ; + final http.Response response = await http.delete( + 'http://163.172.178.146:3000/rooms/' + staticvar.response[select]["_id"], - Future<List<Messages>> _fetchMessages() async { - final MessagesListAPIUrl = "http://10.0.2.2:3000/rooms"; + headers: <String, String>{ + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': 'Bearer $token', + }, + + ); + return response.statusCode; + + } + +//http://163.172.178.146:3000/rooms + Future<List<Room>> _fetchRoom() async { + final MessagesListAPIUrl = "http://163.172.178.146:3000/rooms"; String token = staticvar.token ; final response = await http.get(MessagesListAPIUrl, headers: { @@ -41,7 +70,15 @@ class MessagesListView extends StatelessWidget { if (response.statusCode == 200) { List jsonResponse = json.decode(response.body); - return jsonResponse.map((data) => new Messages.fromJson(data)).toList(); + staticvar.response = jsonResponse; + print(jsonResponse); + + //print(jsonResponse[0]["_id"]); + + + //print(json.decode(response.body)); + + return jsonResponse.map((data) => new Room.fromJson(data)).toList(); } else { throw Exception('Failed to load message from API'); } @@ -49,47 +86,69 @@ class MessagesListView extends StatelessWidget { ListView _MessagesListView(data) { return ListView.builder( - itemCount: data.length, - itemBuilder: (context, index) => new Column( - children: <Widget>[ - new Divider( - height: 10.0, - ), - new ListTile( - leading: new CircleAvatar( - foregroundColor: Theme.of(context).primaryColor, - backgroundColor: Colors.grey, - // backgroundImage: new NetworkImage(dummyData[i].avatarUrl), - ), - title: new Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: <Widget>[ - new Text( - data[index].author, - style: new TextStyle(fontWeight: FontWeight.bold), - ), - new Text( - data[index].date, - style: new TextStyle(color: Colors.grey, fontSize: 14.0), - ), - ], - ), - subtitle: new Container( - padding: const EdgeInsets.only(top: 5.0), - child: new Text( - data[index].message, - style: new TextStyle(color: Colors.grey, fontSize: 15.0), - ), - ), - ) - ], - ), + itemCount: data.length, + itemBuilder: (context, i) => new Column(children: <Widget>[ + + Ink( + child: InkWell( + child: Container( + + child: Row(children: <Widget>[ + Expanded( + child: + new ListTile( + leading: new CircleAvatar( + foregroundColor: Theme.of(context).primaryColor, + backgroundColor: Colors.grey, + // backgroundImage: new NetworkImage(dummyData[i].avatarUrl), + ), + title: new Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: <Widget>[ + Expanded(child: + new Text( + data[i].name, + style: new TextStyle(fontWeight: FontWeight.bold), + ), + ), + ], + ), + subtitle: new Container( + padding: const EdgeInsets.only(top: 5.0), + child: new Text( + data[i].description, + style: new TextStyle(color: Colors.grey, fontSize: 15.0), + ), + ), + ), + ), + IconButton( + icon:const Icon(Icons.delete ), + onPressed: () { - ); + deleteRoom(i); + this.setState(() { + + }); + + } + ), + ]), + ), + onTap: () { + print(i); + staticvar.selectedroom = i; + + Navigator.pushNamed(context, '/messages'); + + }), + ), + ]), + ); } } diff --git a/flutter/lib/Screens/Index/models/chat_model.dart b/flutter/lib/Screens/Index/models/chat_model.dart index 8bcd5db2732b632843cc070629e26b44f248572b..27539186e0a4614e2261f67bc3353a625980214d 100644 --- a/flutter/lib/Screens/Index/models/chat_model.dart +++ b/flutter/lib/Screens/Index/models/chat_model.dart @@ -1,4 +1,3 @@ -import 'package:http/http.dart' as http; class ChatModel { final String name; @@ -8,18 +7,9 @@ class ChatModel { ChatModel(this.name, this.message, this.time, this.avatarUrl); - factory ChatModel.fromMap(Map<String, dynamic> json) { - return ChatModel(json['name'], json['message'], json['time'], json['avatarUrl']); - } - factory ChatModel.fromJson(Map<String, dynamic> json) { - return ChatModel(json['id'], json['title'], json['imgUrl'], json['quantity']); - } } -String url = "http://localhost:19080/messages"; -Future<List<ChatModel>> fetchFruit() async { - final response = await http.get(url); -} + List<ChatModel> dummyData = [ new ChatModel("Pawan Kumar", "Hey Fluttezer, " "You are so amazing !", diff --git a/flutter/lib/Screens/Login/components/body.dart b/flutter/lib/Screens/Login/components/body.dart index d2e51d984c8b2e8a37927afb6509624b630325fe..d81e6febb5722e4a35b39a9251afa7e7d562e653 100644 --- a/flutter/lib/Screens/Login/components/body.dart +++ b/flutter/lib/Screens/Login/components/body.dart @@ -28,6 +28,13 @@ class Body extends StatelessWidget { int code = 0; String popuptext; String token; + final fieldText = TextEditingController(); + final fieldTextPass = TextEditingController(); + void clearText() { + fieldText.clear(); + fieldTextPass.clear(); + } + @override Widget build(BuildContext context) { @@ -38,31 +45,46 @@ class Body extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( - "Login", + "Authentification", style: TextStyle(fontWeight: FontWeight.bold), ), SizedBox(height: size.height * 0.03), SizedBox(height: size.height * 0.03), - RoundedInputField( - hintText: "Your username", - onChanged: (value) { - this.username = value; - }, + Container( + width: MediaQuery.of(context).size.width - 100, + child: TextField( + decoration: InputDecoration( + hintText: "Nom d'utilisateur", + ), + controller: fieldText, + onChanged: (value) { + this.username = value; + }, + ), ), - RoundedPasswordField( - onChanged: (value) { - this.password = value; - }, + Container( + width: MediaQuery.of(context).size.width - 100, + child: TextField( + obscureText: true, + decoration: InputDecoration( + hintText: "Mot de passe", + ), + controller: fieldTextPass, + onChanged: (value) { + this.password = value; + }, + ), ), + RoundedButton( - text: "LOGIN", + text: "Se connecter", press: () async { var jwt = await loguser(this.username, this.password); if(jwt != null){ - staticvar.username = this.username; storage.write(key:"jwt", value: json.decode(jwt)["token"]); - print(json.decode(jwt)["token"]); + clearText(); + //print(json.decode(jwt)["token"]); Navigator.push( context, MaterialPageRoute( @@ -128,10 +150,10 @@ class Body extends StatelessWidget { ], ); } - +//http://163.172.178.146:3000/users/login Future<String> loguser(String username, String password) async { final http.Response response = await http.post( - 'http://10.0.2.2:3000/users/login', + 'http://163.172.178.146:3000/users/login', headers: <String, String>{ 'Content-Type': 'application/json; charset=UTF-8', }, @@ -143,6 +165,11 @@ class Body extends StatelessWidget { if (response.statusCode == 200) { this.code = response.statusCode; staticvar.token = json.decode(response.body)["token"]; + Map<String, dynamic> use = (json.decode(response.body)["user"]); + staticvar.loggedUser = use; + print(staticvar.loggedUser['id']); + // print(json.decode(response.body)); + staticvar.body = response.body; return response.body; diff --git a/flutter/lib/Screens/Model/message.dart b/flutter/lib/Screens/Model/message.dart index 49db8af3e348672162ffc0f217f16dc7b9038c5b..726138093b3f672f52f7eda09a83fa3186e48ebb 100644 --- a/flutter/lib/Screens/Model/message.dart +++ b/flutter/lib/Screens/Model/message.dart @@ -1,20 +1,21 @@ import 'dart:async'; import 'dart:convert'; import 'package:http/http.dart' as http; +import 'package:flutter_auth/Screens/Model/user.dart'; class Messages { - final String id; - final String author; - final String message; + // final String room; + final Map<String, dynamic> author; + final String body; final String date; - Messages({this.id, this.author, this.message, this.date}); + Messages({ this.author,this.body, this.date}); factory Messages.fromJson(Map<String, dynamic> json) { return Messages( - id: json['_id'], - author: json['author'], - message: json['message'], + // room: json['room'], + author: json['author'], + body: json['body'], date: json['date'], ); } diff --git a/flutter/lib/Screens/Model/room.dart b/flutter/lib/Screens/Model/room.dart index dde7494bcd83e39e3ef41b6af59e76cea359dace..226b3001fe8b335923c108e64f0891fc125e66f1 100644 --- a/flutter/lib/Screens/Model/room.dart +++ b/flutter/lib/Screens/Model/room.dart @@ -6,7 +6,7 @@ import 'package:flutter_auth/Screens/Model/user.dart'; class Room { final String name; final String description; - final List<User> users ; + final List users ; final User createdby; Room({this.name, this.description, this.users, this.createdby}); diff --git a/flutter/lib/Screens/Signup/components/body.dart b/flutter/lib/Screens/Signup/components/body.dart index 1a15f61fada7972bac44f9c7beb3082df1f60df0..853bce48fbe0a6f4be1385511588403f378e57f3 100644 --- a/flutter/lib/Screens/Signup/components/body.dart +++ b/flutter/lib/Screens/Signup/components/body.dart @@ -23,7 +23,15 @@ class Body extends StatelessWidget { String confirm; int code; String popuptext; - + final fieldText = TextEditingController(); + final fieldTextPass = TextEditingController(); + final fieldTextPassConfirm = TextEditingController(); + + void clearText() { + fieldText.clear(); + fieldTextPass.clear(); + fieldTextPassConfirm.clear(); + } @override @@ -37,34 +45,55 @@ class Body extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( - "Signup", + "Inscription", style: TextStyle(fontWeight: FontWeight.bold), ), SizedBox(height: size.height * 0.03), - - RoundedInputField( - hintText: "Your Login", - onChanged: (value) { - this.username = value; - }, - - ), - RoundedPasswordField( - onChanged: (value) { - this.password = value; - }, + Container( + width: MediaQuery.of(context).size.width - 100, + child: TextField( + decoration: InputDecoration( + hintText: "Nom d'utilisateur", + ), + controller: fieldText, + onChanged: (value) { + this.username = value; + }, + ), ), - RoundedPasswordField( - onChanged: (value) { - this.confirm = value; - }, + Container( + width: MediaQuery.of(context).size.width - 100, + child: TextField( + obscureText: true, + decoration: InputDecoration( + hintText: "Mot de passe", + ), + controller: fieldTextPass, + onChanged: (value) { + this.password = value; + }, + ), + ), + Container( + width: MediaQuery.of(context).size.width - 100, + child: TextField( + obscureText: true, + decoration: InputDecoration( + hintText: "Répétez le mot de passe", + ), + controller: fieldTextPassConfirm, + onChanged: (value) { + this.confirm = value; + }, + ), ), RoundedButton( - text: "SIGNUP", + text: "S'inscrire", press: () async { var res = await createUser(this.username, this.password, this.confirm); if(res == 200) { + clearText(); Navigator.push( context, MaterialPageRoute( @@ -153,11 +182,12 @@ class Body extends StatelessWidget { ], ); } - +//http://163.172.178.146:3000/users/ Future<int> createUser(String username, String password, String confirm) async { final http.Response response = await http.post( - 'http://10.0.2.2:3000/users/', + 'http://163.172.178.146:3000/users/', + headers: <String, String>{ 'Content-Type': 'application/json; charset=UTF-8', }, diff --git a/flutter/lib/Screens/staticvar.dart b/flutter/lib/Screens/staticvar.dart index c98bd08c27f1eb2dfb2ca04e32d53c3ce9f038cd..42a6b2f7fd848fb34ed85757f4465f46898e887f 100644 --- a/flutter/lib/Screens/staticvar.dart +++ b/flutter/lib/Screens/staticvar.dart @@ -1,6 +1,9 @@ import 'package:flutter/material.dart'; +import 'package:flutter_auth/Screens/Model/user.dart'; bool connected = false; String token = null; -String username = null; -String body = null; \ No newline at end of file +String body = null; +int selectedroom = null; +List response = null; +Map<String, dynamic> loggedUser = null; \ No newline at end of file diff --git a/flutter/lib/main.dart b/flutter/lib/main.dart index 0064d58e801a111aaddc056b71e4929277202286..b8316bcee46f4beadaa268920e7591d0377053e0 100644 --- a/flutter/lib/main.dart +++ b/flutter/lib/main.dart @@ -1,10 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_auth/Screens/Welcome/welcome_screen.dart'; import 'package:flutter_auth/constants.dart'; +import 'package:flutter_auth/Screens/Index/components/Messager.dart'; void main() => runApp(MyApp()); -class MyApp extends StatelessWidget { +class MyApp extends StatefulWidget { + @override + _MyAppState createState() => _MyAppState(); +} +class _MyAppState extends State<MyApp> { // This widget is the root of your application. @override Widget build(BuildContext context) { @@ -14,8 +19,13 @@ class MyApp extends StatelessWidget { theme: ThemeData( primaryColor: kPrimaryColor, scaffoldBackgroundColor: Colors.white, + ), home: WelcomeScreen(), + initialRoute: '/', + routes : { + '/messages': (context) => Messager(), + } ); } } diff --git a/flutter/pubspec.lock b/flutter/pubspec.lock index 2770c632a94ce1b37a6939ba7882ade42c79c42b..c1ca39b60f89d89d4e4ad701a0976c3436022d45 100644 --- a/flutter/pubspec.lock +++ b/flutter/pubspec.lock @@ -7,49 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -63,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -82,7 +75,7 @@ packages: name: flutter_svg url: "https://pub.dartlang.org" source: hosted - version: "0.19.2+1" + version: "0.20.0-nullsafety.3" flutter_test: dependency: "direct dev" description: flutter @@ -108,35 +101,35 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" path_drawing: dependency: transitive description: name: path_drawing url: "https://pub.dartlang.org" source: hosted - version: "0.4.1+1" + version: "0.5.0" path_parsing: dependency: transitive description: name: path_parsing url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.2.0" pedantic: dependency: transitive description: @@ -150,7 +143,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "4.1.0" sky_engine: dependency: transitive description: flutter @@ -162,63 +155,63 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted - version: "4.5.1" + version: "5.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" - flutter: ">=1.24.0-6.0.pre <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.24.0-7.0" diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index bca132d2654b4a9705c81c778b727234eb0b4599..5bbad37d82fa021eeefc8edfbc21516c3fec5ea3 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 - flutter_svg: ^0.19.1 + flutter_svg: ^0.20.0-nullsafety.3 http: ^0.12.2 flutter_secure_storage: ^3.3.5