diff --git a/examples/flutter_gallery/flutter.yaml b/examples/flutter_gallery/flutter.yaml index da28187616..b2eb6fdfff 100644 --- a/examples/flutter_gallery/flutter.yaml +++ b/examples/flutter_gallery/flutter.yaml @@ -26,6 +26,11 @@ assets: - packages/flutter_gallery_assets/landscape_10.jpg - packages/flutter_gallery_assets/landscape_11.jpg - lib/gallery/example_code.dart + - packages/flutter_gallery_assets/shrine/vendors/16c477b.jpg + - packages/flutter_gallery_assets/shrine/vendors/ali-connors.png + - packages/flutter_gallery_assets/shrine/vendors/peter-carlsson.png + - packages/flutter_gallery_assets/shrine/vendors/sandra-adams.jpg + - packages/flutter_gallery_assets/shrine/vendors/zach.jpg fonts: - family: AbrilFatface fonts: diff --git a/examples/flutter_gallery/lib/demo/all.dart b/examples/flutter_gallery/lib/demo/all.dart index 39a792d8a8..a7e38ab38a 100644 --- a/examples/flutter_gallery/lib/demo/all.dart +++ b/examples/flutter_gallery/lib/demo/all.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. export 'buttons_demo.dart'; +export 'contacts_demo.dart'; export 'cards_demo.dart'; export 'calculator_demo.dart'; export 'chip_demo.dart'; @@ -11,7 +12,6 @@ export 'data_table_demo.dart'; export 'date_picker_demo.dart'; export 'dialog_demo.dart'; export 'drop_down_demo.dart'; -export 'flexible_space_demo.dart'; export 'grid_list_demo.dart'; export 'icons_demo.dart'; export 'leave_behind_demo.dart'; diff --git a/examples/flutter_gallery/lib/demo/flexible_space_demo.dart b/examples/flutter_gallery/lib/demo/contacts_demo.dart similarity index 97% rename from examples/flutter_gallery/lib/demo/flexible_space_demo.dart rename to examples/flutter_gallery/lib/demo/contacts_demo.dart index b2b7d49fc4..0f99c4f265 100644 --- a/examples/flutter_gallery/lib/demo/flexible_space_demo.dart +++ b/examples/flutter_gallery/lib/demo/contacts_demo.dart @@ -70,14 +70,14 @@ class _ContactItem extends StatelessWidget { } } -class FlexibleSpaceDemo extends StatefulWidget { - static const String routeName = '/flexible-space'; +class ContactsDemo extends StatefulWidget { + static const String routeName = '/contacts'; @override - FlexibleSpaceDemoState createState() => new FlexibleSpaceDemoState(); + ContactsDemoState createState() => new ContactsDemoState(); } -class FlexibleSpaceDemoState extends State { +class ContactsDemoState extends State { final GlobalKey _scaffoldKey = new GlobalKey(); final double _appBarHeight = 256.0; AppBarBehavior _appBarBehavior = AppBarBehavior.scroll; diff --git a/examples/flutter_gallery/lib/demo/scrolling_techniques_demo.dart b/examples/flutter_gallery/lib/demo/scrolling_techniques_demo.dart deleted file mode 100644 index 1a9b2ed434..0000000000 --- a/examples/flutter_gallery/lib/demo/scrolling_techniques_demo.dart +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/material.dart'; - -import 'flexible_space_demo.dart'; - -class _BarGraphic extends StatelessWidget { - _BarGraphic({ Key key, this.height, this.color, this.leftText, this.rightText: '' }) - : super(key: key) { - assert(height != null); - assert(color != null); - assert(leftText != null); - } - - final double height; - final Color color; - final String leftText; - final String rightText; - - @override - Widget build(BuildContext context) { - return new Container( - height: height, - width: 200.0, - padding: const EdgeInsets.symmetric(horizontal: 16.0), - decoration: new BoxDecoration(backgroundColor: color), - child: new DefaultTextStyle( - style: Theme.of(context).textTheme.body1.copyWith(color: Colors.white), - child: new Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - new Text(leftText), - new Text(rightText) - ] - ) - ) - ); - } -} - -class _StatusBarGraphic extends _BarGraphic { - _StatusBarGraphic() : super( - height: 24.0, - color: Colors.green[400], - leftText: 'Status Bar', - rightText: '24dp' - ); -} - -class _AppBarGraphic extends _BarGraphic { - _AppBarGraphic() : super( - height: 48.0, - color: Colors.blue[400], - leftText: 'Tool Bar', - rightText: '48dp' - ); -} - -class _TabBarGraphic extends _BarGraphic { - _TabBarGraphic() : super( - height: 48.0, - color: Colors.purple[400], - leftText: 'Tab Bar', - rightText: '56dp' - ); -} - -class _FlexibleSpaceGraphic extends _BarGraphic { - _FlexibleSpaceGraphic() : super( - height: 128.0, - color: Colors.pink[400], - leftText: 'Flexible Space' - ); -} - -class _TechniqueItem extends StatelessWidget { - _TechniqueItem({ this.titleText, this.barGraphics, this.builder }); - - final String titleText; - final List barGraphics; - final WidgetBuilder builder; - - void showDemo(BuildContext context) { - Navigator.push(context, new MaterialPageRoute(builder: builder)); - } - - @override - Widget build(BuildContext context) { - return new Card( - child: new InkWell( - onTap: () { showDemo(context); }, - child: new Padding( - padding: const EdgeInsets.all(16.0), - child: new Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children :[ - new Text(titleText), - new Column(children: barGraphics) - ] - ) - ) - ) - ); - } -} - -const String _introText = - "An AppBar is a combination of a ToolBar and a TabBar or a flexible space " - "Widget that is managed by the Scaffold. The Scaffold pads the ToolBar so that " - "it appears behind the device's status bar. When a flexible space Widget is " - "specified it is stacked on top of the ToolBar."; - -class ScrollingTechniquesDemo extends StatelessWidget { - @override - Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: new Text('Scrolling techniques')), - body: new Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: new Block( - children: [ - new Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 32.0), - child: new Text(_introText, style: Theme.of(context).textTheme.caption) - ), - new _TechniqueItem( - builder: (BuildContext context) => new FlexibleSpaceDemo(), - titleText: 'Standard', - barGraphics: [ - new _StatusBarGraphic(), - new _AppBarGraphic() - ] - ), - new _TechniqueItem( - titleText: 'Tabs', - builder: (BuildContext context) => new FlexibleSpaceDemo(), - barGraphics: [ - new _StatusBarGraphic(), - new _AppBarGraphic(), - new _TabBarGraphic() - ] - ), - new _TechniqueItem( - titleText: 'Flexible', - builder: (BuildContext context) => new FlexibleSpaceDemo(), - barGraphics: [ - new _StatusBarGraphic(), - new _AppBarGraphic(), - new _FlexibleSpaceGraphic() - ] - ) - ] - ) - ) - ); - } -} diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_data.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_data.dart index 70dac06a8a..501ad4fa1a 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_data.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_data.dart @@ -6,7 +6,7 @@ import 'shrine_types.dart'; const Vendor _ali = const Vendor( name: 'Ali’s shop', - avatarUrl: 'https://www.gstatic.com/angular/material-adaptive/shrine/ali-connors.png', + avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/ali-connors.png', description: 'Ali Connor’s makes custom goods for folks of all shapes and sizes ' 'made by hand and sometimes by machine, but always with love and care. ' @@ -15,7 +15,7 @@ const Vendor _ali = const Vendor( const Vendor _sandra = const Vendor( name: 'Sandra’s shop', - avatarUrl: 'https://www.gstatic.com/angular/material-adaptive/shrine/sandra-adams.jpg', + avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/sandra-adams.jpg', description: 'Sandra specializes in furniture, beauty and travel products with a classic vibe. ' 'Custom orders are available if you’re looking for a certain color or material.' @@ -23,7 +23,7 @@ const Vendor _sandra = const Vendor( const Vendor _trevor = const Vendor( name: 'Trevor’s shop', - avatarUrl: 'https://www.gstatic.com/angular/material-adaptive/shrine/zach.jpg', + avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/zach.jpg', description: 'Trevor makes great stuff for awesome people like you. Super cool and extra ' 'awesome all of his shop’s goods are handmade with love. Custom orders are ' @@ -32,7 +32,7 @@ const Vendor _trevor = const Vendor( const Vendor _peter = const Vendor( name: 'Peter’s shop', - avatarUrl: 'https://www.gstatic.com/angular/material-adaptive/shrine/peter-carlsson.png', + avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/peter-carlsson.png', description: 'Peter makes great stuff for awesome people like you. Super cool and extra ' 'awesome all of his shop’s goods are handmade with love. Custom orders are ' @@ -41,7 +41,7 @@ const Vendor _peter = const Vendor( const Vendor _stella = const Vendor( name: 'Stella’s shop', - avatarUrl: 'https://www.gstatic.com/angular/material-adaptive/shrine/16c477b.jpg', + avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/16c477b.jpg', description: 'Stella sells awesome stuff at lovely prices. made by hand and sometimes by ' 'machine, but always with love and care. Custom orders are available upon request ' diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart index 44d58cb5b4..3a453c700d 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart @@ -36,9 +36,9 @@ class VendorItem extends StatelessWidget { child: new ClipRRect( xRadius: 12.0, yRadius: 12.0, - child: new NetworkImage( + child: new AssetImage( fit: ImageFit.cover, - src: vendor.avatarUrl + name: vendor.avatarAsset ) ) ), diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart index b0f862afb6..693977cde7 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart @@ -10,17 +10,17 @@ class Vendor { const Vendor({ this.name, this.description, - this.avatarUrl + this.avatarAsset }); final String name; final String description; - final String avatarUrl; + final String avatarAsset; bool isValid() { return name != null && description != null && - avatarUrl != null; + avatarAsset != null; } @override diff --git a/examples/flutter_gallery/lib/gallery/app.dart b/examples/flutter_gallery/lib/gallery/app.dart index 20d7b14159..714c81b0ba 100644 --- a/examples/flutter_gallery/lib/gallery/app.dart +++ b/examples/flutter_gallery/lib/gallery/app.dart @@ -8,11 +8,11 @@ import 'package:flutter/scheduler.dart' show timeDilation; import '../demo/all.dart'; import 'home.dart'; +// Warning: this list must be in the same order that the demos appear in GalleryHome. final Map kRoutes = { ShrineDemo.routeName: (BuildContext context) => new ShrineDemo(), Calculator.routeName: (BuildContext context) => new Calculator(), - FlexibleSpaceDemo.routeName: (BuildContext context) => new FlexibleSpaceDemo(), - TabsFabDemo.routeName: (BuildContext context) => new TabsFabDemo(), + ContactsDemo.routeName: (BuildContext context) => new ContactsDemo(), ButtonsDemo.routeName: (BuildContext context) => new ButtonsDemo(), CardsDemo.routeName: (BuildContext context) => new CardsDemo(), ChipDemo.routeName: (BuildContext context) => new ChipDemo(), @@ -21,6 +21,7 @@ final Map kRoutes = { DialogDemo.routeName: (BuildContext context) => new DialogDemo(), DropDownDemo.routeName: (BuildContext context) => new DropDownDemo(), TwoLevelListDemo.routeName: (BuildContext context) => new TwoLevelListDemo(), + TabsFabDemo.routeName: (BuildContext context) => new TabsFabDemo(), GridListDemo.routeName: (BuildContext context) => new GridListDemo(), IconsDemo.routeName: (BuildContext context) => new IconsDemo(), LeaveBehindDemo.routeName: (BuildContext context) => new LeaveBehindDemo(), diff --git a/examples/flutter_gallery/lib/gallery/home.dart b/examples/flutter_gallery/lib/gallery/home.dart index daf6ec1f25..d53954a482 100644 --- a/examples/flutter_gallery/lib/gallery/home.dart +++ b/examples/flutter_gallery/lib/gallery/home.dart @@ -73,8 +73,7 @@ class GalleryHomeState extends State { children: [ new GalleryItem(title: 'Shrine', routeName: ShrineDemo.routeName), new GalleryItem(title: 'Calculator', routeName: Calculator.routeName), - new GalleryItem(title: 'Flexible space toolbar', routeName: FlexibleSpaceDemo.routeName), - new GalleryItem(title: 'Floating action button', routeName: TabsFabDemo.routeName), + new GalleryItem(title: 'Contacts', routeName: ContactsDemo.routeName) ] ), new TwoLevelSublist( @@ -89,6 +88,7 @@ class GalleryHomeState extends State { new GalleryItem(title: 'Dialog', routeName: DialogDemo.routeName), new GalleryItem(title: 'Drop-down button', routeName: DropDownDemo.routeName), new GalleryItem(title: 'Expand/collapse list control', routeName: TwoLevelListDemo.routeName), + new GalleryItem(title: 'Floating action button', routeName: TabsFabDemo.routeName), new GalleryItem(title: 'Grid', routeName: GridListDemo.routeName), new GalleryItem(title: 'Icons', routeName: IconsDemo.routeName), new GalleryItem(title: 'Leave-behind list items', routeName: LeaveBehindDemo.routeName), diff --git a/examples/flutter_gallery/test/simple_smoke_test.dart b/examples/flutter_gallery/test/simple_smoke_test.dart index 3a5a8ac6f1..f857824ff1 100644 --- a/examples/flutter_gallery/test/simple_smoke_test.dart +++ b/examples/flutter_gallery/test/simple_smoke_test.dart @@ -42,7 +42,7 @@ void main() { await tester.pump(const Duration(seconds: 1)); // end animation // Open Flexible space toolbar - await tester.tap(find.text('Flexible space toolbar')); + await tester.tap(find.text('Contacts')); await tester.pump(); // start animation await tester.pump(const Duration(seconds: 1)); // end animation diff --git a/examples/flutter_gallery/test_driver/transitions_perf_test.dart b/examples/flutter_gallery/test_driver/transitions_perf_test.dart index 9bcc1bd224..42fddf9743 100644 --- a/examples/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/examples/flutter_gallery/test_driver/transitions_perf_test.dart @@ -15,8 +15,8 @@ import 'package:test/test.dart'; const List demoCategories = const ['Demos', 'Components', 'Style']; const List demoNames = const [ - 'Flexible space toolbar', - 'Floating action button', + 'Shrine', + 'Contacts', 'Buttons', 'Cards', 'Chips', @@ -25,6 +25,7 @@ const List demoNames = const [ 'Dialog', 'Drop-down button', 'Expand/collapse list control', + 'Floating action button', 'Grid', 'Icons', 'Leave-behind list items',