@@ -2,6 +2,8 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>SKAdNetworkItems</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
||||
@@ -12,10 +12,28 @@ class MihBannerAd extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MihBannerAdState extends State<MihBannerAd> {
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
MihBannerAdProvider adProvider = context.read<MihBannerAdProvider>();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
adProvider.reset();
|
||||
adProvider.loadBannerAd();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<MihBannerAdProvider>(
|
||||
builder: (context, bannerAdProvider, child) {
|
||||
if (!bannerAdProvider.isBannerAdLoaded) {
|
||||
return SizedBox();
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
bannerAdProvider.bannerAd != null &&
|
||||
|
||||
@@ -41,8 +41,6 @@ class _MihBusinessProfilePreviewState extends State<MihBusinessProfilePreview> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
futureImageUrl =
|
||||
MihFileApi.getMinioFileUrl(widget.business.logo_path, context);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -54,7 +52,8 @@ class _MihBusinessProfilePreviewState extends State<MihBusinessProfilePreview> {
|
||||
return Row(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
future: MihFileApi.getMinioFileUrl(
|
||||
widget.business.logo_path, context),
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
|
||||
@@ -28,6 +28,11 @@ class MihBannerAdProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
void loadBannerAd() {
|
||||
if (bannerAd != null) {
|
||||
bannerAd!.dispose();
|
||||
bannerAd = null;
|
||||
isBannerAdLoaded = false;
|
||||
}
|
||||
bannerAd = BannerAd(
|
||||
adUnitId: adUnitId,
|
||||
request: const AdRequest(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/appointment.dart';
|
||||
|
||||
class MihCalendarProvider extends ChangeNotifier {
|
||||
@@ -57,6 +58,7 @@ class MihCalendarProvider extends ChangeNotifier {
|
||||
int index = personalAppointments?.indexWhere((appointment) =>
|
||||
appointment.idappointments == updatedAppointment.idappointments) ??
|
||||
-1;
|
||||
KenLogger.success("Edit Patient Index: $index");
|
||||
if (index != -1) {
|
||||
personalAppointments?[index] = updatedAppointment;
|
||||
notifyListeners();
|
||||
|
||||
@@ -10,7 +10,7 @@ class MzansiDirectoryProvider extends ChangeNotifier {
|
||||
String userLocation;
|
||||
bool personalSearch;
|
||||
List<BookmarkedBusiness> bookmarkedBusinesses = [];
|
||||
Map<String, Business?> businessDetailsMap = {};
|
||||
List<Business>? favouriteBusinessesList;
|
||||
List<Business>? searchedBusinesses;
|
||||
Business? selectedBusiness;
|
||||
List<AppUser>? searchedUsers;
|
||||
@@ -32,7 +32,6 @@ class MzansiDirectoryProvider extends ChangeNotifier {
|
||||
userLocation = "Unknown Location";
|
||||
personalSearch = true;
|
||||
bookmarkedBusinesses = [];
|
||||
businessDetailsMap = {};
|
||||
searchedBusinesses = null;
|
||||
selectedBusiness = null;
|
||||
searchedUsers = null;
|
||||
@@ -62,13 +61,14 @@ class MzansiDirectoryProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setFavouriteBusinesses({required List<BookmarkedBusiness> businesses}) {
|
||||
void setBookmarkedeBusinesses(
|
||||
{required List<BookmarkedBusiness> businesses}) {
|
||||
bookmarkedBusinesses = businesses;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setBusinessDetailsMap({required Map<String, Business?> detailsMap}) {
|
||||
businessDetailsMap = detailsMap;
|
||||
void setFavouriteBusinesses({required List<Business> businesses}) {
|
||||
favouriteBusinessesList = businesses;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,6 @@ class MzansiWalletProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void addLoyaltyCard({required MIHLoyaltyCard newCard}) {
|
||||
loyaltyCards.add(newCard);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void deleteLoyaltyCard({required int cardId}) {
|
||||
loyaltyCards.removeWhere((card) => card.idloyalty_cards == cardId);
|
||||
notifyListeners();
|
||||
|
||||
@@ -17,7 +17,7 @@ import 'package:mzansi_innovation_hub/mih_packages/mih_home/mih_route_error.dart
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mine_sweeper/mih_mine_sweeper.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_ai/mzansi_ai.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/mzansi_directory.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/mzansi_business_profile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/busines_profile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/mzansi_business_profile_view.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/mzansi_set_up_business_profile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profile/mzansi_profile.dart';
|
||||
@@ -190,9 +190,10 @@ class MihGoRouter {
|
||||
});
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return MzansiBusinessProfile(
|
||||
key: UniqueKey(),
|
||||
);
|
||||
return BusinesProfile();
|
||||
// return MzansiBusinessProfile(
|
||||
// key: UniqueKey(),
|
||||
// );
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_banner_ad_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calculator_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tools/currency_exchange_rate.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calculator/package_tools/simple_calc.dart';
|
||||
@@ -29,7 +28,6 @@ class _MIHCalculatorState extends State<MIHCalculator> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
context.read<MihBannerAdProvider>().loadBannerAd();
|
||||
await getCurrencyCodeList();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
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_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_banner_ad_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calculator_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
@@ -67,7 +66,6 @@ class _CurrencyExchangeRateState extends State<CurrencyExchangeRate> {
|
||||
fullscreen: false,
|
||||
windowTitle: "Calculation Results",
|
||||
onWindowTapClose: () {
|
||||
context.read<MihBannerAdProvider>().loadBannerAd();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_banner_ad.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_banner_ad_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
@@ -99,7 +98,6 @@ class _TipCalcState extends State<TipCalc> {
|
||||
fullscreen: false,
|
||||
windowTitle: "Calculation Results",
|
||||
onWindowTapClose: () {
|
||||
context.read<MihBannerAdProvider>().loadBannerAd();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/appointment.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
@@ -59,6 +58,13 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
void clearControllers() {
|
||||
widget.titleController.clear();
|
||||
widget.descriptionIDController.clear();
|
||||
widget.dateController.clear();
|
||||
widget.timeController.clear();
|
||||
}
|
||||
|
||||
double getPaddingSize() {
|
||||
if (MzansiInnovationHub.of(context)!.theme.screenType == "desktop") {
|
||||
return (width / 10);
|
||||
@@ -72,37 +78,41 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
String heading = "";
|
||||
String description = "";
|
||||
DateTime now;
|
||||
int hourNow = 0;
|
||||
String date = "";
|
||||
int appointHour = 0;
|
||||
String appointDate = "";
|
||||
if (appointmentList[index].date_time.contains("T")) {
|
||||
heading =
|
||||
"${appointmentList[index].date_time.split('T')[1].substring(0, 5)} - ${appointmentList[index].title.toUpperCase()}";
|
||||
description = appointmentList[index].description;
|
||||
now = DateTime.now();
|
||||
hourNow = int.parse(now.toString().split(' ')[1].substring(0, 2));
|
||||
date = DateTime(now.year, now.month, now.day).toString().split(' ')[0];
|
||||
appointDate = appointmentList[index].date_time.split('T')[0];
|
||||
appointHour = int.parse(
|
||||
appointmentList[index].date_time.split('T')[1].substring(0, 2));
|
||||
|
||||
// SAFELY EXTRACT DATE AND TIME
|
||||
String dateTimeString = appointmentList[index].date_time;
|
||||
String timePart = "";
|
||||
String datePart = "";
|
||||
|
||||
if (dateTimeString.contains("T")) {
|
||||
List<String> parts = dateTimeString.split('T');
|
||||
datePart = parts[0];
|
||||
timePart = parts[1].substring(0, 5);
|
||||
} else if (dateTimeString.contains(" ")) {
|
||||
List<String> parts = dateTimeString.split(' ');
|
||||
datePart = parts[0];
|
||||
timePart = parts[1].substring(0, 5);
|
||||
} else {
|
||||
heading =
|
||||
"${appointmentList[index].date_time.split(' ')[1].substring(0, 5)} - ${appointmentList[index].title.toUpperCase()}";
|
||||
description = appointmentList[index].description;
|
||||
now = DateTime.now();
|
||||
hourNow = int.parse(now.toString().split(' ')[1].substring(0, 2));
|
||||
date = DateTime(now.year, now.month, now.day).toString().split(' ')[0];
|
||||
appointDate = appointmentList[index].date_time.split(' ')[0];
|
||||
appointHour = int.parse(
|
||||
appointmentList[index].date_time.split(' ')[1].substring(0, 2));
|
||||
// Fallback if format is unexpected
|
||||
datePart = dateTimeString;
|
||||
timePart = "00:00";
|
||||
}
|
||||
|
||||
String heading =
|
||||
"$timePart - ${appointmentList[index].title.toUpperCase()}";
|
||||
String description = appointmentList[index].description;
|
||||
|
||||
DateTime now = DateTime.now();
|
||||
int hourNow = int.parse(now.toString().split(' ')[1].substring(0, 2));
|
||||
String currentDate =
|
||||
DateTime(now.year, now.month, now.day).toString().split(' ')[0];
|
||||
|
||||
int appointHour = int.parse(timePart.split(':')[0]);
|
||||
|
||||
Color appointmentColor = MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
if (date == appointDate) {
|
||||
|
||||
if (currentDate == datePart) {
|
||||
if (appointHour < hourNow) {
|
||||
appointmentColor = MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
@@ -110,7 +120,7 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
appointmentColor = MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
}
|
||||
} else if (DateTime.parse(appointDate).isBefore(DateTime.parse(date))) {
|
||||
} else if (DateTime.parse(datePart).isBefore(DateTime.parse(currentDate))) {
|
||||
appointmentColor = MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
}
|
||||
@@ -138,15 +148,15 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
// SAFELY SET CONTROLLER VALUES
|
||||
setState(() {
|
||||
widget.titleController.text = appointmentList[index].title;
|
||||
widget.descriptionIDController.text =
|
||||
appointmentList[index].description;
|
||||
widget.dateController.text =
|
||||
appointmentList[index].date_time.split('T')[0];
|
||||
widget.timeController.text =
|
||||
appointmentList[index].date_time.split('T')[1].substring(0, 5);
|
||||
widget.dateController.text = datePart;
|
||||
widget.timeController.text = timePart;
|
||||
});
|
||||
|
||||
if (widget.inWaitingRoom == false) {
|
||||
appointmentDetailsWindow(
|
||||
mzansiProfileProvider, mihCalendarProvider, index, bodyWidth);
|
||||
@@ -214,10 +224,7 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
],
|
||||
onWindowTapClose: () {
|
||||
context.pop();
|
||||
widget.dateController.clear();
|
||||
widget.timeController.clear();
|
||||
widget.titleController.clear();
|
||||
widget.descriptionIDController.clear();
|
||||
clearControllers();
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
@@ -342,10 +349,7 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
],
|
||||
onWindowTapClose: () {
|
||||
context.pop();
|
||||
widget.dateController.clear();
|
||||
widget.timeController.clear();
|
||||
widget.titleController.clear();
|
||||
widget.descriptionIDController.clear();
|
||||
clearControllers();
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
@@ -591,6 +595,7 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
KenLogger.success("ersonalHome: ${mzansiProfileProvider.personalHome}");
|
||||
if (mzansiProfileProvider.personalHome == true) {
|
||||
statusCode = await MihMzansiCalendarApis.updatePersonalAppointment(
|
||||
mzansiProfileProvider.user!,
|
||||
@@ -634,28 +639,30 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
if (statusCode == 200) {
|
||||
context.pop();
|
||||
context.pop();
|
||||
if (!widget.inWaitingRoom) {
|
||||
KenLogger.warning("calendar route");
|
||||
context.goNamed(
|
||||
"mihCalendar",
|
||||
);
|
||||
} else {
|
||||
KenLogger.warning("waiting room route");
|
||||
// GoRouter.of(context).refresh();
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
);
|
||||
context.goNamed(
|
||||
'patientManager',
|
||||
extra: PatManagerArguments(
|
||||
mzansiProfileProvider.user!,
|
||||
false,
|
||||
mzansiProfileProvider.business,
|
||||
mzansiProfileProvider.businessUser,
|
||||
),
|
||||
);
|
||||
// context.pop();
|
||||
}
|
||||
successPopUp("Successfully Updated Appointment",
|
||||
"You appointment has been successfully updated.");
|
||||
// if (!widget.inWaitingRoom) {
|
||||
// KenLogger.warning("calendar route");
|
||||
// context.goNamed(
|
||||
// "mihCalendar",
|
||||
// );
|
||||
// } else {
|
||||
// KenLogger.warning("waiting room route");
|
||||
// // GoRouter.of(context).refresh();
|
||||
// context.goNamed(
|
||||
// 'mihHome',
|
||||
// );
|
||||
// context.goNamed(
|
||||
// 'patientManager',
|
||||
// extra: PatManagerArguments(
|
||||
// mzansiProfileProvider.user!,
|
||||
// false,
|
||||
// mzansiProfileProvider.business,
|
||||
// mzansiProfileProvider.businessUser,
|
||||
// ),
|
||||
// );
|
||||
// // context.pop();
|
||||
// }
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
@@ -724,6 +731,7 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
clearControllers();
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
@@ -805,15 +813,17 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
Widget? child) {
|
||||
List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!
|
||||
: mihCalendarProvider.businessAppointments!;
|
||||
// List<Appointment> appointmentList = mzansiProfileProvider.personalHome
|
||||
// ? mihCalendarProvider.personalAppointments!
|
||||
// : mihCalendarProvider.businessAppointments!;
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: getPaddingSize()),
|
||||
child: ListView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: appointmentList.length,
|
||||
itemCount: mzansiProfileProvider.personalHome
|
||||
? mihCalendarProvider.personalAppointments!.length
|
||||
: mihCalendarProvider.businessAppointments!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return displayAppointment(
|
||||
mzansiProfileProvider, mihCalendarProvider, index, width);
|
||||
|
||||
@@ -139,7 +139,7 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
fullscreen: false,
|
||||
windowTitle: "Add Appointment",
|
||||
onWindowTapClose: () {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
_appointmentDateController.clear();
|
||||
_appointmentTimeController.clear();
|
||||
_appointmentTitleController.clear();
|
||||
|
||||
@@ -13,7 +13,6 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
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_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_banner_ad_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_mine_sweeper_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
@@ -124,8 +123,9 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
return '$hoursStr:$minutesStr:$secondsStr:$centiStr';
|
||||
}
|
||||
|
||||
void showStartGameWindow(MihMineSweeperProvider mihMineSweeperProvider,
|
||||
MihBannerAdProvider addProvider) {
|
||||
void showStartGameWindow(
|
||||
MihMineSweeperProvider mihMineSweeperProvider,
|
||||
) {
|
||||
// easy - 10 * 10 & 15 bombs
|
||||
// Intermediate - 10 * 15 & 23 bombs
|
||||
// Hard - 10 * 20 & 30 bombs
|
||||
@@ -134,7 +134,6 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
builder: (context) {
|
||||
return MihMineSweeperStartGameWindow(
|
||||
onPressed: () {
|
||||
addProvider.loadBannerAd();
|
||||
resetTimer();
|
||||
mihMineSweeperProvider
|
||||
.setDifficulty(mihMineSweeperProvider.difficulty);
|
||||
@@ -241,12 +240,8 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> handleTap(
|
||||
MzansiProfileProvider profileProvider,
|
||||
MihMineSweeperProvider mihMineSweeperProvider,
|
||||
MihBannerAdProvider adProvider,
|
||||
int r,
|
||||
int c) async {
|
||||
Future<void> handleTap(MzansiProfileProvider profileProvider,
|
||||
MihMineSweeperProvider mihMineSweeperProvider, int r, int c) async {
|
||||
if (isGameOver || board[r][c].isOpened || board[r][c].isFlagged) {
|
||||
return;
|
||||
}
|
||||
@@ -304,8 +299,7 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
showStartGameWindow(
|
||||
mihMineSweeperProvider, adProvider);
|
||||
showStartGameWindow(mihMineSweeperProvider);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
@@ -364,7 +358,7 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
squaresLeft--;
|
||||
}
|
||||
// 3. Check for win
|
||||
_checkWinCondition(profileProvider, mihMineSweeperProvider, adProvider);
|
||||
_checkWinCondition(profileProvider, mihMineSweeperProvider);
|
||||
// Update the UI
|
||||
setState(() {});
|
||||
}
|
||||
@@ -383,7 +377,6 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
Future<void> _checkWinCondition(
|
||||
MzansiProfileProvider profileProvider,
|
||||
MihMineSweeperProvider mihMineSweeperProvider,
|
||||
MihBannerAdProvider adProvider,
|
||||
) async {
|
||||
// Game is won if all non-mine squares are opened.
|
||||
if (squaresLeft <= mihMineSweeperProvider.totalMines) {
|
||||
@@ -450,7 +443,7 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
showStartGameWindow(mihMineSweeperProvider, adProvider);
|
||||
showStartGameWindow(mihMineSweeperProvider);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
@@ -558,13 +551,9 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
}
|
||||
|
||||
Widget getBody() {
|
||||
return Consumer3<MzansiProfileProvider, MihMineSweeperProvider,
|
||||
MihBannerAdProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider profileProvider,
|
||||
MihMineSweeperProvider mihMineSweeperProvider,
|
||||
MihBannerAdProvider adProvider,
|
||||
Widget? child) {
|
||||
return Consumer2<MzansiProfileProvider, MihMineSweeperProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
MihMineSweeperProvider mihMineSweeperProvider, Widget? child) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -725,12 +714,8 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
|
||||
return MineTile(
|
||||
square: board[r][c],
|
||||
onTap: () => handleTap(
|
||||
profileProvider,
|
||||
mihMineSweeperProvider,
|
||||
adProvider,
|
||||
r,
|
||||
c),
|
||||
onTap: () => handleTap(profileProvider,
|
||||
mihMineSweeperProvider, r, c),
|
||||
onLongPress: () => handleLongPress(r, c),
|
||||
);
|
||||
},
|
||||
@@ -768,7 +753,7 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onTap: () {
|
||||
mihMineSweeperProvider.setToolIndex(2);
|
||||
mihMineSweeperProvider.setToolIndex(3);
|
||||
},
|
||||
),
|
||||
SpeedDialChild(
|
||||
@@ -778,9 +763,7 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
label: board.isEmpty && squaresLeft < 0
|
||||
? "Start Game"
|
||||
: "Reset Game",
|
||||
label: "Start New Game",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
@@ -794,8 +777,7 @@ class _MineSweeperGameState extends State<MineSweeperGame> {
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onTap: () {
|
||||
showStartGameWindow(
|
||||
mihMineSweeperProvider, adProvider);
|
||||
showStartGameWindow(mihMineSweeperProvider);
|
||||
},
|
||||
),
|
||||
]),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -93,6 +93,8 @@ class _AiChatState extends State<AiChat> {
|
||||
temp +=
|
||||
"- Calculator: Simple calculator with tip and forex calculation functionality.\n";
|
||||
temp += "- MIH Access: Manage and view profile access security.\n";
|
||||
temp +=
|
||||
"- MIH Minesweeper: The first game from MIH! It's the classic brain-teaser ready to entertain you no matter where you are.\n";
|
||||
temp += "**Core Rules and Guidelines:**\n";
|
||||
temp +=
|
||||
"- **Accuracy First:** Always prioritize providing correct information.\n";
|
||||
|
||||
@@ -47,7 +47,7 @@ class _BuildFavouriteBusinessesListState
|
||||
directoryProvider.setSelectedBusiness(
|
||||
business: widget.favouriteBusinesses[index]!,
|
||||
);
|
||||
context.goNamed(
|
||||
context.pushNamed(
|
||||
'businessProfileView',
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tools/mih_favourite_businesses.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tools/mih_search_mzansi.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_location_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MzansiDirectory extends StatefulWidget {
|
||||
@@ -31,11 +36,33 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getFavouriteBusinesses() async {
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
await MihMzansiDirectoryServices().getAllUserBookmarkedBusiness(
|
||||
profileProvider.user!.app_id,
|
||||
directoryProvider,
|
||||
);
|
||||
List<Business> favBus = [];
|
||||
for (var bus in directoryProvider.bookmarkedBusinesses) {
|
||||
await MihBusinessDetailsServices()
|
||||
.getBusinessDetailsByBusinessId(bus.business_id)
|
||||
.then((business) {
|
||||
favBus.add(business!);
|
||||
});
|
||||
}
|
||||
KenLogger.success(favBus);
|
||||
directoryProvider.setFavouriteBusinesses(businesses: favBus);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
initialiseGPSLocation();
|
||||
getFavouriteBusinesses();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.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_search_bar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/build_favourite_businesses_list.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihFavouriteBusinesses extends StatefulWidget {
|
||||
@@ -31,38 +30,13 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
||||
ValueNotifier([]);
|
||||
Timer? _debounce;
|
||||
|
||||
Future<void> getAndMapAllBusinessDetailsForBookmarkedBusinesses(
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MzansiDirectoryProvider directoryProvider,
|
||||
) async {
|
||||
await MihMzansiDirectoryServices().getAllUserBookmarkedBusiness(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
directoryProvider,
|
||||
);
|
||||
Map<String, Business?> businessMap = {};
|
||||
List<Future<Business?>> detailFutures = [];
|
||||
for (var item in directoryProvider.bookmarkedBusinesses) {
|
||||
detailFutures.add(MihBusinessDetailsServices()
|
||||
.getBusinessDetailsByBusinessId(item.business_id));
|
||||
}
|
||||
List<Business?> details = await Future.wait(detailFutures);
|
||||
for (int i = 0; i < directoryProvider.bookmarkedBusinesses.length; i++) {
|
||||
businessMap[directoryProvider.bookmarkedBusinesses[i].business_id] =
|
||||
details[i];
|
||||
}
|
||||
directoryProvider.setBusinessDetailsMap(detailsMap: businessMap);
|
||||
_filterAndSetBusinesses(directoryProvider);
|
||||
}
|
||||
|
||||
void _filterAndSetBusinesses(MzansiDirectoryProvider directoryProvider) {
|
||||
List<Business?> businessesToDisplay = [];
|
||||
String query = businessSearchController.text.toLowerCase();
|
||||
for (var bookmarked in directoryProvider.bookmarkedBusinesses) {
|
||||
if (bookmarked.business_name.toLowerCase().contains(query)) {
|
||||
if (directoryProvider.businessDetailsMap
|
||||
.containsKey(bookmarked.business_id)) {
|
||||
businessesToDisplay.add(
|
||||
directoryProvider.businessDetailsMap[bookmarked.business_id]);
|
||||
if (directoryProvider.favouriteBusinessesList != null) {
|
||||
for (var bus in directoryProvider.favouriteBusinessesList!) {
|
||||
if (bus.Name.toLowerCase().contains(query)) {
|
||||
businessesToDisplay.add(bus);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,13 +56,11 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
||||
super.initState();
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
|
||||
getAndMapAllBusinessDetailsForBookmarkedBusinesses(
|
||||
mzansiProfileProvider,
|
||||
directoryProvider,
|
||||
);
|
||||
// getAndMapAllBusinessDetailsForBookmarkedBusinesses(
|
||||
// mzansiProfileProvider,
|
||||
// directoryProvider,
|
||||
// );
|
||||
_filterAndSetBusinesses(directoryProvider);
|
||||
businessSearchController.addListener(() {
|
||||
if (_debounce?.isActive ?? false) {
|
||||
_debounce!.cancel();
|
||||
@@ -110,116 +82,129 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: MihSearchBar(
|
||||
controller: businessSearchController,
|
||||
hintText: "Search Businesses",
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {},
|
||||
searchFocusNode: searchFocusNode,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ValueListenableBuilder<List<Business?>>(
|
||||
valueListenable: searchBookmarkedBusinesses,
|
||||
builder: (context, filteredBusinesses, child) {
|
||||
if (filteredBusinesses.isEmpty &&
|
||||
businessSearchController.text.isNotEmpty) {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Let's try refining your search",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (filteredBusinesses.isEmpty &&
|
||||
businessSearchController.text.isEmpty) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.businessProfile,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No favourite businesses added to your mzansi directory",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
if (directoryProvider.favouriteBusinessesList == null) {
|
||||
return Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
}
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: MihSearchBar(
|
||||
controller: businessSearchController,
|
||||
hintText: "Search Businesses",
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {},
|
||||
searchFocusNode: searchFocusNode,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ValueListenableBuilder<List<Business?>>(
|
||||
valueListenable: searchBookmarkedBusinesses,
|
||||
builder: (context, filteredBusinesses, child) {
|
||||
if (filteredBusinesses.isEmpty &&
|
||||
businessSearchController.text.isNotEmpty) {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: RichText(
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Let's try refining your search",
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (filteredBusinesses.isEmpty &&
|
||||
businessSearchController.text.isEmpty) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.businessProfile,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No favourite businesses added to your mzansi directory",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Use the mzansi search"),
|
||||
TextSpan(
|
||||
text:
|
||||
" to find your favourite businesses of mzansi"),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Use the mzansi search"),
|
||||
TextSpan(
|
||||
text:
|
||||
" to find your favourite businesses of mzansi"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return BuildFavouriteBusinessesList(
|
||||
favouriteBusinesses: filteredBusinesses,
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
KenLogger.success(filteredBusinesses);
|
||||
return BuildFavouriteBusinessesList(
|
||||
favouriteBusinesses: filteredBusinesses,
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_qr_code.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_reviews.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_user_search.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_team.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_my_business_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_employee_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MzansiBusinessProfile extends StatefulWidget {
|
||||
const MzansiBusinessProfile({
|
||||
super.key,
|
||||
});
|
||||
class BusinesProfile extends StatefulWidget {
|
||||
const BusinesProfile({super.key});
|
||||
|
||||
@override
|
||||
State<MzansiBusinessProfile> createState() => _MzansiBusinessProfileState();
|
||||
State<BusinesProfile> createState() => _BusinesProfileState();
|
||||
}
|
||||
|
||||
class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
|
||||
class _BusinesProfileState extends State<BusinesProfile> {
|
||||
Future<void> initialiseBusinessData() async {
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
await MihBusinessEmployeeServices()
|
||||
.fetchEmployees(profileProvider, context);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
initialiseBusinessData();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: context.watch<MzansiProfileProvider>().businessIndex,
|
||||
onIndexChange: (newIndex) {
|
||||
context.read<MzansiProfileProvider>().setBusinessIndex(newIndex);
|
||||
@@ -45,7 +56,6 @@ class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
|
||||
'mihHome',
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
context.read<MzansiProfileProvider>().setBusinessIndex(0);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -79,22 +89,6 @@ class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
MihBusinessDetails(),
|
||||
MihMyBusinessUser(),
|
||||
MihMyBusinessTeam(),
|
||||
MihBusinessUserSearch(),
|
||||
MihBusinessReviews(
|
||||
business: context.watch<MzansiProfileProvider>().business!),
|
||||
MihBusinessQrCode(
|
||||
business: context.watch<MzansiProfileProvider>().business!,
|
||||
// startUpSearch: "",
|
||||
),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
"Profile",
|
||||
@@ -106,4 +100,16 @@ class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
MihBusinessDetails(),
|
||||
MihMyBusinessUser(),
|
||||
MihMyBusinessTeam(),
|
||||
MihBusinessUserSearch(),
|
||||
MihBusinessReviews(business: null),
|
||||
MihBusinessQrCode(business: null),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
}
|
||||
@@ -14,22 +14,22 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
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_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.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_circle_avatar.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:screenshot/screenshot.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
|
||||
class MihBusinessQrCode extends StatefulWidget {
|
||||
final Business business;
|
||||
// final String? startUpSearch;
|
||||
final Business? business;
|
||||
const MihBusinessQrCode({
|
||||
super.key,
|
||||
required this.business,
|
||||
// required this.startUpSearch,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -38,6 +38,7 @@ class MihBusinessQrCode extends StatefulWidget {
|
||||
|
||||
class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
||||
late Future<String> futureImageUrl;
|
||||
late Business business;
|
||||
PlatformFile? file;
|
||||
late String qrCodedata;
|
||||
int qrSize = 500;
|
||||
@@ -66,14 +67,14 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
||||
.substring(2, 8);
|
||||
// KenLogger.warning(bgColor);
|
||||
String encodedData =
|
||||
Uri.encodeComponent("$qrCodedata${widget.business.business_id}");
|
||||
Uri.encodeComponent("$qrCodedata${business.business_id}");
|
||||
|
||||
return "https://api.qrserver.com/v1/create-qr-code/?data=$encodedData&size=${qrSize}x${qrSize}&bgcolor=$bgColor&color=$color";
|
||||
}
|
||||
|
||||
Future<void> saveImage(Uint8List imageBytes) async {
|
||||
final String filename =
|
||||
"${widget.business.Name}_QR_Code_${DateTime.now().millisecondsSinceEpoch}.png";
|
||||
"${business.Name}_QR_Code_${DateTime.now().millisecondsSinceEpoch}.png";
|
||||
if (kIsWeb) {
|
||||
await FileSaver.instance.saveFile(
|
||||
name: filename,
|
||||
@@ -241,7 +242,7 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
widget.business.Name,
|
||||
business.Name,
|
||||
style: TextStyle(
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -253,7 +254,7 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
widget.business.type,
|
||||
business.type,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -335,9 +336,15 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
if (widget.business != null) {
|
||||
business = widget.business!;
|
||||
} else {
|
||||
business = profileProvider.business!;
|
||||
}
|
||||
_checkUserSession();
|
||||
futureImageUrl =
|
||||
MihFileApi.getMinioFileUrl(widget.business.logo_path, context);
|
||||
futureImageUrl = MihFileApi.getMinioFileUrl(business.logo_path, context);
|
||||
qrCodedata =
|
||||
"${AppEnviroment.baseAppUrl}/business-profile/view?business_id=";
|
||||
}
|
||||
@@ -418,8 +425,8 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
|
||||
onTap: () {
|
||||
shareMIHLink(
|
||||
context,
|
||||
"Check out ${widget.business.Name} on the MIH app",
|
||||
"$qrCodedata${widget.business.business_id}",
|
||||
"Check out ${business.Name} on the MIH app",
|
||||
"$qrCodedata${business.business_id}",
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -5,12 +5,14 @@ import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_review.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_review_business_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihBusinessReviews extends StatefulWidget {
|
||||
final Business business;
|
||||
final Business? business;
|
||||
const MihBusinessReviews({
|
||||
super.key,
|
||||
required this.business,
|
||||
@@ -21,15 +23,19 @@ class MihBusinessReviews extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
||||
// late Future<List<BusinessReview>> _reviews;
|
||||
late Business business;
|
||||
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _reviews = MihMzansiDirectoryServices().getAllReviewsofBusiness(
|
||||
// widget.businessId,
|
||||
// );
|
||||
// }
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
if (widget.business != null) {
|
||||
business = widget.business!;
|
||||
} else {
|
||||
business = profileProvider.business!;
|
||||
}
|
||||
}
|
||||
|
||||
void onReviewTap(BusinessReview? businessReview, double width) {
|
||||
// showDialog(context: context, builder: (context)=> )
|
||||
@@ -37,7 +43,7 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MihReviewBusinessWindow(
|
||||
business: widget.business,
|
||||
business: business,
|
||||
businessReview: businessReview,
|
||||
screenWidth: width,
|
||||
readOnly: true,
|
||||
@@ -52,7 +58,7 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return FutureBuilder(
|
||||
future: MihMzansiDirectoryServices().getAllReviewsofBusiness(
|
||||
widget.business.business_id,
|
||||
business.business_id,
|
||||
),
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||
@@ -93,7 +99,7 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No reviews yet, be the first the review ${widget.business.Name}",
|
||||
"No reviews yet, be the first the review ${business.Name}",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
|
||||
@@ -36,11 +36,9 @@ class _MihBusinessUserSearchState extends State<MihBusinessUserSearch> {
|
||||
|
||||
void submitUserForm(MzansiProfileProvider profileProvider) {
|
||||
if (searchController.text != "") {
|
||||
setState(() {
|
||||
userSearch = searchController.text;
|
||||
hasSearchedBefore = true;
|
||||
userSearchResults = fetchUsers(profileProvider, userSearch);
|
||||
});
|
||||
userSearch = searchController.text;
|
||||
hasSearchedBefore = true;
|
||||
userSearchResults = fetchUsers(profileProvider, userSearch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,6 +190,7 @@ class _MihBusinessUserSearchState extends State<MihBusinessUserSearch> {
|
||||
searchController.clear();
|
||||
userSearch = "";
|
||||
});
|
||||
profileProvider.setUserearchResults(userSearchResults: []);
|
||||
},
|
||||
searchFocusNode: _searchFocusNode,
|
||||
),
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_employee.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/builders/build_employee_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_employee_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihMyBusinessTeam extends StatefulWidget {
|
||||
@@ -23,32 +22,11 @@ class _MihMyBusinessTeamState extends State<MihMyBusinessTeam> {
|
||||
String errorCode = "";
|
||||
String errorBody = "";
|
||||
|
||||
void getEmployeeData(MzansiProfileProvider mzansiProfileProvider) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await MihBusinessEmployeeServices()
|
||||
.fetchEmployees(mzansiProfileProvider, context);
|
||||
});
|
||||
}
|
||||
// Future<void> fetchEmployees(
|
||||
// MzansiProfileProvider mzansiProfileProvider) async {
|
||||
// //print("Patien manager page: $endpoint");
|
||||
// final response = await http.get(Uri.parse(
|
||||
// "${AppEnviroment.baseApiUrl}/business-user/employees/${mzansiProfileProvider.businessUser!.business_id}"));
|
||||
// errorCode = response.statusCode.toString();
|
||||
// errorBody = response.body;
|
||||
// if (response.statusCode == 200) {
|
||||
// //print("Here1");
|
||||
// Iterable l = jsonDecode(response.body);
|
||||
// //print("Here2");
|
||||
// List<BusinessEmployee> employeeList = List<BusinessEmployee>.from(
|
||||
// l.map((model) => BusinessEmployee.fromJson(model)));
|
||||
// mzansiProfileProvider.setEmployeeList(employeeList: employeeList);
|
||||
// //print("Here3");
|
||||
// //print(patientQueue);
|
||||
// // return patientQueue;
|
||||
// } else {
|
||||
// throw Exception('failed to load employees');
|
||||
// }
|
||||
// void getEmployeeData(MzansiProfileProvider mzansiProfileProvider) {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
// await MihBusinessEmployeeServices()
|
||||
// .fetchEmployees(mzansiProfileProvider, context);
|
||||
// });
|
||||
// }
|
||||
|
||||
Widget displayEmployeeList(List<BusinessEmployee> employeeList) {
|
||||
@@ -89,7 +67,6 @@ class _MihMyBusinessTeamState extends State<MihMyBusinessTeam> {
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
|
||||
if (mzansiProfileProvider.employeeList == null) {
|
||||
getEmployeeData(mzansiProfileProvider);
|
||||
return Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
|
||||
@@ -218,19 +218,17 @@ class _MihMyBusinessUserState extends State<MihMyBusinessUser> {
|
||||
void setControllers() {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
setState(() {
|
||||
fileNameController.text =
|
||||
mzansiProfileProvider.user!.pro_pic_path.split("/").last;
|
||||
signtureController.text =
|
||||
mzansiProfileProvider.businessUser!.sig_path.split("/").last;
|
||||
KenLogger.success("title: ${mzansiProfileProvider.businessUser!.title}");
|
||||
KenLogger.success(
|
||||
"sig url: ${mzansiProfileProvider.businessUser!.sig_path}");
|
||||
titleTextController.text = mzansiProfileProvider.businessUser!.title;
|
||||
fnameController.text = mzansiProfileProvider.user!.fname;
|
||||
lnameController.text = mzansiProfileProvider.user!.lname;
|
||||
accessController.text = mzansiProfileProvider.businessUser!.access;
|
||||
});
|
||||
fileNameController.text =
|
||||
mzansiProfileProvider.user!.pro_pic_path.split("/").last;
|
||||
signtureController.text =
|
||||
mzansiProfileProvider.businessUser!.sig_path.split("/").last;
|
||||
KenLogger.success("title: ${mzansiProfileProvider.businessUser!.title}");
|
||||
KenLogger.success(
|
||||
"sig url: ${mzansiProfileProvider.businessUser!.sig_path}");
|
||||
titleTextController.text = mzansiProfileProvider.businessUser!.title;
|
||||
fnameController.text = mzansiProfileProvider.user!.fname;
|
||||
lnameController.text = mzansiProfileProvider.user!.lname;
|
||||
accessController.text = mzansiProfileProvider.businessUser!.access;
|
||||
if (AppEnviroment.getEnv() == "Prod") {
|
||||
env = "Prod";
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_banner_ad.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_banner_ad_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
@@ -58,8 +57,12 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
);
|
||||
}
|
||||
|
||||
void editCardWindow(MzansiProfileProvider mzansiProfileProvider,
|
||||
BuildContext ctxt, int index, double width) {
|
||||
void editCardWindow(
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MzansiWalletProvider walletProvider,
|
||||
BuildContext ctxt,
|
||||
int index,
|
||||
double width) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -144,6 +147,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
int statusCode = await MIHMzansiWalletApis
|
||||
.updateLoyaltyCardAPICall(
|
||||
walletProvider,
|
||||
mzansiProfileProvider.user!,
|
||||
widget.cardList[index].idloyalty_cards,
|
||||
widget.cardList[index].shop_name,
|
||||
@@ -211,7 +215,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
}
|
||||
|
||||
void deleteCardWindow(MzansiProfileProvider mzansiProfileProvider,
|
||||
BuildContext ctxt, int index) {
|
||||
MzansiWalletProvider walletProvider, BuildContext ctxt, int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -221,6 +225,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
onTap: () async {
|
||||
int statusCode =
|
||||
await MIHMzansiWalletApis.deleteLoyaltyCardAPICall(
|
||||
walletProvider,
|
||||
mzansiProfileProvider.user!,
|
||||
widget.cardList[index].idloyalty_cards,
|
||||
context,
|
||||
@@ -238,7 +243,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
}
|
||||
|
||||
void addToFavCardWindow(MzansiProfileProvider mzansiProfileProvider,
|
||||
BuildContext ctxt, int index) {
|
||||
MzansiWalletProvider walletProvider, BuildContext ctxt, int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -270,6 +275,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
onPressed: () async {
|
||||
int statusCode =
|
||||
await MIHMzansiWalletApis.updateLoyaltyCardAPICall(
|
||||
walletProvider,
|
||||
mzansiProfileProvider.user!,
|
||||
widget.cardList[index].idloyalty_cards,
|
||||
widget.cardList[index].shop_name,
|
||||
@@ -283,6 +289,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
context.pop();
|
||||
context.pop();
|
||||
await MIHMzansiWalletApis.getFavouriteLoyaltyCards(
|
||||
walletProvider,
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
context,
|
||||
);
|
||||
@@ -323,7 +330,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
}
|
||||
|
||||
void removeFromFavCardWindow(MzansiProfileProvider mzansiProfileProvider,
|
||||
BuildContext ctxt, int index) {
|
||||
MzansiWalletProvider walletProvider, BuildContext ctxt, int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -355,6 +362,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
onPressed: () async {
|
||||
int statusCode =
|
||||
await MIHMzansiWalletApis.updateLoyaltyCardAPICall(
|
||||
walletProvider,
|
||||
mzansiProfileProvider.user!,
|
||||
widget.cardList[index].idloyalty_cards,
|
||||
widget.cardList[index].shop_name,
|
||||
@@ -368,6 +376,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
context.pop();
|
||||
context.pop();
|
||||
await MIHMzansiWalletApis.getFavouriteLoyaltyCards(
|
||||
walletProvider,
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
context,
|
||||
);
|
||||
@@ -396,8 +405,8 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
);
|
||||
}
|
||||
|
||||
void viewCardWindow(
|
||||
MzansiProfileProvider mzansiProfileProvider, int index, double width) {
|
||||
void viewCardWindow(MzansiProfileProvider mzansiProfileProvider,
|
||||
MzansiWalletProvider walletProvider, 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++) {
|
||||
@@ -441,12 +450,14 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
if (widget.cardList[index].favourite == "") {
|
||||
addToFavCardWindow(
|
||||
mzansiProfileProvider,
|
||||
walletProvider,
|
||||
context,
|
||||
index,
|
||||
);
|
||||
} else {
|
||||
removeFromFavCardWindow(
|
||||
mzansiProfileProvider,
|
||||
walletProvider,
|
||||
context,
|
||||
index,
|
||||
);
|
||||
@@ -476,6 +487,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
});
|
||||
editCardWindow(
|
||||
mzansiProfileProvider,
|
||||
walletProvider,
|
||||
context,
|
||||
index,
|
||||
width,
|
||||
@@ -501,6 +513,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
onTap: () {
|
||||
deleteCardWindow(
|
||||
mzansiProfileProvider,
|
||||
walletProvider,
|
||||
context,
|
||||
index,
|
||||
);
|
||||
@@ -508,7 +521,6 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
),
|
||||
],
|
||||
onWindowTapClose: () {
|
||||
context.read<MihBannerAdProvider>().loadBannerAd();
|
||||
resetScreenBrightness();
|
||||
context.pop();
|
||||
},
|
||||
@@ -570,9 +582,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Consumer(builder: (context, bannerAdDisplay, child) {
|
||||
return MihBannerAd();
|
||||
}),
|
||||
MihBannerAd()
|
||||
// MihBannerAd(),
|
||||
],
|
||||
),
|
||||
@@ -705,9 +715,11 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
// final double width = size.width;
|
||||
//final double height = size.height;
|
||||
if (widget.cardList.isNotEmpty) {
|
||||
return Consumer<MzansiProfileProvider>(
|
||||
return Consumer2<MzansiProfileProvider, MzansiWalletProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MzansiWalletProvider walletProvider,
|
||||
Widget? child) {
|
||||
return GridView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
@@ -732,6 +744,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
setScreenBrightness(1.0);
|
||||
viewCardWindow(
|
||||
mzansiProfileProvider,
|
||||
walletProvider,
|
||||
index,
|
||||
size.width,
|
||||
);
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/components/mih_card_display.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
@@ -72,9 +73,6 @@ class _MihAddCardWindowState extends State<MihAddCardWindow> {
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
context.goNamed(
|
||||
'mzansiWallet',
|
||||
);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
@@ -141,9 +139,11 @@ class _MihAddCardWindowState extends State<MihAddCardWindow> {
|
||||
padding: MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: EdgeInsets.symmetric(horizontal: width * 0),
|
||||
child: Consumer<MzansiProfileProvider>(
|
||||
child: Consumer2<MzansiProfileProvider, MzansiWalletProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider mzansiProfileProvider, Widget? child) {
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MzansiWalletProvider walletProvider,
|
||||
Widget? child) {
|
||||
return Column(
|
||||
children: [
|
||||
MihForm(
|
||||
@@ -158,9 +158,7 @@ class _MihAddCardWindowState extends State<MihAddCardWindow> {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
requiredText: true,
|
||||
dropdownOptions: const [
|
||||
"+More",
|
||||
"Apple Tree",
|
||||
dropdownOptions: const <String>[
|
||||
"+More",
|
||||
"Apple Tree",
|
||||
"Auchan",
|
||||
@@ -206,7 +204,7 @@ class _MihAddCardWindowState extends State<MihAddCardWindow> {
|
||||
"Total Energies",
|
||||
"Toys R Us",
|
||||
"Woermann Brock",
|
||||
"Woolworths"
|
||||
"Woolworths",
|
||||
],
|
||||
),
|
||||
ValueListenableBuilder(
|
||||
@@ -306,6 +304,7 @@ class _MihAddCardWindowState extends State<MihAddCardWindow> {
|
||||
} else {
|
||||
int statusCode = await MIHMzansiWalletApis
|
||||
.addLoyaltyCardAPICall(
|
||||
walletProvider,
|
||||
mzansiProfileProvider.user!,
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
_shopController.text,
|
||||
@@ -317,7 +316,7 @@ class _MihAddCardWindowState extends State<MihAddCardWindow> {
|
||||
);
|
||||
if (statusCode == 201) {
|
||||
context.pop();
|
||||
KenLogger.error("Card Added Successfully");
|
||||
KenLogger.success("Card Added Successfully");
|
||||
successPopUp(
|
||||
"Successfully Added Card",
|
||||
"The loyalty card has been added to your favourites.",
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_banner_ad_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -25,25 +24,31 @@ class _MihWalletState extends State<MihWallet> {
|
||||
bool isLoading = true;
|
||||
|
||||
Future<void> setLoyaltyCards(
|
||||
MzansiProfileProvider mzansiProfileProvider) async {
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MzansiWalletProvider walletProvider,
|
||||
) async {
|
||||
await MIHMzansiWalletApis.getLoyaltyCards(
|
||||
mzansiProfileProvider.user!.app_id, context);
|
||||
walletProvider, mzansiProfileProvider.user!.app_id, context);
|
||||
}
|
||||
|
||||
Future<void> setFavouritesCards(
|
||||
MzansiProfileProvider mzansiProfileProvider) async {
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MzansiWalletProvider walletProvider,
|
||||
) async {
|
||||
await MIHMzansiWalletApis.getFavouriteLoyaltyCards(
|
||||
mzansiProfileProvider.user!.app_id, context);
|
||||
walletProvider, mzansiProfileProvider.user!.app_id, context);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
var mzansiProfileProvider = context.read<MzansiProfileProvider>();
|
||||
await setLoyaltyCards(mzansiProfileProvider);
|
||||
await setFavouritesCards(mzansiProfileProvider);
|
||||
context.read<MihBannerAdProvider>().loadBannerAd();
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
MzansiWalletProvider walletProvider =
|
||||
context.read<MzansiWalletProvider>();
|
||||
await setLoyaltyCards(mzansiProfileProvider, walletProvider);
|
||||
await setFavouritesCards(mzansiProfileProvider, walletProvider);
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
@@ -89,7 +94,6 @@ class _MihWalletState extends State<MihWallet> {
|
||||
temp[const Icon(Icons.favorite)] = () {
|
||||
context.read<MzansiWalletProvider>().setToolIndex(1);
|
||||
};
|
||||
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: context.watch<MzansiWalletProvider>().toolIndex,
|
||||
|
||||
@@ -29,19 +29,20 @@ class MihCards extends StatefulWidget {
|
||||
class _MihCardsState extends State<MihCards> {
|
||||
final TextEditingController cardSearchController = TextEditingController();
|
||||
final FocusNode searchFocusNode = FocusNode();
|
||||
List<MIHLoyaltyCard> listOfCards = [];
|
||||
final ValueNotifier<List<MIHLoyaltyCard>> searchShopName = ValueNotifier([]);
|
||||
final MobileScannerController scannerController = MobileScannerController(
|
||||
detectionSpeed: DetectionSpeed.unrestricted,
|
||||
);
|
||||
final boxFit = BoxFit.contain;
|
||||
late MzansiWalletProvider _walletProvider;
|
||||
late VoidCallback _searchListener;
|
||||
|
||||
void searchShop() {
|
||||
void searchShop(List<MIHLoyaltyCard> allCards) {
|
||||
if (cardSearchController.text.isEmpty) {
|
||||
searchShopName.value = listOfCards;
|
||||
searchShopName.value = allCards;
|
||||
} else {
|
||||
List<MIHLoyaltyCard> temp = [];
|
||||
for (var item in listOfCards) {
|
||||
for (var item in allCards) {
|
||||
if (item.shop_name
|
||||
.toLowerCase()
|
||||
.contains(cardSearchController.text.toLowerCase()) ||
|
||||
@@ -130,24 +131,21 @@ class _MihCardsState extends State<MihCards> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
cardSearchController.removeListener(searchShop);
|
||||
cardSearchController.removeListener(_searchListener);
|
||||
cardSearchController.dispose();
|
||||
searchShopName.dispose();
|
||||
searchFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void getLoyaltyCards(BuildContext context) async {
|
||||
setState(() {
|
||||
listOfCards = context.read<MzansiWalletProvider>().loyaltyCards;
|
||||
});
|
||||
searchShop();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
getLoyaltyCards(context);
|
||||
cardSearchController.addListener(searchShop);
|
||||
_walletProvider = context.read<MzansiWalletProvider>();
|
||||
_searchListener = () {
|
||||
searchShop(_walletProvider.loyaltyCards);
|
||||
};
|
||||
searchShopName.value = _walletProvider.loyaltyCards;
|
||||
cardSearchController.addListener(_searchListener);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -162,76 +160,89 @@ class _MihCardsState extends State<MihCards> {
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: MihSearchBar(
|
||||
controller: cardSearchController,
|
||||
hintText: "Search Cards",
|
||||
// prefixIcon: Icons.search,
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {
|
||||
// print("Search Icon Pressed: ${cardSearchController.text}");
|
||||
},
|
||||
searchFocusNode: searchFocusNode,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Consumer<MzansiWalletProvider>(
|
||||
builder: (context, mzansiWalletProvider, child) {
|
||||
listOfCards = mzansiWalletProvider.loyaltyCards;
|
||||
return ValueListenableBuilder<List<MIHLoyaltyCard>>(
|
||||
valueListenable: searchShopName,
|
||||
builder: (context, filteredCards, child) {
|
||||
return BuildLoyaltyCardList(
|
||||
cardList: filteredCards, //listOfCards,
|
||||
navIndex: 0,
|
||||
favouritesMode: false,
|
||||
searchText: cardSearchController,
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
return Consumer<MzansiWalletProvider>(
|
||||
builder: (BuildContext context, MzansiWalletProvider walletProvider,
|
||||
Widget? child) {
|
||||
if (cardSearchController.text.isEmpty) {
|
||||
searchShopName.value = walletProvider.loyaltyCards;
|
||||
} else {
|
||||
// Re-run search with updated card list
|
||||
searchShop(walletProvider.loyaltyCards);
|
||||
}
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: MihSearchBar(
|
||||
controller: cardSearchController,
|
||||
hintText: "Search Cards",
|
||||
// prefixIcon: Icons.search,
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onPrefixIconTap: () {
|
||||
// print("Search Icon Pressed: ${cardSearchController.text}");
|
||||
},
|
||||
searchFocusNode: searchFocusNode,
|
||||
),
|
||||
),
|
||||
label: "Add Loyalty Card",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
const SizedBox(height: 10),
|
||||
ValueListenableBuilder<List<MIHLoyaltyCard>>(
|
||||
valueListenable: searchShopName,
|
||||
builder: (context, filteredCards, child) {
|
||||
return BuildLoyaltyCardList(
|
||||
cardList: filteredCards, //listOfCards,
|
||||
navIndex: 0,
|
||||
favouritesMode: false,
|
||||
searchText: cardSearchController,
|
||||
);
|
||||
},
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
addCardWindow(context, width);
|
||||
},
|
||||
)
|
||||
]),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
label: "Add Loyalty Card",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onTap: () {
|
||||
addCardWindow(context, width);
|
||||
},
|
||||
)
|
||||
]),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientProfileTile extends StatefulWidget {
|
||||
@@ -27,13 +29,24 @@ class _PatientProfileTileState extends State<PatientProfileTile> {
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageTile(
|
||||
authenticateUser: true,
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
String? app_id = profileProvider.user!.app_id;
|
||||
if (patientManagerProvider.selectedPatient == null) {
|
||||
await MihPatientServices()
|
||||
.getPatientDetails(app_id, patientManagerProvider);
|
||||
}
|
||||
patientManagerProvider.setPersonalMode(true);
|
||||
context.goNamed(
|
||||
'patientProfile',
|
||||
);
|
||||
if (patientManagerProvider.selectedPatient != null) {
|
||||
context.goNamed(
|
||||
'patientProfile',
|
||||
);
|
||||
} else {
|
||||
context.goNamed("patientProfileSetup");
|
||||
}
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/patient-profile',
|
||||
// arguments: widget.arguments,
|
||||
|
||||
@@ -55,7 +55,7 @@ class _PatientClaimOrStatementState extends State<PatientClaimOrStatement> {
|
||||
],
|
||||
),
|
||||
Visibility(
|
||||
visible: patientManagerProvider.personalMode,
|
||||
visible: !patientManagerProvider.personalMode,
|
||||
child: Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_claim_or_statement.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_consultation.dart';
|
||||
@@ -30,19 +29,9 @@ class _PatientProfileState extends State<PatientProfile> {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
String? app_id = profileProvider.user!.app_id;
|
||||
if (patientManagerProvider.selectedPatient == null) {
|
||||
await MihPatientServices()
|
||||
.getPatientDetails(app_id, patientManagerProvider);
|
||||
}
|
||||
if (patientManagerProvider.selectedPatient == null) {
|
||||
// go to set up patient package
|
||||
context.goNamed("patientProfileSetup");
|
||||
} else {
|
||||
if (patientManagerProvider.selectedPatient != null) {
|
||||
await MihPatientServices()
|
||||
.getPatientConsultationNotes(patientManagerProvider);
|
||||
await MihPatientServices().getPatientDocuments(patientManagerProvider);
|
||||
|
||||
@@ -166,7 +166,8 @@ class MihMzansiDirectoryServices {
|
||||
List<BookmarkedBusiness> favouriteBusinesses =
|
||||
List<BookmarkedBusiness>.from(
|
||||
l.map((model) => BookmarkedBusiness.fromJson(model)));
|
||||
directoryProvider.setFavouriteBusinesses(businesses: favouriteBusinesses);
|
||||
directoryProvider.setBookmarkedeBusinesses(
|
||||
businesses: favouriteBusinesses);
|
||||
return favouriteBusinesses;
|
||||
} else if (response.statusCode == 404) {
|
||||
return [];
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/loyalty_card.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import '../mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||
import '../mih_config/mih_env.dart';
|
||||
@@ -17,6 +16,7 @@ class MIHMzansiWalletApis {
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
|
||||
static Future<void> getLoyaltyCards(
|
||||
MzansiWalletProvider walletProvider,
|
||||
String app_id,
|
||||
BuildContext context,
|
||||
) async {
|
||||
@@ -26,7 +26,7 @@ class MIHMzansiWalletApis {
|
||||
Iterable l = jsonDecode(response.body);
|
||||
List<MIHLoyaltyCard> myCards = List<MIHLoyaltyCard>.from(
|
||||
l.map((model) => MIHLoyaltyCard.fromJson(model)));
|
||||
context.read<MzansiWalletProvider>().setLoyaltyCards(cards: myCards);
|
||||
walletProvider.setLoyaltyCards(cards: myCards);
|
||||
// return myCards;
|
||||
} else {
|
||||
throw Exception('failed to fatch loyalty cards');
|
||||
@@ -34,6 +34,7 @@ class MIHMzansiWalletApis {
|
||||
}
|
||||
|
||||
static Future<void> getFavouriteLoyaltyCards(
|
||||
MzansiWalletProvider walletProvider,
|
||||
String app_id,
|
||||
BuildContext context,
|
||||
) async {
|
||||
@@ -44,7 +45,7 @@ class MIHMzansiWalletApis {
|
||||
Iterable l = jsonDecode(response.body);
|
||||
List<MIHLoyaltyCard> myCards = List<MIHLoyaltyCard>.from(
|
||||
l.map((model) => MIHLoyaltyCard.fromJson(model)));
|
||||
context.read<MzansiWalletProvider>().setFavouriteCards(cards: myCards);
|
||||
walletProvider.setFavouriteCards(cards: myCards);
|
||||
}
|
||||
// else {
|
||||
// throw Exception('failed to fatch loyalty cards');
|
||||
@@ -60,6 +61,7 @@ class MIHMzansiWalletApis {
|
||||
///
|
||||
/// Returns VOID (TRIGGERS NOTIGICATIOPN ON SUCCESS)
|
||||
static Future<int> deleteLoyaltyCardAPICall(
|
||||
MzansiWalletProvider walletProvider,
|
||||
AppUser signedInUser,
|
||||
int idloyalty_cards,
|
||||
BuildContext context,
|
||||
@@ -77,9 +79,7 @@ class MIHMzansiWalletApis {
|
||||
//print(response.statusCode);
|
||||
context.pop();
|
||||
if (response.statusCode == 200) {
|
||||
context
|
||||
.read<MzansiWalletProvider>()
|
||||
.deleteLoyaltyCard(cardId: idloyalty_cards);
|
||||
walletProvider.deleteLoyaltyCard(cardId: idloyalty_cards);
|
||||
}
|
||||
return response.statusCode;
|
||||
// if (response.statusCode == 200) {
|
||||
@@ -111,6 +111,7 @@ class MIHMzansiWalletApis {
|
||||
///
|
||||
/// Returns VOID (TRIGGERS SUCCESS pop up)
|
||||
static Future<int> addLoyaltyCardAPICall(
|
||||
MzansiWalletProvider walletProvider,
|
||||
AppUser signedInUser,
|
||||
String app_id,
|
||||
String shop_name,
|
||||
@@ -137,6 +138,10 @@ class MIHMzansiWalletApis {
|
||||
}),
|
||||
);
|
||||
context.pop();
|
||||
KenLogger.success("Response: $response");
|
||||
if (response.statusCode == 201) {
|
||||
await getLoyaltyCards(walletProvider, app_id, context);
|
||||
}
|
||||
return response.statusCode;
|
||||
// if (response.statusCode == 201) {
|
||||
// // Navigator.pop(context);
|
||||
@@ -164,6 +169,7 @@ class MIHMzansiWalletApis {
|
||||
///
|
||||
/// Returns VOID (TRIGGERS NOTIGICATIOPN ON SUCCESS)
|
||||
static Future<int> updateLoyaltyCardAPICall(
|
||||
MzansiWalletProvider walletProvider,
|
||||
AppUser signedInUser,
|
||||
int idloyalty_cards,
|
||||
String shopName,
|
||||
@@ -190,17 +196,17 @@ class MIHMzansiWalletApis {
|
||||
);
|
||||
context.pop();
|
||||
if (response.statusCode == 200) {
|
||||
context.read<MzansiWalletProvider>().editLoyaltyCard(
|
||||
updatedCard: MIHLoyaltyCard(
|
||||
idloyalty_cards: idloyalty_cards,
|
||||
app_id: signedInUser.app_id,
|
||||
shop_name: shopName,
|
||||
card_number: card_number,
|
||||
favourite: favourite,
|
||||
priority_index: priority_index,
|
||||
nickname: nickname,
|
||||
),
|
||||
);
|
||||
walletProvider.editLoyaltyCard(
|
||||
updatedCard: MIHLoyaltyCard(
|
||||
idloyalty_cards: idloyalty_cards,
|
||||
app_id: signedInUser.app_id,
|
||||
shop_name: shopName,
|
||||
card_number: card_number,
|
||||
favourite: favourite,
|
||||
priority_index: priority_index,
|
||||
nickname: nickname,
|
||||
),
|
||||
);
|
||||
}
|
||||
return response.statusCode;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: mzansi_innovation_hub
|
||||
description: ""
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
version: 1.2.2+99
|
||||
version: 1.2.2+103
|
||||
# version: 1.1.1+97 #--- Updated version for upgrader package testing
|
||||
|
||||
environment:
|
||||
|
||||
Reference in New Issue
Block a user