unicorn-demo-app 7.18.3 → 7.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unicorn-demo-app",
3
- "version": "7.18.3",
3
+ "version": "7.19.0",
4
4
  "main": "src/index.js",
5
5
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
6
6
  "license": "MIT",
@@ -1,42 +1,76 @@
1
1
  import React, {Component} from 'react';
2
2
  import {StyleSheet} from 'react-native';
3
- import {View, Text, Constants, GridList, Card, Spacings, BorderRadiuses, GridListProps} from 'react-native-ui-lib';
3
+ import {
4
+ View,
5
+ Text,
6
+ Constants,
7
+ GridList,
8
+ Card,
9
+ Spacings,
10
+ BorderRadiuses,
11
+ GridListProps,
12
+ GridListItem
13
+ } from 'react-native-ui-lib';
4
14
  import products from '../../data/products';
15
+ import {renderBooleanOption} from '../ExampleScreenPresenter';
5
16
 
6
17
  class GridListScreen extends Component {
7
18
  state = {
8
- orientation: Constants.orientation
19
+ orientation: Constants.orientation,
20
+ useGridListItem: false
9
21
  };
10
22
 
11
- renderItem: GridListProps<typeof products[0]>['renderItem'] = ({item}) => {
23
+ renderHeader = () => {
12
24
  return (
13
- <Card flex>
14
- <Card.Section imageSource={{uri: item.mediaUrl}} imageStyle={styles.itemImage}/>
15
- <View padding-s2>
16
- <Text $textDefault>{item.name}</Text>
17
- <Text $textDefault>{item.formattedPrice}</Text>
18
- {item.inventory.status === 'Out of Stock' && (
19
- <Text text90M $textDangerLight>
20
- {item.inventory.status}
21
- </Text>
22
- )}
23
- </View>
24
- </Card>
25
+ <View>
26
+ <Text h1 marginB-s5>
27
+ GridList
28
+ </Text>
29
+ {renderBooleanOption.call(this, 'UseGridListItem', 'useGridListItem')}
30
+ </View>
25
31
  );
26
32
  };
27
33
 
34
+ renderItem: GridListProps<(typeof products)[0]>['renderItem'] = ({item}) => {
35
+ const {useGridListItem} = this.state;
36
+
37
+ if (useGridListItem) {
38
+ return (
39
+ <GridListItem
40
+ // containerStyle={{width: '100%', borderWidth: 1}}
41
+ itemSize={{width: '100%', height: 200}}
42
+ imageProps={{source: {uri: item.mediaUrl}}}
43
+ title="Title"
44
+ subtitle="Subitle"
45
+ overlayText
46
+ />
47
+ );
48
+ } else {
49
+ return (
50
+ <Card flex>
51
+ <Card.Section imageSource={{uri: item.mediaUrl}} imageStyle={styles.itemImage}/>
52
+ <View padding-s2>
53
+ <Text $textDefault>{item.name}</Text>
54
+ <Text $textDefault>{item.formattedPrice}</Text>
55
+ {item.inventory.status === 'Out of Stock' && (
56
+ <Text text90M $textDangerLight>
57
+ {item.inventory.status}
58
+ </Text>
59
+ )}
60
+ </View>
61
+ </Card>
62
+ );
63
+ }
64
+ };
65
+
28
66
  render() {
29
67
  return (
30
- <GridList<typeof products[0]>
31
- ListHeaderComponent={
32
- <Text h1 marginB-s5>
33
- GridList
34
- </Text>
35
- }
68
+ <GridList<(typeof products)[0]>
69
+ ListHeaderComponent={() => this.renderHeader()}
36
70
  data={products}
37
71
  renderItem={this.renderItem}
38
- // numColumns={2}
39
- maxItemWidth={140}
72
+ numColumns={2}
73
+ // maxItemWidth={140}
40
74
  itemSpacing={Spacings.s3}
41
75
  listPadding={Spacings.s5}
42
76
  // keepItemSize
@@ -152,6 +152,7 @@ const NumberInputScreen = () => {
152
152
  label,
153
153
  labelStyle: styles.label,
154
154
  style: textStyle,
155
+ maxLength: 6,
155
156
  validate,
156
157
  validationMessage,
157
158
  validationMessageStyle: Typography.text80M,