@@ -14,310 +14,66 @@ import {
1414 processColor ,
1515 Aerlt ,
1616 Image ,
17- ListView ,
1817 TouchableHighlight ,
1918 RecyclerViewBackedScrollView
2019} from "react-native" ;
2120import Instabug from "instabug-reactnative" ;
22- let DialogAndroid = require ( 'react-native-dialogs' ) ;
2321
2422export default class InstabugSample extends Component {
2523
2624 constructor ( props ) {
2725 super ( props ) ;
28- Instabug . startWithToken ( '0f0dc916bd9175e3b5d2fdf0cfa49a69' ,
29- Instabug . invocationEvent . floatingButton ) ;
30- Instabug . setPreInvocationHandler ( ( ) => {
31- Alert . alert ( "PreInvocationEvent" , "Done :) " ) ;
32- } ) ;
33- const ds = new ListView . DataSource ( { rowHasChanged : ( r1 , r2 ) => r1 !== r2 } ) ;
34- this . state = {
35- dataSource : ds . cloneWithRows ( this . _genRows ( { } ) ) ,
36- } ;
37- }
38-
39- _renderRow ( rowData , sectionID , rowID , highlightRow ) {
40- const that = this ;
41- return (
42- < TouchableHighlight onPress = { ( ) => {
43- that . _pressRow ( rowID ) ;
44- highlightRow ( sectionID , rowID ) ;
45- } } >
46- < View >
47- < View style = { styles . row } >
48- < Text style = { styles . text } >
49- { rowData }
50- </ Text >
51- </ View >
52- </ View >
53- </ TouchableHighlight >
54- ) ;
55- }
5626
57- _genRows ( ) {
58- var dataBlob = [
59- "Invoke" ,
60- "Invoke with invocation mode" ,
61- "Select invocation event" ,
62- "Show intro message" ,
63- "Unread messages count" ,
64- "Set locale" ,
65- "Set color theme" ,
66- "Set primary color"
67- ] ;
68- return dataBlob ;
69- }
70-
71- _pressRow ( rowID ) {
72- if ( rowID == 0 ) {
73- Instabug . invoke ( ) ;
74- } else if ( rowID == 1 ) {
75- this . _showInvocationModeActionSheet ( ) ;
76- } else if ( rowID == 2 ) {
77- this . _showInvocationEventActionSheet ( ) ;
78- } else if ( rowID == 3 ) {
79- Instabug . showIntroMessage ( ) ;
80- } else if ( rowID == 4 ) {
81-
82- Instabug . getUnreadMessagesCount ( ( count ) => {
83- Alert . alert ( "UnReadMessages" , "Messages: " + count ) ;
84- } ) ;
27+ Instabug . setColorTheme ( Instabug . colorTheme . light ) ;
28+ Instabug . setPrimaryColor ( processColor ( '#aaff00' ) ) ;
29+ Instabug . setEmailFieldRequired ( false ) ;
8530
86- } else if ( rowID == 5 ) {
87- this . _showLocaleActionSheet ( ) ;
88- } else if ( rowID == 6 ) {
89- this . _showColorThemeActionSheet ( ) ;
90- } else if ( rowID == 7 ) {
91- this . _showPrimaryColorActionSheet ( ) ;
92- }
9331 }
9432
95- _showInvocationModeActionSheet ( ) {
96- let options = {
97- "items" : [
98- "New bug" ,
99- "New Feedback" ,
100- "New Chat" ,
101- "None"
102- ] ,
103- "title" : "Instabug modes" ,
104- itemsCallback : ( id , text ) => {
105- if ( id == 0 ) {
106- Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newBug ) ;
107- } else if ( id == 1 ) {
108- Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newFeedback ) ;
109- } else if ( id == 2 ) {
110- Instabug . invokeWithInvocationMode ( Instabug . invocationMode . newChat ) ;
111- } else if ( id == 3 ) {
112- Instabug . invokeWithInvocationMode ( Instabug . invocationMode . NA ) ;
113- }
114- }
115- } ;
116-
117- showDialog = function ( ) {
118- let dialog = new DialogAndroid ( ) ;
119- dialog . set ( options ) ;
120- dialog . show ( ) ;
121- } ;
122-
123- showDialog ( ) ;
124- }
125-
126- _showColorThemeActionSheet ( ) {
127- let options = {
128- "items" : [
129- "Light" ,
130- "Dark"
131- ] ,
132- "title" : "Instabug Themes" ,
133- itemsCallback : ( id , text ) => {
134- if ( id == 0 ) {
135- Instabug . setColorTheme ( Instabug . colorTheme . light ) ;
136- } else if ( id == 1 ) {
137- Instabug . setColorTheme ( Instabug . colorTheme . dark ) ;
138- }
139- }
140- } ;
141-
142- showDialog = function ( ) {
143- let dialog = new DialogAndroid ( ) ;
144- dialog . set ( options ) ;
145- dialog . show ( ) ;
146- } ;
147-
148- showDialog ( ) ;
149- }
150-
151- _showPrimaryColorActionSheet ( ) {
152- let options = {
153- "items" : [
154- "Red" ,
155- "Green" ,
156- "Blue"
157- ] ,
158- "title" : "Instabug Primary Color" ,
159- itemsCallback : ( id , text ) => {
160- if ( id == 0 ) {
161- Instabug . setPrimaryColor ( processColor ( '#ff0000' ) ) ;
162- } else if ( id == 1 ) {
163- Instabug . setPrimaryColor ( processColor ( '#00ff00' ) ) ;
164- } else if ( id == 2 ) {
165- Instabug . setPrimaryColor ( processColor ( '#0000ff' ) ) ;
166- }
167- }
168- } ;
169-
170- showDialog = function ( ) {
171- let dialog = new DialogAndroid ( ) ;
172- dialog . set ( options ) ;
173- dialog . show ( ) ;
174- } ;
175-
176- showDialog ( ) ;
177- }
178-
179- _showLocaleActionSheet ( ) {
180-
181- let options = {
182- "items" : [
183- "Arabic" ,
184- "Chinese Simplified" ,
185- "Chinese Traditional" ,
186- "Czech" ,
187- "Danish" ,
188- "English" ,
189- "French" ,
190- "German" ,
191- "Italian" ,
192- "Japanese" ,
193- "Polish" ,
194- "Portuguese Brazil" ,
195- "Russian" ,
196- "Spanish" ,
197- "Swedish" ,
198- "Turkish"
199- ] ,
200- "title" : "Instabug Primary Color" ,
201- itemsCallback : ( id , text ) => {
202- if ( id == 0 ) {
203- Instabug . setLocale ( Instabug . locale . arabic ) ;
204- } else if ( id == 1 ) {
205- Instabug . setLocale ( Instabug . locale . chineseSimplified ) ;
206- } else if ( id == 2 ) {
207- Instabug . setLocale ( Instabug . locale . chineseTraditional ) ;
208- } else if ( id == 3 ) {
209- Instabug . setLocale ( Instabug . locale . czech ) ;
210- } else if ( id == 4 ) {
211- Instabug . setLocale ( Instabug . locale . danish ) ;
212- } else if ( id == 5 ) {
213- Instabug . setLocale ( Instabug . locale . english ) ;
214- } else if ( id == 6 ) {
215- Instabug . setLocale ( Instabug . locale . french ) ;
216- } else if ( id == 7 ) {
217- Instabug . setLocale ( Instabug . locale . german ) ;
218- } else if ( id == 8 ) {
219- Instabug . setLocale ( Instabug . locale . italian ) ;
220- } else if ( id == 9 ) {
221- Instabug . setLocale ( Instabug . locale . japanese ) ;
222- } else if ( id == 10 ) {
223- Instabug . setLocale ( Instabug . locale . polish ) ;
224- } else if ( id == 11 ) {
225- Instabug . setLocale ( Instabug . locale . portugueseBrazil ) ;
226- } else if ( id == 12 ) {
227- Instabug . setLocale ( Instabug . locale . russian ) ;
228- } else if ( id == 13 ) {
229- Instabug . setLocale ( Instabug . locale . spanish ) ;
230- } else if ( id == 14 ) {
231- Instabug . setLocale ( Instabug . locale . swedish ) ;
232- } else if ( id == 15 ) {
233- Instabug . setLocale ( Instabug . locale . turkish ) ;
234- }
235- }
236- } ;
237-
238- showDialog = function ( ) {
239- let dialog = new DialogAndroid ( ) ;
240- dialog . set ( options ) ;
241- dialog . show ( ) ;
242- } ;
243-
244- showDialog ( ) ;
245- }
246-
247- _showInvocationEventActionSheet ( ) {
248-
249-
250- let options = {
251- "items" : [
252- "Shake" ,
253- "Screenshot" ,
254- "Two fingers swipe" ,
255- "Floating button"
256- ] ,
257- "title" : "Instabug Themes" ,
258- itemsCallback : ( id , text ) => {
259- if ( id == 0 ) {
260- Instabug . setInvocationEvent ( Instabug . invocationEvent . shake ) ;
261- } else if ( id == 1 ) {
262- Instabug . setInvocationEvent ( Instabug . invocationEvent . screenshot ) ;
263- } else if ( id == 2 ) {
264- Instabug . setInvocationEvent ( Instabug . invocationEvent . twoFingersSwipe ) ;
265- } else if ( id ) {
266- Instabug . setInvocationEvent ( Instabug . invocationEvent . floatingButton ) ;
267- }
268- }
269- } ;
270-
271- showDialog = function ( ) {
272- let dialog = new DialogAndroid ( ) ;
273- dialog . set ( options ) ;
274- dialog . show ( ) ;
275- } ;
276-
277- showDialog ( ) ;
278- }
279-
280- _renderSeparator ( sectionID , rowID , adjacentRowHighlighted ) {
281- return (
282- < View
283- key = { `${ sectionID } -${ rowID } ` }
284- style = { {
285- height : adjacentRowHighlighted ? 4 : 1 ,
286- backgroundColor : adjacentRowHighlighted ? '#3B5998' : '#CCCCCC' ,
287- } }
288- />
289- ) ;
290- }
29133
29234 render ( ) {
293- console . log ( JSON . stringify ( this . state ) ) ;
29435 return (
295- < ListView
296- dataSource = { this . state . dataSource }
297- renderRow = { this . _renderRow . bind ( this ) }
298- renderScrollComponent = { props => < RecyclerViewBackedScrollView { ...props } /> }
299- style = { styles . listView }
300- />
36+ < View style = { styles . container } >
37+ < Text style = { styles . welcome } >
38+ Welcome to React Native!
39+ </ Text >
40+ < Text style = { styles . instructions } >
41+ To get started, edit index.android.js
42+ </ Text >
43+ < Text style = { styles . instructions } >
44+ Double tap R on your keyboard to reload,{ '\n' }
45+ Shake or press menu button for dev menu
46+ </ Text >
47+ < Button
48+ onPress = { ( ) => {
49+ console . log ( "invoke Button has been clicked" ) ;
50+ Instabug . invoke ( ) } }
51+ title = "Invoke Instabug"
52+ color = "#841584"
53+ disabled = { false }
54+ accessibilityLabel = "Learn more about this purple button"
55+ />
56+ </ View >
30157 ) ;
30258 }
30359}
30460
30561const styles = StyleSheet . create ( {
306- row : {
307- flexDirection : 'row' ,
62+ container : {
63+ flex : 1 ,
30864 justifyContent : 'center' ,
309- padding : 10 ,
310- backgroundColor : '#F6F6F6 ' ,
65+ alignItems : 'center' ,
66+ backgroundColor : '#F5FCFF ' ,
31167 } ,
312- thumb : {
313- width : 64 ,
314- height : 64 ,
315- } ,
316- text : {
317- flex : 1 ,
68+ welcome : {
69+ fontSize : 20 ,
70+ textAlign : 'center' ,
71+ margin : 10 ,
31872 } ,
319- listView : {
320- paddingTop : 20
73+ instructions : {
74+ textAlign : 'center' ,
75+ color : '#333333' ,
76+ marginBottom : 5 ,
32177 } ,
32278} ) ;
32379
0 commit comments