Files
meshcore-open/lib/review_mode/review_mode.dart
T
zjs81 11c94040e3 Add review mode with a simulated radio
Store reviewers have no MeshCore radio, so they could not reach any
screen past Connect or test the Android Auto messaging notifications.

- Long-press the "MeshCore Open" title on the Connect screen to enter
  review mode on any platform
- A simulated radio speaks the companion protocol as a fourth transport,
  so sync, messages, ACKs, notifications and notification replies run
  through the normal code paths
- Seeded contacts, channels and history; a new incoming message every
  45 s, auto-replies a few seconds after sending, and a banner with
  "Send test message" and "Exit"
- Review data uses its own fixed key scope and is cleared on entry, exit
  and at startup; the review scope never adopts legacy unscoped keys,
  and channel mutes changed during review are restored
- Code lives in lib/review_mode/ with tests in test/review_mode/
2026-10-07 20:38:59 -07:00

69 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../connector/meshcore_connector.dart';
import '../l10n/l10n.dart';
import '../screens/channels_screen.dart';
export 'review_mode_banner.dart';
export 'review_mode_entry.dart';
/// Asks for confirmation, connects to the simulated radio and opens the app.
Future<void> enterReviewMode(BuildContext context) async {
final navigator = Navigator.of(context);
final messenger = ScaffoldMessenger.of(context);
final connector = context.read<MeshCoreConnector>();
final l10n = context.l10n;
final confirmed = await showDialog<bool>(
context: context,
builder: (dialogContext) => AlertDialog(
title: Text(dialogContext.l10n.reviewMode_dialogTitle),
content: Text(dialogContext.l10n.reviewMode_dialogBody),
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(false),
child: Text(dialogContext.l10n.reviewMode_cancel),
),
FilledButton(
onPressed: () => Navigator.of(dialogContext).pop(true),
child: Text(dialogContext.l10n.reviewMode_confirm),
),
],
),
);
if (confirmed != true || !navigator.mounted) return;
// Progress dialog on the root navigator while connecting.
showDialog<void>(
context: navigator.context,
barrierDismissible: false,
builder: (_) => const PopScope(
canPop: false,
child: Center(child: CircularProgressIndicator()),
),
);
Object? error;
try {
await connector.connectReview();
} catch (e) {
error = e;
}
if (!navigator.mounted) return;
navigator.pop(); // progress dialog
if (error != null) {
messenger.showSnackBar(
SnackBar(content: Text(l10n.reviewMode_connectFailed(error.toString()))),
);
return;
}
// The connect may have been ignored (another connection was in progress)
// or cancelled by a disconnect while it was running.
if (!connector.isReviewMode || !connector.isConnected) return;
navigator.push(MaterialPageRoute(builder: (_) => const ChannelsScreen()));
}