mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 22:39:22 +00:00
Ready to implement account deletion
This commit is contained in:
parent
9b427b9683
commit
e204c62ba9
91
lib/ui/routes/account_settings/account_privacy_settings.dart
Normal file
91
lib/ui/routes/account_settings/account_privacy_settings.dart
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import 'package:comunic/ui/dialogs/input_user_password_dialog.dart';
|
||||||
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:settings_ui/settings_ui.dart';
|
||||||
|
|
||||||
|
/// Account privacy settings
|
||||||
|
///
|
||||||
|
/// @author Pierre HUBERT
|
||||||
|
|
||||||
|
class AccountPrivacySettings extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: Text(tr("Privacy settings"))),
|
||||||
|
body: _AccountPrivacyScreen(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AccountPrivacyScreen extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
__AccountPrivacyScreenState createState() => __AccountPrivacyScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class __AccountPrivacyScreenState extends State<_AccountPrivacyScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SettingsList(sections: [
|
||||||
|
SettingsSection(title: tr("Privacy settings"), tiles: [
|
||||||
|
SettingsTile(
|
||||||
|
title: tr("Delete your account"),
|
||||||
|
subtitle:
|
||||||
|
tr("Permanently delete your account and all data related to it."),
|
||||||
|
onTap: _deleteAccount,
|
||||||
|
)
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Permanently delete user account
|
||||||
|
void _deleteAccount() async {
|
||||||
|
try {
|
||||||
|
// First dialog
|
||||||
|
if (!await showConfirmDialog(
|
||||||
|
context: context,
|
||||||
|
message: tr(
|
||||||
|
"Do you really want to delete your account? This operation CAN NOT be reverted!")))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Ask user password dialog
|
||||||
|
final password = await showUserPasswordDialog(context);
|
||||||
|
if (password == null) return;
|
||||||
|
|
||||||
|
// Last chance dialog
|
||||||
|
if (await showCupertinoDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (c) => _LastChanceDeleteAccountDialog()) !=
|
||||||
|
true) return;
|
||||||
|
|
||||||
|
// Delete account
|
||||||
|
print("Delete account");
|
||||||
|
} catch (e, stack) {
|
||||||
|
print("Could not delete user account! $e\n$stack");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LastChanceDeleteAccountDialog extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return CupertinoAlertDialog(
|
||||||
|
title: Text(tr("Delete your account")),
|
||||||
|
content: Text(tr(
|
||||||
|
"Let us ask you one last time. Do you really want to delete your account? If you decide to do so, your data will be permanently removed from our servers, so we will not be able to recover your account. If you decide to proceed, the deletion process will start immediatly and you will automatically get disconnected from your account.")),
|
||||||
|
actions: <Widget>[
|
||||||
|
CupertinoDialogAction(
|
||||||
|
isDefaultAction: true,
|
||||||
|
child: Text(tr("Cancel")),
|
||||||
|
onPressed: () => Navigator.of(context).pop(false),
|
||||||
|
),
|
||||||
|
CupertinoDialogAction(
|
||||||
|
isDestructiveAction: true,
|
||||||
|
child: Text(tr("Confirm")),
|
||||||
|
onPressed: () => Navigator.of(context).pop(true),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:comunic/ui/routes/account_settings/account_image_settings.dart';
|
import 'package:comunic/ui/routes/account_settings/account_image_settings.dart';
|
||||||
|
import 'package:comunic/ui/routes/account_settings/account_privacy_settings.dart';
|
||||||
import 'package:comunic/ui/routes/account_settings/account_security_settings.dart';
|
import 'package:comunic/ui/routes/account_settings/account_security_settings.dart';
|
||||||
import 'package:comunic/ui/routes/account_settings/custom_emojies_account_settings.dart';
|
import 'package:comunic/ui/routes/account_settings/custom_emojies_account_settings.dart';
|
||||||
import 'package:comunic/ui/routes/account_settings/general_account_settings.dart';
|
import 'package:comunic/ui/routes/account_settings/general_account_settings.dart';
|
||||||
@ -66,6 +67,14 @@ class __AccountSettingsBodyState extends State<_AccountSettingsBody> {
|
|||||||
leading: Icon(Icons.lock),
|
leading: Icon(Icons.lock),
|
||||||
onTap: () => _openSection(AccountSecuritySettingsScreen()),
|
onTap: () => _openSection(AccountSecuritySettingsScreen()),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Privacy settings
|
||||||
|
SettingsTile(
|
||||||
|
title: tr("Privacy"),
|
||||||
|
subtitle: tr("Here you can make actions to protect your privacy"),
|
||||||
|
leading: Icon(Icons.security),
|
||||||
|
onTap: () => _openSection(AccountPrivacySettings()),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user