From e7f7ff5f279c7fcbda3e934de3f406261fd37132 Mon Sep 17 00:00:00 2001 From: Stein Milder Date: Fri, 25 Nov 2022 08:14:58 +0100 Subject: [PATCH] feat: confirm deleting chat --- packages/flutter_community_chat/pubspec.lock | 4 +-- .../pubspec.lock | 2 +- .../example/pubspec.lock | 2 +- .../lib/src/config/chat_translations.dart | 9 ++++++ .../lib/src/screens/chat_screen.dart | 30 ++++++++++++++++++- .../flutter_community_chat_view/pubspec.lock | 2 +- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/packages/flutter_community_chat/pubspec.lock b/packages/flutter_community_chat/pubspec.lock index 84807b7..f3db7c8 100644 --- a/packages/flutter_community_chat/pubspec.lock +++ b/packages/flutter_community_chat/pubspec.lock @@ -179,7 +179,7 @@ packages: description: path: "packages/flutter_community_chat_interface" ref: HEAD - resolved-ref: a6b21aab224b47e112ae771b3ce81c158843ee5d + resolved-ref: "68578b8ac21493b88cd5b1a2fd55634f0616ff77" 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: "68578b8ac21493b88cd5b1a2fd55634f0616ff77" url: "https://github.com/Iconica-Development/flutter_community_chat.git" source: git version: "0.0.1" diff --git a/packages/flutter_community_chat_firebase/pubspec.lock b/packages/flutter_community_chat_firebase/pubspec.lock index b22daaa..ea5c8b7 100644 --- a/packages/flutter_community_chat_firebase/pubspec.lock +++ b/packages/flutter_community_chat_firebase/pubspec.lock @@ -228,7 +228,7 @@ packages: description: path: "packages/flutter_community_chat_interface" ref: HEAD - resolved-ref: a6b21aab224b47e112ae771b3ce81c158843ee5d + resolved-ref: "68578b8ac21493b88cd5b1a2fd55634f0616ff77" url: "https://github.com/Iconica-Development/flutter_community_chat.git" source: git version: "0.0.1" diff --git a/packages/flutter_community_chat_view/example/pubspec.lock b/packages/flutter_community_chat_view/example/pubspec.lock index dc336eb..e9931ab 100644 --- a/packages/flutter_community_chat_view/example/pubspec.lock +++ b/packages/flutter_community_chat_view/example/pubspec.lock @@ -186,7 +186,7 @@ packages: description: path: "packages/flutter_community_chat_interface" ref: HEAD - resolved-ref: a6b21aab224b47e112ae771b3ce81c158843ee5d + resolved-ref: "68578b8ac21493b88cd5b1a2fd55634f0616ff77" url: "https://github.com/Iconica-Development/flutter_community_chat.git" source: git version: "0.0.1" diff --git a/packages/flutter_community_chat_view/lib/src/config/chat_translations.dart b/packages/flutter_community_chat_view/lib/src/config/chat_translations.dart index 82b428d..a731dff 100644 --- a/packages/flutter_community_chat_view/lib/src/config/chat_translations.dart +++ b/packages/flutter_community_chat_view/lib/src/config/chat_translations.dart @@ -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; } diff --git a/packages/flutter_community_chat_view/lib/src/screens/chat_screen.dart b/packages/flutter_community_chat_view/lib/src/screens/chat_screen.dart index 986ede7..59109bb 100644 --- a/packages/flutter_community_chat_view/lib/src/screens/chat_screen.dart +++ b/packages/flutter_community_chat_view/lib/src/screens/chat_screen.dart @@ -50,7 +50,35 @@ class _ChatScreenState extends State { for (ChatModel chat in snapshot.data ?? []) Builder( builder: (context) => Dismissible( - onDismissed: (_) => widget.onDeleteChat(chat), + onDismissed: (_) => 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: () {}, + ), + ElevatedButton( + onPressed: () => + widget.onDeleteChat(chat), + child: Text( + widget.translations + .deleteChatModalConfirm, + ), + ), + ], + ), + ), background: Container( color: Colors.red, child: Align( diff --git a/packages/flutter_community_chat_view/pubspec.lock b/packages/flutter_community_chat_view/pubspec.lock index 9324675..98cd39c 100644 --- a/packages/flutter_community_chat_view/pubspec.lock +++ b/packages/flutter_community_chat_view/pubspec.lock @@ -179,7 +179,7 @@ packages: description: path: "packages/flutter_community_chat_interface" ref: HEAD - resolved-ref: a6b21aab224b47e112ae771b3ce81c158843ee5d + resolved-ref: "68578b8ac21493b88cd5b1a2fd55634f0616ff77" url: "https://github.com/Iconica-Development/flutter_community_chat.git" source: git version: "0.0.1"