Finish user log in to endi's account + rename some files and class

This commit is contained in:
Emeline G
2020-08-06 14:19:17 +02:00
parent 384c67e9a3
commit 4d6ca678fc
19 changed files with 525 additions and 522 deletions

View File

@@ -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),
),
),
],
),
),
);
}
}

View File

@@ -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,
),
);
}
}

View 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),
),
),
],
),
),
),
);
}
}

View File

@@ -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 {
//
// }
// }
}