1
1
import _ from 'lodash' ;
2
2
import React , { Component } from 'react' ;
3
3
import { StyleSheet , ScrollView } from 'react-native' ;
4
- import {
5
- Constants ,
6
- Colors ,
7
- View ,
8
- Card ,
9
- CardProps ,
10
- Button ,
11
- Text ,
12
- Image
13
- } from 'react-native-ui-lib' ;
4
+ import { Constants , Colors , View , Card , CardProps , Button , Text , Image } from 'react-native-ui-lib' ;
14
5
// @ts -ignore
15
6
import posts from '../../data/posts' ;
16
7
@@ -26,10 +17,7 @@ type CardsScreenState = {
26
17
selected2 : boolean ;
27
18
} ;
28
19
29
- export default class CardsScreen extends Component <
30
- CardsScreenProps ,
31
- CardsScreenState
32
- > {
20
+ export default class CardsScreen extends Component < CardsScreenProps , CardsScreenState > {
33
21
state = {
34
22
selected1 : true ,
35
23
selected2 : true
@@ -47,7 +35,7 @@ export default class CardsScreen extends Component<
47
35
activeOpacity = { 1 }
48
36
marginR-20
49
37
>
50
- < Card . Section source = { cardImage } imageStyle = { { height : '100%' } } />
38
+ < Card . Section source = { cardImage } imageStyle = { { height : '100%' } } />
51
39
</ Card >
52
40
< Card
53
41
height = { 120 }
@@ -61,7 +49,7 @@ export default class CardsScreen extends Component<
61
49
borderWidth : 3
62
50
} }
63
51
>
64
- < Card . Section source = { cardImage } imageStyle = { { height : '100%' } } />
52
+ < Card . Section source = { cardImage } imageStyle = { { height : '100%' } } />
65
53
</ Card >
66
54
</ View >
67
55
) ;
@@ -73,8 +61,7 @@ export default class CardsScreen extends Component<
73
61
content = { [
74
62
{ text : 'You’re Invited!' , text70 : true , dark10 : true } ,
75
63
{
76
- text :
77
- '222 Join Old The Town Barbershop Official Store. Download the Wix app to...' ,
64
+ text : '222 Join Old The Town Barbershop Official Store. Download the Wix app to...' ,
78
65
text80 : true ,
79
66
dark10 : true
80
67
} ,
@@ -92,8 +79,7 @@ export default class CardsScreen extends Component<
92
79
You’re Invited!
93
80
</ Text >
94
81
< Text text80 dark10 >
95
- 222 Join Old The Town Barbershop Official Store. Download the Wix app
96
- to...
82
+ 222 Join Old The Town Barbershop Official Store. Download the Wix app to...
97
83
</ Text >
98
84
< Text text90 dark50 >
99
85
wix.to/A465c
@@ -102,11 +88,7 @@ export default class CardsScreen extends Component<
102
88
) ;
103
89
} ;
104
90
105
- renderHorizontalCard = (
106
- isImageOnLeft : boolean ,
107
- borderRadius : number ,
108
- useSection : boolean
109
- ) => {
91
+ renderHorizontalCard = ( isImageOnLeft : boolean , borderRadius : number , useSection : boolean ) => {
110
92
return (
111
93
< Card
112
94
row
@@ -120,19 +102,9 @@ export default class CardsScreen extends Component<
120
102
activeOpacity = { 1 }
121
103
activeScale = { isImageOnLeft ? 0.96 : 1.04 }
122
104
>
123
- { isImageOnLeft && (
124
- < Card . Section
125
- source = { cardImage }
126
- imageStyle = { { width : 115 , height : '100%' } }
127
- />
128
- ) }
105
+ { isImageOnLeft && < Card . Section source = { cardImage } imageStyle = { { width : 115 , height : '100%' } } /> }
129
106
{ useSection ? this . renderTextSection ( ) : this . renderText ( ) }
130
- { ! isImageOnLeft && (
131
- < Card . Section
132
- source = { cardImage }
133
- imageStyle = { { width : 115 , height : '100%' } }
134
- />
135
- ) }
107
+ { ! isImageOnLeft && < Card . Section source = { cardImage } imageStyle = { { width : 115 , height : '100%' } } /> }
136
108
</ Card >
137
109
) ;
138
110
} ;
@@ -147,22 +119,14 @@ export default class CardsScreen extends Component<
147
119
] }
148
120
style = { { padding : 20 } }
149
121
/>
150
- < Card . Section source = { cardImage2 } imageStyle = { { height : 120 } } />
122
+ < Card . Section source = { cardImage2 } imageStyle = { { height : 120 } } />
151
123
</ Card >
152
124
) ;
153
125
} ;
154
126
155
127
renderCoupon = ( cardProps : CardProps ) => {
156
128
return (
157
- < Card
158
- { ...cardProps }
159
- flex
160
- height = { 160 }
161
- onPress = { ( ) => { } }
162
- useNative
163
- activeOpacity = { 1 }
164
- activeScale = { 0.96 }
165
- >
129
+ < Card { ...cardProps } flex height = { 160 } onPress = { ( ) => { } } useNative activeOpacity = { 1 } activeScale = { 0.96 } >
166
130
< Card . Section
167
131
bg-red30
168
132
padding-20
@@ -194,15 +158,7 @@ export default class CardsScreen extends Component<
194
158
195
159
renderComplexImage = ( cardProps : CardProps , image : React . ReactNode ) => {
196
160
return (
197
- < Card
198
- { ...cardProps }
199
- flex
200
- marginV-10
201
- onPress = { ( ) => { } }
202
- useNative
203
- activeOpacity = { 1 }
204
- activeScale = { 0.96 }
205
- >
161
+ < Card { ...cardProps } flex marginV-10 onPress = { ( ) => { } } useNative activeOpacity = { 1 } activeScale = { 0.96 } >
206
162
{ image }
207
163
< Card . Section
208
164
padding-20
@@ -218,8 +174,7 @@ export default class CardsScreen extends Component<
218
174
< View row spread height = { 160 } >
219
175
{
220
176
// Icon
221
- this . renderComplexImage (
222
- { 'marginR-5' : true } ,
177
+ this . renderComplexImage ( { 'marginR-5' : true } ,
223
178
< Card . Section
224
179
flex
225
180
backgroundColor = { Colors . blue20 }
@@ -233,13 +188,11 @@ export default class CardsScreen extends Component<
233
188
style = { {
234
189
justifyContent : 'center'
235
190
} }
236
- />
237
- )
191
+ /> )
238
192
}
239
193
{
240
194
// Image with overlay content
241
- this . renderComplexImage (
242
- { 'marginL-5' : true } ,
195
+ this . renderComplexImage ( { 'marginL-5' : true } ,
243
196
< Card . Section
244
197
flex
245
198
source = { cardImage2 }
@@ -253,21 +206,16 @@ export default class CardsScreen extends Component<
253
206
alignItems : 'center' ,
254
207
justifyContent : 'center'
255
208
} }
256
- />
257
- )
209
+ /> )
258
210
}
259
211
</ View >
260
212
) ;
261
213
} ;
262
214
263
215
renderNumbers = ( ) => {
264
216
return (
265
- < ScrollView
266
- style = { { height : 100 } }
267
- horizontal
268
- showsHorizontalScrollIndicator = { false }
269
- >
270
- { _ . times ( 4 , ( i ) => {
217
+ < ScrollView style = { { height : 100 } } horizontal showsHorizontalScrollIndicator = { false } >
218
+ { _ . times ( 4 , i => {
271
219
return (
272
220
< Card key = { i } width = { 100 } style = { { marginRight : 20 } } >
273
221
< View padding-15 >
@@ -293,52 +241,38 @@ export default class CardsScreen extends Component<
293
241
renderBackgroundTypes = ( ) => {
294
242
return (
295
243
< View row marginV-10 >
296
- { this . renderBackgroundCard (
297
- { 'marginR-20' : true , style : { backgroundColor : Colors . dark60 } } ,
244
+ { this . renderBackgroundCard ( { 'marginR-20' : true , style : { backgroundColor : Colors . dark60 } } ,
298
245
< Text text80 center white >
299
246
With custom background color
300
- </ Text >
301
- ) }
302
- { this . renderBackgroundCard (
303
- {
304
- 'marginR-20' : true ,
305
- style : { backgroundColor : Colors . rgba ( Colors . dark60 , 0.75 ) }
306
- } ,
307
- < Text text70 center white >
247
+ </ Text > ) }
248
+ { this . renderBackgroundCard ( {
249
+ 'marginR-20' : true ,
250
+ style : { backgroundColor : Colors . rgba ( Colors . dark60 , 0.75 ) }
251
+ } ,
252
+ < Text text70 center white >
308
253
With opacity
309
- </ Text >
310
- ) }
254
+ </ Text > ) }
311
255
{ Constants . isIOS &&
312
- this . renderBackgroundCard (
313
- { enableBlur : true , 'marginL-20' : true } ,
256
+ this . renderBackgroundCard ( { enableBlur : true , 'marginL-20' : true } ,
314
257
< >
315
258
< Text text70 dark20 center >
316
259
With Blur effect
317
260
</ Text >
318
261
< Text text80 dark20 center >
319
262
(iOS only)
320
263
</ Text >
321
- </ >
322
- ) }
264
+ </ > ) }
323
265
</ View >
324
266
) ;
325
267
} ;
326
268
327
269
renderComplexExample = ( ) => {
328
270
return _ . map ( posts , ( post , i ) => {
329
- const statusColor =
330
- post . status === 'Published' ? Colors . green30 : Colors . orange30 ;
271
+ const statusColor = post . status === 'Published' ? Colors . green30 : Colors . orange30 ;
331
272
332
273
return (
333
- < Card
334
- key = { i }
335
- style = { { marginBottom : 15 } }
336
- onPress = { ( ) => console . log ( 'press on a card' ) }
337
- >
338
- < Card . Section
339
- source = { post . coverImage }
340
- imageStyle = { { height : 160 } }
341
- />
274
+ < Card key = { i } style = { { marginBottom : 15 } } onPress = { ( ) => console . log ( 'press on a card' ) } >
275
+ < Card . Section source = { post . coverImage } imageStyle = { { height : 160 } } />
342
276
343
277
< View padding-20 >
344
278
< Text text40 color = { Colors . dark10 } >
@@ -360,14 +294,8 @@ export default class CardsScreen extends Component<
360
294
{ post . likes } Likes
361
295
</ Text >
362
296
< View row right >
363
- < Button
364
- style = { { marginRight : 10 } }
365
- text90
366
- link
367
- iconSource = { featureIcon }
368
- label = "Feature"
369
- />
370
- < Button text90 link iconSource = { shareIcon } label = "Share" />
297
+ < Button style = { { marginRight : 10 } } text90 link iconSource = { featureIcon } label = "Feature" />
298
+ < Button text90 link iconSource = { shareIcon } label = "Share" />
371
299
</ View >
372
300
</ View >
373
301
</ View >
@@ -380,6 +308,7 @@ export default class CardsScreen extends Component<
380
308
return (
381
309
< >
382
310
{ this . renderNumbers ( ) }
311
+ { this . renderImageOnBottom ( ) }
383
312
{ this . renderBackgroundTypes ( ) }
384
313
{ this . renderComplexExample ( ) }
385
314
</ >
@@ -388,25 +317,27 @@ export default class CardsScreen extends Component<
388
317
389
318
render ( ) {
390
319
return (
391
- < View >
392
- < Image
393
- style = { StyleSheet . absoluteFillObject }
394
- source = { {
395
- uri :
396
- 'https://images.pexels.com/photos/1005644/pexels-photo-1005644.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260'
397
- } }
398
- />
399
-
320
+ < View bg-grey70 >
400
321
< ScrollView >
401
322
< View flex padding-20 >
323
+ < Text h1 marginB-s4 > Cards</ Text >
324
+ < Text h3 > Selectable Cards</ Text >
402
325
{ this . renderSelectableCards ( ) }
326
+ < Text h3 marginB-s4 >
327
+ Horizontal Cards
328
+ </ Text >
403
329
{ this . renderHorizontalCard ( true , 0 , true ) }
404
330
{ this . renderHorizontalCard ( true , 20 , false ) }
405
331
{ this . renderHorizontalCard ( false , 0 , false ) }
406
332
{ this . renderHorizontalCard ( false , 20 , true ) }
407
- { this . renderImageOnBottom ( ) }
333
+ < Text h3 marginB-s4 >
334
+ Card Sections
335
+ </ Text >
408
336
{ this . renderCoupons ( ) }
409
337
{ this . renderComplexImages ( ) }
338
+ < Text h3 marginB-s4 >
339
+ Others
340
+ </ Text >
410
341
{ this . renderCustomContent ( ) }
411
342
</ View >
412
343
</ ScrollView >
0 commit comments