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,42 +1,76 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {StyleSheet} from 'react-native';
|
|
3
|
-
import {
|
|
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
|
-
|
|
23
|
+
renderHeader = () => {
|
|
12
24
|
return (
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
39
|
-
maxItemWidth={140}
|
|
72
|
+
numColumns={2}
|
|
73
|
+
// maxItemWidth={140}
|
|
40
74
|
itemSpacing={Spacings.s3}
|
|
41
75
|
listPadding={Spacings.s5}
|
|
42
76
|
// keepItemSize
|