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

Can remove conversation logo

This commit is contained in:
2021-03-13 11:42:58 +01:00
parent 642f5e11fc
commit 99ae726c0a
2 changed files with 43 additions and 6 deletions

View File

@ -175,9 +175,6 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
],
),
// Conversation image
isUpdating ? _buildConversationImageWidget() : Container(),
// Add a member to the conversation
PickUserWidget(
resetOnChoose: true,
@ -190,6 +187,9 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
Column(
children: _members.map((f) => _buildMemberTile(f)).toList(),
),
// Conversation image
isUpdating ? _buildConversationImageWidget() : Container(),
],
),
),
@ -335,9 +335,22 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
: CachedNetworkImage(imageUrl: _image),
SizedBox(height: 5),
isAdmin
? OutlineButton(
onPressed: _uploadNewLogo,
child: Text(tr("Change logo")),
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlineButton(
onPressed: _uploadNewLogo,
child: Text(tr("Change logo")),
),
SizedBox(width: 5),
_image == null
? Container()
: OutlineButton(
onPressed: _deleteLogo,
child: Text(tr("Delete logo")),
highlightedBorderColor: Colors.red,
),
],
)
: Container(),
SizedBox(height: 10),
@ -366,4 +379,20 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
snack(context, tr("Failed to change conversation logo !"));
}
}
/// Delete conversation logo
Future<void> _deleteLogo() async {
try {
if (!await showConfirmDialog(
context: context,
message: tr("Do you really want to delete this logo?"))) return;
await ConversationsHelper.removeLogo(_conversation.id);
setState(() => _image = null);
} catch (e, s) {
logError(e, s);
snack(context, tr("Failed to remove conversation logo!"));
}
}
}