[platform_view]Send platform message when platform view is focused (#105050)
This commit is contained in:
@@ -6,7 +6,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
|
||||
void main() {
|
||||
enableFlutterDriverExtension();
|
||||
// enableFlutterDriverExtension() will disable keyboard,
|
||||
// which is required for flutter_driver tests
|
||||
// But breaks the XCUITests
|
||||
if (const bool.fromEnvironment('ENABLE_DRIVER_EXTENSION')) {
|
||||
enableFlutterDriverExtension();
|
||||
}
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
@@ -26,7 +31,7 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// A page with a button in the center.
|
||||
/// A page with several buttons in the center.
|
||||
///
|
||||
/// On press the button, a page with platform view should be pushed into the scene.
|
||||
class MyHomePage extends StatefulWidget {
|
||||
@@ -51,8 +56,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute<PlatformViewPage>(
|
||||
builder: (BuildContext context) => const PlatformViewPage()),
|
||||
MaterialPageRoute<MergeThreadTestPage>(
|
||||
builder: (BuildContext context) => const MergeThreadTestPage()),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -62,14 +67,25 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
child: const Text('Tap to unmerge threads'),
|
||||
onPressed: () {},
|
||||
),
|
||||
TextButton(
|
||||
key: const ValueKey<String>('platform_view_focus_test'),
|
||||
child: const Text('platform view focus test'),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute<FocusTestPage>(
|
||||
builder: (BuildContext context) => const FocusTestPage()),
|
||||
);
|
||||
},
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A page contains the platform view to be tested.
|
||||
class PlatformViewPage extends StatelessWidget {
|
||||
const PlatformViewPage({super.key});
|
||||
/// A page to test thread merge for platform view.
|
||||
class MergeThreadTestPage extends StatelessWidget {
|
||||
const MergeThreadTestPage({super.key});
|
||||
|
||||
static Key button = const ValueKey<String>('plus_button');
|
||||
|
||||
@@ -77,7 +93,7 @@ class PlatformViewPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Platform View'),
|
||||
title: const Text('Platform View Thread Merge Tests'),
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
@@ -97,3 +113,44 @@ class PlatformViewPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A page to test platform view focus.
|
||||
class FocusTestPage extends StatefulWidget {
|
||||
const FocusTestPage({super.key});
|
||||
|
||||
@override
|
||||
State<FocusTestPage> createState() => _FocusTestPageState();
|
||||
}
|
||||
|
||||
class _FocusTestPageState extends State<FocusTestPage> {
|
||||
|
||||
late TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = TextEditingController();
|
||||
_controller.text = 'Flutter Text Field';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Platform View Focus Tests'),
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
width: 300,
|
||||
height: 50,
|
||||
child: UiKitView(viewType: 'platform_text_field'),
|
||||
),
|
||||
TextField(
|
||||
controller: _controller,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user