driverRegister.dart 18 KB

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