Files
swiftcontrol/lib/widgets/click_v2/keep_awake_warning.dart
Jonas Bark 1d1a0dbf72 feat(click v2): keep the right puck awake, and say when it can't
The right puck switches itself off after a minute of not being used.
BikeControl now prevents that on its own, with no button to press. The
sequence lives in prop; this side supplies what only it knows and shows
the rider the one case they can fix.

- the gate reads raw adverts, not the device list: the sibling only has
  to be nearby, and a left puck the rider ignored — every left puck in
  right-side-only mode — still counts. Discovery is also the retrigger,
  since an ignored puck never completes a handshake
- an optional step on the controller card, and a note on the right puck's
  own card, when no left puck is in range. An offer, never a blocker
- drops the D-pad line from "use the right side only"

Fixes a related bug: the controller link counted every undone step,
optional or not, so an optional offer alone turned a working controller
amber and held back "Ready to ride". The other two links already
excluded optional steps.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 14:55:15 +02:00

34 lines
1.2 KiB
Dart

import 'package:bike_control/utils/i18n_extension.dart';
import 'package:bike_control/widgets/ui/warning.dart';
import 'package:prop/prop.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
/// Tells the rider why their right puck is still going to power itself off.
///
/// Keeping it awake needs both pucks on the air once. When only the right one
/// is connected there is nothing the app can do about it, and nothing on the
/// card would otherwise say so — the puck simply switches off a minute later
/// and looks broken. Shown only in that state; the moment the left puck
/// connects the sequence runs and this goes away on its own.
class ClickV2KeepAwakeWarning extends StatelessWidget {
const ClickV2KeepAwakeWarning({super.key});
@override
Widget build(BuildContext context) {
return ValueListenableBuilder<ClickKeepAwakeStatus>(
valueListenable: ClickLogic.keepAwakeStatus,
builder: (context, status, _) {
if (status != ClickKeepAwakeStatus.waitingForLeftSide) {
return const SizedBox.shrink();
}
return Warning(
important: false,
children: [
Text(context.i18n.clickV2_keepAwakeNeedsLeftSide).xSmall,
],
);
},
);
}
}