Commit f0c7f5a9 authored by Collin Jackson's avatar Collin Jackson Committed by GitHub

Support for overriding Gallery feedback menu item behavior (#7091)

parent 440ddef6
...@@ -31,6 +31,7 @@ class GalleryApp extends StatefulWidget { ...@@ -31,6 +31,7 @@ class GalleryApp extends StatefulWidget {
this.updateUrlFetcher, this.updateUrlFetcher,
this.enablePerformanceOverlay: true, this.enablePerformanceOverlay: true,
this.checkerboardRasterCacheImages: true, this.checkerboardRasterCacheImages: true,
this.onSendFeedback,
Key key} Key key}
) : super(key: key); ) : super(key: key);
...@@ -40,6 +41,8 @@ class GalleryApp extends StatefulWidget { ...@@ -40,6 +41,8 @@ class GalleryApp extends StatefulWidget {
final bool checkerboardRasterCacheImages; final bool checkerboardRasterCacheImages;
final VoidCallback onSendFeedback;
@override @override
GalleryAppState createState() => new GalleryAppState(); GalleryAppState createState() => new GalleryAppState();
} }
...@@ -83,6 +86,7 @@ class GalleryAppState extends State<GalleryApp> { ...@@ -83,6 +86,7 @@ class GalleryAppState extends State<GalleryApp> {
timeDilation = value; timeDilation = value;
}); });
}, },
onSendFeedback: config.onSendFeedback,
); );
if (config.updateUrlFetcher != null) { if (config.updateUrlFetcher != null) {
......
...@@ -97,6 +97,7 @@ class GalleryDrawer extends StatelessWidget { ...@@ -97,6 +97,7 @@ class GalleryDrawer extends StatelessWidget {
this.checkerboardRasterCacheImages, this.checkerboardRasterCacheImages,
this.onCheckerboardRasterCacheImagesChanged, this.onCheckerboardRasterCacheImagesChanged,
this.onPlatformChanged, this.onPlatformChanged,
this.onSendFeedback,
}) : super(key: key) { }) : super(key: key) {
assert(onThemeChanged != null); assert(onThemeChanged != null);
assert(onTimeDilationChanged != null); assert(onTimeDilationChanged != null);
...@@ -116,6 +117,8 @@ class GalleryDrawer extends StatelessWidget { ...@@ -116,6 +117,8 @@ class GalleryDrawer extends StatelessWidget {
final ValueChanged<TargetPlatform> onPlatformChanged; final ValueChanged<TargetPlatform> onPlatformChanged;
final VoidCallback onSendFeedback;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
...@@ -203,12 +206,12 @@ class GalleryDrawer extends StatelessWidget { ...@@ -203,12 +206,12 @@ class GalleryDrawer extends StatelessWidget {
) )
); );
final Widget fileAnIssueItem = new DrawerItem( final Widget sendFeedbackItem = new DrawerItem(
icon: new Icon(Icons.report), icon: new Icon(Icons.report),
onPressed: () { onPressed: onSendFeedback ?? () {
UrlLauncher.launch('https://github.com/flutter/flutter/issues/new'); UrlLauncher.launch('https://github.com/flutter/flutter/issues/new');
}, },
child: new Text('File an issue') child: new Text('Send feedback'),
); );
final Widget aboutItem = new AboutDrawerItem( final Widget aboutItem = new AboutDrawerItem(
...@@ -264,7 +267,7 @@ class GalleryDrawer extends StatelessWidget { ...@@ -264,7 +267,7 @@ class GalleryDrawer extends StatelessWidget {
new Divider(), new Divider(),
animateSlowlyItem, animateSlowlyItem,
// index 8, optional: Performance Overlay // index 8, optional: Performance Overlay
fileAnIssueItem, sendFeedbackItem,
aboutItem aboutItem
]; ];
......
...@@ -79,6 +79,7 @@ class GalleryHome extends StatefulWidget { ...@@ -79,6 +79,7 @@ class GalleryHome extends StatefulWidget {
this.checkerboardRasterCacheImages, this.checkerboardRasterCacheImages,
this.onCheckerboardRasterCacheImagesChanged, this.onCheckerboardRasterCacheImagesChanged,
this.onPlatformChanged, this.onPlatformChanged,
this.onSendFeedback,
}) : super(key: key) { }) : super(key: key) {
assert(onThemeChanged != null); assert(onThemeChanged != null);
assert(onTimeDilationChanged != null); assert(onTimeDilationChanged != null);
...@@ -98,6 +99,8 @@ class GalleryHome extends StatefulWidget { ...@@ -98,6 +99,8 @@ class GalleryHome extends StatefulWidget {
final ValueChanged<TargetPlatform> onPlatformChanged; final ValueChanged<TargetPlatform> onPlatformChanged;
final VoidCallback onSendFeedback;
@override @override
GalleryHomeState createState() => new GalleryHomeState(); GalleryHomeState createState() => new GalleryHomeState();
} }
...@@ -164,6 +167,7 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState ...@@ -164,6 +167,7 @@ class GalleryHomeState extends State<GalleryHome> with SingleTickerProviderState
checkerboardRasterCacheImages: config.checkerboardRasterCacheImages, checkerboardRasterCacheImages: config.checkerboardRasterCacheImages,
onCheckerboardRasterCacheImagesChanged: config.onCheckerboardRasterCacheImagesChanged, onCheckerboardRasterCacheImagesChanged: config.onCheckerboardRasterCacheImagesChanged,
onPlatformChanged: config.onPlatformChanged, onPlatformChanged: config.onPlatformChanged,
onSendFeedback: config.onSendFeedback,
), ),
appBar: new AppBar( appBar: new AppBar(
expandedHeight: _kFlexibleSpaceMaxHeight, expandedHeight: _kFlexibleSpaceMaxHeight,
......
...@@ -49,7 +49,12 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async { ...@@ -49,7 +49,12 @@ Future<Null> smokeDemo(WidgetTester tester, String routeName) async {
} }
Future<Null> runSmokeTest(WidgetTester tester) async { Future<Null> runSmokeTest(WidgetTester tester) async {
await tester.pumpWidget(new GalleryApp()); bool hasFeedback = false;
void mockOnSendFeedback() {
hasFeedback = true;
}
await tester.pumpWidget(new GalleryApp(onSendFeedback: mockOnSendFeedback));
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865 await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame await tester.pump(); // triggers a frame
...@@ -89,6 +94,12 @@ Future<Null> runSmokeTest(WidgetTester tester) async { ...@@ -89,6 +94,12 @@ Future<Null> runSmokeTest(WidgetTester tester) async {
await tester.tap(find.text('Light')); await tester.tap(find.text('Light'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); // Wait until it's changed. await tester.pump(const Duration(seconds: 1)); // Wait until it's changed.
// send feedback
expect(hasFeedback, false);
await tester.tap(find.text('Send feedback'));
await tester.pump();
expect(hasFeedback, true);
} }
void main() { void main() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment