-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignUpForm.dart
119 lines (114 loc) · 4.02 KB
/
signUpForm.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import 'package:flutter/material.dart';
import 'package:digibook2/widgets/ourContainer.dart';
import 'package:digibook2/states/currentUser.dart';
import 'package:provider/provider.dart';
import 'package:digibook2/screens/login/LogIn.dart';
import 'package:provider/provider.dart';
class OurSignUpForm extends StatefulWidget {
@override
_OurSignUpFormState createState() => _OurSignUpFormState();
}
class _OurSignUpFormState extends State<OurSignUpForm> {
TextEditingController _fullNameController=TextEditingController();
TextEditingController _emailController=TextEditingController();
TextEditingController _passwordController=TextEditingController();
TextEditingController _confirmPasswordController=TextEditingController();
void _signUpUser(String email, String password, BuildContext context, String fullName) async{
CurrentUser _currentUser=Provider.of<CurrentUser>(context, listen: false);
//Navigator.pop(context);
String _returnString=await _currentUser.signUpUser(email, password, fullName);
try{
if(_returnString=="success") {
Navigator.pop(context);
}
else{
Scaffold.of(context).showSnackBar(
SnackBar(
content: Text(_returnString),
duration: Duration(seconds: 2),
),
);
}
}catch(e){
print(e);
}
}
@override
Widget build(BuildContext context) {
return ourContainer(
child: Column(
children: <Widget>[
Padding(padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 8.0),
child: Text("Registrati", style: TextStyle(
color: Theme.of(context).secondaryHeaderColor,
fontSize: 25.0,
fontWeight: FontWeight.bold,
),
),
),
TextFormField(
controller: _fullNameController,
decoration: InputDecoration(
prefixIcon: Icon(Icons.person_outline),
hintText: "Nome utente"),
),
SizedBox(height: 20.0,),
TextFormField(
controller: _emailController,
decoration: InputDecoration(
prefixIcon: Icon(Icons.alternate_email),
hintText: "Email"),
),
SizedBox(height: 20.0,),
TextFormField(
controller: _passwordController,
decoration: InputDecoration(
prefixIcon: Icon(Icons.lock_outline),
hintText: "Password"),
obscureText: true,
),
SizedBox(height: 20.0,),
TextFormField(
controller: _confirmPasswordController,
decoration: InputDecoration(
prefixIcon: Icon(Icons.lock_open),
hintText: "Conferma password"
),
obscureText: true,
),
SizedBox(height: 20.0,),
RaisedButton(
color: Theme.of(context).accentColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(7.0),
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 100),
child: Text(
"Registrati",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
),
onPressed: (){
//Navigator.pop(context);
if(_passwordController.text==_confirmPasswordController.text){
_signUpUser(_emailController.text, _passwordController.text, context, _fullNameController.text);
}
else{
Scaffold.of(context).showSnackBar(
SnackBar(content: Text('Le password non corrispondono'),
duration: Duration(seconds: 2),
),
);
}
},
),
],
),
);
}
}