userCustomizedOrder.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. import 'package:flutter/material.dart';
  2. import 'package:intl/intl.dart';
  3. import 'package:putra_go/screens/passenger/userHome/userMatchingDriver.dart';
  4. import '../../../services/auth.dart';
  5. import '../home_page.dart';
  6. class userCustomizedOrder extends StatefulWidget {
  7. @override
  8. _CustomOrderPageState createState() => _CustomOrderPageState();
  9. }
  10. class _CustomOrderPageState extends State<userCustomizedOrder> {
  11. final AuthService _auth = AuthService();
  12. String? selectedRoute;
  13. int? selectedPax;
  14. String? selectedPrice;
  15. DateTime selectedDate = DateTime.now();
  16. final List<String> routes = ['within UPM', 'IOI Mall', 'Sri Serdang'];
  17. final List<int> paxNumbers = [1, 2, 3, 4, 5, 6];
  18. final List<String> prices = ['Price 1', 'Price 2', 'Price 3'];
  19. int routePrice = 0;
  20. String startLoction = '';
  21. Future<void> _selectDateTime(BuildContext context) async {
  22. final DateTime? date = await showDatePicker(
  23. context: context,
  24. initialDate: selectedDate,
  25. firstDate: DateTime.now(),
  26. lastDate: DateTime(2101),
  27. );
  28. if (date == null) return;
  29. final TimeOfDay? time = await showTimePicker(
  30. context: context,
  31. initialTime: TimeOfDay.fromDateTime(selectedDate),
  32. );
  33. if (time == null) return;
  34. setState(() {
  35. selectedDate = DateTime(
  36. date.year,
  37. date.month,
  38. date.day,
  39. time.hour,
  40. time.minute,
  41. );
  42. });
  43. // Here can save the selected date and time to the database
  44. }
  45. @override
  46. Widget build(BuildContext context) {
  47. return Scaffold(
  48. backgroundColor: Colors.white,
  49. //Title
  50. appBar: AppBar(
  51. leading: IconButton(
  52. icon: const Icon(
  53. Icons.chevron_left,
  54. size: 36,
  55. ),
  56. onPressed: () {
  57. Navigator.push(
  58. context,
  59. MaterialPageRoute(builder: (context) => HomePage()),
  60. );
  61. },
  62. ),
  63. //Logout button
  64. actions: <Widget>[
  65. TextButton.icon(
  66. icon: const Icon(Icons.person),
  67. label: const Text('Logout'),
  68. style: TextButton.styleFrom(
  69. foregroundColor: Colors.black, // text color
  70. ),
  71. onPressed: () async {
  72. await _auth.signOut();
  73. },
  74. ),
  75. ],
  76. ),
  77. body:
  78. SingleChildScrollView(
  79. child:
  80. Center(
  81. child: Column(
  82. mainAxisAlignment: MainAxisAlignment.start,
  83. crossAxisAlignment: CrossAxisAlignment.center,
  84. children: <Widget>[
  85. Padding(
  86. padding: const EdgeInsets.all(16.0),
  87. child: Column(
  88. mainAxisSize: MainAxisSize.min,
  89. children: [
  90. const Align(
  91. alignment: Alignment.center,
  92. child: Text(
  93. "Customized your order",
  94. style: TextStyle(
  95. fontFamily: 'Poppins',
  96. fontSize: 30,
  97. fontWeight: FontWeight.bold,
  98. color: Colors.black,
  99. ),
  100. ),
  101. ),
  102. const SizedBox(height: 14),
  103. Container(
  104. width: 334,
  105. height: 52,
  106. padding: const EdgeInsets.symmetric(horizontal: 12),
  107. decoration: BoxDecoration(
  108. borderRadius: BorderRadius.circular(8),
  109. border: Border.all(color: Colors.grey),
  110. ),
  111. child: DropdownButtonFormField<String>(
  112. value: selectedRoute,
  113. decoration: InputDecoration(
  114. border: OutlineInputBorder(
  115. borderRadius: BorderRadius.circular(8),
  116. borderSide: BorderSide.none,
  117. ),
  118. contentPadding: const EdgeInsets.fromLTRB(10, 0, 0, 0),
  119. ),
  120. hint: const Text('Select your route'),
  121. onChanged: (newValue) {
  122. setState(() {
  123. selectedRoute = newValue;
  124. });
  125. // Here, you would usually save the selected 'Pax' to the database
  126. },
  127. items: routes.map((number) {
  128. return DropdownMenuItem(
  129. value: number,
  130. child: Text(number),
  131. );
  132. }).toList(),
  133. ),
  134. ),
  135. const SizedBox(height: 20),
  136. Container(
  137. width: 334,
  138. height: 52,
  139. decoration: BoxDecoration(
  140. borderRadius: BorderRadius.circular(8),
  141. border: Border.all(
  142. color: const Color.fromRGBO(165, 165, 165, 1),
  143. width: 1,
  144. ),
  145. ),
  146. child: Padding(
  147. padding: const EdgeInsets.symmetric(horizontal: 10.0),
  148. child: TextFormField(
  149. decoration: const InputDecoration(
  150. hintText: " Type your start location",
  151. hintStyle: TextStyle(
  152. fontFamily: 'Poppins',
  153. ),
  154. border: InputBorder.none,
  155. ),
  156. style: const TextStyle(
  157. fontFamily: 'Poppins',
  158. // fontSize: 20,
  159. color: Colors.black, // input text color
  160. ),
  161. onChanged: (val) {
  162. startLoction = val;
  163. // need to add startLocation into Database
  164. },
  165. ),
  166. ),
  167. ),
  168. const SizedBox(height: 20),
  169. Container(
  170. width: 334,
  171. height: 50,
  172. decoration: BoxDecoration(
  173. borderRadius: BorderRadius.circular(8),
  174. border: Border.all(
  175. color: const Color.fromRGBO(165, 165, 165, 1),
  176. width: 1,
  177. ),
  178. ),
  179. child: Padding(
  180. padding: const EdgeInsets.symmetric(horizontal: 20.0),
  181. child:
  182. TextFormField(
  183. readOnly: true,
  184. onTap: () => _selectDateTime(context),
  185. decoration: InputDecoration(
  186. hintText: selectedDate != null ? DateFormat.yMd().add_jm().format(selectedDate) : 'Select date and time',
  187. ),
  188. ),
  189. ),
  190. ),
  191. const SizedBox(height: 20),
  192. Container(
  193. width: 334, // Set the width to 334
  194. height: 52, // Set the height to 52
  195. padding: const EdgeInsets.symmetric(horizontal: 12), // You can adjust the horizontal padding if needed
  196. decoration: BoxDecoration(
  197. borderRadius: BorderRadius.circular(8), // Adjust the border radius if needed
  198. border: Border.all(color: Colors.grey), // Add a border with a grey color
  199. ),
  200. child: DropdownButtonFormField<int>(
  201. value: selectedPax,
  202. decoration: InputDecoration(
  203. border: OutlineInputBorder(
  204. borderRadius: BorderRadius.circular(8), // Match the border radius with the Container
  205. borderSide: BorderSide.none, // Use a transparent border side to hide the underline
  206. ),
  207. contentPadding: const EdgeInsets.fromLTRB(11, 0, 0, 0), // Adjust the content padding to center the dropdown value and hint
  208. ),
  209. hint: const Text('Pax (how may persons)'),
  210. onChanged: (newValue) {
  211. setState(() {
  212. selectedPax = newValue;
  213. });
  214. // Here, you would usually save the selected 'Pax' to the database
  215. },
  216. items: paxNumbers.map((number) {
  217. return DropdownMenuItem(
  218. value: number,
  219. child: Text('$number'),
  220. );
  221. }).toList(),
  222. ),
  223. ),
  224. // TextFormField(
  225. // decoration: InputDecoration(
  226. // hintText: "Price",
  227. // hintStyle: TextStyle(
  228. // fontFamily: 'Poppins',
  229. // // fontSize: 20,
  230. // color: Colors.black,
  231. // ),
  232. // border: InputBorder.none,
  233. // ),
  234. // style: TextStyle(
  235. // fontFamily: 'Poppins',
  236. // // fontSize: 20,
  237. // color: Colors.black, // input text color
  238. // ),
  239. // ),
  240. // DropdownButtonFormField<String>(
  241. // value: selectedPrice,
  242. // hint: Text('Price:'),
  243. // onChanged: (newValue) {
  244. // setState(() {
  245. // selectedPrice = newValue;
  246. // });
  247. // // Here, you would usually save the selected 'Price' to the database
  248. // },
  249. // items: prices.map((price) {
  250. // return DropdownMenuItem(
  251. // child: Text(price),
  252. // value: price,
  253. // );
  254. // }).toList(),
  255. // ),
  256. const SizedBox(height: 30),
  257. Container(
  258. width: 334,
  259. height: 65,
  260. decoration: BoxDecoration(
  261. borderRadius: BorderRadius.circular(10),
  262. color: const Color.fromRGBO(119, 97, 255, 1.0),
  263. ),
  264. child: TextButton(
  265. onPressed: () async {
  266. Navigator.push(
  267. context,
  268. MaterialPageRoute(builder: (context) => userMatchingDriver()),
  269. );
  270. },
  271. child: const Text(
  272. 'Countinue',
  273. style: TextStyle(
  274. fontFamily: 'Poppins',
  275. fontSize: 17,
  276. fontWeight: FontWeight.bold,
  277. color: Colors.white,
  278. ),
  279. ),
  280. ),
  281. ),
  282. ],
  283. ),
  284. ),
  285. ],
  286. ),
  287. ),
  288. )
  289. );
  290. }
  291. }