Skip to content

feat: add private view example page #525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added example/assets/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:instabug_flutter/instabug_flutter.dart';
import 'package:instabug_http_client/instabug_http_client.dart';
import 'package:instabug_flutter_example/src/app_routes.dart';
import 'package:instabug_flutter_example/src/widget/nested_view.dart';
import 'package:video_player/video_player.dart';

import 'src/native/instabug_flutter_example_method_channel.dart';
import 'src/widget/instabug_button.dart';
Expand Down Expand Up @@ -40,6 +41,7 @@ part 'src/components/page.dart';
part 'src/components/traces_content.dart';

part 'src/components/flows_content.dart';
part 'src/screens/private_view_page.dart';

void main() {
runZonedGuarded(
Expand Down
19 changes: 19 additions & 0 deletions example/lib/src/screens/my_home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ class _MyHomePageState extends State<MyHomePage> {
);
}

void _navigateToPrivateViews() {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const InstabugCaptureScreenLoading(
screenName: ApmPage.screenName,
child: PrivateViewPage(),
),
settings: const RouteSettings(name: ApmPage.screenName),
),
);
}

void _navigateToComplex() {
Navigator.push(
context,
Expand Down Expand Up @@ -310,6 +323,12 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: _navigateToComplex,
text: 'Complex',
),
InstabugPrivateView(
child: InstabugButton(
onPressed: _navigateToPrivateViews,
text: 'Private views',
),
),
const SectionTitle('Sessions Replay'),
InstabugButton(
onPressed: getCurrentSessionReplaylink,
Expand Down
128 changes: 128 additions & 0 deletions example/lib/src/screens/private_view_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
part of '../../main.dart';

class PrivateViewPage extends StatefulWidget {
const PrivateViewPage({Key? key}) : super(key: key);

@override
_PrivateViewPageState createState() => _PrivateViewPageState();
}

class _PrivateViewPageState extends State<PrivateViewPage> {
late VideoPlayerController _controller;
final _scaffoldKey = GlobalKey<ScaffoldState>();

@override
void initState() {
super.initState();
_controller = VideoPlayerController.networkUrl(
Uri.parse(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'),
)..initialize().then((_) {
setState(() {});
});
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Page(scaffoldKey: _scaffoldKey, title: 'Private views', children: [
SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 16),
InstabugPrivateView(
child: const Text(
'Private TextView',
style: TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
),
const SizedBox(height: 16),
InstabugPrivateView(
child: ElevatedButton(
onPressed: () {
const snackBar = SnackBar(
content: Text('Hello, you clicked on a private button'),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
child: const Text('I am a private button'),
),
),
const SizedBox(height: 16),
InstabugPrivateView(
child: Image.asset(
'assets/img.png',
// Add this image to your assets folder
height: 100,
),
),
const SizedBox(height: 33),
InstabugPrivateView(
child: const TextField(
obscureText: true,
decoration: InputDecoration(
hintText: 'password',
labelText: 'Password',
border: OutlineInputBorder(),
),
),
),
const SizedBox(height: 16),
const TextField(
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
hintText: 'Email',
labelText: 'Email',
border: OutlineInputBorder(),
),
),
const SizedBox(height: 24),
InstabugPrivateView(
child: Container(
height: 300,
child: _controller.value.isInitialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
)
: const Center(child: CircularProgressIndicator()),
),
),
const SizedBox(height: 24),
const SizedBox(height: 24),
const SizedBox(height: 24),
SizedBox(
height: 200,
child: CustomScrollView(
slivers: [
InstabugSliverPrivateView(
sliver: SliverToBoxAdapter(
child: Container(
color: Colors.red,
child: Text(
"Private Sliver Widget",
style: TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
),
),
)
],
),
)
],
),
),
),
]);
}
}
81 changes: 79 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
csslib:
dependency: transitive
description:
name: csslib
sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -80,11 +88,24 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
html:
dependency: transitive
description:
name: html
sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a"
url: "https://pub.dev"
source: hosted
version: "0.15.4"
http:
dependency: "direct main"
description:
Expand Down Expand Up @@ -188,6 +209,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.5"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
process:
dependency: transitive
description:
Expand Down Expand Up @@ -273,6 +302,46 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
video_player:
dependency: "direct main"
description:
name: video_player
sha256: "4a8c3492d734f7c39c2588a3206707a05ee80cef52e8c7f3b2078d430c84bc17"
url: "https://pub.dev"
source: hosted
version: "2.9.2"
video_player_android:
dependency: transitive
description:
name: video_player_android
sha256: "391e092ba4abe2f93b3e625bd6b6a6ec7d7414279462c1c0ee42b5ab8d0a0898"
url: "https://pub.dev"
source: hosted
version: "2.7.16"
video_player_avfoundation:
dependency: transitive
description:
name: video_player_avfoundation
sha256: cd5ab8a8bc0eab65ab0cea40304097edc46da574c8c1ecdee96f28cd8ef3792f
url: "https://pub.dev"
source: hosted
version: "2.6.2"
video_player_platform_interface:
dependency: transitive
description:
name: video_player_platform_interface
sha256: "229d7642ccd9f3dc4aba169609dd6b5f3f443bb4cc15b82f7785fcada5af9bbb"
url: "https://pub.dev"
source: hosted
version: "6.2.3"
video_player_web:
dependency: transitive
description:
name: video_player_web
sha256: "881b375a934d8ebf868c7fb1423b2bfaa393a0a265fa3f733079a86536064a10"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
vm_service:
dependency: transitive
description:
Expand All @@ -281,6 +350,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "14.2.5"
web:
dependency: transitive
description:
name: web
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.dev"
source: hosted
version: "1.1.0"
webdriver:
dependency: transitive
description:
Expand All @@ -290,5 +367,5 @@ packages:
source: hosted
version: "3.0.3"
sdks:
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies:
instabug_flutter:
path: ../
instabug_http_client: ^2.4.0
video_player:

dev_dependencies:
flutter_driver:
Expand All @@ -50,9 +51,8 @@ flutter:
uses-material-design: true

# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets:
- assets/img.png

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