Skip to content

Commit

Permalink
Fixes after PR
Browse files Browse the repository at this point in the history
  • Loading branch information
demchenkoalex committed Jul 13, 2021
1 parent bc179e0 commit e875008
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
40 changes: 21 additions & 19 deletions lib/src/widgets/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Chat extends StatefulWidget {
this.dateFormat,
this.dateLocale,
this.disableImageGallery,
this.emptyState,
this.isAttachmentUploading,
this.isLastPage,
this.l10n = const ChatL10nEn(),
Expand All @@ -45,7 +46,6 @@ class Chat extends StatefulWidget {
this.timeFormat,
this.usePreviewData = true,
required this.user,
this.emptyState,
}) : super(key: key);

/// See [Message.buildCustomMessage]
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -180,6 +182,21 @@ class _ChatState extends State<Chat> {
}
}

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'),
Expand Down Expand Up @@ -360,19 +377,4 @@ class _ChatState extends State<Chat> {
),
);
}

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,
),
);
}
}

0 comments on commit e875008

Please sign in to comment.