TF-3487 Create retriable failure state and toast

This commit is contained in:
DatDang
2025-02-24 10:37:07 +07:00
committed by Dat H. Pham
parent e595aa02a0
commit 91dddff18d
6 changed files with 245 additions and 2 deletions
+33
View File
@@ -617,4 +617,37 @@ abstract class BaseController extends GetxController
final minInputLength = session.getMinInputLengthAutocomplete(accountId);
return minInputLength?.value.toInt() ?? AppConfig.defaultMinInputLengthAutocomplete;
}
void showRetryToast(FeatureFailure failure) {
if (currentOverlayContext == null || currentContext == null) return;
final exception = failure.exception;
final errorMessage = exception is MethodLevelErrors && exception.message != null
? AppLocalizations.of(currentContext!).unexpectedError('${exception.message!}')
: AppLocalizations.of(currentContext!).unknownError;
appToast.showToastMessageWithMultipleActions(
currentOverlayContext!,
errorMessage,
actions: [
if (failure.onRetry != null)
(
actionName: AppLocalizations.of(currentContext!).retry,
onActionClick: () => consumeState(failure.onRetry!),
actionIcon: SvgPicture.asset(imagePaths.icUndo),
),
(
actionName: AppLocalizations.of(currentContext!).close,
onActionClick: () => ToastView.dismiss(),
actionIcon: SvgPicture.asset(
imagePaths.icClose,
colorFilter: Colors.white.asFilter(),
),
)
],
backgroundColor: AppColor.toastErrorBackgroundColor,
textColor: Colors.white,
infinityToast: true,
);
}
}
+6
View File
@@ -4393,5 +4393,11 @@
"type": "text",
"placeholders_order": [],
"placeholders": {}
},
"retry": "Retry",
"@retry": {
"type": "text",
"placeholders_order": [],
"placeholders": {}
}
}
@@ -4618,4 +4618,11 @@ class AppLocalizations {
name: 'viewEntireMessage',
);
}
String get retry {
return Intl.message(
'Retry',
name: 'retry',
);
}
}