BUG: fav bus view fix
This commit is contained in:
@@ -27,8 +27,6 @@ class _BuildFavouriteBusinessesListState
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.favouriteBusinesses.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
|
||||
@@ -81,7 +81,55 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
businessesImages: favBusImages,
|
||||
);
|
||||
}
|
||||
// // --- REVISED FUNCTION FOR PARALLEL FETCHING ---
|
||||
// Future<void> getFavouriteBusinesses() async {
|
||||
// MzansiDirectoryProvider directoryProvider =
|
||||
// context.read<MzansiDirectoryProvider>();
|
||||
// MzansiProfileProvider profileProvider =
|
||||
// context.read<MzansiProfileProvider>();
|
||||
// // 1. Fetch the list of bookmarked business IDs
|
||||
// await MihMzansiDirectoryServices().getAllUserBookmarkedBusiness(
|
||||
// profileProvider.user!.app_id,
|
||||
// directoryProvider,
|
||||
// );
|
||||
// // 2. Map bookmarked businesses to a list of Futures
|
||||
// // Each Future will fetch the business details AND the logo URL concurrently
|
||||
// final List<Future<(Business?, String?)>> detailAndUrlFutures =
|
||||
// directoryProvider.bookmarkedBusinesses.map((bookmarkedBus) {
|
||||
// return MihBusinessDetailsServices()
|
||||
// .getBusinessDetailsByBusinessId(bookmarkedBus.business_id)
|
||||
// .then((business) async {
|
||||
// if (business == null) return (null, null);
|
||||
// // Fetch logo URL for this business concurrently
|
||||
// String businessLogoUrl =
|
||||
// await MihFileApi.getMinioFileUrl(business.logo_path);
|
||||
// return (business, businessLogoUrl);
|
||||
// });
|
||||
// }).toList();
|
||||
// // 3. Wait for ALL futures to complete in parallel
|
||||
// List<(Business?, String?)> results = await Future.wait(detailAndUrlFutures);
|
||||
// // 4. Process the results
|
||||
// List<Business> favBus = [];
|
||||
// Map<String, ImageProvider<Object>?> favBusImages = {};
|
||||
// for (var result in results) {
|
||||
// final business = result.$1;
|
||||
// final businessLogoUrl = result.$2;
|
||||
// if (business != null) {
|
||||
// favBus.add(business);
|
||||
// favBusImages[business.business_id] =
|
||||
// (businessLogoUrl != null && businessLogoUrl.isNotEmpty)
|
||||
// ? NetworkImage(businessLogoUrl)
|
||||
// : null;
|
||||
// }
|
||||
// }
|
||||
// // 5. Update the provider once with all the data
|
||||
// directoryProvider.setFavouriteBusinesses(
|
||||
// businesses: favBus,
|
||||
// businessesImages: favBusImages,
|
||||
// );
|
||||
// }
|
||||
|
||||
// // ---------------------------------------------
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:mzansi_innovation_hub/mih_objects/business.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_search_bar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_directory_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
@@ -89,25 +88,25 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
}
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: MihSearchBar(
|
||||
controller: businessSearchController,
|
||||
hintText: "Search Businesses",
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {},
|
||||
searchFocusNode: searchFocusNode,
|
||||
),
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: MihSearchBar(
|
||||
controller: businessSearchController,
|
||||
hintText: "Search Businesses",
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {},
|
||||
searchFocusNode: searchFocusNode,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ValueListenableBuilder<List<Business?>>(
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
child: ValueListenableBuilder<List<Business?>>(
|
||||
valueListenable: searchBookmarkedBusinesses,
|
||||
builder: (context, filteredBusinesses, child) {
|
||||
if (filteredBusinesses.isEmpty &&
|
||||
@@ -200,8 +199,8 @@ class _MihFavouriteBusinessesState extends State<MihFavouriteBusinesses> {
|
||||
favouriteBusinesses: filteredBusinesses,
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user