1
1
import React , { Component } from 'react' ;
2
2
import { StyleSheet , ScrollView } from 'react-native' ;
3
- import { View , Text , Image , Card , Constants } from 'react-native-ui-lib' ; // eslint-disable-line
3
+ import { View , Text , Image , Card , Constants , Colors } from 'react-native-ui-lib' ; // eslint-disable-line
4
4
5
5
const image = require ( '../../assets/images/card-example.jpg' ) ;
6
+ const customOverlayImage = require ( '../../assets/icons/star.png' ) ;
7
+ const customOverlayImage2 = require ( '../../assets/icons/cameraSelected.png' ) ;
8
+
6
9
const uri = {
7
10
uri : 'https://images.pexels.com/photos/140234/pexels-photo-140234.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260'
8
11
} ;
9
12
10
13
export default class OverlaysScreen extends Component {
11
- getImageWithOverlay = type => {
14
+ getImageWithOverlay = ( type , text , customOverylay ) => {
12
15
return (
13
16
< View centerH >
14
- < Text dark10 > { type } </ Text >
15
- < Image style = { styles . image } source = { image } overlayType = { type } />
17
+ < Text dark10 > { text } </ Text >
18
+ < Image style = { styles . image } source = { image } overlayType = { type } customOverlayContent = { customOverylay } />
16
19
</ View >
17
20
) ;
18
21
} ;
19
22
23
+ renderCustomOverlay ( ) {
24
+ return < Image style = { styles . customOverylay } source = { customOverlayImage } /> ;
25
+ }
26
+
27
+ renderCustomOverlay2 ( ) {
28
+ return (
29
+ < View flex center >
30
+ < Image style = { styles . customOverylay2 } source = { customOverlayImage2 } />
31
+ </ View >
32
+ ) ;
33
+ }
34
+
20
35
render ( ) {
21
36
return (
22
37
< ScrollView showsVerticalScrollIndicator = { false } >
@@ -25,12 +40,12 @@ export default class OverlaysScreen extends Component {
25
40
Image Overlays
26
41
</ Text >
27
42
< View row centerH >
28
- { this . getImageWithOverlay ( Image . overlayTypes . VERTICAL ) }
29
- { this . getImageWithOverlay ( Image . overlayTypes . SOLID ) }
43
+ { this . getImageWithOverlay ( Image . overlayTypes . VERTICAL , 'vertical' ) }
44
+ { this . getImageWithOverlay ( Image . overlayTypes . SOLID , 'solid' ) }
30
45
</ View >
31
46
< View row centerH >
32
- { this . getImageWithOverlay ( Image . overlayTypes . TOP ) }
33
- { this . getImageWithOverlay ( Image . overlayTypes . BOTTOM ) }
47
+ { this . getImageWithOverlay ( Image . overlayTypes . TOP , 'top' ) }
48
+ { this . getImageWithOverlay ( Image . overlayTypes . BOTTOM , 'bottom' ) }
34
49
</ View >
35
50
36
51
< Text text60BO marginB-10 marginT-20 >
@@ -47,6 +62,18 @@ export default class OverlaysScreen extends Component {
47
62
< Image style = { styles . overlayImageAbsoluteBottom } source = { image } overlayType = { Image . overlayTypes . BOTTOM } />
48
63
</ View >
49
64
65
+ < Text text60BO marginB-10 marginT-20 >
66
+ Custom Overlay
67
+ </ Text >
68
+ < View row center >
69
+ { this . getImageWithOverlay ( undefined , 'cutom overlay only' , this . renderCustomOverlay ( ) ) }
70
+ { this . getImageWithOverlay ( Image . overlayTypes . SOLID , 'solid + custom' , this . renderCustomOverlay2 ( ) ) }
71
+ </ View >
72
+ < View row center >
73
+ { this . getImageWithOverlay ( Image . overlayTypes . VERTICAL , 'vertical + custom' , this . renderCustomOverlay2 ( ) ) }
74
+ { this . getImageWithOverlay ( Image . overlayTypes . BOTTOM , 'bottom + custom' , this . renderCustomOverlay ( ) ) }
75
+ </ View >
76
+
50
77
< Text text60BO marginB-10 marginT-20 >
51
78
Card.Image Overlay
52
79
</ Text >
@@ -60,17 +87,22 @@ export default class OverlaysScreen extends Component {
60
87
</ View >
61
88
62
89
< Text text60BO margin-10 >
63
- Image Overlay (cover, remote)
90
+ Image Overlay (cover, remote, custom overlay )
64
91
</ Text >
65
- < Image cover source = { uri } overlayType = { Image . overlayTypes . VERTICAL } />
92
+ < Image
93
+ cover
94
+ source = { uri }
95
+ overlayType = { Image . overlayTypes . VERTICAL }
96
+ customOverlayContent = { this . renderCustomOverlay2 ( ) }
97
+ />
66
98
67
99
< Text text60BO margin-10 >
68
- Image Overlay (cover, asset)
100
+ Image Overlay (cover, asset)
69
101
</ Text >
70
102
< Image cover source = { image } overlayType = { Image . overlayTypes . VERTICAL } />
71
103
72
104
< Text text60BO margin-10 >
73
- Image Overlay (fill, specific height)
105
+ Image Overlay (fill, specific height)
74
106
</ Text >
75
107
< Image source = { image } overlayType = { Image . overlayTypes . VERTICAL } style = { styles . imageFillContainer } />
76
108
</ ScrollView >
@@ -86,37 +118,37 @@ const styles = StyleSheet.create({
86
118
} ,
87
119
overlayImageAbsoluteContainer : {
88
120
width : Constants . screenWidth ,
89
- height : 400 ,
121
+ height : 380 ,
90
122
marginLeft : - 20
91
123
} ,
92
124
overlayImageAbsoluteVertical : {
93
125
position : 'absolute' ,
94
- top : 10 ,
95
- left : 0 ,
126
+ top : 30 ,
127
+ left : 10 ,
96
128
width : 150 ,
97
129
height : 150 ,
98
130
margin : 5
99
131
} ,
100
132
overlayImageAbsoluteSolid : {
101
133
position : 'absolute' ,
102
- top : 0 ,
134
+ top : 30 ,
103
135
right : 10 ,
104
136
width : 150 ,
105
137
height : 150 ,
106
138
margin : 5
107
139
} ,
108
140
overlayImageAbsoluteTop : {
109
141
position : 'absolute' ,
110
- bottom : 0 ,
142
+ bottom : 20 ,
111
143
left : 10 ,
112
144
width : 150 ,
113
145
height : 150 ,
114
146
margin : 5
115
147
} ,
116
148
overlayImageAbsoluteBottom : {
117
149
position : 'absolute' ,
118
- bottom : 10 ,
119
- right : 0 ,
150
+ bottom : 20 ,
151
+ right : 10 ,
120
152
width : 150 ,
121
153
height : 150 ,
122
154
margin : 5
@@ -127,5 +159,22 @@ const styles = StyleSheet.create({
127
159
} ,
128
160
imageFillContainer : {
129
161
height : 100
162
+ } ,
163
+ customOverylay : {
164
+ position : 'absolute' ,
165
+ left : 137 ,
166
+ top : 134 ,
167
+ width : 25 ,
168
+ height : 25 ,
169
+ tintColor : Colors . yellow20 ,
170
+ borderWidth : 1 ,
171
+ borderColor : Colors . yellow20 ,
172
+ borderRadius : 100 ,
173
+ backgroundColor : Colors . rgba ( Colors . yellow20 , 0.2 )
174
+ } ,
175
+ customOverylay2 : {
176
+ width : 40 ,
177
+ height : 40 ,
178
+ tintColor : Colors . white
130
179
}
131
180
} ) ;
0 commit comments