Skip to content

feat: Enhanced UI and Functionality for the Select Screen #18

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

Merged
merged 2 commits into from
Apr 16, 2025

Conversation

Vishveshwara
Copy link
Contributor

@Vishveshwara Vishveshwara commented Apr 10, 2025

Fixes #17

Changes:

  • Added new DisplaySelectionScreen with grid layout for display selection

  • Created display cards with:

    1. Display preview images
    2. Color indicator dots
    3. Technical specs (resolution, aspect ratio, driver)
  • Implemented filter chips for All/Color/B&W/HD displays

  • Created DisplayModel class with:

    1. Display specifications
    2. Color parsing
    3. Aspect ratio calculation
    4. PPI calculation
  • Created DisplayProvider for:

    1. JSON data loading
    2. Filter management
    3. Selection state
    4. EPD class mapping
  • Added displays.json with display configurations for easy support for more displays.

Screenshot:
WhatsApp Image 2025-04-10 at 20 36 46_ecf0d77b

Summary by Sourcery

Implement a comprehensive display selection screen with advanced filtering and display information features for the ePaper application

New Features:

  • Create a new display selection screen with a grid layout for display options
  • Implement dynamic filtering of displays by type (Color, B&W, HD)
  • Add display cards with detailed technical specifications and preview images

Enhancements:

  • Develop a flexible DisplayModel class to manage display metadata
  • Create a DisplayProvider for managing display data and selection state
  • Implement a reusable display card widget with comprehensive display information

Chores:

  • Add displays.json configuration file for easy display management
  • Refactor main application routing to use new display selection screen

Copy link
Contributor

sourcery-ai bot commented Apr 10, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new display selection screen with enhanced UI and functionality. It includes display cards with preview images and technical specifications, filter chips for display types, a DisplayProvider for data management, and a DisplayModel class to represent display specifications. The changes also involve adding a JSON file for display configurations and updating the main application to include the new screen.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Introduced a new screen for display selection with a grid layout.
  • Created a new DisplaySelectionScreen widget.
  • Implemented a grid view to display available ePaper displays.
  • Added a header and subtitle for screen context.
  • Included a continue button to proceed to the image editor.
lib/view/display_selection_screen.dart
Implemented display cards to show display previews, color indicators, and technical specifications.
  • Created a DisplayCard widget to encapsulate display information.
  • Added display name and size to the card.
  • Included color indicator dots and color names.
  • Displayed technical specifications such as model, resolution, aspect ratio, and driver.
  • Added a border to indicate selection status.
lib/view/widget/display_card.dart
Added filter chips for display types (All, Color, B&W, HD).
  • Implemented filter chips to categorize displays.
  • Created a FilterChipOption widget for selectable filter options.
  • Managed active filter state using DisplayProvider.
  • Updated display grid based on the selected filter.
lib/view/display_selection_screen.dart
lib/view/widget/filter_chip_option.dart
Created a DisplayProvider to manage display data, filtering, and selection state.
  • Loaded display configurations from a JSON file.
  • Parsed display specifications, including colors and resolution.
  • Implemented filtering logic based on display type (All, Color, B&W, HD).
  • Managed the selected display state.
  • Mapped display configurations to EPD classes.
lib/provider/display_provider.dart
Defined a DisplayModel class to represent display specifications.
  • Included properties for display name, size, resolution, colors, and driver.
  • Added computed properties for color display, HD status, PPI, and aspect ratio.
  • Implemented color parsing and aspect ratio calculation.
lib/model/display_model.dart
Added a ColorDot widget to visually represent display colors.
  • Created a ColorDot widget to display a colored circle.
  • Added support for indicating selection status with a shadow effect.
lib/view/widget/color_dot.dart
Added a JSON file to store display configurations.
  • Created a displays.json file to store display configurations.
  • Included display properties such as name, size, resolution, colors, and driver.
assets/displays.json
Updated main.dart to include the DisplayProvider and DisplaySelectionScreen.
  • Added DisplayProvider to the MultiProvider.
  • Set DisplaySelectionScreen as the home screen.
lib/main.dart
Added image assets for displays.
  • Added assets/images/displays/ to pubspec.yaml.
  • Added assets/displays.json to pubspec.yaml.
pubspec.yaml

Assessment against linked issues

Issue Objective Addressed Explanation
#17 The app should support a wide range of displays from different vendors.
#17 The app should accommodate various sizes, color configurations, and other essential specifications of displays.
#17 Enhance the UI of the select display screen.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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 @Vishveshwara - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a consistent naming convention (e.g., camelCase) for model properties like ModelName.
  • The _getEpdForClassName method in DisplayProvider could be refactored to use a map for better readability and maintainability.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 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 and I'll use the feedback to improve your reviews.

@mariobehling
Copy link
Member

Thanks, please follow the colors same as in the badge magic app https://github.com/fossasia/badgemagic-app.

Use white as a background color for example.

@Vishveshwara
Copy link
Contributor Author

Thanks, please follow the colors same as in the badge magic app https://github.com/fossasia/badgemagic-app.

Use white as a background color for example.

Thank you for your feedback, please review the updated colors below:

Updated UI
WhatsApp Image 2025-04-11 at 00 01 59_9cc0c715

@mariobehling mariobehling requested a review from kienvo April 10, 2025 20:20
@mariobehling mariobehling merged commit 926d55b into fossasia:main Apr 16, 2025
2 of 3 checks passed
@AsCress
Copy link

AsCress commented Apr 16, 2025

@mariobehling We might want to review the logic used here. This doesn't align with the structure developed by @kienvo.
@kienvo Could you please see to this once ?
@Vishveshwara Also, please remove any LLM comments before you commit code. I also advise you to have a look at the logic and understand it first rather than relying on an LLM for the same.

@Vishveshwara
Copy link
Contributor Author

@AsCress
I appreciate the call for careful review, but I have to admit it’s a bit disheartening to have my core logic attributed to an LLM. While I did use an AI tool to draft a few inline comments for improving readability and improving the names of variables, every function and data model implementation was carefully thought by me to be scalable such as the json display handling and filter chips.

Copy link

@AsCress AsCress left a comment

Choose a reason for hiding this comment

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

@Vishveshwara Understand the fact that using an LLM to generate code isn't bad. However, if you do so, the code has to be cleaned properly before you commit it. LLM code contains numerous things which are either irrelevant / not needed. The right approach is to always get an understanding of where we are, what functionality we want to achieve and then decide upon an approach for the same which takes into account the exact requirements and constraints of the project, something which an LLM has no idea about.

@@ -0,0 +1,26 @@
{
Copy link

Choose a reason for hiding this comment

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

Why would be actually needing JSON storage for this ? The number of displays that we have to interact with are very limited and we already have an abstract class Epd, which is extended to model a display. Those classes could simply be modified to add whatever more parameters you want to show about the displays.

"colors": ["black", "white", "red"],
"driver": "UC8253",
"imagePath": "assets/images/displays/epaper_3.7_bwr.png",
"epdClass": "Gdey037z03"
Copy link

Choose a reason for hiding this comment

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

Also, how is this approach scalable, when we are anyways creating a new class for any new display that we want to add ?


//Colors used in the app
// Primary Colors
const Color colorPrimary = Color(0xFFD32F2F); // You can adjust this color value
Copy link

Choose a reason for hiding this comment

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

Please remove any such LLM comments before committing code.
If you do want to add comments to your code, add proper documentation comments for every function you add, so that it could also be used to generate documentation.


void main() {
runApp(MultiProvider(providers: [
ChangeNotifierProvider(create: (context) => ImageLoader()),
ChangeNotifierProvider(create: (context) => DisplayProvider()),
Copy link

Choose a reason for hiding this comment

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

DisplayProvider() is something which we are using to manage and select displays only. There's no need to register it as a ChangeNotifierProvider() in main() for the whole app.

}

// Helper method to find GCD for aspect ratio calculation
int _findGCD(int a, int b) {
Copy link

Choose a reason for hiding this comment

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

Why a separate function for GCD? Core dart libraries can be used for this purpose.

import 'package:magic_epaper_app/util/epd/edp.dart';

class DisplayModel {
final String id;
Copy link

Choose a reason for hiding this comment

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

Having so many parameters for each display (id, name, ModelName) doesn't make sense to me. This just increases complexity.

}

// Helper method to get the appropriate EPD based on class name
dynamic _getEpdForClassName(String className) {
Copy link

Choose a reason for hiding this comment

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

Another function which just increases complexity, if you're aiming for a scalable approach.

// Notify listeners that the data has changed
notifyListeners();
} catch (e) {
print('Error loading displays from JSON: $e');
Copy link

Choose a reason for hiding this comment

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

Avoid having print() in your code. Use a logging library instead.

class DisplayCard extends StatelessWidget {
final DisplayModel display;
final bool isSelected;
final VoidCallback onTap;
Copy link

Choose a reason for hiding this comment

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

Why not just simply wrap DisplayCard in a GestureDetector, wherever used (in display_selection_screen.dart).

const ColorDot({
super.key,
required this.color,
this.selected = false,
Copy link

Choose a reason for hiding this comment

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

Do you use selected anywhere ? Should only add parameters whenever needed.

@Vishveshwara
Copy link
Contributor Author

@Vishveshwara Understand the fact that using an LLM to generate code isn't bad. However, if you do so, the code has to be cleaned properly before you commit it. LLM code contains numerous things which are either irrelevant / not needed. The right approach is to always get an understanding of where we are, what functionality we want to achieve and then decide upon an approach for the same which takes into account the exact requirements and constraints of the project, something which an LLM has no idea about.

@AsCress
I apologize for the confusion. I did discuss the app’s requirements with @kienvo — namely, supporting multiple e‑ink displays with different drivers, resolutions, and colors(yellow). That’s why I initially separated the display selection UI into its own JSON‑driven configuration. However, I see now that it’s introducing unnecessary complexity at this stage. I’ll simplify the implementation, remove any extraneous LLM‑generated comments, and refocus on a cleaner, more maintainable approach that aligns with our project constraints. I really appreciate you a lot for helping me understand my mistakes, I’ll take this feedback seriously and work on these improvements with a positive, focused approach.

image

this is the reference app, which was mentioned in the ideas list, which supports multiple displays.

@kienvo
Copy link
Member

kienvo commented Apr 19, 2025

@Vishveshwara, your proposed UI looks good. The thing is, the Epd class was there. You just have to improve it instead of relying on LLM. You could use it as a base, resolve the reviews, then we'll have a nicer app.

To resolve the reviews, add incremental commits to this branch, or commit with --amend and force push to this branch.

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.

Enhance the Functionality and UI for the Select Display Screen
4 participants