Skip to content

Commit

Permalink
feat: 🌟 use column instead of stack to remove arbitrary paddings
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbadstuebner committed Jun 17, 2024
1 parent 232214c commit 425f716
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 87 deletions.
12 changes: 3 additions & 9 deletions lib/src/widgets/chat_groupedlist_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,12 @@ class _ChatGroupedListWidgetState extends State<ChatGroupedListWidget>
valueListenable: ChatViewInheritedWidget.of(context)!
.chatController
.newSuggestions,
builder: (context, value, child) {
return SuggestionList(
suggestions: value,
);
},
builder: (context, value, child) => SuggestionList(
suggestions: value,
),
),
),
),

// Adds bottom space to the message list, ensuring it is displayed
// above the message text field.
const SizedBox(height: 100),
],
),
);
Expand Down
157 changes: 79 additions & 78 deletions lib/src/widgets/chat_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,85 +220,86 @@ class _ChatViewState extends State<ChatView>
children: [
if (widget.appBar != null) widget.appBar!,
Expanded(
child: Stack(
children: [
if (chatViewState.isLoading)
ChatViewStateWidget(
chatViewStateWidgetConfig:
chatViewStateConfig?.loadingWidgetConfig,
chatViewState: chatViewState,
)
else if (chatViewState.noMessages)
ChatViewStateWidget(
chatViewStateWidgetConfig:
chatViewStateConfig?.noMessageWidgetConfig,
chatViewState: chatViewState,
onReloadButtonTap:
chatViewStateConfig?.onReloadButtonTap,
)
else if (chatViewState.isError)
ChatViewStateWidget(
chatViewStateWidgetConfig:
chatViewStateConfig?.errorWidgetConfig,
chatViewState: chatViewState,
onReloadButtonTap:
chatViewStateConfig?.onReloadButtonTap,
)
else if (chatViewState.hasMessages)
ValueListenableBuilder<ReplyMessage>(
valueListenable: replyMessage,
builder: (_, state, child) {
return ChatListWidget(
showTypingIndicator:
chatController.showTypingIndicator,
replyMessage: state,
chatController: widget.chatController,
chatBackgroundConfig: widget.chatBackgroundConfig,
reactionPopupConfig: widget.reactionPopupConfig,
typeIndicatorConfig: widget.typeIndicatorConfig,
chatBubbleConfig: widget.chatBubbleConfig,
loadMoreData: widget.loadMoreData,
isLastPage: widget.isLastPage,
replyPopupConfig: widget.replyPopupConfig,
loadingWidget: widget.loadingWidget,
messageConfig: widget.messageConfig,
profileCircleConfig: widget.profileCircleConfig,
repliedMessageConfig: widget.repliedMessageConfig,
swipeToReplyConfig: widget.swipeToReplyConfig,
onChatListTap: widget.onChatListTap,
assignReplyMessage: (message) => _sendMessageKey
.currentState
?.assignReplyMessage(message),
emojiPickerSheetConfig:
widget.emojiPickerSheetConfig,
);
},
),
if (featureActiveConfig.enableTextField)
SendMessageWidget(
key: _sendMessageKey,
chatController: chatController,
sendMessageBuilder: widget.sendMessageBuilder,
sendMessageConfig: widget.sendMessageConfig,
backgroundColor: chatBackgroundConfig.backgroundColor,
onSendTap: (message, replyMessage, messageType) {
if (context.suggestionsConfig
?.autoDismissOnSelection ??
true) {
chatController.removeReplySuggestions();
}
_onSendTap(message, replyMessage, messageType);
},
onReplyCallback: (reply) =>
replyMessage.value = reply,
onReplyCloseCallback: () =>
replyMessage.value = const ReplyMessage(),
messageConfig: widget.messageConfig,
replyMessageBuilder: widget.replyMessageBuilder,
),
],
),
child: [
if (chatViewState.isLoading)
ChatViewStateWidget(
chatViewStateWidgetConfig:
chatViewStateConfig?.loadingWidgetConfig,
chatViewState: chatViewState,
)
else if (chatViewState.noMessages)
ChatViewStateWidget(
chatViewStateWidgetConfig:
chatViewStateConfig?.noMessageWidgetConfig,
chatViewState: chatViewState,
onReloadButtonTap:
chatViewStateConfig?.onReloadButtonTap,
)
else if (chatViewState.isError)
ChatViewStateWidget(
chatViewStateWidgetConfig:
chatViewStateConfig?.errorWidgetConfig,
chatViewState: chatViewState,
onReloadButtonTap:
chatViewStateConfig?.onReloadButtonTap,
)
else if (chatViewState.hasMessages)
ValueListenableBuilder<ReplyMessage>(
valueListenable: replyMessage,
builder: (_, state, child) {
return ChatListWidget(
showTypingIndicator:
chatController.showTypingIndicator,
replyMessage: state,
chatController: widget.chatController,
chatBackgroundConfig: widget.chatBackgroundConfig,
reactionPopupConfig: widget.reactionPopupConfig,
typeIndicatorConfig: widget.typeIndicatorConfig,
chatBubbleConfig: widget.chatBubbleConfig,
loadMoreData: widget.loadMoreData,
isLastPage: widget.isLastPage,
replyPopupConfig: widget.replyPopupConfig,
loadingWidget: widget.loadingWidget,
messageConfig: widget.messageConfig,
profileCircleConfig: widget.profileCircleConfig,
repliedMessageConfig: widget.repliedMessageConfig,
swipeToReplyConfig: widget.swipeToReplyConfig,
onChatListTap: widget.onChatListTap,
assignReplyMessage: (message) => _sendMessageKey
.currentState
?.assignReplyMessage(message),
emojiPickerSheetConfig:
widget.emojiPickerSheetConfig,
);
},
)
else
Container(),
][0],
),
if (featureActiveConfig.enableTextField)
Padding(
padding: const EdgeInsets.only(top: 8),
child: SendMessageWidget(
key: _sendMessageKey,
chatController: chatController,
sendMessageBuilder: widget.sendMessageBuilder,
sendMessageConfig: widget.sendMessageConfig,
backgroundColor: chatBackgroundConfig.backgroundColor,
onSendTap: (message, replyMessage, messageType) {
if (context.suggestionsConfig?.autoDismissOnSelection ??
true) {
chatController.removeReplySuggestions();
}
_onSendTap(message, replyMessage, messageType);
},
onReplyCallback: (reply) => replyMessage.value = reply,
onReplyCloseCallback: () =>
replyMessage.value = const ReplyMessage(),
messageConfig: widget.messageConfig,
replyMessageBuilder: widget.replyMessageBuilder,
),
),
],
),
);
Expand Down

0 comments on commit 425f716

Please sign in to comment.