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 createState() => _ConsentDialogState(); } class _ConsentDialogState extends ConsumerState { 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(); } }