1
1
import React , { Component } from 'react' ;
2
- import { StyleSheet } from 'react-native' ;
3
- import { View , Assets , Constants , Card , Button , Colors , Typography , Text , AnimatedScanner } from 'react-native-ui-lib' ; //eslint-disable-line
2
+ import { View , Card , Button , Colors , Text , AnimatedScanner } from 'react-native-ui-lib' ; //eslint-disable-line
4
3
import posts from '../../data/posts' ;
5
4
5
+
6
6
const featureIcon = require ( '../../assets/icons/star.png' ) ;
7
7
const shareIcon = require ( '../../assets/icons/share.png' ) ;
8
8
9
9
export default class CardScannerScreen extends Component {
10
10
constructor ( props ) {
11
11
super ( props ) ;
12
12
13
- this . start = this . start . bind ( this ) ;
14
- this . reset = this . reset . bind ( this ) ;
15
- this . onBreak = this . onBreak . bind ( this ) ;
16
-
17
13
this . state = {
18
14
progress : 0 ,
19
15
started : false ,
20
16
reset : false ,
21
- isDone : false ,
17
+ isDone : false
22
18
} ;
23
19
}
24
20
25
- onBreak ( { isDone} ) {
21
+ onBreak = ( { isDone} ) => {
26
22
if ( ! isDone ) {
27
23
this . start ( ) ;
28
24
} else {
29
- this . setState ( {
30
- isDone,
31
- } ) ;
25
+ this . setState ( { isDone} ) ;
32
26
}
33
27
}
34
28
35
- start ( ) {
29
+ start = ( ) => {
36
30
const { progress} = this . state ;
31
+
37
32
this . setState ( {
38
33
started : true ,
39
34
reset : false ,
40
- progress : progress + 25 ,
35
+ progress : progress + 25
41
36
} ) ;
42
37
}
43
38
44
- reset ( ) {
39
+ reset = ( ) => {
45
40
this . setState ( {
46
41
started : false ,
47
42
progress : 0 ,
48
43
reset : true ,
49
- isDone : false ,
44
+ isDone : false
50
45
} ) ;
51
46
}
52
47
53
48
render ( ) {
54
49
const { reset} = this . state ;
55
50
const post = posts [ 0 ] ;
56
51
const statusColor = post . status === 'Published' ? Colors . green30 : Colors . orange30 ;
52
+
57
53
return (
58
54
< View flex useSafeArea >
59
55
< View flex padding-20 >
60
- < View paddingL-40 height = { 6 } width = { '100%' } bg-violet50 marginB-20 >
61
- < AnimatedScanner backgroundColor = { Colors . purple30 } progress = { 98 } duration = { 1600 } />
56
+ < View paddingL-40 marginB-20 >
57
+ < AnimatedScanner
58
+ backgroundColor = { Colors . purple30 }
59
+ progress = { 98 } duration = { 1600 }
60
+ containerStyle = { { backgroundColor : Colors . violet50 , height : 6 } }
61
+ />
62
62
</ View >
63
63
64
64
< Card containerStyle = { { marginBottom : 15 } } onPress = { ( ) => console . log ( 'press on a card' ) } >
65
- < Card . Image height = { 115 } imageSource = { post . coverImage } />
65
+ < Card . Image height = { 115 } source = { post . coverImage } />
66
66
< View padding-20 >
67
67
< Text text40 color = { Colors . dark10 } >
68
68
{ post . title }
@@ -80,8 +80,8 @@ export default class CardScannerScreen extends Component {
80
80
{ post . likes } Likes
81
81
</ Text >
82
82
< View row spread >
83
- < Button style = { { marginRight : 10 } } text90 link iconSource = { featureIcon } label = "Feature" />
84
- < Button text90 link iconSource = { shareIcon } label = "Share" />
83
+ < Button style = { { marginRight : 10 } } text90 link iconSource = { featureIcon } label = "Feature" />
84
+ < Button text90 link iconSource = { shareIcon } label = "Share" />
85
85
</ View >
86
86
</ View >
87
87
@@ -107,8 +107,8 @@ export default class CardScannerScreen extends Component {
107
107
</ View >
108
108
109
109
< View row center padding-20 >
110
- < Button size = "medium" label = "Reset" onPress = { this . reset } disabled = { ! this . state . isDone } />
111
- < Button marginL-10 size = "medium" label = "Publish" onPress = { this . start } disabled = { this . state . started } />
110
+ < Button size = "medium" label = "Reset" onPress = { this . reset } disabled = { ! this . state . isDone } />
111
+ < Button marginL-10 size = "medium" label = "Publish" onPress = { this . start } disabled = { this . state . started } />
112
112
</ View >
113
113
</ View >
114
114
) ;
0 commit comments