tane/apps/app_seeds/lib/services/onboarding_store.dart

28 lines
1.2 KiB
Dart

import '../security/secret_store.dart';
/// Remembers whether the intro/onboarding carousel has been shown, so it only
/// appears on first launch. Backed by the OS keystore (via [SecretStore]) to
/// honour the "no plaintext at rest" rule — there is no shared_preferences here.
class OnboardingStore {
OnboardingStore(this._store);
final SecretStore _store;
static const _introSeenKey = 'tane.intro_seen';
static const _marketRulesKey = 'tane.market_rules_accepted';
/// Whether the user has already seen (or skipped) the intro carousel.
Future<bool> introSeen() async => await _store.read(_introSeenKey) == '1';
/// Records that the intro has been shown; subsequent launches skip it.
Future<void> markIntroSeen() => _store.write(_introSeenKey, '1');
/// Whether the user has accepted the community rules that gate the market.
/// Required once before joining the market or publishing anything (stores
/// ask for terms acceptance before user content is created).
Future<bool> marketRulesAccepted() async =>
await _store.read(_marketRulesKey) == '1';
/// Records the one-time acceptance of the community rules.
Future<void> markMarketRulesAccepted() => _store.write(_marketRulesKey, '1');
}