feat: indicator for uploading images

This commit is contained in:
Stein Milder 2022-11-09 11:36:10 +01:00
parent 9e0378fe74
commit 2ebb05bb79
3 changed files with 30 additions and 3 deletions

View file

@ -81,6 +81,27 @@ class _CommunityChatState extends State<CommunityChat> {
);
}
void _beforeUploadingImage() => ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(minutes: 1),
content: Row(
children: [
const SizedBox(
width: 25,
height: 25,
child: CircularProgressIndicator(color: Colors.grey),
),
Padding(
padding: const EdgeInsets.only(left: 16.0),
child: Text(widget.translations.imageUploading),
),
],
),
),
);
_afterUploadingImage() => ScaffoldMessenger.of(context).hideCurrentSnackBar();
Future<void> _onPressSelectImage(BuildContext context, ChatModel chat) =>
showModalBottomSheet<Uint8List?>(
context: context,
@ -97,10 +118,14 @@ class _CommunityChatState extends State<CommunityChat> {
),
),
).then(
(image) {
(image) async {
_beforeUploadingImage();
if (image != null) {
return widget.dataProvider.sendImageMessage(image);
await widget.dataProvider.sendImageMessage(image);
}
_afterUploadingImage();
},
);

View file

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

View file

@ -11,6 +11,7 @@ class ChatTranslations {
this.searchPlaceholder = 'Search...',
this.cancelImagePickerBtn = 'Cancel',
this.messagePlaceholder = 'Write your message here...',
this.imageUploading = 'Image is uploading...',
});
final String chatsTitle;
@ -20,4 +21,5 @@ class ChatTranslations {
final String searchPlaceholder;
final String cancelImagePickerBtn;
final String messagePlaceholder;
final String imageUploading;
}