36 lines
1.5 KiB
Dart
36 lines
1.5 KiB
Dart
import '../../session/session_manager.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 [Session.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);
|
|
|
|
/// Guardian logins are passwordless, so reviewers need a fixed address that
|
|
/// skips the mail round-trip. Deliberately not the `demo@` prefix, which a
|
|
/// real e-mail address could start with.
|
|
static const String guardianEmail = 'demo-eltern@marianum-fulda.de';
|
|
|
|
static bool matchesGuardian(String email) =>
|
|
email.trim().toLowerCase() == guardianEmail;
|
|
|
|
/// True while the active session is a demo session.
|
|
static bool get active => SessionManager().isDemo;
|
|
}
|