123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- import 'package:flutter/material.dart';
- import '../../../services/auth.dart';
- import '../userHome/userCustomizedOrder.dart';
- import '../home_page.dart';
- class userLogin extends StatefulWidget {
- @override
- State<userLogin> createState() => _userLoginState();
- }
- class _userLoginState extends State<userLogin> {
- final AuthService _auth = AuthService();
- final _formKey = GlobalKey<FormState>();
- 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: <Widget>[
- 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),
- ),
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- )
- );
- }
- }
|