forked from yaso_meth/mih-project
NEW: Mzansi Directory Provider Setup
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calculato
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_calendar_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_ai_provider.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_components/mih_providers/mzansi_wallet_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
@@ -91,6 +92,9 @@ class _MzansiInnovationHubState extends State<MzansiInnovationHub> {
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => MzansiAiProvider(),
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => MzansiDirectoryProvider(),
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => MihBannerAdProvider(),
|
||||
),
|
||||
|
||||
@@ -396,7 +396,6 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
||||
return widget.business != null
|
||||
? MihBusinessProfilePreview(
|
||||
business: widget.business!,
|
||||
myLocation: myLocation,
|
||||
)
|
||||
: Text("NoBusiness Data");
|
||||
}
|
||||
@@ -424,7 +423,7 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
||||
"rating",
|
||||
"mission_vision",
|
||||
),
|
||||
startUpSearch: '',
|
||||
// startUpSearch: '',
|
||||
width: 300,
|
||||
).redacted(
|
||||
context: context,
|
||||
|
||||
@@ -4,17 +4,17 @@ 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_circle_avatar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_location_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihBusinessProfilePreview extends StatefulWidget {
|
||||
final Business business;
|
||||
final String? myLocation;
|
||||
const MihBusinessProfilePreview({
|
||||
super.key,
|
||||
required this.business,
|
||||
required this.myLocation,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -26,10 +26,10 @@ class _MihBusinessProfilePreviewState extends State<MihBusinessProfilePreview> {
|
||||
late Future<String> futureImageUrl;
|
||||
PlatformFile? file;
|
||||
|
||||
String calculateDistance() {
|
||||
String calculateDistance(MzansiDirectoryProvider directoryProvider) {
|
||||
try {
|
||||
double distanceInKm = MIHLocationAPI().getDistanceInMeaters(
|
||||
widget.myLocation!, widget.business.gps_location) /
|
||||
directoryProvider.userLocation, widget.business.gps_location) /
|
||||
1000;
|
||||
return "${distanceInKm.toStringAsFixed(2)} km";
|
||||
} catch (error) {
|
||||
@@ -48,73 +48,82 @@ class _MihBusinessProfilePreviewState extends State<MihBusinessProfilePreview> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double profilePictureWidth = 60;
|
||||
return Row(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "") {
|
||||
return MihCircleAvatar(
|
||||
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}),
|
||||
const SizedBox(width: 15),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
widget.business.Name,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.business.type,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.myLocation != null || widget.myLocation!.isEmpty
|
||||
? calculateDistance()
|
||||
: "0.00 km",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "") {
|
||||
return MihCircleAvatar(
|
||||
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
}),
|
||||
const SizedBox(width: 15),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.business.Name,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.business.type,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
directoryProvider.userPosition != null
|
||||
? calculateDistance(directoryProvider)
|
||||
: "0.00 km",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/bookmarked_business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
|
||||
class MzansiDirectoryProvider extends ChangeNotifier {
|
||||
int toolIndex;
|
||||
Position? userPosition;
|
||||
String userLocation;
|
||||
bool personalSearch;
|
||||
List<BookmarkedBusiness> bookmarkedBusinesses = [];
|
||||
Map<String, Business?> businessDetailsMap = {};
|
||||
List<Business>? searchedBusinesses;
|
||||
Business? selectedBusiness;
|
||||
List<AppUser>? searchedUsers;
|
||||
AppUser? selectedUser;
|
||||
String searchTerm;
|
||||
String businessTypeFilter;
|
||||
|
||||
MzansiDirectoryProvider({
|
||||
this.toolIndex = 0,
|
||||
this.personalSearch = true,
|
||||
this.userLocation = "Unknown Location",
|
||||
this.searchTerm = "",
|
||||
this.businessTypeFilter = "",
|
||||
});
|
||||
|
||||
void setToolIndex(int index) {
|
||||
toolIndex = index;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setUserPosition(Position? position) {
|
||||
userPosition = position;
|
||||
userLocation = "${position?.latitude}, ${position?.longitude}";
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setPersonalSearch(bool personal) {
|
||||
personalSearch = personal;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setFavouriteBusinesses({required List<BookmarkedBusiness> businesses}) {
|
||||
bookmarkedBusinesses = businesses;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setBusinessDetailsMap({required Map<String, Business?> detailsMap}) {
|
||||
businessDetailsMap = detailsMap;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setSearchedBusinesses({required List<Business> searchedBusinesses}) {
|
||||
this.searchedBusinesses = searchedBusinesses;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setSelectedBusiness({required Business business}) {
|
||||
selectedBusiness = business;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setSearchedUsers({required List<AppUser> searchedUsers}) {
|
||||
this.searchedUsers = searchedUsers;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setSelectedUser({required AppUser user}) {
|
||||
selectedUser = user;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setSearchTerm({required String searchTerm}) {
|
||||
this.searchTerm = searchTerm;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setBusinessTypeFilter({required String businessTypeFilter}) {
|
||||
this.businessTypeFilter = businessTypeFilter;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_print_prevew.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/Example/package_test.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/about_mih/about_mih.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/access_review/mih_access.dart';
|
||||
@@ -169,14 +169,15 @@ class MihGoRouter {
|
||||
path: MihGoRouterPaths.mzansiProfileView,
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
KenLogger.success("MihGoRouter: mzansiProfileView");
|
||||
final AppUser? user = state.extra as AppUser?;
|
||||
if (user == null) {
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
if (directoryProvider.selectedUser == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.go(MihGoRouterPaths.mihHome);
|
||||
});
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return MzansiProfileView(user: user);
|
||||
return MzansiProfileView();
|
||||
},
|
||||
),
|
||||
// ========================== Mzansi Profile Business ==================================
|
||||
@@ -203,9 +204,10 @@ class MihGoRouter {
|
||||
KenLogger.success("MihGoRouter: businessProfileView");
|
||||
String? businessId = state.uri.queryParameters['business_id'];
|
||||
KenLogger.success("businessId: $businessId");
|
||||
final BusinessViewArguments? args =
|
||||
state.extra as BusinessViewArguments?;
|
||||
if (args == null && businessId == null) {
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
if (directoryProvider.selectedBusiness == null &&
|
||||
businessId == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.go(MihGoRouterPaths.mihHome);
|
||||
});
|
||||
@@ -213,7 +215,6 @@ class MihGoRouter {
|
||||
}
|
||||
return MzansiBusinessProfileView(
|
||||
key: UniqueKey(),
|
||||
arguments: args,
|
||||
businessId: businessId,
|
||||
);
|
||||
},
|
||||
@@ -406,15 +407,13 @@ class MihGoRouter {
|
||||
name: "mzansiDirectory",
|
||||
path: MihGoRouterPaths.mzansiDirectory,
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
final MzansiDirectoryArguments? args =
|
||||
state.extra as MzansiDirectoryArguments?;
|
||||
if (args == null) {
|
||||
if (context.watch<MzansiProfileProvider>().business == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.go(MihGoRouterPaths.mihHome);
|
||||
});
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return MzansiDirectory(arguments: args);
|
||||
return MzansiDirectory();
|
||||
},
|
||||
),
|
||||
// ========================== End ==================================
|
||||
|
||||
@@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
|
||||
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/patient_access.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_access_controlls_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_services/mih_access_controls_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
@@ -10,18 +13,15 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_warning_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patient_access.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildBusinessAccessList extends StatefulWidget {
|
||||
final List<PatientAccess> patientAccessList;
|
||||
final AppUser signedInUser;
|
||||
final String filterText;
|
||||
final void Function()? onSuccessUpate;
|
||||
|
||||
const BuildBusinessAccessList({
|
||||
super.key,
|
||||
required this.patientAccessList,
|
||||
required this.signedInUser,
|
||||
required this.filterText,
|
||||
required this.onSuccessUpate,
|
||||
});
|
||||
|
||||
@@ -60,18 +60,20 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget displayQueue(int index) {
|
||||
String line1 =
|
||||
"Business Name: ${widget.patientAccessList[index].requested_by}";
|
||||
Widget displayQueue(
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihAccessControllsProvider accessProvider,
|
||||
int index,
|
||||
List<PatientAccess> filteredList) {
|
||||
String line1 = "Business Name: ${filteredList[index].requested_by}";
|
||||
String line2 = "";
|
||||
|
||||
line2 +=
|
||||
"Request Date: ${widget.patientAccessList[index].requested_on.substring(0, 16).replaceAll("T", " ")}\n";
|
||||
line2 +=
|
||||
"Profile Type: ${widget.patientAccessList[index].type.toUpperCase()}\n";
|
||||
"Request Date: ${filteredList[index].requested_on.substring(0, 16).replaceAll("T", " ")}\n";
|
||||
line2 += "Profile Type: ${filteredList[index].type.toUpperCase()}\n";
|
||||
//subtitle += "Business Type: ${widget.patientAccessList[index].type}\n";
|
||||
String line3 = "Status: ";
|
||||
String access = widget.patientAccessList[index].status.toUpperCase();
|
||||
String access = filteredList[index].status.toUpperCase();
|
||||
|
||||
TextSpan accessWithColour;
|
||||
if (access == "APPROVED") {
|
||||
@@ -118,7 +120,7 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
// ),
|
||||
// ),
|
||||
onTap: () {
|
||||
viewApprovalPopUp(index);
|
||||
viewApprovalPopUp(mzansiProfileProvider, accessProvider, index);
|
||||
},
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward,
|
||||
@@ -153,23 +155,24 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
}
|
||||
}
|
||||
|
||||
void viewApprovalPopUp(int index) {
|
||||
void viewApprovalPopUp(MzansiProfileProvider mzansiProfileProvider,
|
||||
MihAccessControllsProvider accessProvider, int index) {
|
||||
String subtitle =
|
||||
"Business Name: ${widget.patientAccessList[index].requested_by}\n";
|
||||
"Business Name: ${accessProvider.accessList![index].requested_by}\n";
|
||||
subtitle +=
|
||||
"Requested Date: ${widget.patientAccessList[index].requested_on.substring(0, 16).replaceAll("T", " ")}\n";
|
||||
"Requested Date: ${accessProvider.accessList![index].requested_on.substring(0, 16).replaceAll("T", " ")}\n";
|
||||
|
||||
subtitle +=
|
||||
"Profile Type: ${widget.patientAccessList[index].type.toUpperCase()}\n";
|
||||
"Profile Type: ${accessProvider.accessList![index].type.toUpperCase()}\n";
|
||||
subtitle +=
|
||||
"Status: ${widget.patientAccessList[index].status.toUpperCase()}";
|
||||
if (widget.patientAccessList[index].status == 'pending') {
|
||||
"Status: ${accessProvider.accessList![index].status.toUpperCase()}";
|
||||
if (accessProvider.accessList![index].status == 'pending') {
|
||||
// "\nYou are about to approve an access request to your patient profile.\nPlease be aware that once approved, ${widget.patientAccessList[index].requested_by} will have access to your profile forever and will be able to contribute to it.\nIf you are unsure about an upcoming appointment with ${widget.patientAccessList[index].requested_by}, please contact *Add Number here* for clarification before approving this request.";
|
||||
} else {
|
||||
subtitle +=
|
||||
"\nActioned By: ${widget.patientAccessList[index].approved_by}\n";
|
||||
"\nActioned By: ${accessProvider.accessList![index].approved_by}\n";
|
||||
subtitle +=
|
||||
"Actioned On: ${widget.patientAccessList[index].approved_on.substring(0, 16).replaceAll("T", " ")}";
|
||||
"Actioned On: ${accessProvider.accessList![index].approved_on.substring(0, 16).replaceAll("T", " ")}";
|
||||
// subtitle +=
|
||||
// "You have approved this access request to your patient profile.\nPlease be aware that once approved, ${widget.patientAccessList[index].requested_by} will have access to your profile forever and will be able to contribute to it.";
|
||||
}
|
||||
@@ -199,7 +202,7 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Visibility(
|
||||
visible: widget.patientAccessList[index].status == 'pending',
|
||||
visible: accessProvider.accessList![index].status == 'pending',
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
@@ -271,7 +274,7 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.patientAccessList[index].status == 'approved',
|
||||
visible: accessProvider.accessList![index].status == 'approved',
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
@@ -338,7 +341,7 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
height: 20,
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.patientAccessList[index].status == 'pending',
|
||||
visible: accessProvider.accessList![index].status == 'pending',
|
||||
child: Wrap(
|
||||
runSpacing: 10,
|
||||
spacing: 10,
|
||||
@@ -348,15 +351,20 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
print("request declined");
|
||||
int statusCode = await MihAccessControlsServices()
|
||||
.updatePatientAccessAPICall(
|
||||
widget.patientAccessList[index].business_id,
|
||||
widget.patientAccessList[index].requested_by,
|
||||
widget.patientAccessList[index].app_id,
|
||||
accessProvider.accessList![index].business_id,
|
||||
accessProvider.accessList![index].requested_by,
|
||||
accessProvider.accessList![index].app_id,
|
||||
"declined",
|
||||
"${widget.signedInUser.fname} ${widget.signedInUser.lname}",
|
||||
widget.signedInUser,
|
||||
"${mzansiProfileProvider.user!.fname} ${mzansiProfileProvider.user!.lname}",
|
||||
mzansiProfileProvider.user!,
|
||||
context,
|
||||
);
|
||||
if (statusCode == 200) {
|
||||
await MihAccessControlsServices()
|
||||
.getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
context.pop();
|
||||
successPopUp("Successfully Actioned Request",
|
||||
"You have successfully Declined access request");
|
||||
@@ -384,15 +392,20 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
print("request approved");
|
||||
int statusCode = await MihAccessControlsServices()
|
||||
.updatePatientAccessAPICall(
|
||||
widget.patientAccessList[index].business_id,
|
||||
widget.patientAccessList[index].requested_by,
|
||||
widget.patientAccessList[index].app_id,
|
||||
accessProvider.accessList![index].business_id,
|
||||
accessProvider.accessList![index].requested_by,
|
||||
accessProvider.accessList![index].app_id,
|
||||
"approved",
|
||||
"${widget.signedInUser.fname} ${widget.signedInUser.lname}",
|
||||
widget.signedInUser,
|
||||
"${mzansiProfileProvider.user!.fname} ${mzansiProfileProvider.user!.lname}",
|
||||
mzansiProfileProvider.user!,
|
||||
context,
|
||||
);
|
||||
if (statusCode == 200) {
|
||||
await MihAccessControlsServices()
|
||||
.getBusinessAccessListOfPatient(
|
||||
mzansiProfileProvider.user!.app_id,
|
||||
accessProvider,
|
||||
);
|
||||
context.pop();
|
||||
successPopUp("Successfully Actioned Request",
|
||||
"You have successfully Accepted access request");
|
||||
@@ -487,6 +500,16 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
);
|
||||
}
|
||||
|
||||
List<PatientAccess> filterAccessList(List<PatientAccess> accessList) {
|
||||
if (widget.filterText == "All") {
|
||||
return accessList;
|
||||
}
|
||||
return accessList
|
||||
.where((item) =>
|
||||
item.status.toLowerCase() == widget.filterText.toLowerCase())
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
@@ -500,21 +523,30 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
||||
height = size.height;
|
||||
});
|
||||
checkScreenSize();
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
return Consumer2<MzansiProfileProvider, MihAccessControllsProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider mzansiProfileProvider,
|
||||
MihAccessControllsProvider accessProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemCount: filterAccessList(accessProvider.accessList!).length,
|
||||
itemBuilder: (context, index) {
|
||||
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||
//print(index);
|
||||
final filteredList = filterAccessList(accessProvider.accessList!);
|
||||
return displayQueue(
|
||||
mzansiProfileProvider, accessProvider, index, filteredList);
|
||||
},
|
||||
);
|
||||
},
|
||||
itemCount: widget.patientAccessList.length,
|
||||
itemBuilder: (context, index) {
|
||||
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||
//print(index);
|
||||
return displayQueue(index);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,6 @@ class _MihBusinessHomeState extends State<MihBusinessHome>
|
||||
temp.add({
|
||||
"Mzansi Directory": MzansiDirectoryTile(
|
||||
packageSize: packageSize,
|
||||
personalSelected: false,
|
||||
)
|
||||
});
|
||||
//=============== Calculator ===============
|
||||
|
||||
@@ -118,7 +118,6 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
||||
temp.add({
|
||||
"Mzansi Directory": MzansiDirectoryTile(
|
||||
packageSize: packageSize,
|
||||
personalSelected: true,
|
||||
)
|
||||
});
|
||||
//=============== Calendar ===============
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_business_profile_preview.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildBusinessSearchResultsList extends StatefulWidget {
|
||||
final List<Business> businessList;
|
||||
final String myLocation;
|
||||
final String? startUpSearch;
|
||||
const BuildBusinessSearchResultsList({
|
||||
super.key,
|
||||
required this.businessList,
|
||||
required this.myLocation,
|
||||
required this.startUpSearch,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -26,52 +23,48 @@ class _BuildBusinessSearchResultsListState
|
||||
extends State<BuildBusinessSearchResultsList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.businessList.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
return Material(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'businessProfileView',
|
||||
extra: BusinessViewArguments(
|
||||
widget.businessList[index],
|
||||
widget.businessList[index].Name,
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.businessList.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
return Material(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
directoryProvider.setSelectedBusiness(
|
||||
business: widget.businessList[index],
|
||||
);
|
||||
context.pushNamed(
|
||||
'businessProfileView',
|
||||
);
|
||||
},
|
||||
splashColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||
.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsGeometry.symmetric(
|
||||
// vertical: 5,
|
||||
horizontal: 25,
|
||||
),
|
||||
child: MihBusinessProfilePreview(
|
||||
business: widget.businessList[index],
|
||||
),
|
||||
),
|
||||
);
|
||||
// // Navigator.of(context).pushNamed(
|
||||
// // '/business-profile/view',
|
||||
// // arguments: BusinessViewArguments(
|
||||
// // widget.businessList[index],
|
||||
// // widget.businessList[index].Name,
|
||||
// // ),
|
||||
// );
|
||||
},
|
||||
splashColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||
.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsGeometry.symmetric(
|
||||
// vertical: 5,
|
||||
horizontal: 25,
|
||||
),
|
||||
child: MihBusinessProfilePreview(
|
||||
business: widget.businessList[index],
|
||||
myLocation: widget.myLocation,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_business_profile_preview.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildFavouriteBusinessesList extends StatefulWidget {
|
||||
final List<Business?> favouriteBusinesses;
|
||||
final String? myLocation;
|
||||
const BuildFavouriteBusinessesList({
|
||||
super.key,
|
||||
required this.favouriteBusinesses,
|
||||
required this.myLocation,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -24,54 +23,49 @@ class _BuildFavouriteBusinessesListState
|
||||
extends State<BuildFavouriteBusinessesList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.favouriteBusinesses.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
final Business? business = widget.favouriteBusinesses[index];
|
||||
|
||||
if (business == null) {
|
||||
return const SizedBox(); // Or a placeholder if a business couldn't be loaded
|
||||
}
|
||||
|
||||
return Material(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'businessProfileView',
|
||||
extra: BusinessViewArguments(
|
||||
widget.favouriteBusinesses[index]!,
|
||||
widget.favouriteBusinesses[index]!.Name,
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.favouriteBusinesses.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
if (widget.favouriteBusinesses[index] == null) {
|
||||
return const SizedBox(); // Or a placeholder if a business couldn't be loaded
|
||||
}
|
||||
return Material(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
directoryProvider.setSelectedBusiness(
|
||||
business: widget.favouriteBusinesses[index]!,
|
||||
);
|
||||
context.goNamed(
|
||||
'businessProfileView',
|
||||
);
|
||||
},
|
||||
splashColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||
.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 25,
|
||||
),
|
||||
child: MihBusinessProfilePreview(
|
||||
business: widget.favouriteBusinesses[index]!,
|
||||
),
|
||||
),
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/business-profile/view',
|
||||
// arguments: BusinessViewArguments(
|
||||
// business,
|
||||
// business.Name,
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
splashColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||
.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 25,
|
||||
),
|
||||
child: MihBusinessProfilePreview(
|
||||
business: business, myLocation: widget.myLocation),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -3,7 +3,9 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_personal_profile_preview.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildUserSearchResultsList extends StatefulWidget {
|
||||
final List<AppUser> userList;
|
||||
@@ -21,45 +23,46 @@ class _BuildUserSearchResultsListState
|
||||
extends State<BuildUserSearchResultsList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.userList.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
return Material(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'mzansiProfileView',
|
||||
extra: widget.userList[index],
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/mzansi-profile/view',
|
||||
// arguments: widget.userList[index],
|
||||
// );
|
||||
},
|
||||
splashColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||
.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsGeometry.symmetric(
|
||||
// vertical: 5,
|
||||
horizontal: 25,
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.userList.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
return Material(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
directoryProvider.setSelectedUser(
|
||||
user: widget.userList[index]);
|
||||
context.pushNamed(
|
||||
'mzansiProfileView',
|
||||
);
|
||||
},
|
||||
splashColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||
.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsGeometry.symmetric(
|
||||
// vertical: 5,
|
||||
horizontal: 25,
|
||||
),
|
||||
child:
|
||||
MihPersonalProfilePreview(user: widget.userList[index]),
|
||||
),
|
||||
),
|
||||
child: MihPersonalProfilePreview(
|
||||
user: widget.userList[index],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.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_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_location_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MzansiDirectory extends StatefulWidget {
|
||||
final MzansiDirectoryArguments arguments;
|
||||
const MzansiDirectory({
|
||||
super.key,
|
||||
required this.arguments,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -21,75 +20,54 @@ class MzansiDirectory extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
int _selcetedIndex = 0;
|
||||
late Future<Position?> futurePosition =
|
||||
MIHLocationAPI().getGPSPosition(context);
|
||||
|
||||
Future<void> initialiseGPSLocation() async {
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
MIHLocationAPI().getGPSPosition(context).then((position) {
|
||||
directoryProvider.setUserPosition(position);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.arguments.packageIndex == null) {
|
||||
_selcetedIndex = 0;
|
||||
} else {
|
||||
_selcetedIndex = widget.arguments.packageIndex!;
|
||||
}
|
||||
initialiseGPSLocation();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('MzansiDirectory build method called!');
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: _selcetedIndex,
|
||||
selectedbodyIndex: context.watch<MzansiDirectoryProvider>().toolIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selcetedIndex = newValue;
|
||||
});
|
||||
context.read<MzansiDirectoryProvider>().setToolIndex(newValue);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
FutureBuilder(
|
||||
future: futurePosition,
|
||||
builder: (context, asyncSnapshot) {
|
||||
String myLocation = "";
|
||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||
myLocation = "Getting Your GPS Location Ready";
|
||||
} else {
|
||||
myLocation = asyncSnapshot.data
|
||||
.toString()
|
||||
.replaceAll("Latitude: ", "")
|
||||
.replaceAll("Longitude: ", "");
|
||||
}
|
||||
return MihSearchMzansi(
|
||||
personalSearch: widget.arguments.personalSearch,
|
||||
myLocation: myLocation,
|
||||
startSearchText: widget.arguments.startSearchText,
|
||||
);
|
||||
}),
|
||||
List<Widget> toolBodies = [];
|
||||
// String myLocation = "Getting Your GPS Location Ready";
|
||||
// if (directoryProvider.userPosition != null) {
|
||||
// myLocation = directoryProvider.userPosition
|
||||
// .toString()
|
||||
// .replaceAll("Latitude: ", "")
|
||||
// .replaceAll("Longitude: ", "");
|
||||
// }
|
||||
toolBodies.addAll([
|
||||
MihSearchMzansi(
|
||||
// personalSearch: directoryProvider.personalSearch,
|
||||
// startSearchText: "",
|
||||
),
|
||||
// MihContacts(),
|
||||
FutureBuilder(
|
||||
future: futurePosition,
|
||||
builder: (context, asyncSnapshot) {
|
||||
String myLocation = "";
|
||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||
myLocation = "Getting Your GPS Location Ready";
|
||||
} else {
|
||||
myLocation = asyncSnapshot.data
|
||||
.toString()
|
||||
.replaceAll("Latitude: ", "")
|
||||
.replaceAll("Longitude: ", "");
|
||||
}
|
||||
return MihFavouriteBusinesses(
|
||||
myLocation: myLocation,
|
||||
);
|
||||
}),
|
||||
];
|
||||
MihFavouriteBusinesses(),
|
||||
]);
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
@@ -98,9 +76,13 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
);
|
||||
directoryProvider.setToolIndex(0);
|
||||
directoryProvider.setPersonalSearch(true);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
@@ -109,23 +91,14 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.search)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 0;
|
||||
});
|
||||
context.read<MzansiDirectoryProvider>().setToolIndex(0);
|
||||
};
|
||||
// temp[const Icon(Icons.person)] = () {
|
||||
// setState(() {
|
||||
// _selcetedIndex = 1;
|
||||
// });
|
||||
// };
|
||||
temp[const Icon(Icons.business_center)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 1;
|
||||
});
|
||||
context.read<MzansiDirectoryProvider>().setToolIndex(1);
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: _selcetedIndex,
|
||||
selcetedIndex: context.watch<MzansiDirectoryProvider>().toolIndex,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -133,7 +106,7 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
List<String> toolTitles = [
|
||||
"Mzansi Search",
|
||||
"Favourite Businesses",
|
||||
"Contacts",
|
||||
// "Contacts",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.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_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class MzansiDirectoryTile extends StatefulWidget {
|
||||
final double packageSize;
|
||||
final bool personalSelected;
|
||||
const MzansiDirectoryTile({
|
||||
super.key,
|
||||
required this.packageSize,
|
||||
required this.personalSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -26,10 +23,6 @@ class _MzansiDirectoryTileState extends State<MzansiDirectoryTile> {
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"mzansiDirectory",
|
||||
extra: MzansiDirectoryArguments(
|
||||
personalSearch: widget.personalSelected,
|
||||
startSearchText: null,
|
||||
),
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/mzansi-directory',
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/bookmarked_business.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:supertokens_flutter/supertokens.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihFavouriteBusinesses extends StatefulWidget {
|
||||
final String? myLocation;
|
||||
const MihFavouriteBusinesses({
|
||||
super.key,
|
||||
required this.myLocation,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -29,42 +27,42 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
||||
final TextEditingController businessSearchController =
|
||||
TextEditingController();
|
||||
final FocusNode searchFocusNode = FocusNode();
|
||||
late Future<List<BookmarkedBusiness>> boookmarkedBusinessListFuture;
|
||||
List<BookmarkedBusiness> listBookmarkedBusinesses = [];
|
||||
final ValueNotifier<List<Business?>> searchBookmarkedBusinesses =
|
||||
ValueNotifier([]);
|
||||
late Future<Map<String, Business?>> businessDetailsMapFuture;
|
||||
Map<String, Business?> _businessDetailsMap = {};
|
||||
Timer? _debounce;
|
||||
|
||||
Future<Map<String, Business?>>
|
||||
getAndMapAllBusinessDetailsForBookmarkedBusinesses() async {
|
||||
String user_id = await SuperTokens.getUserId();
|
||||
List<BookmarkedBusiness> bookmarked = await MihMzansiDirectoryServices()
|
||||
.getAllUserBookmarkedBusiness(user_id);
|
||||
listBookmarkedBusinesses = bookmarked;
|
||||
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 bookmarked) {
|
||||
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 < bookmarked.length; i++) {
|
||||
businessMap[bookmarked[i].business_id] = details[i];
|
||||
for (int i = 0; i < directoryProvider.bookmarkedBusinesses.length; i++) {
|
||||
businessMap[directoryProvider.bookmarkedBusinesses[i].business_id] =
|
||||
details[i];
|
||||
}
|
||||
_businessDetailsMap = businessMap;
|
||||
_filterAndSetBusinesses();
|
||||
return businessMap;
|
||||
directoryProvider.setBusinessDetailsMap(detailsMap: businessMap);
|
||||
_filterAndSetBusinesses(directoryProvider);
|
||||
}
|
||||
|
||||
void _filterAndSetBusinesses() {
|
||||
void _filterAndSetBusinesses(MzansiDirectoryProvider directoryProvider) {
|
||||
List<Business?> businessesToDisplay = [];
|
||||
String query = businessSearchController.text.toLowerCase();
|
||||
for (var bookmarked in listBookmarkedBusinesses) {
|
||||
for (var bookmarked in directoryProvider.bookmarkedBusinesses) {
|
||||
if (bookmarked.business_name.toLowerCase().contains(query)) {
|
||||
if (_businessDetailsMap.containsKey(bookmarked.business_id)) {
|
||||
businessesToDisplay.add(_businessDetailsMap[bookmarked.business_id]);
|
||||
if (directoryProvider.businessDetailsMap
|
||||
.containsKey(bookmarked.business_id)) {
|
||||
businessesToDisplay.add(
|
||||
directoryProvider.businessDetailsMap[bookmarked.business_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,14 +80,21 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
businessDetailsMapFuture =
|
||||
getAndMapAllBusinessDetailsForBookmarkedBusinesses();
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
|
||||
getAndMapAllBusinessDetailsForBookmarkedBusinesses(
|
||||
mzansiProfileProvider,
|
||||
directoryProvider,
|
||||
);
|
||||
businessSearchController.addListener(() {
|
||||
if (_debounce?.isActive ?? false) {
|
||||
_debounce!.cancel();
|
||||
}
|
||||
_debounce = Timer(const Duration(milliseconds: 200), () {
|
||||
_filterAndSetBusinesses();
|
||||
_filterAndSetBusinesses(directoryProvider);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -123,141 +128,95 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FutureBuilder<Map<String, Business?>>(
|
||||
future: businessDetailsMapFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Mihloadingcircle(
|
||||
message: "Getting your favourites",
|
||||
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 (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.hasData && snapshot.data!.isNotEmpty) {
|
||||
// No need to re-filter here, _filterAndSetBusinesses is called in initState
|
||||
// and by the text controller listener.
|
||||
return ValueListenableBuilder<List<Business?>>(
|
||||
valueListenable:
|
||||
searchBookmarkedBusinesses, // Listen to changes in this
|
||||
builder: (context, businesses, child) {
|
||||
// Display message if no results after search
|
||||
if (businesses.isEmpty &&
|
||||
businessSearchController.text.isNotEmpty) {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: 165,
|
||||
} 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,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
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"),
|
||||
),
|
||||
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"),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return BuildFavouriteBusinessesList(
|
||||
favouriteBusinesses:
|
||||
businesses, // Pass the filtered list from ValueNotifier
|
||||
myLocation: widget.myLocation,
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
// This block handles the case where there are no bookmarked businesses initially
|
||||
|
||||
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,
|
||||
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"),
|
||||
// WidgetSpan(
|
||||
// alignment:
|
||||
// PlaceholderAlignment.middle,
|
||||
// child: Icon(
|
||||
// Icons.search,
|
||||
// size: 20,
|
||||
// color:
|
||||
// MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
TextSpan(
|
||||
text:
|
||||
" to find your favourite businesses of mzansi"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(
|
||||
child: Text(
|
||||
"Error loading bookmarked businesses: ${snapshot.error}"), // Show specific error
|
||||
);
|
||||
} else {
|
||||
// Fallback for unexpected states
|
||||
return Center(
|
||||
child: Text("An unknown error occurred."),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return BuildFavouriteBusinessesList(
|
||||
favouriteBusinesses: filteredBusinesses,
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
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/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
@@ -9,22 +10,18 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
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_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/build_business_search_resultsList.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/builders/build_user_search_results_list.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihSearchMzansi extends StatefulWidget {
|
||||
final bool personalSearch;
|
||||
final String? myLocation;
|
||||
final String? startSearchText;
|
||||
const MihSearchMzansi({
|
||||
super.key,
|
||||
required this.personalSearch,
|
||||
required this.myLocation,
|
||||
required this.startSearchText,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -35,80 +32,87 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
final TextEditingController mzansiSearchController = TextEditingController();
|
||||
final TextEditingController businessTypeController = TextEditingController();
|
||||
final FocusNode searchFocusNode = FocusNode();
|
||||
late bool userSearch;
|
||||
Future<List<AppUser>?> futureUserSearchResults = Future.value();
|
||||
Future<List<Business>?> futureBusinessSearchResults = Future.value();
|
||||
// late bool userSearch;
|
||||
// Future<List<AppUser>?> futureUserSearchResults = Future.value();
|
||||
List<AppUser> userSearchResults = [];
|
||||
List<Business> businessSearchResults = [];
|
||||
late Future<List<String>> availableBusinessTypes;
|
||||
bool filterOn = false;
|
||||
bool loadingSearchResults = false;
|
||||
|
||||
void swapPressed() {
|
||||
Future<void> swapPressed(MzansiDirectoryProvider directoryProvider) async {
|
||||
directoryProvider.setPersonalSearch(!directoryProvider.personalSearch);
|
||||
setState(() {
|
||||
userSearch = !userSearch;
|
||||
if (filterOn) {
|
||||
filterOn = !filterOn;
|
||||
}
|
||||
});
|
||||
if (businessTypeController.text.isNotEmpty) {
|
||||
setState(() {
|
||||
futureBusinessSearchResults = Future.value();
|
||||
businessTypeController.clear();
|
||||
});
|
||||
}
|
||||
searchPressed();
|
||||
await searchPressed(directoryProvider);
|
||||
}
|
||||
|
||||
void clearAll() {
|
||||
void clearAll(MzansiDirectoryProvider directoryProvider) {
|
||||
directoryProvider.setSearchedBusinesses(searchedBusinesses: []);
|
||||
directoryProvider.setSearchedUsers(searchedUsers: []);
|
||||
directoryProvider.setSearchTerm(searchTerm: "");
|
||||
setState(() {
|
||||
futureUserSearchResults = Future.value();
|
||||
futureBusinessSearchResults = Future.value();
|
||||
mzansiSearchController.clear();
|
||||
businessTypeController.clear();
|
||||
});
|
||||
}
|
||||
|
||||
void searchPressed() {
|
||||
Future<void> searchPressed(MzansiDirectoryProvider directoryProvider) async {
|
||||
setState(() {
|
||||
// userSearch = !userSearch;
|
||||
if (userSearch && mzansiSearchController.text.isNotEmpty) {
|
||||
futureUserSearchResults =
|
||||
MihUserServices().searchUsers(mzansiSearchController.text, context);
|
||||
} else {
|
||||
if (
|
||||
// mzansiSearchController.text.isNotEmpty &&
|
||||
businessTypeController.text.isNotEmpty) {
|
||||
futureBusinessSearchResults = MihBusinessDetailsServices()
|
||||
.searchBusinesses(mzansiSearchController.text,
|
||||
businessTypeController.text, context);
|
||||
} else if (mzansiSearchController.text.isNotEmpty) {
|
||||
futureBusinessSearchResults = MihBusinessDetailsServices()
|
||||
.searchBusinesses(mzansiSearchController.text,
|
||||
businessTypeController.text, context);
|
||||
}
|
||||
loadingSearchResults = true;
|
||||
});
|
||||
directoryProvider.setSearchTerm(searchTerm: mzansiSearchController.text);
|
||||
directoryProvider.setBusinessTypeFilter(
|
||||
businessTypeFilter: businessTypeController.text);
|
||||
if (directoryProvider.personalSearch &&
|
||||
directoryProvider.searchTerm.isNotEmpty) {
|
||||
final userResults = await MihUserServices()
|
||||
.searchUsers(directoryProvider.searchTerm, context);
|
||||
directoryProvider.setSearchedUsers(searchedUsers: userResults);
|
||||
} else {
|
||||
List<Business>? businessSearchResults = [];
|
||||
if (directoryProvider.businessTypeFilter.isNotEmpty) {
|
||||
businessSearchResults = await MihBusinessDetailsServices()
|
||||
.searchBusinesses(directoryProvider.searchTerm,
|
||||
directoryProvider.businessTypeFilter, context);
|
||||
} else if (directoryProvider.searchTerm.isNotEmpty) {
|
||||
businessSearchResults = await MihBusinessDetailsServices()
|
||||
.searchBusinesses(directoryProvider.searchTerm,
|
||||
directoryProvider.businessTypeFilter, context);
|
||||
}
|
||||
directoryProvider.setSearchedBusinesses(
|
||||
searchedBusinesses: businessSearchResults);
|
||||
}
|
||||
setState(() {
|
||||
loadingSearchResults = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
businessTypeController.dispose();
|
||||
mzansiSearchController.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
directoryProvider.setSearchedUsers(searchedUsers: []);
|
||||
setState(() {
|
||||
userSearch = widget.personalSearch;
|
||||
availableBusinessTypes =
|
||||
MihBusinessDetailsServices().fetchAllBusinessTypes();
|
||||
if (widget.startSearchText != null) {
|
||||
mzansiSearchController.text = widget.startSearchText!;
|
||||
searchPressed();
|
||||
} else {
|
||||
mzansiSearchController.text = "";
|
||||
}
|
||||
mzansiSearchController.text = "";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -123,444 +127,426 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: MihSearchBar(
|
||||
controller: mzansiSearchController,
|
||||
hintText: "Search Mzansi",
|
||||
prefixIcon: Icons.search,
|
||||
prefixAltIcon: userSearch ? Icons.person : Icons.business,
|
||||
suffixTools: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
swapPressed();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.swap_horiz_rounded,
|
||||
size: 35,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
],
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {
|
||||
searchPressed();
|
||||
},
|
||||
onClearIconTap: () {
|
||||
clearAll();
|
||||
},
|
||||
searchFocusNode: searchFocusNode,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !userSearch,
|
||||
child: const SizedBox(width: 10),
|
||||
),
|
||||
Visibility(
|
||||
visible: !userSearch,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
if (filterOn) {
|
||||
clearAll();
|
||||
}
|
||||
setState(() {
|
||||
filterOn = !filterOn;
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
!filterOn
|
||||
? Icons.filter_list_rounded
|
||||
: Icons.filter_list_off_rounded,
|
||||
size: 35,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FutureBuilder(
|
||||
future: availableBusinessTypes,
|
||||
builder: (context, asyncSnapshot) {
|
||||
List<String> options = [];
|
||||
if (asyncSnapshot.connectionState == ConnectionState.done) {
|
||||
options.addAll(asyncSnapshot.data!);
|
||||
}
|
||||
return Visibility(
|
||||
visible: filterOn,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
child: MihDropdownField(
|
||||
controller: businessTypeController,
|
||||
hintText: "Business Type",
|
||||
dropdownOptions: options,
|
||||
requiredText: true,
|
||||
editable: true,
|
||||
enableSearch: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
if (businessTypeController.text.isNotEmpty) {
|
||||
searchPressed();
|
||||
} else {
|
||||
MihAlertServices().errorAlert(
|
||||
"Business Type Not Selected",
|
||||
"Please ensure you have selected a Business Type before seareching for Businesses of Mzansi",
|
||||
context,
|
||||
);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
elevation: 10,
|
||||
child: Text(
|
||||
"Search",
|
||||
style: TextStyle(
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: MihSearchBar(
|
||||
controller: mzansiSearchController,
|
||||
hintText: "Search Mzansi",
|
||||
prefixIcon: Icons.search,
|
||||
prefixAltIcon: directoryProvider.personalSearch
|
||||
? Icons.person
|
||||
: Icons.business,
|
||||
suffixTools: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
swapPressed(directoryProvider);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.swap_horiz_rounded,
|
||||
size: 35,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onPrefixIconTap: () {
|
||||
searchPressed(directoryProvider);
|
||||
},
|
||||
onClearIconTap: () {
|
||||
clearAll(directoryProvider);
|
||||
},
|
||||
searchFocusNode: searchFocusNode,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
const SizedBox(height: 10),
|
||||
displaySearchResults(userSearch, widget.myLocation ?? ""),
|
||||
],
|
||||
),
|
||||
Visibility(
|
||||
visible: !directoryProvider.personalSearch,
|
||||
child: const SizedBox(width: 10),
|
||||
),
|
||||
Visibility(
|
||||
visible: !directoryProvider.personalSearch,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
if (filterOn) {
|
||||
clearAll(directoryProvider);
|
||||
}
|
||||
setState(() {
|
||||
filterOn = !filterOn;
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
!filterOn
|
||||
? Icons.filter_list_rounded
|
||||
: Icons.filter_list_off_rounded,
|
||||
size: 35,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FutureBuilder(
|
||||
future: availableBusinessTypes,
|
||||
builder: (context, asyncSnapshot) {
|
||||
List<String> options = [];
|
||||
if (asyncSnapshot.connectionState == ConnectionState.done) {
|
||||
options.addAll(asyncSnapshot.data!);
|
||||
}
|
||||
return Visibility(
|
||||
visible: filterOn,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
child: MihDropdownField(
|
||||
controller: businessTypeController,
|
||||
hintText: "Business Type",
|
||||
dropdownOptions: options,
|
||||
requiredText: true,
|
||||
editable: true,
|
||||
enableSearch: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
if (businessTypeController.text.isNotEmpty) {
|
||||
searchPressed(directoryProvider);
|
||||
} else {
|
||||
MihAlertServices().errorAlert(
|
||||
"Business Type Not Selected",
|
||||
"Please ensure you have selected a Business Type before seareching for Businesses of Mzansi",
|
||||
context,
|
||||
);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
elevation: 10,
|
||||
child: Text(
|
||||
"Search",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
const SizedBox(height: 10),
|
||||
displaySearchResults(directoryProvider),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget displaySearchResults(bool userSearch, String myLocation) {
|
||||
if (userSearch) {
|
||||
return FutureBuilder(
|
||||
future: futureUserSearchResults,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Mihloadingcircle();
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData &&
|
||||
snapshot.requireData!.isNotEmpty) {
|
||||
// return Text("Pulled Data successfully");
|
||||
snapshot.requireData!
|
||||
.sort((a, b) => a.username.compareTo(b.username));
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
"People of Mzansi",
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BuildUserSearchResultsList(userList: snapshot.requireData!),
|
||||
],
|
||||
);
|
||||
} else if (!snapshot.hasData) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.personalProfile,
|
||||
size: 165,
|
||||
Widget displayBusinessSearchResults(
|
||||
MzansiDirectoryProvider directoryProvider) {
|
||||
KenLogger.success(
|
||||
"Searched Businesses: ${directoryProvider.searchedBusinesses}");
|
||||
if (directoryProvider.searchedBusinesses == null || loadingSearchResults) {
|
||||
return Center(
|
||||
child: const Mihloadingcircle(),
|
||||
);
|
||||
} else if (directoryProvider.searchedBusinesses!.isNotEmpty) {
|
||||
// return Text("Pulled Data successfully");
|
||||
directoryProvider.searchedBusinesses!
|
||||
.sort((a, b) => a.Name.compareTo(b.Name));
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
"Businesses of Mzansi",
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BuildBusinessSearchResultsList(
|
||||
businessList: directoryProvider.searchedBusinesses!,
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (directoryProvider.searchedBusinesses!.isEmpty &&
|
||||
directoryProvider.searchTerm.isNotEmpty) {
|
||||
// return Text("Pulled Data successfully");
|
||||
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),
|
||||
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 (directoryProvider.searchedBusinesses!.isEmpty &&
|
||||
directoryProvider.searchTerm.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(
|
||||
"Search for businesses of Mzansi!",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
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"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Search for people of Mzansi!",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
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: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.swap_horiz_rounded,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(text: " to search for businesses of Mzansi"),
|
||||
],
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.swap_horiz_rounded,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
// return Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// children: [
|
||||
// const SizedBox(height: 50),
|
||||
// Icon(
|
||||
// MihIcons.personalProfile,
|
||||
// size: 165,
|
||||
// color:
|
||||
// MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// const SizedBox(height: 10),
|
||||
// Text(
|
||||
// "People Of Mzansi!",
|
||||
// textAlign: TextAlign.center,
|
||||
// overflow: TextOverflow.visible,
|
||||
// style: TextStyle(
|
||||
// fontSize: 25,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color:
|
||||
// MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData &&
|
||||
snapshot.requireData!.isEmpty) {
|
||||
// return Text("Pulled Data successfully");
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
TextSpan(text: " to search for people of Mzansi"),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Let's try refining your search",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.filter_list_rounded,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(text: " to filter business types"),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
child: Text(
|
||||
"Error pulling Patients Data\n/users/search/${mzansiSearchController.text}",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return FutureBuilder(
|
||||
future: futureBusinessSearchResults,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Mihloadingcircle();
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData &&
|
||||
snapshot.requireData!.isNotEmpty) {
|
||||
// return Text("Pulled Data successfully");
|
||||
snapshot.requireData!.sort((a, b) => a.Name.compareTo(b.Name));
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
"Businesses of Mzansi",
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BuildBusinessSearchResultsList(
|
||||
businessList: snapshot.requireData!,
|
||||
myLocation: myLocation,
|
||||
startUpSearch: mzansiSearchController.text,
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData &&
|
||||
snapshot.requireData!.isEmpty) {
|
||||
// return Text("Pulled Data successfully");
|
||||
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),
|
||||
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 (!snapshot.hasData) {
|
||||
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(
|
||||
"Search for businesses of Mzansi!",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
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: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.swap_horiz_rounded,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(text: " to search for people of Mzansi"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
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: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.filter_list_rounded,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(text: " to filter business types"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
child: Text(
|
||||
"Error pulling Patients Data\n/users/search/${mzansiSearchController.text}",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
return Center(
|
||||
child: Text(
|
||||
"Error pulling Patients Data\n/users/search/${directoryProvider.searchTerm}",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget displayPersonalSearchResults(
|
||||
MzansiDirectoryProvider directoryProvider) {
|
||||
if (directoryProvider.searchedUsers == null || loadingSearchResults) {
|
||||
return Center(
|
||||
child: const Mihloadingcircle(),
|
||||
);
|
||||
} else if (directoryProvider.searchedUsers!.isNotEmpty) {
|
||||
// return Text("Pulled Data successfully");
|
||||
directoryProvider.searchedUsers!
|
||||
.sort((a, b) => a.username.compareTo(b.username));
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
"People of Mzansi",
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BuildUserSearchResultsList(
|
||||
userList: directoryProvider.searchedUsers!),
|
||||
],
|
||||
);
|
||||
} else if (directoryProvider.searchedUsers!.isEmpty &&
|
||||
directoryProvider.searchTerm.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.personalProfile,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Search for people of Mzansi!",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
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: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.swap_horiz_rounded,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(text: " to search for businesses of Mzansi"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else if (directoryProvider.searchedUsers!.isEmpty &&
|
||||
directoryProvider.searchTerm.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 {
|
||||
return Center(
|
||||
child: Text(
|
||||
"Error pulling Patients Data\n/users/search/${directoryProvider.searchTerm}",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget displaySearchResults(MzansiDirectoryProvider directoryProvider) {
|
||||
if (directoryProvider.personalSearch) {
|
||||
return displayPersonalSearchResults(directoryProvider);
|
||||
} else {
|
||||
return displayBusinessSearchResults(directoryProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.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_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihAddBookmarkAlert extends StatefulWidget {
|
||||
final Business business;
|
||||
final void Function()? onSuccessDismissPressed;
|
||||
const MihAddBookmarkAlert({
|
||||
super.key,
|
||||
required this.business,
|
||||
required this.onSuccessDismissPressed,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -23,16 +25,16 @@ class MihAddBookmarkAlert extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
|
||||
Future<void> addBookmark(String business_id) async {
|
||||
Future<void> addBookmark(
|
||||
MzansiProfileProvider profileProvider, String business_id) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
String user_id = await SuperTokens.getUserId();
|
||||
await MihMzansiDirectoryServices()
|
||||
.addBookmarkedBusiness(user_id, business_id)
|
||||
.addBookmarkedBusiness(profileProvider.user!.app_id, business_id)
|
||||
.then((statusCode) {
|
||||
context.pop();
|
||||
if (statusCode == 201) {
|
||||
@@ -77,14 +79,9 @@ class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.goNamed(
|
||||
"mzansiDirectory",
|
||||
extra: MzansiDirectoryArguments(
|
||||
personalSearch: false,
|
||||
startSearchText: widget.business.Name,
|
||||
packageIndex: 1,
|
||||
),
|
||||
);
|
||||
widget.onSuccessDismissPressed!.call();
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
@@ -117,69 +114,76 @@ class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageAlert(
|
||||
alertColour: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
alertIcon: Icon(
|
||||
Icons.warning_rounded,
|
||||
size: 100,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
alertTitle: "Bookmark Business",
|
||||
alertBody: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Are you sure you want to save ${widget.business.Name} to your Mzansi Directory?",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15,
|
||||
),
|
||||
return Consumer<MzansiProfileProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
Widget? child) {
|
||||
return MihPackageAlert(
|
||||
alertColour: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
alertIcon: Icon(
|
||||
Icons.warning_rounded,
|
||||
size: 100,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
alertTitle: "Bookmark Business",
|
||||
alertBody: Column(
|
||||
children: [
|
||||
MihButton(
|
||||
width: 300,
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: Text(
|
||||
"Cancel",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
Text(
|
||||
"Are you sure you want to save ${widget.business.Name} to your Mzansi Directory?",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
MihButton(
|
||||
width: 300,
|
||||
onPressed: () {
|
||||
addBookmark(widget.business.business_id);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: Text(
|
||||
"Bookmark Business",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
const SizedBox(height: 25),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
MihButton(
|
||||
width: 300,
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
buttonColor: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
child: Text(
|
||||
"Cancel",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
MihButton(
|
||||
width: 300,
|
||||
onPressed: () {
|
||||
addBookmark(profileProvider, widget.business.business_id);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: Text(
|
||||
"Bookmark Business",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,23 +7,24 @@ import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_review
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.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_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_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_add_bookmark_alert.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_delete_bookmark_alert.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_business_details_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:redacted/redacted.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class MihBusinessCard extends StatefulWidget {
|
||||
final Business business;
|
||||
final String? startUpSearch;
|
||||
final double width;
|
||||
const MihBusinessCard({
|
||||
super.key,
|
||||
required this.business,
|
||||
required this.startUpSearch,
|
||||
required this.width,
|
||||
});
|
||||
|
||||
@@ -409,274 +410,292 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// double screenWidth = MediaQuery.of(context).size.width;
|
||||
return Material(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||
.withValues(alpha: 0.6),
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
elevation: 10,
|
||||
shadowColor: Colors.black,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return Material(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
_buildContactInfo(
|
||||
"Call",
|
||||
"Give us a quick call.",
|
||||
Icons.phone,
|
||||
MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||
.withValues(alpha: 0.6),
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
elevation: 10,
|
||||
shadowColor: Colors.black,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
false,
|
||||
() {
|
||||
// print("Calling ${widget.cellNumber}");
|
||||
_makePhoneCall(widget.business.contact_no);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
_buildContactInfo(
|
||||
"Email",
|
||||
"Send us an email.",
|
||||
Icons.email,
|
||||
MihColors.getPinkColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
false,
|
||||
() {
|
||||
// print("Emailing ${widget.email}");
|
||||
_launchEmail(
|
||||
widget.business.bus_email,
|
||||
"Inquiery about ${widget.business.Name}",
|
||||
"Dear ${widget.business.Name},\n\nI would like to inquire about your services.\n\nBest regards,\n",
|
||||
);
|
||||
},
|
||||
),
|
||||
Visibility(
|
||||
visible: isValidGps(widget.business.gps_location),
|
||||
child: Column(
|
||||
children: [
|
||||
Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
_buildContactInfo(
|
||||
"Call",
|
||||
"Give us a quick call.",
|
||||
Icons.phone,
|
||||
MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
false,
|
||||
() {
|
||||
// print("Calling ${widget.cellNumber}");
|
||||
_makePhoneCall(widget.business.contact_no);
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
_buildContactInfo(
|
||||
"Email",
|
||||
"Send us an email.",
|
||||
Icons.email,
|
||||
MihColors.getPinkColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
false,
|
||||
() {
|
||||
// print("Emailing ${widget.email}");
|
||||
_launchEmail(
|
||||
widget.business.bus_email,
|
||||
"Inquiery about ${widget.business.Name}",
|
||||
"Dear ${widget.business.Name},\n\nI would like to inquire about your services.\n\nBest regards,\n",
|
||||
);
|
||||
},
|
||||
),
|
||||
Visibility(
|
||||
visible: isValidGps(widget.business.gps_location),
|
||||
child: Column(
|
||||
children: [
|
||||
Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
_buildContactInfo(
|
||||
"Location",
|
||||
"Come visit us.",
|
||||
Icons.location_on,
|
||||
MihColors.getOrangeColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
false,
|
||||
() {
|
||||
final latitude = double.parse(
|
||||
widget.business.gps_location.split(',')[0]);
|
||||
final longitude = double.parse(
|
||||
widget.business.gps_location.split(',')[1]);
|
||||
_launchGoogleMapsWithUrl(
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
_buildContactInfo(
|
||||
"Location",
|
||||
"Come visit us.",
|
||||
Icons.location_on,
|
||||
MihColors.getOrangeColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
false,
|
||||
() {
|
||||
final latitude = double.parse(
|
||||
widget.business.gps_location.split(',')[0]);
|
||||
final longitude = double.parse(
|
||||
widget.business.gps_location.split(',')[1]);
|
||||
_launchGoogleMapsWithUrl(
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.business.website.isNotEmpty &&
|
||||
widget.business.website != "",
|
||||
child: Column(
|
||||
children: [
|
||||
Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
_buildContactInfo(
|
||||
"Website",
|
||||
"Find out more about us.",
|
||||
Icons.vpn_lock,
|
||||
MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
false,
|
||||
() {
|
||||
_launchWebsite(widget.business.website);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _businessReviewFuture,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.waiting) {
|
||||
// return const SizedBox.shrink();
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: _buildContactInfo(
|
||||
"Loading Rating",
|
||||
"Loading your rating.",
|
||||
Icons.star_rate_rounded,
|
||||
MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
true,
|
||||
null,
|
||||
),
|
||||
).redacted(context: context, redact: true),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
} else {
|
||||
BusinessReview? businessReview = asyncSnapshot.data;
|
||||
String ratingDisplayTitle = "";
|
||||
if (businessReview == null) {
|
||||
ratingDisplayTitle = "Rate Us";
|
||||
} else {
|
||||
ratingDisplayTitle = "Update Rating";
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
_buildContactInfo(
|
||||
ratingDisplayTitle,
|
||||
"Let us know how we are doing.",
|
||||
Icons.star_rate_rounded,
|
||||
MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
false,
|
||||
() {
|
||||
businessReviewRatingWindow(directoryProvider,
|
||||
businessReview, true, widget.width);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _bookmarkedBusinessFuture,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.waiting) {
|
||||
// return const SizedBox.shrink();
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: _buildContactInfo(
|
||||
"Loading Bookmark",
|
||||
"Loading your bookmark.",
|
||||
Icons.bookmark_add_rounded,
|
||||
MihColors.getBluishPurpleColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
true,
|
||||
null,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
BookmarkedBusiness? bookmarkBusiness = asyncSnapshot.data;
|
||||
String bookmarkDisplayTitle = "";
|
||||
if (bookmarkBusiness == null) {
|
||||
bookmarkDisplayTitle = "Bookmark Us";
|
||||
} else {
|
||||
bookmarkDisplayTitle = "Remove Bookmark";
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
_buildContactInfo(
|
||||
bookmarkDisplayTitle,
|
||||
"Save us for later.",
|
||||
bookmarkBusiness == null
|
||||
? Icons.bookmark_add_rounded
|
||||
: Icons.bookmark_remove_rounded,
|
||||
MihColors.getBluishPurpleColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
false,
|
||||
() {
|
||||
// _launchWebsite(widget.website);
|
||||
if (bookmarkBusiness == null) {
|
||||
showAddBookmarkAlert();
|
||||
} else {
|
||||
showDeleteBookmarkAlert(bookmarkBusiness);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
// child: Divider(
|
||||
// color: MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// ),
|
||||
// _buildContactInfo(
|
||||
// "Bookmark",
|
||||
// "Save us for later.",
|
||||
// Icons.bookmark_add_rounded,
|
||||
// MihColors.getBluishPurpleColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// () {
|
||||
// // _launchWebsite(widget.website);
|
||||
// print("Saving ${widget.business.Name} to Directory");
|
||||
// showBookmarkAlert();
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 10),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
// child: Divider(
|
||||
// color: MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.business.website.isNotEmpty &&
|
||||
widget.business.website != "",
|
||||
child: Column(
|
||||
children: [
|
||||
Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
_buildContactInfo(
|
||||
"Website",
|
||||
"Find out more about us.",
|
||||
Icons.vpn_lock,
|
||||
MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
false,
|
||||
() {
|
||||
_launchWebsite(widget.business.website);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _businessReviewFuture,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||
// return const SizedBox.shrink();
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: _buildContactInfo(
|
||||
"Loading Rating",
|
||||
"Loading your rating.",
|
||||
Icons.star_rate_rounded,
|
||||
MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
true,
|
||||
null,
|
||||
),
|
||||
).redacted(context: context, redact: true),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
BusinessReview? businessReview = asyncSnapshot.data;
|
||||
String ratingDisplayTitle = "";
|
||||
if (businessReview == null) {
|
||||
ratingDisplayTitle = "Rate Us";
|
||||
} else {
|
||||
ratingDisplayTitle = "Update Rating";
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
_buildContactInfo(
|
||||
ratingDisplayTitle,
|
||||
"Let us know how we are doing.",
|
||||
Icons.star_rate_rounded,
|
||||
MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
false,
|
||||
() {
|
||||
businessReviewRatingWindow(
|
||||
businessReview, true, widget.width);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _bookmarkedBusinessFuture,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||
// return const SizedBox.shrink();
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: _buildContactInfo(
|
||||
"Loading Bookmark",
|
||||
"Loading your bookmark.",
|
||||
Icons.bookmark_add_rounded,
|
||||
MihColors.getBluishPurpleColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
true,
|
||||
null,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
BookmarkedBusiness? bookmarkBusiness = asyncSnapshot.data;
|
||||
String bookmarkDisplayTitle = "";
|
||||
if (bookmarkBusiness == null) {
|
||||
bookmarkDisplayTitle = "Bookmark Us";
|
||||
} else {
|
||||
bookmarkDisplayTitle = "Remove Bookmark";
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
_buildContactInfo(
|
||||
bookmarkDisplayTitle,
|
||||
"Save us for later.",
|
||||
bookmarkBusiness == null
|
||||
? Icons.bookmark_add_rounded
|
||||
: Icons.bookmark_remove_rounded,
|
||||
MihColors.getBluishPurpleColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
false,
|
||||
() {
|
||||
// _launchWebsite(widget.website);
|
||||
if (bookmarkBusiness == null) {
|
||||
showAddBookmarkAlert();
|
||||
} else {
|
||||
showDeleteBookmarkAlert(bookmarkBusiness);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
// child: Divider(
|
||||
// color: MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// ),
|
||||
// _buildContactInfo(
|
||||
// "Bookmark",
|
||||
// "Save us for later.",
|
||||
// Icons.bookmark_add_rounded,
|
||||
// MihColors.getBluishPurpleColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// () {
|
||||
// // _launchWebsite(widget.website);
|
||||
// print("Saving ${widget.business.Name} to Directory");
|
||||
// showBookmarkAlert();
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 10),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
// child: Divider(
|
||||
// color: MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> businessReviewRatingWindow(
|
||||
BusinessReview? myReview, bool previouslyRated, double width) async {
|
||||
MzansiDirectoryProvider directoryProvider,
|
||||
BusinessReview? myReview,
|
||||
bool previouslyRated,
|
||||
double width) async {
|
||||
if (_isUserSignedIn) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -685,6 +704,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
businessReview: myReview,
|
||||
screenWidth: width,
|
||||
readOnly: false,
|
||||
onSuccessDismissPressed: () async {
|
||||
List<Business>? businessSearchResults = [];
|
||||
businessSearchResults = await MihBusinessDetailsServices()
|
||||
.searchBusinesses(directoryProvider.searchTerm,
|
||||
directoryProvider.businessTypeFilter, context);
|
||||
directoryProvider.setSearchedBusinesses(
|
||||
searchedBusinesses: businessSearchResults);
|
||||
setState(() {
|
||||
_businessReviewFuture = getUserReview();
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
@@ -698,6 +728,11 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
context: context,
|
||||
builder: (context) => MihAddBookmarkAlert(
|
||||
business: widget.business,
|
||||
onSuccessDismissPressed: () {
|
||||
setState(() {
|
||||
_bookmarkedBusinessFuture = getUserBookmark();
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
@@ -712,7 +747,12 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
builder: (context) => MihDeleteBookmarkAlert(
|
||||
business: widget.business,
|
||||
bookmarkBusiness: bookmarkBusiness,
|
||||
startUpSearch: widget.startUpSearch,
|
||||
onSuccessDismissPressed: () {
|
||||
setState(() {
|
||||
_bookmarkedBusinessFuture = getUserBookmark();
|
||||
});
|
||||
},
|
||||
// startUpSearch: widget.startUpSearch,
|
||||
));
|
||||
} else {
|
||||
showSignInRequiredAlert();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/bookmarked_business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||
@@ -14,12 +13,14 @@ import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services
|
||||
class MihDeleteBookmarkAlert extends StatefulWidget {
|
||||
final Business business;
|
||||
final BookmarkedBusiness? bookmarkBusiness;
|
||||
final String? startUpSearch;
|
||||
final void Function()? onSuccessDismissPressed;
|
||||
// final String? startUpSearch;
|
||||
const MihDeleteBookmarkAlert({
|
||||
super.key,
|
||||
required this.business,
|
||||
required this.bookmarkBusiness,
|
||||
required this.startUpSearch,
|
||||
required this.onSuccessDismissPressed,
|
||||
// required this.startUpSearch,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -80,14 +81,17 @@ class _MihDeleteBookmarkAlertState extends State<MihDeleteBookmarkAlert> {
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.goNamed(
|
||||
"mzansiDirectory",
|
||||
extra: MzansiDirectoryArguments(
|
||||
personalSearch: false,
|
||||
startSearchText: widget.business.Name,
|
||||
packageIndex: 1,
|
||||
),
|
||||
);
|
||||
// context.goNamed(
|
||||
// "mzansiDirectory",
|
||||
// extra: MzansiDirectoryArguments(
|
||||
// personalSearch: false,
|
||||
// startSearchText: widget.business.Name,
|
||||
// packageIndex: 1,
|
||||
// ),
|
||||
// );
|
||||
widget.onSuccessDismissPressed!.call();
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
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_button.dart';
|
||||
@@ -13,23 +12,28 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
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_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_services/mih_alert_services.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:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihReviewBusinessWindow extends StatefulWidget {
|
||||
final Business business;
|
||||
final BusinessReview? businessReview;
|
||||
final double screenWidth;
|
||||
final bool readOnly;
|
||||
final void Function()? onSuccessDismissPressed;
|
||||
const MihReviewBusinessWindow({
|
||||
super.key,
|
||||
required this.business,
|
||||
required this.businessReview,
|
||||
required this.screenWidth,
|
||||
required this.readOnly,
|
||||
required this.onSuccessDismissPressed,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -47,9 +51,8 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
||||
TextEditingController();
|
||||
late final VoidCallback _reviewDescriptionListener;
|
||||
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
|
||||
String userId = "";
|
||||
|
||||
void showDeleteReviewAlert() {
|
||||
void showDeleteReviewAlert(MzansiDirectoryProvider directoryProvider) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => MihPackageAlert(
|
||||
@@ -93,10 +96,11 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
||||
widget.businessReview!.rating_score,
|
||||
widget.business.rating,
|
||||
)
|
||||
.then((statusCode) {
|
||||
.then((statusCode) async {
|
||||
context.pop(); //Remove loading dialog
|
||||
context.pop(); //Remove delete dialog
|
||||
if (statusCode == 200) {
|
||||
await refreshBusiness(directoryProvider);
|
||||
context.pop(); //Remove window
|
||||
successPopUp(
|
||||
"Successfully Deleted Review!",
|
||||
@@ -160,7 +164,19 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
||||
}
|
||||
}
|
||||
|
||||
void submitForm() async {
|
||||
Future<void> refreshBusiness(
|
||||
MzansiDirectoryProvider directoryProvider) async {
|
||||
Business? refresedBusiness = await MihBusinessDetailsServices()
|
||||
.getBusinessDetailsByBusinessId(widget.business.business_id);
|
||||
if (refresedBusiness != null) {
|
||||
directoryProvider.setSelectedBusiness(business: refresedBusiness);
|
||||
}
|
||||
}
|
||||
|
||||
void submitForm(
|
||||
MzansiProfileProvider profileProvider,
|
||||
MzansiDirectoryProvider directoryProvider,
|
||||
) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
@@ -178,9 +194,10 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
||||
widget.businessReview!.rating_score,
|
||||
widget.business.rating,
|
||||
)
|
||||
.then((statusCode) {
|
||||
.then((statusCode) async {
|
||||
context.pop(); //Remove loading dialog
|
||||
if (statusCode == 200) {
|
||||
await refreshBusiness(directoryProvider);
|
||||
context.pop();
|
||||
successPopUp(
|
||||
"Successfully Updated Review!",
|
||||
@@ -197,16 +214,17 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
||||
} else {
|
||||
await MihMzansiDirectoryServices()
|
||||
.addBusinessReview(
|
||||
userId,
|
||||
profileProvider.user!.app_id,
|
||||
widget.business.business_id,
|
||||
_reviewTitleController.text,
|
||||
_reviewDescriptionController.text,
|
||||
_reviewScoreController.text,
|
||||
widget.business.rating.isEmpty ? "0.0" : widget.business.rating,
|
||||
)
|
||||
.then((statusCode) {
|
||||
.then((statusCode) async {
|
||||
context.pop(); //Remove loading dialog
|
||||
if (statusCode == 201) {
|
||||
await refreshBusiness(directoryProvider);
|
||||
context.pop();
|
||||
successPopUp(
|
||||
"Successfully Added Review!",
|
||||
@@ -250,13 +268,15 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
context.goNamed(
|
||||
"mzansiDirectory",
|
||||
extra: MzansiDirectoryArguments(
|
||||
personalSearch: false,
|
||||
startSearchText: widget.business.Name,
|
||||
),
|
||||
);
|
||||
// context.goNamed(
|
||||
// "mzansiDirectory",
|
||||
// extra: MzansiDirectoryArguments(
|
||||
// personalSearch: false,
|
||||
// startSearchText: widget.business.Name,
|
||||
// ),
|
||||
// );
|
||||
widget.onSuccessDismissPressed!.call();
|
||||
context.pop();
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
@@ -323,265 +343,277 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
||||
} else {
|
||||
_reviewScoreController.text = "1.0"; // Default score
|
||||
}
|
||||
SuperTokens.getUserId().then((value) {
|
||||
setState(() {
|
||||
userId = value;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// return const Placeholder();
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: getWindowTitle(),
|
||||
onWindowTapClose: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
menuOptions: widget.businessReview != null && !widget.readOnly
|
||||
? [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Delete Review",
|
||||
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: () {
|
||||
showDeleteReviewAlert();
|
||||
},
|
||||
),
|
||||
]
|
||||
: null,
|
||||
windowBody: MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
return Consumer2<MzansiProfileProvider, MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
MzansiDirectoryProvider directoryProvider, Widget? child) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: getWindowTitle(),
|
||||
onWindowTapClose: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
menuOptions: widget.businessReview != null && !widget.readOnly
|
||||
? [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
label: "Delete Review",
|
||||
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: () {
|
||||
showDeleteReviewAlert(directoryProvider);
|
||||
},
|
||||
),
|
||||
]
|
||||
: null,
|
||||
windowBody: MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding: MzansiInnovationHub.of(context)!.theme.screenType ==
|
||||
"desktop"
|
||||
? EdgeInsets.symmetric(horizontal: widget.screenWidth * 0.05)
|
||||
: EdgeInsets.symmetric(horizontal: widget.screenWidth * 0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Business Rating",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Business Rating",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
widget.readOnly
|
||||
? RatingBar.readOnly(
|
||||
size: 50,
|
||||
alignment: Alignment.centerLeft,
|
||||
filledIcon: Icons.star,
|
||||
emptyIcon: Icons.star_border,
|
||||
halfFilledIcon: Icons.star_half,
|
||||
filledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
// filledColor: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
emptyColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
halfFilledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
// MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
isHalfAllowed: true,
|
||||
initialRating: widget.businessReview != null
|
||||
? double.parse(_reviewScoreController.text)
|
||||
: 1,
|
||||
maxRating: 5,
|
||||
)
|
||||
: RatingBar(
|
||||
size: 50,
|
||||
alignment: Alignment.centerLeft,
|
||||
filledIcon: Icons.star,
|
||||
emptyIcon: Icons.star_border,
|
||||
halfFilledIcon: Icons.star_half,
|
||||
filledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
emptyColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
halfFilledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
isHalfAllowed: true,
|
||||
initialRating: widget.businessReview != null
|
||||
? double.parse(_reviewScoreController.text)
|
||||
: 1,
|
||||
maxRating: 5,
|
||||
onRatingChanged: (double) {
|
||||
setState(() {
|
||||
_reviewScoreController.text =
|
||||
double.toStringAsFixed(1);
|
||||
});
|
||||
print(_reviewScoreController.text);
|
||||
},
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.readOnly,
|
||||
child: const SizedBox(height: 10),
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.readOnly,
|
||||
child: MihTextFormField(
|
||||
// width: 200,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: _reviewReviewerController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Reviewer",
|
||||
validator: (value) {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
// width: 200,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: _reviewTitleController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: widget.readOnly,
|
||||
hintText: "Review Title",
|
||||
validator: (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(_reviewTitleController.text);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
height: 250,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: _reviewDescriptionController,
|
||||
multiLineInput: true,
|
||||
requiredText: widget.readOnly,
|
||||
readOnly: widget.readOnly,
|
||||
hintText: "Review Description",
|
||||
validator: (value) {
|
||||
if (_reviewDescriptionController.text.isEmpty) {
|
||||
return null;
|
||||
} else {
|
||||
return MihValidationServices().validateLength(
|
||||
_reviewDescriptionController.text, 256);
|
||||
}
|
||||
},
|
||||
),
|
||||
Visibility(
|
||||
visible: !widget.readOnly,
|
||||
child: SizedBox(
|
||||
height: 15,
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: _counter,
|
||||
builder: (BuildContext context, int value,
|
||||
Widget? child) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
"$value",
|
||||
style: TextStyle(
|
||||
color: getMissionVisionLimitColor(256),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
"/256",
|
||||
style: TextStyle(
|
||||
color: getMissionVisionLimitColor(256),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Visibility(
|
||||
visible: !widget.readOnly,
|
||||
child: Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
submitForm(
|
||||
profileProvider,
|
||||
directoryProvider,
|
||||
);
|
||||
} else {
|
||||
MihAlertServices()
|
||||
.formNotFilledCompletely(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
widget.businessReview != null
|
||||
? "Update Review"
|
||||
: "Add Review",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
widget.readOnly
|
||||
? RatingBar.readOnly(
|
||||
size: 50,
|
||||
alignment: Alignment.centerLeft,
|
||||
filledIcon: Icons.star,
|
||||
emptyIcon: Icons.star_border,
|
||||
halfFilledIcon: Icons.star_half,
|
||||
filledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
// filledColor: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
emptyColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
halfFilledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
// MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
isHalfAllowed: true,
|
||||
initialRating: widget.businessReview != null
|
||||
? double.parse(_reviewScoreController.text)
|
||||
: 1,
|
||||
maxRating: 5,
|
||||
)
|
||||
: RatingBar(
|
||||
size: 50,
|
||||
alignment: Alignment.centerLeft,
|
||||
filledIcon: Icons.star,
|
||||
emptyIcon: Icons.star_border,
|
||||
halfFilledIcon: Icons.star_half,
|
||||
filledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
emptyColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
halfFilledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
isHalfAllowed: true,
|
||||
initialRating: widget.businessReview != null
|
||||
? double.parse(_reviewScoreController.text)
|
||||
: 1,
|
||||
maxRating: 5,
|
||||
onRatingChanged: (double) {
|
||||
setState(() {
|
||||
_reviewScoreController.text =
|
||||
double.toStringAsFixed(1);
|
||||
});
|
||||
print(_reviewScoreController.text);
|
||||
},
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.readOnly,
|
||||
child: const SizedBox(height: 10),
|
||||
),
|
||||
Visibility(
|
||||
visible: widget.readOnly,
|
||||
child: MihTextFormField(
|
||||
// width: 200,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: _reviewReviewerController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Reviewer",
|
||||
validator: (value) {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
// width: 200,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: _reviewTitleController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: widget.readOnly,
|
||||
hintText: "Review Title",
|
||||
validator: (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(_reviewTitleController.text);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
height: 250,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: _reviewDescriptionController,
|
||||
multiLineInput: true,
|
||||
requiredText: widget.readOnly,
|
||||
readOnly: widget.readOnly,
|
||||
hintText: "Review Description",
|
||||
validator: (value) {
|
||||
if (_reviewDescriptionController.text.isEmpty) {
|
||||
return null;
|
||||
} else {
|
||||
return MihValidationServices().validateLength(
|
||||
_reviewDescriptionController.text, 256);
|
||||
}
|
||||
},
|
||||
),
|
||||
Visibility(
|
||||
visible: !widget.readOnly,
|
||||
child: SizedBox(
|
||||
height: 15,
|
||||
child: ValueListenableBuilder(
|
||||
valueListenable: _counter,
|
||||
builder:
|
||||
(BuildContext context, int value, Widget? child) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
"$value",
|
||||
style: TextStyle(
|
||||
color: getMissionVisionLimitColor(256),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
"/256",
|
||||
style: TextStyle(
|
||||
color: getMissionVisionLimitColor(256),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Visibility(
|
||||
visible: !widget.readOnly,
|
||||
child: Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
submitForm();
|
||||
} else {
|
||||
MihAlertServices().formNotFilledCompletely(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
widget.businessReview != null
|
||||
? "Update Review"
|
||||
: "Add Review",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
|
||||
business: context.watch<MzansiProfileProvider>().business!),
|
||||
MihBusinessQrCode(
|
||||
business: context.watch<MzansiProfileProvider>().business!,
|
||||
startUpSearch: "",
|
||||
// startUpSearch: "",
|
||||
),
|
||||
];
|
||||
return toolBodies;
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.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:flutter/material.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_packages/mzansi_profile/business_profile/package_tools/mih_business_details_view.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_services/mih_business_details_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MzansiBusinessProfileView extends StatefulWidget {
|
||||
final BusinessViewArguments? arguments;
|
||||
final String? businessId;
|
||||
const MzansiBusinessProfileView({
|
||||
super.key,
|
||||
required this.arguments,
|
||||
required this.businessId,
|
||||
});
|
||||
|
||||
@@ -28,16 +27,10 @@ class MzansiBusinessProfileView extends StatefulWidget {
|
||||
|
||||
class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
int _selcetedIndex = 0;
|
||||
Business? business;
|
||||
String startUpSearch = "";
|
||||
|
||||
Future<void> _fetchBusinessDetails() async {
|
||||
if (widget.arguments != null) {
|
||||
setState(() {
|
||||
business = widget.arguments!.business;
|
||||
startUpSearch = widget.arguments!.startUpSearch ?? "";
|
||||
});
|
||||
} else if (widget.businessId != null) {
|
||||
Future<void> _fetchBusinessDetails(
|
||||
MzansiDirectoryProvider directoryProvider) async {
|
||||
if (widget.businessId != null) {
|
||||
final biz = await MihBusinessDetailsServices()
|
||||
.getBusinessDetailsByBusinessId(widget.businessId!);
|
||||
if (biz == null) {
|
||||
@@ -47,10 +40,7 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
);
|
||||
} else {
|
||||
KenLogger.success("Business found: ${biz.Name}");
|
||||
setState(() {
|
||||
business = biz;
|
||||
startUpSearch = "";
|
||||
});
|
||||
directoryProvider.setSelectedBusiness(business: biz);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,32 +48,39 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fetchBusinessDetails();
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
_fetchBusinessDetails(directoryProvider);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (business == null) {
|
||||
KenLogger.warning("Business is null, showing loading indicator");
|
||||
return Scaffold(
|
||||
body: const Center(
|
||||
child: Mihloadingcircle(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: _selcetedIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selcetedIndex = newValue;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
if (directoryProvider.selectedBusiness == null) {
|
||||
KenLogger.warning("Business is null, showing loading indicator");
|
||||
return Scaffold(
|
||||
body: const Center(
|
||||
child: Mihloadingcircle(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(directoryProvider),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex: _selcetedIndex,
|
||||
onIndexChange: (newValue) {
|
||||
setState(() {
|
||||
_selcetedIndex = newValue;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageAction getAction() {
|
||||
@@ -91,13 +88,18 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"mzansiDirectory",
|
||||
extra: MzansiDirectoryArguments(
|
||||
personalSearch: false,
|
||||
startSearchText: business!.Name,
|
||||
),
|
||||
);
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
if (profileProvider.user == null) {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
);
|
||||
} else {
|
||||
context.pop();
|
||||
}
|
||||
// context.goNamed(
|
||||
// "mzansiDirectory",
|
||||
// );
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
@@ -126,16 +128,12 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> getToolBody(MzansiDirectoryProvider directoryProvider) {
|
||||
List<Widget> toolBodies = [
|
||||
MihBusinessDetailsView(
|
||||
business: business!,
|
||||
startUpSearch: startUpSearch,
|
||||
),
|
||||
MihBusinessReviews(business: business!),
|
||||
MihBusinessDetailsView(),
|
||||
MihBusinessReviews(business: directoryProvider.selectedBusiness!),
|
||||
MihBusinessQrCode(
|
||||
business: business!,
|
||||
startUpSearch: startUpSearch,
|
||||
business: directoryProvider.selectedBusiness!,
|
||||
)
|
||||
];
|
||||
return toolBodies;
|
||||
|
||||
@@ -135,7 +135,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
||||
width: 700,
|
||||
child: MihBusinessCard(
|
||||
business: mzansiProfileProvider.business!,
|
||||
startUpSearch: null,
|
||||
// startUpSearch: null,
|
||||
width: width,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -2,22 +2,19 @@ import 'package:custom_rating_bar/custom_rating_bar.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.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_providers/mzansi_directory_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_business_info_card.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.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_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihBusinessDetailsView extends StatefulWidget {
|
||||
final Business business;
|
||||
final String? startUpSearch;
|
||||
const MihBusinessDetailsView({
|
||||
super.key,
|
||||
required this.business,
|
||||
required this.startUpSearch,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -36,8 +33,10 @@ class _MihBusinessDetailsViewState extends State<MihBusinessDetailsView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
futureImageUrl =
|
||||
MihFileApi.getMinioFileUrl(widget.business.logo_path, context);
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
futureImageUrl = MihFileApi.getMinioFileUrl(
|
||||
directoryProvider.selectedBusiness!.logo_path, context);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -52,173 +51,182 @@ class _MihBusinessDetailsViewState extends State<MihBusinessDetailsView> {
|
||||
|
||||
Widget getBody(double width, BuildContext context) {
|
||||
double profilePictureWidth = 150;
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding: MzansiInnovationHub.of(context)!.theme.screenType ==
|
||||
"desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||
child: Column(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "") {
|
||||
return MihCircleAvatar(
|
||||
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
child: Column(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "") {
|
||||
return MihCircleAvatar(
|
||||
imageFile:
|
||||
NetworkImage(asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
}),
|
||||
// Center(
|
||||
// child: MihCircleAvatar(
|
||||
// imageFile: widget.logoImage,
|
||||
// width: 150,
|
||||
// editable: false,
|
||||
// fileNameController: fileNameController,
|
||||
// userSelectedfile: imageFile,
|
||||
// frameColor:
|
||||
// MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// backgroundColor:
|
||||
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// onChange: (selectedfile) {
|
||||
// setState(() {
|
||||
// imageFile = selectedfile;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
directoryProvider.selectedBusiness!.Name,
|
||||
style: TextStyle(
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
}),
|
||||
// Center(
|
||||
// child: MihCircleAvatar(
|
||||
// imageFile: widget.logoImage,
|
||||
// width: 150,
|
||||
// editable: false,
|
||||
// fileNameController: fileNameController,
|
||||
// userSelectedfile: imageFile,
|
||||
// frameColor:
|
||||
// MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// backgroundColor:
|
||||
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// onChange: (selectedfile) {
|
||||
// setState(() {
|
||||
// imageFile = selectedfile;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
widget.business.Name,
|
||||
style: TextStyle(
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
widget.business.type,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
// FittedBox(
|
||||
// child: Text(
|
||||
// "Mission & Vision",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
widget.business.mission_vision.isNotEmpty
|
||||
? widget.business.mission_vision
|
||||
: "No Mission & Vision added yet",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
directoryProvider.selectedBusiness!.type,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
// FittedBox(
|
||||
// child: Text(
|
||||
// "Mission & Vision",
|
||||
// style: TextStyle(
|
||||
// fontSize: 15,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
directoryProvider
|
||||
.selectedBusiness!.mission_vision.isNotEmpty
|
||||
? directoryProvider
|
||||
.selectedBusiness!.mission_vision
|
||||
: "No Mission & Vision added yet",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
RatingBar.readOnly(
|
||||
size: 50,
|
||||
alignment: Alignment.center,
|
||||
filledIcon: Icons.star,
|
||||
emptyIcon: Icons.star_border,
|
||||
halfFilledIcon: Icons.star_half,
|
||||
filledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
emptyColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
halfFilledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
isHalfAllowed: true,
|
||||
initialRating:
|
||||
directoryProvider.selectedBusiness!.rating.isNotEmpty
|
||||
? double.parse(
|
||||
directoryProvider.selectedBusiness!.rating)
|
||||
: 0,
|
||||
maxRating: 5,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
width: 700,
|
||||
child: MihBusinessCard(
|
||||
business: directoryProvider.selectedBusiness!,
|
||||
width: width,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
RatingBar.readOnly(
|
||||
size: 50,
|
||||
alignment: Alignment.center,
|
||||
filledIcon: Icons.star,
|
||||
emptyIcon: Icons.star_border,
|
||||
halfFilledIcon: Icons.star_half,
|
||||
filledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
emptyColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
halfFilledColor: MihColors.getYellowColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
isHalfAllowed: true,
|
||||
initialRating: widget.business.rating.isNotEmpty
|
||||
? double.parse(widget.business.rating)
|
||||
: 0,
|
||||
maxRating: 5,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
width: 700,
|
||||
child: MihBusinessCard(
|
||||
business: widget.business,
|
||||
startUpSearch: widget.startUpSearch,
|
||||
// businessid: widget.business.business_id,
|
||||
// businessName: widget.business.Name,
|
||||
// cellNumber: widget.business.contact_no,
|
||||
// email: widget.business.bus_email,
|
||||
// gpsLocation: widget.business.gps_location,
|
||||
// rating: widget.business.rating.isNotEmpty
|
||||
// ? double.parse(widget.business.rating)
|
||||
// : 0,
|
||||
// website: widget.business.website,
|
||||
width: width,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ import 'package:supertokens_flutter/supertokens.dart';
|
||||
|
||||
class MihBusinessQrCode extends StatefulWidget {
|
||||
final Business business;
|
||||
final String? startUpSearch;
|
||||
// final String? startUpSearch;
|
||||
const MihBusinessQrCode({
|
||||
super.key,
|
||||
required this.business,
|
||||
required this.startUpSearch,
|
||||
// required this.startUpSearch,
|
||||
});
|
||||
|
||||
@override
|
||||
|
||||
@@ -41,6 +41,7 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
||||
businessReview: businessReview,
|
||||
screenWidth: width,
|
||||
readOnly: true,
|
||||
onSuccessDismissPressed: () {},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.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';
|
||||
@@ -8,10 +6,8 @@ import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/personal_profi
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MzansiProfileView extends StatefulWidget {
|
||||
final AppUser user;
|
||||
const MzansiProfileView({
|
||||
super.key,
|
||||
required this.user,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -42,13 +38,7 @@ class _MzansiProfileViewState extends State<MzansiProfileView> {
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
"mzansiDirectory",
|
||||
extra: MzansiDirectoryArguments(
|
||||
personalSearch: true,
|
||||
startSearchText: widget.user.username,
|
||||
),
|
||||
);
|
||||
context.pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
@@ -69,9 +59,9 @@ class _MzansiProfileViewState extends State<MzansiProfileView> {
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [];
|
||||
toolBodies.add(MihPersonalProfileView(
|
||||
user: widget.user,
|
||||
));
|
||||
toolBodies.add(
|
||||
MihPersonalProfileView(),
|
||||
);
|
||||
return toolBodies;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||
@@ -8,12 +8,11 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihPersonalProfileView extends StatefulWidget {
|
||||
final AppUser user;
|
||||
const MihPersonalProfileView({
|
||||
super.key,
|
||||
required this.user,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -32,8 +31,10 @@ class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
futureImageUrl =
|
||||
MihFileApi.getMinioFileUrl(widget.user.pro_pic_path, context);
|
||||
MzansiDirectoryProvider directoryProvider =
|
||||
context.read<MzansiDirectoryProvider>();
|
||||
futureImageUrl = MihFileApi.getMinioFileUrl(
|
||||
directoryProvider.selectedUser!.pro_pic_path, context);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -48,152 +49,123 @@ class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
|
||||
|
||||
Widget getBody(double width) {
|
||||
double profilePictureWidth = 150;
|
||||
return MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding: MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "") {
|
||||
return MihCircleAvatar(
|
||||
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
return Consumer<MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futureImageUrl,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
if (asyncSnapshot.requireData != "") {
|
||||
return MihCircleAvatar(
|
||||
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||
width: profilePictureWidth,
|
||||
editable: false,
|
||||
fileNameController: TextEditingController(),
|
||||
userSelectedfile: file,
|
||||
frameColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onChange: () {},
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Icon(
|
||||
MihIcons.mihRing,
|
||||
size: profilePictureWidth,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
}),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
directoryProvider.selectedUser!.username.isNotEmpty
|
||||
? directoryProvider.selectedUser!.username
|
||||
: "Username",
|
||||
style: TextStyle(
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
);
|
||||
}
|
||||
// return Center(
|
||||
// child: MihCircleAvatar(
|
||||
// imageFile: propicPreview,
|
||||
// width: 150,
|
||||
// editable: false,
|
||||
// fileNameController: proPicController,
|
||||
// userSelectedfile: proPic,
|
||||
// frameColor: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// backgroundColor:
|
||||
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// onChange: (selectedImage) {
|
||||
// setState(() {
|
||||
// proPic = selectedImage;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
}),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
widget.user.username.isNotEmpty
|
||||
? widget.user.username
|
||||
: "Username",
|
||||
style: TextStyle(
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
widget.user.fname.isNotEmpty
|
||||
? "${widget.user.fname} ${widget.user.lname}"
|
||||
: "Name Surname",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
widget.user.type.toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
widget.user.purpose.isNotEmpty
|
||||
? widget.user.purpose
|
||||
: "No Personal Mission added yet",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
directoryProvider.selectedUser!.fname.isNotEmpty
|
||||
? "${directoryProvider.selectedUser!.fname} ${directoryProvider.selectedUser!.lname}"
|
||||
: "Name Surname",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
FittedBox(
|
||||
child: Text(
|
||||
directoryProvider.selectedUser!.type.toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 700,
|
||||
child: Text(
|
||||
directoryProvider.selectedUser!.purpose.isNotEmpty
|
||||
? directoryProvider.selectedUser!.purpose
|
||||
: "No Personal Mission added yet",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30.0),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 30.0),
|
||||
// Center(
|
||||
// child: MihButton(
|
||||
// onPressed: () {
|
||||
// // Connect with the user
|
||||
// },
|
||||
// buttonColor:
|
||||
// MihColors.getGreenColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// width: 300,
|
||||
// child: Text(
|
||||
// widget.user.username.isEmpty
|
||||
// ? "Set Up Profile"
|
||||
// : "Edit Profile",
|
||||
// style: TextStyle(
|
||||
// color:
|
||||
// MihColors.getPrimaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// fontSize: 20,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/bookmarked_business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_review.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
@@ -156,14 +157,17 @@ class MihMzansiDirectoryServices {
|
||||
|
||||
Future<List<BookmarkedBusiness>> getAllUserBookmarkedBusiness(
|
||||
String app_id,
|
||||
MzansiDirectoryProvider directoryProvider,
|
||||
) async {
|
||||
final response = await http.get(Uri.parse(
|
||||
"${AppEnviroment.baseApiUrl}/mzansi-directory/bookmarked-business/user/all/$app_id/"));
|
||||
if (response.statusCode == 200) {
|
||||
Iterable l = jsonDecode(response.body);
|
||||
List<BookmarkedBusiness> businessReviews = List<BookmarkedBusiness>.from(
|
||||
l.map((model) => BookmarkedBusiness.fromJson(model)));
|
||||
return businessReviews;
|
||||
List<BookmarkedBusiness> favouriteBusinesses =
|
||||
List<BookmarkedBusiness>.from(
|
||||
l.map((model) => BookmarkedBusiness.fromJson(model)));
|
||||
directoryProvider.setFavouriteBusinesses(businesses: favouriteBusinesses);
|
||||
return favouriteBusinesses;
|
||||
} else if (response.statusCode == 404) {
|
||||
return [];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user