driverRegister.dart 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. import 'package:flutter/material.dart';
  2. import 'driverMain.dart';
  3. import 'driverResisterSuccess.dart';
  4. class driverRegister extends StatefulWidget {
  5. @override
  6. State<driverRegister> createState() => _userRegisterState();
  7. }
  8. class _userRegisterState extends State<driverRegister> {
  9. // text field state
  10. String name = '';
  11. String email = '';
  12. String phoneNumber = '';
  13. String icNumber = '';
  14. String password = '';
  15. String passwordCheck = '';
  16. // text about car information
  17. String carID = '';
  18. String carBrand = '';
  19. String carColor = '';
  20. @override
  21. Widget build(BuildContext context) {
  22. return Scaffold(
  23. backgroundColor: Colors.white,
  24. appBar: AppBar(
  25. leading: IconButton(
  26. icon: const Icon(
  27. Icons.chevron_left,
  28. size: 36,
  29. ),
  30. onPressed: () {
  31. Navigator.push(
  32. context,
  33. MaterialPageRoute(builder: (context) => driverMain()),
  34. );
  35. },
  36. ),
  37. ),
  38. body:
  39. SingleChildScrollView(
  40. child: Column(
  41. children: <Widget>[
  42. Padding(
  43. padding: const EdgeInsets.all(16.0),
  44. child: Column(
  45. mainAxisAlignment: MainAxisAlignment.start, // Align at the top
  46. crossAxisAlignment: CrossAxisAlignment.center,
  47. children: [
  48. const Align(
  49. alignment: Alignment.centerLeft,
  50. child: Text(
  51. "Register as a Driver..",
  52. style: TextStyle(
  53. fontFamily: 'Poppins',
  54. fontSize: 30,
  55. fontWeight: FontWeight.bold,
  56. color: Colors.black,
  57. ),
  58. ),
  59. ),
  60. // Input name
  61. const SizedBox(height: 10),
  62. Container(
  63. width: 334,
  64. height: 52,
  65. decoration: BoxDecoration(
  66. borderRadius: BorderRadius.circular(8),
  67. color: Colors.white,
  68. border: Border.all(
  69. color: const Color.fromRGBO(165, 165, 165, 1),
  70. width: 1,
  71. ),
  72. ),
  73. child: Padding(
  74. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  75. child: TextFormField(
  76. decoration: const InputDecoration(
  77. hintText: "Name",
  78. hintStyle: TextStyle(
  79. fontFamily: 'Poppins',
  80. fontSize: 20,
  81. color: Color.fromRGBO(165, 165, 165, 1),
  82. ),
  83. border: InputBorder.none,
  84. ),
  85. style: const TextStyle(
  86. fontFamily: 'Poppins',
  87. fontSize: 20,
  88. color: Colors.black, // input text color
  89. ),
  90. validator: (val) => val!.length < 4 ? 'Enter a name more than 3 chars' : null,
  91. onChanged: (val) {
  92. setState(() => name = val);
  93. },
  94. ),
  95. ),
  96. ),
  97. // Input UPM email
  98. const SizedBox(height: 10),
  99. Container(
  100. width: 334,
  101. height: 52,
  102. decoration: BoxDecoration(
  103. borderRadius: BorderRadius.circular(8),
  104. color: Colors.white,
  105. border: Border.all(
  106. color: const Color.fromRGBO(165, 165, 165, 1),
  107. width: 1,
  108. ),
  109. ),
  110. child: Padding(
  111. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  112. child: TextFormField(
  113. decoration: const InputDecoration(
  114. hintText: "UPM email",
  115. hintStyle: TextStyle(
  116. fontFamily: 'Poppins',
  117. fontSize: 20,
  118. color: Color.fromRGBO(165, 165, 165, 1),
  119. ),
  120. border: InputBorder.none,
  121. ),
  122. style: const TextStyle(
  123. fontFamily: 'Poppins',
  124. fontSize: 20,
  125. color: Colors.black, // input text color
  126. ),
  127. validator: (val) =>
  128. val!.isEmpty ? 'Enter your UPM email' : null,
  129. obscureText: false,
  130. onChanged: (val) {
  131. setState(() => email= val);
  132. },
  133. ),
  134. ),
  135. ),
  136. // Input Phone Number
  137. const SizedBox(height: 10),
  138. Container(
  139. width: 334,
  140. height: 52,
  141. decoration: BoxDecoration(
  142. borderRadius: BorderRadius.circular(8),
  143. color: Colors.white,
  144. border: Border.all(
  145. color: const Color.fromRGBO(165, 165, 165, 1),
  146. width: 1,
  147. ),
  148. ),
  149. child: Padding(
  150. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  151. child: TextFormField(
  152. decoration: const InputDecoration(
  153. hintText: "Phone Number (11-, not 011-)",
  154. hintStyle: TextStyle(
  155. fontFamily: 'Poppins',
  156. fontSize: 20,
  157. color: Color.fromRGBO(165, 165, 165, 1),
  158. ),
  159. border: InputBorder.none,
  160. ),
  161. style: const TextStyle(
  162. fontFamily: 'Poppins',
  163. fontSize: 20,
  164. color: Colors.black, // input text color
  165. ),
  166. validator: (val) =>
  167. val!.length != 10 ? 'Enter a valid phone number' : null,
  168. obscureText: false,
  169. onChanged: (val) {
  170. setState(() => phoneNumber = val);
  171. },
  172. ),
  173. ),
  174. ),
  175. // Input IC number
  176. const SizedBox(height: 10),
  177. Container(
  178. width: 334,
  179. height: 52,
  180. decoration: BoxDecoration(
  181. borderRadius: BorderRadius.circular(8),
  182. color: Colors.white,
  183. border: Border.all(
  184. color: const Color.fromRGBO(165, 165, 165, 1),
  185. width: 1,
  186. ),
  187. ),
  188. child: Padding(
  189. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  190. child: TextFormField(
  191. decoration: const InputDecoration(
  192. hintText: "IC Number / Passort Number",
  193. hintStyle: TextStyle(
  194. fontFamily: 'Poppins',
  195. fontSize: 20,
  196. color: Color.fromRGBO(165, 165, 165, 1),
  197. ),
  198. border: InputBorder.none,
  199. ),
  200. style: const TextStyle(
  201. fontFamily: 'Poppins',
  202. fontSize: 20,
  203. color: Colors.black, // input text color
  204. ),
  205. validator: (val) =>
  206. val!.length != 12 || val.length != 9 ? 'Enter a valid IC/Passport Number' : null,
  207. obscureText: false,
  208. onChanged: (val) {
  209. setState(() => icNumber = val);
  210. },
  211. ),
  212. ),
  213. ),
  214. // Input CarID
  215. const SizedBox(height: 10),
  216. Container(
  217. width: 334,
  218. height: 52,
  219. decoration: BoxDecoration(
  220. borderRadius: BorderRadius.circular(8),
  221. color: Colors.white,
  222. border: Border.all(
  223. color: const Color.fromRGBO(165, 165, 165, 1),
  224. width: 1,
  225. ),
  226. ),
  227. child: Padding(
  228. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  229. child: TextFormField(
  230. decoration: const InputDecoration(
  231. hintText: "Car ID (Plate Number)",
  232. hintStyle: TextStyle(
  233. fontFamily: 'Poppins',
  234. fontSize: 20,
  235. color: Color.fromRGBO(165, 165, 165, 1),
  236. ),
  237. border: InputBorder.none,
  238. ),
  239. style: const TextStyle(
  240. fontFamily: 'Poppins',
  241. fontSize: 20,
  242. color: Colors.black, // input text color
  243. ),
  244. validator: (val) => val!.length < 4 ? 'Enter a valid Car ID' : null,
  245. onChanged: (val) {
  246. setState(() => carID = val);
  247. },
  248. ),
  249. ),
  250. ),
  251. // Input Car Brand
  252. const SizedBox(height: 10),
  253. Container(
  254. width: 334,
  255. height: 52,
  256. decoration: BoxDecoration(
  257. borderRadius: BorderRadius.circular(8),
  258. color: Colors.white,
  259. border: Border.all(
  260. color: const Color.fromRGBO(165, 165, 165, 1),
  261. width: 1,
  262. ),
  263. ),
  264. child: Padding(
  265. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  266. child: TextFormField(
  267. decoration: const InputDecoration(
  268. hintText: "Car Brand",
  269. hintStyle: TextStyle(
  270. fontFamily: 'Poppins',
  271. fontSize: 20,
  272. color: Color.fromRGBO(165, 165, 165, 1),
  273. ),
  274. border: InputBorder.none,
  275. ),
  276. style: const TextStyle(
  277. fontFamily: 'Poppins',
  278. fontSize: 20,
  279. color: Colors.black, // input text color
  280. ),
  281. validator: (val) => val!.length < 3 ? 'Enter a valid Car Brand' : null,
  282. onChanged: (val) {
  283. setState(() => carBrand = val);
  284. },
  285. ),
  286. ),
  287. ),
  288. // Input Car Color
  289. const SizedBox(height: 10),
  290. Container(
  291. width: 334,
  292. height: 52,
  293. decoration: BoxDecoration(
  294. borderRadius: BorderRadius.circular(8),
  295. color: Colors.white,
  296. border: Border.all(
  297. color: const Color.fromRGBO(165, 165, 165, 1),
  298. width: 1,
  299. ),
  300. ),
  301. child: Padding(
  302. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  303. child: TextFormField(
  304. decoration: const InputDecoration(
  305. hintText: "Car Color",
  306. hintStyle: TextStyle(
  307. fontFamily: 'Poppins',
  308. fontSize: 20,
  309. color: Color.fromRGBO(165, 165, 165, 1),
  310. ),
  311. border: InputBorder.none,
  312. ),
  313. style: const TextStyle(
  314. fontFamily: 'Poppins',
  315. fontSize: 20,
  316. color: Colors.black, // input text color
  317. ),
  318. validator: (val) => val!.length < 2 ? 'Enter a valid Car Color' : null,
  319. onChanged: (val) {
  320. setState(() => carColor = val);
  321. },
  322. ),
  323. ),
  324. ),
  325. // Input Password
  326. const SizedBox(height: 10),
  327. Container(
  328. width: 334,
  329. height: 52,
  330. decoration: BoxDecoration(
  331. borderRadius: BorderRadius.circular(8),
  332. color: Colors.white,
  333. border: Border.all(
  334. color: const Color.fromRGBO(165, 165, 165, 1),
  335. width: 1,
  336. ),
  337. ),
  338. child: Padding(
  339. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  340. child: TextFormField(
  341. decoration: const InputDecoration(
  342. hintText: "Password",
  343. hintStyle: TextStyle(
  344. fontFamily: 'Poppins',
  345. fontSize: 20,
  346. color: Color.fromRGBO(165, 165, 165, 1),
  347. ),
  348. border: InputBorder.none,
  349. ),
  350. style: const TextStyle(
  351. fontFamily: 'Poppins',
  352. fontSize: 20,
  353. color: Colors.black, // input text color
  354. ),
  355. validator: (val) =>
  356. val!.length < 6 ? 'Enter a password > 6 chars long' : null,
  357. obscureText: true,
  358. onChanged: (val) {
  359. setState(() => password = val);
  360. },
  361. ),
  362. ),
  363. ),
  364. // Check Password
  365. const SizedBox(height: 10),
  366. Container(
  367. width: 334,
  368. height: 52,
  369. decoration: BoxDecoration(
  370. borderRadius: BorderRadius.circular(8),
  371. color: Colors.white,
  372. border: Border.all(
  373. color: const Color.fromRGBO(165, 165, 165, 1),
  374. width: 1,
  375. ),
  376. ),
  377. child: Padding(
  378. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  379. child: TextFormField(
  380. decoration: const InputDecoration(
  381. hintText: "Password again",
  382. hintStyle: TextStyle(
  383. fontFamily: 'Poppins',
  384. fontSize: 20,
  385. color: Color.fromRGBO(165, 165, 165, 1),
  386. ),
  387. border: InputBorder.none,
  388. ),
  389. style: const TextStyle(
  390. fontFamily: 'Poppins',
  391. fontSize: 20,
  392. color: Colors.black, // input text color
  393. ),
  394. validator: (val) =>
  395. val! != password ? 'Passwords are different' : null,
  396. obscureText: true,
  397. ),
  398. ),
  399. ),
  400. // Continue Button
  401. const SizedBox(height: 20),
  402. Container(
  403. width: 334,
  404. height: 65,
  405. decoration: BoxDecoration(
  406. borderRadius: BorderRadius.circular(10),
  407. color: const Color.fromRGBO(119, 97, 255, 1.0),
  408. ),
  409. child: TextButton(
  410. onPressed: () {
  411. // Handle Next button press
  412. Navigator.push(
  413. context,
  414. MaterialPageRoute(builder: (context) => driverRegisterSuccess()),
  415. );
  416. },
  417. child: const Text(
  418. 'Continue',
  419. style: TextStyle(
  420. fontFamily: 'Poppins',
  421. fontSize: 17,
  422. fontWeight: FontWeight.bold,
  423. color: Colors.white,
  424. ),
  425. ),
  426. ),
  427. ),
  428. const SizedBox(height: 10),
  429. ],
  430. ),
  431. ),
  432. ],
  433. ),
  434. )
  435. );
  436. }
  437. }