-
Notifications
You must be signed in to change notification settings - Fork 177
feat: 🌟 use column instead of stack to remove arbitrary paddings #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,83 +211,97 @@ 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( | ||
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, | ||
fallbackTitle: "Loading…", | ||
chatViewState: chatViewState, | ||
) | ||
else if (chatViewState.noMessages) | ||
ChatViewStateWidget( | ||
chatViewStateWidgetConfig: | ||
chatViewStateConfig?.noMessageWidgetConfig, | ||
fallbackTitle: "No messages yet.", | ||
chatViewState: chatViewState, | ||
onReloadButtonTap: | ||
chatViewStateConfig?.onReloadButtonTap, | ||
) | ||
else if (chatViewState.isError) | ||
ChatViewStateWidget( | ||
chatViewStateWidgetConfig: | ||
chatViewStateConfig?.errorWidgetConfig, | ||
fallbackTitle: "Error", | ||
chatViewState: chatViewState, | ||
onReloadButtonTap: | ||
chatViewStateConfig?.onReloadButtonTap, | ||
) | ||
else if (chatViewState.hasMessages) | ||
Stack( | ||
clipBehavior: Clip.none, | ||
children: [ | ||
Positioned.fill( | ||
bottom: -MediaQuery.of(context).size.height, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, this should be as big as the textfield is and not some large value like screen height. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cannot know how large the Textfield is, because the Textfield is built after the chat list. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found a different solution, let me know what you think after my next push. |
||
child: ValueListenableBuilder<ReplyMessage>( | ||
valueListenable: replyMessage, | ||
builder: (_, state, child) { | ||
return ChatListWidget( | ||
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(), | ||
jonasbadstuebner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
][0], | ||
jonasbadstuebner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
if (featureActiveConfig.enableTextField) | ||
SendMessageWidget( | ||
key: _sendMessageKey, | ||
chatController: chatController, | ||
sendMessageBuilder: widget.sendMessageBuilder, | ||
sendMessageConfig: widget.sendMessageConfig, | ||
backgroundColor: Colors.transparent, | ||
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, | ||
), | ||
], | ||
), | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ class ChatViewStateWidget extends StatelessWidget { | |
const ChatViewStateWidget({ | ||
Key? key, | ||
this.chatViewStateWidgetConfig, | ||
required this.fallbackTitle, | ||
required this.chatViewState, | ||
this.onReloadButtonTap, | ||
}) : super(key: key); | ||
|
@@ -17,6 +18,9 @@ class ChatViewStateWidget extends StatelessWidget { | |
/// Provides current state of chat view. | ||
final ChatViewState chatViewState; | ||
|
||
/// Fallback if no title is given via config. | ||
final String fallbackTitle; | ||
|
||
/// Provides callback when user taps on reload button in error and no messages | ||
/// state. | ||
final VoidCallBack? onReloadButtonTap; | ||
|
@@ -31,7 +35,8 @@ class ChatViewStateWidget extends StatelessWidget { | |
children: [ | ||
Text( | ||
(chatViewStateWidgetConfig?.title | ||
.getChatViewStateTitle(chatViewState))!, | ||
.getChatViewStateTitle(chatViewState)) ?? | ||
fallbackTitle, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will compulsorily show the title even when the end user may not want it. Please revert this change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a good argument against the current usage:
So the I suggest we fall back to a default title and just hide the Text widget if the title is |
||
style: chatViewStateWidgetConfig?.titleTextStyle ?? | ||
const TextStyle( | ||
fontSize: 22, | ||
|
Uh oh!
There was an error while loading. Please reload this page.