@@ -10,7 +10,10 @@ import {
10
10
StyleSheet ,
11
11
Text ,
12
12
View ,
13
- TouchableOpacity
13
+ TouchableOpacity ,
14
+ processColor ,
15
+ Switch ,
16
+ ScrollView
14
17
} from 'react-native' ;
15
18
16
19
import Instabug from 'instabug-reactnative' ;
@@ -27,39 +30,109 @@ export default class App extends Component<{}> {
27
30
28
31
constructor ( props ) {
29
32
super ( props ) ;
33
+ this . state = {
34
+ switchValue : false ,
35
+ colorTheme : 'Dark'
36
+ } ;
37
+ Instabug . startWithToken ( "8020a1fab5139a4be54038a9728c4dc8" , Instabug . invocationEvent . shake ) ;
30
38
Instabug . setReportCategories ( "Performance" , "UI" , "Flow" , "Other" ) ;
31
39
Instabug . setPromptOptionsEnabled ( true , true , true ) ;
40
+ Instabug . setLocale ( Instabug . locale . english ) ;
32
41
}
33
42
34
43
render ( ) {
35
44
return (
36
45
< View style = { styles . container } >
37
- < Text style = { styles . details } >
38
- Hello Instabug awesome user! The purpose of this application is to show you the different
39
- options for customizing the SDK and how easy it is to integrate it to your existing app
40
- </ Text >
41
- < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showIntroMessage ( ) } >
42
- < Text style = { styles . text } > SHOW INTRO MESSAGE </ Text >
43
- </ TouchableOpacity >
44
- < TouchableOpacity style = { styles . button } onPress = { ( ) => this . invoke ( ) } >
45
- < Text style = { styles . text } > INVOKE </ Text >
46
- </ TouchableOpacity >
47
- < TouchableOpacity style = { styles . button } onPress = { ( ) => this . sendBugReport ( ) } >
48
- < Text style = { styles . text } > SEND BUG REPORT </ Text >
49
- </ TouchableOpacity >
50
- < TouchableOpacity style = { styles . button } onPress = { ( ) => this . sendFeedback ( ) } >
51
- < Text style = { styles . text } > SEND FEEDBACK </ Text >
52
- </ TouchableOpacity >
53
- < TouchableOpacity style = { styles . button } onPress = { ( ) => this . startNewConversation ( ) } >
54
- < Text style = { styles . text } > START A NEW CONVERSATION </ Text >
55
- </ TouchableOpacity >
56
- < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showUnreadMessagesCount ( ) } >
57
- < Text style = { styles . text } > GET UNREAD MESSAGES COUNT </ Text >
58
- </ TouchableOpacity >
46
+ < ScrollView contentContainerStyle = { styles . contentContainer } >
47
+ < Text style = { styles . details } >
48
+ Hello { "Instabug's" } awesome user! The purpose of this application is to show you the different
49
+ options for customizing the SDK and how easy it is to integrate it to your existing app
50
+ </ Text >
51
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showIntroMessage ( ) } >
52
+ < Text style = { styles . text } > SHOW INTRO MESSAGE </ Text >
53
+ </ TouchableOpacity >
54
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . invoke ( ) } >
55
+ < Text style = { styles . text } > INVOKE </ Text >
56
+ </ TouchableOpacity >
57
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . sendBugReport ( ) } >
58
+ < Text style = { styles . text } > SEND BUG REPORT </ Text >
59
+ </ TouchableOpacity >
60
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . sendFeedback ( ) } >
61
+ < Text style = { styles . text } > SEND FEEDBACK </ Text >
62
+ </ TouchableOpacity >
63
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . startNewConversation ( ) } >
64
+ < Text style = { styles . text } > START A NEW CONVERSATION </ Text >
65
+ </ TouchableOpacity >
66
+ < TouchableOpacity style = { styles . button } onPress = { ( ) => this . showUnreadMessagesCount ( ) } >
67
+ < Text style = { styles . text } > GET UNREAD MESSAGES COUNT </ Text >
68
+ </ TouchableOpacity >
69
+ { this . invocationEvent ( ) }
70
+ < Text style = { styles . textColor } > Set primary color </ Text >
71
+ < View style = { styles . rowView } >
72
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . setPrimaryColor ( '#FF0000' ) } >
73
+ < Text style = { styles . text } > RED </ Text >
74
+ </ TouchableOpacity >
75
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . setPrimaryColor ( '#00FF00' ) } >
76
+ < Text style = { styles . text } > GREEN </ Text >
77
+ </ TouchableOpacity >
78
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . setPrimaryColor ( '#0000FF' ) } >
79
+ < Text style = { styles . text } > BLUE </ Text >
80
+ </ TouchableOpacity >
81
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . setPrimaryColor ( '#FFFF00' ) } >
82
+ < Text style = { styles . text } > YELLOW </ Text >
83
+ </ TouchableOpacity >
84
+ </ View >
85
+ < View style = { styles . switchView } >
86
+ < Text style = { styles . textSwitchStyle } > Color Theme: { this . state . colorTheme } </ Text >
87
+ < Switch
88
+ onValueChange = { this . toggleSwitch }
89
+ value = { this . state . switchValue } />
90
+ </ View >
91
+ </ ScrollView >
59
92
</ View >
60
93
) ;
61
94
}
62
95
96
+ invocationEvent ( ) {
97
+ if ( Platform . OS === 'ios ') {
98
+ return (
99
+ < View >
100
+ < Text style = { styles . textColor } > Change Invocation Event < / T e x t >
101
+ < View style = { styles . rowView } >
102
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Shake' ) } >
103
+ < Text style = { styles . textInvoke } > SHAKE </ Text >
104
+ </ TouchableOpacity >
105
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Button' ) } >
106
+ < Text style = { styles . textInvoke } > FLOATING BUTTON </ Text >
107
+ </ TouchableOpacity >
108
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'Screenshot' ) } >
109
+ < Text style = { styles . textInvoke } > SCREENSHOT </ Text >
110
+ </ TouchableOpacity >
111
+ < TouchableOpacity style = { styles . buttonColor } onPress = { ( ) => this . changeInvocationEvent ( 'None' ) } >
112
+ < Text style = { styles . textInvoke } > NONE </ Text >
113
+ </ TouchableOpacity >
114
+ </ View >
115
+ < / V i e w >
116
+ ) ;
117
+ }
118
+ return ;
119
+ }
120
+
121
+ toggleSwitch = ( value ) => {
122
+ this . setState ( { switchValue : value } )
123
+ if ( value ) {
124
+ this . setState ( { colorTheme : 'Light' } ) ;
125
+ Instabug . setColorTheme ( Instabug . colorTheme . light ) ;
126
+ } else {
127
+ this . setState ( { colorTheme : 'Dark' } ) ;
128
+ Instabug . setColorTheme ( Instabug . colorTheme . dark ) ;
129
+ }
130
+ }
131
+
132
+ setPrimaryColor ( color ) {
133
+ Instabug . setPrimaryColor ( processColor ( color ) ) ;
134
+ }
135
+
63
136
showIntroMessage ( ) {
64
137
Instabug . showIntroMessage ( ) ;
65
138
}
@@ -76,6 +149,17 @@ export default class App extends Component<{}> {
76
149
Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newFeedback ) ;
77
150
}
78
151
152
+ changeInvocationEvent ( invocationEvent ) {
153
+ if ( invocationEvent === 'Shake' )
154
+ Instabug . setInvocationEvent ( Instabug . invocationEvent . shake ) ;
155
+ if ( invocationEvent === 'Button' )
156
+ Instabug . setInvocationEvent ( Instabug . invocationEvent . floatingButton ) ;
157
+ if ( invocationEvent === 'Screenshot' )
158
+ Instabug . setInvocationEvent ( Instabug . invocationEvent . screenshot ) ;
159
+ if ( invocationEvent === 'None' )
160
+ Instabug . setInvocationEvent ( Instabug . invocationEvent . none ) ;
161
+ }
162
+
79
163
startNewConversation ( ) {
80
164
Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newChat ) ;
81
165
}
@@ -96,16 +180,53 @@ const styles = StyleSheet.create({
96
180
details : {
97
181
textAlign : 'center' ,
98
182
color : '#333333' ,
99
- margin : 20
183
+ margin : 20 ,
184
+ marginTop : Platform . OS === 'ios' ? 40 : 20
100
185
} ,
101
186
text : {
102
- color : '#FFFFFF'
187
+ color : '#FFFFFF' ,
188
+ fontSize : 12 ,
189
+ fontWeight : 'bold'
103
190
} ,
104
191
button : {
105
192
marginTop : 10 ,
106
193
backgroundColor : "#1D82DC" ,
107
194
padding : 10 ,
108
195
alignItems : 'center' ,
109
196
borderRadius : 5
197
+ } ,
198
+ rowView : {
199
+ flexDirection : 'row' ,
200
+ marginTop : 10
201
+ } ,
202
+ textColor : {
203
+ fontSize : 14 ,
204
+ fontWeight : 'bold' ,
205
+ marginTop : 10 ,
206
+ } ,
207
+ buttonColor : {
208
+ marginTop : 10 ,
209
+ backgroundColor : "#1D82DC" ,
210
+ padding : 10 ,
211
+ alignItems : 'center' ,
212
+ borderRadius : 5 ,
213
+ marginRight : 5
214
+ } ,
215
+ textSwitchStyle : {
216
+ marginTop : 10 ,
217
+ marginRight : 5 ,
218
+ fontWeight : 'bold'
219
+ } ,
220
+ switchView : {
221
+ flexDirection : 'row' ,
222
+ marginTop : 20 ,
223
+ } ,
224
+ textInvoke : {
225
+ color : '#FFFFFF' ,
226
+ fontSize : 10 ,
227
+ fontWeight : 'bold'
228
+ } ,
229
+ contentContainer : {
230
+ padding : 10
110
231
}
111
232
} ) ;
0 commit comments