refactor: Switch to loading dialog
This commit is contained in:
parent
9521a93622
commit
75797a62b9
36 changed files with 461 additions and 350 deletions
23
lib/utils/localized_exception_extension.dart
Normal file
23
lib/utils/localized_exception_extension.dart
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
extension LocalizedExceptionExtension on Object {
|
||||
String toLocalizedString(BuildContext context) {
|
||||
if (this is MatrixException) {
|
||||
switch ((this as MatrixException).error) {
|
||||
case MatrixError.M_FORBIDDEN:
|
||||
return L10n.of(context).noPermission;
|
||||
case MatrixError.M_LIMIT_EXCEEDED:
|
||||
return L10n.of(context).tooManyRequestsWarning;
|
||||
default:
|
||||
return (this as MatrixException).errorMessage;
|
||||
}
|
||||
}
|
||||
if (this is MatrixConnectionException) {
|
||||
L10n.of(context).noConnectionToTheServer;
|
||||
}
|
||||
Logs().d('Something went wrong: ', this);
|
||||
return L10n.of(context).oopsSomethingWentWrong;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue