driverLogin.dart 7.9 KB

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