feat(onboarding): every step reveals in reading order, not all at once

The welcome screen already arrived a piece at a time while every other
step faded in as one block. What made the welcome screen feel considered
was never the fade — the other steps had one too — it was the stagger:
content arriving in the order it is meant to be read, so the eye is led
down the page instead of being handed everything and left to find the
starting point.

_Reveal was a private near-duplicate of OnboardingFadeUp (520ms/14px
against 300ms/12px). Rather than copy a third variant around the step
files, both are replaced by one OnboardingReveal, and the page-level
blanket fade gives way to a KeyedSubtree — it would only have competed
with the per-child reveals, while the re-key still re-mounts each screen
so it reveals again on every step change.

Eleven bodies across the six steps, including the controller step's four
phases and the trainer step's three states.

Two judgement calls: Gaps pass through unwrapped, because animating empty
space buys nothing and leaving it in place from the first frame means the
column's layout is settled before anything fades in — nothing shifts under
the rider's eye, and the cadence stays even. And the delay stops growing
after eight items: the controller step's list grows with every device in
the room, and uncapped the last entry on a busy screen would arrive a
second and a half after the first, which a rider reaching for it would
watch move.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonas Bark
2026-08-11 18:25:12 +02:00
parent 0626328413
commit b2e210e09d
11 changed files with 202 additions and 87 deletions

View File

@@ -12,7 +12,6 @@ import 'package:bike_control/bluetooth/messages/notification.dart';
import 'package:bike_control/main.dart';
import 'package:bike_control/pages/onboarding/onboarding_methods.dart';
import 'package:bike_control/pages/onboarding/onboarding_models.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_fade_up.dart';
import 'package:bike_control/pages/onboarding/onboarding_sheets.dart';
import 'package:bike_control/pages/onboarding/steps/step_app.dart';
import 'package:bike_control/pages/onboarding/steps/step_connection.dart';
@@ -828,9 +827,11 @@ class _OnboardingPageState extends State<OnboardingPage> {
child: onboardingShell(
overlayContext,
step: _step,
// Re-keyed per step + controller phase so every screen slides in
// like the design's bk-fade-up entrance.
body: OnboardingFadeUp(
// Re-keyed per step + controller phase so every screen re-mounts and
// its contents reveal themselves again. The reveal lives on the
// children (see onboardingReveal) rather than on one wrapper, so a
// screen arrives in reading order instead of all at once.
body: KeyedSubtree(
key: ValueKey('onboarding-body-$_step-$_controllerPhase'),
child: _body(overlayContext),
),

View File

@@ -1,4 +1,5 @@
import 'package:bike_control/pages/onboarding/widgets/onboarding_theme.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_reveal.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_update_banner.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_group_label.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_note.dart';
@@ -111,7 +112,7 @@ Widget onboardingAppBody(BuildContext context,
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: onboardingReveal([
// Desktop has no welcome screen, so the update offer lives here.
if (showUpdateBanner) const OnboardingUpdateBanner(),
Text(context.i18n.onboardingAppTitle).h4,
@@ -125,6 +126,6 @@ Widget onboardingAppBody(BuildContext context,
grid(other),
Gap(14),
OnboardingNote(context.i18n.onboardingAppNote),
],
]),
);
}

View File

@@ -1,4 +1,5 @@
import 'package:bike_control/pages/onboarding/widgets/onboarding_theme.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_reveal.dart';
import 'package:bike_control/bluetooth/devices/trainer_connection.dart';
import 'package:bike_control/pages/onboarding/onboarding_app_guides.dart';
import 'package:bike_control/pages/onboarding/onboarding_methods.dart';
@@ -206,7 +207,7 @@ Widget onboardingConnectionBody(
};
}
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: onboardingReveal([
Text(context.i18n.onboardingConnectionTitle(app.name)).h4,
Gap(6),
Text(target == Target.thisDevice
@@ -227,5 +228,5 @@ Widget onboardingConnectionBody(
OnboardingGroupLabel(context.i18n.onboardingPairAsTrainer),
OnboardingPairAsTrainerCard(app: app, trainerName: trainerName),
],
]);
]));
}

View File

@@ -1,4 +1,5 @@
import 'package:bike_control/pages/onboarding/widgets/onboarding_theme.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_reveal.dart';
import 'package:bike_control/bluetooth/devices/base_device.dart';
import 'package:bike_control/bluetooth/devices/sram/sram_axs.dart';
import 'package:bike_control/bluetooth/devices/zwift/zwift_clickv2.dart';
@@ -146,7 +147,7 @@ Widget onboardingControllerBody(BuildContext context,
switch (phase) {
case ControllerPhase.permission:
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: onboardingReveal([
Text(context.i18n.onboardingBluetoothTitle).h4,
Gap(6),
Text(context.i18n.onboardingBluetoothSubtitle).small.muted,
@@ -165,9 +166,9 @@ Widget onboardingControllerBody(BuildContext context,
context, LucideIcons.bell, context.i18n.onboardingBluetoothNotifyTitle, context.i18n.onboardingBluetoothNotifySub),
Gap(6),
_infoRow(context, LucideIcons.shieldCheck, context.i18n.onboardingBluetoothPrivacy, ''),
]);
]));
case ControllerPhase.scanning:
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: onboardingReveal([
Text(context.i18n.onboardingScanTitle).h4,
Gap(6),
Text(context.i18n.onboardingScanSubtitle).small.muted,
@@ -175,9 +176,9 @@ Widget onboardingControllerBody(BuildContext context,
Center(child: SmoothWifiAnimation()),
Gap(20),
Center(child: Text(context.i18n.scanningForDevices).small.muted),
]);
]));
case ControllerPhase.empty:
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: onboardingReveal([
Text(context.i18n.onboardingScanEmptyTitle).h4,
Gap(6),
Text(context.i18n.onboardingScanEmptySubtitle).small.muted,
@@ -188,9 +189,9 @@ Widget onboardingControllerBody(BuildContext context,
context.i18n.onboardingScanEmptyDisconnectSub),
_infoRow(context, LucideIcons.ruler, context.i18n.onboardingScanEmptyCloserTitle,
context.i18n.onboardingScanEmptyCloserSub),
]);
]));
case ControllerPhase.list:
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: onboardingReveal([
Text(anyConnected ? context.i18n.onboardingControllerReadyTitle : context.i18n.onboardingControllerListTitle).h4,
Gap(6),
Text(anyConnected ? context.i18n.onboardingControllerReadySubtitle : context.i18n.onboardingControllerListSubtitle)
@@ -223,6 +224,6 @@ Widget onboardingControllerBody(BuildContext context,
Gap(12),
_infoRow(context, LucideIcons.lightbulb, context.i18n.onboardingControllerMapped(appName), ''),
],
]);
]));
}
}

View File

@@ -1,4 +1,5 @@
import 'package:bike_control/utils/i18n_extension.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_reveal.dart';
import 'package:bike_control/utils/keymap/apps/supported_app.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
@@ -26,7 +27,7 @@ Widget onboardingDoneBody(BuildContext context,
? (LucideIcons.bike, trainerName, context.i18n.onboardingSummaryBridged, true)
: (LucideIcons.bike, trainerName, context.i18n.onboardingSummaryWaitingFor(app.name), false),
];
return Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
return Column(crossAxisAlignment: CrossAxisAlignment.center, children: onboardingReveal([
Gap(8),
_SuccessBurst(reduceMotion: reduceMotion, ready: allReady),
Gap(14),
@@ -79,7 +80,7 @@ Widget onboardingDoneBody(BuildContext context,
]),
),
],
]);
]));
}
/// Green success circle shown at the top of the "done" step. Pops in with a

View File

@@ -1,4 +1,5 @@
import 'package:bike_control/pages/onboarding/widgets/onboarding_theme.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_reveal.dart';
import 'package:bike_control/bluetooth/devices/proxy/proxy_device.dart';
import 'package:bike_control/utils/i18n_extension.dart';
import 'package:bike_control/utils/keymap/apps/supported_app.dart';
@@ -38,7 +39,7 @@ Widget onboardingTrainerBody(BuildContext context,
// same device would never be found — explain it and name the two setups
// that do work instead of silently hiding the step.
if (bridged.isEmpty && virtualShiftingBlocked) {
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: onboardingReveal([
Text(context.i18n.onboardingVsBlockedTitle).h4,
Gap(6),
Text(context.i18n.onboardingVsBlockedSubtitle(app.name)).small.muted,
@@ -78,12 +79,12 @@ Widget onboardingTrainerBody(BuildContext context,
Icon(LucideIcons.externalLink, size: 13),
]),
),
]);
]));
}
if (bridged.isNotEmpty) {
final t = bridged.first;
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: onboardingReveal([
Text(context.i18n.onboardingTrainerConnectedTitle).h4,
Gap(6),
Text(context.i18n.onboardingTrainerConnectedSubtitle).small.muted,
@@ -103,7 +104,7 @@ Widget onboardingTrainerBody(BuildContext context,
),
Gap(12),
Text(context.i18n.onboardingTrainerNextStepNote(app.name)).xSmall.muted,
]);
]));
}
Widget benefit(IconData icon, String title, String sub) => Container(
@@ -122,7 +123,7 @@ Widget onboardingTrainerBody(BuildContext context,
]),
);
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: onboardingReveal([
Text(context.i18n.onboardingTrainerTitle).h4,
Gap(6),
Text(context.i18n.onboardingTrainerSubtitle).small.muted,
@@ -177,5 +178,5 @@ Widget onboardingTrainerBody(BuildContext context,
Icon(LucideIcons.externalLink, size: 13),
]),
),
]);
]));
}

View File

@@ -1,35 +1,9 @@
import 'package:bike_control/main.dart' show screenshotMode;
import 'package:bike_control/pages/onboarding/widgets/onboarding_theme.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_reveal.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_update_banner.dart';
import 'package:bike_control/utils/i18n_extension.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
/// Reveals its child with a fade + rise once [delay] has elapsed. Static under
/// reduced motion and in screenshotMode so captures stay deterministic.
class _Reveal extends StatelessWidget {
const _Reveal({required this.child, required this.delay});
final Widget child;
final Duration delay;
@override
Widget build(BuildContext context) {
if (screenshotMode || MediaQuery.of(context).disableAnimations) return child;
const span = Duration(milliseconds: 520);
final total = span + delay;
final start = delay.inMilliseconds / total.inMilliseconds;
return TweenAnimationBuilder<double>(
tween: Tween(begin: 0, end: 1),
duration: total,
curve: Interval(start, 1, curve: Curves.easeOutCubic),
builder: (context, t, child) => Opacity(
opacity: t,
child: Transform.translate(offset: Offset(0, 14 * (1 - t)), child: child),
),
child: child,
);
}
}
/// The mobile-only welcome screen: the headline's words arrive one after the
/// other, then the subtitle, the reassurance rows and the actions.
///
@@ -45,7 +19,7 @@ class OnboardingWelcome extends StatelessWidget {
final accent = onboardingAccent(context);
final words = context.i18n.onboardingWelcomeTitle.split(' ');
Widget point(IconData icon, String text, int index) => _Reveal(
Widget point(IconData icon, String text, int index) => OnboardingReveal(
delay: Duration(milliseconds: 900 + index * 110),
child: Padding(
padding: const EdgeInsets.only(bottom: 10),
@@ -74,7 +48,7 @@ class OnboardingWelcome extends StatelessWidget {
children: [
const Spacer(flex: 2),
const OnboardingUpdateBanner(),
_Reveal(
OnboardingReveal(
delay: Duration.zero,
child: Image.asset('icon.png', width: 64, height: 64),
),
@@ -85,14 +59,14 @@ class OnboardingWelcome extends StatelessWidget {
runSpacing: 2,
children: [
for (var i = 0; i < words.length; i++)
_Reveal(
OnboardingReveal(
delay: Duration(milliseconds: 180 + i * 90),
child: Text(words[i]).x3Large.semiBold,
),
],
),
Gap(12),
_Reveal(
OnboardingReveal(
delay: Duration(milliseconds: 180 + words.length * 90),
child: Text(context.i18n.onboardingWelcomeSubtitle).small.muted,
),
@@ -101,7 +75,7 @@ class OnboardingWelcome extends StatelessWidget {
point(LucideIcons.bike, context.i18n.onboardingWelcomePointTrainer, 1),
point(LucideIcons.wifi, context.i18n.onboardingWelcomePointApp, 2),
const Spacer(flex: 3),
_Reveal(
OnboardingReveal(
delay: const Duration(milliseconds: 1300),
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
PrimaryButton(

View File

@@ -1,4 +1,5 @@
import 'package:bike_control/pages/onboarding/widgets/onboarding_theme.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_reveal.dart';
import 'package:bike_control/pages/onboarding/widgets/onboarding_note.dart';
import 'package:bike_control/utils/i18n_extension.dart';
import 'package:bike_control/utils/keymap/apps/supported_app.dart';
@@ -83,7 +84,7 @@ Widget onboardingWhereBody(BuildContext context,
t == Target.thisDevice ? context.i18n.onboardingWhereEnablesLocal : context.i18n.onboardingWhereEnablesNetwork;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: onboardingReveal([
Text(context.i18n.onboardingWhereTitle(app.name)).h4,
Gap(6),
Text(context.i18n.onboardingWhereSubtitle).small.muted,
@@ -105,6 +106,6 @@ Widget onboardingWhereBody(BuildContext context,
],
Gap(4),
OnboardingNote(context.i18n.onboardingWhereChangeLater, icon: LucideIcons.pencil),
],
]),
);
}

View File

@@ -1,29 +0,0 @@
import 'package:bike_control/main.dart' show screenshotMode;
import 'package:shadcn_flutter/shadcn_flutter.dart';
/// The design's `bk-fade-up` entrance: fade in while sliding up ~12px over
/// 300ms. Give it a new [key] to re-run (the wizard keys it by step + phase).
/// Renders statically under reduced motion and in [screenshotMode] (which the
/// snapshot harness enables, keeping captures deterministic).
class OnboardingFadeUp extends StatelessWidget {
const OnboardingFadeUp({super.key, required this.child, this.delay = Duration.zero});
final Widget child;
final Duration delay;
@override
Widget build(BuildContext context) {
if (screenshotMode || MediaQuery.of(context).disableAnimations) return child;
final total = const Duration(milliseconds: 300) + delay;
final start = delay.inMilliseconds / total.inMilliseconds;
return TweenAnimationBuilder<double>(
tween: Tween(begin: 0, end: 1),
duration: total,
curve: Interval(start, 1, curve: Curves.easeOutCubic),
builder: (context, t, child) => Opacity(
opacity: t,
child: Transform.translate(offset: Offset(0, 12 * (1 - t)), child: child),
),
child: child,
);
}
}

View File

@@ -0,0 +1,74 @@
import 'package:bike_control/main.dart' show screenshotMode;
import 'package:shadcn_flutter/shadcn_flutter.dart';
/// Reveals its child with a fade + rise once [delay] has elapsed.
///
/// Staggering these — see [onboardingReveal] — is what makes a wizard screen
/// arrive rather than appear: the eye is led down the page in the order the
/// content is meant to be read, instead of being handed everything at once and
/// left to find the starting point itself.
///
/// Renders statically under reduced motion and in [screenshotMode] (which the
/// snapshot harness enables, keeping captures deterministic).
class OnboardingReveal extends StatelessWidget {
const OnboardingReveal({super.key, required this.child, this.delay = Duration.zero});
final Widget child;
final Duration delay;
/// The rise and the span the welcome screen uses. Long enough to read as
/// movement, short enough that a staggered column has finished arriving
/// before a rider could act on it.
static const Duration span = Duration(milliseconds: 520);
static const double rise = 14;
/// Gap between consecutive items in a staggered column.
static const Duration interval = Duration(milliseconds: 70);
/// How many items still earn a longer delay. The controller step's list grows
/// with every device in the room, and without a ceiling the last entry on a
/// busy screen would arrive a second and a half after the first — long enough
/// that a rider reaching for it watches it move.
static const int maxStaggered = 8;
@override
Widget build(BuildContext context) {
if (screenshotMode || MediaQuery.of(context).disableAnimations) return child;
final total = span + delay;
final start = delay.inMilliseconds / total.inMilliseconds;
return TweenAnimationBuilder<double>(
tween: Tween(begin: 0, end: 1),
duration: total,
curve: Interval(start, 1, curve: Curves.easeOutCubic),
builder: (context, t, child) => Opacity(
opacity: t,
child: Transform.translate(offset: Offset(0, rise * (1 - t)), child: child),
),
child: child,
);
}
}
/// Wraps a column's [children] so they arrive one after another.
///
/// [Gap]s are passed through untouched: they are empty space, so animating
/// them would buy nothing visually while making the cadence uneven — and
/// leaving them in place from the first frame means the column's layout is
/// settled before anything fades in, so nothing shifts under the rider's eye.
List<Widget> onboardingReveal(
List<Widget> children, {
Duration delay = Duration.zero,
Duration interval = OnboardingReveal.interval,
}) {
var index = 0;
return [
for (final child in children)
if (child is Gap)
child
else
OnboardingReveal(
delay: delay + interval * (index++).clamp(0, OnboardingReveal.maxStaggered),
child: child,
),
];
}

View File

@@ -0,0 +1,89 @@
import 'package:bike_control/pages/onboarding/widgets/onboarding_reveal.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
List<OnboardingReveal> revealsIn(List<Widget> wrapped) => wrapped.whereType<OnboardingReveal>().toList();
void main() {
group('onboardingReveal staggering', () {
test('each item is delayed one interval further than the last', () {
final wrapped = onboardingReveal([const Text('a'), const Text('b'), const Text('c')]);
expect(
revealsIn(wrapped).map((r) => r.delay),
[Duration.zero, OnboardingReveal.interval, OnboardingReveal.interval * 2],
);
});
test('gaps pass through untouched, so the layout is settled from frame one', () {
final wrapped = onboardingReveal([const Text('a'), const Gap(8), const Text('b')]);
expect(wrapped[1], isA<Gap>());
// The gap does not consume a stagger slot — the two texts stay adjacent
// in the cadence rather than leaving a hole in it.
expect(revealsIn(wrapped).map((r) => r.delay), [Duration.zero, OnboardingReveal.interval]);
});
test('an offset delay shifts the whole column without changing its rhythm', () {
final wrapped = onboardingReveal(
[const Text('a'), const Text('b')],
delay: const Duration(milliseconds: 200),
);
expect(
revealsIn(wrapped).map((r) => r.delay),
[const Duration(milliseconds: 200), const Duration(milliseconds: 200) + OnboardingReveal.interval],
);
});
// A long device list must not push its last entry a second and a half out —
// a rider reaching for it would watch it move.
test('the delay stops growing past the cap', () {
final wrapped = onboardingReveal(List.generate(20, (i) => Text('$i')));
final delays = revealsIn(wrapped).map((r) => r.delay).toList();
final capped = OnboardingReveal.interval * OnboardingReveal.maxStaggered;
expect(delays.last, capped);
expect(delays.every((d) => d <= capped), isTrue);
});
test('an empty column stays empty', () {
expect(onboardingReveal(const []), isEmpty);
});
});
group('OnboardingReveal rendering', () {
testWidgets('renders its child statically when animations are disabled', (tester) async {
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(disableAnimations: true),
child: Directionality(
textDirection: TextDirection.ltr,
child: OnboardingReveal(delay: Duration(milliseconds: 400), child: Text('hello')),
),
),
);
// No animation to wait out: the child is simply there, at full opacity.
expect(find.text('hello'), findsOneWidget);
expect(find.byType(TweenAnimationBuilder<double>), findsNothing);
});
testWidgets('animates in, and settles', (tester) async {
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(),
child: Directionality(
textDirection: TextDirection.ltr,
child: OnboardingReveal(child: Text('hello')),
),
),
);
await tester.pump();
final opacity = tester.widget<Opacity>(find.byType(Opacity).first);
expect(opacity.opacity, lessThan(1));
await tester.pumpAndSettle();
expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 1);
});
});
}