-
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 snowflake animation #1008
feat: Added the snowflake animation #1008
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 new snowflake animation feature for the badge display, along with several refactoring changes to improve the animation system and badge rendering. The changes include new utility functions for binary conversions, a restructured animation framework, and updates to the badge view and drawing logic. 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 refactoring the DrawBadgeProvider class to reduce its responsibilities. It's currently handling too many aspects of the application and could benefit from being split into more focused classes or services.
- Look into abstracting common animation logic to reduce code duplication across different animation classes. This could improve maintainability and make it easier to add new animations in the future.
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.
|
||
String hexToBin(String hex) { | ||
// Convert hex to binary string | ||
String binaryString = BigInt.parse(hex, radix: 16).toRadixString(2); |
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): Reconsider using BigInt for hex to binary conversion
Using BigInt ensures accuracy for large numbers, but it might be overkill for typical use cases and could impact performance. Consider using standard integer operations if the input size allows it.
String binaryString = BigInt.parse(hex, radix: 16).toRadixString(2); | |
String binaryString = int.parse(hex, radix: 16).toRadixString(2).padLeft((hex.length * 4), '0'); |
@@ -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: Split badgeAnimation function for better separation of concerns
This function is doing too much - both preparing the data and triggering the animation. Consider splitting it into separate functions for data preparation and animation triggering. This will improve readability and make the code easier to maintain and test.
Future<void> prepareBadgeData(String message) async {
// Data preparation logic here
}
Future<void> triggerBadgeAnimation() async {
// Animation triggering logic here
}
void badgeAnimation(String message) async {
await prepareBadgeData(message);
await triggerBadgeAnimation();
}
_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.
suggestion (performance): Implement debouncing for text input handling
Calling badgeAnimation on every text change could lead to performance issues with long text or rapid typing. Consider implementing a debounce mechanism to limit the frequency of these calls.
Timer? _debounceTimer;
void _controllerListener() {
if (_debounceTimer?.isActive ?? false) _debounceTimer!.cancel();
_debounceTimer = Timer(const Duration(milliseconds: 300), () {
logger.d('Controller Listener : ${inlineImageProvider.getController().text}');
// Add your badgeAnimation call here
});
}
} | ||
} | ||
|
||
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 changeGridValue function for improved readability
This function is quite complex and handles multiple responsibilities. Consider breaking it down into smaller, more focused functions to improve readability and maintainability.
void changeGridValue(List<List<int>> newGrid) {
_validateGridDimensions(newGrid);
_updateGrid(newGrid);
_notifyListeners();
}
void _validateGridDimensions(List<List<int>> grid) {
if (grid.length != homeViewGrid.length || grid[0].length != homeViewGrid[0].length) {
throw ArgumentError('New grid dimensions do not match existing grid');
}
}
@@ -0,0 +1,15 @@ | |||
abstract class BadgeAnimation { |
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: Simplify animation method signature using a parameter object
The animation method has many parameters, which can make it hard to use and maintain. Consider creating a parameter object to encapsulate these values, which would simplify the method signature and make it easier to add or remove parameters in the future.
abstract class BadgeAnimation {
void animation(BadgeAnimationParams params);
}
class BadgeAnimationParams {
final List<List<bool>> grid;
// Add other parameters here
BadgeAnimationParams({required this.grid});
}
#1007
Summary by Sourcery
Add a snowflake animation feature and refactor badge display logic to use a new provider system, enhancing the flexibility and control over badge animations. Introduce new animation classes for various effects and remove the deprecated provider.
New Features:
Enhancements:
badgeview_provider
, replacing the previousdrawbadge_provider
.Chores:
drawbadge_provider.dart
file as it has been replaced by the newbadgeview_provider
implementation.