1
+ import _ from 'lodash' ;
1
2
import React , { Component } from 'react' ;
2
3
import { Constants , View , Text , Button , Image , FeatureHighlight } from 'react-native-ui-lib' ; // eslint-disable-line
3
4
4
5
class FeatureHighlightScreen extends Component {
5
6
6
7
constructor ( props ) {
7
8
super ( props ) ;
8
- this . closeHighlight = this . closeHighlight . bind ( this ) ;
9
- this . showHighlight = this . showHighlight . bind ( this ) ;
10
9
11
10
this . state = {
12
- showFTE : false ,
11
+ showFTE : true ,
12
+ currentTargetIndex : 0 ,
13
13
} ;
14
+
14
15
this . targets = [ ] ;
16
+
17
+ this . closeHighlight = this . closeHighlight . bind ( this ) ;
18
+ this . showHighlight = this . showHighlight . bind ( this ) ;
19
+ this . moveNext = this . moveNext . bind ( this ) ;
15
20
}
16
21
17
22
componentDidMount ( ) {
18
- this . showHighlight ( ) ;
23
+ // this.showHighlight();
19
24
}
20
25
21
26
closeHighlight ( ) {
@@ -26,6 +31,25 @@ class FeatureHighlightScreen extends Component {
26
31
this . setState ( { showFTE : true } ) ;
27
32
}
28
33
34
+ addTarget ( ref ) {
35
+ if ( ref != null ) {
36
+ if ( ! _ . find ( this . targets , { props : { testID : ref . props . testID } } ) ) {
37
+ this . targets . push ( ref ) ;
38
+ }
39
+ }
40
+ }
41
+
42
+ moveNext ( ) {
43
+ const { currentTargetIndex} = this . state ;
44
+ const newTargetIndex = currentTargetIndex + 1 ;
45
+
46
+ if ( newTargetIndex < this . targets . length ) {
47
+ this . setState ( { currentTargetIndex : newTargetIndex } ) ;
48
+ } else {
49
+ this . closeHighlight ( ) ;
50
+ }
51
+ }
52
+
29
53
renderHighlighterOverlay ( ) {
30
54
const { showFTE} = this . state ;
31
55
return (
@@ -34,8 +58,8 @@ class FeatureHighlightScreen extends Component {
34
58
title = "Get Notified"
35
59
message = "Important notifications appear right on your clubs and groups.
36
60
Tap them to get more information about the most important things that you should pay attention to."
37
- confirmButtonProps = { { label : 'Got It' , onPress : this . closeHighlight } }
38
- getTarget = { ( ) => this . targets [ Math . floor ( Math . random ( ) * this . targets . length ) ] }
61
+ confirmButtonProps = { { label : 'Got It' , onPress : this . moveNext } }
62
+ getTarget = { ( ) => this . targets [ this . state . currentTargetIndex ] }
39
63
// highlightFrame={{x: 30, y: 70, width: 150, height: 30}}
40
64
// highlightFrame={{x: 175, y: 334, width: 150, height: 56}}
41
65
/>
@@ -47,19 +71,29 @@ class FeatureHighlightScreen extends Component {
47
71
< View flex >
48
72
< View row flex >
49
73
< View left >
50
- < View marginT-40 br100 bg-yellow10 style = { { width : 32 , height : 32 } } ref = { r => ( this . targets . push ( r ) ) } />
51
- < View marginT-40 bg-red10 style = { { width : 12 , height : 12 } } ref = { r => ( this . targets . push ( r ) ) } />
74
+ < View
75
+ marginT-40 br100 bg-yellow10
76
+ style = { { width : 32 , height : 32 } }
77
+ testID = { '0' }
78
+ ref = { r => ( this . addTarget ( r ) ) }
79
+ />
80
+ < View marginT-40 bg-red10 style = { { width : 12 , height : 12 } } testID = { '1' } ref = { r => ( this . addTarget ( r ) ) } />
52
81
</ View >
53
82
< View right flex >
54
83
< View row flex >
55
- < View marginT-40 marginR-60 bg-cyan30 style = { { width : 50 , height : 70 } } ref = { r => ( this . targets . push ( r ) ) } />
56
- < View marginT-40 bg-violet30 style = { { width : 70 , height : 50 } } ref = { r => ( this . targets . push ( r ) ) } />
84
+ < View
85
+ marginT-40 marginR-60 bg-cyan30
86
+ style = { { width : 50 , height : 70 } }
87
+ testID = { '2' }
88
+ ref = { r => ( this . addTarget ( r ) ) } />
89
+ < View marginT-40 bg-violet30 style = { { width : 70 , height : 50 } } testID = { '3' } ref = { r => ( this . addTarget ( r ) ) } />
57
90
</ View >
58
91
< View
59
92
marginT-40 marginR-50
60
93
bg-purple40
61
94
style = { { width : 150 , height : 56 } }
62
- ref = { r => ( this . targets . push ( r ) ) }
95
+ testID = { '4' }
96
+ ref = { r => ( this . addTarget ( r ) ) }
63
97
/>
64
98
</ View >
65
99
</ View >
@@ -72,7 +106,7 @@ class FeatureHighlightScreen extends Component {
72
106
into electronic typesetting, < Text > remaining</ Text > essentially unchanged.
73
107
</ Text >
74
108
</ View >
75
- < View marginT-20 ref = { r => ( this . targets . push ( r ) ) } >
109
+ < View marginT-20 testID = { '5' } ref = { r => ( this . addTarget ( r ) ) } >
76
110
< Button label = "Show Overlay" onPress = { this . showHighlight } />
77
111
</ View >
78
112
</ View >
0 commit comments