sync status eta (#1701)

* sync status eta

* other necessary changes

* feat: Enhance Sync ETA display mode

- Enhance block rate calculation with weighted averages(accounts for network flunctuations and sync speed of more recent blocks while calculating eta, basically giving us more accuracy)
- Add option to switch between ETA and blocks remaining display in display settings
- Add placeholder ETA while gathering block data

* chore: Listen to smaller changes in eta

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
Co-authored-by: Blazebrain <davidadegoke16@gmail.com>
This commit is contained in:
Matthew Fosse
2025-08-19 18:09:51 +03:00
committed by GitHub
co-authored by Omar Hatem Blazebrain
parent 013211e7a6
commit c8dca29f68
36 changed files with 361 additions and 8 deletions
+19 -4
View File
@@ -1,11 +1,26 @@
import 'package:cake_wallet/entities/sync_status_display_mode.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cw_core/sync_status.dart';
String syncStatusTitle(SyncStatus syncStatus) {
String syncStatusTitle(SyncStatus syncStatus, SyncStatusDisplayMode syncStatusDisplayMode) {
if (syncStatus is SyncingSyncStatus) {
return syncStatus.blocksLeft == 1
? S.current.block_remaining
: S.current.Blocks_remaining('${syncStatus.blocksLeft}');
if (syncStatus.blocksLeft == 1) {
return S.current.block_remaining;
}
// Check user preference for sync status display
if (syncStatusDisplayMode == SyncStatusDisplayMode.eta) {
// Get ETA with placeholder while gathering data
String eta = syncStatus.getFormattedEtaWithPlaceholder() ?? '';
if (eta.isEmpty) {
return S.current.Blocks_remaining('${syncStatus.blocksLeft}');
} else {
return "${syncStatus.formattedProgress()} - ${S.current.eta} $eta";
}
} else {
return S.current.Blocks_remaining('${syncStatus.blocksLeft}');
}
}
if (syncStatus is SyncedTipSyncStatus) {