diff --git a/lib/main.dart b/lib/main.dart index 70704b9..6264cce 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,14 +1,15 @@ -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 'file:///D:/AndroidStudioProjects/astronote_app/lib/services/log_in_services.dart'; +import 'package:astronote_app/themes/style.dart'; +import 'package:astronote_app/views/company_choice.dart'; +import 'package:astronote_app/views/dashboard.dart'; +import 'package:astronote_app/views/log_in.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { + // This widget is the root of your application. @override Widget build(BuildContext context) { return MultiProvider( @@ -19,11 +20,11 @@ class MyApp extends StatelessWidget { builder:(context, logIn, _) => MaterialApp( debugShowCheckedModeBanner: false, theme: appTheme(), - home: logIn.isLog ? CompanyChoiceScreen() : LogInScreen(), + home: logIn.isLog ? CompanyChoiceView() : LogInView(), routes: { - "/logInScreen": (context) => LogInScreen(), - "/companyChoiceScreen": (context) => CompanyChoiceScreen(), - "/dashboardScreen": (context) => DashBoardScreen() + "/logInScreen": (context) => LogInView(), + "/companyChoiceScreen": (context) => CompanyChoiceView(), + "/dashboardScreen": (context) => DashBoardView() }, ), ), diff --git a/lib/models/companie.dart b/lib/models/company.dart similarity index 100% rename from lib/models/companie.dart rename to lib/models/company.dart diff --git a/lib/models/user_datas.dart b/lib/models/user_datas.dart index caa93c6..5cabb58 100644 --- a/lib/models/user_datas.dart +++ b/lib/models/user_datas.dart @@ -1,15 +1,15 @@ -import 'package:astronote_app/models/companie.dart'; +import 'package:astronote_app/models/company.dart'; -class User { +class UserDatas { String lastname; List companies; String firstname; String civilite; - User({this.lastname, this.companies, this.firstname, this.civilite}); + UserDatas({this.lastname, this.companies, this.firstname, this.civilite}); - User.fromJson(Map json) { + UserDatas.fromJson(Map json) { lastname = json['lastname']; if (json['companies'] != null) { companies = new List(); diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart deleted file mode 100644 index 2f7b988..0000000 --- a/lib/screens/dashboard_screen.dart +++ /dev/null @@ -1,59 +0,0 @@ -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/providers/log_in.dart b/lib/services/log_in_services.dart similarity index 62% rename from lib/providers/log_in.dart rename to lib/services/log_in_services.dart index 2375857..610de01 100644 --- a/lib/providers/log_in.dart +++ b/lib/services/log_in_services.dart @@ -1,6 +1,4 @@ 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'; @@ -37,7 +35,6 @@ class LogIn with ChangeNotifier { _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; @@ -58,32 +55,9 @@ class LogIn with ChangeNotifier { // 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']); + UserDatas userDatas = new UserDatas.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/theme/style.dart b/lib/themes/style.dart similarity index 100% rename from lib/theme/style.dart rename to lib/themes/style.dart diff --git a/lib/viewmodels/db.dart b/lib/viewmodels/db.dart new file mode 100644 index 0000000..463d375 --- /dev/null +++ b/lib/viewmodels/db.dart @@ -0,0 +1,21 @@ +// 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; +// } \ No newline at end of file diff --git a/lib/screens/company_choice_screen.dart b/lib/views/company_choice.dart similarity index 85% rename from lib/screens/company_choice_screen.dart rename to lib/views/company_choice.dart index 164c940..5ce7cad 100644 --- a/lib/screens/company_choice_screen.dart +++ b/lib/views/company_choice.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:astronote_app/models/companie.dart'; +import 'package:astronote_app/models/company.dart'; -class CompanyChoiceScreen extends StatefulWidget { +class CompanyChoiceView extends StatefulWidget { @override - _CompanyChoiceScreenState createState() => _CompanyChoiceScreenState(); + _CompanyChoiceViewState createState() => _CompanyChoiceViewState(); } -class _CompanyChoiceScreenState extends State { +class _CompanyChoiceViewState extends State { Companie companies = new Companie(); @override diff --git a/lib/views/dashboard.dart b/lib/views/dashboard.dart new file mode 100644 index 0000000..47d53b6 --- /dev/null +++ b/lib/views/dashboard.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class DashBoardView extends StatefulWidget { + @override + _DashBoardViewState createState() => _DashBoardViewState(); +} + +class _DashBoardViewState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + bottomNavigationBar: BottomAppBar(), + ); + } +} diff --git a/lib/screens/log_in_screen.dart b/lib/views/log_in.dart similarity index 96% rename from lib/screens/log_in_screen.dart rename to lib/views/log_in.dart index 211310f..c62d520 100644 --- a/lib/screens/log_in_screen.dart +++ b/lib/views/log_in.dart @@ -1,16 +1,16 @@ -import 'package:astronote_app/providers/log_in.dart'; +import 'file:///D:/AndroidStudioProjects/astronote_app/lib/services/log_in_services.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; -class LogInScreen extends StatefulWidget { +class LogInView extends StatefulWidget { // static const routeName = '/logInScreen'; @override - _LogInScreenState createState() => _LogInScreenState(); + _LogInViewState createState() => _LogInViewState(); } -class _LogInScreenState extends State { +class _LogInViewState extends State { var _obscurePassword = true; var _isLoading = false;