Skip to content

Support passing max item width to grid view #1640

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 9 commits into from
Nov 24, 2021

Conversation

ethanshar
Copy link
Collaborator

Description

  • Add maxItemWidth prop to GridView to support a responsive item width without having to know number of colums
  • Minor refactor - keep itemSize on state instead on class since it affect the render cycle

WOAUILIB-2207

Changelog

GridView now supports maxItemWidth prop for a responsive item size (this is instead of passing numColumns prop)

/**
* @description: A auto-generated grid view that calculate item size according to given props
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/GridViewScreen.tsx
*/
class GridView extends UIComponent<GridViewProps, State> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why you're not passing 'State'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

/**
* @description: A auto-generated grid view that calculate item size according to given props
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/GridViewScreen.tsx
*/
class GridView extends UIComponent<GridViewProps, State> {
class GridView extends UIComponent<GridViewProps> {
static displayName = 'GridView';

static defaultProps = {
numColumns: 3,
Copy link
Collaborator

Choose a reason for hiding this comment

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

DEFAULT_NUM_COLUMNS instead of "3"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

/**
* @description: A auto-generated grid view that calculate item size according to given props
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/GridViewScreen.tsx
*/
class GridView extends UIComponent<GridViewProps, State> {
class GridView extends UIComponent<GridViewProps> {
static displayName = 'GridView';

static defaultProps = {
numColumns: 3,
itemSpacing: Spacings.s4
Copy link
Collaborator

@Inbal-Tish Inbal-Tish Nov 16, 2021

Choose a reason for hiding this comment

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

Better take this too to const as you're using it again as default in line #136 and #125

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

import {Colors, Spacings} from 'style';
// TODO: we should use asBaseComponent here instead of using UIComponent directly
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't you want to include this in your refactor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not at the moment..

@ethanshar ethanshar requested a review from Inbal-Tish November 22, 2021 15:56
@Inbal-Tish Inbal-Tish merged commit 317d408 into master Nov 24, 2021
@ethanshar ethanshar deleted the feat/GridView_maxItemWidth branch June 13, 2022 08:16
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