Skip to content

Commit 2cad7da

Browse files
committed
Fix GridView and GridListItem folder names and add exports for the component
1 parent 1b11d02 commit 2cad7da

File tree

5 files changed

+25
-37
lines changed

5 files changed

+25
-37
lines changed

demo/src/screens/componentScreens/GridViewScreen.tsx

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import _ from 'lodash';
2-
import {View, Text, Colors, Constants, Avatar} from 'react-native-ui-lib';
2+
import {View, Text, Colors, Constants, Avatar, GridView} from 'react-native-ui-lib';
33
import React, {Component} from 'react';
44
import {Alert, ScrollView} from 'react-native';
5-
import GridView from '../../../../src/components/GridView';
65
import conversations from '../../data/conversations';
76
import products from '../../data/products';
87

9-
108
class GridViewScreen extends Component {
119
state = {
1210
contacts: _.chain(conversations)
@@ -26,12 +24,7 @@ class GridViewScreen extends Component {
2624
onPress: () => Alert.alert('My price is ' + product.formattedPrice),
2725
renderOverlay: () => {
2826
if (index < 7) {
29-
return (
30-
<Text
31-
text={product.price}
32-
style={{alignSelf: 'center', marginTop: 3}}
33-
/>
34-
);
27+
return <Text text={product.price} style={{alignSelf: 'center', marginTop: 3}}/>;
3528
}
3629
}
3730
}))
@@ -94,18 +87,17 @@ class GridViewScreen extends Component {
9487
renderOverlay: () => {
9588
if (index === 0) {
9689
return (
97-
<Text
98-
margin-10 text80BO
99-
style={{alignSelf: 'flex-start', marginTop: 12, marginLeft: 12}}
100-
>{product.formattedPrice}</Text>
90+
<Text margin-10 text80BO style={{alignSelf: 'flex-start', marginTop: 12, marginLeft: 12}}>
91+
{product.formattedPrice}
92+
</Text>
10193
);
10294
}
10395
}
10496
}))
10597
.value(),
10698
avatars: _.chain(conversations)
10799
.take(9)
108-
.map((item) => ({
100+
.map(item => ({
109101
renderCustomItem: () => {
110102
const imageElementElement = item.thumbnail;
111103
return (
@@ -168,27 +160,15 @@ class GridViewScreen extends Component {
168160
<Text margin-30 text60BO>
169161
Pairs
170162
</Text>
171-
<GridView
172-
items={pairs}
173-
numColumns={2}
174-
useCustomTheme
175-
/>
163+
<GridView items={pairs} numColumns={2} useCustomTheme/>
176164
<Text margin-30 text60BO>
177165
Dynamic itemSize
178166
</Text>
179-
<GridView
180-
items={dynamicLayout}
181-
numColumns={2}
182-
useCustomTheme
183-
/>
167+
<GridView items={dynamicLayout} numColumns={2} useCustomTheme/>
184168
<Text margin-30 text60BO>
185169
OverlayText
186170
</Text>
187-
<GridView
188-
items={overlayText}
189-
numColumns={2}
190-
useCustomTheme
191-
/>
171+
<GridView items={overlayText} numColumns={2} useCustomTheme/>
192172
<Text margin-30 text60BO>
193173
Custom content (Avatars)
194174
</Text>

src/components/gridListItem_/index.tsx renamed to src/components/gridListItem/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Text from '../text';
88
import TouchableOpacity, {TouchableOpacityProps} from '../touchableOpacity';
99
import Image, {ImageProps} from '../image';
1010

11-
export interface GridItemProps {
11+
export interface GridListItemProps {
1212
/**
1313
* Image props object for rendering an image item
1414
*/
@@ -112,7 +112,7 @@ interface RenderContentType {
112112
* @description: A single grid view/list item component
113113
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/GridViewScreen.tsx
114114
*/
115-
class GridListItem extends Component<GridItemProps> {
115+
class GridListItem extends Component<GridListItemProps> {
116116
static displayName = 'GridListItem';
117117

118118
static defaultProps = {

src/components/gridView_/index.tsx renamed to src/components/gridView/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import {Colors, Spacings} from 'style';
77
import View from '../view';
88
import Text from '../text';
99
import {Constants} from 'helpers';
10-
import GridListItem, {GridItemProps} from '../GridListItem';
10+
import GridListItem, {GridListItemProps} from '../gridListItem';
1111
import {formatLastItemLabel} from '../../helpers/FormattingPresenter';
1212

13-
interface Props {
13+
export interface GridViewProps {
1414
/**
1515
* The list of items based on GridListItem props
1616
*/
17-
items?: GridItemProps[];
17+
items?: GridListItemProps[];
1818
/**
1919
* pass the desired grid view width (will improve loading time)
2020
*/
@@ -48,12 +48,12 @@ interface State {
4848
}
4949

5050

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

5959
static defaultProps = {
@@ -171,7 +171,7 @@ class GridView extends UIComponent<Props, State> {
171171
);
172172
}
173173

174-
renderItem = (item: GridItemProps, index: number) => {
174+
renderItem = (item: GridListItemProps, index: number) => {
175175
const {items, itemSpacing} = this.props;
176176
const {numColumns} = this.state;
177177
const itemsCount = _.size(items);

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export default {
6666
get FeatureHighlight() {
6767
return require('./components/featureHighlight').default;
6868
},
69+
get GridListItem() {
70+
return require('./components/gridListItem').default;
71+
},
72+
get GridView() {
73+
return require('./components/gridView').default;
74+
},
6975
get Hint() {
7076
return require('./components/hint').default;
7177
},

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export {default as ColorPicker, ColorPickerProps} from './components/colorPicker
3737
export {default as ColorPalette, ColorPaletteProps} from './components/colorPicker/ColorPalette';
3838
export {default as ColorSwatch, ColorSwatchProps} from './components/colorPicker/ColorSwatch';
3939
export {default as FloatingButton, FloatingButtonProps} from './components/floatingButton';
40+
export {default as GridListItem, GridListItemProps} from './components/gridListItem';
41+
export {default as GridView, GridViewProps} from './components/gridView';
4042
export {default as Image, ImageProps} from './components/image';
4143
export {default as Overlay, OverlayTypes} from './components/overlay';
4244
export {default as RadioButton, RadioButtonPropTypes, RadioButtonProps} from './components/radioButton';

0 commit comments

Comments
 (0)