switch to new image api strat and fix onboarding cache strat

This commit is contained in:
yaso 2026-07-07 14:30:58 +02:00
parent 48b434dad9
commit a5bdee892c
39 changed files with 540 additions and 791 deletions

View file

@ -47,7 +47,6 @@ class _MihAddBookmarkAlertState extends State<MihAddBookmarkAlert> {
}
directoryProvider.setFavouriteBusinesses(
businesses: favBus,
businessesImagesUrl: favBusImages,
);
}

View file

@ -52,7 +52,6 @@ class _MihDeleteBookmarkAlertState extends State<MihDeleteBookmarkAlert> {
}
directoryProvider.setFavouriteBusinesses(
businesses: favBus,
businessesImagesUrl: favBusImages,
);
}

View file

@ -69,58 +69,20 @@ class _MihBusinessDetailsViewState extends State<MihBusinessDetailsView> {
: EdgeInsets.symmetric(horizontal: width * 0),
child: Column(
children: [
FutureBuilder(
future: futureImageUrl,
builder: (context, asyncSnapshot) {
if (asyncSnapshot.connectionState ==
ConnectionState.done &&
asyncSnapshot.hasData) {
if (asyncSnapshot.requireData != "") {
return MihCircleAvatar(
imageFile: CachedNetworkImageProvider(
asyncSnapshot.requireData),
width: profilePictureWidth,
expandable: true,
editable: false,
fileNameController: TextEditingController(),
userSelectedfile: file,
frameColor: MihColors.secondary(),
backgroundColor: MihColors.primary(),
onChange: () {},
);
} else {
return Icon(
MihIcons.mihIDontKnow,
size: profilePictureWidth,
color: MihColors.secondary(),
);
}
} else {
return Icon(
MihIcons.mihRing,
size: profilePictureWidth,
color: MihColors.secondary(),
);
}
}),
// Center(
// child: MihCircleAvatar(
// imageFile: widget.logoImage,
// width: 150,
// editable: false,
// fileNameController: fileNameController,
// userSelectedfile: imageFile,
// frameColor:
// MihColors.secondary(),
// backgroundColor:
// MihColors.primary(),
// onChange: (selectedfile) {
// setState(() {
// imageFile = selectedfile;
// });
// },
// ),
// ),
MihCircleAvatar(
imageFile: CachedNetworkImageProvider(
MihFileApi.getMinioFileUrlV2(
directoryProvider.selectedBusiness!.logo_path),
),
width: profilePictureWidth,
expandable: true,
editable: false,
fileNameController: TextEditingController(),
userSelectedfile: file,
frameColor: MihColors.secondary(),
backgroundColor: MihColors.primary(),
onChange: () {},
),
FittedBox(
child: Text(
directoryProvider.selectedBusiness!.Name,

View file

@ -1,5 +1,3 @@
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:file_picker/file_picker.dart';
import 'package:file_saver/file_saver.dart';
@ -59,7 +57,7 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
String encodedData =
Uri.encodeComponent("$qrCodedata${business.business_id}");
return "https://api.qrserver.com/v1/create-qr-code/?data=$encodedData&size=${qrSize}x${qrSize}&bgcolor=$bgColor&color=$color";
return "https://api.qrserver.com/v1/create-qr-code/?data=$encodedData&size=${qrSize}x$qrSize&bgcolor=$bgColor&color=$color";
}
Future<void> saveImage(Uint8List imageBytes) async {
@ -206,41 +204,18 @@ class _MihBusinessQrCodeState extends State<MihBusinessQrCode> {
backgroundColor: MihColors.secondary(),
onChange: () {},
)
: FutureBuilder(
future: futureImageUrl,
builder: (context, asyncSnapshot) {
if (asyncSnapshot.connectionState ==
ConnectionState.done &&
asyncSnapshot.hasData) {
if (asyncSnapshot.requireData != "" ||
asyncSnapshot.requireData.isNotEmpty) {
return MihCircleAvatar(
imageFile: CachedNetworkImageProvider(
asyncSnapshot.requireData),
width: profilePictureWidth,
expandable: true,
editable: false,
fileNameController: TextEditingController(),
userSelectedfile: file,
frameColor: MihColors.primary(),
backgroundColor: MihColors.secondary(),
onChange: () {},
);
} else {
return Icon(
MihIcons.mihIDontKnow,
size: profilePictureWidth,
color: MihColors.primary(),
);
}
} else {
return Icon(
MihIcons.mihRing,
size: profilePictureWidth,
color: MihColors.primary(),
);
}
},
: MihCircleAvatar(
imageFile: CachedNetworkImageProvider(
MihFileApi.getMinioFileUrlV2(business.logo_path),
),
width: profilePictureWidth,
expandable: true,
editable: false,
fileNameController: TextEditingController(),
userSelectedfile: file,
frameColor: MihColors.primary(),
backgroundColor: MihColors.secondary(),
onChange: () {},
),
FittedBox(
child: Text(

View file

@ -86,12 +86,9 @@ class _MihEditPersonalProfileWindowState
);
if (responseCode == 200) {
setState(() {
setProfileVariables(mzansiProfileProvider);
newSelectedProPic = null;
});
// if (originalProfileTypeIsBusiness == false && businessUser == true) {
// stayOnPersonalSide = false;
// }
await mzansiProfileProvider.syncWithMihServerData();
String message = "Your information has been updated successfully!";
successPopUp(
mzansiProfileProvider,

View file

@ -174,35 +174,67 @@ class _MihPersonalProfileState extends State<MihPersonalProfile> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
MihButton(
onPressed: () {
addProfileLinksWindow();
},
buttonColor: MihColors.green(),
width: mzansiProfileProvider.personalLinks.isNotEmpty
? 50
: null,
height: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.add,
color: MihColors.primary(),
),
if (mzansiProfileProvider.personalLinks.isEmpty)
Text(
"Add Links",
style: TextStyle(
color: MihColors.primary(),
fontSize: 15,
fontWeight: FontWeight.bold,
),
mzansiProfileProvider.user!.username != ""
? MihButton(
onPressed: () {
addProfileLinksWindow();
},
buttonColor: MihColors.green(),
width:
mzansiProfileProvider.personalLinks.isNotEmpty
? 50
: null,
height: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.add,
color: MihColors.primary(),
),
if (mzansiProfileProvider
.personalLinks.isEmpty)
Text(
"Add Links",
style: TextStyle(
color: MihColors.primary(),
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
],
),
],
),
),
)
: MihButton(
onPressed: () {
editProfileWindow();
},
buttonColor: MihColors.green(),
width: null,
height: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.edit,
color: MihColors.primary(),
),
const SizedBox(
width: 10,
),
Text(
"Add Profile",
style: TextStyle(
color: MihColors.primary(),
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
],
),
),
const SizedBox(width: 8.0),
if (mzansiProfileProvider.personalLinks.isNotEmpty)
MihButton(

View file

@ -75,40 +75,21 @@ class _MihPersonalProfileViewState extends State<MihPersonalProfileView> {
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
FutureBuilder(
future: futureImageUrl,
builder: (context, asyncSnapshot) {
if (asyncSnapshot.connectionState ==
ConnectionState.done &&
asyncSnapshot.hasData) {
if (asyncSnapshot.requireData != "") {
return MihCircleAvatar(
imageFile: CachedNetworkImageProvider(
asyncSnapshot.requireData),
width: profilePictureWidth,
expandable: true,
editable: false,
fileNameController: TextEditingController(),
userSelectedfile: file,
frameColor: MihColors.secondary(),
backgroundColor: MihColors.primary(),
onChange: () {},
);
} else {
return Icon(
MihIcons.mihIDontKnow,
size: profilePictureWidth,
color: MihColors.secondary(),
);
}
} else {
return Icon(
MihIcons.mihRing,
size: profilePictureWidth,
color: MihColors.secondary(),
);
}
}),
MihCircleAvatar(
imageFile: CachedNetworkImageProvider(
MihFileApi.getMinioFileUrlV2(
directoryProvider.selectedUser!.pro_pic_path,
),
),
width: profilePictureWidth,
expandable: true,
editable: false,
fileNameController: TextEditingController(),
userSelectedfile: file,
frameColor: MihColors.secondary(),
backgroundColor: MihColors.primary(),
onChange: () {},
),
FittedBox(
child: Text(
directoryProvider.selectedUser!.username.isNotEmpty

View file

@ -206,41 +206,18 @@ class _MihPersonalQrCodeState extends State<MihPersonalQrCode> {
backgroundColor: MihColors.secondary(),
onChange: () {},
)
: FutureBuilder(
future: futureImageUrl,
builder: (context, asyncSnapshot) {
if (asyncSnapshot.connectionState ==
ConnectionState.done &&
asyncSnapshot.hasData) {
if (asyncSnapshot.requireData != "" ||
asyncSnapshot.requireData.isNotEmpty) {
return MihCircleAvatar(
imageFile: CachedNetworkImageProvider(
asyncSnapshot.requireData),
width: profilePictureWidth,
expandable: true,
editable: false,
fileNameController: TextEditingController(),
userSelectedfile: file,
frameColor: MihColors.primary(),
backgroundColor: MihColors.secondary(),
onChange: () {},
);
} else {
return Icon(
MihIcons.mihIDontKnow,
size: profilePictureWidth,
color: MihColors.primary(),
);
}
} else {
return Icon(
MihIcons.mihRing,
size: profilePictureWidth,
color: MihColors.primary(),
);
}
},
: MihCircleAvatar(
imageFile: CachedNetworkImageProvider(
MihFileApi.getMinioFileUrlV2(user.pro_pic_path),
),
width: profilePictureWidth,
expandable: true,
editable: false,
fileNameController: TextEditingController(),
userSelectedfile: file,
frameColor: MihColors.primary(),
backgroundColor: MihColors.secondary(),
onChange: () {},
),
FittedBox(
child: Text(