From bdff05c99250ae45ddf30d1897d8b4c0e6ed2cdb Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Mon, 10 Mar 2025 11:01:53 +0200 Subject: [PATCH] delete old version of wallet --- .../mzansi_wallet/loyalty_cards.dart | 358 ------------------ .../mzansi_wallet/mzansi_wallet.dart | 179 --------- 2 files changed, 537 deletions(-) delete mode 100644 Frontend/lib/mih_packages/mzansi_wallet/loyalty_cards.dart delete mode 100644 Frontend/lib/mih_packages/mzansi_wallet/mzansi_wallet.dart diff --git a/Frontend/lib/mih_packages/mzansi_wallet/loyalty_cards.dart b/Frontend/lib/mih_packages/mzansi_wallet/loyalty_cards.dart deleted file mode 100644 index 072f6b96..00000000 --- a/Frontend/lib/mih_packages/mzansi_wallet/loyalty_cards.dart +++ /dev/null @@ -1,358 +0,0 @@ -import 'package:Mzansi_Innovation_Hub/main.dart'; -import 'package:Mzansi_Innovation_Hub/mih_apis/mih_mzansi_wallet_apis.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_button.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_dropdown_input.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_number_input.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_search_input.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_window.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_error_message.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart'; -import 'package:Mzansi_Innovation_Hub/mih_objects/app_user.dart'; -import 'package:Mzansi_Innovation_Hub/mih_objects/loyalty_card.dart'; -import 'package:Mzansi_Innovation_Hub/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart'; -import 'package:Mzansi_Innovation_Hub/mih_packages/mzansi_wallet/components/mih_card_display.dart'; -import 'package:flutter/material.dart'; -import 'package:mobile_scanner/mobile_scanner.dart'; - -class LoyaltyCards extends StatefulWidget { - final AppUser signedInUser; - const LoyaltyCards({ - super.key, - required this.signedInUser, - }); - - @override - State createState() => _LoyaltyCardsState(); -} - -class _LoyaltyCardsState extends State { - final TextEditingController shopController = TextEditingController(); - final TextEditingController cardNumberController = TextEditingController(); - final TextEditingController cardSearchController = TextEditingController(); - late Future> cardList; - List listOfCards = []; - //bool showSelectedCardType = false; - final ValueNotifier shopName = ValueNotifier(""); - final ValueNotifier> searchShopName = ValueNotifier([]); - - final MobileScannerController scannerController = MobileScannerController( - detectionSpeed: DetectionSpeed.unrestricted, - ); - final boxFit = BoxFit.contain; - - void foundCode(BarcodeCapture bcode) { - if (bcode.barcodes.first.rawValue != null) { - setState(() { - cardNumberController.text = bcode.barcodes.first.rawValue!; - }); - //print(bcode.barcodes.first.rawValue); - scannerController.stop(); - Navigator.of(context).pop(); - } - } - - void openscanner() async { - // if (MzanziInnovationHub.of(context)!.theme.getPlatform() == "Web") { - // print("================ Web ===================="); - // print("here 1"); - // try { - // String? res = await SimpleBarcodeScanner.scanBarcode( - // context, - // barcodeAppBar: const BarcodeAppBar( - // appBarTitle: 'Scan Barcode', - // centerTitle: true, - // enableBackButton: true, - // backButtonIcon: Icon(Icons.arrow_back), - // ), - // isShowFlashIcon: true, - // delayMillis: 500, - // cameraFace: CameraFace.back, - // scanFormat: ScanFormat.ONLY_BARCODE, - // ); - // if (res != null) { - // setState(() { - // cardNumberController.text = res; - // }); - // } - // } catch (error) { - // print(error); - // } - // } else { - Navigator.of(context).pushNamed( - '/scanner', - arguments: cardNumberController, - ); - // } - } - - void addCardWindow(BuildContext ctxt) { - showDialog( - context: context, - barrierDismissible: false, - builder: (context) => MIHWindow( - fullscreen: false, - windowTitle: "Add New Loyalty Card", - windowTools: const [ - SizedBox(width: 35), - // IconButton( - // onPressed: () { - // //Delete card API Call - // }, - // icon: Icon( - // Icons.delete, - // color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), - // ), - // ), - ], - onWindowTapClose: () { - shopController.clear(); - cardNumberController.clear(); - shopName.value = ""; - Navigator.pop(context); - }, - windowBody: [ - MIHDropdownField( - controller: shopController, - hintText: "Shop Name", - dropdownOptions: const [ - "Best Before", - "Checkers", - "Clicks", - "Cotton:On", - "Dis-Chem", - "Edgars", - "Eskom", - "Fresh Stop", - "Infinity", - "Jet", - "Makro", - "Panarottis", - "Pick n Pay", - "Shell", - "Shoprite", - "Spar", - "Spur", - "Woolworths" - ], - required: true, - editable: true, - enableSearch: false, - ), - ValueListenableBuilder( - valueListenable: shopName, - builder: (BuildContext context, String value, Widget? child) { - return Visibility( - visible: value != "", - child: Column( - children: [ - const SizedBox(height: 10), - MihCardDisplay(shopName: shopName.value, height: 200), - ], - ), - ); - }, - ), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Flexible( - child: MIHNumberField( - controller: cardNumberController, - hintText: "Card Number", - editable: true, - required: true, - enableDecimal: false, - ), - ), - const SizedBox(width: 10), - MIHButton( - onTap: () async { - openscanner(); - }, - buttonText: "Scan", - buttonColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - textColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - ), - ], - ), - const SizedBox(height: 15), - SizedBox( - width: 300, - height: 50, - child: MIHButton( - onTap: () { - if (shopController.text == "" || - cardNumberController.text == "") { - showDialog( - context: context, - builder: (context) { - return const MIHErrorMessage(errorType: "Input Error"); - }, - ); - } else { - MIHMzansiWalletApis.addLoyaltyCardAPICall( - widget.signedInUser, - widget.signedInUser.app_id, - shopController.text, - cardNumberController.text, - context, - ); - } - }, - buttonText: "Add", - buttonColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(), - ), - ), - ], - ), - ); - } - - void shopSelected() { - if (shopController.text.isNotEmpty) { - shopName.value = shopController.text; - } else { - shopName.value = ""; - } - } - - void searchShop() { - if (cardSearchController.text.isEmpty) { - searchShopName.value = listOfCards; - } else { - List temp = []; - for (var item in listOfCards) { - if (item.shop_name - .toLowerCase() - .contains(cardSearchController.text.toLowerCase())) { - temp.add(item); - } - } - searchShopName.value = temp; - } - } - - @override - void dispose() { - cardNumberController.dispose(); - - shopController.removeListener(shopSelected); - shopController.dispose(); - cardSearchController.removeListener(searchShop); - cardSearchController.dispose(); - searchShopName.dispose(); - shopName.dispose(); - super.dispose(); - } - - @override - void initState() { - cardList = MIHMzansiWalletApis.getLoyaltyCards(widget.signedInUser.app_id); - shopController.addListener(shopSelected); - cardSearchController.addListener(searchShop); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: cardList, - builder: (context, snapshot) { - //print(snapshot.connectionState); - if (snapshot.connectionState == ConnectionState.waiting) { - return const Center( - child: Mihloadingcircle(), - ); - } else if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - listOfCards = snapshot.data!; - searchShop(); - //print(listOfCards); - return Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Loyalty Cards", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 25, - fontWeight: FontWeight.bold, - color: MzanziInnovationHub.of(context)! - .theme - .secondaryColor(), - ), - ), - IconButton( - icon: const Icon(Icons.add_card), - alignment: Alignment.topRight, - color: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - onPressed: () { - addCardWindow(context); - }, - ) - ], - ), - // Divider( - // color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), - // ), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Flexible( - flex: 4, - child: SizedBox( - height: 50, - child: MIHSearchField( - controller: cardSearchController, - hintText: "Shop Name", - required: false, - editable: true, - onTap: () {}, - ), - ), - ), - Flexible( - flex: 1, - child: IconButton( - onPressed: () { - FocusScope.of(context).unfocus(); - cardSearchController.clear(); - }, - icon: const Icon(Icons.filter_alt_off), - ), - ), - ], - ), - const SizedBox(height: 10), - ValueListenableBuilder( - valueListenable: searchShopName, - builder: (BuildContext context, List value, - Widget? child) { - return BuildLoyaltyCardList( - cardList: searchShopName.value, - signedInUser: widget.signedInUser, - ); - }, - ), - ], - ); - } else { - return const Center( - child: Text("Error Loading Loyalty Cards"), - ); - } - }, - ); - } -} diff --git a/Frontend/lib/mih_packages/mzansi_wallet/mzansi_wallet.dart b/Frontend/lib/mih_packages/mzansi_wallet/mzansi_wallet.dart deleted file mode 100644 index f8cc7dc1..00000000 --- a/Frontend/lib/mih_packages/mzansi_wallet/mzansi_wallet.dart +++ /dev/null @@ -1,179 +0,0 @@ -import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_action.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_body.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_header.dart'; -import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_layout_builder.dart'; -import 'package:Mzansi_Innovation_Hub/mih_objects/app_user.dart'; -import 'package:Mzansi_Innovation_Hub/mih_objects/arguments.dart'; -import 'package:Mzansi_Innovation_Hub/mih_packages/mzansi_wallet/loyalty_cards.dart'; -import 'package:flutter/material.dart'; - -class MzansiWallet extends StatefulWidget { - final AppUser signedInUser; - const MzansiWallet({ - super.key, - required this.signedInUser, - }); - - @override - State createState() => _MzansiWalletState(); -} - -class _MzansiWalletState extends State { - int _selectedIndex = 0; - - MIHAction getActionButton() { - return MIHAction( - icon: const Icon(Icons.arrow_back), - iconSize: 35, - onTap: () { - Navigator.of(context).pop(); - Navigator.of(context).popAndPushNamed( - '/', - arguments: AuthArguments(true, false), - ); - }, - ); - } - - MIHHeader getHeader() { - return const MIHHeader( - headerAlignment: MainAxisAlignment.center, - headerItems: [ - Text( - "", - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25, - ), - ), - ], - ); - } - - MIHHeader getSecAction() { - return MIHHeader( - headerAlignment: MainAxisAlignment.end, - headerItems: [ - //============ Patient Details ================ - Visibility( - visible: _selectedIndex != 0, - child: IconButton( - onPressed: () { - setState(() { - _selectedIndex = 0; - }); - }, - icon: const Icon( - Icons.card_membership, - size: 35, - ), - ), - ), - Visibility( - visible: _selectedIndex == 0, - child: IconButton.filled( - iconSize: 35, - onPressed: () { - setState(() { - _selectedIndex = 0; - }); - }, - icon: const Icon( - Icons.card_membership, - ), - ), - ), - //============ Patient Notes ================ - // Visibility( - // visible: _selectedIndex != 1, - // child: IconButton( - // onPressed: () { - // setState(() { - // _selectedIndex = 1; - // }); - // }, - // icon: const Icon( - // Icons.article_outlined, - // size: 35, - // ), - // ), - // ), - // Visibility( - // visible: _selectedIndex == 1, - // child: IconButton.filled( - // onPressed: () { - // setState(() { - // _selectedIndex = 1; - // }); - // }, - // icon: const Icon( - // Icons.article_outlined, - // size: 35, - // ), - // ), - // ), - // //============ Patient Files ================ - // Visibility( - // visible: _selectedIndex != 2, - // child: IconButton( - // onPressed: () { - // setState(() { - // _selectedIndex = 2; - // }); - // }, - // icon: const Icon( - // Icons.file_present, - // size: 35, - // ), - // ), - // ), - // Visibility( - // visible: _selectedIndex == 2, - // child: IconButton.filled( - // onPressed: () { - // setState(() { - // _selectedIndex = 2; - // }); - // }, - // icon: const Icon( - // Icons.file_present, - // size: 35, - // ), - // ), - // ), - ], - ); - } - - MIHBody getBody() { - return MIHBody( - borderOn: true, - bodyItems: [showSelection(_selectedIndex)], - ); - } - - Widget showSelection(int index) { - if (index == 0) { - return LoyaltyCards(signedInUser: widget.signedInUser); - } else if (index == 1) { - return const Placeholder(); - } else { - return const Placeholder(); - } - } - - @override - Widget build(BuildContext context) { - return MIHLayoutBuilder( - actionButton: getActionButton(), - header: getHeader(), - secondaryActionButton: getSecAction(), - body: getBody(), - actionDrawer: null, - secondaryActionDrawer: null, - bottomNavBar: null, - pullDownToRefresh: false, - onPullDown: () async {}, - ); - } -}