From e8750087a03eb1632bca4603f43b07d515b2ae96 Mon Sep 17 00:00:00 2001 From: Alex Demchenko Date: Tue, 13 Jul 2021 23:27:51 +0200 Subject: [PATCH] Fixes after PR --- CHANGELOG.md | 4 +++- lib/src/widgets/chat.dart | 40 ++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38f5f725..9a8fe725 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## 1.1.6 -- Added `emptyState` that allows you to customize what the user sees when there are no messages +- Added `emptyState` that allows you to customize what the user sees when there are no messages. Thanks @AndreHaueisen for the PR! +- Added Korean localization. Thanks @ChangJoo-Park for the PR! +- Can't send spaces anymore. Thanks @kwamerex101 for reporting the bug! ## 1.1.5 diff --git a/lib/src/widgets/chat.dart b/lib/src/widgets/chat.dart index 9f5e8181..c61e8205 100644 --- a/lib/src/widgets/chat.dart +++ b/lib/src/widgets/chat.dart @@ -27,6 +27,7 @@ class Chat extends StatefulWidget { this.dateFormat, this.dateLocale, this.disableImageGallery, + this.emptyState, this.isAttachmentUploading, this.isLastPage, this.l10n = const ChatL10nEn(), @@ -45,7 +46,6 @@ class Chat extends StatefulWidget { this.timeFormat, this.usePreviewData = true, required this.user, - this.emptyState, }) : super(key: key); /// See [Message.buildCustomMessage] @@ -75,6 +75,11 @@ class Chat extends StatefulWidget { /// Disable automatic image preview on tap. final bool? disableImageGallery; + /// Allows you to change what the user sees when there are no messages. + /// `emptyChatPlaceholder` and `emptyChatPlaceholderTextStyle` are ignored + /// in this case. + final Widget? emptyState; + /// See [Input.isAttachmentUploading] final bool? isAttachmentUploading; @@ -139,9 +144,6 @@ class Chat extends StatefulWidget { /// See [InheritedUser.user] final types.User user; - /// Allows you to change what the user sees when there are no messages - final Widget? emptyState; - @override _ChatState createState() => _ChatState(); } @@ -180,6 +182,21 @@ class _ChatState extends State { } } + Widget _buildEmptyState() { + return widget.emptyState ?? + Container( + alignment: Alignment.center, + margin: const EdgeInsets.symmetric( + horizontal: 24, + ), + child: Text( + widget.l10n.emptyChatPlaceholder, + style: widget.theme.emptyChatPlaceholderTextStyle, + textAlign: TextAlign.center, + ), + ); + } + Widget _buildImageGallery() { return Dismissible( key: const Key('photo_view_gallery'), @@ -360,19 +377,4 @@ class _ChatState extends State { ), ); } - - Widget _buildEmptyState() { - return widget.emptyState ?? - Container( - alignment: Alignment.center, - margin: const EdgeInsets.symmetric( - horizontal: 24, - ), - child: Text( - widget.l10n.emptyChatPlaceholder, - style: widget.theme.emptyChatPlaceholderTextStyle, - textAlign: TextAlign.center, - ), - ); - } }