From b6183f2a5dec195f0f63ecc2b2adedb7bbd31866 Mon Sep 17 00:00:00 2001 From: Yasien Mac Mini Date: Fri, 6 Jun 2025 12:35:11 +0200 Subject: [PATCH] fix wallet padding --- .../builder/build_loyalty_card_list.dart | 166 ++++----- .../package_tools/mih_cards.dart | 325 +++++++++--------- 2 files changed, 256 insertions(+), 235 deletions(-) diff --git a/Frontend/lib/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart b/Frontend/lib/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart index a972ca49..07ba37ae 100644 --- a/Frontend/lib/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart +++ b/Frontend/lib/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart @@ -43,7 +43,7 @@ class _BuildLoyaltyCardListState extends State { ); } - void editCardWindow(BuildContext ctxt, int index) { + void editCardWindow(BuildContext ctxt, int index, double width) { showDialog( context: context, barrierDismissible: false, @@ -55,56 +55,95 @@ class _BuildLoyaltyCardListState extends State { _nicknameController.clear(); Navigator.pop(context); }, - windowBody: Column( - children: [ - MihForm( - formKey: _formKey, - formFields: [ - MihTextFormField( - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: _nicknameController, - multiLineInput: false, - requiredText: false, - hintText: "Card Title", - ), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisSize: MainAxisSize.max, - children: [ - Flexible( - child: MihTextFormField( - fillColor: MzanziInnovationHub.of(context)! + windowBody: Padding( + padding: + MzanziInnovationHub.of(context)!.theme.screenType == "desktop" + ? EdgeInsets.symmetric(horizontal: width * 0.05) + : EdgeInsets.symmetric(horizontal: width * 0), + child: Column( + children: [ + MihForm( + formKey: _formKey, + formFields: [ + MihTextFormField( + fillColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: _nicknameController, + multiLineInput: false, + requiredText: false, + hintText: "Card Title", + ), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisSize: MainAxisSize.max, + children: [ + Flexible( + child: MihTextFormField( + fillColor: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + inputColor: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + controller: _cardNumberController, + multiLineInput: false, + requiredText: true, + hintText: "Card Number", + numberMode: true, + validator: (value) { + return MihValidationServices().isEmpty(value); + }, + ), + ), + const SizedBox(width: 20), + MihButton( + onPressed: () { + openscanner(); + }, + buttonColor: MzanziInnovationHub.of(context)! .theme .secondaryColor(), - inputColor: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - controller: _cardNumberController, - multiLineInput: false, - requiredText: true, - hintText: "Card Number", - numberMode: true, - validator: (value) { - return MihValidationServices().isEmpty(value); - }, + width: 100, + child: Text( + "Scan", + style: TextStyle( + color: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), ), - ), - const SizedBox(width: 20), - MihButton( + ], + ), + const SizedBox(height: 15), + Center( + child: MihButton( onPressed: () { - openscanner(); + if (_formKey.currentState!.validate()) { + MIHMzansiWalletApis.updateLoyaltyCardAPICall( + widget.signedInUser, + widget.cardList[index].idloyalty_cards, + widget.cardList[index].favourite, + widget.cardList[index].priority_index, + _nicknameController.text, + _cardNumberController.text, + 0, + ctxt, + ); + } }, buttonColor: MzanziInnovationHub.of(context)! .theme .secondaryColor(), - width: 100, + width: 300, child: Text( - "Scan", + "Update", style: TextStyle( color: MzanziInnovationHub.of(context)! .theme @@ -114,40 +153,11 @@ class _BuildLoyaltyCardListState extends State { ), ), ), - ], - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - if (_formKey.currentState!.validate()) { - MIHMzansiWalletApis.updateLoyaltyCardAPICall( - widget.signedInUser, - widget.cardList[index].idloyalty_cards, - widget.cardList[index].favourite, - widget.cardList[index].priority_index, - _nicknameController.text, - _cardNumberController.text, - 0, - ctxt, - ); - } - }, - buttonColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - width: 300, - child: Text( - "Update", - style: TextStyle( - color: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - fontSize: 20, - fontWeight: FontWeight.bold, - ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), ), ); @@ -290,7 +300,7 @@ class _BuildLoyaltyCardListState extends State { ); } - void viewCardWindow(int index) { + void viewCardWindow(int index, double width) { //print(widget.cardList[index].card_number); String formattedCardNumber = ""; for (int i = 0; i <= widget.cardList[index].card_number.length - 1; i++) { @@ -356,7 +366,7 @@ class _BuildLoyaltyCardListState extends State { _cardNumberController.text = widget.cardList[index].card_number; _nicknameController.text = widget.cardList[index].nickname; }); - editCardWindow(context, index); + editCardWindow(context, index, width); }, ), SpeedDialChild( @@ -500,7 +510,7 @@ class _BuildLoyaltyCardListState extends State { height: 100, ), onTap: () { - viewCardWindow(index); + viewCardWindow(index, size.width); }, ); }, diff --git a/Frontend/lib/mih_packages/mzansi_wallet/package_tools/mih_cards.dart b/Frontend/lib/mih_packages/mzansi_wallet/package_tools/mih_cards.dart index de1d50d0..7378d781 100644 --- a/Frontend/lib/mih_packages/mzansi_wallet/package_tools/mih_cards.dart +++ b/Frontend/lib/mih_packages/mzansi_wallet/package_tools/mih_cards.dart @@ -83,7 +83,7 @@ class _MihCardsState extends State { } } - void addCardWindow(BuildContext ctxt) { + void addCardWindow(BuildContext ctxt, double width) { showDialog( context: context, barrierDismissible: false, @@ -97,127 +97,178 @@ class _MihCardsState extends State { shopName.value = ""; Navigator.pop(context); }, - windowBody: Column( - children: [ - MihForm( - formKey: _formKey, - formFields: [ - MIHDropdownField( - controller: shopController, - hintText: "Shop Name", - dropdownOptions: const [ - "+More", - "Apple Tree", - "Auchan", - "Best Before", - "Big Save", - "Boxer", - "BP", - "Builders Warehouse", - "Checkers", - "Choppies", - "Clicks", - "Continente", - "Cotton:On", - "Carrefour", - "Dis-Chem", - "Edgars", - "Eskom", - "Exclusive Books", - "Fresh Stop", - "Fresmart", - "Infinity", - "Jet", - "Justrite", - "Kero", - "Leroy Merlin", - "Makro", - "Naivas", - "OK Foods", - "Panarottis", - "Pick n Pay", - "PnA", - "PQ Clothing", - "Rage", - "Sefalana", - "Sasol", - "Shell", - "Shoprite", - "Signature Cosmetics & Fragrances", - "Spar", - "Spur", - "TFG Group", - "Toys R Us", - "Woermann Brock", - "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, - nickname: "", - height: 200), - ], + windowBody: Padding( + padding: + MzanziInnovationHub.of(context)!.theme.screenType == "desktop" + ? EdgeInsets.symmetric(horizontal: width * 0.05) + : EdgeInsets.symmetric(horizontal: width * 0), + child: Column( + children: [ + MihForm( + formKey: _formKey, + formFields: [ + MIHDropdownField( + controller: shopController, + hintText: "Shop Name", + dropdownOptions: const [ + "+More", + "Apple Tree", + "Auchan", + "Best Before", + "Big Save", + "Boxer", + "BP", + "Builders Warehouse", + "Checkers", + "Choppies", + "Clicks", + "Continente", + "Cotton:On", + "Carrefour", + "Dis-Chem", + "Edgars", + "Eskom", + "Exclusive Books", + "Fresh Stop", + "Fresmart", + "Infinity", + "Jet", + "Justrite", + "Kero", + "Leroy Merlin", + "Makro", + "Naivas", + "OK Foods", + "Panarottis", + "Pick n Pay", + "PnA", + "PQ Clothing", + "Rage", + "Sefalana", + "Sasol", + "Shell", + "Shoprite", + "Signature Cosmetics & Fragrances", + "Spar", + "Spur", + "TFG Group", + "Toys R Us", + "Woermann Brock", + "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, + nickname: "", + height: 200), + ], + ), + ); + }, + ), + const SizedBox(height: 10), + MihTextFormField( + fillColor: + MzanziInnovationHub.of(context)!.theme.secondaryColor(), + inputColor: + MzanziInnovationHub.of(context)!.theme.primaryColor(), + controller: _nicknameController, + multiLineInput: false, + requiredText: false, + hintText: "Card Title", + ), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisSize: MainAxisSize.max, + children: [ + Flexible( + child: MihTextFormField( + fillColor: MzanziInnovationHub.of(context)! + .theme + .secondaryColor(), + inputColor: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + controller: cardNumberController, + multiLineInput: false, + requiredText: true, + hintText: "Card Number", + numberMode: true, + validator: (value) { + return MihValidationServices().isEmpty(value); + }, + ), ), - ); - }, - ), - const SizedBox(height: 10), - MihTextFormField( - fillColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - inputColor: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - controller: _nicknameController, - multiLineInput: false, - requiredText: false, - hintText: "Card Title", - ), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisSize: MainAxisSize.max, - children: [ - Flexible( - child: MihTextFormField( - fillColor: MzanziInnovationHub.of(context)! + const SizedBox(width: 20), + MihButton( + onPressed: () { + openscanner(); + }, + buttonColor: MzanziInnovationHub.of(context)! .theme .secondaryColor(), - inputColor: MzanziInnovationHub.of(context)! - .theme - .primaryColor(), - controller: cardNumberController, - multiLineInput: false, - requiredText: true, - hintText: "Card Number", - numberMode: true, - validator: (value) { - return MihValidationServices().isEmpty(value); - }, + width: 100, + child: Text( + "Scan", + style: TextStyle( + color: MzanziInnovationHub.of(context)! + .theme + .primaryColor(), + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), ), - ), - const SizedBox(width: 20), - MihButton( + ], + ), + const SizedBox(height: 15), + Center( + child: MihButton( onPressed: () { - openscanner(); + if (_formKey.currentState!.validate()) { + if (shopController.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, + "", + 0, + _nicknameController.text, + 0, + context, + ); + } + } }, buttonColor: MzanziInnovationHub.of(context)! .theme .secondaryColor(), - width: 100, + width: 300, child: Text( - "Scan", + "Add", style: TextStyle( color: MzanziInnovationHub.of(context)! .theme @@ -227,51 +278,11 @@ class _MihCardsState extends State { ), ), ), - ], - ), - const SizedBox(height: 15), - MihButton( - onPressed: () { - if (_formKey.currentState!.validate()) { - if (shopController.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, - "", - 0, - _nicknameController.text, - 0, - context, - ); - } - } - }, - buttonColor: - MzanziInnovationHub.of(context)!.theme.secondaryColor(), - width: 300, - child: Text( - "Add", - style: TextStyle( - color: - MzanziInnovationHub.of(context)!.theme.primaryColor(), - fontSize: 20, - fontWeight: FontWeight.bold, - ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), ), ); @@ -388,7 +399,7 @@ class _MihCardsState extends State { backgroundColor: MzanziInnovationHub.of(context)!.theme.successColor(), onTap: () { - addCardWindow(context); + addCardWindow(context, width); }, ) ]),