-
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 Fixed animation code #1002
feat: Added the Fixed animation code #1002
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 fixed animation feature for the badge display. It includes new utility functions for converting data formats, animation logic, and updates to the UI to support the new animation functionality. 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 and they look great!
Here's what I looked at during the review
- 🟡 General issues: 3 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 output array size dynamic
The function uses a fixed size of 11 for the outer list. This might cause issues if the input doesn't align with this expectation. Consider making the size dynamic based on the input or adding input validation.
List<List<int>> byteArrayToBinaryArray(List<int> byteArray) {
int size = (byteArray.length * 8 + 7) ~/ 8;
List<List<int>> binaryArray = List.generate(size, (_) => []);
_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): Consider debouncing the text input listener
To improve performance, consider debouncing the input listener. This will reduce the frequency of updates, especially when the user is typing quickly, and can help prevent unnecessary processing.
Timer? _debounce;
void _controllerListener() {
if (_debounce?.isActive ?? false) _debounce!.cancel();
_debounce = Timer(const Duration(milliseconds: 300), () {
logger.d('Controller Listener : ${inlineImageProvider.getController().text}');
});
}
const Duration aniFlashSpeed = Duration(microseconds: 500000); // in uS | ||
|
||
// Function to calculate animation speed based on speed level | ||
int aniSpeedStrategy(int speedLevel) { |
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 using an enum for speed levels
Using an enum for speed levels instead of raw integers would make the code more type-safe and self-documenting. This can help prevent errors and improve code readability.
enum SpeedLevel { slow, medium, fast, veryFast }
int aniSpeedStrategy(SpeedLevel level) {
final int speedFactor = SpeedLevel.values.indexOf(level);
return aniBaseSpeed.inMicroseconds -
(speedFactor * aniBaseSpeed.inMicroseconds ~/ 8);
}
Summary by Sourcery
Add new animation capabilities for badge displays, including left, right, and fixed animations. Refactor the badge drawing logic to use a new provider for better state management and introduce utility functions for data conversion. Clean up the code by removing unused logging statements.
New Features:
Enhancements:
Chores: