diff --git a/lib/main.dart b/lib/main.dart index 00ac518..70704b9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,16 +1,32 @@ -import 'package:astronote_app/screens/sign_in_screen.dart'; +import 'package:astronote_app/screens/company_choice_screen.dart'; +import 'package:astronote_app/screens/dashboard_screen.dart'; +import 'package:astronote_app/screens/log_in_screen.dart'; +import 'package:astronote_app/providers/log_in.dart'; +import 'package:astronote_app/theme/style.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( - theme: ThemeData( - fontFamily: 'Varela Round', - ), - home: LoginScreen() + return MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: LogIn()), + ], + child: Consumer( + builder:(context, logIn, _) => MaterialApp( + debugShowCheckedModeBanner: false, + theme: appTheme(), + home: logIn.isLog ? CompanyChoiceScreen() : LogInScreen(), + routes: { + "/logInScreen": (context) => LogInScreen(), + "/companyChoiceScreen": (context) => CompanyChoiceScreen(), + "/dashboardScreen": (context) => DashBoardScreen() + }, + ), + ), ); } } diff --git a/lib/models/companie.dart b/lib/models/companie.dart new file mode 100644 index 0000000..f99b079 --- /dev/null +++ b/lib/models/companie.dart @@ -0,0 +1,23 @@ +class Companie { + int id; + String name; + + Companie({this.id, this.name}); + + Companie.fromJson(Map json) { + id = json['id']; + name = json['name']; + } + +// Map toJson() { +// final Map data = new Map(); +// data['id'] = this.id; +// data['name'] = this.name; +// return data; +// } + + @override + String toString() { + return 'Companie{name: $name}'; + } +} \ No newline at end of file diff --git a/lib/models/companies.dart b/lib/models/companies.dart deleted file mode 100644 index 413e489..0000000 --- a/lib/models/companies.dart +++ /dev/null @@ -1,18 +0,0 @@ -class Companies { - int id; - String name; - - Companies({this.id, this.name}); - - Companies.fromJson(Map json) { - id = json['id']; - name = json['name']; - } - - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['name'] = this.name; - return data; - } -} \ No newline at end of file diff --git a/lib/models/credential.dart b/lib/models/credential.dart new file mode 100644 index 0000000..ac61384 --- /dev/null +++ b/lib/models/credential.dart @@ -0,0 +1,15 @@ +import 'package:flutter/foundation.dart'; + +class Credential { + int userId; + String url; + String login; + String password; + + Credential({this.url,this.login,this.password,this.userId}); + + @override + String toString() { + return 'UserLogIn{url: $url, login: $login}'; + } +} \ No newline at end of file diff --git a/lib/models/datas.dart b/lib/models/datas.dart deleted file mode 100644 index b8608d3..0000000 --- a/lib/models/datas.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:astronote_app/models/companies.dart'; - -class Datas { - String lastname; - List companies; - String firstname; - String civilite; - - Datas({this.lastname, this.companies, this.firstname, this.civilite}); - - Datas.fromJson(Map json) { - lastname = json['lastname']; - if (json['companies'] != null) { - companies = new List(); - json['companies'].forEach((v) { - companies.add(new Companies.fromJson(v)); - }); - } - firstname = json['firstname']; - civilite = json['civilite']; - } - - Map toJson() { - final Map data = new Map(); - data['lastname'] = this.lastname; - if (this.companies != null) { - data['companies'] = this.companies.map((v) => v.toJson()).toList(); - } - data['firstname'] = this.firstname; - data['civilite'] = this.civilite; - return data; - } -} \ No newline at end of file diff --git a/lib/models/sign_in_api.dart b/lib/models/sign_in_api.dart deleted file mode 100644 index 594a07b..0000000 --- a/lib/models/sign_in_api.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:astronote_app/models/datas.dart'; - -class Api { - String status; - String api; - String id; - Datas datas; - - Api ({this.status, this.api, this.id, this.datas}); - - Api.fromJson(Map json) { - status = json['status']; - api = json['api']; - id = json['id']; - datas = json['datas'] != null ? new Datas.fromJson(json['datas']) : null; - } - - Map toJson() { - final Map data = new Map(); - data['status'] = this.status; - data['api'] = this.api; - data['id'] = this.id; - if (this.datas != null) { - data['datas'] = this.datas.toJson(); - } - return data; - } -} \ No newline at end of file diff --git a/lib/models/user_datas.dart b/lib/models/user_datas.dart new file mode 100644 index 0000000..caa93c6 --- /dev/null +++ b/lib/models/user_datas.dart @@ -0,0 +1,41 @@ +import 'package:astronote_app/models/companie.dart'; + +class User { + String lastname; + List companies; + String firstname; + String civilite; + + User({this.lastname, this.companies, this.firstname, this.civilite}); + + + User.fromJson(Map json) { + lastname = json['lastname']; + if (json['companies'] != null) { + companies = new List(); + json['companies'].forEach((v) { + companies.add(new Companie.fromJson(v)); + }); + } + firstname = json['firstname']; + civilite = json['civilite']; + } + +// Map toJson() { +// final Map data = new Map(); +// data['lastname'] = this.lastname; +// if (this.companies != null) { +// data['companies'] = this.companies.map((v) => v.toJson()).toList(); +// } +// data['firstname'] = this.firstname; +// data['civilite'] = this.civilite; +// return data; +// } + + + + @override + String toString() { + return 'User{lastname: $lastname, companies: $companies, firstname: $firstname, civilite: $civilite}'; + } +} \ No newline at end of file diff --git a/lib/providers/log_in.dart b/lib/providers/log_in.dart new file mode 100644 index 0000000..2375857 --- /dev/null +++ b/lib/providers/log_in.dart @@ -0,0 +1,89 @@ +import 'dart:convert'; +import 'package:path/path.dart'; +import 'package:sqflite/sqflite.dart'; +import 'package:astronote_app/models/user_datas.dart'; +import 'package:astronote_app/models/credential.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:http/http.dart' as http; + +class LogIn with ChangeNotifier { + String _cookie; + Credential _userCredentials; + + bool get isLog { + return token != null; + } + + String get token { + if (_cookie != null) { + return _cookie; + } + return null; + } + + Future logIn(String url, String login, String password) async { + String urlApi = url + '/api/v1/login'; + + Map headers = { + "X-Requested-With": "XMLHttpRequest", + "Content-Type": "application/json", + }; + var body = json.encode({"login": login, "password": password}); + + final response = await http.post(urlApi, headers: headers, body: body); + if (response.statusCode == 200) { + // If the server did return a 20 0 OK response, + _cookie = response.headers['set-cookie']; + _userCredentials = new Credential(url: url, login: login, password: password); + print(_userCredentials.toString()); +// await OpenLocalBdd(); + return recoverUserDatas(urlApi); + } else{ + _cookie = null; + _userCredentials = null; + } + notifyListeners(); + } + + Future recoverUserDatas(String url) async { + Map headers = { + "X-Requested-With": "XMLHttpRequest", + "Cookie": _cookie + }; + + final response = await http.get(url, headers: headers); + + if (response.statusCode == 200) { + // If the server did return a 200 OK response then parse the JSON. + final responseJson = json.decode(response.body); + + User userDatas = new User.fromJson(responseJson['datas']); + print(userDatas.companies[0].toString()); + } + } + +// Future OpenLocalBdd() async { +// // Open the database and store the reference. +// final Future database = openDatabase( +// // Set the path to the database. Note: Using the `join` function from the +// // `path` package is best practice to ensure the path is correctly +// // constructed for each platform. +// join(await getDatabasesPath(), 'astronote_database.db'), +// onCreate: (db, version) { +// // Run the CREATE TABLE statement on the database. +// return db.execute( +// "CREATE TABLE credentials(id INTEGER PRIMARY KEY, name TEXT, age INTEGER)", +// ); +// }, +// // Set the version. This executes the onCreate function and provides a +// // path to perform database upgrades and downgrades. +// version: 1, +// +// ); +// print(await getDatabasesPath()); +// await database; +// } + + +} diff --git a/lib/providers/sign_in.dart b/lib/providers/sign_in.dart deleted file mode 100644 index 2c81a03..0000000 --- a/lib/providers/sign_in.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; -import 'package:http/http.dart' as http; - -class SignIn with ChangeNotifier { - String cookie; - - Future login(String url, String email, String password) async { - String urlApi = url + '/api/v1/login'; - - Map headers = { - "X-Requested-With": "XMLHttpRequest", - "Content-Type": "application/json", - }; - var body = json.encode({"login": email, "password": password}); - - final response = await http.post(urlApi, headers: headers, body: body); - if (response.statusCode == 200) { - // If the server did return a 200 OK response, - // then parse the JSON. - print(response.headers['set-cookie']); - cookie = response.headers['set-cookie']; - //TODO : return http.get + company_choice_screen root - recoverUserData(urlApi); - // If the server did not return a 200 OK response, - // then throw an exception. - //TODO: error message ? - } - -// final responseJson = json.decode(response.body); - } - - Future recoverUserData(String url) async { - Map headers = {"X-Requested-With": "XMLHttpRequest","Cookie":cookie}; - - final response = await http.get(url, headers: headers); - - if (response.statusCode == 200) { - // If the server did return a 200 OK response, - // then parse the JSON. - print(response.headers['datas']); - } else { - // If the server did not return a 200 OK response, - // then throw an exception. - } -// final responseJson = json.decode(response.body); -// -// print(responseJson); - } -} diff --git a/lib/screens/company_choice_screen.dart b/lib/screens/company_choice_screen.dart index e69de29..164c940 100644 --- a/lib/screens/company_choice_screen.dart +++ b/lib/screens/company_choice_screen.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:astronote_app/models/companie.dart'; + +class CompanyChoiceScreen extends StatefulWidget { + @override + _CompanyChoiceScreenState createState() => _CompanyChoiceScreenState(); +} + +class _CompanyChoiceScreenState extends State { + Companie companies = new Companie(); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Container( + margin: EdgeInsets.only( + top: MediaQuery.of(context).size.height * 0.09, + bottom: MediaQuery.of(context).size.height * 0.05), + padding: EdgeInsets.only( + left: MediaQuery.of(context).size.height * 0.05, + right: MediaQuery.of(context).size.height * 0.05), + child: Column( + children: [ + Text("Bonjour !", style: Theme.of(context).textTheme.headline1), + SizedBox(height: MediaQuery.of(context).size.height * 0.08), + Text("Pour quelle enseigne souhaitez-vous gérer vos notes de dépenses ?", style: Theme.of(context).textTheme.headline2,textAlign: TextAlign.center), + SizedBox(height: MediaQuery.of(context).size.height * 0.07), + ButtonTheme.fromButtonThemeData( + data: Theme.of(context).buttonTheme, + child: RaisedButton( + elevation: 3.0, + onPressed: () { + Navigator.pushNamed(context, '/dashboardScreen'); + }, + + child: Text("C'est parti !", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.button), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index e69de29..2f7b988 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; + +class DashBoardScreen extends StatefulWidget { + @override + _DashBoardScreenState createState() => _DashBoardScreenState(); +} + +class _DashBoardScreenState extends State { + int _selectedIndex = 0; + static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold); + static const List _widgetOptions = [ + Text( + 'Index 0: Accueil', + style: optionStyle, + ), + Text( + 'Index 1: Notes', + style: optionStyle, + ), + Text( + 'Index 2: Enseignes', + style: optionStyle, + ), + ]; + + void _onItemTapped(int index) { + setState(() { + _selectedIndex = index; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: _widgetOptions.elementAt(_selectedIndex), + ), + bottomNavigationBar: BottomNavigationBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + title: Text('Accueil'), + ), + BottomNavigationBarItem( + icon: Icon(Icons.add), + title: Text('Notes'), + ), + BottomNavigationBarItem( + icon: Icon(Icons.business), + title: Text('Enseignes'), + ), + ], + currentIndex: _selectedIndex, + selectedItemColor: Colors.indigo[900], + onTap: _onItemTapped, + ), + ); + } +} diff --git a/lib/screens/log_in_screen.dart b/lib/screens/log_in_screen.dart new file mode 100644 index 0000000..211310f --- /dev/null +++ b/lib/screens/log_in_screen.dart @@ -0,0 +1,186 @@ +import 'package:astronote_app/providers/log_in.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class LogInScreen extends StatefulWidget { +// static const routeName = '/logInScreen'; + + @override + _LogInScreenState createState() => _LogInScreenState(); +} + +class _LogInScreenState extends State { + + var _obscurePassword = true; + var _isLoading = false; + + final urlEndi = "https://endi.coop"; + final urlAstrolabe = "https://astrolabe.coop"; + + final GlobalKey _formKey = GlobalKey(); + final GlobalKey _scaffoldKey = new GlobalKey(); + + final TextEditingController urlController = new TextEditingController(); + final TextEditingController loginController = new TextEditingController(); + final TextEditingController passwordController = new TextEditingController(); + + Future _submit() async { + if (!_formKey.currentState.validate()) { + // Invalid! + return; + } + _formKey.currentState.save(); + + try { + setState(() { + _isLoading = true; + }); + await Provider.of(context, listen: false).logIn( + urlController.text, loginController.text, passwordController.text); + if(Provider.of(context, listen: false).isLog){ + Navigator.pushNamed(context, '/companyChoiceScreen'); + } + } catch (Exception) { + setState(() { + _isLoading = false; + }); + _scaffoldKey.currentState.showSnackBar(SnackBar( + backgroundColor: Colors.red[300], + duration: Duration(seconds: 3), + content: Row( + children: [ + Icon(Icons.error_outline), + Text(' Les données ne sont pas correctes'), + ], + ), + )); + } + } + + @override + Widget build(BuildContext context) { + final TextStyle style = Theme.of(context).textTheme.bodyText1; + + return Scaffold( + key: _scaffoldKey, + body: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.only( + top: MediaQuery.of(context).size.height * 0.04, + left: MediaQuery.of(context).size.height * 0.07, + right: MediaQuery.of(context).size.height * 0.07), + child: SingleChildScrollView( + child: Column( + children: [ + Image.asset( + "assets/astrolabe_logo.jpg", + ), + SizedBox(height: MediaQuery.of(context).size.height * 0.01), + Text("AstroNotes", style: style.copyWith(fontSize: 36.0)), + SizedBox(height: MediaQuery.of(context).size.height * 0.08), + Form( + key: _formKey, + child: Column( + children: [ + TextFormField( + controller: urlController, + style: style, + keyboardType: TextInputType.url, + decoration: InputDecoration( + contentPadding: + EdgeInsets.fromLTRB(20.0, 15.0, 0.0, 15.0), + labelText: "Lien enDI", + suffixIcon: + Icon(Icons.link, color: Colors.indigo[900]), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(32.0))), + ), + SizedBox(height: MediaQuery.of(context).size.height * 0.03), + TextFormField( + controller: loginController, + style: style, + keyboardType: TextInputType.emailAddress, + decoration: InputDecoration( + contentPadding: + EdgeInsets.fromLTRB(20.0, 15.0, 0.0, 15.0), + labelText: "E-mail", + suffixIcon: + Icon(Icons.mail, color: Colors.indigo[900]), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(32.0))), + ), + SizedBox(height: MediaQuery.of(context).size.height * 0.03), + TextFormField( + controller: passwordController, + style: style, + obscureText: _obscurePassword, + decoration: InputDecoration( + contentPadding: + EdgeInsets.fromLTRB(20.0, 15.0, 0.0, 15.0), + labelText: "Mot de passe", + suffixIcon: IconButton( + icon: Icon( + _obscurePassword + ? Icons.visibility + : Icons.visibility_off, + color: Colors.indigo[900]), + onPressed: () { + setState( + () => _obscurePassword = !_obscurePassword); + }), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(32.0))), + ), + SizedBox(height: MediaQuery.of(context).size.height * 0.07), + ButtonTheme.fromButtonThemeData( + data: Theme.of(context).buttonTheme, + child: RaisedButton( + elevation: 3.0, + onPressed: () { + _submit(); + }, + child: _isLoading + ? CircularProgressIndicator() + : Text("Connexion", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.button), + ), + ), + ], + ), + ), + SizedBox(height: MediaQuery.of(context).size.height * 0.08), + InkWell( + onTap: () async { + if (await canLaunch(urlEndi)) { + await launch(urlEndi); + } + }, + child: Text( + "En collaboration avec enDI", + style: style.copyWith( + fontSize: 13.0, decoration: TextDecoration.underline), + ), + ), + SizedBox(height: MediaQuery.of(context).size.height * 0.01), + InkWell( + onTap: () async { + if (await canLaunch(urlAstrolabe)) { + await launch(urlAstrolabe); + } + }, + child: Text( + "Développé par Astrolabe", + style: style.copyWith( + fontSize: 13, decoration: TextDecoration.underline), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/sign_in_screen.dart b/lib/screens/sign_in_screen.dart deleted file mode 100644 index a58b4e1..0000000 --- a/lib/screens/sign_in_screen.dart +++ /dev/null @@ -1,85 +0,0 @@ -import 'package:flutter/material.dart'; -import 'file:///D:/AndroidStudioProjects/astronote_app/lib/widgets/footer_sign_in_widget.dart'; - -import 'file:///D:/AndroidStudioProjects/astronote_app/lib/widgets/form_sign_in_widget.dart'; -import 'package:astronote_app/widgets/header_sign__in_widget.dart'; - -class LoginScreen extends StatefulWidget { - @override - _LoginScreenState createState() => _LoginScreenState(); -} - -class _LoginScreenState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - body: Container( -// width: double.infinity, - child: SingleChildScrollView( - padding: EdgeInsets.only( - left: MediaQuery.of(context).size.height * 0.07, - right: MediaQuery.of(context).size.height * 0.07), -// scrollDirection: Axis.vertical, - child: Column( - children: [ - HeaderLogWidget(), - SizedBox(height: MediaQuery.of(context).size.height * 0.08), - FormLogWidget(), - SizedBox(height: MediaQuery.of(context).size.height * 0.08), - FooterLogWidget(), - SizedBox(height: MediaQuery.of(context).size.height * 0.05), - ], - ), - ), - ), - ); - } - -// Widget _enDIUrl() { -// return InkWell( -// onTap: _enDIUrl, -// child: Text( -// "En collaboration avec enDI", -// style: style.copyWith( -// color: Colors.black, -// fontSize: 15.0, -// decoration: TextDecoration.underline), -// ), -// ); -// } -// -// Widget _astrolabeUrl() { -// return InkWell( -// onTap: _launchLinkAstrolabe, -// child: Text( -// "Développé par Astrolabe", -// style: style.copyWith( -// color: Colors.black, -// fontSize: 15, -// decoration: TextDecoration.underline), -// ), -// ); -// } -// -// -// -// void launchLinkEnDI() async { -// const urlEndi = "hhuh"; -// -// if (await canLaunch(urlEndi)) { -// await launch(urlEndi); -// } else { -// -// } -// } -// -// void _launchLinkAstrolabe() async { -// const url = "https://astrolabe.coop"; -// -// if (await canLaunch(url)) { -// await launch(url); -// } else { -// -// } -// } -} diff --git a/lib/theme/style.dart b/lib/theme/style.dart new file mode 100644 index 0000000..36bedd5 --- /dev/null +++ b/lib/theme/style.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +ThemeData appTheme() { + return ThemeData( + scaffoldBackgroundColor: Colors.white, + fontFamily: 'Varela Round', + textTheme: TextTheme( + bodyText1: TextStyle(fontSize: 16.0, color: Colors.black), + button: TextStyle( + fontSize: 17.0, color: Colors.white, fontWeight: FontWeight.bold), + headline1: TextStyle(fontSize: 26.0, color: Colors.black), + headline2: TextStyle(fontSize: 21.0, color: Colors.black)), + buttonTheme: ButtonThemeData( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)), + padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), + buttonColor: Colors.indigo[900], + ), + ); +} diff --git a/lib/widgets/footer_sign_in_widget.dart b/lib/widgets/footer_sign_in_widget.dart deleted file mode 100644 index 8c6b887..0000000 --- a/lib/widgets/footer_sign_in_widget.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class FooterLogWidget extends StatelessWidget { - final TextStyle style = TextStyle(fontFamily: 'Varela Round', fontSize: 20.0); - - - @override - Widget build(BuildContext context) { - return Center( - child: Column( - children: [ - _enDIUrl(), - SizedBox(height: 5), - _astrolabeUrl() - ], - ), - ); - } - - Widget _enDIUrl() { - return InkWell( - onTap: _launchLinkEnDI, - child: Text( - "En collaboration avec enDI", - style: style.copyWith( - color: Colors.black, - fontSize: 15.0, - decoration: TextDecoration.underline), - ), - ); - } - - Widget _astrolabeUrl() { - return InkWell( - onTap: _launchLinkAstrolabe, - child: Text( - "Développé par Astrolabe", - style: style.copyWith( - color: Colors.black, - fontSize: 15, - decoration: TextDecoration.underline), - ), - ); - } - - void _launchLinkEnDI() async { - const urlEndi = "https://endi.coop"; - - if (await canLaunch(urlEndi)) { - await launch(urlEndi); - } else { - //TODO : error message - } - } - - void _launchLinkAstrolabe() async { - const url = "https://astrolabe.coop"; - - if (await canLaunch(url)) { - await launch(url); - } else { - //TODO : error message - } - } -} diff --git a/lib/widgets/form_sign_in_widget.dart b/lib/widgets/form_sign_in_widget.dart deleted file mode 100644 index 2ff2e79..0000000 --- a/lib/widgets/form_sign_in_widget.dart +++ /dev/null @@ -1,109 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter/widgets.dart'; -import 'package:astronote_app/providers/sign_in.dart'; - -class FormLogWidget extends StatefulWidget { - @override - _FormLogWidgetState createState() => _FormLogWidgetState(); -} - -class _FormLogWidgetState extends State { - TextStyle style = TextStyle(fontFamily: 'Varela Round', fontSize: 20.0); - - bool _obscurePassword = true; - final GlobalKey _formKey = GlobalKey(); - bool _isLoading = false; - - TextEditingController urlController = new TextEditingController(); - TextEditingController emailController = new TextEditingController(); - TextEditingController passwordController = new TextEditingController(); - - - @override - Widget build(BuildContext context) { - return Form( - key: _formKey, - child: Column( - children: [ - _urlFormField(), - SizedBox(height: MediaQuery.of(context).size.height * 0.03), - _emailFormField(), - SizedBox(height: MediaQuery.of(context).size.height * 0.03), - _passwordFormField(), - SizedBox(height: MediaQuery.of(context).size.height * 0.07), - _logButton() - ], - ), - ); - } - - Widget _urlFormField() { - return TextFormField( - controller: urlController, - style: style, - keyboardType: TextInputType.url, - decoration: InputDecoration( - contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), - labelText: "Lien enDI", - suffixIcon: Icon(Icons.link,color: Colors.indigo[900]), - border: - OutlineInputBorder(borderRadius: BorderRadius.circular(32.0))), - ); - } - - Widget _emailFormField() { - return TextFormField( - controller: emailController, - style: style, - keyboardType: TextInputType.emailAddress, - decoration: InputDecoration( - contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), - labelText: "E-mail", - suffixIcon: Icon(Icons.mail,color: Colors.indigo[900]), - border: - OutlineInputBorder(borderRadius: BorderRadius.circular(32.0))), - ); - } - - Widget _passwordFormField() { - return TextFormField( - controller: passwordController, - style: style, - obscureText: _obscurePassword, - decoration: InputDecoration( - contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), - labelText: "Mot de passe", - suffixIcon: IconButton( - icon: Icon( - _obscurePassword ? Icons.visibility : Icons.visibility_off,color: Colors.indigo[900]), - onPressed: () { - setState(() => _obscurePassword = !_obscurePassword); - }), - border: - OutlineInputBorder(borderRadius: BorderRadius.circular(32.0))), - ); - } - - Widget _logButton() { - return Material( - elevation: 3.0, - borderRadius: BorderRadius.circular(30.0), - color: Colors.indigo[900], - child: MaterialButton( -// minWidth: MediaQuery.of(context).size.width, - padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0), - onPressed: () { - setState(() { - _isLoading = true; - }); - SignIn().login(urlController.text, emailController.text, passwordController.text); - }, - child: Text("Connexion", - textAlign: TextAlign.center, - style: style.copyWith( - color: Colors.white, fontWeight: FontWeight.bold)), - ) - ); - } -} diff --git a/lib/widgets/header_sign__in_widget.dart b/lib/widgets/header_sign__in_widget.dart deleted file mode 100644 index 7fe1488..0000000 --- a/lib/widgets/header_sign__in_widget.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:flutter/material.dart'; - -class HeaderLogWidget extends StatelessWidget { - final TextStyle style = TextStyle(fontFamily: 'Varela Round', fontSize: 20.0); - - @override - Widget build(BuildContext context) { - return Center( - child: Container( - margin: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.09), - child: Column( - children: [_astrolabeLogo(), SizedBox(height: 5.0), _appTitle(context)], - ), - ), - ); - } - - Widget _astrolabeLogo() { - return Image.asset( - "assets/astrolabe_logo.jpg", - ); - } - - Widget _appTitle(BuildContext context) { - return Text("AstroNotes", - style: - style.copyWith(color: Colors.black, fontSize: 40)); - } -} diff --git a/pubspec.lock b/pubspec.lock index f579648..2007e86 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -64,20 +64,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "5.2.1" - flushbar: - dependency: "direct main" - description: - name: flushbar - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.4" flutter: dependency: "direct main" description: flutter @@ -114,13 +100,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.12" - intl: - dependency: transitive - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" matcher: dependency: transitive description: @@ -143,26 +122,12 @@ packages: source: hosted version: "0.0.4" path: - dependency: transitive + dependency: "direct main" description: name: path url: "https://pub.dartlang.org" source: hosted version: "1.6.4" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.1+2" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" pedantic: dependency: transitive description: @@ -177,13 +142,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.4.0" - platform: - dependency: transitive - description: - name: platform - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.1" platform_detect: dependency: transitive description: @@ -198,13 +156,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" - process: - dependency: transitive - description: - name: process - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.13" provider: dependency: "direct main" description: @@ -226,41 +177,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.3" - shared_preferences: - dependency: "direct main" - description: - name: shared_preferences - url: "https://pub.dartlang.org" - source: hosted - version: "0.5.8" - shared_preferences_linux: - dependency: transitive - description: - name: shared_preferences_linux - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.2+1" - shared_preferences_macos: - dependency: transitive - description: - name: shared_preferences_macos - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.1+10" - shared_preferences_platform_interface: - dependency: transitive - description: - name: shared_preferences_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - shared_preferences_web: - dependency: transitive - description: - name: shared_preferences_web - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.2+7" sky_engine: dependency: transitive description: flutter @@ -273,6 +189,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.7.0" + sqflite: + dependency: "direct main" + description: + name: sqflite + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2+1" stack_trace: dependency: transitive description: @@ -294,6 +224,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.5" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0+2" term_glyph: dependency: transitive description: @@ -357,13 +294,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" - xdg_directories: - dependency: transitive - description: - name: xdg_directories - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.0" xml: dependency: transitive description: @@ -372,5 +302,5 @@ packages: source: hosted version: "3.6.1" sdks: - dart: ">=2.7.2 <3.0.0" + dart: ">=2.8.0 <3.0.0" flutter: ">=1.16.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 61212d9..94b0b3d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,11 +24,10 @@ dependencies: flutter: sdk: flutter url_launcher: ^5.5.0 - flushbar: ^1.10.4 http: ^0.12.2 provider: ^4.3.1 - shared_preferences: ^0.5.8 - + sqflite: + path: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.