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_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/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_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_profile_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
@@ -91,6 +92,9 @@ class _MzansiInnovationHubState extends State<MzansiInnovationHub> {
|
|||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (context) => MzansiAiProvider(),
|
create: (context) => MzansiAiProvider(),
|
||||||
),
|
),
|
||||||
|
ChangeNotifierProvider(
|
||||||
|
create: (context) => MzansiDirectoryProvider(),
|
||||||
|
),
|
||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (context) => MihBannerAdProvider(),
|
create: (context) => MihBannerAdProvider(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -396,7 +396,6 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
return widget.business != null
|
return widget.business != null
|
||||||
? MihBusinessProfilePreview(
|
? MihBusinessProfilePreview(
|
||||||
business: widget.business!,
|
business: widget.business!,
|
||||||
myLocation: myLocation,
|
|
||||||
)
|
)
|
||||||
: Text("NoBusiness Data");
|
: Text("NoBusiness Data");
|
||||||
}
|
}
|
||||||
@@ -424,7 +423,7 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
"rating",
|
"rating",
|
||||||
"mission_vision",
|
"mission_vision",
|
||||||
),
|
),
|
||||||
startUpSearch: '',
|
// startUpSearch: '',
|
||||||
width: 300,
|
width: 300,
|
||||||
).redacted(
|
).redacted(
|
||||||
context: context,
|
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_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_circle_avatar.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_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_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.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:mzansi_innovation_hub/mih_services/mih_location_services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class MihBusinessProfilePreview extends StatefulWidget {
|
class MihBusinessProfilePreview extends StatefulWidget {
|
||||||
final Business business;
|
final Business business;
|
||||||
final String? myLocation;
|
|
||||||
const MihBusinessProfilePreview({
|
const MihBusinessProfilePreview({
|
||||||
super.key,
|
super.key,
|
||||||
required this.business,
|
required this.business,
|
||||||
required this.myLocation,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -26,10 +26,10 @@ class _MihBusinessProfilePreviewState extends State<MihBusinessProfilePreview> {
|
|||||||
late Future<String> futureImageUrl;
|
late Future<String> futureImageUrl;
|
||||||
PlatformFile? file;
|
PlatformFile? file;
|
||||||
|
|
||||||
String calculateDistance() {
|
String calculateDistance(MzansiDirectoryProvider directoryProvider) {
|
||||||
try {
|
try {
|
||||||
double distanceInKm = MIHLocationAPI().getDistanceInMeaters(
|
double distanceInKm = MIHLocationAPI().getDistanceInMeaters(
|
||||||
widget.myLocation!, widget.business.gps_location) /
|
directoryProvider.userLocation, widget.business.gps_location) /
|
||||||
1000;
|
1000;
|
||||||
return "${distanceInKm.toStringAsFixed(2)} km";
|
return "${distanceInKm.toStringAsFixed(2)} km";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -48,73 +48,82 @@ class _MihBusinessProfilePreviewState extends State<MihBusinessProfilePreview> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
double profilePictureWidth = 60;
|
double profilePictureWidth = 60;
|
||||||
return Row(
|
return Consumer<MzansiDirectoryProvider>(
|
||||||
children: [
|
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||||
FutureBuilder(
|
Widget? child) {
|
||||||
future: futureImageUrl,
|
return Row(
|
||||||
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: [
|
children: [
|
||||||
Text(
|
FutureBuilder(
|
||||||
widget.business.Name,
|
future: futureImageUrl,
|
||||||
style: TextStyle(
|
builder: (context, asyncSnapshot) {
|
||||||
fontWeight: FontWeight.bold,
|
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||||
fontSize: 18,
|
asyncSnapshot.hasData) {
|
||||||
),
|
if (asyncSnapshot.requireData != "") {
|
||||||
),
|
return MihCircleAvatar(
|
||||||
Text(
|
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||||
widget.business.type,
|
width: profilePictureWidth,
|
||||||
style: TextStyle(
|
editable: false,
|
||||||
fontWeight: FontWeight.bold,
|
fileNameController: TextEditingController(),
|
||||||
fontSize: 15,
|
userSelectedfile: file,
|
||||||
),
|
frameColor: MihColors.getSecondaryColor(
|
||||||
),
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
Text(
|
"Dark"),
|
||||||
widget.myLocation != null || widget.myLocation!.isEmpty
|
backgroundColor: MihColors.getPrimaryColor(
|
||||||
? calculateDistance()
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
: "0.00 km",
|
"Dark"),
|
||||||
style: TextStyle(
|
onChange: () {},
|
||||||
fontWeight: FontWeight.bold,
|
);
|
||||||
fontSize: 10,
|
} 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:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.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_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_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_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_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/about_mih/about_mih.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/access_review/mih_access.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/access_review/mih_access.dart';
|
||||||
@@ -169,14 +169,15 @@ class MihGoRouter {
|
|||||||
path: MihGoRouterPaths.mzansiProfileView,
|
path: MihGoRouterPaths.mzansiProfileView,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
KenLogger.success("MihGoRouter: mzansiProfileView");
|
KenLogger.success("MihGoRouter: mzansiProfileView");
|
||||||
final AppUser? user = state.extra as AppUser?;
|
MzansiDirectoryProvider directoryProvider =
|
||||||
if (user == null) {
|
context.read<MzansiDirectoryProvider>();
|
||||||
|
if (directoryProvider.selectedUser == null) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.go(MihGoRouterPaths.mihHome);
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
});
|
});
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
return MzansiProfileView(user: user);
|
return MzansiProfileView();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// ========================== Mzansi Profile Business ==================================
|
// ========================== Mzansi Profile Business ==================================
|
||||||
@@ -203,9 +204,10 @@ class MihGoRouter {
|
|||||||
KenLogger.success("MihGoRouter: businessProfileView");
|
KenLogger.success("MihGoRouter: businessProfileView");
|
||||||
String? businessId = state.uri.queryParameters['business_id'];
|
String? businessId = state.uri.queryParameters['business_id'];
|
||||||
KenLogger.success("businessId: $businessId");
|
KenLogger.success("businessId: $businessId");
|
||||||
final BusinessViewArguments? args =
|
MzansiDirectoryProvider directoryProvider =
|
||||||
state.extra as BusinessViewArguments?;
|
context.read<MzansiDirectoryProvider>();
|
||||||
if (args == null && businessId == null) {
|
if (directoryProvider.selectedBusiness == null &&
|
||||||
|
businessId == null) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.go(MihGoRouterPaths.mihHome);
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
});
|
});
|
||||||
@@ -213,7 +215,6 @@ class MihGoRouter {
|
|||||||
}
|
}
|
||||||
return MzansiBusinessProfileView(
|
return MzansiBusinessProfileView(
|
||||||
key: UniqueKey(),
|
key: UniqueKey(),
|
||||||
arguments: args,
|
|
||||||
businessId: businessId,
|
businessId: businessId,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -406,15 +407,13 @@ class MihGoRouter {
|
|||||||
name: "mzansiDirectory",
|
name: "mzansiDirectory",
|
||||||
path: MihGoRouterPaths.mzansiDirectory,
|
path: MihGoRouterPaths.mzansiDirectory,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
final MzansiDirectoryArguments? args =
|
if (context.watch<MzansiProfileProvider>().business == null) {
|
||||||
state.extra as MzansiDirectoryArguments?;
|
|
||||||
if (args == null) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.go(MihGoRouterPaths.mihHome);
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
});
|
});
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
return MzansiDirectory(arguments: args);
|
return MzansiDirectory();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// ========================== End ==================================
|
// ========================== End ==================================
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:ken_logger/ken_logger.dart';
|
import 'package:ken_logger/ken_logger.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.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_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_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_access_controls_services.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';
|
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_error_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_warning_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_config/mih_env.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patient_access.dart';
|
|
||||||
|
|
||||||
class BuildBusinessAccessList extends StatefulWidget {
|
class BuildBusinessAccessList extends StatefulWidget {
|
||||||
final List<PatientAccess> patientAccessList;
|
final String filterText;
|
||||||
final AppUser signedInUser;
|
|
||||||
final void Function()? onSuccessUpate;
|
final void Function()? onSuccessUpate;
|
||||||
|
|
||||||
const BuildBusinessAccessList({
|
const BuildBusinessAccessList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.patientAccessList,
|
required this.filterText,
|
||||||
required this.signedInUser,
|
|
||||||
required this.onSuccessUpate,
|
required this.onSuccessUpate,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -60,18 +60,20 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget displayQueue(int index) {
|
Widget displayQueue(
|
||||||
String line1 =
|
MzansiProfileProvider mzansiProfileProvider,
|
||||||
"Business Name: ${widget.patientAccessList[index].requested_by}";
|
MihAccessControllsProvider accessProvider,
|
||||||
|
int index,
|
||||||
|
List<PatientAccess> filteredList) {
|
||||||
|
String line1 = "Business Name: ${filteredList[index].requested_by}";
|
||||||
String line2 = "";
|
String line2 = "";
|
||||||
|
|
||||||
line2 +=
|
line2 +=
|
||||||
"Request Date: ${widget.patientAccessList[index].requested_on.substring(0, 16).replaceAll("T", " ")}\n";
|
"Request Date: ${filteredList[index].requested_on.substring(0, 16).replaceAll("T", " ")}\n";
|
||||||
line2 +=
|
line2 += "Profile Type: ${filteredList[index].type.toUpperCase()}\n";
|
||||||
"Profile Type: ${widget.patientAccessList[index].type.toUpperCase()}\n";
|
|
||||||
//subtitle += "Business Type: ${widget.patientAccessList[index].type}\n";
|
//subtitle += "Business Type: ${widget.patientAccessList[index].type}\n";
|
||||||
String line3 = "Status: ";
|
String line3 = "Status: ";
|
||||||
String access = widget.patientAccessList[index].status.toUpperCase();
|
String access = filteredList[index].status.toUpperCase();
|
||||||
|
|
||||||
TextSpan accessWithColour;
|
TextSpan accessWithColour;
|
||||||
if (access == "APPROVED") {
|
if (access == "APPROVED") {
|
||||||
@@ -118,7 +120,7 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
viewApprovalPopUp(index);
|
viewApprovalPopUp(mzansiProfileProvider, accessProvider, index);
|
||||||
},
|
},
|
||||||
// trailing: Icon(
|
// trailing: Icon(
|
||||||
// Icons.arrow_forward,
|
// 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 =
|
String subtitle =
|
||||||
"Business Name: ${widget.patientAccessList[index].requested_by}\n";
|
"Business Name: ${accessProvider.accessList![index].requested_by}\n";
|
||||||
subtitle +=
|
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 +=
|
subtitle +=
|
||||||
"Profile Type: ${widget.patientAccessList[index].type.toUpperCase()}\n";
|
"Profile Type: ${accessProvider.accessList![index].type.toUpperCase()}\n";
|
||||||
subtitle +=
|
subtitle +=
|
||||||
"Status: ${widget.patientAccessList[index].status.toUpperCase()}";
|
"Status: ${accessProvider.accessList![index].status.toUpperCase()}";
|
||||||
if (widget.patientAccessList[index].status == 'pending') {
|
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.";
|
// "\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 {
|
} else {
|
||||||
subtitle +=
|
subtitle +=
|
||||||
"\nActioned By: ${widget.patientAccessList[index].approved_by}\n";
|
"\nActioned By: ${accessProvider.accessList![index].approved_by}\n";
|
||||||
subtitle +=
|
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 +=
|
// 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.";
|
// "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),
|
const SizedBox(height: 20.0),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: widget.patientAccessList[index].status == 'pending',
|
visible: accessProvider.accessList![index].status == 'pending',
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@@ -271,7 +274,7 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: widget.patientAccessList[index].status == 'approved',
|
visible: accessProvider.accessList![index].status == 'approved',
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@@ -338,7 +341,7 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
|||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: widget.patientAccessList[index].status == 'pending',
|
visible: accessProvider.accessList![index].status == 'pending',
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
runSpacing: 10,
|
runSpacing: 10,
|
||||||
spacing: 10,
|
spacing: 10,
|
||||||
@@ -348,15 +351,20 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
|||||||
print("request declined");
|
print("request declined");
|
||||||
int statusCode = await MihAccessControlsServices()
|
int statusCode = await MihAccessControlsServices()
|
||||||
.updatePatientAccessAPICall(
|
.updatePatientAccessAPICall(
|
||||||
widget.patientAccessList[index].business_id,
|
accessProvider.accessList![index].business_id,
|
||||||
widget.patientAccessList[index].requested_by,
|
accessProvider.accessList![index].requested_by,
|
||||||
widget.patientAccessList[index].app_id,
|
accessProvider.accessList![index].app_id,
|
||||||
"declined",
|
"declined",
|
||||||
"${widget.signedInUser.fname} ${widget.signedInUser.lname}",
|
"${mzansiProfileProvider.user!.fname} ${mzansiProfileProvider.user!.lname}",
|
||||||
widget.signedInUser,
|
mzansiProfileProvider.user!,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
if (statusCode == 200) {
|
if (statusCode == 200) {
|
||||||
|
await MihAccessControlsServices()
|
||||||
|
.getBusinessAccessListOfPatient(
|
||||||
|
mzansiProfileProvider.user!.app_id,
|
||||||
|
accessProvider,
|
||||||
|
);
|
||||||
context.pop();
|
context.pop();
|
||||||
successPopUp("Successfully Actioned Request",
|
successPopUp("Successfully Actioned Request",
|
||||||
"You have successfully Declined access request");
|
"You have successfully Declined access request");
|
||||||
@@ -384,15 +392,20 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
|||||||
print("request approved");
|
print("request approved");
|
||||||
int statusCode = await MihAccessControlsServices()
|
int statusCode = await MihAccessControlsServices()
|
||||||
.updatePatientAccessAPICall(
|
.updatePatientAccessAPICall(
|
||||||
widget.patientAccessList[index].business_id,
|
accessProvider.accessList![index].business_id,
|
||||||
widget.patientAccessList[index].requested_by,
|
accessProvider.accessList![index].requested_by,
|
||||||
widget.patientAccessList[index].app_id,
|
accessProvider.accessList![index].app_id,
|
||||||
"approved",
|
"approved",
|
||||||
"${widget.signedInUser.fname} ${widget.signedInUser.lname}",
|
"${mzansiProfileProvider.user!.fname} ${mzansiProfileProvider.user!.lname}",
|
||||||
widget.signedInUser,
|
mzansiProfileProvider.user!,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
if (statusCode == 200) {
|
if (statusCode == 200) {
|
||||||
|
await MihAccessControlsServices()
|
||||||
|
.getBusinessAccessListOfPatient(
|
||||||
|
mzansiProfileProvider.user!.app_id,
|
||||||
|
accessProvider,
|
||||||
|
);
|
||||||
context.pop();
|
context.pop();
|
||||||
successPopUp("Successfully Actioned Request",
|
successPopUp("Successfully Actioned Request",
|
||||||
"You have successfully Accepted access 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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -500,21 +523,30 @@ class _BuildPatientsListState extends State<BuildBusinessAccessList> {
|
|||||||
height = size.height;
|
height = size.height;
|
||||||
});
|
});
|
||||||
checkScreenSize();
|
checkScreenSize();
|
||||||
return ListView.separated(
|
return Consumer2<MzansiProfileProvider, MihAccessControllsProvider>(
|
||||||
shrinkWrap: true,
|
builder: (BuildContext context,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
MzansiProfileProvider mzansiProfileProvider,
|
||||||
separatorBuilder: (BuildContext context, index) {
|
MihAccessControllsProvider accessProvider,
|
||||||
return Divider(
|
Widget? child) {
|
||||||
color: MihColors.getSecondaryColor(
|
return ListView.separated(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
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({
|
temp.add({
|
||||||
"Mzansi Directory": MzansiDirectoryTile(
|
"Mzansi Directory": MzansiDirectoryTile(
|
||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
personalSelected: false,
|
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
//=============== Calculator ===============
|
//=============== Calculator ===============
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ class _MihPersonalHomeState extends State<MihPersonalHome>
|
|||||||
temp.add({
|
temp.add({
|
||||||
"Mzansi Directory": MzansiDirectoryTile(
|
"Mzansi Directory": MzansiDirectoryTile(
|
||||||
packageSize: packageSize,
|
packageSize: packageSize,
|
||||||
personalSelected: true,
|
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
//=============== Calendar ===============
|
//=============== Calendar ===============
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.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.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_business_profile_preview.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:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class BuildBusinessSearchResultsList extends StatefulWidget {
|
class BuildBusinessSearchResultsList extends StatefulWidget {
|
||||||
final List<Business> businessList;
|
final List<Business> businessList;
|
||||||
final String myLocation;
|
|
||||||
final String? startUpSearch;
|
|
||||||
const BuildBusinessSearchResultsList({
|
const BuildBusinessSearchResultsList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.businessList,
|
required this.businessList,
|
||||||
required this.myLocation,
|
|
||||||
required this.startUpSearch,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -26,52 +23,48 @@ class _BuildBusinessSearchResultsListState
|
|||||||
extends State<BuildBusinessSearchResultsList> {
|
extends State<BuildBusinessSearchResultsList> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView.separated(
|
return Consumer<MzansiDirectoryProvider>(
|
||||||
shrinkWrap: true,
|
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
Widget? child) {
|
||||||
itemCount: widget.businessList.length,
|
return ListView.separated(
|
||||||
separatorBuilder: (BuildContext context, index) {
|
shrinkWrap: true,
|
||||||
return Divider(
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
color: MihColors.getSecondaryColor(
|
itemCount: widget.businessList.length,
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
separatorBuilder: (BuildContext context, index) {
|
||||||
);
|
return Divider(
|
||||||
},
|
color: MihColors.getSecondaryColor(
|
||||||
itemBuilder: (context, index) {
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
return Material(
|
);
|
||||||
color: MihColors.getPrimaryColor(
|
},
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
itemBuilder: (context, index) {
|
||||||
child: InkWell(
|
return Material(
|
||||||
onTap: () {
|
color: MihColors.getPrimaryColor(
|
||||||
context.goNamed(
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
'businessProfileView',
|
child: InkWell(
|
||||||
extra: BusinessViewArguments(
|
onTap: () {
|
||||||
widget.businessList[index],
|
directoryProvider.setSelectedBusiness(
|
||||||
widget.businessList[index].Name,
|
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:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.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.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_business_profile_preview.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:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class BuildFavouriteBusinessesList extends StatefulWidget {
|
class BuildFavouriteBusinessesList extends StatefulWidget {
|
||||||
final List<Business?> favouriteBusinesses;
|
final List<Business?> favouriteBusinesses;
|
||||||
final String? myLocation;
|
|
||||||
const BuildFavouriteBusinessesList({
|
const BuildFavouriteBusinessesList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.favouriteBusinesses,
|
required this.favouriteBusinesses,
|
||||||
required this.myLocation,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -24,54 +23,49 @@ class _BuildFavouriteBusinessesListState
|
|||||||
extends State<BuildFavouriteBusinessesList> {
|
extends State<BuildFavouriteBusinessesList> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView.separated(
|
return Consumer<MzansiDirectoryProvider>(
|
||||||
shrinkWrap: true,
|
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
Widget? child) {
|
||||||
itemCount: widget.favouriteBusinesses.length,
|
return ListView.separated(
|
||||||
separatorBuilder: (BuildContext context, index) {
|
shrinkWrap: true,
|
||||||
return Divider(
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
itemCount: widget.favouriteBusinesses.length,
|
||||||
);
|
separatorBuilder: (BuildContext context, index) {
|
||||||
},
|
return Divider(
|
||||||
itemBuilder: (context, index) {
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
final Business? business = widget.favouriteBusinesses[index];
|
);
|
||||||
|
},
|
||||||
if (business == null) {
|
itemBuilder: (context, index) {
|
||||||
return const SizedBox(); // Or a placeholder if a business couldn't be loaded
|
if (widget.favouriteBusinesses[index] == null) {
|
||||||
}
|
return const SizedBox(); // Or a placeholder if a business couldn't be loaded
|
||||||
|
}
|
||||||
return Material(
|
return Material(
|
||||||
color: MihColors.getPrimaryColor(
|
color: MihColors.getPrimaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
directoryProvider.setSelectedBusiness(
|
||||||
'businessProfileView',
|
business: widget.favouriteBusinesses[index]!,
|
||||||
extra: BusinessViewArguments(
|
);
|
||||||
widget.favouriteBusinesses[index]!,
|
context.goNamed(
|
||||||
widget.favouriteBusinesses[index]!.Name,
|
'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/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.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_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:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class BuildUserSearchResultsList extends StatefulWidget {
|
class BuildUserSearchResultsList extends StatefulWidget {
|
||||||
final List<AppUser> userList;
|
final List<AppUser> userList;
|
||||||
@@ -21,45 +23,46 @@ class _BuildUserSearchResultsListState
|
|||||||
extends State<BuildUserSearchResultsList> {
|
extends State<BuildUserSearchResultsList> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView.separated(
|
return Consumer<MzansiDirectoryProvider>(
|
||||||
shrinkWrap: true,
|
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
Widget? child) {
|
||||||
itemCount: widget.userList.length,
|
return ListView.separated(
|
||||||
separatorBuilder: (BuildContext context, index) {
|
shrinkWrap: true,
|
||||||
return Divider(
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
color: MihColors.getSecondaryColor(
|
itemCount: widget.userList.length,
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
separatorBuilder: (BuildContext context, index) {
|
||||||
);
|
return Divider(
|
||||||
},
|
color: MihColors.getSecondaryColor(
|
||||||
itemBuilder: (context, index) {
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
return Material(
|
);
|
||||||
color: MihColors.getPrimaryColor(
|
},
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
itemBuilder: (context, index) {
|
||||||
child: InkWell(
|
return Material(
|
||||||
onTap: () {
|
color: MihColors.getPrimaryColor(
|
||||||
context.goNamed(
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
'mzansiProfileView',
|
child: InkWell(
|
||||||
extra: widget.userList[index],
|
onTap: () {
|
||||||
);
|
directoryProvider.setSelectedUser(
|
||||||
// Navigator.of(context).pushNamed(
|
user: widget.userList[index]);
|
||||||
// '/mzansi-profile/view',
|
context.pushNamed(
|
||||||
// arguments: widget.userList[index],
|
'mzansiProfileView',
|
||||||
// );
|
);
|
||||||
},
|
},
|
||||||
splashColor: MihColors.getSecondaryColor(
|
splashColor: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||||
.withOpacity(0.2),
|
.withOpacity(0.2),
|
||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(15),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsetsGeometry.symmetric(
|
padding: EdgeInsetsGeometry.symmetric(
|
||||||
// vertical: 5,
|
// vertical: 5,
|
||||||
horizontal: 25,
|
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:flutter/material.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:go_router/go_router.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.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_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.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_favourite_businesses.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_directory/package_tools/mih_search_mzansi.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:mzansi_innovation_hub/mih_services/mih_location_services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class MzansiDirectory extends StatefulWidget {
|
class MzansiDirectory extends StatefulWidget {
|
||||||
final MzansiDirectoryArguments arguments;
|
|
||||||
const MzansiDirectory({
|
const MzansiDirectory({
|
||||||
super.key,
|
super.key,
|
||||||
required this.arguments,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -21,75 +20,54 @@ class MzansiDirectory extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MzansiDirectoryState extends State<MzansiDirectory> {
|
class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||||
int _selcetedIndex = 0;
|
|
||||||
late Future<Position?> futurePosition =
|
late Future<Position?> futurePosition =
|
||||||
MIHLocationAPI().getGPSPosition(context);
|
MIHLocationAPI().getGPSPosition(context);
|
||||||
|
|
||||||
|
Future<void> initialiseGPSLocation() async {
|
||||||
|
MzansiDirectoryProvider directoryProvider =
|
||||||
|
context.read<MzansiDirectoryProvider>();
|
||||||
|
MIHLocationAPI().getGPSPosition(context).then((position) {
|
||||||
|
directoryProvider.setUserPosition(position);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.arguments.packageIndex == null) {
|
initialiseGPSLocation();
|
||||||
_selcetedIndex = 0;
|
|
||||||
} else {
|
|
||||||
_selcetedIndex = widget.arguments.packageIndex!;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
print('MzansiDirectory build method called!');
|
|
||||||
return MihPackage(
|
return MihPackage(
|
||||||
appActionButton: getAction(),
|
appActionButton: getAction(),
|
||||||
appTools: getTools(),
|
appTools: getTools(),
|
||||||
appBody: getToolBody(),
|
appBody: getToolBody(),
|
||||||
appToolTitles: getToolTitle(),
|
appToolTitles: getToolTitle(),
|
||||||
selectedbodyIndex: _selcetedIndex,
|
selectedbodyIndex: context.watch<MzansiDirectoryProvider>().toolIndex,
|
||||||
onIndexChange: (newValue) {
|
onIndexChange: (newValue) {
|
||||||
setState(() {
|
context.read<MzansiDirectoryProvider>().setToolIndex(newValue);
|
||||||
_selcetedIndex = newValue;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getToolBody() {
|
List<Widget> getToolBody() {
|
||||||
List<Widget> toolBodies = [
|
List<Widget> toolBodies = [];
|
||||||
FutureBuilder(
|
// String myLocation = "Getting Your GPS Location Ready";
|
||||||
future: futurePosition,
|
// if (directoryProvider.userPosition != null) {
|
||||||
builder: (context, asyncSnapshot) {
|
// myLocation = directoryProvider.userPosition
|
||||||
String myLocation = "";
|
// .toString()
|
||||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
// .replaceAll("Latitude: ", "")
|
||||||
myLocation = "Getting Your GPS Location Ready";
|
// .replaceAll("Longitude: ", "");
|
||||||
} else {
|
// }
|
||||||
myLocation = asyncSnapshot.data
|
toolBodies.addAll([
|
||||||
.toString()
|
MihSearchMzansi(
|
||||||
.replaceAll("Latitude: ", "")
|
// personalSearch: directoryProvider.personalSearch,
|
||||||
.replaceAll("Longitude: ", "");
|
// startSearchText: "",
|
||||||
}
|
),
|
||||||
return MihSearchMzansi(
|
|
||||||
personalSearch: widget.arguments.personalSearch,
|
|
||||||
myLocation: myLocation,
|
|
||||||
startSearchText: widget.arguments.startSearchText,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
// MihContacts(),
|
// MihContacts(),
|
||||||
FutureBuilder(
|
MihFavouriteBusinesses(),
|
||||||
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,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
return toolBodies;
|
return toolBodies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,9 +76,13 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
|||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
iconSize: 35,
|
iconSize: 35,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
MzansiDirectoryProvider directoryProvider =
|
||||||
|
context.read<MzansiDirectoryProvider>();
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'mihHome',
|
'mihHome',
|
||||||
);
|
);
|
||||||
|
directoryProvider.setToolIndex(0);
|
||||||
|
directoryProvider.setPersonalSearch(true);
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -109,23 +91,14 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
|||||||
MihPackageTools getTools() {
|
MihPackageTools getTools() {
|
||||||
Map<Widget, void Function()?> temp = {};
|
Map<Widget, void Function()?> temp = {};
|
||||||
temp[const Icon(Icons.search)] = () {
|
temp[const Icon(Icons.search)] = () {
|
||||||
setState(() {
|
context.read<MzansiDirectoryProvider>().setToolIndex(0);
|
||||||
_selcetedIndex = 0;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
// temp[const Icon(Icons.person)] = () {
|
|
||||||
// setState(() {
|
|
||||||
// _selcetedIndex = 1;
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
temp[const Icon(Icons.business_center)] = () {
|
temp[const Icon(Icons.business_center)] = () {
|
||||||
setState(() {
|
context.read<MzansiDirectoryProvider>().setToolIndex(1);
|
||||||
_selcetedIndex = 1;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
return MihPackageTools(
|
return MihPackageTools(
|
||||||
tools: temp,
|
tools: temp,
|
||||||
selcetedIndex: _selcetedIndex,
|
selcetedIndex: context.watch<MzansiDirectoryProvider>().toolIndex,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +106,7 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
|||||||
List<String> toolTitles = [
|
List<String> toolTitles = [
|
||||||
"Mzansi Search",
|
"Mzansi Search",
|
||||||
"Favourite Businesses",
|
"Favourite Businesses",
|
||||||
"Contacts",
|
// "Contacts",
|
||||||
];
|
];
|
||||||
return toolTitles;
|
return toolTitles;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.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_icons.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tile.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';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
|
||||||
class MzansiDirectoryTile extends StatefulWidget {
|
class MzansiDirectoryTile extends StatefulWidget {
|
||||||
final double packageSize;
|
final double packageSize;
|
||||||
final bool personalSelected;
|
|
||||||
const MzansiDirectoryTile({
|
const MzansiDirectoryTile({
|
||||||
super.key,
|
super.key,
|
||||||
required this.packageSize,
|
required this.packageSize,
|
||||||
required this.personalSelected,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -26,10 +23,6 @@ class _MzansiDirectoryTileState extends State<MzansiDirectoryTile> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
"mzansiDirectory",
|
"mzansiDirectory",
|
||||||
extra: MzansiDirectoryArguments(
|
|
||||||
personalSearch: widget.personalSelected,
|
|
||||||
startSearchText: null,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
// Navigator.of(context).pushNamed(
|
// Navigator.of(context).pushNamed(
|
||||||
// '/mzansi-directory',
|
// '/mzansi-directory',
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.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_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_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_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_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_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_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_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_business_details_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_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 {
|
class MihFavouriteBusinesses extends StatefulWidget {
|
||||||
final String? myLocation;
|
|
||||||
const MihFavouriteBusinesses({
|
const MihFavouriteBusinesses({
|
||||||
super.key,
|
super.key,
|
||||||
required this.myLocation,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -29,42 +27,42 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
|||||||
final TextEditingController businessSearchController =
|
final TextEditingController businessSearchController =
|
||||||
TextEditingController();
|
TextEditingController();
|
||||||
final FocusNode searchFocusNode = FocusNode();
|
final FocusNode searchFocusNode = FocusNode();
|
||||||
late Future<List<BookmarkedBusiness>> boookmarkedBusinessListFuture;
|
|
||||||
List<BookmarkedBusiness> listBookmarkedBusinesses = [];
|
|
||||||
final ValueNotifier<List<Business?>> searchBookmarkedBusinesses =
|
final ValueNotifier<List<Business?>> searchBookmarkedBusinesses =
|
||||||
ValueNotifier([]);
|
ValueNotifier([]);
|
||||||
late Future<Map<String, Business?>> businessDetailsMapFuture;
|
|
||||||
Map<String, Business?> _businessDetailsMap = {};
|
|
||||||
Timer? _debounce;
|
Timer? _debounce;
|
||||||
|
|
||||||
Future<Map<String, Business?>>
|
Future<void> getAndMapAllBusinessDetailsForBookmarkedBusinesses(
|
||||||
getAndMapAllBusinessDetailsForBookmarkedBusinesses() async {
|
MzansiProfileProvider mzansiProfileProvider,
|
||||||
String user_id = await SuperTokens.getUserId();
|
MzansiDirectoryProvider directoryProvider,
|
||||||
List<BookmarkedBusiness> bookmarked = await MihMzansiDirectoryServices()
|
) async {
|
||||||
.getAllUserBookmarkedBusiness(user_id);
|
await MihMzansiDirectoryServices().getAllUserBookmarkedBusiness(
|
||||||
listBookmarkedBusinesses = bookmarked;
|
mzansiProfileProvider.user!.app_id,
|
||||||
|
directoryProvider,
|
||||||
|
);
|
||||||
Map<String, Business?> businessMap = {};
|
Map<String, Business?> businessMap = {};
|
||||||
List<Future<Business?>> detailFutures = [];
|
List<Future<Business?>> detailFutures = [];
|
||||||
for (var item in bookmarked) {
|
for (var item in directoryProvider.bookmarkedBusinesses) {
|
||||||
detailFutures.add(MihBusinessDetailsServices()
|
detailFutures.add(MihBusinessDetailsServices()
|
||||||
.getBusinessDetailsByBusinessId(item.business_id));
|
.getBusinessDetailsByBusinessId(item.business_id));
|
||||||
}
|
}
|
||||||
List<Business?> details = await Future.wait(detailFutures);
|
List<Business?> details = await Future.wait(detailFutures);
|
||||||
for (int i = 0; i < bookmarked.length; i++) {
|
for (int i = 0; i < directoryProvider.bookmarkedBusinesses.length; i++) {
|
||||||
businessMap[bookmarked[i].business_id] = details[i];
|
businessMap[directoryProvider.bookmarkedBusinesses[i].business_id] =
|
||||||
|
details[i];
|
||||||
}
|
}
|
||||||
_businessDetailsMap = businessMap;
|
directoryProvider.setBusinessDetailsMap(detailsMap: businessMap);
|
||||||
_filterAndSetBusinesses();
|
_filterAndSetBusinesses(directoryProvider);
|
||||||
return businessMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _filterAndSetBusinesses() {
|
void _filterAndSetBusinesses(MzansiDirectoryProvider directoryProvider) {
|
||||||
List<Business?> businessesToDisplay = [];
|
List<Business?> businessesToDisplay = [];
|
||||||
String query = businessSearchController.text.toLowerCase();
|
String query = businessSearchController.text.toLowerCase();
|
||||||
for (var bookmarked in listBookmarkedBusinesses) {
|
for (var bookmarked in directoryProvider.bookmarkedBusinesses) {
|
||||||
if (bookmarked.business_name.toLowerCase().contains(query)) {
|
if (bookmarked.business_name.toLowerCase().contains(query)) {
|
||||||
if (_businessDetailsMap.containsKey(bookmarked.business_id)) {
|
if (directoryProvider.businessDetailsMap
|
||||||
businessesToDisplay.add(_businessDetailsMap[bookmarked.business_id]);
|
.containsKey(bookmarked.business_id)) {
|
||||||
|
businessesToDisplay.add(
|
||||||
|
directoryProvider.businessDetailsMap[bookmarked.business_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,14 +80,21 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
businessDetailsMapFuture =
|
MzansiDirectoryProvider directoryProvider =
|
||||||
getAndMapAllBusinessDetailsForBookmarkedBusinesses();
|
context.read<MzansiDirectoryProvider>();
|
||||||
|
MzansiProfileProvider mzansiProfileProvider =
|
||||||
|
context.read<MzansiProfileProvider>();
|
||||||
|
|
||||||
|
getAndMapAllBusinessDetailsForBookmarkedBusinesses(
|
||||||
|
mzansiProfileProvider,
|
||||||
|
directoryProvider,
|
||||||
|
);
|
||||||
businessSearchController.addListener(() {
|
businessSearchController.addListener(() {
|
||||||
if (_debounce?.isActive ?? false) {
|
if (_debounce?.isActive ?? false) {
|
||||||
_debounce!.cancel();
|
_debounce!.cancel();
|
||||||
}
|
}
|
||||||
_debounce = Timer(const Duration(milliseconds: 200), () {
|
_debounce = Timer(const Duration(milliseconds: 200), () {
|
||||||
_filterAndSetBusinesses();
|
_filterAndSetBusinesses(directoryProvider);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -123,141 +128,95 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
FutureBuilder<Map<String, Business?>>(
|
ValueListenableBuilder<List<Business?>>(
|
||||||
future: businessDetailsMapFuture,
|
valueListenable: searchBookmarkedBusinesses,
|
||||||
builder: (context, snapshot) {
|
builder: (context, filteredBusinesses, child) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (filteredBusinesses.isEmpty &&
|
||||||
return Mihloadingcircle(
|
businessSearchController.text.isNotEmpty) {
|
||||||
message: "Getting your favourites",
|
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) {
|
} else if (filteredBusinesses.isEmpty &&
|
||||||
if (snapshot.hasData && snapshot.data!.isNotEmpty) {
|
businessSearchController.text.isEmpty) {
|
||||||
// No need to re-filter here, _filterAndSetBusinesses is called in initState
|
return Padding(
|
||||||
// and by the text controller listener.
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
return ValueListenableBuilder<List<Business?>>(
|
child: Column(
|
||||||
valueListenable:
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
searchBookmarkedBusinesses, // Listen to changes in this
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
builder: (context, businesses, child) {
|
children: [
|
||||||
// Display message if no results after search
|
const SizedBox(height: 50),
|
||||||
if (businesses.isEmpty &&
|
Icon(
|
||||||
businessSearchController.text.isNotEmpty) {
|
MihIcons.businessProfile,
|
||||||
return Column(
|
size: 165,
|
||||||
children: [
|
color: MihColors.getSecondaryColor(
|
||||||
const SizedBox(height: 50),
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
Icon(
|
"Dark"),
|
||||||
MihIcons.iDontKnow,
|
),
|
||||||
size: 165,
|
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(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!
|
MzansiInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.mode ==
|
.mode ==
|
||||||
"Dark"),
|
"Dark"),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
children: [
|
||||||
Text(
|
TextSpan(text: "Use the mzansi search"),
|
||||||
"Let's try refining your search",
|
TextSpan(
|
||||||
textAlign: TextAlign.center,
|
text:
|
||||||
overflow: TextOverflow.visible,
|
" to find your favourite businesses of mzansi"),
|
||||||
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"),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
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:flutter/material.dart';
|
||||||
|
import 'package:ken_logger/ken_logger.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.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/app_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.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_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_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_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_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_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_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_alert_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_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:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class MihSearchMzansi extends StatefulWidget {
|
class MihSearchMzansi extends StatefulWidget {
|
||||||
final bool personalSearch;
|
|
||||||
final String? myLocation;
|
|
||||||
final String? startSearchText;
|
|
||||||
const MihSearchMzansi({
|
const MihSearchMzansi({
|
||||||
super.key,
|
super.key,
|
||||||
required this.personalSearch,
|
|
||||||
required this.myLocation,
|
|
||||||
required this.startSearchText,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -35,80 +32,87 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
|||||||
final TextEditingController mzansiSearchController = TextEditingController();
|
final TextEditingController mzansiSearchController = TextEditingController();
|
||||||
final TextEditingController businessTypeController = TextEditingController();
|
final TextEditingController businessTypeController = TextEditingController();
|
||||||
final FocusNode searchFocusNode = FocusNode();
|
final FocusNode searchFocusNode = FocusNode();
|
||||||
late bool userSearch;
|
// late bool userSearch;
|
||||||
Future<List<AppUser>?> futureUserSearchResults = Future.value();
|
// Future<List<AppUser>?> futureUserSearchResults = Future.value();
|
||||||
Future<List<Business>?> futureBusinessSearchResults = Future.value();
|
|
||||||
List<AppUser> userSearchResults = [];
|
List<AppUser> userSearchResults = [];
|
||||||
List<Business> businessSearchResults = [];
|
List<Business> businessSearchResults = [];
|
||||||
late Future<List<String>> availableBusinessTypes;
|
late Future<List<String>> availableBusinessTypes;
|
||||||
bool filterOn = false;
|
bool filterOn = false;
|
||||||
|
bool loadingSearchResults = false;
|
||||||
|
|
||||||
void swapPressed() {
|
Future<void> swapPressed(MzansiDirectoryProvider directoryProvider) async {
|
||||||
|
directoryProvider.setPersonalSearch(!directoryProvider.personalSearch);
|
||||||
setState(() {
|
setState(() {
|
||||||
userSearch = !userSearch;
|
|
||||||
if (filterOn) {
|
if (filterOn) {
|
||||||
filterOn = !filterOn;
|
filterOn = !filterOn;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (businessTypeController.text.isNotEmpty) {
|
if (businessTypeController.text.isNotEmpty) {
|
||||||
setState(() {
|
setState(() {
|
||||||
futureBusinessSearchResults = Future.value();
|
|
||||||
businessTypeController.clear();
|
businessTypeController.clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
searchPressed();
|
await searchPressed(directoryProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearAll() {
|
void clearAll(MzansiDirectoryProvider directoryProvider) {
|
||||||
|
directoryProvider.setSearchedBusinesses(searchedBusinesses: []);
|
||||||
|
directoryProvider.setSearchedUsers(searchedUsers: []);
|
||||||
|
directoryProvider.setSearchTerm(searchTerm: "");
|
||||||
setState(() {
|
setState(() {
|
||||||
futureUserSearchResults = Future.value();
|
|
||||||
futureBusinessSearchResults = Future.value();
|
|
||||||
mzansiSearchController.clear();
|
mzansiSearchController.clear();
|
||||||
businessTypeController.clear();
|
businessTypeController.clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void searchPressed() {
|
Future<void> searchPressed(MzansiDirectoryProvider directoryProvider) async {
|
||||||
setState(() {
|
setState(() {
|
||||||
// userSearch = !userSearch;
|
loadingSearchResults = true;
|
||||||
if (userSearch && mzansiSearchController.text.isNotEmpty) {
|
});
|
||||||
futureUserSearchResults =
|
directoryProvider.setSearchTerm(searchTerm: mzansiSearchController.text);
|
||||||
MihUserServices().searchUsers(mzansiSearchController.text, context);
|
directoryProvider.setBusinessTypeFilter(
|
||||||
} else {
|
businessTypeFilter: businessTypeController.text);
|
||||||
if (
|
if (directoryProvider.personalSearch &&
|
||||||
// mzansiSearchController.text.isNotEmpty &&
|
directoryProvider.searchTerm.isNotEmpty) {
|
||||||
businessTypeController.text.isNotEmpty) {
|
final userResults = await MihUserServices()
|
||||||
futureBusinessSearchResults = MihBusinessDetailsServices()
|
.searchUsers(directoryProvider.searchTerm, context);
|
||||||
.searchBusinesses(mzansiSearchController.text,
|
directoryProvider.setSearchedUsers(searchedUsers: userResults);
|
||||||
businessTypeController.text, context);
|
} else {
|
||||||
} else if (mzansiSearchController.text.isNotEmpty) {
|
List<Business>? businessSearchResults = [];
|
||||||
futureBusinessSearchResults = MihBusinessDetailsServices()
|
if (directoryProvider.businessTypeFilter.isNotEmpty) {
|
||||||
.searchBusinesses(mzansiSearchController.text,
|
businessSearchResults = await MihBusinessDetailsServices()
|
||||||
businessTypeController.text, context);
|
.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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
businessTypeController.dispose();
|
||||||
mzansiSearchController.dispose();
|
mzansiSearchController.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
MzansiDirectoryProvider directoryProvider =
|
||||||
|
context.read<MzansiDirectoryProvider>();
|
||||||
|
directoryProvider.setSearchedUsers(searchedUsers: []);
|
||||||
setState(() {
|
setState(() {
|
||||||
userSearch = widget.personalSearch;
|
|
||||||
availableBusinessTypes =
|
availableBusinessTypes =
|
||||||
MihBusinessDetailsServices().fetchAllBusinessTypes();
|
MihBusinessDetailsServices().fetchAllBusinessTypes();
|
||||||
if (widget.startSearchText != null) {
|
mzansiSearchController.text = "";
|
||||||
mzansiSearchController.text = widget.startSearchText!;
|
|
||||||
searchPressed();
|
|
||||||
} else {
|
|
||||||
mzansiSearchController.text = "";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,444 +127,426 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getBody(double width) {
|
Widget getBody(double width) {
|
||||||
return MihSingleChildScroll(
|
return Consumer<MzansiDirectoryProvider>(
|
||||||
child: Column(
|
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||||
children: [
|
Widget? child) {
|
||||||
Padding(
|
return MihSingleChildScroll(
|
||||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
child: Column(
|
||||||
child: Row(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
Padding(
|
||||||
children: [
|
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||||
Expanded(
|
child: Row(
|
||||||
child: MihSearchBar(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
controller: mzansiSearchController,
|
children: [
|
||||||
hintText: "Search Mzansi",
|
Expanded(
|
||||||
prefixIcon: Icons.search,
|
child: MihSearchBar(
|
||||||
prefixAltIcon: userSearch ? Icons.person : Icons.business,
|
controller: mzansiSearchController,
|
||||||
suffixTools: [
|
hintText: "Search Mzansi",
|
||||||
IconButton(
|
prefixIcon: Icons.search,
|
||||||
onPressed: () {
|
prefixAltIcon: directoryProvider.personalSearch
|
||||||
swapPressed();
|
? Icons.person
|
||||||
},
|
: Icons.business,
|
||||||
icon: Icon(
|
suffixTools: [
|
||||||
Icons.swap_horiz_rounded,
|
IconButton(
|
||||||
size: 35,
|
onPressed: () {
|
||||||
color: MihColors.getPrimaryColor(
|
swapPressed(directoryProvider);
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
},
|
||||||
"Dark"),
|
icon: Icon(
|
||||||
),
|
Icons.swap_horiz_rounded,
|
||||||
),
|
size: 35,
|
||||||
],
|
|
||||||
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(
|
|
||||||
color: MihColors.getPrimaryColor(
|
color: MihColors.getPrimaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark"),
|
"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,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Visibility(
|
||||||
);
|
visible: !directoryProvider.personalSearch,
|
||||||
}),
|
child: const SizedBox(width: 10),
|
||||||
const SizedBox(height: 10),
|
),
|
||||||
displaySearchResults(userSearch, widget.myLocation ?? ""),
|
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) {
|
Widget displayBusinessSearchResults(
|
||||||
if (userSearch) {
|
MzansiDirectoryProvider directoryProvider) {
|
||||||
return FutureBuilder(
|
KenLogger.success(
|
||||||
future: futureUserSearchResults,
|
"Searched Businesses: ${directoryProvider.searchedBusinesses}");
|
||||||
builder: (context, snapshot) {
|
if (directoryProvider.searchedBusinesses == null || loadingSearchResults) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
return Center(
|
||||||
return const Mihloadingcircle();
|
child: const Mihloadingcircle(),
|
||||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
);
|
||||||
snapshot.hasData &&
|
} else if (directoryProvider.searchedBusinesses!.isNotEmpty) {
|
||||||
snapshot.requireData!.isNotEmpty) {
|
// return Text("Pulled Data successfully");
|
||||||
// return Text("Pulled Data successfully");
|
directoryProvider.searchedBusinesses!
|
||||||
snapshot.requireData!
|
.sort((a, b) => a.Name.compareTo(b.Name));
|
||||||
.sort((a, b) => a.username.compareTo(b.username));
|
return Column(
|
||||||
return Column(
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
"Businesses of Mzansi",
|
||||||
"People of Mzansi",
|
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
const SizedBox(height: 10),
|
BuildBusinessSearchResultsList(
|
||||||
BuildUserSearchResultsList(userList: snapshot.requireData!),
|
businessList: directoryProvider.searchedBusinesses!,
|
||||||
],
|
),
|
||||||
);
|
],
|
||||||
} else if (!snapshot.hasData) {
|
);
|
||||||
return Padding(
|
} else if (directoryProvider.searchedBusinesses!.isEmpty &&
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
directoryProvider.searchTerm.isNotEmpty) {
|
||||||
child: Column(
|
// return Text("Pulled Data successfully");
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
children: [
|
||||||
children: [
|
const SizedBox(height: 50),
|
||||||
const SizedBox(height: 50),
|
Icon(
|
||||||
Icon(
|
MihIcons.iDontKnow,
|
||||||
MihIcons.personalProfile,
|
size: 165,
|
||||||
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(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
children: [
|
||||||
Text(
|
TextSpan(text: "Press "),
|
||||||
"Search for people of Mzansi!",
|
WidgetSpan(
|
||||||
textAlign: TextAlign.center,
|
alignment: PlaceholderAlignment.middle,
|
||||||
overflow: TextOverflow.visible,
|
child: Icon(
|
||||||
style: TextStyle(
|
Icons.swap_horiz_rounded,
|
||||||
fontSize: 25,
|
size: 20,
|
||||||
fontWeight: FontWeight.bold,
|
color: MihColors.getSecondaryColor(
|
||||||
color: MihColors.getSecondaryColor(
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
"Dark"),
|
||||||
"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"),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
TextSpan(text: " to search for people of Mzansi"),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
);
|
|
||||||
// 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"),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
),
|
||||||
Text(
|
),
|
||||||
"Let's try refining your search",
|
const SizedBox(height: 10),
|
||||||
textAlign: TextAlign.center,
|
Center(
|
||||||
overflow: TextOverflow.visible,
|
child: RichText(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
text: TextSpan(
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 25,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.normal,
|
||||||
color: MihColors.getSecondaryColor(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
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 {
|
} else {
|
||||||
return FutureBuilder(
|
return Center(
|
||||||
future: futureBusinessSearchResults,
|
child: Text(
|
||||||
builder: (context, snapshot) {
|
"Error pulling Patients Data\n/users/search/${directoryProvider.searchTerm}",
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
style: TextStyle(
|
||||||
return const Mihloadingcircle();
|
fontSize: 25,
|
||||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
color: MihColors.getRedColor(
|
||||||
snapshot.hasData &&
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||||
snapshot.requireData!.isNotEmpty) {
|
textAlign: TextAlign.center,
|
||||||
// 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,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.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.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_button.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_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_pop_up_messages/mih_loading_circle.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.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: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 {
|
class MihAddBookmarkAlert extends StatefulWidget {
|
||||||
final Business business;
|
final Business business;
|
||||||
|
final void Function()? onSuccessDismissPressed;
|
||||||
const MihAddBookmarkAlert({
|
const MihAddBookmarkAlert({
|
||||||
super.key,
|
super.key,
|
||||||
required this.business,
|
required this.business,
|
||||||
|
required this.onSuccessDismissPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -23,16 +25,16 @@ class MihAddBookmarkAlert extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
|
class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
|
||||||
Future<void> addBookmark(String business_id) async {
|
Future<void> addBookmark(
|
||||||
|
MzansiProfileProvider profileProvider, String business_id) async {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return const Mihloadingcircle();
|
return const Mihloadingcircle();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
String user_id = await SuperTokens.getUserId();
|
|
||||||
await MihMzansiDirectoryServices()
|
await MihMzansiDirectoryServices()
|
||||||
.addBookmarkedBusiness(user_id, business_id)
|
.addBookmarkedBusiness(profileProvider.user!.app_id, business_id)
|
||||||
.then((statusCode) {
|
.then((statusCode) {
|
||||||
context.pop();
|
context.pop();
|
||||||
if (statusCode == 201) {
|
if (statusCode == 201) {
|
||||||
@@ -77,14 +79,9 @@ class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
|
|||||||
Center(
|
Center(
|
||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.goNamed(
|
widget.onSuccessDismissPressed!.call();
|
||||||
"mzansiDirectory",
|
context.pop();
|
||||||
extra: MzansiDirectoryArguments(
|
context.pop();
|
||||||
personalSearch: false,
|
|
||||||
startSearchText: widget.business.Name,
|
|
||||||
packageIndex: 1,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
buttonColor: MihColors.getGreenColor(
|
buttonColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
@@ -117,69 +114,76 @@ class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MihPackageAlert(
|
return Consumer<MzansiProfileProvider>(
|
||||||
alertColour: MihColors.getSecondaryColor(
|
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
Widget? child) {
|
||||||
alertIcon: Icon(
|
return MihPackageAlert(
|
||||||
Icons.warning_rounded,
|
alertColour: MihColors.getSecondaryColor(
|
||||||
size: 100,
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
color: MihColors.getSecondaryColor(
|
alertIcon: Icon(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
Icons.warning_rounded,
|
||||||
),
|
size: 100,
|
||||||
alertTitle: "Bookmark Business",
|
color: MihColors.getSecondaryColor(
|
||||||
alertBody: Column(
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25),
|
alertTitle: "Bookmark Business",
|
||||||
Wrap(
|
alertBody: Column(
|
||||||
spacing: 10,
|
|
||||||
runSpacing: 10,
|
|
||||||
children: [
|
children: [
|
||||||
MihButton(
|
Text(
|
||||||
width: 300,
|
"Are you sure you want to save ${widget.business.Name} to your Mzansi Directory?",
|
||||||
onPressed: () async {
|
style: TextStyle(
|
||||||
Navigator.of(context).pop();
|
color: MihColors.getSecondaryColor(
|
||||||
},
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
buttonColor: MihColors.getRedColor(
|
fontSize: 15,
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
MihButton(
|
const SizedBox(height: 25),
|
||||||
width: 300,
|
Wrap(
|
||||||
onPressed: () {
|
spacing: 10,
|
||||||
addBookmark(widget.business.business_id);
|
runSpacing: 10,
|
||||||
},
|
children: [
|
||||||
buttonColor: MihColors.getGreenColor(
|
MihButton(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
width: 300,
|
||||||
child: Text(
|
onPressed: () async {
|
||||||
"Bookmark Business",
|
Navigator.of(context).pop();
|
||||||
style: TextStyle(
|
},
|
||||||
color: MihColors.getPrimaryColor(
|
buttonColor: MihColors.getRedColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
fontSize: 20,
|
child: Text(
|
||||||
fontWeight: FontWeight.bold,
|
"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_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_icons.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_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_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_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_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_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:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:redacted/redacted.dart';
|
import 'package:redacted/redacted.dart';
|
||||||
import 'package:supertokens_flutter/supertokens.dart';
|
import 'package:supertokens_flutter/supertokens.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class MihBusinessCard extends StatefulWidget {
|
class MihBusinessCard extends StatefulWidget {
|
||||||
final Business business;
|
final Business business;
|
||||||
final String? startUpSearch;
|
|
||||||
final double width;
|
final double width;
|
||||||
const MihBusinessCard({
|
const MihBusinessCard({
|
||||||
super.key,
|
super.key,
|
||||||
required this.business,
|
required this.business,
|
||||||
required this.startUpSearch,
|
|
||||||
required this.width,
|
required this.width,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -409,274 +410,292 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// double screenWidth = MediaQuery.of(context).size.width;
|
// double screenWidth = MediaQuery.of(context).size.width;
|
||||||
return Material(
|
return Consumer<MzansiDirectoryProvider>(
|
||||||
color: MihColors.getSecondaryColor(
|
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
Widget? child) {
|
||||||
.withValues(alpha: 0.6),
|
return Material(
|
||||||
borderRadius: BorderRadius.circular(25),
|
|
||||||
elevation: 10,
|
|
||||||
shadowColor: Colors.black,
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: MihColors.getSecondaryColor(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||||
borderRadius: BorderRadius.circular(10),
|
.withValues(alpha: 0.6),
|
||||||
),
|
borderRadius: BorderRadius.circular(25),
|
||||||
child: Column(
|
elevation: 10,
|
||||||
children: [
|
shadowColor: Colors.black,
|
||||||
const SizedBox(height: 10),
|
child: Container(
|
||||||
_buildContactInfo(
|
decoration: BoxDecoration(
|
||||||
"Call",
|
color: MihColors.getSecondaryColor(
|
||||||
"Give us a quick call.",
|
|
||||||
Icons.phone,
|
|
||||||
MihColors.getGreenColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
false,
|
borderRadius: BorderRadius.circular(10),
|
||||||
() {
|
|
||||||
// print("Calling ${widget.cellNumber}");
|
|
||||||
_makePhoneCall(widget.business.contact_no);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
Divider(
|
child: Column(
|
||||||
color: MihColors.getPrimaryColor(
|
children: [
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
const SizedBox(height: 10),
|
||||||
),
|
_buildContactInfo(
|
||||||
_buildContactInfo(
|
"Call",
|
||||||
"Email",
|
"Give us a quick call.",
|
||||||
"Send us an email.",
|
Icons.phone,
|
||||||
Icons.email,
|
MihColors.getGreenColor(
|
||||||
MihColors.getPinkColor(
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
false,
|
||||||
false,
|
() {
|
||||||
() {
|
// print("Calling ${widget.cellNumber}");
|
||||||
// print("Emailing ${widget.email}");
|
_makePhoneCall(widget.business.contact_no);
|
||||||
_launchEmail(
|
},
|
||||||
widget.business.bus_email,
|
),
|
||||||
"Inquiery about ${widget.business.Name}",
|
Divider(
|
||||||
"Dear ${widget.business.Name},\n\nI would like to inquire about your services.\n\nBest regards,\n",
|
color: MihColors.getPrimaryColor(
|
||||||
);
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
},
|
),
|
||||||
),
|
_buildContactInfo(
|
||||||
Visibility(
|
"Email",
|
||||||
visible: isValidGps(widget.business.gps_location),
|
"Send us an email.",
|
||||||
child: Column(
|
Icons.email,
|
||||||
children: [
|
MihColors.getPinkColor(
|
||||||
Divider(
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
color: MihColors.getPrimaryColor(
|
false,
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
() {
|
||||||
|
// 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",
|
Visibility(
|
||||||
"Come visit us.",
|
visible: widget.business.website.isNotEmpty &&
|
||||||
Icons.location_on,
|
widget.business.website != "",
|
||||||
MihColors.getOrangeColor(
|
child: Column(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
children: [
|
||||||
false,
|
Divider(
|
||||||
() {
|
color: MihColors.getPrimaryColor(
|
||||||
final latitude = double.parse(
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
widget.business.gps_location.split(',')[0]);
|
"Dark"),
|
||||||
final longitude = double.parse(
|
),
|
||||||
widget.business.gps_location.split(',')[1]);
|
_buildContactInfo(
|
||||||
_launchGoogleMapsWithUrl(
|
"Website",
|
||||||
latitude: latitude,
|
"Find out more about us.",
|
||||||
longitude: longitude,
|
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(
|
Future<void> businessReviewRatingWindow(
|
||||||
BusinessReview? myReview, bool previouslyRated, double width) async {
|
MzansiDirectoryProvider directoryProvider,
|
||||||
|
BusinessReview? myReview,
|
||||||
|
bool previouslyRated,
|
||||||
|
double width) async {
|
||||||
if (_isUserSignedIn) {
|
if (_isUserSignedIn) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -685,6 +704,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
businessReview: myReview,
|
businessReview: myReview,
|
||||||
screenWidth: width,
|
screenWidth: width,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
|
onSuccessDismissPressed: () async {
|
||||||
|
List<Business>? businessSearchResults = [];
|
||||||
|
businessSearchResults = await MihBusinessDetailsServices()
|
||||||
|
.searchBusinesses(directoryProvider.searchTerm,
|
||||||
|
directoryProvider.businessTypeFilter, context);
|
||||||
|
directoryProvider.setSearchedBusinesses(
|
||||||
|
searchedBusinesses: businessSearchResults);
|
||||||
|
setState(() {
|
||||||
|
_businessReviewFuture = getUserReview();
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -698,6 +728,11 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (context) => MihAddBookmarkAlert(
|
builder: (context) => MihAddBookmarkAlert(
|
||||||
business: widget.business,
|
business: widget.business,
|
||||||
|
onSuccessDismissPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_bookmarkedBusinessFuture = getUserBookmark();
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -712,7 +747,12 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
builder: (context) => MihDeleteBookmarkAlert(
|
builder: (context) => MihDeleteBookmarkAlert(
|
||||||
business: widget.business,
|
business: widget.business,
|
||||||
bookmarkBusiness: bookmarkBusiness,
|
bookmarkBusiness: bookmarkBusiness,
|
||||||
startUpSearch: widget.startUpSearch,
|
onSuccessDismissPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_bookmarkedBusinessFuture = getUserBookmark();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// startUpSearch: widget.startUpSearch,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
showSignInRequiredAlert();
|
showSignInRequiredAlert();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.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/bookmarked_business.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/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';
|
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 {
|
class MihDeleteBookmarkAlert extends StatefulWidget {
|
||||||
final Business business;
|
final Business business;
|
||||||
final BookmarkedBusiness? bookmarkBusiness;
|
final BookmarkedBusiness? bookmarkBusiness;
|
||||||
final String? startUpSearch;
|
final void Function()? onSuccessDismissPressed;
|
||||||
|
// final String? startUpSearch;
|
||||||
const MihDeleteBookmarkAlert({
|
const MihDeleteBookmarkAlert({
|
||||||
super.key,
|
super.key,
|
||||||
required this.business,
|
required this.business,
|
||||||
required this.bookmarkBusiness,
|
required this.bookmarkBusiness,
|
||||||
required this.startUpSearch,
|
required this.onSuccessDismissPressed,
|
||||||
|
// required this.startUpSearch,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -80,14 +81,17 @@ class _MihDeleteBookmarkAlertState extends State<MihDeleteBookmarkAlert> {
|
|||||||
Center(
|
Center(
|
||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.goNamed(
|
// context.goNamed(
|
||||||
"mzansiDirectory",
|
// "mzansiDirectory",
|
||||||
extra: MzansiDirectoryArguments(
|
// extra: MzansiDirectoryArguments(
|
||||||
personalSearch: false,
|
// personalSearch: false,
|
||||||
startSearchText: widget.business.Name,
|
// startSearchText: widget.business.Name,
|
||||||
packageIndex: 1,
|
// packageIndex: 1,
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
|
widget.onSuccessDismissPressed!.call();
|
||||||
|
context.pop();
|
||||||
|
context.pop();
|
||||||
},
|
},
|
||||||
buttonColor: MihColors.getGreenColor(
|
buttonColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
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:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.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.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_review.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';
|
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_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_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_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_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.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_mzansi_directory_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_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 {
|
class MihReviewBusinessWindow extends StatefulWidget {
|
||||||
final Business business;
|
final Business business;
|
||||||
final BusinessReview? businessReview;
|
final BusinessReview? businessReview;
|
||||||
final double screenWidth;
|
final double screenWidth;
|
||||||
final bool readOnly;
|
final bool readOnly;
|
||||||
|
final void Function()? onSuccessDismissPressed;
|
||||||
const MihReviewBusinessWindow({
|
const MihReviewBusinessWindow({
|
||||||
super.key,
|
super.key,
|
||||||
required this.business,
|
required this.business,
|
||||||
required this.businessReview,
|
required this.businessReview,
|
||||||
required this.screenWidth,
|
required this.screenWidth,
|
||||||
required this.readOnly,
|
required this.readOnly,
|
||||||
|
required this.onSuccessDismissPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -47,9 +51,8 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
|||||||
TextEditingController();
|
TextEditingController();
|
||||||
late final VoidCallback _reviewDescriptionListener;
|
late final VoidCallback _reviewDescriptionListener;
|
||||||
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
|
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
|
||||||
String userId = "";
|
|
||||||
|
|
||||||
void showDeleteReviewAlert() {
|
void showDeleteReviewAlert(MzansiDirectoryProvider directoryProvider) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => MihPackageAlert(
|
builder: (context) => MihPackageAlert(
|
||||||
@@ -93,10 +96,11 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
|||||||
widget.businessReview!.rating_score,
|
widget.businessReview!.rating_score,
|
||||||
widget.business.rating,
|
widget.business.rating,
|
||||||
)
|
)
|
||||||
.then((statusCode) {
|
.then((statusCode) async {
|
||||||
context.pop(); //Remove loading dialog
|
context.pop(); //Remove loading dialog
|
||||||
context.pop(); //Remove delete dialog
|
context.pop(); //Remove delete dialog
|
||||||
if (statusCode == 200) {
|
if (statusCode == 200) {
|
||||||
|
await refreshBusiness(directoryProvider);
|
||||||
context.pop(); //Remove window
|
context.pop(); //Remove window
|
||||||
successPopUp(
|
successPopUp(
|
||||||
"Successfully Deleted Review!",
|
"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(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@@ -178,9 +194,10 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
|||||||
widget.businessReview!.rating_score,
|
widget.businessReview!.rating_score,
|
||||||
widget.business.rating,
|
widget.business.rating,
|
||||||
)
|
)
|
||||||
.then((statusCode) {
|
.then((statusCode) async {
|
||||||
context.pop(); //Remove loading dialog
|
context.pop(); //Remove loading dialog
|
||||||
if (statusCode == 200) {
|
if (statusCode == 200) {
|
||||||
|
await refreshBusiness(directoryProvider);
|
||||||
context.pop();
|
context.pop();
|
||||||
successPopUp(
|
successPopUp(
|
||||||
"Successfully Updated Review!",
|
"Successfully Updated Review!",
|
||||||
@@ -197,16 +214,17 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
|||||||
} else {
|
} else {
|
||||||
await MihMzansiDirectoryServices()
|
await MihMzansiDirectoryServices()
|
||||||
.addBusinessReview(
|
.addBusinessReview(
|
||||||
userId,
|
profileProvider.user!.app_id,
|
||||||
widget.business.business_id,
|
widget.business.business_id,
|
||||||
_reviewTitleController.text,
|
_reviewTitleController.text,
|
||||||
_reviewDescriptionController.text,
|
_reviewDescriptionController.text,
|
||||||
_reviewScoreController.text,
|
_reviewScoreController.text,
|
||||||
widget.business.rating.isEmpty ? "0.0" : widget.business.rating,
|
widget.business.rating.isEmpty ? "0.0" : widget.business.rating,
|
||||||
)
|
)
|
||||||
.then((statusCode) {
|
.then((statusCode) async {
|
||||||
context.pop(); //Remove loading dialog
|
context.pop(); //Remove loading dialog
|
||||||
if (statusCode == 201) {
|
if (statusCode == 201) {
|
||||||
|
await refreshBusiness(directoryProvider);
|
||||||
context.pop();
|
context.pop();
|
||||||
successPopUp(
|
successPopUp(
|
||||||
"Successfully Added Review!",
|
"Successfully Added Review!",
|
||||||
@@ -250,13 +268,15 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
|||||||
Center(
|
Center(
|
||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.goNamed(
|
// context.goNamed(
|
||||||
"mzansiDirectory",
|
// "mzansiDirectory",
|
||||||
extra: MzansiDirectoryArguments(
|
// extra: MzansiDirectoryArguments(
|
||||||
personalSearch: false,
|
// personalSearch: false,
|
||||||
startSearchText: widget.business.Name,
|
// startSearchText: widget.business.Name,
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
|
widget.onSuccessDismissPressed!.call();
|
||||||
|
context.pop();
|
||||||
},
|
},
|
||||||
buttonColor: MihColors.getGreenColor(
|
buttonColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
@@ -323,265 +343,277 @@ class _MihReviewBusinessWindowState extends State<MihReviewBusinessWindow> {
|
|||||||
} else {
|
} else {
|
||||||
_reviewScoreController.text = "1.0"; // Default score
|
_reviewScoreController.text = "1.0"; // Default score
|
||||||
}
|
}
|
||||||
SuperTokens.getUserId().then((value) {
|
|
||||||
setState(() {
|
|
||||||
userId = value;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// return const Placeholder();
|
// return const Placeholder();
|
||||||
return MihPackageWindow(
|
return Consumer2<MzansiProfileProvider, MzansiDirectoryProvider>(
|
||||||
fullscreen: false,
|
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||||
windowTitle: getWindowTitle(),
|
MzansiDirectoryProvider directoryProvider, Widget? child) {
|
||||||
onWindowTapClose: () {
|
return MihPackageWindow(
|
||||||
Navigator.of(context).pop();
|
fullscreen: false,
|
||||||
},
|
windowTitle: getWindowTitle(),
|
||||||
menuOptions: widget.businessReview != null && !widget.readOnly
|
onWindowTapClose: () {
|
||||||
? [
|
Navigator.of(context).pop();
|
||||||
SpeedDialChild(
|
},
|
||||||
child: Icon(
|
menuOptions: widget.businessReview != null && !widget.readOnly
|
||||||
Icons.delete,
|
? [
|
||||||
color: MihColors.getPrimaryColor(
|
SpeedDialChild(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
child: Icon(
|
||||||
),
|
Icons.delete,
|
||||||
label: "Delete Review",
|
color: MihColors.getPrimaryColor(
|
||||||
labelBackgroundColor: MihColors.getGreenColor(
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
"Dark"),
|
||||||
labelStyle: TextStyle(
|
),
|
||||||
color: MihColors.getPrimaryColor(
|
label: "Delete Review",
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
labelBackgroundColor: MihColors.getGreenColor(
|
||||||
fontWeight: FontWeight.bold,
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
),
|
labelStyle: TextStyle(
|
||||||
backgroundColor: MihColors.getGreenColor(
|
color: MihColors.getPrimaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
onTap: () {
|
"Dark"),
|
||||||
showDeleteReviewAlert();
|
fontWeight: FontWeight.bold,
|
||||||
},
|
),
|
||||||
),
|
backgroundColor: MihColors.getGreenColor(
|
||||||
]
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
: null,
|
onTap: () {
|
||||||
windowBody: MihSingleChildScroll(
|
showDeleteReviewAlert(directoryProvider);
|
||||||
child: Padding(
|
},
|
||||||
padding:
|
),
|
||||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
]
|
||||||
|
: 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.05)
|
||||||
: EdgeInsets.symmetric(horizontal: widget.screenWidth * 0),
|
: EdgeInsets.symmetric(horizontal: widget.screenWidth * 0),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
MihForm(
|
MihForm(
|
||||||
formKey: _formKey,
|
formKey: _formKey,
|
||||||
formFields: [
|
formFields: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Business Rating",
|
"Business Rating",
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: MihColors.getSecondaryColor(
|
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 ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark"),
|
"Dark"),
|
||||||
fontSize: 18,
|
inputColor: MihColors.getPrimaryColor(
|
||||||
fontWeight: FontWeight.bold,
|
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!),
|
business: context.watch<MzansiProfileProvider>().business!),
|
||||||
MihBusinessQrCode(
|
MihBusinessQrCode(
|
||||||
business: context.watch<MzansiProfileProvider>().business!,
|
business: context.watch<MzansiProfileProvider>().business!,
|
||||||
startUpSearch: "",
|
// startUpSearch: "",
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
return toolBodies;
|
return toolBodies;
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:ken_logger/ken_logger.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.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_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
import 'package:flutter/material.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_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_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_qr_code.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_reviews.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_reviews.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_business_details_services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class MzansiBusinessProfileView extends StatefulWidget {
|
class MzansiBusinessProfileView extends StatefulWidget {
|
||||||
final BusinessViewArguments? arguments;
|
|
||||||
final String? businessId;
|
final String? businessId;
|
||||||
const MzansiBusinessProfileView({
|
const MzansiBusinessProfileView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.arguments,
|
|
||||||
required this.businessId,
|
required this.businessId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -28,16 +27,10 @@ class MzansiBusinessProfileView extends StatefulWidget {
|
|||||||
|
|
||||||
class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||||
int _selcetedIndex = 0;
|
int _selcetedIndex = 0;
|
||||||
Business? business;
|
|
||||||
String startUpSearch = "";
|
|
||||||
|
|
||||||
Future<void> _fetchBusinessDetails() async {
|
Future<void> _fetchBusinessDetails(
|
||||||
if (widget.arguments != null) {
|
MzansiDirectoryProvider directoryProvider) async {
|
||||||
setState(() {
|
if (widget.businessId != null) {
|
||||||
business = widget.arguments!.business;
|
|
||||||
startUpSearch = widget.arguments!.startUpSearch ?? "";
|
|
||||||
});
|
|
||||||
} else if (widget.businessId != null) {
|
|
||||||
final biz = await MihBusinessDetailsServices()
|
final biz = await MihBusinessDetailsServices()
|
||||||
.getBusinessDetailsByBusinessId(widget.businessId!);
|
.getBusinessDetailsByBusinessId(widget.businessId!);
|
||||||
if (biz == null) {
|
if (biz == null) {
|
||||||
@@ -47,10 +40,7 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
KenLogger.success("Business found: ${biz.Name}");
|
KenLogger.success("Business found: ${biz.Name}");
|
||||||
setState(() {
|
directoryProvider.setSelectedBusiness(business: biz);
|
||||||
business = biz;
|
|
||||||
startUpSearch = "";
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,32 +48,39 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_fetchBusinessDetails();
|
MzansiDirectoryProvider directoryProvider =
|
||||||
|
context.read<MzansiDirectoryProvider>();
|
||||||
|
_fetchBusinessDetails(directoryProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (business == null) {
|
return Consumer<MzansiDirectoryProvider>(
|
||||||
KenLogger.warning("Business is null, showing loading indicator");
|
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||||
return Scaffold(
|
Widget? child) {
|
||||||
body: const Center(
|
if (directoryProvider.selectedBusiness == null) {
|
||||||
child: Mihloadingcircle(),
|
KenLogger.warning("Business is null, showing loading indicator");
|
||||||
),
|
return Scaffold(
|
||||||
);
|
body: const Center(
|
||||||
} else {
|
child: Mihloadingcircle(),
|
||||||
return MihPackage(
|
),
|
||||||
appActionButton: getAction(),
|
);
|
||||||
appTools: getTools(),
|
} else {
|
||||||
appBody: getToolBody(),
|
return MihPackage(
|
||||||
appToolTitles: getToolTitle(),
|
appActionButton: getAction(),
|
||||||
selectedbodyIndex: _selcetedIndex,
|
appTools: getTools(),
|
||||||
onIndexChange: (newValue) {
|
appBody: getToolBody(directoryProvider),
|
||||||
setState(() {
|
appToolTitles: getToolTitle(),
|
||||||
_selcetedIndex = newValue;
|
selectedbodyIndex: _selcetedIndex,
|
||||||
});
|
onIndexChange: (newValue) {
|
||||||
},
|
setState(() {
|
||||||
);
|
_selcetedIndex = newValue;
|
||||||
}
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MihPackageAction getAction() {
|
MihPackageAction getAction() {
|
||||||
@@ -91,13 +88,18 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
|||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
iconSize: 35,
|
iconSize: 35,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
MzansiProfileProvider profileProvider =
|
||||||
"mzansiDirectory",
|
context.read<MzansiProfileProvider>();
|
||||||
extra: MzansiDirectoryArguments(
|
if (profileProvider.user == null) {
|
||||||
personalSearch: false,
|
context.goNamed(
|
||||||
startSearchText: business!.Name,
|
'mihHome',
|
||||||
),
|
);
|
||||||
);
|
} else {
|
||||||
|
context.pop();
|
||||||
|
}
|
||||||
|
// context.goNamed(
|
||||||
|
// "mzansiDirectory",
|
||||||
|
// );
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -126,16 +128,12 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getToolBody() {
|
List<Widget> getToolBody(MzansiDirectoryProvider directoryProvider) {
|
||||||
List<Widget> toolBodies = [
|
List<Widget> toolBodies = [
|
||||||
MihBusinessDetailsView(
|
MihBusinessDetailsView(),
|
||||||
business: business!,
|
MihBusinessReviews(business: directoryProvider.selectedBusiness!),
|
||||||
startUpSearch: startUpSearch,
|
|
||||||
),
|
|
||||||
MihBusinessReviews(business: business!),
|
|
||||||
MihBusinessQrCode(
|
MihBusinessQrCode(
|
||||||
business: business!,
|
business: directoryProvider.selectedBusiness!,
|
||||||
startUpSearch: startUpSearch,
|
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
return toolBodies;
|
return toolBodies;
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class _MihBusinessDetailsState extends State<MihBusinessDetails> {
|
|||||||
width: 700,
|
width: 700,
|
||||||
child: MihBusinessCard(
|
child: MihBusinessCard(
|
||||||
business: mzansiProfileProvider.business!,
|
business: mzansiProfileProvider.business!,
|
||||||
startUpSearch: null,
|
// startUpSearch: null,
|
||||||
width: width,
|
width: width,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2,22 +2,19 @@ import 'package:custom_rating_bar/custom_rating_bar.dart';
|
|||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_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_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_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_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_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_package_tool_body.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_circle_avatar.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class MihBusinessDetailsView extends StatefulWidget {
|
class MihBusinessDetailsView extends StatefulWidget {
|
||||||
final Business business;
|
|
||||||
final String? startUpSearch;
|
|
||||||
const MihBusinessDetailsView({
|
const MihBusinessDetailsView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.business,
|
|
||||||
required this.startUpSearch,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -36,8 +33,10 @@ class _MihBusinessDetailsViewState extends State<MihBusinessDetailsView> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
futureImageUrl =
|
MzansiDirectoryProvider directoryProvider =
|
||||||
MihFileApi.getMinioFileUrl(widget.business.logo_path, context);
|
context.read<MzansiDirectoryProvider>();
|
||||||
|
futureImageUrl = MihFileApi.getMinioFileUrl(
|
||||||
|
directoryProvider.selectedBusiness!.logo_path, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -52,173 +51,182 @@ class _MihBusinessDetailsViewState extends State<MihBusinessDetailsView> {
|
|||||||
|
|
||||||
Widget getBody(double width, BuildContext context) {
|
Widget getBody(double width, BuildContext context) {
|
||||||
double profilePictureWidth = 150;
|
double profilePictureWidth = 150;
|
||||||
return Stack(
|
return Consumer<MzansiDirectoryProvider>(
|
||||||
children: [
|
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||||
MihSingleChildScroll(
|
Widget? child) {
|
||||||
child: Padding(
|
return Stack(
|
||||||
padding:
|
children: [
|
||||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
MihSingleChildScroll(
|
||||||
|
child: Padding(
|
||||||
|
padding: MzansiInnovationHub.of(context)!.theme.screenType ==
|
||||||
|
"desktop"
|
||||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: futureImageUrl,
|
future: futureImageUrl,
|
||||||
builder: (context, asyncSnapshot) {
|
builder: (context, asyncSnapshot) {
|
||||||
if (asyncSnapshot.connectionState ==
|
if (asyncSnapshot.connectionState ==
|
||||||
ConnectionState.done &&
|
ConnectionState.done &&
|
||||||
asyncSnapshot.hasData) {
|
asyncSnapshot.hasData) {
|
||||||
if (asyncSnapshot.requireData != "") {
|
if (asyncSnapshot.requireData != "") {
|
||||||
return MihCircleAvatar(
|
return MihCircleAvatar(
|
||||||
imageFile: NetworkImage(asyncSnapshot.requireData),
|
imageFile:
|
||||||
width: profilePictureWidth,
|
NetworkImage(asyncSnapshot.requireData),
|
||||||
editable: false,
|
width: profilePictureWidth,
|
||||||
fileNameController: TextEditingController(),
|
editable: false,
|
||||||
userSelectedfile: file,
|
fileNameController: TextEditingController(),
|
||||||
frameColor: MihColors.getSecondaryColor(
|
userSelectedfile: file,
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
frameColor: MihColors.getSecondaryColor(
|
||||||
"Dark"),
|
MzansiInnovationHub.of(context)!
|
||||||
backgroundColor: MihColors.getPrimaryColor(
|
.theme
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
.mode ==
|
||||||
"Dark"),
|
"Dark"),
|
||||||
onChange: () {},
|
backgroundColor: MihColors.getPrimaryColor(
|
||||||
);
|
MzansiInnovationHub.of(context)!
|
||||||
} else {
|
.theme
|
||||||
return Icon(
|
.mode ==
|
||||||
MihIcons.iDontKnow,
|
"Dark"),
|
||||||
size: profilePictureWidth,
|
onChange: () {},
|
||||||
color: MihColors.getSecondaryColor(
|
);
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
} else {
|
||||||
"Dark"),
|
return Icon(
|
||||||
);
|
MihIcons.iDontKnow,
|
||||||
}
|
size: profilePictureWidth,
|
||||||
} else {
|
color: MihColors.getSecondaryColor(
|
||||||
return Icon(
|
MzansiInnovationHub.of(context)!
|
||||||
MihIcons.mihRing,
|
.theme
|
||||||
size: profilePictureWidth,
|
.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(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark"),
|
"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 {
|
class MihBusinessQrCode extends StatefulWidget {
|
||||||
final Business business;
|
final Business business;
|
||||||
final String? startUpSearch;
|
// final String? startUpSearch;
|
||||||
const MihBusinessQrCode({
|
const MihBusinessQrCode({
|
||||||
super.key,
|
super.key,
|
||||||
required this.business,
|
required this.business,
|
||||||
required this.startUpSearch,
|
// required this.startUpSearch,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
|||||||
businessReview: businessReview,
|
businessReview: businessReview,
|
||||||
screenWidth: width,
|
screenWidth: width,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
onSuccessDismissPressed: () {},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import 'package:go_router/go_router.dart';
|
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.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_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.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';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class MzansiProfileView extends StatefulWidget {
|
class MzansiProfileView extends StatefulWidget {
|
||||||
final AppUser user;
|
|
||||||
const MzansiProfileView({
|
const MzansiProfileView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.user,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -42,13 +38,7 @@ class _MzansiProfileViewState extends State<MzansiProfileView> {
|
|||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
iconSize: 35,
|
iconSize: 35,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.pop();
|
||||||
"mzansiDirectory",
|
|
||||||
extra: MzansiDirectoryArguments(
|
|
||||||
personalSearch: true,
|
|
||||||
startSearchText: widget.user.username,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -69,9 +59,9 @@ class _MzansiProfileViewState extends State<MzansiProfileView> {
|
|||||||
|
|
||||||
List<Widget> getToolBody() {
|
List<Widget> getToolBody() {
|
||||||
List<Widget> toolBodies = [];
|
List<Widget> toolBodies = [];
|
||||||
toolBodies.add(MihPersonalProfileView(
|
toolBodies.add(
|
||||||
user: widget.user,
|
MihPersonalProfileView(),
|
||||||
));
|
);
|
||||||
return toolBodies;
|
return toolBodies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:mzansi_innovation_hub/main.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_icons.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_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.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_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:mzansi_innovation_hub/mih_components/mih_package_components/mih_circle_avatar.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class MihPersonalProfileView extends StatefulWidget {
|
class MihPersonalProfileView extends StatefulWidget {
|
||||||
final AppUser user;
|
|
||||||
const MihPersonalProfileView({
|
const MihPersonalProfileView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.user,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -32,8 +31,10 @@ class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
futureImageUrl =
|
MzansiDirectoryProvider directoryProvider =
|
||||||
MihFileApi.getMinioFileUrl(widget.user.pro_pic_path, context);
|
context.read<MzansiDirectoryProvider>();
|
||||||
|
futureImageUrl = MihFileApi.getMinioFileUrl(
|
||||||
|
directoryProvider.selectedUser!.pro_pic_path, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -48,152 +49,123 @@ class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
|
|||||||
|
|
||||||
Widget getBody(double width) {
|
Widget getBody(double width) {
|
||||||
double profilePictureWidth = 150;
|
double profilePictureWidth = 150;
|
||||||
return MihSingleChildScroll(
|
return Consumer<MzansiDirectoryProvider>(
|
||||||
child: Padding(
|
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||||
padding: MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
Widget? child) {
|
||||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
return MihSingleChildScroll(
|
||||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
child: Padding(
|
||||||
child: Column(
|
padding:
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||||
children: [
|
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||||
FutureBuilder(
|
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||||
future: futureImageUrl,
|
child: Column(
|
||||||
builder: (context, asyncSnapshot) {
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
if (asyncSnapshot.connectionState == ConnectionState.done &&
|
children: [
|
||||||
asyncSnapshot.hasData) {
|
FutureBuilder(
|
||||||
if (asyncSnapshot.requireData != "") {
|
future: futureImageUrl,
|
||||||
return MihCircleAvatar(
|
builder: (context, asyncSnapshot) {
|
||||||
imageFile: NetworkImage(asyncSnapshot.requireData),
|
if (asyncSnapshot.connectionState ==
|
||||||
width: profilePictureWidth,
|
ConnectionState.done &&
|
||||||
editable: false,
|
asyncSnapshot.hasData) {
|
||||||
fileNameController: TextEditingController(),
|
if (asyncSnapshot.requireData != "") {
|
||||||
userSelectedfile: file,
|
return MihCircleAvatar(
|
||||||
frameColor: MihColors.getSecondaryColor(
|
imageFile: NetworkImage(asyncSnapshot.requireData),
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
width: profilePictureWidth,
|
||||||
"Dark"),
|
editable: false,
|
||||||
backgroundColor: MihColors.getPrimaryColor(
|
fileNameController: TextEditingController(),
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
userSelectedfile: file,
|
||||||
"Dark"),
|
frameColor: MihColors.getSecondaryColor(
|
||||||
onChange: () {},
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
);
|
"Dark"),
|
||||||
} else {
|
backgroundColor: MihColors.getPrimaryColor(
|
||||||
return Icon(
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
MihIcons.iDontKnow,
|
"Dark"),
|
||||||
size: profilePictureWidth,
|
onChange: () {},
|
||||||
color: MihColors.getSecondaryColor(
|
);
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
} else {
|
||||||
"Dark"),
|
return Icon(
|
||||||
);
|
MihIcons.iDontKnow,
|
||||||
}
|
size: profilePictureWidth,
|
||||||
} else {
|
color: MihColors.getSecondaryColor(
|
||||||
return Icon(
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
MihIcons.mihRing,
|
"Dark"),
|
||||||
size: profilePictureWidth,
|
);
|
||||||
|
}
|
||||||
|
} 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(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark"),
|
"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 'dart:convert';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/bookmarked_business.dart';
|
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_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:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
|
|
||||||
@@ -156,14 +157,17 @@ class MihMzansiDirectoryServices {
|
|||||||
|
|
||||||
Future<List<BookmarkedBusiness>> getAllUserBookmarkedBusiness(
|
Future<List<BookmarkedBusiness>> getAllUserBookmarkedBusiness(
|
||||||
String app_id,
|
String app_id,
|
||||||
|
MzansiDirectoryProvider directoryProvider,
|
||||||
) async {
|
) async {
|
||||||
final response = await http.get(Uri.parse(
|
final response = await http.get(Uri.parse(
|
||||||
"${AppEnviroment.baseApiUrl}/mzansi-directory/bookmarked-business/user/all/$app_id/"));
|
"${AppEnviroment.baseApiUrl}/mzansi-directory/bookmarked-business/user/all/$app_id/"));
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Iterable l = jsonDecode(response.body);
|
Iterable l = jsonDecode(response.body);
|
||||||
List<BookmarkedBusiness> businessReviews = List<BookmarkedBusiness>.from(
|
List<BookmarkedBusiness> favouriteBusinesses =
|
||||||
l.map((model) => BookmarkedBusiness.fromJson(model)));
|
List<BookmarkedBusiness>.from(
|
||||||
return businessReviews;
|
l.map((model) => BookmarkedBusiness.fromJson(model)));
|
||||||
|
directoryProvider.setFavouriteBusinesses(businesses: favouriteBusinesses);
|
||||||
|
return favouriteBusinesses;
|
||||||
} else if (response.statusCode == 404) {
|
} else if (response.statusCode == 404) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user