dashboard_view.dart 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. // ignore_for_file: unused_local_variable, unused_field, non_constant_identifier_names, depend_on_referenced_packages
  2. import 'package:ai_barcode_scanner/ai_barcode_scanner.dart';
  3. import 'package:buttons_tabbar/buttons_tabbar.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_form_builder/flutter_form_builder.dart';
  6. import 'package:form_field_validator/form_field_validator.dart';
  7. import 'package:gozap_package/components/coloredcontainer.dart';
  8. import 'package:gozap_package/components/icons/gozap_icons.dart';
  9. import 'package:gozap_package/components/localization/app_translations.dart';
  10. import 'package:gozap_package/components/quantity_input.dart';
  11. import 'package:gozap_package/components/responsive.dart';
  12. import 'package:gozap_package/components/themes/themes.dart';
  13. import 'package:gozap_package/models/user/user_model.dart';
  14. import 'package:gozap_package/views/log_in/log_in_view.dart';
  15. import 'package:gozap_package/views/reports/asset_report.dart';
  16. import 'package:gozap_package/views/reports/recharge_report.dart';
  17. import 'package:gozap_package/views/reports/service_report.dart';
  18. import 'package:gozap_package/views/reports/swap_report.dart';
  19. import 'package:provider/provider.dart';
  20. import 'package:toast/toast.dart';
  21. // import model
  22. import '/models/dashboard/dashboard_model.dart';
  23. // import controller
  24. import '/controllers/dashboard/dashboard_controller.dart';
  25. enum Menu { itemOne, itemTwo, itemThree, itemFour }
  26. class DashboardView extends StatefulWidget {
  27. const DashboardView({super.key});
  28. @override
  29. State<DashboardView> createState() => _DashboardViewState();
  30. }
  31. class _DashboardViewState extends State<DashboardView>
  32. with AutomaticKeepAliveClientMixin<DashboardView> {
  33. @override
  34. bool get wantKeepAlive => true;
  35. final _globalOEDashboardSwapKey = GlobalKey<FormBuilderState>();
  36. final _globalOEDashboardRechargeKey = GlobalKey<FormBuilderState>();
  37. final _globalOEDashboardServiceKey = GlobalKey<FormBuilderState>();
  38. final _globalOEDashboardAssetKey = GlobalKey<FormBuilderState>();
  39. int SwapRechargeCount = 1;
  40. DateTime? startDate = DateTime.now();
  41. DateTime? endDate = DateTime.now();
  42. int selectedIndex = 0;
  43. DashboardController viewController = DashboardController();
  44. void onItemTapped(int index) {
  45. setState(() {
  46. selectedIndex = index;
  47. });
  48. }
  49. @override
  50. Widget build(BuildContext context) {
  51. super.build(context);
  52. return ChangeNotifierProvider<DashboardModel>(
  53. create: (context) => DashboardModel.instance(context),
  54. child: Consumer<DashboardModel>(
  55. builder: (context, viewModel, child) {
  56. if (viewModel.status == DashboardModelStatus.Loading) {
  57. return const Center(
  58. child: CircularProgressIndicator.adaptive(),
  59. );
  60. } else if (viewModel.adminModule == null) {
  61. return const Center(
  62. child: Text("Somthing went wrong"),
  63. );
  64. } else if (!viewModel.adminModule!.User.IsAdmin) {
  65. return const Center(child: Text("You are not a admin"));
  66. } else {
  67. var topBarWidget = Row(
  68. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  69. children: [
  70. SizedBox(
  71. child: Card(
  72. elevation: 10,
  73. shape: RoundedRectangleBorder(
  74. borderRadius: BorderRadius.circular(15),
  75. ),
  76. child: ClipRRect(
  77. borderRadius: const BorderRadius.all(Radius.circular(15)),
  78. child: Image.asset(
  79. 'assets/images/logos/gozap_small_color_logo.png',
  80. width: 50,
  81. fit: BoxFit.cover,
  82. package: "gozap_package",
  83. ),
  84. ),
  85. ),
  86. ),
  87. Row(
  88. children: const [],
  89. ),
  90. SizedBox(
  91. width: 50,
  92. child: Card(
  93. elevation: 10,
  94. shape: RoundedRectangleBorder(
  95. borderRadius: BorderRadius.circular(15),
  96. ),
  97. child: ClipRRect(
  98. borderRadius: const BorderRadius.all(Radius.circular(15)),
  99. child: PopupMenuButton(
  100. onSelected: ((Menu item) {
  101. if (item == Menu.itemFour) {
  102. Provider.of<userChangeNotifier>(context,
  103. listen: false)
  104. .remove(
  105. context,
  106. LogInView(
  107. nextScreen: const DashboardView()));
  108. }
  109. }),
  110. position: PopupMenuPosition.under,
  111. padding: const EdgeInsets.all(0),
  112. icon: Image.asset(
  113. 'assets/images/personal_info_profile.png',
  114. width: 100,
  115. fit: BoxFit.cover,
  116. package: "gozap_package",
  117. ),
  118. itemBuilder: (BuildContext context) =>
  119. <PopupMenuEntry<Menu>>[
  120. const PopupMenuItem<Menu>(
  121. value: Menu.itemOne,
  122. child: Text('Profile'),
  123. ),
  124. const PopupMenuItem<Menu>(
  125. value: Menu.itemTwo,
  126. child: Text('Swap Report'),
  127. ),
  128. const PopupMenuItem<Menu>(
  129. value: Menu.itemThree,
  130. child: Text('Recharge Report'),
  131. ),
  132. const PopupMenuItem<Menu>(
  133. value: Menu.itemFour,
  134. child: Text('Logout'),
  135. ),
  136. ]),
  137. ),
  138. ),
  139. ),
  140. ],
  141. );
  142. var totalSwapCountCardWidget = ColoredContainer(
  143. child: Row(
  144. children: [
  145. const Padding(
  146. padding: EdgeInsets.all(5),
  147. child: Icon(
  148. GoZAPPIcon.admin_total_swaps,
  149. ),
  150. ),
  151. Expanded(
  152. child: Column(
  153. children: [
  154. const Text("Total Swap's"),
  155. Text(
  156. "${viewModel.adminModule!.SwapHistoryMeta.TotalCount}",
  157. style: const TextStyle(
  158. fontSize: 18, fontWeight: FontWeight.w700),
  159. ),
  160. ],
  161. ),
  162. ),
  163. ],
  164. ));
  165. var freeSwapCountCardWidget = ColoredContainer(
  166. containerColor: AppTheme.organeColor.withOpacity(0.2),
  167. child: Row(
  168. children: [
  169. const Padding(
  170. padding: EdgeInsets.all(5),
  171. child: Icon(GoZAPPIcon.admin_free_swaps),
  172. ),
  173. Expanded(
  174. child: Column(
  175. children: [
  176. const Text("Free Swap's"),
  177. Text(
  178. "${viewModel.adminModule!.SwapHistoryMeta.FreeSwapCount}",
  179. style: const TextStyle(
  180. fontSize: 18, fontWeight: FontWeight.w700),
  181. ),
  182. ],
  183. ),
  184. ),
  185. ],
  186. ));
  187. var paidSwapCountWidget = ColoredContainer(
  188. containerColor: AppTheme.pinkColor.withOpacity(0.2),
  189. child: Row(
  190. children: [
  191. const Padding(
  192. padding: EdgeInsets.all(5),
  193. child: Icon(GoZAPPIcon.admin_paid_swaps),
  194. ),
  195. Expanded(
  196. child: Column(
  197. children: [
  198. const Text("Paid Swap's"),
  199. Text(
  200. "${viewModel.adminModule!.SwapHistoryMeta.PaidSwapCount}",
  201. style: const TextStyle(
  202. fontSize: 18, fontWeight: FontWeight.w700),
  203. ),
  204. ],
  205. ),
  206. ),
  207. ],
  208. ));
  209. var rechargeCountWidget = ColoredContainer(
  210. containerColor: AppTheme.brownColor.withOpacity(0.2),
  211. child: Row(
  212. children: [
  213. const Padding(
  214. padding: EdgeInsets.all(5),
  215. child: Icon(GoZAPPIcon.admin_recharge_swaps),
  216. ),
  217. Expanded(
  218. child: Column(
  219. children: [
  220. const Text("Recharge"),
  221. Text(
  222. "${viewModel.adminModule!.RechargeHistoryMeta.TotalRechargeCount}",
  223. style: const TextStyle(
  224. fontSize: 18, fontWeight: FontWeight.w700),
  225. ),
  226. ],
  227. ),
  228. ),
  229. ],
  230. ));
  231. var serviceCountWidget = ColoredContainer(
  232. containerColor: AppTheme.cyanColor.withOpacity(0.2),
  233. child: Row(
  234. children: [
  235. const Padding(
  236. padding: EdgeInsets.all(5),
  237. child: Icon(GoZAPPIcon.service),
  238. ),
  239. Expanded(
  240. child: Column(
  241. children: [
  242. const Text("Service"),
  243. Text(
  244. "${viewModel.adminModule!.ServiceHistoryMeta.TotalCount}",
  245. style: const TextStyle(
  246. fontSize: 18, fontWeight: FontWeight.w700)),
  247. Text(
  248. "${viewModel.adminModule!.ServiceHistoryMeta.InCompletedCount} / ${viewModel.adminModule!.ServiceHistoryMeta.ServicedCount}",
  249. style: const TextStyle(
  250. fontSize: 16, fontWeight: FontWeight.w700),
  251. ),
  252. ],
  253. ),
  254. ),
  255. ],
  256. ));
  257. var assetCountWidget = ColoredContainer(
  258. containerColor: AppTheme.yellowColor.withOpacity(0.2),
  259. child: Row(
  260. children: [
  261. const Padding(
  262. padding: EdgeInsets.all(5),
  263. child: Icon(GoZAPPIcon.asset),
  264. ),
  265. Expanded(
  266. child: Column(
  267. children: [
  268. const Text("Asset"),
  269. Text(
  270. "${viewModel.adminModule!.AssetMeta.TotalAssetCount}",
  271. style: const TextStyle(
  272. fontSize: 18, fontWeight: FontWeight.w700),
  273. ),
  274. ],
  275. ),
  276. ),
  277. ],
  278. ));
  279. var countCardsWidget = Wrap(
  280. alignment: WrapAlignment.center,
  281. runAlignment: WrapAlignment.center,
  282. crossAxisAlignment: WrapCrossAlignment.center,
  283. runSpacing: 20,
  284. spacing: 20,
  285. children: [
  286. totalSwapCountCardWidget,
  287. freeSwapCountCardWidget,
  288. paidSwapCountWidget,
  289. rechargeCountWidget,
  290. serviceCountWidget,
  291. assetCountWidget
  292. ],
  293. );
  294. var swapRechargeCountWidget = Row(
  295. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  296. children: [
  297. const Text(
  298. "Swaps",
  299. style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700),
  300. ),
  301. QuantityInput(
  302. readOnly: true,
  303. value: SwapRechargeCount,
  304. onChanged: (value) => setState(() => SwapRechargeCount =
  305. int.parse(
  306. value.replaceAll(',', '').replaceAll('.', '')))),
  307. ],
  308. );
  309. var swapReferTextWidget = const Padding(
  310. padding: EdgeInsets.all(8.0),
  311. child: Text("Refer 1 member & get 3 Swaps free"),
  312. );
  313. var swapReferAndPayButtonWidget = Row(
  314. children: [
  315. Expanded(
  316. child: OutlinedButton(
  317. onPressed: () {},
  318. child: const Text(
  319. "Refer",
  320. style: TextStyle(
  321. fontSize: 16, fontWeight: FontWeight.w500),
  322. )),
  323. ),
  324. const SizedBox(
  325. width: 10,
  326. ),
  327. Expanded(
  328. child: ElevatedButton(
  329. onPressed: () {},
  330. child: const Text(
  331. "Pay",
  332. style: TextStyle(
  333. fontSize: 16, fontWeight: FontWeight.w500),
  334. )),
  335. ),
  336. ],
  337. );
  338. var swapFormWidget = Padding(
  339. padding: const EdgeInsets.all(10),
  340. child: FormBuilder(
  341. key: _globalOEDashboardSwapKey,
  342. onChanged: () async {
  343. _globalOEDashboardSwapKey.currentState!.save();
  344. await Future.delayed(const Duration(milliseconds: 500))
  345. .then((value) {
  346. try {
  347. String returenBatteryID = _globalOEDashboardSwapKey
  348. .currentState?.value["ReturnBatteryID"];
  349. if (returenBatteryID.isNotEmpty) {
  350. viewModel.checkAssetForReturnBattery(
  351. context, returenBatteryID);
  352. }
  353. String swapBatteryID = _globalOEDashboardSwapKey
  354. .currentState?.value["SwapBatteryID"];
  355. if (swapBatteryID.isNotEmpty) {
  356. viewModel.checkAssetForSwapBattery(
  357. context, swapBatteryID);
  358. }
  359. } catch (e) {
  360. // print(e);
  361. }
  362. });
  363. },
  364. child: Column(
  365. children: <Widget>[
  366. //rider ID
  367. FormBuilderTextField(
  368. readOnly: true,
  369. onTap: (() async {
  370. await Navigator.push(
  371. context,
  372. MaterialPageRoute(
  373. builder: (context) => AiBarcodeScanner(
  374. onScan: (String value) {
  375. _globalOEDashboardSwapKey
  376. .currentState!.fields["RiderID"]!
  377. .didChange(value);
  378. },
  379. ),
  380. ));
  381. }),
  382. name: "RiderID",
  383. inputFormatters: const [],
  384. validator: MultiValidator([
  385. RequiredValidator(
  386. errorText: AppTranslations.of(context)!
  387. .text("key_field_requird")),
  388. ]),
  389. keyboardType: TextInputType.text,
  390. textInputAction: TextInputAction.done,
  391. decoration: InputDecoration(
  392. border: OutlineInputBorder(
  393. borderRadius: BorderRadius.circular(20.0),
  394. ),
  395. errorBorder: OutlineInputBorder(
  396. borderRadius: BorderRadius.circular(20.0),
  397. borderSide:
  398. const BorderSide(color: Colors.red, width: 0.0),
  399. ),
  400. fillColor: Colors.white,
  401. filled: true,
  402. prefixIcon: const Icon(
  403. GoZAPPIcon.rider_id,
  404. color: Colors.black,
  405. size: 23.0,
  406. ),
  407. hintText: AppTranslations.of(context)!
  408. .text("key_field_RiderID"),
  409. ),
  410. ),
  411. const SizedBox(
  412. height: 20,
  413. ),
  414. //Return Battery
  415. FormBuilderTextField(
  416. readOnly: true,
  417. onTap: (() async {
  418. await Navigator.push(
  419. context,
  420. MaterialPageRoute(
  421. builder: (context) => AiBarcodeScanner(
  422. onScan: (String value) {
  423. _globalOEDashboardSwapKey
  424. .currentState!.fields["ReturnBatteryID"]!
  425. .didChange(value);
  426. },
  427. ),
  428. ));
  429. }),
  430. name: "ReturnBatteryID",
  431. validator: MultiValidator([
  432. RequiredValidator(
  433. errorText: AppTranslations.of(context)!
  434. .text("key_field_requird")),
  435. ]),
  436. keyboardType: TextInputType.text,
  437. textInputAction: TextInputAction.done,
  438. decoration: InputDecoration(
  439. border: OutlineInputBorder(
  440. borderRadius: BorderRadius.circular(20.0),
  441. ),
  442. errorBorder: OutlineInputBorder(
  443. borderRadius: BorderRadius.circular(20.0),
  444. borderSide:
  445. const BorderSide(color: Colors.red, width: 0.0),
  446. ),
  447. fillColor: Colors.white,
  448. filled: true,
  449. prefixIcon: const Icon(
  450. GoZAPPIcon.returning_battery_id,
  451. color: Colors.black,
  452. size: 23.0,
  453. ),
  454. hintText: AppTranslations.of(context)!
  455. .text("key_field_ReturnBatteryID"),
  456. ),
  457. ),
  458. Visibility(
  459. visible: viewModel.swapReturnBatteryErrorText != "",
  460. child: Text(
  461. viewModel.swapReturnBatteryErrorText,
  462. style: TextStyle(color: AppTheme.redColor),
  463. ),
  464. ),
  465. const SizedBox(
  466. height: 20,
  467. ),
  468. //Return Battery
  469. FormBuilderTextField(
  470. readOnly: true,
  471. onTap: (() async {
  472. await Navigator.push(
  473. context,
  474. MaterialPageRoute(
  475. builder: (context) => AiBarcodeScanner(
  476. onScan: (String value) {
  477. _globalOEDashboardSwapKey
  478. .currentState!.fields["SwapBatteryID"]!
  479. .didChange(value);
  480. },
  481. ),
  482. ));
  483. }),
  484. name: "SwapBatteryID",
  485. validator: MultiValidator([
  486. RequiredValidator(
  487. errorText: AppTranslations.of(context)!
  488. .text("key_field_requird")),
  489. ]),
  490. keyboardType: TextInputType.text,
  491. textInputAction: TextInputAction.done,
  492. decoration: InputDecoration(
  493. border: OutlineInputBorder(
  494. borderRadius: BorderRadius.circular(20.0),
  495. ),
  496. errorBorder: OutlineInputBorder(
  497. borderRadius: BorderRadius.circular(20.0),
  498. borderSide:
  499. const BorderSide(color: Colors.red, width: 0.0),
  500. ),
  501. fillColor: Colors.white,
  502. filled: true,
  503. prefixIcon: const Icon(
  504. GoZAPPIcon.swap_battery_id,
  505. color: Colors.black,
  506. size: 23.0,
  507. ),
  508. hintText: AppTranslations.of(context)!
  509. .text("key_field_SwapBatteryID"),
  510. ),
  511. ),
  512. Visibility(
  513. visible: viewModel.swapBatteryErrorText != "",
  514. child: Text(
  515. viewModel.swapBatteryErrorText,
  516. style: TextStyle(color: AppTheme.redColor),
  517. ),
  518. ),
  519. const SizedBox(
  520. height: 20,
  521. ),
  522. //Login Button
  523. SizedBox(
  524. width: double.infinity,
  525. child: ElevatedButton(
  526. style: ButtonStyle(
  527. shape: MaterialStateProperty.all(
  528. RoundedRectangleBorder(
  529. borderRadius: BorderRadius.circular(10),
  530. ),
  531. ),
  532. ),
  533. onPressed: () {
  534. if (_globalOEDashboardSwapKey
  535. .currentState?.value["SwapBatteryID"] !=
  536. null &&
  537. _globalOEDashboardSwapKey.currentState
  538. ?.value["ReturnBatteryID"] !=
  539. null &&
  540. _globalOEDashboardSwapKey
  541. .currentState?.value["RiderID"] !=
  542. null) {
  543. viewModel.swap(
  544. context,
  545. data: _globalOEDashboardSwapKey
  546. .currentState?.value,
  547. );
  548. } else {
  549. Toast.show(
  550. AppTranslations.of(context)!
  551. .text("key_field_requird"),
  552. duration: Toast.lengthLong,
  553. gravity: Toast.bottom);
  554. }
  555. },
  556. child: Padding(
  557. padding: const EdgeInsets.all(10),
  558. child: Text(
  559. AppTranslations.of(context)!
  560. .text("key_btn_submit"),
  561. style: const TextStyle(fontSize: 16),
  562. ),
  563. )),
  564. ),
  565. ],
  566. ),
  567. ),
  568. );
  569. var rechargeFormWidget = Padding(
  570. padding: const EdgeInsets.all(10),
  571. child: FormBuilder(
  572. key: _globalOEDashboardRechargeKey,
  573. onChanged: () {
  574. _globalOEDashboardRechargeKey.currentState!.save();
  575. },
  576. child: Column(
  577. children: <Widget>[
  578. //rider ID
  579. FormBuilderTextField(
  580. readOnly: true,
  581. onTap: (() async {
  582. await Navigator.push(
  583. context,
  584. MaterialPageRoute(
  585. builder: (context) => AiBarcodeScanner(
  586. onScan: (String value) {
  587. _globalOEDashboardRechargeKey
  588. .currentState!.fields["RechargeRiderID"]!
  589. .didChange(value);
  590. },
  591. ),
  592. ));
  593. }),
  594. name: "RechargeRiderID",
  595. inputFormatters: const [],
  596. validator: MultiValidator([
  597. RequiredValidator(
  598. errorText: AppTranslations.of(context)!
  599. .text("key_field_requird")),
  600. ]),
  601. keyboardType: TextInputType.text,
  602. textInputAction: TextInputAction.done,
  603. decoration: InputDecoration(
  604. border: OutlineInputBorder(
  605. borderRadius: BorderRadius.circular(20.0),
  606. ),
  607. errorBorder: OutlineInputBorder(
  608. borderRadius: BorderRadius.circular(20.0),
  609. borderSide:
  610. const BorderSide(color: Colors.red, width: 0.0),
  611. ),
  612. fillColor: Colors.white,
  613. filled: true,
  614. prefixIcon: const Icon(
  615. GoZAPPIcon.rider_id,
  616. color: Colors.black,
  617. size: 23.0,
  618. ),
  619. hintText: AppTranslations.of(context)!
  620. .text("key_field_RiderID"),
  621. ),
  622. ),
  623. const SizedBox(
  624. height: 20,
  625. ),
  626. swapRechargeCountWidget,
  627. const SizedBox(
  628. height: 20,
  629. ),
  630. FormBuilderDropdown(
  631. items: const [
  632. DropdownMenuItem(
  633. value: "1",
  634. child: Text("Cash"),
  635. ),
  636. DropdownMenuItem(
  637. value: "2",
  638. child: Text("UPI"),
  639. ),
  640. DropdownMenuItem(
  641. value: "3",
  642. child: Text("Card"),
  643. ),
  644. ],
  645. onTap: (() async {}),
  646. name: "PaymentType",
  647. validator: MultiValidator([
  648. RequiredValidator(
  649. errorText: AppTranslations.of(context)!
  650. .text("key_field_requird")),
  651. ]),
  652. decoration: InputDecoration(
  653. border: OutlineInputBorder(
  654. borderRadius: BorderRadius.circular(20.0),
  655. ),
  656. errorBorder: OutlineInputBorder(
  657. borderRadius: BorderRadius.circular(20.0),
  658. borderSide:
  659. const BorderSide(color: Colors.red, width: 0.0),
  660. ),
  661. fillColor: Colors.white,
  662. filled: true,
  663. prefixIcon: const Icon(
  664. GoZAPPIcon.payment_type,
  665. color: Colors.black,
  666. size: 23.0,
  667. ),
  668. hintText: AppTranslations.of(context)!
  669. .text("key_field_PaymentType"),
  670. ),
  671. ),
  672. const SizedBox(
  673. height: 20,
  674. ),
  675. Visibility(
  676. visible: false,
  677. child: FormBuilderTextField(name: "SwapRechargeCount")),
  678. //Recharge Submit Button
  679. SizedBox(
  680. width: double.infinity,
  681. child: ElevatedButton(
  682. style: ButtonStyle(
  683. shape: MaterialStateProperty.all(
  684. RoundedRectangleBorder(
  685. borderRadius: BorderRadius.circular(10),
  686. ),
  687. ),
  688. ),
  689. onPressed: () {
  690. if (_globalOEDashboardRechargeKey.currentState!
  691. .fields["RechargeRiderID"] !=
  692. null &&
  693. _globalOEDashboardRechargeKey
  694. .currentState?.value["PaymentType"] !=
  695. null) {
  696. viewModel.recharge(context,
  697. data: _globalOEDashboardRechargeKey
  698. .currentState?.value,
  699. SwapRechargeCount: SwapRechargeCount);
  700. } else {
  701. Toast.show(
  702. AppTranslations.of(context)!
  703. .text("key_field_requird"),
  704. duration: Toast.lengthLong,
  705. gravity: Toast.bottom);
  706. }
  707. },
  708. child: Padding(
  709. padding: const EdgeInsets.all(10),
  710. child: Text(
  711. AppTranslations.of(context)!
  712. .text("key_btn_submit"),
  713. style: const TextStyle(fontSize: 16),
  714. ),
  715. )),
  716. ),
  717. ],
  718. ),
  719. ),
  720. );
  721. var serviceFormWidget = Padding(
  722. padding: const EdgeInsets.all(10),
  723. child: FormBuilder(
  724. key: _globalOEDashboardServiceKey,
  725. onChanged: () {
  726. _globalOEDashboardServiceKey.currentState!.save();
  727. },
  728. child: Column(
  729. children: <Widget>[
  730. //rider ID
  731. FormBuilderTextField(
  732. readOnly: true,
  733. onTap: (() async {
  734. await Navigator.push(
  735. context,
  736. MaterialPageRoute(
  737. builder: (context) => AiBarcodeScanner(
  738. onScan: (String value) {
  739. _globalOEDashboardServiceKey
  740. .currentState!.fields["ServiceAssetID"]!
  741. .didChange(value);
  742. },
  743. ),
  744. ));
  745. }),
  746. name: "ServiceAssetID",
  747. inputFormatters: const [],
  748. validator: MultiValidator([
  749. RequiredValidator(
  750. errorText: AppTranslations.of(context)!
  751. .text("key_field_requird")),
  752. ]),
  753. keyboardType: TextInputType.text,
  754. textInputAction: TextInputAction.done,
  755. decoration: InputDecoration(
  756. border: OutlineInputBorder(
  757. borderRadius: BorderRadius.circular(20.0),
  758. ),
  759. errorBorder: OutlineInputBorder(
  760. borderRadius: BorderRadius.circular(20.0),
  761. borderSide:
  762. const BorderSide(color: Colors.red, width: 0.0),
  763. ),
  764. fillColor: Colors.white,
  765. filled: true,
  766. prefixIcon: const Icon(
  767. GoZAPPIcon.asset_id,
  768. color: Colors.black,
  769. size: 23.0,
  770. ),
  771. hintText: AppTranslations.of(context)!
  772. .text("key_field_AssetID"),
  773. ),
  774. ),
  775. const SizedBox(
  776. height: 20,
  777. ),
  778. //Login Button
  779. SizedBox(
  780. width: double.infinity,
  781. child: ElevatedButton(
  782. style: ButtonStyle(
  783. shape: MaterialStateProperty.all(
  784. RoundedRectangleBorder(
  785. borderRadius: BorderRadius.circular(10),
  786. ),
  787. ),
  788. ),
  789. onPressed: () {
  790. if (_globalOEDashboardServiceKey
  791. .currentState?.value["ServiceAssetID"] !=
  792. null) {
  793. viewModel.service(
  794. context,
  795. data: _globalOEDashboardServiceKey
  796. .currentState?.value,
  797. );
  798. } else {
  799. Toast.show(
  800. AppTranslations.of(context)!
  801. .text("key_field_requird"),
  802. duration: Toast.lengthLong,
  803. gravity: Toast.bottom);
  804. }
  805. },
  806. child: Padding(
  807. padding: const EdgeInsets.all(10),
  808. child: Text(
  809. AppTranslations.of(context)!
  810. .text("key_btn_submit"),
  811. style: const TextStyle(fontSize: 16),
  812. ),
  813. )),
  814. ),
  815. ],
  816. ),
  817. ),
  818. );
  819. var assetsFormWidget = Padding(
  820. padding: const EdgeInsets.all(10),
  821. child: FormBuilder(
  822. key: _globalOEDashboardAssetKey,
  823. onChanged: () {
  824. _globalOEDashboardAssetKey.currentState!.save();
  825. },
  826. child: Column(
  827. children: <Widget>[
  828. //rider ID
  829. FormBuilderTextField(
  830. readOnly: true,
  831. onTap: (() async {
  832. await Navigator.push(
  833. context,
  834. MaterialPageRoute(
  835. builder: (context) => AiBarcodeScanner(
  836. onScan: (String value) {
  837. _globalOEDashboardAssetKey
  838. .currentState!.fields["AssetID"]!
  839. .didChange(value);
  840. },
  841. ),
  842. ));
  843. }),
  844. name: "AssetID",
  845. inputFormatters: const [],
  846. validator: MultiValidator([
  847. RequiredValidator(
  848. errorText: AppTranslations.of(context)!
  849. .text("key_field_requird")),
  850. ]),
  851. keyboardType: TextInputType.text,
  852. textInputAction: TextInputAction.done,
  853. decoration: InputDecoration(
  854. border: OutlineInputBorder(
  855. borderRadius: BorderRadius.circular(20.0),
  856. ),
  857. errorBorder: OutlineInputBorder(
  858. borderRadius: BorderRadius.circular(20.0),
  859. borderSide:
  860. const BorderSide(color: Colors.red, width: 0.0),
  861. ),
  862. fillColor: Colors.white,
  863. filled: true,
  864. prefixIcon: const Icon(
  865. GoZAPPIcon.asset_id,
  866. color: Colors.black,
  867. size: 23.0,
  868. ),
  869. hintText: AppTranslations.of(context)!
  870. .text("key_field_AssetID"),
  871. ),
  872. ),
  873. const SizedBox(
  874. height: 20,
  875. ),
  876. FormBuilderTextField(
  877. name: "AssetName",
  878. inputFormatters: const [],
  879. validator: MultiValidator([
  880. RequiredValidator(
  881. errorText: AppTranslations.of(context)!
  882. .text("key_field_requird")),
  883. ]),
  884. keyboardType: TextInputType.text,
  885. textInputAction: TextInputAction.done,
  886. decoration: InputDecoration(
  887. border: OutlineInputBorder(
  888. borderRadius: BorderRadius.circular(20.0),
  889. ),
  890. errorBorder: OutlineInputBorder(
  891. borderRadius: BorderRadius.circular(20.0),
  892. borderSide:
  893. const BorderSide(color: Colors.red, width: 0.0),
  894. ),
  895. fillColor: Colors.white,
  896. filled: true,
  897. prefixIcon: const Icon(
  898. GoZAPPIcon.asset,
  899. color: Colors.black,
  900. size: 23.0,
  901. ),
  902. hintText: AppTranslations.of(context)!
  903. .text("key_field_AssetName"),
  904. ),
  905. ),
  906. const SizedBox(
  907. height: 20,
  908. ),
  909. FormBuilderDropdown(
  910. items: const [
  911. DropdownMenuItem(
  912. value: "1",
  913. child: Text("Battery"),
  914. ),
  915. DropdownMenuItem(
  916. value: "2",
  917. child: Text("Vehicle"),
  918. ),
  919. ],
  920. onTap: (() async {}),
  921. name: "AssetCategoryID",
  922. validator: MultiValidator([
  923. RequiredValidator(
  924. errorText: AppTranslations.of(context)!
  925. .text("key_field_requird")),
  926. ]),
  927. decoration: InputDecoration(
  928. border: OutlineInputBorder(
  929. borderRadius: BorderRadius.circular(20.0),
  930. ),
  931. errorBorder: OutlineInputBorder(
  932. borderRadius: BorderRadius.circular(20.0),
  933. borderSide:
  934. const BorderSide(color: Colors.red, width: 0.0),
  935. ),
  936. fillColor: Colors.white,
  937. filled: true,
  938. prefixIcon: const Icon(
  939. GoZAPPIcon.asset_category_id,
  940. color: Colors.black,
  941. size: 23.0,
  942. ),
  943. hintText: AppTranslations.of(context)!
  944. .text("key_field_AssetCategory"),
  945. ),
  946. ),
  947. const SizedBox(
  948. height: 20,
  949. ),
  950. //Login Button
  951. SizedBox(
  952. width: double.infinity,
  953. child: ElevatedButton(
  954. style: ButtonStyle(
  955. shape: MaterialStateProperty.all(
  956. RoundedRectangleBorder(
  957. borderRadius: BorderRadius.circular(10),
  958. ),
  959. ),
  960. ),
  961. onPressed: () {
  962. if (_globalOEDashboardAssetKey
  963. .currentState?.value["AssetID"] !=
  964. null &&
  965. _globalOEDashboardAssetKey
  966. .currentState?.value["AssetName"] !=
  967. null &&
  968. _globalOEDashboardAssetKey.currentState
  969. ?.value["AssetCategoryID"] !=
  970. null) {
  971. viewModel.asset(
  972. context,
  973. data: _globalOEDashboardAssetKey
  974. .currentState?.value,
  975. );
  976. } else {
  977. Toast.show(
  978. AppTranslations.of(context)!
  979. .text("key_field_requird"),
  980. duration: Toast.lengthLong,
  981. gravity: Toast.bottom);
  982. }
  983. },
  984. child: Padding(
  985. padding: const EdgeInsets.all(10),
  986. child: Text(
  987. AppTranslations.of(context)!
  988. .text("key_btn_submit"),
  989. style: const TextStyle(fontSize: 16),
  990. ),
  991. )),
  992. ),
  993. ],
  994. ),
  995. ),
  996. );
  997. var formTabWidget = DefaultTabController(
  998. length: 4,
  999. child: Column(
  1000. children: <Widget>[
  1001. ButtonsTabBar(
  1002. backgroundColor: AppTheme.secondaryColor,
  1003. unselectedBackgroundColor: AppTheme.primaryColor,
  1004. labelStyle: TextStyle(color: AppTheme.whiteColor),
  1005. tabs: [
  1006. Tab(
  1007. child: Text(
  1008. 'Swap',
  1009. style: TextStyle(color: AppTheme.whiteColor),
  1010. )),
  1011. Tab(
  1012. child: Text(
  1013. 'Recharge',
  1014. style: TextStyle(color: AppTheme.whiteColor),
  1015. )),
  1016. Tab(
  1017. child: Text(
  1018. 'Service',
  1019. style: TextStyle(color: AppTheme.whiteColor),
  1020. )),
  1021. Tab(
  1022. child: Text(
  1023. 'Assets',
  1024. style: TextStyle(color: AppTheme.whiteColor),
  1025. )),
  1026. ],
  1027. ),
  1028. Expanded(
  1029. child: TabBarView(
  1030. children: [
  1031. swapFormWidget,
  1032. rechargeFormWidget,
  1033. serviceFormWidget,
  1034. assetsFormWidget,
  1035. ],
  1036. ),
  1037. ),
  1038. ],
  1039. ));
  1040. var reportTabWidget = DefaultTabController(
  1041. length: 4,
  1042. child: Column(
  1043. children: <Widget>[
  1044. ButtonsTabBar(
  1045. backgroundColor: AppTheme.secondaryColor,
  1046. unselectedBackgroundColor: AppTheme.primaryColor,
  1047. labelStyle: TextStyle(color: AppTheme.whiteColor),
  1048. tabs: [
  1049. Tab(
  1050. child: Text(
  1051. 'Swap',
  1052. style: TextStyle(color: AppTheme.whiteColor),
  1053. )),
  1054. Tab(
  1055. child: Text(
  1056. 'Recharge',
  1057. style: TextStyle(color: AppTheme.whiteColor),
  1058. )),
  1059. Tab(
  1060. child: Text(
  1061. 'Service',
  1062. style: TextStyle(color: AppTheme.whiteColor),
  1063. )),
  1064. Tab(
  1065. child: Text(
  1066. 'Assets',
  1067. style: TextStyle(color: AppTheme.whiteColor),
  1068. )),
  1069. ],
  1070. ),
  1071. Expanded(
  1072. child: TabBarView(
  1073. children: [
  1074. SwapReportWidget(
  1075. SwapHistoryList: viewModel
  1076. .adminModule!.SwapHistoryMeta.SwapHistoryList,
  1077. ),
  1078. RechargeReportWidget(
  1079. rechargeHistoryModuleList: viewModel.adminModule!
  1080. .RechargeHistoryMeta.RechargeHistoryList),
  1081. ServiceReportWidget(
  1082. serviceHistoryModuleList: viewModel.adminModule!
  1083. .ServiceHistoryMeta.ServiceHistoryList),
  1084. AssetReportWidget(
  1085. assetModuleList:
  1086. viewModel.adminModule!.AssetMeta.AssetList),
  1087. ],
  1088. ),
  1089. ),
  1090. ],
  1091. ),
  1092. );
  1093. final widgetOptions = [
  1094. countCardsWidget,
  1095. formTabWidget,
  1096. reportTabWidget
  1097. ];
  1098. final widgetTitle = ["Dashboard", "Entry", "Report"];
  1099. return Scaffold(
  1100. bottomNavigationBar: !ResponsiveWidget.isDesktop(context)
  1101. ? BottomNavigationBar(
  1102. items: const <BottomNavigationBarItem>[
  1103. BottomNavigationBarItem(
  1104. icon: Icon(
  1105. Icons.dashboard,
  1106. ),
  1107. label: "Dashboard"),
  1108. BottomNavigationBarItem(
  1109. icon: Icon(
  1110. Icons.edit_note,
  1111. ),
  1112. label: "Entry"),
  1113. BottomNavigationBarItem(
  1114. icon: Icon(
  1115. Icons.summarize,
  1116. ),
  1117. label: "Report"),
  1118. ],
  1119. currentIndex: selectedIndex,
  1120. fixedColor: AppTheme.primaryColor,
  1121. onTap: onItemTapped,
  1122. selectedLabelStyle:
  1123. const TextStyle(color: Colors.red, fontSize: 20),
  1124. )
  1125. : null,
  1126. body: SafeArea(
  1127. child: SizedBox(
  1128. width: double.infinity,
  1129. child: SingleChildScrollView(
  1130. scrollDirection: Axis.vertical,
  1131. child: Padding(
  1132. padding: const EdgeInsets.all(15),
  1133. child: ResponsiveWidget(
  1134. mobileBody: Column(
  1135. children: [
  1136. topBarWidget,
  1137. Padding(
  1138. padding: const EdgeInsets.all(10),
  1139. child: Text(
  1140. widgetTitle.elementAt(selectedIndex),
  1141. style: TextStyle(
  1142. fontSize: 24, color: AppTheme.primaryColor),
  1143. ),
  1144. ),
  1145. SizedBox(
  1146. height: ResponsiveWidget.fullHeight(context) * .7,
  1147. child: widgetOptions.elementAt(selectedIndex)),
  1148. ],
  1149. ),
  1150. desktopBody: Column(children: [
  1151. topBarWidget,
  1152. Row(
  1153. crossAxisAlignment: CrossAxisAlignment.start,
  1154. children: [
  1155. SizedBox(
  1156. width: MediaQuery.of(context).size.width * .2,
  1157. height: MediaQuery.of(context).size.height,
  1158. child: Column(
  1159. crossAxisAlignment: CrossAxisAlignment.start,
  1160. children: [
  1161. Padding(
  1162. padding: const EdgeInsets.all(10),
  1163. child: Text(
  1164. "Dashbaord",
  1165. style: TextStyle(
  1166. fontSize: 24,
  1167. color: AppTheme.primaryColor),
  1168. ),
  1169. ),
  1170. countCardsWidget,
  1171. ],
  1172. )),
  1173. SizedBox(
  1174. width: MediaQuery.of(context).size.width * .3,
  1175. height: MediaQuery.of(context).size.height,
  1176. child: Column(
  1177. crossAxisAlignment: CrossAxisAlignment.start,
  1178. children: [
  1179. // //login form
  1180. Padding(
  1181. padding: const EdgeInsets.all(10),
  1182. child: Text(
  1183. "Entry",
  1184. style: TextStyle(
  1185. fontSize: 24,
  1186. color: AppTheme.primaryColor),
  1187. ),
  1188. ),
  1189. Expanded(child: formTabWidget),
  1190. ],
  1191. )),
  1192. SizedBox(
  1193. width: MediaQuery.of(context).size.width * .46,
  1194. height: MediaQuery.of(context).size.height,
  1195. child: Column(
  1196. crossAxisAlignment: CrossAxisAlignment.start,
  1197. children: [
  1198. //login form
  1199. Padding(
  1200. padding: const EdgeInsets.all(10),
  1201. child: Text(
  1202. "Report",
  1203. style: TextStyle(
  1204. fontSize: 24,
  1205. color: AppTheme.primaryColor),
  1206. ),
  1207. ),
  1208. Expanded(child: reportTabWidget),
  1209. ],
  1210. )),
  1211. ],
  1212. )
  1213. ]),
  1214. ),
  1215. ),
  1216. ),
  1217. )),
  1218. );
  1219. }
  1220. },
  1221. ),
  1222. );
  1223. }
  1224. }