| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236 |
- // ignore_for_file: unused_local_variable, unused_field, non_constant_identifier_names, depend_on_referenced_packages
- import 'package:ai_barcode_scanner/ai_barcode_scanner.dart';
- import 'package:buttons_tabbar/buttons_tabbar.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_form_builder/flutter_form_builder.dart';
- import 'package:form_field_validator/form_field_validator.dart';
- import 'package:gozap_package/components/coloredcontainer.dart';
- import 'package:gozap_package/components/icons/gozap_icons.dart';
- import 'package:gozap_package/components/localization/app_translations.dart';
- import 'package:gozap_package/components/quantity_input.dart';
- import 'package:gozap_package/components/responsive.dart';
- import 'package:gozap_package/components/themes/themes.dart';
- import 'package:gozap_package/models/user/user_model.dart';
- import 'package:gozap_package/views/log_in/log_in_view.dart';
- import 'package:gozap_package/views/reports/asset_report.dart';
- import 'package:gozap_package/views/reports/recharge_report.dart';
- import 'package:gozap_package/views/reports/service_report.dart';
- import 'package:gozap_package/views/reports/swap_report.dart';
- import 'package:provider/provider.dart';
- import 'package:toast/toast.dart';
- // import model
- import '/models/dashboard/dashboard_model.dart';
- // import controller
- import '/controllers/dashboard/dashboard_controller.dart';
- enum Menu { itemOne, itemTwo, itemThree, itemFour }
- class DashboardView extends StatefulWidget {
- const DashboardView({super.key});
- @override
- State<DashboardView> createState() => _DashboardViewState();
- }
- class _DashboardViewState extends State<DashboardView>
- with AutomaticKeepAliveClientMixin<DashboardView> {
- @override
- bool get wantKeepAlive => true;
- final _globalOEDashboardSwapKey = GlobalKey<FormBuilderState>();
- final _globalOEDashboardRechargeKey = GlobalKey<FormBuilderState>();
- final _globalOEDashboardServiceKey = GlobalKey<FormBuilderState>();
- final _globalOEDashboardAssetKey = GlobalKey<FormBuilderState>();
- int SwapRechargeCount = 1;
- DateTime? startDate = DateTime.now();
- DateTime? endDate = DateTime.now();
- int selectedIndex = 0;
- DashboardController viewController = DashboardController();
- void onItemTapped(int index) {
- setState(() {
- selectedIndex = index;
- });
- }
- @override
- Widget build(BuildContext context) {
- super.build(context);
- return ChangeNotifierProvider<DashboardModel>(
- create: (context) => DashboardModel.instance(context),
- child: Consumer<DashboardModel>(
- builder: (context, viewModel, child) {
- if (viewModel.status == DashboardModelStatus.Loading) {
- return const Center(
- child: CircularProgressIndicator.adaptive(),
- );
- } else if (viewModel.adminModule == null) {
- return const Center(
- child: Text("Somthing went wrong"),
- );
- } else if (!viewModel.adminModule!.User.IsAdmin) {
- return const Center(child: Text("You are not a admin"));
- } else {
- var topBarWidget = Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- SizedBox(
- child: Card(
- elevation: 10,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(15),
- ),
- child: ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(15)),
- child: Image.asset(
- 'assets/images/logos/gozap_small_color_logo.png',
- width: 50,
- fit: BoxFit.cover,
- package: "gozap_package",
- ),
- ),
- ),
- ),
- Row(
- children: const [],
- ),
- SizedBox(
- width: 50,
- child: Card(
- elevation: 10,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(15),
- ),
- child: ClipRRect(
- borderRadius: const BorderRadius.all(Radius.circular(15)),
- child: PopupMenuButton(
- onSelected: ((Menu item) {
- if (item == Menu.itemFour) {
- Provider.of<userChangeNotifier>(context,
- listen: false)
- .remove(
- context,
- LogInView(
- nextScreen: const DashboardView()));
- }
- }),
- position: PopupMenuPosition.under,
- padding: const EdgeInsets.all(0),
- icon: Image.asset(
- 'assets/images/personal_info_profile.png',
- width: 100,
- fit: BoxFit.cover,
- package: "gozap_package",
- ),
- itemBuilder: (BuildContext context) =>
- <PopupMenuEntry<Menu>>[
- const PopupMenuItem<Menu>(
- value: Menu.itemOne,
- child: Text('Profile'),
- ),
- const PopupMenuItem<Menu>(
- value: Menu.itemTwo,
- child: Text('Swap Report'),
- ),
- const PopupMenuItem<Menu>(
- value: Menu.itemThree,
- child: Text('Recharge Report'),
- ),
- const PopupMenuItem<Menu>(
- value: Menu.itemFour,
- child: Text('Logout'),
- ),
- ]),
- ),
- ),
- ),
- ],
- );
- var totalSwapCountCardWidget = ColoredContainer(
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(
- GoZAPPIcon.admin_total_swaps,
- ),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("Total Swap's"),
- Text(
- "${viewModel.adminModule!.SwapHistoryMeta.TotalCount}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- ));
- var freeSwapCountCardWidget = ColoredContainer(
- containerColor: AppTheme.organeColor.withOpacity(0.2),
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(GoZAPPIcon.admin_free_swaps),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("Free Swap's"),
- Text(
- "${viewModel.adminModule!.SwapHistoryMeta.FreeSwapCount}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- ));
- var paidSwapCountWidget = ColoredContainer(
- containerColor: AppTheme.pinkColor.withOpacity(0.2),
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(GoZAPPIcon.admin_paid_swaps),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("Paid Swap's"),
- Text(
- "${viewModel.adminModule!.SwapHistoryMeta.PaidSwapCount}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- ));
- var rechargeCountWidget = ColoredContainer(
- containerColor: AppTheme.brownColor.withOpacity(0.2),
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(GoZAPPIcon.admin_recharge_swaps),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("Recharge"),
- Text(
- "${viewModel.adminModule!.RechargeHistoryMeta.TotalRechargeCount}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- ));
- var serviceCountWidget = ColoredContainer(
- containerColor: AppTheme.cyanColor.withOpacity(0.2),
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(GoZAPPIcon.service),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("Service"),
- Text(
- "${viewModel.adminModule!.ServiceHistoryMeta.TotalCount}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700)),
- Text(
- "${viewModel.adminModule!.ServiceHistoryMeta.InCompletedCount} / ${viewModel.adminModule!.ServiceHistoryMeta.ServicedCount}",
- style: const TextStyle(
- fontSize: 16, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- ));
- var assetCountWidget = ColoredContainer(
- containerColor: AppTheme.yellowColor.withOpacity(0.2),
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(GoZAPPIcon.asset),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("Asset"),
- Text(
- "${viewModel.adminModule!.AssetMeta.TotalAssetCount}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- ));
- var countCardsWidget = Wrap(
- alignment: WrapAlignment.center,
- runAlignment: WrapAlignment.center,
- crossAxisAlignment: WrapCrossAlignment.center,
- runSpacing: 20,
- spacing: 20,
- children: [
- totalSwapCountCardWidget,
- freeSwapCountCardWidget,
- paidSwapCountWidget,
- rechargeCountWidget,
- serviceCountWidget,
- assetCountWidget
- ],
- );
- var swapRechargeCountWidget = Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- const Text(
- "Swaps",
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700),
- ),
- QuantityInput(
- readOnly: true,
- value: SwapRechargeCount,
- onChanged: (value) => setState(() => SwapRechargeCount =
- int.parse(
- value.replaceAll(',', '').replaceAll('.', '')))),
- ],
- );
- var swapReferTextWidget = const Padding(
- padding: EdgeInsets.all(8.0),
- child: Text("Refer 1 member & get 3 Swaps free"),
- );
- var swapReferAndPayButtonWidget = Row(
- children: [
- Expanded(
- child: OutlinedButton(
- onPressed: () {},
- child: const Text(
- "Refer",
- style: TextStyle(
- fontSize: 16, fontWeight: FontWeight.w500),
- )),
- ),
- const SizedBox(
- width: 10,
- ),
- Expanded(
- child: ElevatedButton(
- onPressed: () {},
- child: const Text(
- "Pay",
- style: TextStyle(
- fontSize: 16, fontWeight: FontWeight.w500),
- )),
- ),
- ],
- );
- var swapFormWidget = Padding(
- padding: const EdgeInsets.all(10),
- child: FormBuilder(
- key: _globalOEDashboardSwapKey,
- onChanged: () async {
- _globalOEDashboardSwapKey.currentState!.save();
- await Future.delayed(const Duration(milliseconds: 500))
- .then((value) {
- try {
- String returenBatteryID = _globalOEDashboardSwapKey
- .currentState?.value["ReturnBatteryID"];
- if (returenBatteryID.isNotEmpty) {
- viewModel.checkAssetForReturnBattery(
- context, returenBatteryID);
- }
- String swapBatteryID = _globalOEDashboardSwapKey
- .currentState?.value["SwapBatteryID"];
- if (swapBatteryID.isNotEmpty) {
- viewModel.checkAssetForSwapBattery(
- context, swapBatteryID);
- }
- } catch (e) {
- // print(e);
- }
- });
- },
- child: Column(
- children: <Widget>[
- //rider ID
- FormBuilderTextField(
- readOnly: true,
- onTap: (() async {
- await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AiBarcodeScanner(
- onScan: (String value) {
- _globalOEDashboardSwapKey
- .currentState!.fields["RiderID"]!
- .didChange(value);
- },
- ),
- ));
- }),
- name: "RiderID",
- inputFormatters: const [],
- validator: MultiValidator([
- RequiredValidator(
- errorText: AppTranslations.of(context)!
- .text("key_field_requird")),
- ]),
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.done,
- decoration: InputDecoration(
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- borderSide:
- const BorderSide(color: Colors.red, width: 0.0),
- ),
- fillColor: Colors.white,
- filled: true,
- prefixIcon: const Icon(
- GoZAPPIcon.rider_id,
- color: Colors.black,
- size: 23.0,
- ),
- hintText: AppTranslations.of(context)!
- .text("key_field_RiderID"),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- //Return Battery
- FormBuilderTextField(
- readOnly: true,
- onTap: (() async {
- await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AiBarcodeScanner(
- onScan: (String value) {
- _globalOEDashboardSwapKey
- .currentState!.fields["ReturnBatteryID"]!
- .didChange(value);
- },
- ),
- ));
- }),
- name: "ReturnBatteryID",
- validator: MultiValidator([
- RequiredValidator(
- errorText: AppTranslations.of(context)!
- .text("key_field_requird")),
- ]),
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.done,
- decoration: InputDecoration(
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- borderSide:
- const BorderSide(color: Colors.red, width: 0.0),
- ),
- fillColor: Colors.white,
- filled: true,
- prefixIcon: const Icon(
- GoZAPPIcon.returning_battery_id,
- color: Colors.black,
- size: 23.0,
- ),
- hintText: AppTranslations.of(context)!
- .text("key_field_ReturnBatteryID"),
- ),
- ),
- Visibility(
- visible: viewModel.swapReturnBatteryErrorText != "",
- child: Text(
- viewModel.swapReturnBatteryErrorText,
- style: TextStyle(color: AppTheme.redColor),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- //Return Battery
- FormBuilderTextField(
- readOnly: true,
- onTap: (() async {
- await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AiBarcodeScanner(
- onScan: (String value) {
- _globalOEDashboardSwapKey
- .currentState!.fields["SwapBatteryID"]!
- .didChange(value);
- },
- ),
- ));
- }),
- name: "SwapBatteryID",
- validator: MultiValidator([
- RequiredValidator(
- errorText: AppTranslations.of(context)!
- .text("key_field_requird")),
- ]),
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.done,
- decoration: InputDecoration(
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- borderSide:
- const BorderSide(color: Colors.red, width: 0.0),
- ),
- fillColor: Colors.white,
- filled: true,
- prefixIcon: const Icon(
- GoZAPPIcon.swap_battery_id,
- color: Colors.black,
- size: 23.0,
- ),
- hintText: AppTranslations.of(context)!
- .text("key_field_SwapBatteryID"),
- ),
- ),
- Visibility(
- visible: viewModel.swapBatteryErrorText != "",
- child: Text(
- viewModel.swapBatteryErrorText,
- style: TextStyle(color: AppTheme.redColor),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- //Login Button
- SizedBox(
- width: double.infinity,
- child: ElevatedButton(
- style: ButtonStyle(
- shape: MaterialStateProperty.all(
- RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10),
- ),
- ),
- ),
- onPressed: () {
- if (_globalOEDashboardSwapKey
- .currentState?.value["SwapBatteryID"] !=
- null &&
- _globalOEDashboardSwapKey.currentState
- ?.value["ReturnBatteryID"] !=
- null &&
- _globalOEDashboardSwapKey
- .currentState?.value["RiderID"] !=
- null) {
- viewModel.swap(
- context,
- data: _globalOEDashboardSwapKey
- .currentState?.value,
- );
- } else {
- Toast.show(
- AppTranslations.of(context)!
- .text("key_field_requird"),
- duration: Toast.lengthLong,
- gravity: Toast.bottom);
- }
- },
- child: Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- AppTranslations.of(context)!
- .text("key_btn_submit"),
- style: const TextStyle(fontSize: 16),
- ),
- )),
- ),
- ],
- ),
- ),
- );
- var rechargeFormWidget = Padding(
- padding: const EdgeInsets.all(10),
- child: FormBuilder(
- key: _globalOEDashboardRechargeKey,
- onChanged: () {
- _globalOEDashboardRechargeKey.currentState!.save();
- },
- child: Column(
- children: <Widget>[
- //rider ID
- FormBuilderTextField(
- readOnly: true,
- onTap: (() async {
- await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AiBarcodeScanner(
- onScan: (String value) {
- _globalOEDashboardRechargeKey
- .currentState!.fields["RechargeRiderID"]!
- .didChange(value);
- },
- ),
- ));
- }),
- name: "RechargeRiderID",
- inputFormatters: const [],
- validator: MultiValidator([
- RequiredValidator(
- errorText: AppTranslations.of(context)!
- .text("key_field_requird")),
- ]),
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.done,
- decoration: InputDecoration(
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- borderSide:
- const BorderSide(color: Colors.red, width: 0.0),
- ),
- fillColor: Colors.white,
- filled: true,
- prefixIcon: const Icon(
- GoZAPPIcon.rider_id,
- color: Colors.black,
- size: 23.0,
- ),
- hintText: AppTranslations.of(context)!
- .text("key_field_RiderID"),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- swapRechargeCountWidget,
- const SizedBox(
- height: 20,
- ),
- FormBuilderDropdown(
- items: const [
- DropdownMenuItem(
- value: "1",
- child: Text("Cash"),
- ),
- DropdownMenuItem(
- value: "2",
- child: Text("UPI"),
- ),
- DropdownMenuItem(
- value: "3",
- child: Text("Card"),
- ),
- ],
- onTap: (() async {}),
- name: "PaymentType",
- validator: MultiValidator([
- RequiredValidator(
- errorText: AppTranslations.of(context)!
- .text("key_field_requird")),
- ]),
- decoration: InputDecoration(
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- borderSide:
- const BorderSide(color: Colors.red, width: 0.0),
- ),
- fillColor: Colors.white,
- filled: true,
- prefixIcon: const Icon(
- GoZAPPIcon.payment_type,
- color: Colors.black,
- size: 23.0,
- ),
- hintText: AppTranslations.of(context)!
- .text("key_field_PaymentType"),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- Visibility(
- visible: false,
- child: FormBuilderTextField(name: "SwapRechargeCount")),
- //Recharge Submit Button
- SizedBox(
- width: double.infinity,
- child: ElevatedButton(
- style: ButtonStyle(
- shape: MaterialStateProperty.all(
- RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10),
- ),
- ),
- ),
- onPressed: () {
- if (_globalOEDashboardRechargeKey.currentState!
- .fields["RechargeRiderID"] !=
- null &&
- _globalOEDashboardRechargeKey
- .currentState?.value["PaymentType"] !=
- null) {
- viewModel.recharge(context,
- data: _globalOEDashboardRechargeKey
- .currentState?.value,
- SwapRechargeCount: SwapRechargeCount);
- } else {
- Toast.show(
- AppTranslations.of(context)!
- .text("key_field_requird"),
- duration: Toast.lengthLong,
- gravity: Toast.bottom);
- }
- },
- child: Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- AppTranslations.of(context)!
- .text("key_btn_submit"),
- style: const TextStyle(fontSize: 16),
- ),
- )),
- ),
- ],
- ),
- ),
- );
- var serviceFormWidget = Padding(
- padding: const EdgeInsets.all(10),
- child: FormBuilder(
- key: _globalOEDashboardServiceKey,
- onChanged: () {
- _globalOEDashboardServiceKey.currentState!.save();
- },
- child: Column(
- children: <Widget>[
- //rider ID
- FormBuilderTextField(
- readOnly: true,
- onTap: (() async {
- await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AiBarcodeScanner(
- onScan: (String value) {
- _globalOEDashboardServiceKey
- .currentState!.fields["ServiceAssetID"]!
- .didChange(value);
- },
- ),
- ));
- }),
- name: "ServiceAssetID",
- inputFormatters: const [],
- validator: MultiValidator([
- RequiredValidator(
- errorText: AppTranslations.of(context)!
- .text("key_field_requird")),
- ]),
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.done,
- decoration: InputDecoration(
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- borderSide:
- const BorderSide(color: Colors.red, width: 0.0),
- ),
- fillColor: Colors.white,
- filled: true,
- prefixIcon: const Icon(
- GoZAPPIcon.asset_id,
- color: Colors.black,
- size: 23.0,
- ),
- hintText: AppTranslations.of(context)!
- .text("key_field_AssetID"),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- //Login Button
- SizedBox(
- width: double.infinity,
- child: ElevatedButton(
- style: ButtonStyle(
- shape: MaterialStateProperty.all(
- RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10),
- ),
- ),
- ),
- onPressed: () {
- if (_globalOEDashboardServiceKey
- .currentState?.value["ServiceAssetID"] !=
- null) {
- viewModel.service(
- context,
- data: _globalOEDashboardServiceKey
- .currentState?.value,
- );
- } else {
- Toast.show(
- AppTranslations.of(context)!
- .text("key_field_requird"),
- duration: Toast.lengthLong,
- gravity: Toast.bottom);
- }
- },
- child: Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- AppTranslations.of(context)!
- .text("key_btn_submit"),
- style: const TextStyle(fontSize: 16),
- ),
- )),
- ),
- ],
- ),
- ),
- );
- var assetsFormWidget = Padding(
- padding: const EdgeInsets.all(10),
- child: FormBuilder(
- key: _globalOEDashboardAssetKey,
- onChanged: () {
- _globalOEDashboardAssetKey.currentState!.save();
- },
- child: Column(
- children: <Widget>[
- //rider ID
- FormBuilderTextField(
- readOnly: true,
- onTap: (() async {
- await Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AiBarcodeScanner(
- onScan: (String value) {
- _globalOEDashboardAssetKey
- .currentState!.fields["AssetID"]!
- .didChange(value);
- },
- ),
- ));
- }),
- name: "AssetID",
- inputFormatters: const [],
- validator: MultiValidator([
- RequiredValidator(
- errorText: AppTranslations.of(context)!
- .text("key_field_requird")),
- ]),
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.done,
- decoration: InputDecoration(
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- borderSide:
- const BorderSide(color: Colors.red, width: 0.0),
- ),
- fillColor: Colors.white,
- filled: true,
- prefixIcon: const Icon(
- GoZAPPIcon.asset_id,
- color: Colors.black,
- size: 23.0,
- ),
- hintText: AppTranslations.of(context)!
- .text("key_field_AssetID"),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- FormBuilderTextField(
- name: "AssetName",
- inputFormatters: const [],
- validator: MultiValidator([
- RequiredValidator(
- errorText: AppTranslations.of(context)!
- .text("key_field_requird")),
- ]),
- keyboardType: TextInputType.text,
- textInputAction: TextInputAction.done,
- decoration: InputDecoration(
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- borderSide:
- const BorderSide(color: Colors.red, width: 0.0),
- ),
- fillColor: Colors.white,
- filled: true,
- prefixIcon: const Icon(
- GoZAPPIcon.asset,
- color: Colors.black,
- size: 23.0,
- ),
- hintText: AppTranslations.of(context)!
- .text("key_field_AssetName"),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- FormBuilderDropdown(
- items: const [
- DropdownMenuItem(
- value: "1",
- child: Text("Battery"),
- ),
- DropdownMenuItem(
- value: "2",
- child: Text("Vehicle"),
- ),
- ],
- onTap: (() async {}),
- name: "AssetCategoryID",
- validator: MultiValidator([
- RequiredValidator(
- errorText: AppTranslations.of(context)!
- .text("key_field_requird")),
- ]),
- decoration: InputDecoration(
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- ),
- errorBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(20.0),
- borderSide:
- const BorderSide(color: Colors.red, width: 0.0),
- ),
- fillColor: Colors.white,
- filled: true,
- prefixIcon: const Icon(
- GoZAPPIcon.asset_category_id,
- color: Colors.black,
- size: 23.0,
- ),
- hintText: AppTranslations.of(context)!
- .text("key_field_AssetCategory"),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- //Login Button
- SizedBox(
- width: double.infinity,
- child: ElevatedButton(
- style: ButtonStyle(
- shape: MaterialStateProperty.all(
- RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10),
- ),
- ),
- ),
- onPressed: () {
- if (_globalOEDashboardAssetKey
- .currentState?.value["AssetID"] !=
- null &&
- _globalOEDashboardAssetKey
- .currentState?.value["AssetName"] !=
- null &&
- _globalOEDashboardAssetKey.currentState
- ?.value["AssetCategoryID"] !=
- null) {
- viewModel.asset(
- context,
- data: _globalOEDashboardAssetKey
- .currentState?.value,
- );
- } else {
- Toast.show(
- AppTranslations.of(context)!
- .text("key_field_requird"),
- duration: Toast.lengthLong,
- gravity: Toast.bottom);
- }
- },
- child: Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- AppTranslations.of(context)!
- .text("key_btn_submit"),
- style: const TextStyle(fontSize: 16),
- ),
- )),
- ),
- ],
- ),
- ),
- );
- var formTabWidget = DefaultTabController(
- length: 4,
- child: Column(
- children: <Widget>[
- ButtonsTabBar(
- backgroundColor: AppTheme.secondaryColor,
- unselectedBackgroundColor: AppTheme.primaryColor,
- labelStyle: TextStyle(color: AppTheme.whiteColor),
- tabs: [
- Tab(
- child: Text(
- 'Swap',
- style: TextStyle(color: AppTheme.whiteColor),
- )),
- Tab(
- child: Text(
- 'Recharge',
- style: TextStyle(color: AppTheme.whiteColor),
- )),
- Tab(
- child: Text(
- 'Service',
- style: TextStyle(color: AppTheme.whiteColor),
- )),
- Tab(
- child: Text(
- 'Assets',
- style: TextStyle(color: AppTheme.whiteColor),
- )),
- ],
- ),
- Expanded(
- child: TabBarView(
- children: [
- swapFormWidget,
- rechargeFormWidget,
- serviceFormWidget,
- assetsFormWidget,
- ],
- ),
- ),
- ],
- ));
- var reportTabWidget = DefaultTabController(
- length: 4,
- child: Column(
- children: <Widget>[
- ButtonsTabBar(
- backgroundColor: AppTheme.secondaryColor,
- unselectedBackgroundColor: AppTheme.primaryColor,
- labelStyle: TextStyle(color: AppTheme.whiteColor),
- tabs: [
- Tab(
- child: Text(
- 'Swap',
- style: TextStyle(color: AppTheme.whiteColor),
- )),
- Tab(
- child: Text(
- 'Recharge',
- style: TextStyle(color: AppTheme.whiteColor),
- )),
- Tab(
- child: Text(
- 'Service',
- style: TextStyle(color: AppTheme.whiteColor),
- )),
- Tab(
- child: Text(
- 'Assets',
- style: TextStyle(color: AppTheme.whiteColor),
- )),
- ],
- ),
- Expanded(
- child: TabBarView(
- children: [
- SwapReportWidget(
- SwapHistoryList: viewModel
- .adminModule!.SwapHistoryMeta.SwapHistoryList,
- ),
- RechargeReportWidget(
- rechargeHistoryModuleList: viewModel.adminModule!
- .RechargeHistoryMeta.RechargeHistoryList),
- ServiceReportWidget(
- serviceHistoryModuleList: viewModel.adminModule!
- .ServiceHistoryMeta.ServiceHistoryList),
- AssetReportWidget(
- assetModuleList:
- viewModel.adminModule!.AssetMeta.AssetList),
- ],
- ),
- ),
- ],
- ),
- );
- final widgetOptions = [
- countCardsWidget,
- formTabWidget,
- reportTabWidget
- ];
- final widgetTitle = ["Dashboard", "Entry", "Report"];
- return Scaffold(
- bottomNavigationBar: !ResponsiveWidget.isDesktop(context)
- ? BottomNavigationBar(
- items: const <BottomNavigationBarItem>[
- BottomNavigationBarItem(
- icon: Icon(
- Icons.dashboard,
- ),
- label: "Dashboard"),
- BottomNavigationBarItem(
- icon: Icon(
- Icons.edit_note,
- ),
- label: "Entry"),
- BottomNavigationBarItem(
- icon: Icon(
- Icons.summarize,
- ),
- label: "Report"),
- ],
- currentIndex: selectedIndex,
- fixedColor: AppTheme.primaryColor,
- onTap: onItemTapped,
- selectedLabelStyle:
- const TextStyle(color: Colors.red, fontSize: 20),
- )
- : null,
- body: SafeArea(
- child: SizedBox(
- width: double.infinity,
- child: SingleChildScrollView(
- scrollDirection: Axis.vertical,
- child: Padding(
- padding: const EdgeInsets.all(15),
- child: ResponsiveWidget(
- mobileBody: Column(
- children: [
- topBarWidget,
- Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- widgetTitle.elementAt(selectedIndex),
- style: TextStyle(
- fontSize: 24, color: AppTheme.primaryColor),
- ),
- ),
- SizedBox(
- height: ResponsiveWidget.fullHeight(context) * .7,
- child: widgetOptions.elementAt(selectedIndex)),
- ],
- ),
- desktopBody: Column(children: [
- topBarWidget,
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- SizedBox(
- width: MediaQuery.of(context).size.width * .2,
- height: MediaQuery.of(context).size.height,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- "Dashbaord",
- style: TextStyle(
- fontSize: 24,
- color: AppTheme.primaryColor),
- ),
- ),
- countCardsWidget,
- ],
- )),
- SizedBox(
- width: MediaQuery.of(context).size.width * .3,
- height: MediaQuery.of(context).size.height,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // //login form
- Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- "Entry",
- style: TextStyle(
- fontSize: 24,
- color: AppTheme.primaryColor),
- ),
- ),
- Expanded(child: formTabWidget),
- ],
- )),
- SizedBox(
- width: MediaQuery.of(context).size.width * .46,
- height: MediaQuery.of(context).size.height,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- //login form
- Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- "Report",
- style: TextStyle(
- fontSize: 24,
- color: AppTheme.primaryColor),
- ),
- ),
- Expanded(child: reportTabWidget),
- ],
- )),
- ],
- )
- ]),
- ),
- ),
- ),
- )),
- );
- }
- },
- ),
- );
- }
- }
|