use Mih Package Window instead of MIH Window

This commit is contained in:
2025-05-27 13:57:10 +02:00
parent 2f071bfa22
commit 10b77eb51c
27 changed files with 2401 additions and 2382 deletions

View File

@@ -4,7 +4,6 @@ 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_number_input.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_text_input.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_window.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
@@ -50,85 +49,86 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
builder: (context) => MihPackageWindow(
fullscreen: false,
windowTitle: "Edit Loyalty Card",
windowTools: const [
SizedBox(width: 35),
],
windowTools: null,
onWindowTapClose: () {
_cardNumberController.clear();
_nicknameController.clear();
Navigator.pop(context);
},
windowBody: [
MIHTextField(
controller: _nicknameController,
hintText: "Card Title",
editable: true,
required: false,
),
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,
windowBody: Column(
children: [
MIHTextField(
controller: _nicknameController,
hintText: "Card Title",
editable: true,
required: false,
),
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();
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 (_cardNumberController.text == "") {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Input Error");
},
);
} else {
MIHMzansiWalletApis.updateLoyaltyCardAPICall(
widget.signedInUser,
widget.cardList[index].idloyalty_cards,
widget.cardList[index].favourite,
widget.cardList[index].priority_index,
_nicknameController.text,
_cardNumberController.text,
0,
ctxt,
);
}
},
buttonText: "Scan",
buttonText: "Update",
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 (_cardNumberController.text == "") {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Input Error");
},
);
} else {
MIHMzansiWalletApis.updateLoyaltyCardAPICall(
widget.signedInUser,
widget.cardList[index].idloyalty_cards,
widget.cardList[index].favourite,
widget.cardList[index].priority_index,
_nicknameController.text,
_cardNumberController.text,
0,
ctxt,
);
}
},
buttonText: "Update",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
],
],
),
),
);
}
@@ -279,98 +279,88 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
builder: (context) => MihPackageWindow(
fullscreen: false,
windowTitle: widget.cardList[index].shop_name.toUpperCase(),
windowTools: Row(
children: [
Padding(
padding: const EdgeInsets.only(top: 5.0),
child: MihFloatingMenu(
animatedIcon: AnimatedIcons.menu_close,
direction: SpeedDialDirection.down,
children: [
SpeedDialChild(
child: widget.cardList[index].favourite == ""
? Icon(
Icons.favorite,
color: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
)
: Icon(
Icons.favorite_border,
color: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
),
label: widget.cardList[index].favourite == ""
? "Add to Favourite"
: "Remove from Favourite",
labelBackgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
labelStyle: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
fontWeight: FontWeight.bold,
),
backgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
onTap: () {
if (widget.cardList[index].favourite == "") {
addToFavCardWindow(context, index);
} else {
removeFromFavCardWindow(context, index);
}
},
),
SpeedDialChild(
child: Icon(
Icons.edit,
color:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
label: "Edit Card Details",
labelBackgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
labelStyle: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
fontWeight: FontWeight.bold,
),
backgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
onTap: () {
setState(() {
_cardNumberController.text =
widget.cardList[index].card_number;
_nicknameController.text =
widget.cardList[index].nickname;
});
editCardWindow(context, index);
},
),
SpeedDialChild(
child: Icon(
Icons.delete,
color:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
label: "Delete Card",
labelBackgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
labelStyle: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
fontWeight: FontWeight.bold,
),
backgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
onTap: () {
deleteCardWindow(context, index);
},
),
],
windowTools: Padding(
padding: const EdgeInsets.only(top: 5.0),
child: MihFloatingMenu(
animatedIcon: AnimatedIcons.menu_close,
direction: SpeedDialDirection.down,
children: [
SpeedDialChild(
child: widget.cardList[index].favourite == ""
? Icon(
Icons.favorite,
color: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
)
: Icon(
Icons.favorite_border,
color: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
),
label: widget.cardList[index].favourite == ""
? "Add to Favourite"
: "Remove from Favourite",
labelBackgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
labelStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
fontWeight: FontWeight.bold,
),
backgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
onTap: () {
if (widget.cardList[index].favourite == "") {
addToFavCardWindow(context, index);
} else {
removeFromFavCardWindow(context, index);
}
},
),
),
],
SpeedDialChild(
child: Icon(
Icons.edit,
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
label: "Edit Card Details",
labelBackgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
labelStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
fontWeight: FontWeight.bold,
),
backgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
onTap: () {
setState(() {
_cardNumberController.text =
widget.cardList[index].card_number;
_nicknameController.text = widget.cardList[index].nickname;
});
editCardWindow(context, index);
},
),
SpeedDialChild(
child: Icon(
Icons.delete,
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
label: "Delete Card",
labelBackgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
labelStyle: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
fontWeight: FontWeight.bold,
),
backgroundColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
onTap: () {
deleteCardWindow(context, index);
},
),
],
),
),
onWindowTapClose: () {
Navigator.pop(context);

View File

@@ -7,9 +7,9 @@ import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_search_input.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_text_input.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_single_child_scroll.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_window.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tool_body.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_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';
@@ -81,21 +81,10 @@ class _MihCardsState extends State<MihCards> {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
builder: (context) => MihPackageWindow(
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(),
// ),
// ),
],
windowTools: null,
onWindowTapClose: () {
shopController.clear();
cardNumberController.clear();
@@ -103,145 +92,148 @@ class _MihCardsState extends State<MihCards> {
shopName.value = "";
Navigator.pop(context);
},
windowBody: [
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: Column(
children: [
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),
MIHTextField(
controller: _nicknameController,
hintText: "Card Title",
editable: true,
required: false,
),
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(height: 10),
MIHTextField(
controller: _nicknameController,
hintText: "Card Title",
editable: true,
required: false,
),
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(width: 10),
MIHButton(
onTap: () async {
openscanner();
],
),
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,
"",
0,
_nicknameController.text,
0,
context,
);
}
},
buttonText: "Scan",
buttonText: "Add",
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,
"",
0,
_nicknameController.text,
0,
context,
);
}
},
buttonText: "Add",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
],
],
),
),
);
}