Skip to content

Commit 6dcdffb

Browse files
feat: add private view example page (#525)
* feat: add private view page * fix private view screen
1 parent 5b94581 commit 6dcdffb

File tree

6 files changed

+231
-5
lines changed

6 files changed

+231
-5
lines changed

example/assets/img.png

177 KB
Loading

example/lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:instabug_flutter/instabug_flutter.dart';
88
import 'package:instabug_http_client/instabug_http_client.dart';
99
import 'package:instabug_flutter_example/src/app_routes.dart';
1010
import 'package:instabug_flutter_example/src/widget/nested_view.dart';
11+
import 'package:video_player/video_player.dart';
1112

1213
import 'src/native/instabug_flutter_example_method_channel.dart';
1314
import 'src/widget/instabug_button.dart';
@@ -40,6 +41,7 @@ part 'src/components/page.dart';
4041
part 'src/components/traces_content.dart';
4142

4243
part 'src/components/flows_content.dart';
44+
part 'src/screens/private_view_page.dart';
4345

4446
void main() {
4547
runZonedGuarded(

example/lib/src/screens/my_home_page.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ class _MyHomePageState extends State<MyHomePage> {
151151
);
152152
}
153153

154+
void _navigateToPrivateViews() {
155+
Navigator.push(
156+
context,
157+
MaterialPageRoute(
158+
builder: (context) => const InstabugCaptureScreenLoading(
159+
screenName: ApmPage.screenName,
160+
child: PrivateViewPage(),
161+
),
162+
settings: const RouteSettings(name: ApmPage.screenName),
163+
),
164+
);
165+
}
166+
154167
void _navigateToComplex() {
155168
Navigator.push(
156169
context,
@@ -310,6 +323,12 @@ class _MyHomePageState extends State<MyHomePage> {
310323
onPressed: _navigateToComplex,
311324
text: 'Complex',
312325
),
326+
InstabugPrivateView(
327+
child: InstabugButton(
328+
onPressed: _navigateToPrivateViews,
329+
text: 'Private views',
330+
),
331+
),
313332
const SectionTitle('Sessions Replay'),
314333
InstabugButton(
315334
onPressed: getCurrentSessionReplaylink,
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
part of '../../main.dart';
2+
3+
class PrivateViewPage extends StatefulWidget {
4+
const PrivateViewPage({Key? key}) : super(key: key);
5+
6+
@override
7+
_PrivateViewPageState createState() => _PrivateViewPageState();
8+
}
9+
10+
class _PrivateViewPageState extends State<PrivateViewPage> {
11+
late VideoPlayerController _controller;
12+
final _scaffoldKey = GlobalKey<ScaffoldState>();
13+
14+
@override
15+
void initState() {
16+
super.initState();
17+
_controller = VideoPlayerController.networkUrl(
18+
Uri.parse(
19+
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'),
20+
)..initialize().then((_) {
21+
setState(() {});
22+
});
23+
}
24+
25+
@override
26+
void dispose() {
27+
_controller.dispose();
28+
super.dispose();
29+
}
30+
31+
@override
32+
Widget build(BuildContext context) {
33+
return Page(scaffoldKey: _scaffoldKey, title: 'Private views', children: [
34+
SingleChildScrollView(
35+
child: Padding(
36+
padding: const EdgeInsets.all(8.0),
37+
child: Column(
38+
crossAxisAlignment: CrossAxisAlignment.center,
39+
children: [
40+
const SizedBox(height: 16),
41+
InstabugPrivateView(
42+
child: const Text(
43+
'Private TextView',
44+
style: TextStyle(fontSize: 18),
45+
textAlign: TextAlign.center,
46+
),
47+
),
48+
const SizedBox(height: 16),
49+
InstabugPrivateView(
50+
child: ElevatedButton(
51+
onPressed: () {
52+
const snackBar = SnackBar(
53+
content: Text('Hello, you clicked on a private button'),
54+
);
55+
ScaffoldMessenger.of(context).showSnackBar(snackBar);
56+
},
57+
child: const Text('I am a private button'),
58+
),
59+
),
60+
const SizedBox(height: 16),
61+
InstabugPrivateView(
62+
child: Image.asset(
63+
'assets/img.png',
64+
// Add this image to your assets folder
65+
height: 100,
66+
),
67+
),
68+
const SizedBox(height: 33),
69+
InstabugPrivateView(
70+
child: const TextField(
71+
obscureText: true,
72+
decoration: InputDecoration(
73+
hintText: 'password',
74+
labelText: 'Password',
75+
border: OutlineInputBorder(),
76+
),
77+
),
78+
),
79+
const SizedBox(height: 16),
80+
const TextField(
81+
keyboardType: TextInputType.emailAddress,
82+
decoration: InputDecoration(
83+
hintText: 'Email',
84+
labelText: 'Email',
85+
border: OutlineInputBorder(),
86+
),
87+
),
88+
const SizedBox(height: 24),
89+
InstabugPrivateView(
90+
child: Container(
91+
height: 300,
92+
child: _controller.value.isInitialized
93+
? AspectRatio(
94+
aspectRatio: _controller.value.aspectRatio,
95+
child: VideoPlayer(_controller),
96+
)
97+
: const Center(child: CircularProgressIndicator()),
98+
),
99+
),
100+
const SizedBox(height: 24),
101+
const SizedBox(height: 24),
102+
const SizedBox(height: 24),
103+
SizedBox(
104+
height: 200,
105+
child: CustomScrollView(
106+
slivers: [
107+
InstabugSliverPrivateView(
108+
sliver: SliverToBoxAdapter(
109+
child: Container(
110+
color: Colors.red,
111+
child: Text(
112+
"Private Sliver Widget",
113+
style: TextStyle(fontSize: 18),
114+
textAlign: TextAlign.center,
115+
),
116+
),
117+
),
118+
)
119+
],
120+
),
121+
)
122+
],
123+
),
124+
),
125+
),
126+
]);
127+
}
128+
}

example/pubspec.lock

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ packages:
4141
url: "https://pub.dev"
4242
source: hosted
4343
version: "1.18.0"
44+
csslib:
45+
dependency: transitive
46+
description:
47+
name: csslib
48+
sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb"
49+
url: "https://pub.dev"
50+
source: hosted
51+
version: "1.0.0"
4452
fake_async:
4553
dependency: transitive
4654
description:
@@ -80,11 +88,24 @@ packages:
8088
description: flutter
8189
source: sdk
8290
version: "0.0.0"
91+
flutter_web_plugins:
92+
dependency: transitive
93+
description: flutter
94+
source: sdk
95+
version: "0.0.0"
8396
fuchsia_remote_debug_protocol:
8497
dependency: transitive
8598
description: flutter
8699
source: sdk
87100
version: "0.0.0"
101+
html:
102+
dependency: transitive
103+
description:
104+
name: html
105+
sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a"
106+
url: "https://pub.dev"
107+
source: hosted
108+
version: "0.15.4"
88109
http:
89110
dependency: "direct main"
90111
description:
@@ -188,6 +209,14 @@ packages:
188209
url: "https://pub.dev"
189210
source: hosted
190211
version: "3.1.5"
212+
plugin_platform_interface:
213+
dependency: transitive
214+
description:
215+
name: plugin_platform_interface
216+
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
217+
url: "https://pub.dev"
218+
source: hosted
219+
version: "2.1.8"
191220
process:
192221
dependency: transitive
193222
description:
@@ -273,6 +302,46 @@ packages:
273302
url: "https://pub.dev"
274303
source: hosted
275304
version: "2.1.4"
305+
video_player:
306+
dependency: "direct main"
307+
description:
308+
name: video_player
309+
sha256: "4a8c3492d734f7c39c2588a3206707a05ee80cef52e8c7f3b2078d430c84bc17"
310+
url: "https://pub.dev"
311+
source: hosted
312+
version: "2.9.2"
313+
video_player_android:
314+
dependency: transitive
315+
description:
316+
name: video_player_android
317+
sha256: "391e092ba4abe2f93b3e625bd6b6a6ec7d7414279462c1c0ee42b5ab8d0a0898"
318+
url: "https://pub.dev"
319+
source: hosted
320+
version: "2.7.16"
321+
video_player_avfoundation:
322+
dependency: transitive
323+
description:
324+
name: video_player_avfoundation
325+
sha256: cd5ab8a8bc0eab65ab0cea40304097edc46da574c8c1ecdee96f28cd8ef3792f
326+
url: "https://pub.dev"
327+
source: hosted
328+
version: "2.6.2"
329+
video_player_platform_interface:
330+
dependency: transitive
331+
description:
332+
name: video_player_platform_interface
333+
sha256: "229d7642ccd9f3dc4aba169609dd6b5f3f443bb4cc15b82f7785fcada5af9bbb"
334+
url: "https://pub.dev"
335+
source: hosted
336+
version: "6.2.3"
337+
video_player_web:
338+
dependency: transitive
339+
description:
340+
name: video_player_web
341+
sha256: "881b375a934d8ebf868c7fb1423b2bfaa393a0a265fa3f733079a86536064a10"
342+
url: "https://pub.dev"
343+
source: hosted
344+
version: "2.3.3"
276345
vm_service:
277346
dependency: transitive
278347
description:
@@ -281,6 +350,14 @@ packages:
281350
url: "https://pub.dev"
282351
source: hosted
283352
version: "14.2.5"
353+
web:
354+
dependency: transitive
355+
description:
356+
name: web
357+
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
358+
url: "https://pub.dev"
359+
source: hosted
360+
version: "1.1.0"
284361
webdriver:
285362
dependency: transitive
286363
description:
@@ -290,5 +367,5 @@ packages:
290367
source: hosted
291368
version: "3.0.3"
292369
sdks:
293-
dart: ">=3.3.0 <4.0.0"
294-
flutter: ">=3.18.0-18.0.pre.54"
370+
dart: ">=3.5.0 <4.0.0"
371+
flutter: ">=3.24.0"

example/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dependencies:
2727
instabug_flutter:
2828
path: ../
2929
instabug_http_client: ^2.4.0
30+
video_player:
3031

3132
dev_dependencies:
3233
flutter_driver:
@@ -50,9 +51,8 @@ flutter:
5051
uses-material-design: true
5152

5253
# To add assets to your application, add an assets section, like this:
53-
# assets:
54-
# - images/a_dot_burr.jpeg
55-
# - images/a_dot_ham.jpeg
54+
assets:
55+
- assets/img.png
5656

5757
# An image asset can refer to one or more resolution-specific "variants", see
5858
# https://flutter.dev/assets-and-images/#resolution-aware.

0 commit comments

Comments
 (0)