1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Can delete custom emoji

This commit is contained in:
2020-04-29 17:22:34 +02:00
parent 5d432a5f87
commit 3cf9ee39d0
2 changed files with 30 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:comunic/helpers/settings_helper.dart';
import 'package:comunic/helpers/users_helper.dart';
import 'package:comunic/lists/custom_emojies_list.dart';
import 'package:comunic/models/custom_emoji.dart';
import 'package:comunic/models/new_emoji.dart';
import 'package:comunic/models/user.dart';
import 'package:comunic/ui/widgets/async_screen_widget.dart';
@ -71,6 +72,9 @@ class _CustomEmojiesAccountBodyState extends State<_CustomEmojiesAccountBody> {
.map((u) => ListTile(
leading: NetworkImageWidget(url: u.url, width: 50),
title: Text(u.shortcut),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () => _deleteEmoji(u)),
))
.toList());
}
@ -106,6 +110,22 @@ class _CustomEmojiesAccountBodyState extends State<_CustomEmojiesAccountBody> {
_key.currentState.refresh();
}
/// Ask for confirmation before deleting permanently an emoji
void _deleteEmoji(CustomEmoji u) async {
try {
if (!await showConfirmDialog(
context: context,
message: tr("Do you really want to delete this custom emoji ?")))
return;
await SettingsHelper.deleteCustomEmoji(u.id);
_key.currentState.refresh();
} catch (e, stack) {
print("Could not delete custom emoji! $e\n$stack");
}
}
}
/// Dialog used to upload new custom emojies