| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- // ignore_for_file: unused_local_variable, unused_field, non_constant_identifier_names, depend_on_referenced_packages
- import 'package:flutter/material.dart';
- import 'package:gozap_package/components/coloredcontainer.dart';
- import 'package:gozap_package/components/icons/gozap_icons.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:intl/intl.dart';
- import 'package:provider/provider.dart';
- import 'package:qr_flutter/qr_flutter.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> {
- int simpleIntInput = 1;
- final String _selectedMenu = '';
- @override
- Widget build(BuildContext context) {
- DashboardController viewController = DashboardController();
- 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.swapModule == null) {
- return const Center(
- child: Text("Somthing went wrong"),
- );
- } 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",
- ),
- ),
- ),
- ),
- 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 riderIDTextWidget = SelectableText(
- "Rider ID - ${viewModel.swapModule!.User.PhoneNumber}",
- style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
- );
- var qrCodeWidget = Card(
- elevation: 10,
- child: ColoredContainer(
- containerColor: AppTheme.whiteColor.withOpacity(0.5),
- child: QrImage(
- data: viewModel.swapModule!.User.PhoneNumber,
- version: QrVersions.auto,
- size: 200.0,
- ),
- ),
- );
- var countCardsWidget = Wrap(
- alignment: WrapAlignment.center,
- runAlignment: WrapAlignment.center,
- crossAxisAlignment: WrapCrossAlignment.center,
- runSpacing: 20,
- spacing: 20,
- children: [
- ColoredContainer(
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(
- GoZAPPIcon.remaing_swaps,
- ),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("Remaing Swaps"),
- Text(
- "${viewModel.swapModule!.RemaingSwap.Available}/${viewModel.swapModule!.RemaingSwap.Total}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- )),
- ColoredContainer(
- containerColor: AppTheme.organeColor.withOpacity(0.2),
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(GoZAPPIcon.free_swaps),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("No. free Swaps"),
- Text(
- "${viewModel.swapModule!.FreeSwap.Available}/${viewModel.swapModule!.FreeSwap.Total}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- )),
- ColoredContainer(
- containerColor: AppTheme.pinkColor.withOpacity(0.2),
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(GoZAPPIcon.month_swaps),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("No. Month Swaps"),
- Text(
- "${viewModel.swapModule!.SwapHistoryMeta.TotalCount}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- )),
- ColoredContainer(
- containerColor: AppTheme.blueColor.withOpacity(0.2),
- child: Row(
- children: [
- const Padding(
- padding: EdgeInsets.all(5),
- child: Icon(GoZAPPIcon.recharged_swaps),
- ),
- Expanded(
- child: Column(
- children: [
- const Text("Recharged Swaps"),
- Text(
- "${viewModel.swapModule!.RechargeSwap.Available}/${viewModel.swapModule!.RechargeSwap.Total}",
- style: const TextStyle(
- fontSize: 18, fontWeight: FontWeight.w700),
- ),
- ],
- ),
- ),
- ],
- )),
- ],
- );
- var swapRechargeCountWidget = Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- const Text(
- "Swaps",
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700),
- ),
- QuantityInput(
- readOnly: true,
- value: simpleIntInput,
- onChanged: (value) => setState(() => simpleIntInput =
- 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),
- )),
- ),
- ],
- );
- return Scaffold(
- 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,
- const SizedBox(
- height: 20,
- ),
- riderIDTextWidget,
- qrCodeWidget,
- const SizedBox(
- height: 20,
- ),
- countCardsWidget,
- const SizedBox(
- height: 20,
- ),
- swapRechargeCountWidget,
- swapReferTextWidget,
- swapReferAndPayButtonWidget
- ],
- ),
- desktopBody: Column(children: [
- topBarWidget,
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- "Dashbaord",
- style: TextStyle(
- fontSize: 24,
- color: AppTheme.primaryColor),
- ),
- ),
- countCardsWidget,
- ],
- )),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.all(20),
- child: Text(
- "Report",
- style: TextStyle(
- fontSize: 24,
- color: AppTheme.primaryColor),
- ),
- ),
- Column(
- children: viewModel.swapModule!
- .SwapHistoryMeta.SwapHistoryList
- .map(
- (History) {
- var date = DateFormat('MMM dd, yyyy')
- .format(History.SwapCreatedAt);
- return ListTile(
- leading: CircleAvatar(
- radius: 5,
- backgroundColor:
- (History.IsFreeSwap)
- ? null
- : AppTheme.redColor,
- ),
- title: Text(History.SwapFormattedCreatedAt));
- },
- ).toList(),
- ),
- ],
- )),
- Expanded(
- child: Column(
- children: [
- Padding(
- padding: const EdgeInsets.all(10),
- child: SelectableText(
- "Rider ID - ${viewModel.swapModule!.User.PhoneNumber}",
- style: TextStyle(
- fontSize: 24,
- color: AppTheme.primaryColor),
- ),
- ),
- qrCodeWidget,
- const SizedBox(
- height: 20,
- ),
- // riderIDTextWidget,
- // const SizedBox(
- // height: 20,
- // ),
- swapRechargeCountWidget,
- swapReferTextWidget,
- swapReferAndPayButtonWidget
- ],
- )),
- ],
- )
- ]),
- ),
- ),
- ),
- )),
- );
- }
- },
- ),
- );
- }
- }
|