Finish user log in to endi's account + rename some files and class
This commit is contained in:
parent
384c67e9a3
commit
4d6ca678fc
@ -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<LogIn>(
|
||||
builder:(context, logIn, _) => MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: appTheme(),
|
||||
home: logIn.isLog ? CompanyChoiceScreen() : LogInScreen(),
|
||||
routes: {
|
||||
"/logInScreen": (context) => LogInScreen(),
|
||||
"/companyChoiceScreen": (context) => CompanyChoiceScreen(),
|
||||
"/dashboardScreen": (context) => DashBoardScreen()
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
23
lib/models/companie.dart
Normal file
23
lib/models/companie.dart
Normal file
@ -0,0 +1,23 @@
|
||||
class Companie {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
Companie({this.id, this.name});
|
||||
|
||||
Companie.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
}
|
||||
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['id'] = this.id;
|
||||
// data['name'] = this.name;
|
||||
// return data;
|
||||
// }
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Companie{name: $name}';
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
class Companies {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
Companies({this.id, this.name});
|
||||
|
||||
Companies.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['name'] = this.name;
|
||||
return data;
|
||||
}
|
||||
}
|
15
lib/models/credential.dart
Normal file
15
lib/models/credential.dart
Normal file
@ -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}';
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
import 'package:astronote_app/models/companies.dart';
|
||||
|
||||
class Datas {
|
||||
String lastname;
|
||||
List<Companies> companies;
|
||||
String firstname;
|
||||
String civilite;
|
||||
|
||||
Datas({this.lastname, this.companies, this.firstname, this.civilite});
|
||||
|
||||
Datas.fromJson(Map<String, dynamic> json) {
|
||||
lastname = json['lastname'];
|
||||
if (json['companies'] != null) {
|
||||
companies = new List<Companies>();
|
||||
json['companies'].forEach((v) {
|
||||
companies.add(new Companies.fromJson(v));
|
||||
});
|
||||
}
|
||||
firstname = json['firstname'];
|
||||
civilite = json['civilite'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
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;
|
||||
}
|
||||
}
|
@ -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<String, dynamic> json) {
|
||||
status = json['status'];
|
||||
api = json['api'];
|
||||
id = json['id'];
|
||||
datas = json['datas'] != null ? new Datas.fromJson(json['datas']) : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['status'] = this.status;
|
||||
data['api'] = this.api;
|
||||
data['id'] = this.id;
|
||||
if (this.datas != null) {
|
||||
data['datas'] = this.datas.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
41
lib/models/user_datas.dart
Normal file
41
lib/models/user_datas.dart
Normal file
@ -0,0 +1,41 @@
|
||||
import 'package:astronote_app/models/companie.dart';
|
||||
|
||||
class User {
|
||||
String lastname;
|
||||
List<Companie> companies;
|
||||
String firstname;
|
||||
String civilite;
|
||||
|
||||
User({this.lastname, this.companies, this.firstname, this.civilite});
|
||||
|
||||
|
||||
User.fromJson(Map<String, dynamic> json) {
|
||||
lastname = json['lastname'];
|
||||
if (json['companies'] != null) {
|
||||
companies = new List<Companie>();
|
||||
json['companies'].forEach((v) {
|
||||
companies.add(new Companie.fromJson(v));
|
||||
});
|
||||
}
|
||||
firstname = json['firstname'];
|
||||
civilite = json['civilite'];
|
||||
}
|
||||
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// 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}';
|
||||
}
|
||||
}
|
89
lib/providers/log_in.dart
Normal file
89
lib/providers/log_in.dart
Normal file
@ -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<void> logIn(String url, String login, String password) async {
|
||||
String urlApi = url + '/api/v1/login';
|
||||
|
||||
Map<String, String> 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<void> recoverUserDatas(String url) async {
|
||||
Map<String, String> 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<Database> OpenLocalBdd() async {
|
||||
// // Open the database and store the reference.
|
||||
// final Future<Database> 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;
|
||||
// }
|
||||
|
||||
|
||||
}
|
@ -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<void> login(String url, String email, String password) async {
|
||||
String urlApi = url + '/api/v1/login';
|
||||
|
||||
Map<String, String> 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<void> recoverUserData(String url) async {
|
||||
Map<String, String> 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);
|
||||
}
|
||||
}
|
@ -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<CompanyChoiceScreen> {
|
||||
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: <Widget>[
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DashBoardScreen extends StatefulWidget {
|
||||
@override
|
||||
_DashBoardScreenState createState() => _DashBoardScreenState();
|
||||
}
|
||||
|
||||
class _DashBoardScreenState extends State<DashBoardScreen> {
|
||||
int _selectedIndex = 0;
|
||||
static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
|
||||
static const List<Widget> _widgetOptions = <Widget>[
|
||||
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>[
|
||||
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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
186
lib/screens/log_in_screen.dart
Normal file
186
lib/screens/log_in_screen.dart
Normal file
@ -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<LogInScreen> {
|
||||
|
||||
var _obscurePassword = true;
|
||||
var _isLoading = false;
|
||||
|
||||
final urlEndi = "https://endi.coop";
|
||||
final urlAstrolabe = "https://astrolabe.coop";
|
||||
|
||||
final GlobalKey<FormState> _formKey = GlobalKey();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
|
||||
final TextEditingController urlController = new TextEditingController();
|
||||
final TextEditingController loginController = new TextEditingController();
|
||||
final TextEditingController passwordController = new TextEditingController();
|
||||
|
||||
Future<void> _submit() async {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
// Invalid!
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
|
||||
try {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
await Provider.of<LogIn>(context, listen: false).logIn(
|
||||
urlController.text, loginController.text, passwordController.text);
|
||||
if(Provider.of<LogIn>(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: <Widget>[
|
||||
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: <Widget>[
|
||||
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: <Widget>[
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -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<LoginScreen> {
|
||||
@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: <Widget>[
|
||||
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 {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
19
lib/theme/style.dart
Normal file
19
lib/theme/style.dart
Normal file
@ -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],
|
||||
),
|
||||
);
|
||||
}
|
@ -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: <Widget>[
|
||||
_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
|
||||
}
|
||||
}
|
||||
}
|
@ -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<FormLogWidget> {
|
||||
TextStyle style = TextStyle(fontFamily: 'Varela Round', fontSize: 20.0);
|
||||
|
||||
bool _obscurePassword = true;
|
||||
final GlobalKey<FormState> _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: <Widget>[
|
||||
_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)),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -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: <Widget>[_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));
|
||||
}
|
||||
}
|
116
pubspec.lock
116
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"
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user