Ocideck/lib/widgets/dialogs/consent_dialog.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

188 lines
6.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../l10n/app_localizations.dart';
import '../../state/consent_provider.dart';
class ConsentDialog extends ConsumerStatefulWidget {
const ConsentDialog({super.key});
@override
ConsumerState<ConsentDialog> createState() => _ConsentDialogState();
}
class _ConsentDialogState extends ConsumerState<ConsentDialog> {
bool _licenseExpanded = false;
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final theme = Theme.of(context);
return AlertDialog(
title: Text(l10n.d('Welkom bij OciDeck')),
content: SizedBox(
width: 600,
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Privacy & Use Explanation
Text(
l10n.d('Privacy en gebruik'),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: theme.colorScheme.surface,
border: Border.all(
color: theme.colorScheme.outlineVariant,
),
borderRadius: BorderRadius.circular(8),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
l10n.d(
'OciDeck is een lokale desktop-applicatie. Uw presentaties en gegevens worden uitsluitend op uw computer opgeslagen.',
),
style: const TextStyle(fontSize: 12),
),
const SizedBox(height: 10),
Text(
l10n.d(
'De app verzamelt geen persoonlijke gegevens, geen statistieken en geen gebruiksgegevens. Uw privacy is onze prioriteit.',
),
style: const TextStyle(fontSize: 12),
),
const SizedBox(height: 10),
Text(
l10n.d(
'Alle gegevens die u in OciDeck invoert, blijven op uw lokale systeem en worden niet naar externe servers gestuurd.',
),
style: const TextStyle(fontSize: 12),
),
],
),
),
const SizedBox(height: 18),
// License Section
ExpansionTile(
title: Text(
l10n.d('Licentie (MIT)'),
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
initiallyExpanded: _licenseExpanded,
onExpansionChanged: (expanded) {
setState(() => _licenseExpanded = expanded);
},
children: [
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: theme.colorScheme.surface,
border: Border.all(
color: theme.colorScheme.outlineVariant,
),
borderRadius: BorderRadius.circular(8),
),
constraints: const BoxConstraints(maxHeight: 250),
child: SingleChildScrollView(
child: Text(
l10n.d(_getLicenseText()),
style: const TextStyle(
fontSize: 11,
fontFamily: 'monospace',
color: Color(0xFF475569),
),
),
),
),
],
),
const SizedBox(height: 18),
// Confirmation Section
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: theme.colorScheme.primaryContainer
.withValues(alpha: 0.2),
border: Border.all(
color: theme.colorScheme.primary.withValues(alpha: 0.3),
),
borderRadius: BorderRadius.circular(8),
),
child: Text(
l10n.d(
'Door op "Akkoord gaan" te klikken, accepteert u deze voorwaarden en gaat u akkoord met het gebruik van OciDeck.',
),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
],
),
),
),
actions: [
TextButton(
onPressed: () => _launchLicense(context),
child: Text(l10n.d('Volledige licentie online')),
),
const Spacer(),
ElevatedButton(
onPressed: () => _acceptConsent(ref),
child: Text(l10n.d('Akkoord gaan')),
),
],
);
}
String _getLicenseText() {
return '''MIT License
Copyright (c) 2024 De Winter Information Solutions
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.''';
}
void _launchLicense(BuildContext context) async {
const url =
'https://github.com/yourusername/ocideck/blob/main/LICENSE.md';
if (await canLaunchUrl(Uri.parse(url))) {
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
}
}
void _acceptConsent(WidgetRef ref) {
ref.read(consentProvider.notifier).acceptConsent();
}
}