Skip to content

fix: changes the implementation of the display selection screen #23

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 6 commits into from
Apr 26, 2025

Conversation

Vishveshwara
Copy link
Contributor

@Vishveshwara Vishveshwara commented Apr 20, 2025

Fixes #18

Screenshot
WhatsApp Image 2025-04-21 at 00 40 33_fc163a9f

Changes:

  • Removed JSON implementation
  • Removed Filtering Logic
  • Removed Display Provider
  • Updated epd class for displaying the specification

Summary by Sourcery

Refactor the display selection screen by removing JSON, filtering logic, and provider-based state management, and simplify the implementation to use a more direct approach for selecting e-paper displays.

Bug Fixes:

  • Simplified the display selection process by removing unnecessary complexity

Enhancements:

  • Replaced provider-based state management with a more straightforward stateful widget implementation
  • Streamlined the display card and selection mechanism

Chores:

  • Removed unused provider, JSON configuration, and filter chip components
  • Cleaned up unused files and simplified the codebase

Copy link

sourcery-ai bot commented Apr 20, 2025

Reviewer's Guide by Sourcery

This pull request refactors the display selection screen to remove the previous JSON implementation and filtering logic. It replaces the dynamic display grid with a hardcoded list of Epd objects and implements a simple state management for display selection. The DisplayCard widget has been updated to work with the new Epd model, and concrete implementations of the Epd abstract class have been added.

Updated class diagram for DisplaySelectionScreen

classDiagram
  class DisplaySelectionScreen {
    -List<Epd> displays
    -int? selectedIndex
    +Widget build(BuildContext context)
    -Widget _buildContinueButton(BuildContext context)
  }

  class _DisplaySelectionScreenState {
    -List<Epd> displays
    -int? selectedIndex
    +Widget build(BuildContext context)
    -Widget _buildContinueButton(BuildContext context)
  }

  DisplaySelectionScreen -- _DisplaySelectionScreenState

  class Epd {
    <<abstract>>
    +int width
    +int height
    +List~Image Function(img.Image)~ processingMethods
    +String name
    +String modelId
    +String aspectRatio
    +String driverName
    +String imgPath
    +List~Color~ colors
    +Driver controller
  }

  class Gdey037z03 {
    +int width
    +int height
    +String name
    +String modelId
    +String aspectRatio
    +String driverName
    +String imgPath
    +List~Color~ colors
  }

  class Gdey037z03BW {
    +int width
    +int height
    +String name
    +String modelId
    +String aspectRatio
    +String driverName
    +String imgPath
    +List~Color~ colors
  }

  Epd <|-- Gdey037z03
  Epd <|-- Gdey037z03BW

  class DisplayCard {
    -Epd display
    -bool isSelected
    -VoidCallback onTap
    +Widget build(BuildContext context)
    -String _getColorName(Color color)
    -Widget _buildSpecRow(String label, String value)
  }

  DisplaySelectionScreen -- DisplayCard

  note for DisplaySelectionScreen "Removes JSON implementation and filtering logic.
Replaces dynamic display grid with a hardcoded list of Epd objects.
Implements simple state management for display selection."

  note for DisplayCard "Updated to work with the new Epd model."

  note for Epd "Abstract class for ePaper displays."

  note for Gdey037z03 "Concrete implementation of Epd for a specific display."

  note for Gdey037z03BW "Concrete implementation of Epd for a specific display."
Loading

File-Level Changes

Change Details Files
Refactored the display selection screen to remove the JSON implementation, filtering logic, and display provider.
  • Removed the dependency on DisplayProvider.
  • Removed the filter chips section.
  • Replaced the dynamic display grid with a hardcoded list of Epd objects.
  • Implemented a simple state management for display selection using setState.
  • Updated the continue button to navigate to the ImageEditor with the selected Epd object.
lib/view/display_selection_screen.dart
Updated the DisplayCard widget to work with the new Epd model.
  • Removed the dependency on DisplayModel.
  • Updated the widget to receive an Epd object directly.
  • Modified the widget to display the Epd's properties.
  • Added InkWell for visual feedback on tap.
lib/view/widget/display_card.dart
Added concrete implementations of the Epd abstract class.
  • Created Gdey037z03 to represent a specific e-paper display model.
  • Created Gdey037z03BW to represent a black and white e-paper display model.
  • Implemented the abstract members of the Epd class.
lib/util/epd/gdey037z03.dart
lib/util/epd/gdey037z03bw.dart
Removed filter chip option widget.
  • Removed the FilterChipOption widget.
lib/view/widget/filter_chip_option.dart
Updated the ColorDot widget.
  • Removed the selected property.
  • Removed the shadow effect.
lib/view/widget/color_dot.dart
Removed the displays.json file.
  • Deleted the displays.json file.
assets/displays.json
Removed the DisplayProvider class.
  • Deleted the DisplayProvider class.
lib/provider/display_provider.dart
Removed the home_screen.dart file.
  • Deleted the home_screen.dart file.
lib/view/home_screen.dart

Assessment against linked issues

Issue Objective Addressed Explanation
#18 Implement a new display selection screen with a grid layout for display options, display preview images, color indicator dots, and technical specifications. The PR removes the JSON implementation, filtering logic, and display provider, which are essential for implementing the display selection screen as described in the issue. While it updates the epd class for displaying specifications, it doesn't fully address the objective of creating a comprehensive display selection screen with all the features mentioned.
#18 Implement dynamic filtering of displays by type (Color, B&W, HD). The PR explicitly removes the filtering logic, thus failing to address this objective.
#18 Create DisplayModel class with display specifications, color parsing, aspect ratio calculation, and PPI calculation and a DisplayProvider for JSON data loading, filter management, selection state, and EPD class mapping. The PR removes the JSON implementation and Display Provider, which are key components for achieving this objective. The changes do not include the creation or maintenance of the DisplayModel class as described in the issue.

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

@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 ListView.builder instead of GridView.builder if you expect a small number of displays, as it might be more performant.
  • The _getColorName method in DisplayCard could be moved to the Epd class to promote code reuse.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue 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 and I'll use the feedback to improve your reviews.

onTap: onTap,
highlightColor: Colors.redAccent,
borderRadius: BorderRadius.circular(12),
splashColor: Colors.redAccent.withValues(alpha: 0.2),
Copy link

Choose a reason for hiding this comment

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

issue (typo): Potential typo in splashColor method usage.

It appears that withValues(alpha: 0.2) might be intended to set opacity. Consider replacing with withOpacity(0.2) to correctly apply the desired transparency.

Suggested change
splashColor: Colors.redAccent.withValues(alpha: 0.2),
splashColor: Colors.redAccent.withOpacity(0.2),

@Vishveshwara
Copy link
Contributor Author

Vishveshwara commented Apr 20, 2025

@AsCress @kienvo
Can you please review this PR?

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 Nice work on the refactoring ! This code is now much more simplified and makes much more sense.

@Vishveshwara
Copy link
Contributor Author

@Vishveshwara Nice work on the refactoring ! This code is now much more simplified and makes much more sense.

Thank you for the review! 🙏 I appreciate your guidance in helping simplify the architecture.

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.

LGTM!
@kienvo We might want to test the app once and decide upon the UI implementations before we merge this. I'll leave this to you.

Copy link
Member

@kienvo kienvo left a comment

Choose a reason for hiding this comment

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

Looks good. Some minor issues need to be fixed before merging.

@override
String get aspectRatio => '26:15';
@override
String get driverName => 'UC8253';
Copy link
Member

Choose a reason for hiding this comment

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

I think this driverName should be moved to util/epd/driver /driver.dart.

aspectRatio is not so important, can we remove it?

Comment on lines 19 to 21
if (color == Colors.black) return 'Black';
if (color == Colors.white) return 'White';
if (color == Colors.red) return 'Red';
Copy link
Member

Choose a reason for hiding this comment

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

Not just Black, White, Red, but also Yellow, Blue, Green, and Orange.

@AsCress
Copy link

AsCress commented Apr 23, 2025

@mariobehling This is good to go.

@mariobehling mariobehling merged commit 0d008a8 into fossasia:main Apr 26, 2025
2 of 3 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.

4 participants