update
feat(api_service): Update try-catch funtion and handle exception update(loading_animation): Update loading animation using Lottie
This commit is contained in:
@@ -38,35 +38,42 @@ changeUserInfomation(
|
||||
? IconButton(
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
formKey.currentState!.save();
|
||||
String latitude = user.latitude ?? "";
|
||||
String longitude = user.longitude ?? "";
|
||||
Map<String, dynamic> body = {
|
||||
"name": username,
|
||||
"email": email,
|
||||
"phone": tel,
|
||||
"address": address,
|
||||
"latitude": latitude,
|
||||
"longitude": longitude
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserProfile(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_profile_success,
|
||||
Colors.green,
|
||||
Colors.white);
|
||||
} else {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_profile_failed,
|
||||
Colors.redAccent,
|
||||
Colors.white);
|
||||
try {
|
||||
formKey.currentState!.save();
|
||||
String latitude = user.latitude ?? "";
|
||||
String longitude = user.longitude ?? "";
|
||||
Map<String, dynamic> body = {
|
||||
"name": username,
|
||||
"email": email,
|
||||
"phone": tel,
|
||||
"address": address,
|
||||
"latitude": latitude,
|
||||
"longitude": longitude
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserProfile(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_profile_success,
|
||||
Colors.green,
|
||||
Colors.white);
|
||||
} else {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_profile_failed,
|
||||
Colors.redAccent,
|
||||
Colors.white);
|
||||
}
|
||||
settingsBloc.getUserProfile(context);
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
showErrorTopSnackBarCustom(
|
||||
context, e.toString());
|
||||
}
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
}
|
||||
},
|
||||
icon:
|
||||
@@ -205,35 +212,42 @@ changeUserInfomation(
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
formKey.currentState!.save();
|
||||
String latitude = user.latitude ?? "";
|
||||
String longitude = user.longitude ?? "";
|
||||
Map<String, dynamic> body = {
|
||||
"name": username,
|
||||
"email": email,
|
||||
"phone": tel,
|
||||
"address": address,
|
||||
"latitude": latitude,
|
||||
"longitude": longitude
|
||||
};
|
||||
int statusCode = await apiServices
|
||||
.updateUserProfile(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_profile_success,
|
||||
Colors.green,
|
||||
Colors.white);
|
||||
} else {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_profile_failed,
|
||||
Colors.redAccent,
|
||||
Colors.white);
|
||||
try {
|
||||
formKey.currentState!.save();
|
||||
String latitude = user.latitude ?? "";
|
||||
String longitude = user.longitude ?? "";
|
||||
Map<String, dynamic> body = {
|
||||
"name": username,
|
||||
"email": email,
|
||||
"phone": tel,
|
||||
"address": address,
|
||||
"latitude": latitude,
|
||||
"longitude": longitude
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserProfile(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_profile_success,
|
||||
Colors.green,
|
||||
Colors.white);
|
||||
} else {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_profile_failed,
|
||||
Colors.redAccent,
|
||||
Colors.white);
|
||||
}
|
||||
settingsBloc.getUserProfile(context);
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
showErrorTopSnackBarCustom(
|
||||
context, e.toString());
|
||||
}
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
}
|
||||
},
|
||||
style: const ButtonStyle(
|
||||
@@ -282,30 +296,36 @@ changeUserPassword(BuildContext context, SettingsBloc settingsBloc) {
|
||||
isChangeSnapshot.data ?? isChange
|
||||
? IconButton(
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
formKey.currentState!.save();
|
||||
Map<String, dynamic> body = {
|
||||
"password_old": oldPass,
|
||||
"password_new": newPass,
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserPassword(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_password_success,
|
||||
Colors.green,
|
||||
Colors.white);
|
||||
} else {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_password_failed,
|
||||
Colors.redAccent,
|
||||
Colors.white);
|
||||
try {
|
||||
if (formKey.currentState!.validate()) {
|
||||
formKey.currentState!.save();
|
||||
Map<String, dynamic> body = {
|
||||
"password_old": oldPass,
|
||||
"password_new": newPass,
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserPassword(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_password_success,
|
||||
Colors.green,
|
||||
Colors.white);
|
||||
} else {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_password_failed,
|
||||
Colors.redAccent,
|
||||
Colors.white);
|
||||
}
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
}
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
showErrorTopSnackBarCustom(
|
||||
context, e.toString());
|
||||
}
|
||||
},
|
||||
icon:
|
||||
@@ -390,30 +410,36 @@ changeUserPassword(BuildContext context, SettingsBloc settingsBloc) {
|
||||
? Center(
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
formKey.currentState!.save();
|
||||
Map<String, dynamic> body = {
|
||||
"password_old": oldPass,
|
||||
"password_new": newPass,
|
||||
};
|
||||
int statusCode = await apiServices
|
||||
.updateUserPassword(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_password_success,
|
||||
Colors.green,
|
||||
Colors.white);
|
||||
} else {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_password_failed,
|
||||
Colors.redAccent,
|
||||
Colors.white);
|
||||
try {
|
||||
if (formKey.currentState!.validate()) {
|
||||
formKey.currentState!.save();
|
||||
Map<String, dynamic> body = {
|
||||
"password_old": oldPass,
|
||||
"password_new": newPass,
|
||||
};
|
||||
int statusCode =
|
||||
await apiServices.updateUserPassword(body);
|
||||
if (statusCode == 200) {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_password_success,
|
||||
Colors.green,
|
||||
Colors.white);
|
||||
} else {
|
||||
showNoIconTopSnackBar(
|
||||
modalBottomSheetContext,
|
||||
appLocalization(context)
|
||||
.notification_update_password_failed,
|
||||
Colors.redAccent,
|
||||
Colors.white);
|
||||
}
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
}
|
||||
Navigator.pop(modalBottomSheetContext);
|
||||
} catch (e) {
|
||||
if (!context.mounted) return;
|
||||
showErrorTopSnackBarCustom(
|
||||
context, e.toString());
|
||||
}
|
||||
},
|
||||
style: const ButtonStyle(
|
||||
|
||||
Reference in New Issue
Block a user