fix(app): persist disclosure acknowledgement only after acceptance #5
@@ -19,23 +19,28 @@ class DataDisclosureDialog {
|
|||||||
|
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
|
|
||||||
await showDialog(
|
final accepted = await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false, // Must tap Continue — no tap-outside dismiss.
|
barrierDismissible: false, // Must tap Continue — no tap-outside dismiss.
|
||||||
builder: (_) => _DisclosureDialog(
|
builder: (_) => const _DisclosureDialog(),
|
||||||
onContinue: () {
|
|
||||||
prefs.setBool(_key, true);
|
|
||||||
Navigator.of(context).pop(); // Dismiss the dialog.
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
if (accepted != true) return;
|
||||||
|
|
||||||
|
// Persist only after the user action is complete. If storage fails, do not
|
||||||
|
// invent an accepted state; the disclosure will simply reappear later.
|
||||||
|
try {
|
||||||
|
final saved = await prefs.setBool(_key, true);
|
||||||
|
if (!saved) {
|
||||||
|
debugPrint('[Disclosure] Preference write was rejected');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('[Disclosure] Failed to persist acknowledgement: $e');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DisclosureDialog extends StatelessWidget {
|
class _DisclosureDialog extends StatelessWidget {
|
||||||
final VoidCallback onContinue;
|
const _DisclosureDialog();
|
||||||
|
|
||||||
const _DisclosureDialog({required this.onContinue});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -49,7 +54,6 @@ class _DisclosureDialog extends StatelessWidget {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// Title
|
|
||||||
const Text(
|
const Text(
|
||||||
'Before you connect',
|
'Before you connect',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -59,8 +63,6 @@ class _DisclosureDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
// Body
|
|
||||||
const Text(
|
const Text(
|
||||||
'Revolt VPN creates a secure VPN tunnel to protect your '
|
'Revolt VPN creates a secure VPN tunnel to protect your '
|
||||||
'traffic. To enforce your data/time quota, we log your '
|
'traffic. To enforce your data/time quota, we log your '
|
||||||
@@ -76,12 +78,10 @@ class _DisclosureDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
// Continue button — full-width, accent
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: onContinue,
|
onPressed: () => Navigator.of(context).pop(true),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AppColors.accent,
|
backgroundColor: AppColors.accent,
|
||||||
foregroundColor: AppColors.bgDeep,
|
foregroundColor: AppColors.bgDeep,
|
||||||
|
|||||||
Reference in new issue
Block a user