diff --git a/lib/helpers/groups_helper.dart b/lib/helpers/groups_helper.dart index 2f65e26..c1a2550 100644 --- a/lib/helpers/groups_helper.dart +++ b/lib/helpers/groups_helper.dart @@ -237,6 +237,12 @@ class GroupsHelper { .addBytesFile("logo", BytesFile("logo.png", bytes)) .execWithFilesAndThrow(); + /// Delete group logo + static Future deleteLogo(int groupID) async => + await APIRequest(uri: "groups/delete_logo", needLogin: true) + .addInt("id", groupID) + .execWithThrow(); + /// Turn an API entry into a group object Group _getGroupFromAPI(Map map) { return Group( diff --git a/lib/ui/screens/group_settings_screen.dart b/lib/ui/screens/group_settings_screen.dart index 8a1159f..0e99a7a 100644 --- a/lib/ui/screens/group_settings_screen.dart +++ b/lib/ui/screens/group_settings_screen.dart @@ -261,7 +261,13 @@ class _GroupSettingsScreenState extends SafeState { SettingsTile( title: tr("Generate a new random logo"), onTap: _generateRandomLogo, - ) + ), + + // Delete current logo + SettingsTile( + title: tr("Delete logo"), + onTap: _deleteLogo, + ), ], ); } @@ -294,4 +300,20 @@ class _GroupSettingsScreenState extends SafeState { await GroupsHelper.uploadNewLogo(_groupSettings.id, bytes); _key.currentState.refresh(); } + + /// Delete previous group logo + void _deleteLogo() async { + try { + if (!await showConfirmDialog( + context: context, + message: tr("Do you really want to delete the logo of this group ?"))) + return; + + await GroupsHelper.deleteLogo(_groupSettings.id); + _key.currentState.refresh(); + } catch (e, s) { + print("Could not delete group logo! $e\n$s"); + showSimpleSnack(context, tr("Could not delete group logo!")); + } + } }