-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: improve chat message animations #7890
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
Conversation
Reviewer's GuideThis pull request significantly improves chat message animations and list behavior by refactoring the main chat list to use Sequence Diagram for New Message Handling in ChatAnimatedListsequenceDiagram
participant User as U
participant ChatController as CC
participant ChatAnimatedListState as CALS
participant ItemScrollController as ISC
CC->>CALS: New message received (triggers _onInserted)
CALS->>CALS: _onInserted(position, data)
alt If message is the last and by current user
CALS->>CALS: _scrollLastMessageToTop(data)
CALS->>ISC: scrollTo(index, duration, curve)
end
Sequence Diagram for User Scrolling to Bottom of ChatsequenceDiagram
actor User
participant ScrollToBottomButton as STBB
participant ChatAnimatedListState as CALS
participant ItemScrollController as ISC
participant "_scrollToBottomController (AnimationController)" as AnimCtrl
User->>STBB: Clicks "Scroll to Bottom"
STBB->>CALS: Calls _handleScrollToBottom()
CALS->>AnimCtrl: reverse() (hides button)
CALS->>ISC: scrollTo(index, alignment, duration, curve) to scroll to end
Class Diagram: ChatAnimatedListState RefactorclassDiagram
class ChatAnimatedListState {
-ScrollOffsetController scrollOffsetController
-ItemScrollController itemScrollController
-ScrollOffsetListener scrollOffsetListener
-ItemPositionsListener itemPositionsListener
-int _lastUserMessageIndex
-bool _isScrollingToBottom
+initState()
+dispose()
+build(BuildContext context) Widget
-_handleScrollToBottom() void
-_handleToggleScrollToBottom() void
-_onInserted(int position, Message data) void
-_scrollLastMessageToTop(Message data) void
}
note for ChatAnimatedListState "Refactored to use ScrollablePositionedList for improved scrolling and animation. Removed _userHasScrolled and related logic. Updated message insertion and scroll handling methods."
Class Diagram: BulletedListIcon RefactorclassDiagram
BulletedListIcon --|> StatefulWidget
_BulletedListIconState --|> State
BulletedListIcon ..> _BulletedListIconState : creates
class BulletedListIcon {
+Node node
+final List~String~ bulletedListIcons
+createState() _BulletedListIconState
}
class _BulletedListIconState {
-int index
-double size
+void initState()
+Widget build(BuildContext context)
-int get level
}
note for BulletedListIcon "Refactored from StatelessWidget to StatefulWidget to dynamically update icon based on nesting level, improving rendering performance and correctness."
Class Diagram: New ChatMessage WidgetclassDiagram
ChatMessage --|> StatelessWidget
class ChatMessage {
+final Message message
+final Widget child
+final AlignmentGeometry sentMessageAlignment
+final AlignmentGeometry receivedMessageAlignment
+final EdgeInsetsGeometry padding
+Widget build(BuildContext context)
}
note for ChatMessage "New widget to encapsulate chat message styling and alignment logic, promoting reusability and consistency."
Class Diagram: ReminderBloc Logging UpdateclassDiagram
class ReminderBloc {
-final DeepCollectionEquality _deepEquality
+ReminderBloc()
+StreamSubscription _fetchAllRemindersSubscription
}
note for ReminderBloc "Updated reminder fetching logic to use DeepCollectionEquality for comparing reminder ID sets. This reduces unnecessary logging when the reminder list hasn't actually changed."
Class Diagram: LoadChatMessageStatusReady UpdateclassDiagram
class LoadChatMessageStatusReady {
+View view
+UserProfilePB userProfile
+Widget build(BuildContext context)
}
LoadChatMessageStatusReady ..> ChatMessage : uses in chatMessageBuilder
LoadChatMessageStatusReady ..> ChatAnimationListWidget : configures
class ChatMessage
class ChatAnimationListWidget
note for LoadChatMessageStatusReady "Updated to use the new ChatMessage widget for rendering messages. Removed 'enableReversedList' property from ChatAnimationListWidget as part of the list behavior refactor."
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @LucasXu0 - I've reviewed your changes - here's some feedback:
- The transition from
SliverAnimatedList
toScrollablePositionedList
might alter how individual message insertion animations are handled; verify this aligns with the intended animation improvements. - The chat now scrolls the current user's last message towards the top on new message arrival; confirm this specific scrolling behavior is intended for all new messages.
- The fixed
400
pixel padding in chat lists could be made more adaptive, perhaps by relating it to screen height or making it a themeable constant.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -168,7 +168,7 @@ class ChatAnimatedListReversedState extends State<ChatAnimatedListReversed> | |||
slivers: <Widget>[ | |||
SliverPadding( | |||
padding: EdgeInsets.only( | |||
top: widget.bottomPadding ?? 0, | |||
top: 400, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Hard-coded top padding value may need review.
Verify that the 400px top padding is intentional and adapts correctly to various screen sizes and orientations.
Feature Preview
PR Checklist
Summary by Sourcery
Improve chat message animations and scrolling behavior in the AppFlowy chat interface
New Features:
Enhancements:
Chores: