profile Picture fix

This commit is contained in:
2024-08-28 20:41:31 +02:00
parent 5d67e2549f
commit 4fc7f31943
3 changed files with 42 additions and 59 deletions

View File

@@ -55,7 +55,9 @@ class _MIHAppDrawerState extends State<MIHAppDrawer>
}
Future<String> getFileUrlApiCall(String filePath) async {
if (AppEnviroment.getEnv() == "Dev") {
if (widget.signedInUser.pro_pic_path == "") {
return "";
} else if (AppEnviroment.getEnv() == "Dev") {
return "${AppEnviroment.baseFileUrl}/mih/$filePath";
} else {
var url = "${AppEnviroment.baseApiUrl}/minio/pull/file/$filePath/prod";
@@ -81,11 +83,9 @@ class _MIHAppDrawerState extends State<MIHAppDrawer>
@override
void initState() {
if (widget.signedInUser.pro_pic_path.isNotEmpty) {
setState(() {
proPicUrl = getFileUrlApiCall(widget.signedInUser.pro_pic_path);
});
}
setState(() {
proPicUrl = getFileUrlApiCall(widget.signedInUser.pro_pic_path);
});
_controller = GifController(vsync: this);
super.initState();
}
@@ -118,7 +118,7 @@ class _MIHAppDrawerState extends State<MIHAppDrawer>
future: proPicUrl,
builder: (BuildContext context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasData) {
if (snapshot.hasData && snapshot.data != "") {
return Stack(
alignment: Alignment.center,
fit: StackFit.loose,
@@ -137,32 +137,16 @@ class _MIHAppDrawerState extends State<MIHAppDrawer>
],
);
} else {
return Center(
child: Text(
'${snapshot.error} occurred',
style: const TextStyle(fontSize: 18),
),
return SizedBox(
width: 60,
child: Image(image: logoThemeSwitch),
);
}
} else {
return SizedBox(
width: 60,
child: Gif(
image: MzanziInnovationHub.of(context)!
.theme
.loadingImage(),
controller:
_controller, // if duration and fps is null, original gif fps will be used.
fps: 15,
//duration: const Duration(seconds: 3),
autostart: Autostart.loop,
placeholder: (context) => const Center(
child: CircularProgressIndicator(),
),
onFetchCompleted: () {
_controller.reset();
_controller.forward();
},
return Center(
child: Text(
'${snapshot.error} occurred',
style: const TextStyle(fontSize: 18),
),
);
}

View File

@@ -45,7 +45,9 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate>
late final GifController _controller;
Future<String> getFileUrlApiCall(String filePath) async {
if (AppEnviroment.getEnv() == "Dev") {
if (widget.signedInUser.pro_pic_path == "") {
return "";
} else if (AppEnviroment.getEnv() == "Dev") {
return "${AppEnviroment.baseFileUrl}/mih/$filePath";
} else {
var url = "${AppEnviroment.baseApiUrl}/minio/pull/file/$filePath/prod";
@@ -222,12 +224,10 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate>
var proPicName = "";
if (widget.signedInUser.pro_pic_path.isNotEmpty) {
proPicName = widget.signedInUser.pro_pic_path.split("/").last;
setState(() {
proPicUrl = getFileUrlApiCall(widget.signedInUser.pro_pic_path);
});
}
_controller = GifController(vsync: this);
setState(() {
proPicUrl = getFileUrlApiCall(widget.signedInUser.pro_pic_path);
proPicController.text = proPicName;
fnameController.text = widget.signedInUser.fname;
lnameController.text = widget.signedInUser.lname;
@@ -270,7 +270,7 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate>
future: proPicUrl,
builder: (BuildContext context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasData) {
if (snapshot.hasData && snapshot.data != "") {
return Stack(
alignment: Alignment.center,
fit: StackFit.loose,
@@ -292,32 +292,18 @@ class _ProfileUserUpdateState extends State<ProfileUserUpdate>
],
);
} else {
return Center(
child: Text(
'${snapshot.error} occurred',
style: const TextStyle(fontSize: 18),
),
);
return SizedBox(
width: 110,
child: Image(
image: MzanziInnovationHub.of(context)!
.theme
.altLogoImage()));
}
} else {
return SizedBox(
width: 110,
child: Gif(
image: MzanziInnovationHub.of(context)!
.theme
.loadingImage(),
controller:
_controller, // if duration and fps is null, original gif fps will be used.
fps: 15,
//duration: const Duration(seconds: 3),
autostart: Autostart.loop,
placeholder: (context) => const Center(
child: CircularProgressIndicator(),
),
onFetchCompleted: () {
_controller.reset();
_controller.forward();
},
return Center(
child: Text(
'${snapshot.error} occurred',
style: const TextStyle(fontSize: 18),
),
);
}

View File

@@ -164,6 +164,19 @@ class MyTheme {
return loading;
}
AssetImage altLoadingImage() {
if (mode == "Dark") {
loading = const AssetImage(
'images/loading_dark.gif',
);
} else {
loading = const AssetImage(
'images/loading_light.gif',
);
}
return loading;
}
Color primaryColor() {
if (mode == "Dark") {
_mainColor = 0XFF3A4454;