Skip to content

Commit 60952c1

Browse files
authored
CardsScreen - fix backgrounds and remove obsolete examples (#1124)
1 parent 83bb764 commit 60952c1

File tree

1 file changed

+58
-61
lines changed

1 file changed

+58
-61
lines changed

demo/src/screens/componentScreens/CardsScreen.tsx

Lines changed: 58 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
33
import {StyleSheet, ScrollView} from 'react-native';
4-
import {Constants, Colors, View, Card, CardProps, Button, Text, Image} from 'react-native-ui-lib';
4+
import {Colors, View, Card, CardProps, Button, Text} from 'react-native-ui-lib';
55
// @ts-ignore
66
import posts from '../../data/posts';
77

@@ -11,7 +11,6 @@ const cardImage = require('../../assets/images/card-example.jpg');
1111
const cardImage2 = require('../../assets/images/empty-state.jpg');
1212

1313
type CardsScreenProps = {};
14-
1514
type CardsScreenState = {
1615
selected1: boolean;
1716
selected2: boolean;
@@ -25,6 +24,7 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
2524

2625
renderSelectableCards = () => {
2726
const {selected1, selected2} = this.state;
27+
2828
return (
2929
<View row marginV-10>
3030
<Card
@@ -35,7 +35,7 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
3535
activeOpacity={1}
3636
marginR-20
3737
>
38-
<Card.Section source={cardImage} imageStyle={{height: '100%'}}/>
38+
<Card.Section imageSource={cardImage} imageStyle={{height: '100%'}}/>
3939
</Card>
4040
<Card
4141
height={120}
@@ -44,12 +44,12 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
4444
onPress={() => this.setState({selected2: !selected2})}
4545
activeOpacity={1}
4646
selectionOptions={{
47-
color: Colors.dark10,
47+
color: Colors.grey10,
4848
indicatorSize: 25,
4949
borderWidth: 3
5050
}}
5151
>
52-
<Card.Section source={cardImage} imageStyle={{height: '100%'}}/>
52+
<Card.Section imageSource={cardImage} imageStyle={{height: '100%'}}/>
5353
</Card>
5454
</View>
5555
);
@@ -59,13 +59,13 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
5959
return (
6060
<Card.Section
6161
content={[
62-
{text: 'You’re Invited!', text70: true, dark10: true},
62+
{text: 'You’re Invited!', text70: true, grey10: true},
6363
{
6464
text: '222 Join Old The Town Barbershop Official Store. Download the Wix app to...',
6565
text80: true,
66-
dark10: true
66+
grey10: true
6767
},
68-
{text: 'wix.to/A465c', text90: true, dark50: true}
68+
{text: 'wix.to/A465c', text90: true, grey50: true}
6969
]}
7070
style={{padding: 20, flex: 1}}
7171
/>
@@ -75,13 +75,14 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
7575
renderText = () => {
7676
return (
7777
<View padding-20 flex>
78-
<Text text70 dark10>
78+
<Text text70 grey10>
7979
You’re Invited!
8080
</Text>
81-
<Text text80 dark10>
82-
222 Join Old The Town Barbershop Official Store. Download the Wix app to...
81+
<Text text80 grey10>
82+
222 Join Old The Town Barbershop Official Store. Download the Wix app
83+
to...
8384
</Text>
84-
<Text text90 dark50>
85+
<Text text90 grey50>
8586
wix.to/A465c
8687
</Text>
8788
</View>
@@ -95,16 +96,25 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
9596
height={160}
9697
style={{marginBottom: 15}}
9798
onPress={() => {}}
98-
enableBlur
9999
borderRadius={borderRadius}
100100
useNative
101101
backgroundColor={Colors.white}
102102
activeOpacity={1}
103103
activeScale={isImageOnLeft ? 0.96 : 1.04}
104104
>
105-
{isImageOnLeft && <Card.Section source={cardImage} imageStyle={{width: 115, height: '100%'}}/>}
105+
{isImageOnLeft && (
106+
<Card.Section
107+
imageSource={cardImage}
108+
imageStyle={{width: 115, height: '100%'}}
109+
/>
110+
)}
106111
{useSection ? this.renderTextSection() : this.renderText()}
107-
{!isImageOnLeft && <Card.Section source={cardImage} imageStyle={{width: 115, height: '100%'}}/>}
112+
{!isImageOnLeft && (
113+
<Card.Section
114+
imageSource={cardImage}
115+
imageStyle={{width: 115, height: '100%'}}
116+
/>
117+
)}
108118
</Card>
109119
);
110120
};
@@ -113,13 +123,14 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
113123
return (
114124
<Card style={{marginBottom: 10}} onPress={() => {}}>
115125
<Card.Section
126+
bg-white
116127
content={[
117-
{text: 'You’re Invited!', text70: true, dark10: true},
118-
{text: 'join now', text90: true, dark50: true}
128+
{text: 'You’re Invited!', text70: true, grey10: true},
129+
{text: 'join now', text90: true, grey50: true}
119130
]}
120131
style={{padding: 20}}
121132
/>
122-
<Card.Section source={cardImage2} imageStyle={{height: 120}}/>
133+
<Card.Section imageSource={cardImage2} imageStyle={{height: 120}}/>
123134
</Card>
124135
);
125136
};
@@ -138,9 +149,10 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
138149
contentStyle={{alignItems: 'center'}}
139150
/>
140151
<Card.Section
152+
bg-white
141153
padding-20
142154
flex
143-
content={[{text: 'All site', text70: true, dark10: true}]}
155+
content={[{text: 'All site', text70: true, grey10: true}]}
144156
contentStyle={{alignItems: 'center', margin: 0, padding: 0}}
145157
/>
146158
</Card>
@@ -161,8 +173,9 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
161173
<Card {...cardProps} flex marginV-10 onPress={() => {}} useNative activeOpacity={1} activeScale={0.96}>
162174
{image}
163175
<Card.Section
176+
bg-white
164177
padding-20
165-
content={[{text: 'All site', text70: true, dark10: true}]}
178+
content={[{text: 'All site', text70: true, grey10: true}]}
166179
contentStyle={{alignItems: 'center'}}
167180
/>
168181
</Card>
@@ -178,7 +191,7 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
178191
<Card.Section
179192
flex
180193
backgroundColor={Colors.blue20}
181-
source={featureIcon}
194+
imageSource={featureIcon}
182195
imageStyle={{
183196
width: 25,
184197
height: 25,
@@ -195,7 +208,7 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
195208
this.renderComplexImage({'marginL-5': true},
196209
<Card.Section
197210
flex
198-
source={cardImage2}
211+
imageSource={cardImage2}
199212
imageStyle={{height: '100%'}}
200213
content={[
201214
{text: 'Special sale!', text70: true, blue10: true},
@@ -214,12 +227,12 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
214227

215228
renderNumbers = () => {
216229
return (
217-
<ScrollView style={{height: 100}} horizontal showsHorizontalScrollIndicator={false}>
230+
<ScrollView style={{height: 100, marginBottom: 20}} horizontal showsHorizontalScrollIndicator={false}>
218231
{_.times(4, i => {
219232
return (
220-
<Card key={i} width={100} style={{marginRight: 20}}>
233+
<Card key={i} width={100} style={{marginRight: 20}} backgroundColor={Colors.white}>
221234
<View padding-15>
222-
<Text text30 dark30>
235+
<Text text30 grey30>
223236
{i}
224237
</Text>
225238
</View>
@@ -238,44 +251,23 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
238251
);
239252
};
240253

241-
renderBackgroundTypes = () => {
242-
return (
243-
<View row marginV-10>
244-
{this.renderBackgroundCard({'marginR-20': true, style: {backgroundColor: Colors.dark60}},
245-
<Text text80 center white>
246-
With custom background color
247-
</Text>)}
248-
{this.renderBackgroundCard({
249-
'marginR-20': true,
250-
style: {backgroundColor: Colors.rgba(Colors.dark60, 0.75)}
251-
},
252-
<Text text70 center white>
253-
With opacity
254-
</Text>)}
255-
{Constants.isIOS &&
256-
this.renderBackgroundCard({enableBlur: true, 'marginL-20': true},
257-
<>
258-
<Text text70 dark20 center>
259-
With Blur effect
260-
</Text>
261-
<Text text80 dark20 center>
262-
(iOS only)
263-
</Text>
264-
</>)}
265-
</View>
266-
);
267-
};
268-
269254
renderComplexExample = () => {
270255
return _.map(posts, (post, i) => {
271256
const statusColor = post.status === 'Published' ? Colors.green30 : Colors.orange30;
272257

273258
return (
274-
<Card key={i} style={{marginBottom: 15}} onPress={() => console.log('press on a card')}>
275-
<Card.Section source={post.coverImage} imageStyle={{height: 160}}/>
259+
<Card
260+
key={i}
261+
style={{marginBottom: 15}}
262+
onPress={() => console.log('press on a card')}
263+
>
264+
<Card.Section
265+
imageSource={post.coverImage}
266+
imageStyle={{height: 160}}
267+
/>
276268

277-
<View padding-20>
278-
<Text text40 color={Colors.dark10}>
269+
<View padding-20 bg-white>
270+
<Text text40 color={Colors.grey10}>
279271
{post.title}
280272
</Text>
281273
<View row>
@@ -285,16 +277,22 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
285277
<Text text90> | {post.timestamp}</Text>
286278
</View>
287279

288-
<Text text70 color={Colors.dark10}>
280+
<Text text70 color={Colors.grey10}>
289281
{post.description}
290282
</Text>
291283

292284
<View>
293-
<Text text90 color={Colors.dark50}>
285+
<Text text90 color={Colors.grey50}>
294286
{post.likes} Likes
295287
</Text>
296288
<View row right>
297-
<Button style={{marginRight: 10}} text90 link iconSource={featureIcon} label="Feature"/>
289+
<Button
290+
style={{marginRight: 10}}
291+
text90
292+
link
293+
iconSource={featureIcon}
294+
label="Feature"
295+
/>
298296
<Button text90 link iconSource={shareIcon} label="Share"/>
299297
</View>
300298
</View>
@@ -309,7 +307,6 @@ export default class CardsScreen extends Component<CardsScreenProps, CardsScreen
309307
<>
310308
{this.renderNumbers()}
311309
{this.renderImageOnBottom()}
312-
{this.renderBackgroundTypes()}
313310
{this.renderComplexExample()}
314311
</>
315312
);

0 commit comments

Comments
 (0)