driverLogin.dart 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import 'package:flutter/material.dart';
  2. import '../../../services/auth.dart';
  3. import 'driverHome/driverSelectOrder.dart';
  4. import 'driverMain.dart';
  5. class driverLogin extends StatefulWidget {
  6. @override
  7. State<driverLogin> createState() => _userLoginState();
  8. }
  9. class _userLoginState extends State<driverLogin> {
  10. final AuthService _auth = AuthService();
  11. final _formKey = GlobalKey<FormState>();
  12. String error = '';
  13. bool loading = false;
  14. // text field state
  15. String email = '';
  16. String password = '';
  17. @override
  18. Widget build(BuildContext context) {
  19. return Scaffold(
  20. backgroundColor: Colors.white,
  21. appBar: AppBar(
  22. leading: IconButton(
  23. icon: const Icon(
  24. Icons.chevron_left,
  25. size: 36,
  26. ),
  27. onPressed: () {
  28. Navigator.push(
  29. context,
  30. MaterialPageRoute(builder: (context) => driverMain()),
  31. );
  32. },
  33. ),
  34. ),
  35. body:
  36. SingleChildScrollView(
  37. child: Column(
  38. children: <Widget>[
  39. Padding(
  40. padding: const EdgeInsets.all(16.0),
  41. child: Column(
  42. mainAxisAlignment: MainAxisAlignment.start, // Align at the top
  43. crossAxisAlignment: CrossAxisAlignment.center,
  44. children: [
  45. // Title: Login
  46. const Align(
  47. alignment: Alignment.centerLeft,
  48. child: Text(
  49. "Driver Login",
  50. style: TextStyle(
  51. fontFamily: 'Poppins',
  52. fontSize: 30,
  53. fontWeight: FontWeight.bold,
  54. color: Colors.black,
  55. ),
  56. ),
  57. ),
  58. // Input student email
  59. const SizedBox(height: 10),
  60. Container(
  61. width: 334,
  62. height: 52,
  63. decoration: BoxDecoration(
  64. borderRadius: BorderRadius.circular(8),
  65. color: Colors.white,
  66. border: Border.all(
  67. color: const Color.fromRGBO(165, 165, 165, 1),
  68. width: 1,
  69. ),
  70. ),
  71. child: Padding(
  72. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  73. child: TextFormField(
  74. decoration: const InputDecoration(
  75. hintText: "UPM Email",
  76. hintStyle: TextStyle(
  77. fontFamily: 'Poppins',
  78. fontSize: 20,
  79. color: Color.fromRGBO(165, 165, 165, 1),
  80. ),
  81. border: InputBorder.none,
  82. ),
  83. style: const TextStyle(
  84. fontFamily: 'Poppins',
  85. fontSize: 20,
  86. color: Colors.black, // input text color
  87. ),
  88. validator: (val) => val!.isEmpty ? 'Enter a student email' : null,
  89. onChanged: (val) {
  90. setState(() => email = val);
  91. },
  92. ),
  93. ),
  94. ),
  95. // Input Password
  96. const SizedBox(height: 10),
  97. Container(
  98. width: 334,
  99. height: 52,
  100. decoration: BoxDecoration(
  101. borderRadius: BorderRadius.circular(8),
  102. color: Colors.white,
  103. border: Border.all(
  104. color: const Color.fromRGBO(165, 165, 165, 1),
  105. width: 1,
  106. ),
  107. ),
  108. child: Padding(
  109. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  110. child: TextFormField(
  111. decoration: const InputDecoration(
  112. hintText: "Password",
  113. hintStyle: TextStyle(
  114. fontFamily: 'Poppins',
  115. fontSize: 20,
  116. color: Color.fromRGBO(165, 165, 165, 1),
  117. ),
  118. border: InputBorder.none,
  119. ),
  120. style: const TextStyle(
  121. fontFamily: 'Poppins',
  122. fontSize: 20,
  123. color: Colors.black, // input text color
  124. ),
  125. validator: (val) =>
  126. val!.length < 6 ? 'Enter a password 6+ chars long' : null,
  127. obscureText: true,
  128. onChanged: (val) {
  129. setState(() => password = val);
  130. },
  131. ),
  132. ),
  133. ),
  134. //Check the Auth
  135. const SizedBox(height: 20),
  136. Container(
  137. width: 334,
  138. height: 65,
  139. decoration: BoxDecoration(
  140. borderRadius: BorderRadius.circular(10),
  141. color: const Color.fromRGBO(119, 97, 255, 1.0),
  142. ),
  143. child: TextButton(
  144. onPressed: () async {
  145. Navigator.push(
  146. context,
  147. MaterialPageRoute(builder: (context) => driverSelectOrder()),
  148. );
  149. // if (_formKey.currentState!.validate()) {
  150. // setState(() => loading = true);
  151. // dynamic result = await _auth.signInWithEmailAndPassword(email, password);
  152. // if (result == null) {
  153. // setState(() {
  154. // setState(() {
  155. // loading = false;
  156. // error = 'Could not sign in with those credentials';
  157. // });
  158. // });
  159. // }
  160. // }
  161. },
  162. child: const Text(
  163. 'Continue',
  164. style: TextStyle(
  165. fontFamily: 'Poppins',
  166. fontSize: 17,
  167. fontWeight: FontWeight.bold,
  168. color: Colors.white,
  169. ),
  170. ),
  171. ),
  172. ),
  173. // Forget Password little button
  174. const SizedBox(height: 10),
  175. TextButton(
  176. onPressed: () {
  177. // Navigator.push(
  178. // context,
  179. // MaterialPageRoute(builder: (context) => driverSelectOrder()),
  180. // );
  181. },
  182. child: const Text(
  183. 'Forgot password',
  184. style: TextStyle(
  185. fontFamily: 'Poppins',
  186. fontSize: 17,
  187. fontWeight: FontWeight.w500,
  188. decoration: TextDecoration.underline,
  189. color: Color.fromRGBO(119, 97, 255, 1.0),
  190. ),
  191. ),
  192. ),
  193. ],
  194. ),
  195. ),
  196. ],
  197. ),
  198. )
  199. );
  200. }
  201. }