BUG: fav bus view fix performace pt 2
This commit is contained in:
@@ -27,8 +27,8 @@ class _BuildBusinessSearchResultsListState
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
// shrinkWrap: true,
|
||||
// physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.businessList.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
|
||||
@@ -27,8 +27,8 @@ class _BuildUserSearchResultsListState
|
||||
builder: (BuildContext context, MzansiDirectoryProvider directoryProvider,
|
||||
Widget? child) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
// shrinkWrap: true,
|
||||
// physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: widget.userList.length,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -30,6 +31,8 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
bool _isLoadingInitialData = true;
|
||||
late Future<Position?> futurePosition =
|
||||
MIHLocationAPI().getGPSPosition(context);
|
||||
late final MihSearchMzansi _searchTool;
|
||||
late final MihFavouriteBusinesses _favouritesTool;
|
||||
|
||||
Future<void> _loadInitialData() async {
|
||||
setState(() {
|
||||
@@ -72,8 +75,9 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
.then((business) async {
|
||||
favBus.add(business!);
|
||||
businessLogoUrl = await MihFileApi.getMinioFileUrl(business.logo_path);
|
||||
favBusImages[business.business_id] =
|
||||
businessLogoUrl != "" ? NetworkImage(businessLogoUrl) : null;
|
||||
favBusImages[business.business_id] = businessLogoUrl != ""
|
||||
? CachedNetworkImageProvider(businessLogoUrl)
|
||||
: null;
|
||||
});
|
||||
}
|
||||
directoryProvider.setFavouriteBusinesses(
|
||||
@@ -133,6 +137,8 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_searchTool = const MihSearchMzansi();
|
||||
_favouritesTool = const MihFavouriteBusinesses();
|
||||
_loadInitialData();
|
||||
}
|
||||
|
||||
@@ -163,12 +169,10 @@ class _MzansiDirectoryState extends State<MzansiDirectory> {
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [];
|
||||
toolBodies.addAll([
|
||||
MihSearchMzansi(),
|
||||
MihFavouriteBusinesses(),
|
||||
]);
|
||||
return toolBodies;
|
||||
return [
|
||||
_searchTool,
|
||||
_favouritesTool,
|
||||
];
|
||||
}
|
||||
|
||||
MihPackageAction getAction() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
@@ -86,8 +87,9 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
KenLogger.success("Business Logo Path: ${user.pro_pic_path}");
|
||||
usernProPicUrl = await MihFileApi.getMinioFileUrl(user.pro_pic_path);
|
||||
KenLogger.success("Business Logo Path: ${user.pro_pic_path}");
|
||||
userImages[user.app_id] =
|
||||
usernProPicUrl != "" ? NetworkImage(usernProPicUrl) : null;
|
||||
userImages[user.app_id] = usernProPicUrl != ""
|
||||
? CachedNetworkImageProvider(usernProPicUrl)
|
||||
: null;
|
||||
}
|
||||
|
||||
directoryProvider.setSearchedUsers(
|
||||
@@ -111,8 +113,9 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
KenLogger.success("Business Logo Path: ${bus.logo_path}");
|
||||
businessLogoUrl = await MihFileApi.getMinioFileUrl(bus.logo_path);
|
||||
KenLogger.success("Business Logo Path: ${bus.logo_path}");
|
||||
busImages[bus.business_id] =
|
||||
businessLogoUrl != "" ? NetworkImage(businessLogoUrl) : null;
|
||||
busImages[bus.business_id] = businessLogoUrl != ""
|
||||
? CachedNetworkImageProvider(businessLogoUrl)
|
||||
: null;
|
||||
}
|
||||
directoryProvider.setSearchedBusinesses(
|
||||
searchedBusinesses: businessSearchResults,
|
||||
@@ -158,9 +161,15 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
return Consumer2<MzansiProfileProvider, MzansiDirectoryProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
MzansiDirectoryProvider directoryProvider, Widget? child) {
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
directoryProvider.personalSearch
|
||||
? "People Search"
|
||||
: "Businesses Search",
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: Row(
|
||||
@@ -295,9 +304,12 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
);
|
||||
}),
|
||||
const SizedBox(height: 10),
|
||||
displaySearchResults(directoryProvider),
|
||||
],
|
||||
Expanded(
|
||||
child: directoryProvider.personalSearch
|
||||
? displayPersonalSearchResults(directoryProvider)
|
||||
: displayBusinessSearchResults(directoryProvider),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -313,22 +325,13 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
// return Text("Pulled Data successfully");
|
||||
directoryProvider.searchedBusinesses!
|
||||
.sort((a, b) => a.Name.compareTo(b.Name));
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
"Businesses of Mzansi",
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BuildBusinessSearchResultsList(
|
||||
return BuildBusinessSearchResultsList(
|
||||
businessList: directoryProvider.searchedBusinesses!,
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (directoryProvider.searchedBusinesses!.isEmpty &&
|
||||
directoryProvider.searchTerm.isNotEmpty) {
|
||||
// return Text("Pulled Data successfully");
|
||||
return Column(
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
@@ -350,10 +353,12 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else if (directoryProvider.searchedBusinesses!.isEmpty &&
|
||||
directoryProvider.searchTerm.isEmpty) {
|
||||
return Padding(
|
||||
return MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -387,7 +392,8 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
@@ -415,7 +421,8 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
@@ -436,6 +443,7 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
@@ -458,23 +466,14 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
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!),
|
||||
],
|
||||
);
|
||||
return BuildUserSearchResultsList(
|
||||
userList: directoryProvider.searchedUsers!);
|
||||
} else if (directoryProvider.searchedUsers!.isEmpty &&
|
||||
directoryProvider.searchTerm.isEmpty) {
|
||||
return Padding(
|
||||
return MihSingleChildScroll(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -508,7 +507,8 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
@@ -529,10 +529,12 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (directoryProvider.searchedUsers!.isEmpty &&
|
||||
directoryProvider.searchTerm.isNotEmpty) {
|
||||
return Column(
|
||||
return MihSingleChildScroll(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
@@ -554,6 +556,7 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
@@ -568,12 +571,4 @@ class _MihSearchMzansiState extends State<MihSearchMzansi> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget displaySearchResults(MzansiDirectoryProvider directoryProvider) {
|
||||
if (directoryProvider.personalSearch) {
|
||||
return displayPersonalSearchResults(directoryProvider);
|
||||
} else {
|
||||
return displayBusinessSearchResults(directoryProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user