import 'package:flutter/material.dart'; import '../../../services/auth.dart'; import '../userHome/userCustomizedOrder.dart'; import '../home_page.dart'; class userLogin extends StatefulWidget { @override State createState() => _userLoginState(); } class _userLoginState extends State { final AuthService _auth = AuthService(); final _formKey = GlobalKey(); String error = ''; bool loading = false; // text field state String email = ''; String password = ''; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( leading: //back to previous page IconButton( icon: const Icon( Icons.chevron_left, size: 36, ), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => const HomePage()), ); }, ), ), body: SingleChildScrollView( child: Column( children: [ Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, // Align at the top crossAxisAlignment: CrossAxisAlignment.center, children: [ // Title: Login const Align( alignment: Alignment.centerLeft, child: Text( "Login", style: TextStyle( fontFamily: 'Poppins', fontSize: 30, fontWeight: FontWeight.bold, color: Colors.black, ), ), ), // Input student email const SizedBox(height: 10), Container( width: 334, height: 52, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Colors.white, border: Border.all( color: const Color.fromRGBO(165, 165, 165, 1), width: 1, ), ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: TextFormField( decoration: const InputDecoration( hintText: "UPM Email", hintStyle: TextStyle( fontFamily: 'Poppins', fontSize: 20, color: Color.fromRGBO(165, 165, 165, 1), ), border: InputBorder.none, ), style: const TextStyle( fontFamily: 'Poppins', fontSize: 20, color: Colors.black, // input text color ), validator: (val) => val!.isEmpty ? 'Enter a student email' : null, onChanged: (val) { setState(() => email = val); }, ), ), ), // Input Password const SizedBox(height: 10), Container( width: 334, height: 52, decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), color: Colors.white, border: Border.all( color: const Color.fromRGBO(165, 165, 165, 1), width: 1, ), ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: TextFormField( decoration: const InputDecoration( hintText: "Password", hintStyle: TextStyle( fontFamily: 'Poppins', fontSize: 20, color: Color.fromRGBO(165, 165, 165, 1), ), border: InputBorder.none, ), style: const TextStyle( fontFamily: 'Poppins', fontSize: 20, color: Colors.black, // input text color ), validator: (val) => val!.length < 6 ? 'Enter a password 6+ chars long' : null, obscureText: true, onChanged: (val) { setState(() => password = val); }, ), ), ), // Login const SizedBox(height: 20), Container( width: 334, height: 65, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: const Color.fromRGBO(119, 97, 255, 1.0), ), child: TextButton( onPressed: () async { Navigator.push( context, MaterialPageRoute(builder: (context) => userCustomizedOrder()), ); // print(email); // print(password); // if (_formKey.currentState!.validate()) { // setState(() => loading = true); // dynamic result = await _auth.signInWithEmailAndPassword(email, password); // if (result == null) { // setState(() { // setState(() { // loading = false; // error = 'Could not sign in with those credentials'; // }); // }); // } // } }, child: const Text( 'Continue', style: TextStyle( fontFamily: 'Poppins', fontSize: 17, fontWeight: FontWeight.bold, color: Colors.white, ), ), ), ), // Forget Password little button const SizedBox(height: 10), TextButton( onPressed: () { // Handle forgot password button press }, child: const Text( 'Forgot password', style: TextStyle( fontFamily: 'Poppins', fontSize: 17, fontWeight: FontWeight.w500, decoration: TextDecoration.underline, color: Color.fromRGBO(119, 97, 255, 1.0), ), ), ), ], ), ), ], ), ) ); } }