From 47b5c37f1a70e2ec2362b289257e4a7e3b1f09d5 Mon Sep 17 00:00:00 2001 From: amirh Date: Tue, 28 Nov 2017 18:17:11 -0800 Subject: [PATCH] Add Images demo to the gallery app. (#13141) --- dev/benchmarks/complex_layout/pubspec.yaml | 2 +- examples/flutter_gallery/lib/demo/all.dart | 1 + .../flutter_gallery/lib/demo/images_demo.dart | 28 +++++++++++++++++++ .../lib/gallery/example_code.dart | 9 ++++++ .../flutter_gallery/lib/gallery/item.dart | 8 ++++++ examples/flutter_gallery/pubspec.yaml | 4 ++- .../flutter_gallery/test/live_smoketest.dart | 3 ++ .../test_driver/transitions_perf_test.dart | 3 ++ 8 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 examples/flutter_gallery/lib/demo/images_demo.dart diff --git a/dev/benchmarks/complex_layout/pubspec.yaml b/dev/benchmarks/complex_layout/pubspec.yaml index 12d949cbc72..15b595d98ab 100644 --- a/dev/benchmarks/complex_layout/pubspec.yaml +++ b/dev/benchmarks/complex_layout/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter_gallery_assets: git: url: https://flutter.googlesource.com/gallery-assets - ref: 6427f36af1bdb2fffaeda1c46d5e52d7b636c93d + ref: d318485f208376e06d7e330d9f191141d14722b8 dev_dependencies: flutter_test: diff --git a/examples/flutter_gallery/lib/demo/all.dart b/examples/flutter_gallery/lib/demo/all.dart index f1c5469c267..a4a680a7a9b 100644 --- a/examples/flutter_gallery/lib/demo/all.dart +++ b/examples/flutter_gallery/lib/demo/all.dart @@ -7,6 +7,7 @@ export 'calculator_demo.dart'; export 'colors_demo.dart'; export 'contacts_demo.dart'; export 'cupertino/cupertino.dart'; +export 'images_demo.dart'; export 'material/material.dart'; export 'pesto_demo.dart'; export 'shrine_demo.dart'; diff --git a/examples/flutter_gallery/lib/demo/images_demo.dart b/examples/flutter_gallery/lib/demo/images_demo.dart new file mode 100644 index 00000000000..7b0c2cf301d --- /dev/null +++ b/examples/flutter_gallery/lib/demo/images_demo.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; + +import '../gallery/demo.dart'; + +class ImagesDemo extends StatelessWidget { + static const String routeName = '/images'; + + @override + Widget build(BuildContext context) { + return new TabbedComponentDemoScaffold( + title: 'Animated images', + demos: [ + new ComponentDemoTabData( + tabName: 'ANIMATED WEBP', + description: '', + exampleCodeTag: 'animated_image', + demoWidget: new Image.asset('packages/flutter_gallery_assets/animated_flutter_stickers.webp'), + ), + new ComponentDemoTabData( + tabName: 'ANIMATED GIF', + description: '', + exampleCodeTag: 'animated_image', + demoWidget: new Image.asset('packages/flutter_gallery_assets/animated_flutter_lgtm.gif'), + ), + ] + ); + } +} diff --git a/examples/flutter_gallery/lib/gallery/example_code.dart b/examples/flutter_gallery/lib/gallery/example_code.dart index 97d22eb4071..41de2730ccd 100644 --- a/examples/flutter_gallery/lib/gallery/example_code.dart +++ b/examples/flutter_gallery/lib/gallery/example_code.dart @@ -227,3 +227,12 @@ new GridView.count( // END } } + + +class AnimatedImage { + void animatedImage() { +// START animated_image +new Image.network('https://example.com/animated-image.gif'); +// END + } +} diff --git a/examples/flutter_gallery/lib/gallery/item.dart b/examples/flutter_gallery/lib/gallery/item.dart index 71a1f35d597..5aaf644395b 100644 --- a/examples/flutter_gallery/lib/gallery/item.dart +++ b/examples/flutter_gallery/lib/gallery/item.dart @@ -306,6 +306,14 @@ List _buildGalleryItems() { routeName: CupertinoSwitchDemo.routeName, buildRoute: (BuildContext context) => new CupertinoSwitchDemo(), ), + // Media + new GalleryItem( + title: 'Animated images', + subtitle: 'GIF and WebP animations', + category: 'Media', + routeName: ImagesDemo.routeName, + buildRoute: (BuildContext context) => new ImagesDemo(), + ), // Styles new GalleryItem( title: 'Colors', diff --git a/examples/flutter_gallery/pubspec.yaml b/examples/flutter_gallery/pubspec.yaml index 18d18d44f2f..eac33051a2b 100644 --- a/examples/flutter_gallery/pubspec.yaml +++ b/examples/flutter_gallery/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: flutter_gallery_assets: git: url: https://flutter.googlesource.com/gallery-assets - ref: 6427f36af1bdb2fffaeda1c46d5e52d7b636c93d + ref: d318485f208376e06d7e330d9f191141d14722b8 dev_dependencies: flutter_test: @@ -67,6 +67,8 @@ flutter: uses-material-design: true assets: - lib/gallery/example_code.dart + - packages/flutter_gallery_assets/animated_flutter_lgtm.gif + - packages/flutter_gallery_assets/animated_flutter_stickers.webp - packages/flutter_gallery_assets/appbar_background.jpg - packages/flutter_gallery_assets/appbar/appbar_background_layer0.png - packages/flutter_gallery_assets/appbar/appbar_background_layer1.png diff --git a/examples/flutter_gallery/test/live_smoketest.dart b/examples/flutter_gallery/test/live_smoketest.dart index 901183b147c..2e097fcdd52 100644 --- a/examples/flutter_gallery/test/live_smoketest.dart +++ b/examples/flutter_gallery/test/live_smoketest.dart @@ -100,6 +100,9 @@ const List demos = const [ const Demo('Sliders'), const Demo('Switches'), + // Media + const Demo('Animated Images'), + // Style const Demo('Colors'), const Demo('Typography'), diff --git a/examples/flutter_gallery/test_driver/transitions_perf_test.dart b/examples/flutter_gallery/test_driver/transitions_perf_test.dart index 3d52e94aaaa..db57fdef43d 100644 --- a/examples/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/examples/flutter_gallery/test_driver/transitions_perf_test.dart @@ -74,6 +74,9 @@ const List demos = const [ const Demo('Sliders'), const Demo('Switches'), + // Media + const Demo('Animated Images'), + // Style const Demo('Colors'), const Demo('Typography'),