mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-30 09:42:48 +01:00
Desktop was routed straight into step 1's rail, which asks a rider to pick a trainer app before anything has said what BikeControl does or how long setup takes. The one screen that answers "what am I about to agree to" was the one desktop never saw. The screen was built for a phone column — Spacers, full-width buttons, 24px padding — so simply unlocking it would have stretched a column of short lines across a 1400px window. It is capped to kOnboardingBodyMaxWidth, the same measure the wizard's own body uses on desktop, so stepping from the welcome into the rail keeps the text at one width instead of snapping narrower. step_app's update banner already keyed off _showedWelcome, so the offer moves to the welcome screen on desktop by itself and never appears twice; only its comment claimed desktop had no welcome screen. The existing test asserted the behaviour being removed, so it is rewritten around the new one, plus a case pinning the readable measure on a wide window — that cap is the whole reason this doesn't look wrong on desktop. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
132 lines
5.1 KiB
Dart
132 lines
5.1 KiB
Dart
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';
|
|
import 'package:bike_control/utils/i18n_extension.dart';
|
|
import 'package:bike_control/utils/keymap/apps/supported_app.dart';
|
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
|
|
|
const _success = Color(0xFF22C55E);
|
|
|
|
/// One app tile per the design: white card, logo (or monogram), dark caption,
|
|
/// blue 1.5px border + top-right blue check dot when selected. Public so the
|
|
/// grid-uniformity test can measure the rendered tiles.
|
|
class OnboardingAppTile extends StatelessWidget {
|
|
const OnboardingAppTile({super.key, required this.app, required this.selected, required this.onTap});
|
|
final SupportedApp app;
|
|
final bool selected;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final scheme = Theme.of(context).colorScheme;
|
|
return Button.ghost(
|
|
style: ButtonStyle.ghost().withPadding(padding: EdgeInsets.zero),
|
|
onPressed: onTap,
|
|
child: Stack(children: [
|
|
Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: selected ? onboardingAccent(context) : scheme.border, width: 1.5),
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: scheme.card,
|
|
),
|
|
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
|
SizedBox(
|
|
height: 40,
|
|
child: Center(
|
|
child: app.logoAsset != null
|
|
? Image.asset(app.logoAsset!, height: 36, fit: BoxFit.contain)
|
|
: Container(
|
|
width: 40,
|
|
height: 40,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(10),
|
|
color: scheme.muted,
|
|
),
|
|
child: Text(app.name.substring(0, 1).toUpperCase()).semiBold.muted,
|
|
),
|
|
),
|
|
),
|
|
Gap(9),
|
|
Text(app.name, textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.ellipsis)
|
|
.xSmall
|
|
.semiBold,
|
|
]),
|
|
),
|
|
if (selected)
|
|
Positioned(
|
|
top: 7,
|
|
right: 7,
|
|
child: Container(
|
|
width: 18,
|
|
height: 18,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(shape: BoxShape.circle, color: onboardingAccent(context)),
|
|
child: Icon(LucideIcons.check, size: 11, color: onboardingOnAccent),
|
|
),
|
|
),
|
|
]),
|
|
);
|
|
}
|
|
}
|
|
|
|
Widget _verifiedBadge(BuildContext context) => Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(5),
|
|
color: _success.withValues(alpha: 0.12),
|
|
),
|
|
child: DefaultTextStyle.merge(
|
|
style: const TextStyle(color: _success, letterSpacing: 0.6),
|
|
child: Text(context.i18n.onboardingVerified.toUpperCase()).xSmall.semiBold,
|
|
),
|
|
);
|
|
|
|
Widget onboardingAppBody(BuildContext context,
|
|
{required SupportedApp? selected,
|
|
required ValueChanged<SupportedApp> onSelect,
|
|
bool showUpdateBanner = false}) {
|
|
final official = SupportedApp.supportedApps.where((a) => a.officialIntegration).toList();
|
|
final other = SupportedApp.supportedApps.where((a) => !a.officialIntegration).toList();
|
|
|
|
Widget grid(List<SupportedApp> apps) => LayoutBuilder(builder: (context, constraints) {
|
|
final cols = constraints.maxWidth >= 560 ? 5 : 3;
|
|
return GridView.count(
|
|
crossAxisCount: cols,
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
mainAxisSpacing: 8,
|
|
crossAxisSpacing: 8,
|
|
childAspectRatio: 1.15,
|
|
children: [
|
|
for (final app in apps)
|
|
OnboardingAppTile(app: app, selected: selected?.name == app.name, onTap: () => onSelect(app)),
|
|
],
|
|
);
|
|
});
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: onboardingReveal([
|
|
// Shown only when the welcome screen didn't already make the offer.
|
|
if (showUpdateBanner) const OnboardingUpdateBanner(),
|
|
Text(context.i18n.onboardingAppTitle).h4,
|
|
Gap(6),
|
|
Text(context.i18n.onboardingAppSubtitle).small.muted,
|
|
Gap(18),
|
|
OnboardingGroupLabel(context.i18n.officiallySupported, trailing: _verifiedBadge(context)),
|
|
grid(official),
|
|
Gap(18),
|
|
OnboardingGroupLabel(context.i18n.otherTrainerApps),
|
|
grid(other),
|
|
Gap(14),
|
|
OnboardingNote(context.i18n.onboardingAppNote),
|
|
]),
|
|
);
|
|
}
|