mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-22 16:22:18 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,free-days-interop) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / free-days-interop (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Flutter 3.50 deprecates package:flutter/material.dart, so the app moves to material_ui 1.11.0 together with sync_settings_ui 0.8.0 and github_device_auth 0.5.0 (crdt_sync 0.13.1 rides along). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
133 lines
4.6 KiB
Dart
133 lines
4.6 KiB
Dart
import 'package:material_ui/material_ui.dart';
|
|
import 'package:wake_alarm_sync/services/dismiss_gate.dart';
|
|
import 'package:wake_alarm_sync/services/room_proof.dart';
|
|
import 'package:wake_alarm_sync/ui/spoken_label.dart';
|
|
|
|
/// The three-step progress list shown while the room proof is incomplete.
|
|
///
|
|
/// Showing every stage up front — including the ones not yet live — is
|
|
/// deliberate: a half-asleep user needs to see that a second tag is coming,
|
|
/// not discover it after walking back to bed.
|
|
class RingChecklist extends StatelessWidget {
|
|
/// Creates a checklist reflecting [gate]'s current stage.
|
|
const RingChecklist({required this.gate, super.key});
|
|
|
|
/// The sequence being displayed.
|
|
final DismissGate gate;
|
|
|
|
static const List<(DismissStage, String)> _rows = <(DismissStage, String)>[
|
|
(DismissStage.tag1, 'Tap tag 1'),
|
|
(DismissStage.steps, 'Walk 25 steps'),
|
|
(DismissStage.tag2, 'Tap tag 2'),
|
|
];
|
|
|
|
/// Whether [stage] has already been passed.
|
|
bool _isDone(DismissStage stage) => stage.index < gate.stage.index;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final colorScheme = theme.colorScheme;
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
for (final (stage, label) in _rows)
|
|
if (!(gate.bypassActive && stage != DismissStage.steps))
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
|
child: SpokenLabel(
|
|
semanticLabel: label,
|
|
key: ValueKey<String>('ring-row-${stage.name}'),
|
|
child: Row(
|
|
children: <Widget>[
|
|
Icon(
|
|
_isDone(stage)
|
|
? Icons.check_circle
|
|
: Icons.radio_button_unchecked,
|
|
color: _isDone(stage)
|
|
? colorScheme.primary
|
|
: theme.disabledColor,
|
|
size: gate.stage == stage ? 32 : 24,
|
|
),
|
|
const SizedBox(width: 12),
|
|
_stageGlyphs(stage, gate.stage == stage, colorScheme),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (gate.bypassActive)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 12),
|
|
child: SpokenLabel(
|
|
semanticLabel: gate.awayActive
|
|
? 'Away from home — the tags are elsewhere. Walk, then '
|
|
'answer ${gate.challengesRequired} questions.'
|
|
: 'Tags unavailable — walk, then answer '
|
|
'${gate.challengesRequired} questions instead.',
|
|
key: const Key('ring-bypass'),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Icon(
|
|
gate.awayActive ? Icons.explore : Icons.block,
|
|
color: colorScheme.error,
|
|
),
|
|
const Icon(Icons.arrow_forward, size: 16),
|
|
const Icon(Icons.directions_walk),
|
|
const Icon(Icons.arrow_forward, size: 16),
|
|
const Icon(Icons.quiz_outlined),
|
|
Text('${gate.challengesRequired}'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _stageGlyphs(DismissStage stage, bool current, ColorScheme cs) {
|
|
final primary = cs.primary;
|
|
final muted = cs.onSurfaceVariant;
|
|
final color = current ? primary : muted;
|
|
final size = current ? 32.0 : 24.0;
|
|
switch (stage) {
|
|
case DismissStage.tag1:
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Icon(Icons.nfc, size: size, color: color),
|
|
Text(
|
|
'1',
|
|
style: TextStyle(fontSize: size, color: color),
|
|
),
|
|
],
|
|
);
|
|
case DismissStage.steps:
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Icon(Icons.directions_walk, size: size, color: color),
|
|
Text(
|
|
'${RoomProof.requiredSteps}',
|
|
style: TextStyle(fontSize: size, color: color),
|
|
),
|
|
],
|
|
);
|
|
case DismissStage.tag2:
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Icon(Icons.nfc, size: size, color: color),
|
|
Text(
|
|
'2',
|
|
style: TextStyle(fontSize: size, color: color),
|
|
),
|
|
],
|
|
);
|
|
case DismissStage.challenges:
|
|
case DismissStage.done:
|
|
return const SizedBox.shrink();
|
|
}
|
|
}
|
|
}
|