chore: Better connection status indicator
This commit is contained in:
parent
892e379a2a
commit
7599ce8627
7 changed files with 195 additions and 187 deletions
27
lib/utils/sync_status_localization.dart
Normal file
27
lib/utils/sync_status_localization.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
|
||||
extension SyncStatusLocalization on SyncStatusUpdate {
|
||||
String calcLocalizedString(BuildContext context) {
|
||||
final progress = this.progress;
|
||||
switch (status) {
|
||||
case SyncStatus.waitingForResponse:
|
||||
return L10n.of(context).waitingForServer;
|
||||
case SyncStatus.error:
|
||||
return ((error?.exception ?? Object()) as Object)
|
||||
.toLocalizedString(context);
|
||||
case SyncStatus.processing:
|
||||
case SyncStatus.cleaningUp:
|
||||
case SyncStatus.finished:
|
||||
return progress == null
|
||||
? L10n.of(context).synchronizingPleaseWait
|
||||
: L10n.of(context).synchronizingPleaseWaitCounter(
|
||||
progress.round().toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue