QOL: Add reset function to providers

This commit is contained in:
2025-10-24 12:58:29 +02:00
parent 7de2cb7b36
commit a9ea3594b9
12 changed files with 123 additions and 0 deletions

View File

@@ -7,6 +7,11 @@ class AboutMihProvider extends ChangeNotifier {
this.toolIndex = 0,
});
void reset() {
toolIndex = 0;
notifyListeners();
}
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();

View File

@@ -9,6 +9,12 @@ class MihAccessControllsProvider extends ChangeNotifier {
this.toolIndex = 0,
});
void reset() {
toolIndex = 0;
accessList = null;
notifyListeners();
}
void setToolIndex(int index) {
toolIndex = index;
}

View File

@@ -7,6 +7,11 @@ class MihAuthenticationProvider extends ChangeNotifier {
this.toolIndex = 0,
});
void reset() {
toolIndex = 0;
notifyListeners();
}
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();

View File

@@ -14,6 +14,13 @@ class MihBannerAdProvider extends ChangeNotifier {
this.errorMessage = '',
});
void reset() {
bannerAd = null;
isBannerAdLoaded = false;
errorMessage = "";
notifyListeners();
}
@override
void dispose() {
bannerAd?.dispose();

View File

@@ -9,6 +9,12 @@ class MihCalculatorProvider extends ChangeNotifier {
this.toolIndex = 0,
});
void reset() {
availableCurrencies = [];
toolIndex = 0;
notifyListeners();
}
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();

View File

@@ -11,6 +11,13 @@ class MihCalendarProvider extends ChangeNotifier {
this.toolIndex = 0,
});
void reset() {
toolIndex = 0;
personalAppointments = null;
businessAppointments = null;
notifyListeners();
}
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();

View File

@@ -1,18 +1,34 @@
import 'package:flutter/widgets.dart';
class MihMineSweeperProvider extends ChangeNotifier {
String difficulty;
int toolIndex;
int rowCount;
int columnCount;
int totalMines;
MihMineSweeperProvider({
this.difficulty = "Normal",
this.toolIndex = 0,
this.rowCount = 10,
this.columnCount = 10,
this.totalMines = 15,
});
void reset() {
difficulty = "Normal";
toolIndex = 0;
rowCount = 10;
columnCount = 10;
totalMines = 15;
notifyListeners();
}
void setDifficulty(String difficulty) {
this.difficulty = difficulty;
notifyListeners();
}
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();

View File

@@ -8,6 +8,12 @@ class MzansiAiProvider extends ChangeNotifier {
this.toolIndex = 0,
});
void reset() {
toolIndex = 0;
startUpQuestion = null;
notifyListeners();
}
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();

View File

@@ -26,6 +26,22 @@ class MzansiDirectoryProvider extends ChangeNotifier {
this.businessTypeFilter = "",
});
void reset() {
toolIndex = 0;
userPosition = null;
userLocation = "Unknown Location";
personalSearch = true;
bookmarkedBusinesses = [];
businessDetailsMap = {};
searchedBusinesses = null;
selectedBusiness = null;
searchedUsers = null;
selectedUser = null;
searchTerm = "";
businessTypeFilter = "";
notifyListeners();
}
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();

View File

@@ -41,6 +41,7 @@ class MzansiProfileProvider extends ChangeNotifier {
businessUserSignatureUrl = null;
businessUserSignature = null;
userConsent = null;
notifyListeners();
}
void setPersonalHome(bool isPersonalHome) {

View File

@@ -12,6 +12,12 @@ class MzansiWalletProvider extends ChangeNotifier {
this.toolIndex = 0,
});
void reset() {
toolIndex = 0;
loyaltyCards = [];
favouriteCards = [];
}
void setToolIndex(int index) {
toolIndex = index;
notifyListeners();

View File

@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
class PatientManagerProvider extends ChangeNotifier {
int patientProfileIndex;
int patientManagerIndex;
bool personalMode;
Patient? selectedPatient;
PatientManagerProvider({
this.patientProfileIndex = 0,
this.patientManagerIndex = 0,
this.personalMode = true,
});
void reset() {
patientProfileIndex = 0;
patientManagerIndex = 0;
personalMode = true;
selectedPatient = null;
}
void setPatientProfileIndex(int index) {
patientProfileIndex = index;
notifyListeners();
}
void setPatientManagerIndex(int index) {
patientManagerIndex = index;
notifyListeners();
}
void setPersonalMode(bool personalMode) {
this.personalMode = personalMode;
notifyListeners();
}
void setSelectedPatient({required Patient? selectedPatient}) {
this.selectedPatient = selectedPatient;
notifyListeners();
}
}