28 lines
1.2 KiB
Dart
28 lines
1.2 KiB
Dart
import '../../model/account_data.dart';
|
|
|
|
/// Central switch for the client-side demo mode.
|
|
///
|
|
/// A login whose username starts with [usernamePrefix] (the password is
|
|
/// ignored) enters demo mode: instead of talking to the real backends, the app
|
|
/// serves curated fixtures from `DemoData` for every feature. This lets Google
|
|
/// Play reviewers and automated screenshot runs see a fully populated app
|
|
/// without a real account and without any network dependency.
|
|
///
|
|
/// The flag is persisted through [AccountData.isDemo], so a demo session
|
|
/// survives cold starts exactly like a normal login. It works in release builds
|
|
/// too — reviewers run the shipped release build.
|
|
class DemoMode {
|
|
const DemoMode._();
|
|
|
|
/// Usernames starting with this prefix trigger demo mode. Whatever the
|
|
/// reviewer types as the password is accepted.
|
|
static const String usernamePrefix = 'demo@';
|
|
|
|
/// Whether [username], as typed on the login screen, should enter demo mode.
|
|
static bool matches(String username) =>
|
|
username.trim().toLowerCase().startsWith(usernamePrefix);
|
|
|
|
/// True while the active session is a demo session.
|
|
static bool get active => AccountData().isDemo;
|
|
}
|