|
|
|
import 'package:country_list_pick/country_list_pick.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:teso/Pages/Sub_Pages/LandingPage/createPassword.dart';
|
|
|
|
import 'package:teso/providers/pageAnimations.dart';
|
|
|
|
import 'package:teso/Classes/TesoUser.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:teso/util/consts.dart';
|
|
|
|
import 'package:teso/GeneralWidgets/generalInput.dart';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
|
|
|
class FinalProcess extends StatefulWidget {
|
|
|
|
final TesoUser? newuser;
|
|
|
|
const FinalProcess({Key? key, this.newuser}) : super(key: key);
|
|
|
|
@override
|
|
|
|
_FinalProcessState createState() => _FinalProcessState(newuser: this.newuser);
|
|
|
|
}
|
|
|
|
|
|
|
|
class _FinalProcessState extends State<FinalProcess> {
|
|
|
|
TesoUser? newuser;
|
|
|
|
_FinalProcessState({this.newuser});
|
|
|
|
double phoneborder = 1.0;
|
|
|
|
bool phone = true;
|
|
|
|
bool email = false;
|
|
|
|
double mailborder = 0.5;
|
|
|
|
String? countryPrefix = "";
|
|
|
|
TextEditingController firstname = new TextEditingController();
|
|
|
|
TextEditingController surname = new TextEditingController();
|
|
|
|
TextEditingController address = new TextEditingController();
|
|
|
|
TextEditingController emailaddress = new TextEditingController();
|
|
|
|
bool loading = false;
|
|
|
|
|
|
|
|
void _countryPrefix(CountryCode? code) {
|
|
|
|
setState(() {
|
|
|
|
countryPrefix = code!.dialCode;
|
|
|
|
newuser!.country = code.dialCode;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
emailaddress.addListener(() {
|
|
|
|
setState(() {
|
|
|
|
email = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void startProcessing() async {
|
|
|
|
try {
|
|
|
|
setState(() {
|
|
|
|
loading = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
var client = await http.get(Uri.parse(
|
|
|
|
serverLocation + "api/email/" + emailaddress.text.toString().trim()));
|
|
|
|
print(client.body);
|
|
|
|
if (client.statusCode == 200) {
|
|
|
|
newuser!.firstname = firstname.text.trim();
|
|
|
|
newuser!.lastname = surname.text.trim();
|
|
|
|
newuser!.address = "NAN";
|
|
|
|
newuser!.country = countryPrefix;
|
|
|
|
newuser!.email = emailaddress.text.toString().trim();
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
PageTransition(
|
|
|
|
type: PageTransitionType.rightToLeft,
|
|
|
|
child: CreatePassword(
|
|
|
|
newuser: newuser,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
setState(() {
|
|
|
|
loading = false;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setState(() {
|
|
|
|
email = true;
|
|
|
|
loading = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
setState(() {
|
|
|
|
email = true;
|
|
|
|
loading = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: Theme.of(context).primaryColor,
|
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: Theme.of(context).primaryColorDark,
|
|
|
|
leading: IconButton(
|
|
|
|
icon: Icon(Icons.arrow_back_ios),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: Container(
|
|
|
|
height: MediaQuery.of(context).size.height * 0.9,
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
child: new Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
bottom: MediaQuery.of(context).size.height * 0.02,
|
|
|
|
),
|
|
|
|
child: Center(
|
|
|
|
child: Text(
|
|
|
|
"Personnal Information",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(color: Colors.grey, fontSize: 18),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
child: fineText(context, firstname, "Firstname"),
|
|
|
|
),
|
|
|
|
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
|
|
|
|
Container(
|
|
|
|
child: fineText(context, surname, "Lastname"),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
child: fineText(context, emailaddress, "Email"),
|
|
|
|
),
|
|
|
|
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
margin: EdgeInsets.symmetric(
|
|
|
|
horizontal: MediaQuery.of(context).size.width * 0.03),
|
|
|
|
padding: EdgeInsets.only(left: 5, right: 5),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
right: BorderSide(
|
|
|
|
color: Colors.grey,
|
|
|
|
width: 1,
|
|
|
|
),
|
|
|
|
left: BorderSide(
|
|
|
|
color: Colors.grey,
|
|
|
|
width: 1,
|
|
|
|
),
|
|
|
|
top: BorderSide(
|
|
|
|
color: Colors.grey,
|
|
|
|
width: 1,
|
|
|
|
),
|
|
|
|
bottom: BorderSide(
|
|
|
|
color: Colors.grey,
|
|
|
|
width: 1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: new Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Text(
|
|
|
|
"Country",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(color: Colors.grey, fontSize: 15),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
child: CountryListPick(
|
|
|
|
theme: CountryTheme(
|
|
|
|
initialSelection: "Ghana",
|
|
|
|
isShowFlag: true,
|
|
|
|
isShowCode: false,
|
|
|
|
isShowTitle: true),
|
|
|
|
|
|
|
|
//initialSelection: user.currentUser.country,
|
|
|
|
onChanged: (CountryCode? code) =>
|
|
|
|
_countryPrefix(code)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(height: MediaQuery.of(context).size.height * 0.001),
|
|
|
|
Visibility(
|
|
|
|
visible: loading,
|
|
|
|
child: SizedBox(
|
|
|
|
height: MediaQuery.of(context).size.height * 0.025),
|
|
|
|
),
|
|
|
|
Visibility(
|
|
|
|
visible: loading,
|
|
|
|
child: Center(
|
|
|
|
child: CupertinoActivityIndicator(
|
|
|
|
animating: true,
|
|
|
|
radius: 15,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Visibility(
|
|
|
|
visible: email,
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.only(top: 20),
|
|
|
|
width: MediaQuery.of(context).size.width * 0.9,
|
|
|
|
child: Center(
|
|
|
|
child: Text(
|
|
|
|
"Email already exists, if you forgot your password please try to reset your password from the login page!!!",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.red,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Visibility(
|
|
|
|
visible: !loading,
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.only(top: 20),
|
|
|
|
width: MediaQuery.of(context).size.width * 0.6,
|
|
|
|
height: 40.0,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
gradient: LinearGradient(
|
|
|
|
begin: Alignment.topCenter,
|
|
|
|
end: Alignment.bottomCenter,
|
|
|
|
colors: [
|
|
|
|
accentMain,
|
|
|
|
darkAccent,
|
|
|
|
],
|
|
|
|
// stops: [0.1, 0.4, 0.7, 0.8],
|
|
|
|
),
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.grey[500]!,
|
|
|
|
offset: Offset(0.0, 1.5),
|
|
|
|
blurRadius: 1.5,
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
child: Material(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
Radius.circular(25.0),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: startProcessing,
|
|
|
|
child: Center(
|
|
|
|
child: Text(
|
|
|
|
"NEXT",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|