Skip to content

Commit 86dd770

Browse files
authored
Flutter [Sample App]: Create Flutter Sample App (#64)
* Create Sample App to match React Native's Sample App
1 parent e91149d commit 86dd770

File tree

4 files changed

+222
-151
lines changed

4 files changed

+222
-151
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## Master
1+
## Version 1.0.0-beta.1 (2019-04-16)
22

3+
* Adds New Sample App
34
* Adds Replies Api mappings
45
* Adds Chats Api mappings
56
* Adds FeatureRequests Api mappings.

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ A Flutter plugin for [Instabug](https://instabug.com/).
88

99
| Feature | Status |
1010
|:---------------------------------------------------------:|:-------:|
11-
| [Bug Reporting](https://instabug.com/bug-reporting) | ⚙️ |
12-
| [Crash Reporting](https://instabug.com/crash-reporting) | |
13-
| [In-App Chat](https://instabug.com/in-app-chat) | ⚙️ |
14-
| [In-App Surveys](https://instabug.com/in-app-surveys) | ⚙️ |
15-
| [Feature Requests](https://instabug.com/feature-requests) | ⚙️ |
11+
| [Bug Reporting](https://instabug.com/bug-reporting) | |
12+
| [Crash Reporting](https://instabug.com/crash-reporting) | |
13+
| [In-App Chat](https://instabug.com/in-app-chat) | |
14+
| [In-App Surveys](https://instabug.com/in-app-surveys) | |
15+
| [Feature Requests](https://instabug.com/feature-requests) | |
1616

1717
* ✅ Stable
1818
* ⚙️ Under active development
19-
* Not available yet
19+
* Not available yet
2020

2121
### APIs
2222

@@ -44,7 +44,6 @@ The section below contains the APIs we're planning to implement for our 1.0 rele
4444
| `show()` | `show()`<br>`+ show` |
4545
| `setSessionProfilerEnabled(bool sessionProfilerEnabled)` | `setSessionProfilerState(Feature.State state)`<br>`sessionProfilerEnabled` |
4646
| `setPrimaryColor(Color color)` | `setPrimaryColor(@ColorInt int primaryColorValue)`<br>`tintColor` |
47-
| | `onReportSubmitHandler(Report.OnReportCreatedListener listener)`<br>`willSendReportHandler`. |
4847
| `setUserData(String userData)` | `setUserData(String userData)`<br>`userData` |
4948
| `addFileAttachmentWithURL(String filePath, String fileName)` | `addFileAttachment(Uri fileUri, String fileNameWithExtension)`<br>`+ addFileAttachmentWithURL:` |
5049
| `addFileAttachmentWithData(Uint8List data, String fileName)` | `addFileAttachment(byte[] data, String fileNameWithExtension)` `+ addFileAttachmentWithData:` |

example/lib/main.dart

Lines changed: 213 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -35,54 +35,6 @@ class _MyAppState extends State<MyApp> {
3535
if (Platform.isIOS) {
3636
Instabug.start('068ba9a8c3615035e163dc5f829c73be', <InvocationEvent>[InvocationEvent.shake]);
3737
}
38-
//Instabug.showWelcomeMessageWithMode(WelcomeMessageMode.beta);
39-
//Instabug.setWelcomeMessageMode(WelcomeMessageMode.beta);
40-
Instabug.identifyUser('[email protected]', 'Aly Ezz');
41-
InstabugLog.logInfo('Test Log Info Message from Flutter!');
42-
InstabugLog.logDebug('Test Debug Message from Flutter!');
43-
InstabugLog.logVerbose('Test Verbose Message from Flutter!');
44-
InstabugLog.clearAllLogs();
45-
InstabugLog.logError('Test Error Message from Flutter!');
46-
InstabugLog.logWarn('Test Warn Message from Flutter!');
47-
Instabug.logOut();
48-
//Instabug.setLocale(Locale.German);
49-
Instabug.setColorTheme(ColorTheme.dark);
50-
Instabug.appendTags(<String>['tag1', 'tag2']);
51-
Instabug.setUserAttribute('19', 'Age');
52-
Instabug.setUserAttribute('female', 'gender');
53-
Instabug.removeUserAttribute('gender');
54-
final String value = await Instabug.getUserAttributeForKey('Age');
55-
print('User Attribute ' + value);
56-
final Map<String, String> userAttributes = await Instabug.getUserAttributes();
57-
print(userAttributes.toString());
58-
Instabug.logUserEvent('Aly Event');
59-
Instabug.setValueForStringWithKey('What\'s the problem', IBGCustomTextPlaceHolderKey.reportBug);
60-
Instabug.setValueForStringWithKey('Send some ideas', IBGCustomTextPlaceHolderKey.reportFeedback);
61-
Instabug.setSessionProfilerEnabled(false);
62-
Color c = const Color.fromRGBO(255, 0, 255, 1.0);
63-
Instabug.setPrimaryColor(c);
64-
Instabug.setUserData("This is some useful data");
65-
var list = Uint8List(10);
66-
Instabug.addFileAttachmentWithData(list, "My File");
67-
Instabug.clearFileAttachments();
68-
//Instabug.clearFileAttachments();
69-
//BugReporting.setEnabled(false);
70-
BugReporting.setOnInvokeCallback(sdkInvoked);
71-
BugReporting.setOnDismissCallback(sdkDismissed);
72-
BugReporting.setInvocationEvents(<InvocationEvent>[InvocationEvent.floatingButton]);
73-
Surveys.setEnabled(true);
74-
Surveys.setAutoShowingEnabled(false);
75-
Surveys.setOnShowCallback(surveyShown);
76-
Surveys.setOnDismissCallback(surveyDismiss);
77-
//Replies.setInAppNotificationsEnabled(false);
78-
Replies.setEnabled(true);
79-
Replies.show();
80-
Replies.setOnNewReplyReceivedCallback(replies);
81-
//BugReporting.setEnabledAttachmentTypes(false, false, false, false);
82-
//BugReporting.setReportTypes(<ReportType>[ReportType.FEEDBACK,ReportType.BUG]);
83-
//BugReporting.setExtendedBugReportMode(ExtendedBugReportMode.ENABLED_WITH_REQUIRED_FIELDS);
84-
//BugReporting.setInvocationOptions(<InvocationOption>[InvocationOption.EMAIL_FIELD_HIDDEN]);
85-
8638
} on PlatformException {
8739
platformVersion = 'Failed to get platform version.';
8840
}
@@ -96,92 +48,250 @@ class _MyAppState extends State<MyApp> {
9648
});
9749
}
9850

99-
void resetTags() {
100-
Instabug.resetTags();
51+
void show() {
52+
Instabug.show();
10153
}
10254

103-
void getSurveys(List<String> surveys) {
104-
int x = surveys.length;
105-
debugPrint(x.toString());
55+
void sendBugReport() {
56+
BugReporting.invoke(InvocationMode.bug, [InvocationOption.emailFieldOptional]);
10657
}
10758

108-
void sdkInvoked() {
109-
debugPrint("I am called before invocation");
59+
void sendFeedback() {
60+
BugReporting.invoke(InvocationMode.feedback, [InvocationOption.emailFieldOptional]);
11061
}
11162

112-
void surveyShown() {
113-
debugPrint("The user will se a survey nwoww");
63+
void startNewConversation () {
64+
Chats.show();
11465
}
11566

116-
void surveyDismiss() {
117-
debugPrint("The survey is Dismissed");
67+
void showNpsSurvey() {
68+
Surveys.showSurvey('pcV_mE2ttqHxT1iqvBxL0w');
11869
}
11970

120-
void sdkDismissed(DismissType dismissType, ReportType reportType) {
121-
debugPrint('SDK Dismissed DismissType: ' + dismissType.toString());
122-
debugPrint('SDK Dismissed ReportType: ' + reportType.toString());
71+
void showMultipleQuestionSurvey() {
72+
Surveys.showSurvey('ZAKSlVz98QdPyOx1wIt8BA');
12373
}
12474

125-
void hasResponded(bool hasResponded) {
126-
debugPrint(hasResponded.toString());
75+
void showFeatureRequests () {
76+
FeatureRequests.show();
12777
}
12878

129-
void replies() {
130-
debugPrint("new Replyyy");
131-
}
132-
void show() {
133-
//Instabug.show();
134-
// Surveys.getAvailableSurveys(getSurveys);
135-
// Surveys.showSurveyIfAvailable();
136-
// Surveys.setShouldShowWelcomeScreen(true);
137-
//Surveys.showSurvey("BHJI1iaKYhr4CYHHcUAaTg");
138-
//BugReporting.showWithOptions(ReportType.bug, <InvocationOption>[InvocationOption.emailFieldHidden]);
139-
// FeatureRequests.setEmailFieldRequired(false, [ActionType.allActions]);
140-
// FeatureRequests.show();
141-
// Replies.setEnabled(true);
142-
// Replies.show();
143-
//Replies.setInAppNotificationsEnabled(false);
144-
//Replies.getUnreadRepliesCount(replies);
79+
void setInvocationEvent(InvocationEvent invocationEvent) {
80+
BugReporting.setInvocationEvents([invocationEvent]);
14581
}
14682

147-
void invokeWithMode() {
148-
Surveys.hasRespondedToSurvey("BHJI1iaKYhr4CYHHcUAaTg", hasResponded);
149-
// BugReporting.invokeWithMode(InvocationMode.bug, [InvocationOption.emailFieldHidden]);
83+
void setPrimaryColor (Color c) {
84+
Instabug.setPrimaryColor(c);
15085
}
15186

152-
void getTags() async {
153-
final List<String> tags = await Instabug.getTags();
154-
print(tags.toString());
87+
void setColorTheme (ColorTheme colorTheme) {
88+
Instabug.setColorTheme(colorTheme);
15589
}
15690

15791
@override
15892
Widget build(BuildContext context) {
15993
return MaterialApp(
16094
home: Scaffold(
161-
appBar: AppBar(
162-
title: const Text('Plugin example app'),
163-
),
164-
body: Center(
95+
body: SingleChildScrollView(
96+
padding: EdgeInsets.only(top: 60.0),
16597
child: Column(
16698
mainAxisAlignment: MainAxisAlignment.center,
16799
children: <Widget>[
168-
Text('Running on: $_platformVersion\n'),
169-
RaisedButton(
100+
Container(
101+
margin: const EdgeInsets.only(left: 20.0, right: 20.0, bottom: 20.0),
102+
child : Text(
103+
'Hello Instabug\'s awesome user! The purpose of this application is to show you the different options for customizing the SDK and how easy it is to integrate it to your existing app',
104+
textAlign: TextAlign.center,
105+
),
106+
),
107+
Container(
108+
width: double.infinity,
109+
margin: const EdgeInsets.only(left: 20.0, right: 20.0),
110+
// height: double.infinity,
111+
child: RaisedButton(
170112
onPressed: show,
171-
child: Text('show'),
113+
textColor: Colors.white,
114+
child: Text('Invoke'),
115+
color: Colors.lightBlue),
116+
),
117+
Container(
118+
width: double.infinity,
119+
margin: const EdgeInsets.only(left: 20.0, right: 20.0),
120+
// height: double.infinity,
121+
child: RaisedButton(
122+
onPressed: sendBugReport,
123+
textColor: Colors.white,
124+
child: Text('Send Bug Report'),
125+
color: Colors.lightBlue),
126+
),
127+
Container(
128+
width: double.infinity,
129+
margin: const EdgeInsets.only(left: 20.0, right: 20.0),
130+
// height: double.infinity,
131+
child: RaisedButton(
132+
onPressed: sendFeedback,
133+
textColor: Colors.white,
134+
child: Text('Send Feedback'),
135+
color: Colors.lightBlue),
136+
),
137+
Container(
138+
width: double.infinity,
139+
margin: const EdgeInsets.only(left: 20.0, right: 20.0),
140+
// height: double.infinity,
141+
child: RaisedButton(
142+
onPressed: startNewConversation,
143+
textColor: Colors.white,
144+
child: Text('Start a New Conversation'),
145+
color: Colors.lightBlue),
146+
),
147+
Container(
148+
width: double.infinity,
149+
margin: const EdgeInsets.only(left: 20.0, right: 20.0),
150+
// height: double.infinity,
151+
child: RaisedButton(
152+
onPressed: showNpsSurvey,
153+
textColor: Colors.white,
154+
child: Text('Show NPS Survey'),
172155
color: Colors.lightBlue),
173-
RaisedButton(
174-
onPressed: invokeWithMode,
175-
child: Text('invokeWithMode'),
156+
),
157+
Container(
158+
width: double.infinity,
159+
margin: const EdgeInsets.only(left: 20.0, right: 20.0),
160+
// height: double.infinity,
161+
child: RaisedButton(
162+
onPressed: showMultipleQuestionSurvey,
163+
textColor: Colors.white,
164+
child: Text('Show Multiple Questions Survey'),
176165
color: Colors.lightBlue),
177-
RaisedButton(
178-
onPressed: resetTags,
179-
child: Text('reset tags'),
166+
),
167+
Container(
168+
width: double.infinity,
169+
margin: const EdgeInsets.only(left: 20.0, right: 20.0),
170+
// height: double.infinity,
171+
child: RaisedButton(
172+
onPressed: showFeatureRequests,
173+
textColor: Colors.white,
174+
child: Text('Show Feature Requests'),
180175
color: Colors.lightBlue),
181-
RaisedButton(
182-
onPressed: getTags,
183-
child: Text('get tags'),
184-
color: Colors.lightBlue)
176+
),
177+
Container(
178+
alignment: Alignment.centerLeft,
179+
margin: const EdgeInsets.only(top: 20.0, left: 20.0),
180+
child : Text(
181+
'Change Invocation Event',
182+
textAlign: TextAlign.left,
183+
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
184+
),
185+
),
186+
ButtonBar (
187+
mainAxisSize: MainAxisSize.min,
188+
alignment: MainAxisAlignment.start,
189+
children: <Widget>[
190+
RaisedButton(
191+
onPressed: ()=>setInvocationEvent(InvocationEvent.none),
192+
textColor: Colors.white,
193+
child: Text('none'),
194+
color: Colors.lightBlue),
195+
RaisedButton(
196+
onPressed: ()=>setInvocationEvent(InvocationEvent.shake),
197+
textColor: Colors.white,
198+
child: Text('Shake'),
199+
color: Colors.lightBlue),
200+
RaisedButton(
201+
onPressed: ()=>setInvocationEvent(InvocationEvent.screenshot),
202+
textColor: Colors.white,
203+
child: Text('Screenshot'),
204+
color: Colors.lightBlue),
205+
],
206+
),
207+
ButtonBar (
208+
mainAxisSize: MainAxisSize.min,
209+
alignment: MainAxisAlignment.start,
210+
children: <Widget>[
211+
RaisedButton(
212+
onPressed: ()=>setInvocationEvent(InvocationEvent.floatingButton),
213+
textColor: Colors.white,
214+
child: Text('Floating Button'),
215+
color: Colors.lightBlue),
216+
RaisedButton(
217+
onPressed: ()=>setInvocationEvent(InvocationEvent.twoFingersSwipeLeft),
218+
textColor: Colors.white,
219+
child: Text('Two Fingers Swipe Left'),
220+
color: Colors.lightBlue),
221+
],
222+
),
223+
Container(
224+
alignment: Alignment.centerLeft,
225+
margin: const EdgeInsets.only( left: 20.0),
226+
child : Text(
227+
'Set Primary Color',
228+
textAlign: TextAlign.left,
229+
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
230+
),
231+
),
232+
ButtonBar (
233+
mainAxisSize: MainAxisSize.min,
234+
alignment: MainAxisAlignment.center,
235+
children: <Widget>[
236+
ButtonTheme(
237+
minWidth: 50.0,
238+
height: 30.0,
239+
child: RaisedButton(
240+
onPressed: ()=>setPrimaryColor(Colors.red),
241+
textColor: Colors.white,
242+
color: Colors.red),
243+
),
244+
ButtonTheme(
245+
minWidth: 50.0,
246+
height: 30.0,
247+
child: RaisedButton(
248+
onPressed: ()=>setPrimaryColor(Colors.green),
249+
textColor: Colors.white,
250+
color: Colors.green),
251+
),
252+
ButtonTheme(
253+
minWidth: 50.0,
254+
height: 30.0,
255+
child: RaisedButton(
256+
onPressed: ()=>setPrimaryColor(Colors.blue),
257+
textColor: Colors.white,
258+
color: Colors.blue),
259+
),
260+
ButtonTheme(
261+
minWidth: 50.0,
262+
height: 30.0,
263+
child: RaisedButton(
264+
onPressed: ()=>setPrimaryColor(Colors.yellow),
265+
textColor: Colors.white,
266+
color: Colors.yellow),
267+
),
268+
],
269+
),
270+
Container(
271+
alignment: Alignment.centerLeft,
272+
margin: const EdgeInsets.only( left: 20.0),
273+
child : Text(
274+
'Color Theme',
275+
textAlign: TextAlign.left,
276+
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
277+
),
278+
),
279+
ButtonBar (
280+
mainAxisSize: MainAxisSize.max,
281+
alignment: MainAxisAlignment.center,
282+
children: <Widget>[
283+
RaisedButton(
284+
onPressed: ()=> setColorTheme(ColorTheme.light),
285+
textColor: Colors.lightBlue,
286+
child: Text('Light'),
287+
color: Colors.white),
288+
RaisedButton(
289+
onPressed: ()=> setColorTheme(ColorTheme.dark),
290+
textColor: Colors.white,
291+
child: Text('Dark'),
292+
color: Colors.black),
293+
],
294+
),
185295
],
186296
)),
187297
),

0 commit comments

Comments
 (0)