import 'package:flutter/material.dart'; import 'package:mzansi_innovation_hub/mih_objects/loyalty_card.dart'; class MzansiWalletProvider extends ChangeNotifier { List loyaltyCards; List favouriteCards; int toolIndex; MzansiWalletProvider({ this.loyaltyCards = const [], this.favouriteCards = const [], this.toolIndex = 0, }); void reset() { toolIndex = 0; loyaltyCards = []; favouriteCards = []; } void setToolIndex(int index) { toolIndex = index; notifyListeners(); } void setLoyaltyCards({required List cards}) async { loyaltyCards = cards; notifyListeners(); } void setFavouriteCards({required List cards}) async { favouriteCards = cards; notifyListeners(); } void deleteLoyaltyCard({required int cardId}) { loyaltyCards.removeWhere((card) => card.idloyalty_cards == cardId); notifyListeners(); } void editLoyaltyCard({required MIHLoyaltyCard updatedCard}) { int index = loyaltyCards.indexWhere( (card) => card.idloyalty_cards == updatedCard.idloyalty_cards); if (index != -1) { loyaltyCards[index] = updatedCard; notifyListeners(); } } }