From 87fb075fa1e6f9879537f0c6ceed253f39cd393d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Tiselice?= Date: Thu, 15 Sep 2016 17:38:41 -0700 Subject: [PATCH] Renamed DropDown to Dropdown. (#5897) Fixes #3208. --- .../lib/demo/buttons_demo.dart | 8 +- .../lib/demo/shrine/shrine_order.dart | 6 +- .../lib/gallery/example_code.dart | 4 +- .../flutter/lib/src/material/data_table.dart | 6 +- .../flutter/lib/src/material/drop_down.dart | 112 +++++++++--------- .../flutter/lib/src/material/flat_button.dart | 2 +- .../src/material/paginated_data_table.dart | 8 +- .../lib/src/material/raised_button.dart | 2 +- .../flutter/test/material/drop_down_test.dart | 6 +- 9 files changed, 77 insertions(+), 77 deletions(-) diff --git a/examples/flutter_gallery/lib/demo/buttons_demo.dart b/examples/flutter_gallery/lib/demo/buttons_demo.dart index 356bfb54806..25f20e0eb90 100644 --- a/examples/flutter_gallery/lib/demo/buttons_demo.dart +++ b/examples/flutter_gallery/lib/demo/buttons_demo.dart @@ -143,7 +143,7 @@ class _ButtonsDemoState extends State { children: [ new ListItem( title: new Text('Scrollable dropdown:'), - trailing: new DropDownButton( + trailing: new DropdownButton( value: dropdown1Value, onChanged: (String newValue) { setState(() { @@ -156,7 +156,7 @@ class _ButtonsDemoState extends State { 'Bit', 'More', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten' ] .map((String value) { - return new DropDownMenuItem( + return new DropdownMenuItem( value: value, child: new Text(value)); }) @@ -168,7 +168,7 @@ class _ButtonsDemoState extends State { ), new ListItem( title: new Text('Simple dropdown:'), - trailing: new DropDownButton( + trailing: new DropdownButton( value: dropdown2Value, onChanged: (String newValue) { setState(() { @@ -178,7 +178,7 @@ class _ButtonsDemoState extends State { }, items: ['One', 'Two', 'Free', 'Four'] .map((String value) { - return new DropDownMenuItem( + return new DropdownMenuItem( value: value, child: new Text(value)); }) diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart index 03b898a2457..08da4736ce4 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart @@ -73,16 +73,16 @@ class OrderItem extends StatelessWidget { new SizedBox(height: 16.0), new Padding( padding: const EdgeInsets.only(top: 8.0, bottom: 8.0, right: 88.0), - child: new DropDownButtonHideUnderline( + child: new DropdownButtonHideUnderline( child: new Container( decoration: new BoxDecoration( border: new Border.all( color: const Color(0xFFD9D9D9) ) ), - child: new DropDownButton( + child: new DropdownButton( items: [0, 1, 2, 3, 4, 5].map((int value) { - return new DropDownMenuItem( + return new DropdownMenuItem( value: value, child: new Padding( padding: const EdgeInsets.only(left: 8.0), diff --git a/examples/flutter_gallery/lib/gallery/example_code.dart b/examples/flutter_gallery/lib/gallery/example_code.dart index dea5336a0f2..d611114654b 100644 --- a/examples/flutter_gallery/lib/gallery/example_code.dart +++ b/examples/flutter_gallery/lib/gallery/example_code.dart @@ -56,7 +56,7 @@ new FlatButton( String dropdownValue; // Drop down button with string values. -new DropDownButton( +new DropdownButton( value: dropdownValue, onChanged: (String newValue) { // null indicates the user didn't select a @@ -68,7 +68,7 @@ new DropDownButton( }, items: ['One', 'Two', 'Free', 'Four'] .map((String value) { - return new DropDownMenuItem( + return new DropdownMenuItem( value: value, child: new Text(value)); }) diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index a466a25e6b7..e087b1cb1d7 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -153,7 +153,7 @@ class DataCell { /// Creates an object to hold the data for a cell in a [DataTable]. /// /// The first argument is the widget to show for the cell, typically - /// a [Text] or [DropDownButton] widget; this becomes the [widget] + /// a [Text] or [DropdownButton] widget; this becomes the [widget] /// property and must not be null. /// /// If the cell has no data, then a [Text] widget with placeholder @@ -170,7 +170,7 @@ class DataCell { /// The data for the row. /// - /// Typically a [Text] widget or a [DropDownButton] widget. + /// Typically a [Text] widget or a [DropdownButton] widget. /// /// If the cell has no data, then a [Text] widget with placeholder /// text should be provided instead, and [placeholder] should be set @@ -470,7 +470,7 @@ class DataTable extends StatelessWidget { data: new IconThemeData( color: isLightTheme ? Colors.black54 : Colors.white70 ), - child: new DropDownButtonHideUnderline(child: label) + child: new DropdownButtonHideUnderline(child: label) ) ) ); diff --git a/packages/flutter/lib/src/material/drop_down.dart b/packages/flutter/lib/src/material/drop_down.dart index 601018886c3..5e276c88101 100644 --- a/packages/flutter/lib/src/material/drop_down.dart +++ b/packages/flutter/lib/src/material/drop_down.dart @@ -19,13 +19,13 @@ import 'shadows.dart'; import 'theme.dart'; import 'material.dart'; -const Duration _kDropDownMenuDuration = const Duration(milliseconds: 300); +const Duration _kDropdownMenuDuration = const Duration(milliseconds: 300); const double _kMenuItemHeight = 48.0; const EdgeInsets _kMenuVerticalPadding = const EdgeInsets.symmetric(vertical: 8.0); const EdgeInsets _kMenuHorizontalPadding = const EdgeInsets.symmetric(horizontal: 16.0); -class _DropDownMenuPainter extends CustomPainter { - _DropDownMenuPainter({ +class _DropdownMenuPainter extends CustomPainter { + _DropdownMenuPainter({ Color color, int elevation, this.selectedIndex, @@ -68,7 +68,7 @@ class _DropDownMenuPainter extends CustomPainter { } @override - bool shouldRepaint(_DropDownMenuPainter oldPainter) { + bool shouldRepaint(_DropdownMenuPainter oldPainter) { return oldPainter.color != color || oldPainter.elevation != elevation || oldPainter.selectedIndex != selectedIndex @@ -78,8 +78,8 @@ class _DropDownMenuPainter extends CustomPainter { // Do not use the platform-specific default scroll configuration. // Dropdown menus should never overscroll or display an overscroll indicator. -class _DropDownScrollConfigurationDelegate extends ScrollConfigurationDelegate { - const _DropDownScrollConfigurationDelegate(this._platform); +class _DropdownScrollConfigurationDelegate extends ScrollConfigurationDelegate { + const _DropdownScrollConfigurationDelegate(this._platform); @override TargetPlatform get platform => _platform; @@ -97,19 +97,19 @@ class _DropDownScrollConfigurationDelegate extends ScrollConfigurationDelegate { bool updateShouldNotify(ScrollConfigurationDelegate old) => platform != old.platform; } -class _DropDownMenu extends StatefulWidget { - _DropDownMenu({ +class _DropdownMenu extends StatefulWidget { + _DropdownMenu({ Key key, - _DropDownRoute route + _DropdownRoute route }) : route = route, super(key: key); - final _DropDownRoute route; + final _DropdownRoute route; @override - _DropDownMenuState createState() => new _DropDownMenuState(); + _DropdownMenuState createState() => new _DropdownMenuState(); } -class _DropDownMenuState extends State<_DropDownMenu> { +class _DropdownMenuState extends State<_DropdownMenu> { CurvedAnimation _fadeOpacity; CurvedAnimation _resize; @@ -142,7 +142,7 @@ class _DropDownMenuState extends State<_DropDownMenu> { // // When the menu is dismissed we just fade the entire thing out // in the first 0.25s. - final _DropDownRoute route = config.route; + final _DropdownRoute route = config.route; final double unit = 0.5 / (route.items.length + 1.5); final List children = []; for (int itemIndex = 0; itemIndex < route.items.length; ++itemIndex) { @@ -163,7 +163,7 @@ class _DropDownMenuState extends State<_DropDownMenu> { ), onTap: () => Navigator.pop( context, - new _DropDownRouteResult(route.items[itemIndex].value) + new _DropdownRouteResult(route.items[itemIndex].value) ) ) )); @@ -172,7 +172,7 @@ class _DropDownMenuState extends State<_DropDownMenu> { return new FadeTransition( opacity: _fadeOpacity, child: new CustomPaint( - painter: new _DropDownMenuPainter( + painter: new _DropdownMenuPainter( color: Theme.of(context).canvasColor, elevation: route.elevation, selectedIndex: route.selectedIndex, @@ -182,7 +182,7 @@ class _DropDownMenuState extends State<_DropDownMenu> { type: MaterialType.transparency, textStyle: route.style, child: new ScrollConfiguration( - delegate: new _DropDownScrollConfigurationDelegate(Theme.of(context).platform), + delegate: new _DropdownScrollConfigurationDelegate(Theme.of(context).platform), child: new Scrollbar( child: new ScrollableList( scrollableKey: config.route.scrollableKey, @@ -198,10 +198,10 @@ class _DropDownMenuState extends State<_DropDownMenu> { } } -class _DropDownMenuRouteLayout extends SingleChildLayoutDelegate { - _DropDownMenuRouteLayout({ this.route }); +class _DropdownMenuRouteLayout extends SingleChildLayoutDelegate { + _DropdownMenuRouteLayout({ this.route }); - final _DropDownRoute route; + final _DropdownRoute route; Rect get buttonRect => route.buttonRect; int get selectedIndex => route.selectedIndex; @@ -263,22 +263,22 @@ class _DropDownMenuRouteLayout extends SingleChildLayoutDelegate { } @override - bool shouldRelayout(_DropDownMenuRouteLayout oldDelegate) => oldDelegate.route != route; + bool shouldRelayout(_DropdownMenuRouteLayout oldDelegate) => oldDelegate.route != route; } // We box the return value so that the return value can be null. Otherwise, // canceling the route (which returns null) would get confused with actually // returning a real null value. -class _DropDownRouteResult { - const _DropDownRouteResult(this.result); +class _DropdownRouteResult { + const _DropdownRouteResult(this.result); final T result; @override bool operator ==(dynamic other) { - if (other is! _DropDownRouteResult) + if (other is! _DropdownRouteResult) return false; - final _DropDownRouteResult typedOther = other; + final _DropdownRouteResult typedOther = other; return result == typedOther.result; } @@ -286,9 +286,9 @@ class _DropDownRouteResult { int get hashCode => result.hashCode; } -class _DropDownRoute extends PopupRoute<_DropDownRouteResult> { - _DropDownRoute({ - Completer<_DropDownRouteResult> completer, +class _DropdownRoute extends PopupRoute<_DropdownRouteResult> { + _DropdownRoute({ + Completer<_DropdownRouteResult> completer, this.items, this.buttonRect, this.selectedIndex, @@ -298,8 +298,8 @@ class _DropDownRoute extends PopupRoute<_DropDownRouteResult> { assert(style != null); } - final GlobalKey scrollableKey = new GlobalKey(debugLabel: '_DropDownMenu'); - final List> items; + final GlobalKey scrollableKey = new GlobalKey(debugLabel: '_DropdownMenu'); + final List> items; final Rect buttonRect; final int selectedIndex; final int elevation; @@ -319,7 +319,7 @@ class _DropDownRoute extends PopupRoute<_DropDownRouteResult> { } @override - Duration get transitionDuration => _kDropDownMenuDuration; + Duration get transitionDuration => _kDropdownMenuDuration; @override bool get barrierDismissable => true; @@ -330,21 +330,21 @@ class _DropDownRoute extends PopupRoute<_DropDownRouteResult> { @override Widget buildPage(BuildContext context, Animation animation, Animation forwardAnimation) { return new CustomSingleChildLayout( - delegate: new _DropDownMenuRouteLayout(route: this), - child: new _DropDownMenu(route: this) + delegate: new _DropdownMenuRouteLayout(route: this), + child: new _DropdownMenu(route: this) ); } } -/// An item in a menu created by a [DropDownButton]. +/// An item in a menu created by a [DropdownButton]. /// /// The type `T` is the type of the value the entry represents. All the entries /// in a given menu must represent values with consistent types. -class DropDownMenuItem extends StatelessWidget { +class DropdownMenuItem extends StatelessWidget { /// Creates an item for a drop down menu. /// /// The [child] argument is required. - DropDownMenuItem({ + DropdownMenuItem({ Key key, this.value, this.child @@ -359,7 +359,7 @@ class DropDownMenuItem extends StatelessWidget { /// The value to return if the user selects this menu item. /// - /// Eventually returned in a call to [DropDownButton.onChanged]. + /// Eventually returned in a call to [DropdownButton.onChanged]. final T value; @override @@ -372,30 +372,30 @@ class DropDownMenuItem extends StatelessWidget { } } -/// An inherited widget that causes any descendant [DropDownButton] +/// An inherited widget that causes any descendant [DropdownButton] /// widgets to not include their regular underline. /// /// This is used by [DataTable] to remove the underline from any -/// [DropDownButton] widgets placed within material data tables, as +/// [DropdownButton] widgets placed within material data tables, as /// required by the material design specification. -class DropDownButtonHideUnderline extends InheritedWidget { - /// Creates a [DropDownButtonHideUnderline]. A non-null [child] must +class DropdownButtonHideUnderline extends InheritedWidget { + /// Creates a [DropdownButtonHideUnderline]. A non-null [child] must /// be given. - DropDownButtonHideUnderline({ + DropdownButtonHideUnderline({ Key key, Widget child }) : super(key: key, child: child) { assert(child != null); } - /// Returns whether the underline of [DropDownButton] widgets should + /// Returns whether the underline of [DropdownButton] widgets should /// be hidden. static bool at(BuildContext context) { - return context.inheritFromWidgetOfExactType(DropDownButtonHideUnderline) != null; + return context.inheritFromWidgetOfExactType(DropdownButtonHideUnderline) != null; } @override - bool updateShouldNotify(DropDownButtonHideUnderline old) => false; + bool updateShouldNotify(DropdownButtonHideUnderline old) => false; } /// A material design button for selecting from a list of items. @@ -411,14 +411,14 @@ class DropDownButtonHideUnderline extends InheritedWidget { /// * [RaisedButton] /// * [FlatButton] /// * -class DropDownButton extends StatefulWidget { +class DropdownButton extends StatefulWidget { /// Creates a drop down button. /// /// The [items] must have distinct values and [value] must be among them. /// /// The [elevation] and [iconSize] arguments must not be null (they both have /// defaults, so do not need to be specified). - DropDownButton({ + DropdownButton({ Key key, @required this.items, @required this.value, @@ -428,11 +428,11 @@ class DropDownButton extends StatefulWidget { this.iconSize: 24.0 }) : super(key: key) { assert(items != null); - assert(items.where((DropDownMenuItem item) => item.value == value).length == 1); + assert(items.where((DropdownMenuItem item) => item.value == value).length == 1); } /// The list of possible items to select among. - final List> items; + final List> items; /// The currently selected item. final T value; @@ -458,10 +458,10 @@ class DropDownButton extends StatefulWidget { final double iconSize; @override - _DropDownButtonState createState() => new _DropDownButtonState(); + _DropdownButtonState createState() => new _DropdownButtonState(); } -class _DropDownButtonState extends State> { +class _DropdownButtonState extends State> { @override void initState() { super.initState(); @@ -470,7 +470,7 @@ class _DropDownButtonState extends State> { } @override - void didUpdateConfig(DropDownButton oldConfig) { + void didUpdateConfig(DropdownButton oldConfig) { if (config.items[_selectedIndex].value != config.value) _updateSelectedIndex(); } @@ -488,14 +488,14 @@ class _DropDownButtonState extends State> { TextStyle get _textStyle => config.style ?? Theme.of(context).textTheme.subhead; - _DropDownRoute _currentRoute; + _DropdownRoute _currentRoute; void _handleTap() { assert(_currentRoute == null); final RenderBox itemBox = context.findRenderObject(); final Rect itemRect = itemBox.localToGlobal(Point.origin) & itemBox.size; - final Completer<_DropDownRouteResult> completer = new Completer<_DropDownRouteResult>(); - _currentRoute = new _DropDownRoute( + final Completer<_DropdownRouteResult> completer = new Completer<_DropdownRouteResult>(); + _currentRoute = new _DropdownRoute( completer: completer, items: config.items, buttonRect: _kMenuHorizontalPadding.inflateRect(itemRect), @@ -504,7 +504,7 @@ class _DropDownButtonState extends State> { style: _textStyle ); Navigator.push(context, _currentRoute); - completer.future.then((_DropDownRouteResult newValue) { + completer.future.then((_DropdownRouteResult newValue) { _currentRoute = null; if (!mounted || newValue == null) return; @@ -540,7 +540,7 @@ class _DropDownButtonState extends State> { ) ); - if (!DropDownButtonHideUnderline.at(context)) { + if (!DropdownButtonHideUnderline.at(context)) { result = new Stack( children: [ result, diff --git a/packages/flutter/lib/src/material/flat_button.dart b/packages/flutter/lib/src/material/flat_button.dart index 18a0d3dfca9..1a2922f14ed 100644 --- a/packages/flutter/lib/src/material/flat_button.dart +++ b/packages/flutter/lib/src/material/flat_button.dart @@ -32,7 +32,7 @@ import 'theme.dart'; /// See also: /// /// * [RaisedButton] -/// * [DropDownButton] +/// * [DropdownButton] /// * class FlatButton extends StatelessWidget { /// Creates a flat button. diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index 6bd5d2a70c6..54d92397c1a 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -307,8 +307,8 @@ class PaginatedDataTableState extends State { if (config.onRowsPerPageChanged != null) { List availableRowsPerPage = config.availableRowsPerPage .where((int value) => value <= _rowCount) - .map/*>*/((int value) { - return new DropDownMenuItem( + .map/*>*/((int value) { + return new DropdownMenuItem( value: value, child: new Text('$value') ); @@ -316,8 +316,8 @@ class PaginatedDataTableState extends State { .toList(); footerWidgets.addAll([ new Text('Rows per page:'), - new DropDownButtonHideUnderline( - child: new DropDownButton( + new DropdownButtonHideUnderline( + child: new DropdownButton( items: availableRowsPerPage, value: config.rowsPerPage, onChanged: config.onRowsPerPageChanged, diff --git a/packages/flutter/lib/src/material/raised_button.dart b/packages/flutter/lib/src/material/raised_button.dart index 4a0a36877bc..066e4005b74 100644 --- a/packages/flutter/lib/src/material/raised_button.dart +++ b/packages/flutter/lib/src/material/raised_button.dart @@ -29,7 +29,7 @@ import 'theme.dart'; /// See also: /// /// * [FlatButton] -/// * [DropDownButton] +/// * [DropdownButton] /// * [FloatingActionButton] /// * class RaisedButton extends StatelessWidget { diff --git a/packages/flutter/test/material/drop_down_test.dart b/packages/flutter/test/material/drop_down_test.dart index c24075de2b5..5ac353b6bf2 100644 --- a/packages/flutter/test/material/drop_down_test.dart +++ b/packages/flutter/test/material/drop_down_test.dart @@ -8,15 +8,15 @@ import 'package:flutter/material.dart'; void main() { testWidgets('Drop down screen edges', (WidgetTester tester) async { int value = 4; - List> items = >[]; + List> items = >[]; for (int i = 0; i < 20; ++i) - items.add(new DropDownMenuItem(value: i, child: new Text('$i'))); + items.add(new DropdownMenuItem(value: i, child: new Text('$i'))); void handleChanged(int newValue) { value = newValue; } - DropDownButton button = new DropDownButton( + DropdownButton button = new DropdownButton( value: value, onChanged: handleChanged, items: items