-
Notifications
You must be signed in to change notification settings - Fork 213
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: Added the scroll down animation #1005
feat: Added the scroll down animation #1005
Conversation
…badge. feat: Added the modes support for left right top down fixed and animation support for flash and marquee. animation right
Reviewer's Guide by SourceryThis pull request implements a scroll down animation feature for a badge display system. The changes include new utility functions for byte array and binary conversions, modifications to the badge view and animation logic, and the addition of new animation classes. File-Level Changes
Tips
|
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 @Jhalakupadhyay - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding more explanatory comments for complex animation calculations, especially in the DrawBadgeProvider class.
- Ensure all references to drawbadge_provider.dart have been updated to badgeview_provider.dart throughout the project.
Here's what I looked at during the review
- 🟡 General issues: 5 issues 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 to tell me if it was helpful.
@@ -28,3 +28,56 @@ List<int> hexStringToByteArray(String hexString) { | |||
logger.d(data.length); | |||
return data; | |||
} | |||
|
|||
List<List<int>> byteArrayToBinaryArray(List<int> byteArray) { |
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.
suggestion: Consider making the byteArrayToBinaryArray function more flexible
The function assumes a fixed size of 11 rows, which might not be suitable for different badge sizes. Consider parameterizing the number of rows or deriving it from the input array size.
List<List<int>> byteArrayToBinaryArray(List<int> byteArray, {int? rows}) {
int numRows = rows ?? (byteArray.length * 8 + 7) ~/ 8;
List<List<int>> binaryArray = List.generate(numRows, (_) => []);
@@ -43,6 +43,22 @@ class Converters { | |||
return hexStrings; | |||
} | |||
|
|||
void badgeAnimation(String message) async { |
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.
suggestion: Refactor badgeAnimation function to improve separation of concerns
This function is doing too much - converting messages, manipulating data, and updating UI state. Consider splitting it into smaller, more focused functions and moving UI updates to a more appropriate place in the widget tree.
Future<void> processBadgeMessage(String message) async {
final convertedMessage = await convertMessage(message);
final badgeData = generateBadgeData(convertedMessage);
updateBadgeState(badgeData);
}
void updateBadgeState(List<List<int>> badgeData) {
// Update UI state here
}
_startImageCaching(); | ||
super.initState(); | ||
|
||
_tabController = TabController(length: 3, vsync: this); | ||
} | ||
|
||
void _controllerListner() { |
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.
issue: Fix typo in function name and reconsider its responsibilities
The function name has a typo ('Listner' should be 'Listener'). Also, this function is directly manipulating UI state through converters.badgeAnimation, which could make the code harder to test and maintain. Consider refactoring to improve separation of concerns.
} | ||
} | ||
|
||
void changeGridValue(List<List<int>> newGrid) { |
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.
suggestion: Refactor complex animation logic in changeGridValue
This function is quite complex and handles multiple responsibilities. Consider breaking it down into smaller, more focused functions. Also, replace magic numbers (like 11 and 44) with named constants or configurable parameters.
void changeGridValue(List<List<int>> newGrid) {
_updateGrid(newGrid);
_animateGridChanges();
}
void _updateGrid(List<List<int>> newGrid) {
// Implementation details...
}
void _animateGridChanges() {
// Implementation details...
}
AnimationController? _controller; | ||
int animationSpeed = aniBaseSpeed.inMilliseconds; | ||
int counter = 0; | ||
Timer? timer; |
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.
suggestion (performance): Consider using Flutter's animation framework instead of Timer
Using a Timer for animations might not provide the smoothest experience. Consider using Flutter's AnimationController for more efficient and smoother animations.
AnimationController? _animationController;
Summary by Sourcery
Add a new badge animation feature with various animation types and refactor the badge drawing logic by introducing a new BadgeViewProvider. Enhance data processing with new utility functions for byte and binary conversions, and clean up the code by removing unused logger statements.
New Features:
Enhancements:
Chores: