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

Added restaurant card implementation #1398

Open
wants to merge 1 commit into
base: ui/redesign
Choose a base branch
from

Conversation

abutuc
Copy link

@abutuc abutuc commented Nov 26, 2024

Closes #1274

Added the redesign implementation of the restaurant card. The card has as input parameters "restaurantName", "restaurantType", "menuItems", "isFavorite" and "onFavoriteToggle" callback function, which allows us to abstract the logic from the component. Additionally, this card returns a Generic Card whose child is the actual restaurant card content.

Restaurant Card

Note: the background color and the elevation property are being inherited from the Generic Card implementation, so when the Generic Card implementation has these issues fixed, the Restaurant Card should look like the mock version.

Review checklist

  • Terms and conditions reflect the current change
  • Contains enough appropriate tests
  • If aimed at production, writes a new summary in whatsnew/whatsnew-pt-PT
  • Properly adds an entry in changelog.md with the change
  • If PR includes UI updates/additions, its description has screenshots
  • Behavior is as expected
  • Clean, well-structured code

@abutuc abutuc requested a review from DGoiana November 26, 2024 12:47
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 12%. Comparing base (0d8b0af) to head (0cdab5d).
Report is 1 commits behind head on ui/redesign.

Additional details and impacted files
@@             Coverage Diff             @@
##           ui/redesign   #1398   +/-   ##
===========================================
  Coverage           12%     12%           
===========================================
  Files              266     266           
  Lines             7201    7201           
===========================================
  Hits               806     806           
  Misses            6395    6395           

@DGoiana
Copy link
Collaborator

DGoiana commented Nov 26, 2024

@abutuc can you add screenshots of the result?

@DGoiana
Copy link
Collaborator

DGoiana commented Nov 26, 2024

Use TabBar in order to build and implement the top bar

@thePeras thePeras requested a review from a team November 30, 2024 20:09
}
}

class RestaurantCardHeader extends StatefulWidget {
Copy link
Member

@vitormpp vitormpp Dec 2, 2024

Choose a reason for hiding this comment

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

Extend StatelessWidget instead. The state should be managed in the uni_app package, and passed as a boolean argument (isFavorite) to the RestaurantCard, along with a void function / VoidCallback (typedef VoidCallback = void Function();) to handle the favorite icon click.
(if a StatefulWidget were to be used, it should be limited to managing only the state of the icon itself)

break;
default:
iconType = cow;
}
Copy link
Member

@vitormpp vitormpp Dec 2, 2024

Choose a reason for hiding this comment

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

According to previous discussions, uni_app should "send" the icons to the RestaurantCard component. Therefore, the icons should be passed as an argument.

);
}

class MenuItem {
Copy link
Member

@vitormpp vitormpp Dec 2, 2024

Choose a reason for hiding this comment

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

To avoid introducing models in the uni_ui package, I suggest creating a MenuItem widget in uni_ui instead of defining a MenuItem model (that would take parameters like icon and name) and handle the display logic for each menu item. The RestaurantCard would then receive a list of MenuItem widgets, and uni_app would be responsible for creating and passing this list.
What do you think?

Copy link
Collaborator

@DGoiana DGoiana Dec 9, 2024

Choose a reason for hiding this comment

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

I'm a bit skeptical and I do not like the idea of having models in the ui, so you got a point there. However, if I understood what you're saying, we'd have to create a model in the ui and follow the following path: create in ui -> instantiate in app -> pass to ui, which is a bit strange.
Either way, or that or passing all the information destructured.

Copy link
Member

Choose a reason for hiding this comment

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

To clarify my point: instead of defining any model in the uni_ui package, we should create a widget that takes attributes like icon and name as parameters. The RestaurantCard would then receive a list of these widgets.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @vitormpp. MenuItem can be a widget and the restaurant card receives a list of MenuItem widgets

@DGoiana DGoiana mentioned this pull request Dec 9, 2024
7 tasks
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