@@ -10,7 +10,11 @@ class BugReportingPage extends StatefulWidget {
10
10
}
11
11
12
12
class _BugReportingPageState extends State <BugReportingPage > {
13
- List <ReportType > reportTypes = [ReportType .bug,ReportType .feedback,ReportType .question];
13
+ List <ReportType > reportTypes = [
14
+ ReportType .bug,
15
+ ReportType .feedback,
16
+ ReportType .question
17
+ ];
14
18
List <InvocationOption > invocationOptions = [];
15
19
16
20
final disclaimerTextController = TextEditingController ();
@@ -19,6 +23,7 @@ class _BugReportingPageState extends State<BugReportingPage> {
19
23
bool attachmentsOptionsExtraScreenshot = true ;
20
24
bool attachmentsOptionsGalleryImage = true ;
21
25
bool attachmentsOptionsScreenRecording = true ;
26
+ File ? fileAttachment;
22
27
23
28
void restartInstabug () {
24
29
Instabug .setEnabled (false );
@@ -30,13 +35,11 @@ class _BugReportingPageState extends State<BugReportingPage> {
30
35
BugReporting .setInvocationEvents ([invocationEvent]);
31
36
}
32
37
33
- void setUserConsent (
34
- String key,
35
- String description,
36
- bool mandatory,
37
- bool checked,
38
- UserConsentActionType ? actionType,
39
- ) {
38
+ void setUserConsent (String key,
39
+ String description,
40
+ bool mandatory,
41
+ bool checked,
42
+ UserConsentActionType ? actionType,) {
40
43
BugReporting .addUserConsents (
41
44
key: key,
42
45
description: description,
@@ -49,6 +52,21 @@ class _BugReportingPageState extends State<BugReportingPage> {
49
52
Instabug .show ();
50
53
}
51
54
55
+ Future <void > addFileAttachment () async {
56
+ FilePickerResult ? result = await FilePicker .platform.pickFiles ();
57
+
58
+ if (result != null ) {
59
+ fileAttachment = File (result.files.single.path! );
60
+ Instabug .addFileAttachmentWithURL (fileAttachment! .path, fileAttachment! .path
61
+ .split ('/' )
62
+ .last.substring (0 ));
63
+ }
64
+ }
65
+
66
+ void removeFileAttachment () {
67
+ Instabug .clearFileAttachments ();
68
+ }
69
+
52
70
void addAttachmentOptions () {
53
71
BugReporting .setEnabledAttachmentTypes (
54
72
attachmentsOptionsScreenshot,
@@ -84,9 +102,10 @@ class _BugReportingPageState extends State<BugReportingPage> {
84
102
if (dismissType == DismissType .submit) {
85
103
showDialog (
86
104
context: context,
87
- builder: (_) => const AlertDialog (
88
- title: Text ('Bug Reporting sent' ),
89
- ));
105
+ builder: (_) =>
106
+ const AlertDialog (
107
+ title: Text ('Bug Reporting sent' ),
108
+ ));
90
109
}
91
110
});
92
111
}
@@ -192,22 +211,24 @@ class _BugReportingPageState extends State<BugReportingPage> {
192
211
children: < Widget > [
193
212
ElevatedButton (
194
213
key: const Key ('user_consent_media_manadatory' ),
195
- onPressed: () => setUserConsent (
196
- 'media_mandatory' ,
197
- "Mandatory for Media" ,
198
- true ,
199
- true ,
200
- UserConsentActionType .dropAutoCapturedMedia),
214
+ onPressed: () =>
215
+ setUserConsent (
216
+ 'media_mandatory' ,
217
+ "Mandatory for Media" ,
218
+ true ,
219
+ true ,
220
+ UserConsentActionType .dropAutoCapturedMedia),
201
221
child: const Text ('Drop Media Mandatory' ),
202
222
),
203
223
ElevatedButton (
204
224
key: const Key ('user_consent_no_chat_manadatory' ),
205
- onPressed: () => setUserConsent (
206
- 'noChat_mandatory' ,
207
- "Mandatory for No Chat" ,
208
- true ,
209
- true ,
210
- UserConsentActionType .noChat),
225
+ onPressed: () =>
226
+ setUserConsent (
227
+ 'noChat_mandatory' ,
228
+ "Mandatory for No Chat" ,
229
+ true ,
230
+ true ,
231
+ UserConsentActionType .noChat),
211
232
child: const Text ('No Chat Mandatory' ),
212
233
),
213
234
],
@@ -219,22 +240,24 @@ class _BugReportingPageState extends State<BugReportingPage> {
219
240
children: < Widget > [
220
241
ElevatedButton (
221
242
key: const Key ('user_consent_drop_logs_manadatory' ),
222
- onPressed: () => setUserConsent (
223
- 'dropLogs_mandatory' ,
224
- "Mandatory for Drop logs" ,
225
- true ,
226
- true ,
227
- UserConsentActionType .dropLogs),
243
+ onPressed: () =>
244
+ setUserConsent (
245
+ 'dropLogs_mandatory' ,
246
+ "Mandatory for Drop logs" ,
247
+ true ,
248
+ true ,
249
+ UserConsentActionType .dropLogs),
228
250
child: const Text ('Drop logs Mandatory' ),
229
251
),
230
252
ElevatedButton (
231
253
key: const Key ('user_consent_no_chat_optional' ),
232
- onPressed: () => setUserConsent (
233
- 'noChat_mandatory' ,
234
- "Optional for No Chat" ,
235
- false ,
236
- true ,
237
- UserConsentActionType .noChat),
254
+ onPressed: () =>
255
+ setUserConsent (
256
+ 'noChat_mandatory' ,
257
+ "Optional for No Chat" ,
258
+ false ,
259
+ true ,
260
+ UserConsentActionType .noChat),
238
261
child: const Text ('No Chat optional' ),
239
262
),
240
263
],
@@ -246,8 +269,9 @@ class _BugReportingPageState extends State<BugReportingPage> {
246
269
children: < Widget > [
247
270
ElevatedButton (
248
271
key: const Key ('invocation_option_disable_post_sending_dialog' ),
249
- onPressed: () => addInvocationOption (
250
- InvocationOption .disablePostSendingDialog),
272
+ onPressed: () =>
273
+ addInvocationOption (
274
+ InvocationOption .disablePostSendingDialog),
251
275
child: const Text ('disablePostSendingDialog' ),
252
276
),
253
277
ElevatedButton (
@@ -305,7 +329,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
305
329
attachmentsOptionsExtraScreenshot = value ?? false ;
306
330
});
307
331
addAttachmentOptions ();
308
-
309
332
},
310
333
title: const Text ("Extra Screenshot" ),
311
334
subtitle: const Text ('Enable attachment for extra screenShot' ),
@@ -319,7 +342,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
319
342
attachmentsOptionsGalleryImage = value ?? false ;
320
343
});
321
344
addAttachmentOptions ();
322
-
323
345
},
324
346
title: const Text ("Gallery" ),
325
347
subtitle: const Text ('Enable attachment for gallery' ),
@@ -333,7 +355,6 @@ class _BugReportingPageState extends State<BugReportingPage> {
333
355
attachmentsOptionsScreenRecording = value ?? false ;
334
356
});
335
357
addAttachmentOptions ();
336
-
337
358
},
338
359
title: const Text ("Screen Recording" ),
339
360
subtitle: const Text ('Enable attachment for screen Recording' ),
@@ -344,38 +365,46 @@ class _BugReportingPageState extends State<BugReportingPage> {
344
365
),
345
366
const SectionTitle ('Bug reporting type' ),
346
367
347
- ButtonBar (
348
- mainAxisSize: MainAxisSize .min,
349
- alignment: MainAxisAlignment .start,
350
- children: < Widget > [
351
- ElevatedButton (
352
- key: const Key ('bug_report_type_bug' ),
353
- style: ElevatedButton .styleFrom (
354
- backgroundColor: reportTypes.contains (ReportType .bug)? Colors .grey.shade400: null
355
- ),
356
- onPressed: () => toggleReportType (ReportType .bug),
357
- child: const Text ('Bug' ),
358
- ),
359
- ElevatedButton (
360
- key: const Key ('bug_report_type_feedback' ),
361
- onPressed: () => toggleReportType (ReportType .feedback),
362
- style: ElevatedButton .styleFrom (
363
- backgroundColor: reportTypes.contains (ReportType .feedback)? Colors .grey.shade400: null
364
- ),
365
- child: const Text ('Feedback' ),
366
- ),
367
- ElevatedButton (
368
- key: const Key ('bug_report_type_question' ),
369
- onPressed: () => toggleReportType (ReportType .question),
370
- style: ElevatedButton .styleFrom (
371
- backgroundColor: reportTypes.contains (ReportType .question)? Colors .grey.shade400: null
372
- ),
373
- child: const Text ('Question' ),
374
- ),
375
- ],
368
+ CheckboxListTile (
369
+ value: reportTypes.contains (ReportType .bug),
370
+ onChanged: (value) {
371
+ toggleReportType (ReportType .bug);
372
+ setState (() {
373
+ });
374
+ },
375
+ title: const Text ("Bug" ),
376
+ subtitle: const Text ('Enable Bug reporting type' ),
377
+ key: const Key ('bug_report_type_bug' ),
378
+
379
+ ),
380
+ CheckboxListTile (
381
+ value: reportTypes.contains (ReportType .feedback),
382
+ onChanged: (value) {
383
+ toggleReportType (ReportType .feedback);
384
+ setState (() {
385
+ });
386
+ },
387
+ title: const Text ("Feedback" ),
388
+ subtitle: const Text ('Enable Feedback reporting type' ),
389
+ key: const Key ('bug_report_type_feedback' ),
390
+
391
+ ),
392
+
393
+ CheckboxListTile (
394
+ value: reportTypes.contains (ReportType .question),
395
+ onChanged: (value) {
396
+ toggleReportType (ReportType .question);
397
+ setState (() {
398
+ });
399
+ },
400
+ title: const Text ("Question" ),
401
+ subtitle: const Text ('Enable Question reporting type' ),
402
+ key: const Key ('bug_report_type_question' ),
403
+
376
404
),
377
405
InstabugButton (
378
- onPressed: () => {
406
+ onPressed: () =>
407
+ {
379
408
BugReporting .show (
380
409
ReportType .bug, [InvocationOption .emailFieldOptional])
381
410
},
@@ -400,15 +429,17 @@ class _BugReportingPageState extends State<BugReportingPage> {
400
429
children: < Widget > [
401
430
ElevatedButton (
402
431
key: const Key ('extended_bug_report_mode_disabled' ),
403
- onPressed: () => BugReporting .setExtendedBugReportMode (
404
- ExtendedBugReportMode .disabled),
432
+ onPressed: () =>
433
+ BugReporting .setExtendedBugReportMode (
434
+ ExtendedBugReportMode .disabled),
405
435
child: const Text ('disabled' ),
406
436
),
407
437
ElevatedButton (
408
438
key:
409
- const Key ('extended_bug_report_mode_required_fields_enabled' ),
410
- onPressed: () => BugReporting .setExtendedBugReportMode (
411
- ExtendedBugReportMode .enabledWithRequiredFields),
439
+ const Key ('extended_bug_report_mode_required_fields_enabled' ),
440
+ onPressed: () =>
441
+ BugReporting .setExtendedBugReportMode (
442
+ ExtendedBugReportMode .enabledWithRequiredFields),
412
443
child: const Text ('enabledWithRequiredFields' ),
413
444
),
414
445
],
@@ -419,9 +450,10 @@ class _BugReportingPageState extends State<BugReportingPage> {
419
450
children: < Widget > [
420
451
ElevatedButton (
421
452
key:
422
- const Key ('extended_bug_report_mode_optional_fields_enabled' ),
423
- onPressed: () => BugReporting .setExtendedBugReportMode (
424
- ExtendedBugReportMode .enabledWithOptionalFields),
453
+ const Key ('extended_bug_report_mode_optional_fields_enabled' ),
454
+ onPressed: () =>
455
+ BugReporting .setExtendedBugReportMode (
456
+ ExtendedBugReportMode .enabledWithOptionalFields),
425
457
child: const Text ('enabledWithOptionalFields' ),
426
458
),
427
459
],
@@ -431,6 +463,15 @@ class _BugReportingPageState extends State<BugReportingPage> {
431
463
onPressed: setOnDismissCallback,
432
464
text: 'Set On Dismiss Callback' ,
433
465
),
466
+ const SectionTitle ('Attachments' ),
467
+ InstabugButton (
468
+ onPressed: addFileAttachment,
469
+ text: 'Add file attachment' ,
470
+ ),
471
+ InstabugButton (
472
+ onPressed: removeFileAttachment,
473
+ text: 'Clear All attachment' ,
474
+ ),
434
475
], // This trailing comma makes auto-formatting nicer for build methods.
435
476
);
436
477
}
0 commit comments