You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

207 lines
6.1 KiB

import 'package:flutter/material.dart';
import 'package:teso/Pages/PageWidgets/Login/signupusername.dart';
import 'package:teso/Pages/Sub_Pages/LandingPage/FinalProcess.dart';
import 'package:teso/providers/pageAnimations.dart';
import 'package:flutter/cupertino.dart';
import 'package:teso/util/consts.dart';
import 'package:teso/Classes/TesoUser.dart';
import 'package:http/http.dart' as http;
class SignUpPage extends StatefulWidget {
@override
_SignUpPageState createState() => _SignUpPageState();
}
class _SignUpPageState extends State<SignUpPage> {
TesoUser newuser = new TesoUser();
TextEditingController user = new TextEditingController();
bool loading = false;
bool taken = false;
@override
void dispose() {
super.dispose();
}
@override
void initState() {
super.initState();
user.addListener(() {
taken = false;
});
}
void startProcessing() async {
setState(() {
loading = true;
});
var client = await http.get(Uri.parse(
serverLocation + "api/username/" + user.text.toString().trim()));
if (client.statusCode == 200) {
newuser.username = user.text;
Navigator.push(
context,
PageTransition(
type: PageTransitionType.rightToLeft,
child: FinalProcess(
newuser: this.newuser,
)),
);
setState(() {
loading = false;
});
} else {
setState(() {
loading = false;
taken = true;
});
}
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.05,
),
height: MediaQuery.of(context).size.height * 0.9,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: new Column(
children: <Widget>[
new Container(
// color: Colors.white,
margin: EdgeInsets.only(
left: 20.0,
top: 20.0,
bottom: 12.0,
),
child: Row(
children: [
Container(
child: InkWell(
onTap: () => Navigator.pop(context),
child: Icon(Icons.close),
),
),
Expanded(
child: Container(
width: double.infinity,
child: Center(
child: Text(
"Create username",
style: TextStyle(
fontSize: 20.0,
color: Colors.black,
),
),
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Divider(
thickness: 0.8,
),
),
Container(
width: double.infinity,
margin: EdgeInsets.only(
bottom: MediaQuery.of(context).size.height * 0.02,
),
child: Center(
child: Text(
"Choose a username for your new account. You can always change it later.",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.grey,
),
),
),
),
SizedBox(
height: 20,
),
usersignup(context, user),
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: taken,
child: Container(
margin: EdgeInsets.only(top: 20),
width: MediaQuery.of(context).size.width * 0.6,
// height: 40.0,
child: Center(
child: Text(
"Username has already been taken...",
style: TextStyle(
color: Colors.red,
),
),
),
),
),
SizedBox(height: MediaQuery.of(context).size.height * 0.001),
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,
),
),
)),
),
),
],
),
),
);
}
}