-
Notifications
You must be signed in to change notification settings - Fork 208
feat: ✨ Add Animation in ChatViewList #371
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
feat: ✨ Add Animation in ChatViewList #371
Conversation
cfb7bff to
e62a92b
Compare
example/lib/chat_operations.dart
Outdated
| sentBy: 'User', | ||
| id: 'msg-${DateTime.now().millisecondsSinceEpoch}', | ||
| ), | ||
| settings: const ChatSettings( |
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.
This should be default.
| if (_searchResultMap != null) { | ||
| if (_searchResultMap?.containsKey(chatId) ?? false) { | ||
| _searchResultMap?.remove(chatId); | ||
| if (_chatListStreamController.isClosed) return; | ||
| animatedList.currentState?.removeItemByKey(chatId); | ||
| _chatListStreamController.add(_searchResultMap ?? chatListMap); | ||
| } | ||
| return; | ||
| } | ||
| if (_chatListStreamController.isClosed) return; | ||
| animatedList.currentState?.removeItemByKey(chatId); | ||
| _chatListStreamController.add(chatListMap); |
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.
Please restructure this.
| _chatListStreamController.add(chatListMap); | ||
| animatedList.currentState?.addChatItem( | ||
| chat, | ||
| isPinned: (item) => item.settings.pinStatus.isPinned, |
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.
This can be the default function.
| final message = messages[i]; | ||
| _messageKeys.putIfAbsent(message.id, () => GlobalKey()); |
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.
This wouldn't run if separator is disabled by the user.
| : const SizedBox.shrink( | ||
| key: ValueKey('pinIcon-empty'), | ||
| ), |
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.
You can take this inside of IconScaleAnimation and provide key to icon inside as well.
| final removedKeys = | ||
| oldPositions.keys.where((key) => !newItemKeys.contains(key)).toList(); |
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.
I believe you can accommodate this in the above loops.
| ..currentIndex = i; | ||
| } else { | ||
| // New item - only initialize if not already handled by addItem methods | ||
| if (!_itemStates.containsKey(key)) { |
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.
Please invert the condition for better readability.
| itemState.moveController.reset(); | ||
| itemState.moveController.forward().then((_) { |
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.
Please utilise cascade notation.
| // Create animation controller for new item | ||
| final moveController = AnimationController( | ||
| duration: widget.animationDuration, | ||
| vsync: this, | ||
| ); | ||
|
|
||
| _itemStates[key] = _ItemState<T>( | ||
| moveController: moveController, | ||
| item: newItem, | ||
| currentIndex: position, | ||
| ); | ||
| _itemKeys[key] = GlobalKey(); |
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.
This section seems to be repeated. Can you please extract it to a function?.
|
|
||
| setState(() { | ||
| // Only animate if new item is added at top and should animate | ||
| if (_isNewItemAddedAtTop) { |
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.
Please invert the condition for better readability.
e62a92b to
fd42228
Compare
ffe4325 to
679b038
Compare
679b038 to
02c61a7
Compare
Description
Checklist
fix:,feat:,docs:etc).docsand added dartdoc comments with///.examplesordocs.Breaking Change?