Skip to content
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 screen for draw clipart functionality #976

Merged
merged 11 commits into from
Jul 31, 2024

Conversation

Jhalakupadhyay
Copy link
Contributor

@Jhalakupadhyay Jhalakupadhyay commented Jul 25, 2024

#975 #978

Summary by Sourcery

This pull request introduces a new screen for drawing clipart, complete with a custom painter for rendering a grid-based badge. It also adds a navigation drawer to the home screen for easier navigation and refactors the badge rendering logic for improved flexibility.

  • New Features:
    • Introduced a new screen for drawing clipart, including a custom painter for rendering the badge grid.
    • Added a navigation drawer with options to navigate to the home screen and the new draw clipart screen.
  • Enhancements:
    • Refactored the badge rendering logic to use a grid-based approach for better flexibility and maintainability.
    • Updated the home screen to include a navigation drawer and improved badge display.

Copy link
Contributor

sourcery-ai bot commented Jul 25, 2024

Reviewer's Guide by Sourcery

This pull request introduces a new screen for drawing clipart on badges. The implementation refactors the badge drawing logic to use a grid-based approach with a custom painter, adds state management for drawing and erasing, and integrates a new draw badge screen with a navigation drawer.

File-Level Changes

Files Changes
lib/virtualbadge/view/cell.dart
lib/virtualbadge/view/draw_badge_UI.dart
lib/virtualbadge/widgets/badgeWidget.dart
Refactored badge drawing logic to use a grid-based approach with a custom painter.
lib/providers/imageprovider.dart
lib/view/drawBadgeScreen.dart
Implemented state management for drawing and erasing on the badge.
lib/main.dart
lib/view/homescreen.dart
lib/view/widgets/navigation_drawer.dart
Added navigation drawer and integrated new draw badge screen.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Widget build(BuildContext context) {
InlineImageProvider drawToggle = Provider.of<InlineImageProvider>(context);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
SystemChrome.setPreferredOrientations([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Use OrientationBuilder for more robust orientation management

Instead of manually setting orientations, consider using OrientationBuilder for more robust and flexible orientation management across different parts of the app.

Suggested change
SystemChrome.setPreferredOrientations([
return OrientationBuilder(
builder: (context, orientation) {
if (orientation == Orientation.landscape) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
}
return Scaffold(
// Your existing widget tree here
);
},
);

Container(
margin: EdgeInsets.symmetric(vertical: 20.h, horizontal: 20.w),
padding: EdgeInsets.all(10.dg),
height: 400.h,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Use more flexible sizing instead of fixed dimensions

The use of fixed sizes with ScreenUtil might cause issues on different device sizes. Consider using more flexible sizing approaches, such as AspectRatio or LayoutBuilder, to ensure proper rendering across various devices.

Suggested change
height: 400.h,
height: MediaQuery.of(context).size.height * 0.5,

InlineImageProvider cellStateToggle =
Provider.of<InlineImageProvider>(context);
return CustomPaint(
size: const Size(400, 480),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Use available space instead of fixed size for CustomPaint

Using a fixed size for the CustomPaint widget could cause rendering issues on different screen sizes. Consider using the available space or a responsive sizing approach to ensure the badge scales properly across different devices.

Suggested change
size: const Size(400, 480),
return LayoutBuilder(
builder: (context, constraints) {
return CustomPaint(
size: Size(constraints.maxWidth, constraints.maxHeight),
painter: BadgePainter(grid: cellStateToggle.getGrid()),
);
},
);

@override
State<Cell> createState() => _CellState();
}
class BadgePainter extends CustomPainter {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename the class to badge_painter.dart

Comment on lines 45 to 61
appBar: AppBar(
leading: Builder(builder: (context) {
return IconButton(
onPressed: () {
Scaffold.of(context).openDrawer();
},
icon: const Icon(
Icons.menu,
color: Colors.white,
));
}),
backgroundColor: Colors.red,
title: const Text(
'Badge Magic',
style: TextStyle(color: Colors.white),
),
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should create a common class which will encapsulate this logic, rather than duplicating it. We need to manage the drawer from one class. You can then have these hooks which inject the content and creates the entire page for you

@adityastic adityastic merged commit 7595618 into fossasia:flutter_app Jul 31, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants