feat: confirm deleting chat

This commit is contained in:
Stein Milder 2022-11-25 08:14:58 +01:00
parent 3dde81838d
commit 13f57a0817
6 changed files with 44 additions and 5 deletions

View file

@ -179,7 +179,7 @@ packages:
description:
path: "packages/flutter_community_chat_interface"
ref: HEAD
resolved-ref: a6b21aab224b47e112ae771b3ce81c158843ee5d
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git
version: "0.0.1"
@ -188,7 +188,7 @@ packages:
description:
path: "packages/flutter_community_chat_view"
ref: HEAD
resolved-ref: a6b21aab224b47e112ae771b3ce81c158843ee5d
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git
version: "0.0.1"

View file

@ -228,7 +228,7 @@ packages:
description:
path: "packages/flutter_community_chat_interface"
ref: HEAD
resolved-ref: a6b21aab224b47e112ae771b3ce81c158843ee5d
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git
version: "0.0.1"

View file

@ -186,7 +186,7 @@ packages:
description:
path: "packages/flutter_community_chat_interface"
ref: HEAD
resolved-ref: a6b21aab224b47e112ae771b3ce81c158843ee5d
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git
version: "0.0.1"

View file

@ -13,6 +13,11 @@ class ChatTranslations {
this.messagePlaceholder = 'Write your message here...',
this.imageUploading = 'Image is uploading...',
this.deleteChatButton = 'Delete',
this.deleteChatModalTitle = 'Delete chat',
this.deleteChatModalDescription =
'Are you sure you want to delete this chat?',
this.deleteChatModalCancel = 'Cancel',
this.deleteChatModalConfirm = 'Delete',
});
final String chatsTitle;
@ -24,4 +29,8 @@ class ChatTranslations {
final String cancelImagePickerBtn;
final String messagePlaceholder;
final String imageUploading;
final String deleteChatModalTitle;
final String deleteChatModalDescription;
final String deleteChatModalCancel;
final String deleteChatModalConfirm;
}

View file

@ -50,6 +50,36 @@ class _ChatScreenState extends State<ChatScreen> {
for (ChatModel chat in snapshot.data ?? [])
Builder(
builder: (context) => Dismissible(
confirmDismiss: (_) => showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text(
widget.translations.deleteChatModalTitle,
),
content: Text(
widget.translations
.deleteChatModalDescription,
),
actions: [
TextButton(
child: Text(
widget
.translations.deleteChatModalCancel,
),
onPressed: () =>
Navigator.of(context).pop(false),
),
ElevatedButton(
onPressed: () =>
Navigator.of(context).pop(true),
child: Text(
widget.translations
.deleteChatModalConfirm,
),
),
],
),
),
onDismissed: (_) => widget.onDeleteChat(chat),
background: Container(
color: Colors.red,

View file

@ -179,7 +179,7 @@ packages:
description:
path: "packages/flutter_community_chat_interface"
ref: HEAD
resolved-ref: a6b21aab224b47e112ae771b3ce81c158843ee5d
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git
version: "0.0.1"