Merge pull request #81 from yaso-meth/QOL--Mzansi-Wallet-Delete-Prompt

QOL--Mzansi-Wallet-Delete-Prompt
This commit is contained in:
yaso-meth
2025-02-13 11:07:56 +02:00
committed by GitHub
3 changed files with 105 additions and 5 deletions

View File

@@ -68,6 +68,7 @@ class MIHMzansiWalletApis {
int idloyalty_cards,
BuildContext context,
) async {
loadingPopUp(context);
var response = await http.delete(
Uri.parse(
"${AppEnviroment.baseApiUrl}/mzasni-wallet/loyalty-cards/delete/"),
@@ -79,6 +80,7 @@ class MIHMzansiWalletApis {
//print("Here4");
//print(response.statusCode);
if (response.statusCode == 200) {
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pushNamed(

View File

@@ -379,6 +379,88 @@ class _MIHDeleteMessageState extends State<MIHDeleteMessage> {
);
}
void setDeleteLoyaltyCard() {
messageTypes["Loyalty Card"] = Stack(
children: [
Container(
padding: EdgeInsets.all(popUpPaddingSize),
width: popUpWidth,
height: popUpheight,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.warning_amber_rounded,
size: popUpIconSize,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
//const SizedBox(height: 15),
Text(
"Are you sure you want to delete this?",
textAlign: TextAlign.center,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpTitleSize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
Text(
"This Card will be deleted permanently from your Mzansi Wallet. Are you certain you want to delete it?",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: popUpBodySize,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 15),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: widget.onTap,
buttonText: "Delete",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
))
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
);
}
Widget? getDeleteMessage(String type) {
return messageTypes[type];
}
@@ -400,6 +482,7 @@ class _MIHDeleteMessageState extends State<MIHDeleteMessage> {
setFileNote();
setDeleteEmployee();
setDeleteAppointment();
setDeleteLoyaltyCard();
//print(size);
// setState(() {
// width = size.width;

View File

@@ -1,6 +1,7 @@
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_layout/mih_window.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_delete_message.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/components/mih_card_display.dart';
@@ -23,6 +24,24 @@ class BuildLoyaltyCardList extends StatefulWidget {
}
class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
void deleteCardWindow(BuildContext ctxt, int index) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return MIHDeleteMessage(
deleteType: "Loyalty Card",
onTap: () {
MIHMzansiWalletApis.deleteLoyaltyCardAPICall(
widget.signedInUser,
widget.cardList[index].idloyalty_cards,
context,
);
});
},
);
}
void viewCardWindow(int index) {
//print(widget.cardList[index].card_number);
String formattedCardNumber = "";
@@ -41,11 +60,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
windowTools: [
IconButton(
onPressed: () {
MIHMzansiWalletApis.deleteLoyaltyCardAPICall(
widget.signedInUser,
widget.cardList[index].idloyalty_cards,
context,
);
deleteCardWindow(context, index);
},
icon: Icon(
Icons.delete,