Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions bitwindow/lib/widgets/fork_countdown_timer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -88,9 +94,7 @@ class _ForkCountdownTimerState extends State<ForkCountdownTimer> {
),
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,
),
Expand Down
2 changes: 1 addition & 1 deletion bitwindow/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions bitwindow/test/fork_countdown_timer_test.dart
Original file line number Diff line number Diff line change
@@ -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');
});
}
Loading