Ocideck/lib/app.dart
Brenno de Winter c6190dc31b Add consent/privacy screen at startup and license display
Implement three privacy features:
1. Consent gate at app startup - users must accept privacy terms before using OciDeck
2. License visibility - MIT license displayed in consent dialog
3. Consent revocation - privacy settings tab allows users to withdraw consent and return to consent screen

Changes:
- New ConsentProvider for managing consent state with SharedPreferences persistence
- New ConsentDialog with privacy explanation and MIT license (expandable)
- Added Privacy tab to settings dialog with revoke consent button
- Updated localization strings for Dutch/English consent screens

Consent flow:
- On first launch or after revocation, consent screen blocks app access
- Users can read privacy terms, view license, and accept to proceed
- Consent can be revoked anytime from Settings → Privacy tab
- After revocation, app returns to consent screen on next launch

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-06-11 14:01:06 +02:00

87 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'l10n/app_localizations.dart';
import 'state/settings_provider.dart';
import 'state/consent_provider.dart';
import 'theme/app_theme.dart';
import 'widgets/app_shell.dart';
import 'widgets/dialogs/consent_dialog.dart';
class OciDeckApp extends ConsumerWidget {
const OciDeckApp({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final languageCode = ref.watch(
settingsProvider.select((s) => s.languageCode),
);
final appearance = ref.watch(
settingsProvider.select((s) => s.appAppearanceProfile),
);
final uiTextScale = ref.watch(
settingsProvider.select((s) => s.uiTextScale),
);
AppLocalizations.setActiveLanguageCode(languageCode);
return MaterialApp(
title: 'OciDeck',
theme: AppTheme.fromProfile(appearance),
debugShowCheckedModeBanner: false,
// Interface text scaling (WCAG 1.4.4): the user's setting multiplies
// whatever the OS already asks for. Slides themselves opt out — they
// are a fixed design canvas (see SlidePreviewWidget).
builder: (context, child) {
final media = MediaQuery.of(context);
return MediaQuery(
data: media.copyWith(
textScaler: TextScaler.linear(
(media.textScaler.scale(1.0) * uiTextScale).clamp(1.0, 2.0),
),
),
child: child!,
);
},
locale: AppLocalizations.materialLocaleFor(languageCode),
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
home: const _ConsentGate(),
);
}
}
class _ConsentGate extends ConsumerWidget {
const _ConsentGate();
@override
Widget build(BuildContext context, WidgetRef ref) {
final consent = ref.watch(consentProvider);
if (consent.isLoading) {
return Scaffold(
body: Center(
child: const CircularProgressIndicator(),
),
);
}
if (!consent.hasAccepted) {
return MaterialApp(
title: 'OciDeck',
theme: ThemeData.light(),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: ConsentDialog(),
),
),
);
}
return const AppShell();
}
}