Skip to content

Commit 5624473

Browse files
feat: 🌟 use column instead of stack to remove arbitrary paddings
1 parent 232214c commit 5624473

File tree

4 files changed

+105
-88
lines changed

4 files changed

+105
-88
lines changed

lib/src/widgets/chat_groupedlist_widget.dart

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,15 @@ class _ChatGroupedListWidgetState extends State<ChatGroupedListWidget>
234234
valueListenable: ChatViewInheritedWidget.of(context)!
235235
.chatController
236236
.newSuggestions,
237-
builder: (context, value, child) {
238-
return SuggestionList(
239-
suggestions: value,
240-
);
241-
},
237+
builder: (context, value, child) => SuggestionList(
238+
suggestions: value,
239+
),
242240
),
243241
),
244242
),
245-
246-
// Adds bottom space to the message list, ensuring it is displayed
247-
// above the message text field.
248-
const SizedBox(height: 100),
243+
SizedBox(
244+
height: MediaQuery.of(context).size.height,
245+
),
249246
],
250247
),
251248
);

lib/src/widgets/chat_list_widget.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class _ChatListWidgetState extends State<ChatListWidget>
190190
valueListenable: showPopUp,
191191
builder: (_, showPopupValue, child) {
192192
return Stack(
193+
clipBehavior: Clip.none,
193194
children: [
194195
ChatGroupedListWidget(
195196
showPopUp: showPopupValue,

lib/src/widgets/chat_view.dart

Lines changed: 92 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -220,85 +220,99 @@ class _ChatViewState extends State<ChatView>
220220
children: [
221221
if (widget.appBar != null) widget.appBar!,
222222
Expanded(
223-
child: Stack(
224-
children: [
225-
if (chatViewState.isLoading)
226-
ChatViewStateWidget(
227-
chatViewStateWidgetConfig:
228-
chatViewStateConfig?.loadingWidgetConfig,
229-
chatViewState: chatViewState,
230-
)
231-
else if (chatViewState.noMessages)
232-
ChatViewStateWidget(
233-
chatViewStateWidgetConfig:
234-
chatViewStateConfig?.noMessageWidgetConfig,
235-
chatViewState: chatViewState,
236-
onReloadButtonTap:
237-
chatViewStateConfig?.onReloadButtonTap,
238-
)
239-
else if (chatViewState.isError)
240-
ChatViewStateWidget(
241-
chatViewStateWidgetConfig:
242-
chatViewStateConfig?.errorWidgetConfig,
243-
chatViewState: chatViewState,
244-
onReloadButtonTap:
245-
chatViewStateConfig?.onReloadButtonTap,
246-
)
247-
else if (chatViewState.hasMessages)
248-
ValueListenableBuilder<ReplyMessage>(
249-
valueListenable: replyMessage,
250-
builder: (_, state, child) {
251-
return ChatListWidget(
252-
showTypingIndicator:
253-
chatController.showTypingIndicator,
254-
replyMessage: state,
255-
chatController: widget.chatController,
256-
chatBackgroundConfig: widget.chatBackgroundConfig,
257-
reactionPopupConfig: widget.reactionPopupConfig,
258-
typeIndicatorConfig: widget.typeIndicatorConfig,
259-
chatBubbleConfig: widget.chatBubbleConfig,
260-
loadMoreData: widget.loadMoreData,
261-
isLastPage: widget.isLastPage,
262-
replyPopupConfig: widget.replyPopupConfig,
263-
loadingWidget: widget.loadingWidget,
264-
messageConfig: widget.messageConfig,
265-
profileCircleConfig: widget.profileCircleConfig,
266-
repliedMessageConfig: widget.repliedMessageConfig,
267-
swipeToReplyConfig: widget.swipeToReplyConfig,
268-
onChatListTap: widget.onChatListTap,
269-
assignReplyMessage: (message) => _sendMessageKey
270-
.currentState
271-
?.assignReplyMessage(message),
272-
emojiPickerSheetConfig:
273-
widget.emojiPickerSheetConfig,
274-
);
275-
},
276-
),
277-
if (featureActiveConfig.enableTextField)
278-
SendMessageWidget(
279-
key: _sendMessageKey,
280-
chatController: chatController,
281-
sendMessageBuilder: widget.sendMessageBuilder,
282-
sendMessageConfig: widget.sendMessageConfig,
283-
backgroundColor: chatBackgroundConfig.backgroundColor,
284-
onSendTap: (message, replyMessage, messageType) {
285-
if (context.suggestionsConfig
286-
?.autoDismissOnSelection ??
287-
true) {
288-
chatController.removeReplySuggestions();
289-
}
290-
_onSendTap(message, replyMessage, messageType);
291-
},
292-
onReplyCallback: (reply) =>
293-
replyMessage.value = reply,
294-
onReplyCloseCallback: () =>
295-
replyMessage.value = const ReplyMessage(),
296-
messageConfig: widget.messageConfig,
297-
replyMessageBuilder: widget.replyMessageBuilder,
298-
),
299-
],
300-
),
223+
child: [
224+
if (chatViewState.isLoading)
225+
ChatViewStateWidget(
226+
chatViewStateWidgetConfig:
227+
chatViewStateConfig?.loadingWidgetConfig,
228+
fallbackTitle: "Loading…",
229+
chatViewState: chatViewState,
230+
)
231+
else if (chatViewState.noMessages)
232+
ChatViewStateWidget(
233+
chatViewStateWidgetConfig:
234+
chatViewStateConfig?.noMessageWidgetConfig,
235+
fallbackTitle: "No messages yet.",
236+
chatViewState: chatViewState,
237+
onReloadButtonTap:
238+
chatViewStateConfig?.onReloadButtonTap,
239+
)
240+
else if (chatViewState.isError)
241+
ChatViewStateWidget(
242+
chatViewStateWidgetConfig:
243+
chatViewStateConfig?.errorWidgetConfig,
244+
fallbackTitle: "Error",
245+
chatViewState: chatViewState,
246+
onReloadButtonTap:
247+
chatViewStateConfig?.onReloadButtonTap,
248+
)
249+
else if (chatViewState.hasMessages)
250+
Stack(
251+
clipBehavior: Clip.none,
252+
children: [
253+
Positioned.fill(
254+
bottom: -MediaQuery.of(context).size.height,
255+
child: ValueListenableBuilder<ReplyMessage>(
256+
valueListenable: replyMessage,
257+
builder: (_, state, child) {
258+
return ChatListWidget(
259+
showTypingIndicator:
260+
chatController.showTypingIndicator,
261+
replyMessage: state,
262+
chatController: widget.chatController,
263+
chatBackgroundConfig:
264+
widget.chatBackgroundConfig,
265+
reactionPopupConfig:
266+
widget.reactionPopupConfig,
267+
typeIndicatorConfig:
268+
widget.typeIndicatorConfig,
269+
chatBubbleConfig: widget.chatBubbleConfig,
270+
loadMoreData: widget.loadMoreData,
271+
isLastPage: widget.isLastPage,
272+
replyPopupConfig: widget.replyPopupConfig,
273+
loadingWidget: widget.loadingWidget,
274+
messageConfig: widget.messageConfig,
275+
profileCircleConfig:
276+
widget.profileCircleConfig,
277+
repliedMessageConfig:
278+
widget.repliedMessageConfig,
279+
swipeToReplyConfig: widget.swipeToReplyConfig,
280+
onChatListTap: widget.onChatListTap,
281+
assignReplyMessage: (message) =>
282+
_sendMessageKey.currentState
283+
?.assignReplyMessage(message),
284+
emojiPickerSheetConfig:
285+
widget.emojiPickerSheetConfig,
286+
);
287+
},
288+
),
289+
)
290+
],
291+
)
292+
else
293+
Container(),
294+
][0],
301295
),
296+
if (featureActiveConfig.enableTextField)
297+
SendMessageWidget(
298+
key: _sendMessageKey,
299+
chatController: chatController,
300+
sendMessageBuilder: widget.sendMessageBuilder,
301+
sendMessageConfig: widget.sendMessageConfig,
302+
backgroundColor: Colors.transparent,
303+
onSendTap: (message, replyMessage, messageType) {
304+
if (context.suggestionsConfig?.autoDismissOnSelection ??
305+
true) {
306+
chatController.removeReplySuggestions();
307+
}
308+
_onSendTap(message, replyMessage, messageType);
309+
},
310+
onReplyCallback: (reply) => replyMessage.value = reply,
311+
onReplyCloseCallback: () =>
312+
replyMessage.value = const ReplyMessage(),
313+
messageConfig: widget.messageConfig,
314+
replyMessageBuilder: widget.replyMessageBuilder,
315+
),
302316
],
303317
),
304318
);

lib/src/widgets/chatview_state_widget.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class ChatViewStateWidget extends StatelessWidget {
66
const ChatViewStateWidget({
77
Key? key,
88
this.chatViewStateWidgetConfig,
9+
required this.fallbackTitle,
910
required this.chatViewState,
1011
this.onReloadButtonTap,
1112
}) : super(key: key);
@@ -17,6 +18,9 @@ class ChatViewStateWidget extends StatelessWidget {
1718
/// Provides current state of chat view.
1819
final ChatViewState chatViewState;
1920

21+
/// Fallback if no title is given via config.
22+
final String fallbackTitle;
23+
2024
/// Provides callback when user taps on reload button in error and no messages
2125
/// state.
2226
final VoidCallBack? onReloadButtonTap;
@@ -31,7 +35,8 @@ class ChatViewStateWidget extends StatelessWidget {
3135
children: [
3236
Text(
3337
(chatViewStateWidgetConfig?.title
34-
.getChatViewStateTitle(chatViewState))!,
38+
.getChatViewStateTitle(chatViewState)) ??
39+
fallbackTitle,
3540
style: chatViewStateWidgetConfig?.titleTextStyle ??
3641
const TextStyle(
3742
fontSize: 22,

0 commit comments

Comments
 (0)