123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- import 'dart:convert';
-
- import 'package:flutter_login/flutter_login.dart';
- import 'package:flutter/material.dart';
- import 'package:google_fonts/google_fonts.dart';
- import 'package:http/http.dart' as http;
- import 'dart:convert' as convert;
-
-
-
- //
- //Still to add:
- // Email verification, that the input has "@" and "."
- // Hash the passwords
- // Allow users to login
- // Verify password and confirm password match
- //
-
- class RegisterPage extends StatefulWidget{
-
- RegisterPage({Key key, this.title}) : super(key: key);
- final String title;
-
- @override
- _RegisterPageState createState() => _RegisterPageState();
- }
-
- class _RegisterPageState extends State<RegisterPage> {
- // TextEditingController name = new TextEditingController();
- TextEditingController email = new TextEditingController();
- TextEditingController password = new TextEditingController() ;
- TextEditingController confirmpass = new TextEditingController();
-
-
- Future<List> send_data() async {
-
-
- var url = 'https://ada.uprrp.edu/~hector.sierra/FastMed/API/InsertUser.php';
- final data = await http.post(url, body: {
- "email": email.text,
- "password": password.text,
- });
- print(data.body);
- if("user not registered" == data.body){
- print("maybe we use this");
- }
-
- }
-
- bool _SamePass() {
- if (password.text == confirmpass.text) {
- return true;
- }
- else {
- return false;
- }
- }
-
- _Alerts(BuildContext context){
-
- TextEditingController msg = new TextEditingController();
-
-
- //
- //Useful code for adding pop up messages with animations
- //
- //
-
- // Navigator.of(context).push(
- //
- // PageRouteBuilder(
- // transitionDuration: Duration(seconds: 2),
- // pageBuilder: (context, animation, secAnimation ) => AlertDialog(
- // title: Text("Testing"),
- // elevation: 1,
- // backgroundColor: Colors.transparent,
- //
- // ),
- // opaque: false,
- // )
- //
- // );
-
- showDialog<void>(
- context: context,
- barrierDismissible: false,
- barrierColor: Colors.transparent,
-
- builder: (BuildContext context){
- Future.delayed(Duration(seconds: 2), () {
- Navigator.of(context).pop(true);
- });
-
- return Material(
- color: Colors.transparent,
- child: InkResponse(
- child: Container(
-
- alignment: Alignment.bottomCenter,
- padding: EdgeInsets.only(bottom: 30),
- child: Text(
- "Email address is already registered",
- style: TextStyle(fontSize: 18, color: Colors.red),),
-
- ),
- )
- );
-
- // return Banner(
- // location: BannerLocation.bottomEnd,
- // message: "Hello there",
- //
- // );
-
- // // allows the message to disappear
- // Future.delayed(Duration(seconds: 2), () {
- // Navigator.of(context).pop(true);
- // });
- // return AlertDialog(
- // buttonPadding: ,
- // title: Text("Testing"),
- // elevation: 1,
- // backgroundColor: Colors.transparent,
- // );
- }
- );
- }
-
-
-
- Widget _BackButton(BuildContext context) {
- return InkWell(
- onTap: () {
- Navigator.pop(context);
- },
- child: Row(
- children: <Widget>[
- Container(
- padding: EdgeInsets.only(left: 0, top: 10, bottom: 10),
- child: Icon(Icons.arrow_back_ios, color: Colors.black),
- ),
- Text("Back",
- style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500))
- ]
- ),
- );
- }
-
- Widget _SubmitButton(BuildContext context) {
- return InkResponse(
- onTap: () {
- send_data();
- // _Alert(BuildContext);
- // _Match(context);
- _Alerts(context);
- },
- child: Material(
- borderRadius: BorderRadius.circular(30),
- elevation: 3,
- child: Container(
- padding: EdgeInsets.symmetric(vertical: 10),
- width: 250,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: Colors.red,
- borderRadius: BorderRadius.circular(30),
- ),
-
- child: Text(
- "Submit",
- style: TextStyle(fontSize: 22, color: Colors.white),
- ),
- ),
- ),
- );
- }
-
- Widget _EntryField(String title, TextEditingController controller,
- {bool pass = false}) {
- return Container(
- padding: EdgeInsets.only(left: 0, top: 10, bottom: 10),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
-
- children: <Widget>[
- Text(
- title,
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
- ),
- SizedBox(
- height: 30
- ),
- TextField(
- controller: controller,
- obscureText: pass,
- decoration: InputDecoration(
- border: (
- UnderlineInputBorder()
- ),
- ),
- )
- ]
- ),
-
- );
- }
-
- Widget _Fills() {
- return Column(
- children: <Widget>[
- _EntryField("Email", email),
- _EntryField("Password", password, pass: true),
- _EntryField("Confirm Password", confirmpass, pass: true)
-
- ]
- );
- }
-
- //add column or stack
- @override
- Widget build(BuildContext context) {
- final height = MediaQuery
- .of(context)
- .size
- .height;
- return Scaffold(
- body: Container(
- height: height,
- child: Stack(
-
- children: <Widget>[
- Container(
- padding: EdgeInsets.symmetric(horizontal: 20),
- child: SingleChildScrollView(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- // Text("Username", style: TextStyle(fontSize: 18.0),),
- // TextField(
- // controller: name,
- // decoration: InputDecoration(
- // hintText: 'name'
- // ),
- // ),
- SizedBox(
- height: 700,
- ),
- _Fills(),
- //Add code to verify if password and confirm password match
- SizedBox(
- height: 20,
- ),
- _SubmitButton(context),
- SizedBox(
- height: 10,
- ),
- // ElevatedButton(
- // onPressed: send_data, child: Text("Register")),
- ],
- ),
- )
- ),
- Positioned(
- top: 15, left: 20, child: _BackButton(context),
- ),
- ],
-
- ),
- )
- );
- }
- }
|