|
|
@@ -1,4 +1,20 @@
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:physigo/Services/AuthServiec.dart';
|
|
|
+
|
|
|
+//Fields..
|
|
|
+TextEditingController _name = TextEditingController();
|
|
|
+TextEditingController _surname = TextEditingController();
|
|
|
+TextEditingController _mail = TextEditingController();
|
|
|
+TextEditingController _phoneNumber = TextEditingController();
|
|
|
+TextEditingController _address = TextEditingController();
|
|
|
+TextEditingController _username = TextEditingController();
|
|
|
+TextEditingController _passwd = TextEditingController();
|
|
|
+TextEditingController _passwd2 = TextEditingController();
|
|
|
+
|
|
|
+bool anonymous = false;
|
|
|
+String? _dateString;
|
|
|
+
|
|
|
+final AuthenticationServices _auth = AuthenticationServices();
|
|
|
|
|
|
class SignupPage extends StatefulWidget {
|
|
|
const SignupPage({Key? key}) : super(key: key);
|
|
|
@@ -9,14 +25,26 @@ class SignupPage extends StatefulWidget {
|
|
|
|
|
|
class _SignupPageState extends State<SignupPage> {
|
|
|
int _pageIndex = 0;
|
|
|
- List<Widget> forms = [SignupForm1(title: '',), SignupForm2(title: '',), SignupForm3(title: '',)];
|
|
|
+
|
|
|
+ List<Widget> forms = [
|
|
|
+ SignupForm1(
|
|
|
+ title: '',
|
|
|
+ ),
|
|
|
+ SignupForm2(
|
|
|
+ title: '',
|
|
|
+ ),
|
|
|
+ SignupForm3(
|
|
|
+ title: '',
|
|
|
+ )
|
|
|
+ ];
|
|
|
|
|
|
void _updatePageIndex(int newPageIndex) {
|
|
|
- if(newPageIndex == -1) {
|
|
|
+ if (newPageIndex == -1) {
|
|
|
Navigator.pushNamed(context, '/');
|
|
|
} else if (newPageIndex == 3) {
|
|
|
//autentification
|
|
|
- newPageIndex = 2;
|
|
|
+ //Navigator.pop(context);
|
|
|
+ newPageIndex == 2;
|
|
|
} else {
|
|
|
setState(() {
|
|
|
_pageIndex = newPageIndex;
|
|
|
@@ -30,15 +58,15 @@ class _SignupPageState extends State<SignupPage> {
|
|
|
floatingActionButton: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
children: [
|
|
|
- FloatingActionButton(child: Icon(Icons.navigate_before_outlined),
|
|
|
- onPressed: () => _updatePageIndex(_pageIndex - 1)
|
|
|
- ),
|
|
|
+ FloatingActionButton(
|
|
|
+ child: Icon(Icons.navigate_before_outlined),
|
|
|
+ onPressed: () => _updatePageIndex(_pageIndex - 1)),
|
|
|
SizedBox(
|
|
|
width: 25,
|
|
|
),
|
|
|
-
|
|
|
- FloatingActionButton(child: Icon(Icons.navigate_next_outlined),
|
|
|
- onPressed: () => _updatePageIndex(_pageIndex +1 ))
|
|
|
+ FloatingActionButton(
|
|
|
+ child: Icon(Icons.navigate_next_outlined),
|
|
|
+ onPressed: () => _updatePageIndex(_pageIndex + 1))
|
|
|
],
|
|
|
),
|
|
|
body: Center(child: forms[_pageIndex]),
|
|
|
@@ -57,7 +85,6 @@ class SignupForm1 extends StatefulWidget {
|
|
|
|
|
|
class _SignupForm1 extends State<SignupForm1> {
|
|
|
DateTime? _dateTime;
|
|
|
- String? _dateString;
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
@@ -67,58 +94,58 @@ class _SignupForm1 extends State<SignupForm1> {
|
|
|
),
|
|
|
body: Center(
|
|
|
child: SizedBox(
|
|
|
- width: 300,
|
|
|
- child: Column(children: <Widget>[
|
|
|
- const SizedBox(height: 30),
|
|
|
- Text(
|
|
|
- 'Personal Information',
|
|
|
- style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
|
|
- ),
|
|
|
- const SizedBox(height: 30),
|
|
|
- Image.asset(
|
|
|
- 'assets/user.png',
|
|
|
- width: 150,
|
|
|
- ),
|
|
|
- const SizedBox(height: 30),
|
|
|
- TextField(
|
|
|
- decoration: InputDecoration(
|
|
|
- hintText: 'Name',
|
|
|
- ),
|
|
|
- ),
|
|
|
- const SizedBox(height: 10),
|
|
|
- TextField(
|
|
|
- decoration: InputDecoration(
|
|
|
- hintText: 'Surname',
|
|
|
- ),
|
|
|
- ),
|
|
|
-
|
|
|
- const SizedBox(height: 10),
|
|
|
- Row(children: <Widget>[
|
|
|
- Text(_dateString == null
|
|
|
- ? 'Select birthday date :'
|
|
|
- : _dateString.toString()),
|
|
|
- const SizedBox(width: 49),
|
|
|
- ElevatedButton(
|
|
|
- onPressed: () {
|
|
|
- showDatePicker(
|
|
|
+ width: 300,
|
|
|
+ child: Column(children: <Widget>[
|
|
|
+ const SizedBox(height: 30),
|
|
|
+ Text(
|
|
|
+ 'Personal Information',
|
|
|
+ style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 30),
|
|
|
+ Image.asset(
|
|
|
+ 'assets/user.png',
|
|
|
+ width: 150,
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 30),
|
|
|
+ TextFormField(
|
|
|
+ controller: _name,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ hintText: 'Name',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ TextFormField(
|
|
|
+ controller: _surname,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ hintText: 'Surname',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ Row(children: <Widget>[
|
|
|
+ Text(_dateString == null
|
|
|
+ ? 'Select birthday date :'
|
|
|
+ : _dateString.toString()),
|
|
|
+ const SizedBox(width: 49),
|
|
|
+ ElevatedButton(
|
|
|
+ onPressed: () {
|
|
|
+ showDatePicker(
|
|
|
context: context,
|
|
|
initialDate: DateTime.now(),
|
|
|
firstDate: DateTime(1900),
|
|
|
- lastDate: DateTime(2222))
|
|
|
- .then((date) {
|
|
|
- setState(() {
|
|
|
- _dateTime = date!;
|
|
|
- _dateString = "${date.day}/${date.month}/${date.year}";
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- child: const Text('Select date'),
|
|
|
- ),
|
|
|
- ]),
|
|
|
- const SizedBox(height: 10),
|
|
|
-
|
|
|
- ]),
|
|
|
- )),
|
|
|
+ lastDate: DateTime.now())
|
|
|
+ .then((date) {
|
|
|
+ setState(() {
|
|
|
+ _dateTime = date!;
|
|
|
+ _dateString = "${date.day}/${date.month}/${date.year}";
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ child: const Text('Select date'),
|
|
|
+ ),
|
|
|
+ ]),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ ]),
|
|
|
+ )),
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
@@ -133,7 +160,6 @@ class SignupForm2 extends StatefulWidget {
|
|
|
}
|
|
|
|
|
|
class _SignupForm2 extends State<SignupForm2> {
|
|
|
- bool isChecked = false;
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Scaffold(
|
|
|
@@ -142,58 +168,57 @@ class _SignupForm2 extends State<SignupForm2> {
|
|
|
),
|
|
|
body: Center(
|
|
|
child: SizedBox(
|
|
|
- width: 300,
|
|
|
- child: Column(children: <Widget>[
|
|
|
- const SizedBox(height: 30),
|
|
|
- Text(
|
|
|
- 'Contact Details',
|
|
|
- style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
|
|
- ),
|
|
|
- const SizedBox(height: 30),
|
|
|
- Image.asset(
|
|
|
- 'assets/communicate.png',
|
|
|
- width: 150,
|
|
|
- ),
|
|
|
- const SizedBox(height: 30),
|
|
|
- TextField(
|
|
|
- decoration: InputDecoration(
|
|
|
- hintText: 'Mail',
|
|
|
- ),
|
|
|
- ),
|
|
|
- const SizedBox(height: 10),
|
|
|
- TextField(
|
|
|
- decoration: InputDecoration(
|
|
|
- hintText: 'Phone Number',
|
|
|
- ),
|
|
|
- ),
|
|
|
- const SizedBox(height: 10),
|
|
|
- TextField(
|
|
|
- decoration: InputDecoration(
|
|
|
- hintText: 'Home Adress..',
|
|
|
- ),
|
|
|
- ),
|
|
|
- const SizedBox(height: 10),
|
|
|
- Row(children: <Widget>[
|
|
|
- Text('Anonymous'),
|
|
|
- Checkbox(
|
|
|
-
|
|
|
- checkColor: Colors.white,
|
|
|
- value: isChecked,
|
|
|
- onChanged: (bool? value) {
|
|
|
- setState(() {
|
|
|
- isChecked = value!;
|
|
|
- });
|
|
|
- },),
|
|
|
- ]),
|
|
|
-
|
|
|
- const SizedBox(height: 10),
|
|
|
-
|
|
|
-
|
|
|
- ]),
|
|
|
- )),
|
|
|
+ width: 300,
|
|
|
+ child: Column(children: <Widget>[
|
|
|
+ const SizedBox(height: 30),
|
|
|
+ Text(
|
|
|
+ 'Contact Details',
|
|
|
+ style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 30),
|
|
|
+ Image.asset(
|
|
|
+ 'assets/communicate.png',
|
|
|
+ width: 150,
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 30),
|
|
|
+ TextFormField(
|
|
|
+ controller: _mail,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ hintText: 'Mail',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ TextFormField(
|
|
|
+ controller: _phoneNumber,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ hintText: 'Phone Number',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ TextFormField(
|
|
|
+ controller: _address,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ hintText: 'Home Adress..',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ Row(children: <Widget>[
|
|
|
+ Text('Anonymous'),
|
|
|
+ Checkbox(
|
|
|
+ checkColor: Colors.white,
|
|
|
+ value: anonymous,
|
|
|
+ onChanged: (bool? value) {
|
|
|
+ setState(() {
|
|
|
+ anonymous = value!;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ]),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ ]),
|
|
|
+ )),
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
class SignupForm3 extends StatefulWidget {
|
|
|
@@ -206,7 +231,6 @@ class SignupForm3 extends StatefulWidget {
|
|
|
}
|
|
|
|
|
|
class _SignupForm3 extends State<SignupForm3> {
|
|
|
-
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Scaffold(
|
|
|
@@ -215,41 +239,91 @@ class _SignupForm3 extends State<SignupForm3> {
|
|
|
),
|
|
|
body: Center(
|
|
|
child: SizedBox(
|
|
|
- width: 300,
|
|
|
- child: Column(children: <Widget>[
|
|
|
- const SizedBox(height: 30),
|
|
|
- Text(
|
|
|
- 'User details',
|
|
|
- style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
|
|
- ),
|
|
|
- const SizedBox(height: 30),
|
|
|
- Image.asset(
|
|
|
- 'assets/id-card.png',
|
|
|
- width: 150,
|
|
|
- ),
|
|
|
- const SizedBox(height: 30),
|
|
|
- TextField(
|
|
|
- decoration: InputDecoration(
|
|
|
- hintText: 'Username',
|
|
|
- ),
|
|
|
- ),
|
|
|
- const SizedBox(height: 10),
|
|
|
- TextField(
|
|
|
- decoration: InputDecoration(
|
|
|
- hintText: 'Password',
|
|
|
- ),
|
|
|
- ),
|
|
|
- const SizedBox(height: 10),
|
|
|
- TextField(
|
|
|
- decoration: InputDecoration(
|
|
|
- hintText: 'Repeat password',
|
|
|
- ),
|
|
|
- ),
|
|
|
- const SizedBox(height: 10),
|
|
|
-
|
|
|
- ]),
|
|
|
- )),
|
|
|
+ width: 300,
|
|
|
+ child: Column(children: <Widget>[
|
|
|
+ const SizedBox(height: 30),
|
|
|
+ Text(
|
|
|
+ 'User details',
|
|
|
+ style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 30),
|
|
|
+ Image.asset(
|
|
|
+ 'assets/id-card.png',
|
|
|
+ width: 150,
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 30),
|
|
|
+ TextFormField(
|
|
|
+ controller: _username,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ hintText: 'Username',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ TextFormField(
|
|
|
+ controller: _passwd,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ hintText: 'Password',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ TextFormField(
|
|
|
+ controller: _passwd2,
|
|
|
+ decoration: InputDecoration(
|
|
|
+ hintText: 'Repeat password',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 15),
|
|
|
+ ElevatedButton(
|
|
|
+ onPressed: () {
|
|
|
+ try {
|
|
|
+ if (_passwd.text == _passwd2.text) {
|
|
|
+ createUser();
|
|
|
+ Navigator.pop(context);
|
|
|
+ } else {
|
|
|
+ print("passwd is not the same");
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ print(e.toString());
|
|
|
+ }
|
|
|
+ },
|
|
|
+ child: const Text('Finish Register'))
|
|
|
+ ]),
|
|
|
+ )),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+ void createUser() async {
|
|
|
+ dynamic result =
|
|
|
+ await _auth.createNewUser(_name.text, _mail.text, _passwd.text);
|
|
|
+ if (result == null) {
|
|
|
+ print('mail not valid');
|
|
|
+ } else {
|
|
|
+ //print(result.toString());
|
|
|
+ //[51.787378° N, 19.449455° E]
|
|
|
+
|
|
|
+ print('***** address: ' + _address.text +
|
|
|
+ ' anonymous: ' + anonymous.toString() +
|
|
|
+ ' birthdate: ' + _dateString.toString() +
|
|
|
+ ' createDate: ' + DateTime.now().toString()+
|
|
|
+ ' last_challenge_data: ' + 'null'+
|
|
|
+ ' mail: ' + _mail.text +
|
|
|
+ ' name: ' + _name.text +
|
|
|
+ ' passwd: ' + '??? ' +
|
|
|
+ ' phone_number: ' + _phoneNumber.text+
|
|
|
+ ' shared_id: ' + _username.text +
|
|
|
+ ' surname: ' + _surname.text +
|
|
|
+ ' totalpoints: 0 ' +
|
|
|
+ ' update_date: ' + DateTime.now().toString()+
|
|
|
+ ' weeklyplace: ' + 'null');
|
|
|
+
|
|
|
+ _name.clear();
|
|
|
+ _surname.clear();
|
|
|
+ _mail.clear();
|
|
|
+ _phoneNumber.clear();
|
|
|
+ _address.clear();
|
|
|
+ _username.clear();
|
|
|
+ _passwd.clear();
|
|
|
+ _passwd2.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|