diff --git a/bitwindow/lib/widgets/fork_countdown_timer.dart b/bitwindow/lib/widgets/fork_countdown_timer.dart index 8ed0ef0b3..ef4fea0db 100644 --- a/bitwindow/lib/widgets/fork_countdown_timer.dart +++ b/bitwindow/lib/widgets/fork_countdown_timer.dart @@ -5,6 +5,12 @@ import 'package:flutter/widgets.dart'; import 'package:get_it/get_it.dart'; import 'package:sail_ui/sail_ui.dart'; +/// The strip label, for example "ECASH HARDFORK · IN 10 BLOCKS". +String forkStripLabel(String networkName, int blocksLeft) { + final fork = networkName.isEmpty ? 'HARDFORK' : '${networkName.toUpperCase()} HARDFORK'; + return '$fork · IN $blocksLeft ${blocksLeft == 1 ? 'BLOCK' : 'BLOCKS'}'; +} + /// Pins the [ForkCountdownTimer] strip above [child] on every tab. The strip is /// a thin sliver, so it stays put rather than collapsing on scroll; it hides /// itself entirely (via [ForkCountdownTimer]) when there's no fork ahead. @@ -23,7 +29,7 @@ class ForkCountdownHeader extends StatelessWidget { } } -/// "HARDFORK · T-MINUS" countdown, rendered as a single-line status strip. +/// "HARDFORK · IN N BLOCKS" countdown, rendered as a single-line status strip. /// Visible on every page while the fork is still ahead. The target instant is /// held stable by [ForkProvider] (re-anchored only every 10 blocks); this /// widget just ticks the local clock down to it once a second, so the @@ -88,9 +94,7 @@ class _ForkCountdownTimerState extends State { ), const SizedBox(width: 8), SailText.secondary12( - _fork.networkName.isEmpty - ? 'HARDFORK · T-MINUS' - : '${_fork.networkName.toUpperCase()} HARDFORK · T-MINUS', + forkStripLabel(_fork.networkName, _fork.blocksUntilFork), bold: true, color: theme.colors.textSecondary, ), diff --git a/bitwindow/pubspec.yaml b/bitwindow/pubspec.yaml index a4ed11649..e5f3ba44f 100644 --- a/bitwindow/pubspec.yaml +++ b/bitwindow/pubspec.yaml @@ -3,7 +3,7 @@ description: "A frontend for interacting with a Drivechain-enabled layer 1 bitcoin network." publish_to: "none" -version: 0.2.255 +version: 0.2.256 environment: sdk: 3.13.5 diff --git a/bitwindow/test/fork_countdown_timer_test.dart b/bitwindow/test/fork_countdown_timer_test.dart new file mode 100644 index 000000000..55d270cd6 --- /dev/null +++ b/bitwindow/test/fork_countdown_timer_test.dart @@ -0,0 +1,10 @@ +import 'package:bitwindow/widgets/fork_countdown_timer.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('the fork strip counts the blocks that are left', () { + expect(forkStripLabel('eCash', 10), 'ECASH HARDFORK · IN 10 BLOCKS'); + expect(forkStripLabel('eCash', 1), 'ECASH HARDFORK · IN 1 BLOCK'); + expect(forkStripLabel('', 0), 'HARDFORK · IN 0 BLOCKS'); + }); +}