diff --git a/lib/helpers/settings_helper.dart b/lib/helpers/settings_helper.dart index 01cac03..89b9c6a 100644 --- a/lib/helpers/settings_helper.dart +++ b/lib/helpers/settings_helper.dart @@ -50,4 +50,10 @@ class SettingsHelper { .key) .exec()) .isOK; + + /// Delete user account image + static Future deleteAccountImage() async => + (await APIRequest(uri: "settings/delete_account_image", needLogin: true) + .exec()) + .isOK; } diff --git a/lib/ui/routes/account_settings/account_image_settings.dart b/lib/ui/routes/account_settings/account_image_settings.dart index d20d8d1..ded8c6e 100644 --- a/lib/ui/routes/account_settings/account_image_settings.dart +++ b/lib/ui/routes/account_settings/account_image_settings.dart @@ -93,7 +93,12 @@ class __AccountImageSettingsBodyState extends State<_AccountImageSettingsBody> { ? tr("Comunic users") : tr("My friends only"), })), - SettingsTile(title: tr("Delete account image")) + + // Delete account image + SettingsTile( + title: tr("Delete account image"), + onTap: () => _deleteAccountImage(), + ), ]; } @@ -148,4 +153,19 @@ class __AccountImageSettingsBodyState extends State<_AccountImageSettingsBody> { _key.currentState.refresh(); } + + /// Delete user account image + void _deleteAccountImage() async { + if (!await showConfirmDialog( + context: context, + message: tr("Do you really want to delete your account image ?"))) + return; + + if (!await SettingsHelper.deleteAccountImage()) { + showSimpleSnack(context, tr("Could not user account image!")); + return; + } + + _key.currentState.refresh(); + } }