Commit 87fb075f authored by Dragoș Tiselice's avatar Dragoș Tiselice Committed by GitHub

Renamed DropDown to Dropdown. (#5897)

Fixes #3208.
parent 8ac14f86
......@@ -143,7 +143,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
children: <Widget>[
new ListItem(
title: new Text('Scrollable dropdown:'),
trailing: new DropDownButton<String>(
trailing: new DropdownButton<String>(
value: dropdown1Value,
onChanged: (String newValue) {
setState(() {
......@@ -156,7 +156,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
'Bit', 'More', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'
]
.map((String value) {
return new DropDownMenuItem<String>(
return new DropdownMenuItem<String>(
value: value,
child: new Text(value));
})
......@@ -168,7 +168,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
),
new ListItem(
title: new Text('Simple dropdown:'),
trailing: new DropDownButton<String>(
trailing: new DropdownButton<String>(
value: dropdown2Value,
onChanged: (String newValue) {
setState(() {
......@@ -178,7 +178,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
},
items: <String>['One', 'Two', 'Free', 'Four']
.map((String value) {
return new DropDownMenuItem<String>(
return new DropdownMenuItem<String>(
value: value,
child: new Text(value));
})
......
......@@ -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<int>(
child: new DropdownButton<int>(
items: <int>[0, 1, 2, 3, 4, 5].map((int value) {
return new DropDownMenuItem<int>(
return new DropdownMenuItem<int>(
value: value,
child: new Padding(
padding: const EdgeInsets.only(left: 8.0),
......
......@@ -56,7 +56,7 @@ new FlatButton(
String dropdownValue;
// Drop down button with string values.
new DropDownButton<String>(
new DropdownButton<String>(
value: dropdownValue,
onChanged: (String newValue) {
// null indicates the user didn't select a
......@@ -68,7 +68,7 @@ new DropDownButton<String>(
},
items: <String>['One', 'Two', 'Free', 'Four']
.map((String value) {
return new DropDownMenuItem<String>(
return new DropdownMenuItem<String>(
value: value,
child: new Text(value));
})
......
......@@ -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)
)
)
);
......
......@@ -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<T> extends StatefulWidget {
_DropDownMenu({
class _DropdownMenu<T> extends StatefulWidget {
_DropdownMenu({
Key key,
_DropDownRoute<T> route
_DropdownRoute<T> route
}) : route = route, super(key: key);
final _DropDownRoute<T> route;
final _DropdownRoute<T> route;
@override
_DropDownMenuState<T> createState() => new _DropDownMenuState<T>();
_DropdownMenuState<T> createState() => new _DropdownMenuState<T>();
}
class _DropDownMenuState<T> extends State<_DropDownMenu<T>> {
class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
CurvedAnimation _fadeOpacity;
CurvedAnimation _resize;
......@@ -142,7 +142,7 @@ class _DropDownMenuState<T> extends State<_DropDownMenu<T>> {
//
// When the menu is dismissed we just fade the entire thing out
// in the first 0.25s.
final _DropDownRoute<T> route = config.route;
final _DropdownRoute<T> route = config.route;
final double unit = 0.5 / (route.items.length + 1.5);
final List<Widget> children = <Widget>[];
for (int itemIndex = 0; itemIndex < route.items.length; ++itemIndex) {
......@@ -163,7 +163,7 @@ class _DropDownMenuState<T> extends State<_DropDownMenu<T>> {
),
onTap: () => Navigator.pop(
context,
new _DropDownRouteResult<T>(route.items[itemIndex].value)
new _DropdownRouteResult<T>(route.items[itemIndex].value)
)
)
));
......@@ -172,7 +172,7 @@ class _DropDownMenuState<T> extends State<_DropDownMenu<T>> {
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<T> extends State<_DropDownMenu<T>> {
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<T> extends State<_DropDownMenu<T>> {
}
}
class _DropDownMenuRouteLayout<T> extends SingleChildLayoutDelegate {
_DropDownMenuRouteLayout({ this.route });
class _DropdownMenuRouteLayout<T> extends SingleChildLayoutDelegate {
_DropdownMenuRouteLayout({ this.route });
final _DropDownRoute<T> route;
final _DropdownRoute<T> route;
Rect get buttonRect => route.buttonRect;
int get selectedIndex => route.selectedIndex;
......@@ -263,22 +263,22 @@ class _DropDownMenuRouteLayout<T> extends SingleChildLayoutDelegate {
}
@override
bool shouldRelayout(_DropDownMenuRouteLayout<T> oldDelegate) => oldDelegate.route != route;
bool shouldRelayout(_DropdownMenuRouteLayout<T> 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<T> {
const _DropDownRouteResult(this.result);
class _DropdownRouteResult<T> {
const _DropdownRouteResult(this.result);
final T result;
@override
bool operator ==(dynamic other) {
if (other is! _DropDownRouteResult<T>)
if (other is! _DropdownRouteResult<T>)
return false;
final _DropDownRouteResult<T> typedOther = other;
final _DropdownRouteResult<T> typedOther = other;
return result == typedOther.result;
}
......@@ -286,9 +286,9 @@ class _DropDownRouteResult<T> {
int get hashCode => result.hashCode;
}
class _DropDownRoute<T> extends PopupRoute<_DropDownRouteResult<T>> {
_DropDownRoute({
Completer<_DropDownRouteResult<T>> completer,
class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
_DropdownRoute({
Completer<_DropdownRouteResult<T>> completer,
this.items,
this.buttonRect,
this.selectedIndex,
......@@ -298,8 +298,8 @@ class _DropDownRoute<T> extends PopupRoute<_DropDownRouteResult<T>> {
assert(style != null);
}
final GlobalKey<ScrollableState> scrollableKey = new GlobalKey<ScrollableState>(debugLabel: '_DropDownMenu');
final List<DropDownMenuItem<T>> items;
final GlobalKey<ScrollableState> scrollableKey = new GlobalKey<ScrollableState>(debugLabel: '_DropdownMenu');
final List<DropdownMenuItem<T>> items;
final Rect buttonRect;
final int selectedIndex;
final int elevation;
......@@ -319,7 +319,7 @@ class _DropDownRoute<T> extends PopupRoute<_DropDownRouteResult<T>> {
}
@override
Duration get transitionDuration => _kDropDownMenuDuration;
Duration get transitionDuration => _kDropdownMenuDuration;
@override
bool get barrierDismissable => true;
......@@ -330,21 +330,21 @@ class _DropDownRoute<T> extends PopupRoute<_DropDownRouteResult<T>> {
@override
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> forwardAnimation) {
return new CustomSingleChildLayout(
delegate: new _DropDownMenuRouteLayout<T>(route: this),
child: new _DropDownMenu<T>(route: this)
delegate: new _DropdownMenuRouteLayout<T>(route: this),
child: new _DropdownMenu<T>(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<T> extends StatelessWidget {
class DropdownMenuItem<T> 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<T> 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<T> 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]
/// * <https://www.google.com/design/spec/components/buttons.html#buttons-dropdown-buttons>
class DropDownButton<T> extends StatefulWidget {
class DropdownButton<T> 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<T> extends StatefulWidget {
this.iconSize: 24.0
}) : super(key: key) {
assert(items != null);
assert(items.where((DropDownMenuItem<T> item) => item.value == value).length == 1);
assert(items.where((DropdownMenuItem<T> item) => item.value == value).length == 1);
}
/// The list of possible items to select among.
final List<DropDownMenuItem<T>> items;
final List<DropdownMenuItem<T>> items;
/// The currently selected item.
final T value;
......@@ -458,10 +458,10 @@ class DropDownButton<T> extends StatefulWidget {
final double iconSize;
@override
_DropDownButtonState<T> createState() => new _DropDownButtonState<T>();
_DropdownButtonState<T> createState() => new _DropdownButtonState<T>();
}
class _DropDownButtonState<T> extends State<DropDownButton<T>> {
class _DropdownButtonState<T> extends State<DropdownButton<T>> {
@override
void initState() {
super.initState();
......@@ -470,7 +470,7 @@ class _DropDownButtonState<T> extends State<DropDownButton<T>> {
}
@override
void didUpdateConfig(DropDownButton<T> oldConfig) {
void didUpdateConfig(DropdownButton<T> oldConfig) {
if (config.items[_selectedIndex].value != config.value)
_updateSelectedIndex();
}
......@@ -488,14 +488,14 @@ class _DropDownButtonState<T> extends State<DropDownButton<T>> {
TextStyle get _textStyle => config.style ?? Theme.of(context).textTheme.subhead;
_DropDownRoute<T> _currentRoute;
_DropdownRoute<T> _currentRoute;
void _handleTap() {
assert(_currentRoute == null);
final RenderBox itemBox = context.findRenderObject();
final Rect itemRect = itemBox.localToGlobal(Point.origin) & itemBox.size;
final Completer<_DropDownRouteResult<T>> completer = new Completer<_DropDownRouteResult<T>>();
_currentRoute = new _DropDownRoute<T>(
final Completer<_DropdownRouteResult<T>> completer = new Completer<_DropdownRouteResult<T>>();
_currentRoute = new _DropdownRoute<T>(
completer: completer,
items: config.items,
buttonRect: _kMenuHorizontalPadding.inflateRect(itemRect),
......@@ -504,7 +504,7 @@ class _DropDownButtonState<T> extends State<DropDownButton<T>> {
style: _textStyle
);
Navigator.push(context, _currentRoute);
completer.future.then((_DropDownRouteResult<T> newValue) {
completer.future.then((_DropdownRouteResult<T> newValue) {
_currentRoute = null;
if (!mounted || newValue == null)
return;
......@@ -540,7 +540,7 @@ class _DropDownButtonState<T> extends State<DropDownButton<T>> {
)
);
if (!DropDownButtonHideUnderline.at(context)) {
if (!DropdownButtonHideUnderline.at(context)) {
result = new Stack(
children: <Widget>[
result,
......
......@@ -32,7 +32,7 @@ import 'theme.dart';
/// See also:
///
/// * [RaisedButton]
/// * [DropDownButton]
/// * [DropdownButton]
/// * <https://www.google.com/design/spec/components/buttons.html>
class FlatButton extends StatelessWidget {
/// Creates a flat button.
......
......@@ -307,8 +307,8 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
if (config.onRowsPerPageChanged != null) {
List<Widget> availableRowsPerPage = config.availableRowsPerPage
.where((int value) => value <= _rowCount)
.map/*<DropDownMenuItem<int>>*/((int value) {
return new DropDownMenuItem<int>(
.map/*<DropdownMenuItem<int>>*/((int value) {
return new DropdownMenuItem<int>(
value: value,
child: new Text('$value')
);
......@@ -316,8 +316,8 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
.toList();
footerWidgets.addAll(<Widget>[
new Text('Rows per page:'),
new DropDownButtonHideUnderline(
child: new DropDownButton<int>(
new DropdownButtonHideUnderline(
child: new DropdownButton<int>(
items: availableRowsPerPage,
value: config.rowsPerPage,
onChanged: config.onRowsPerPageChanged,
......
......@@ -29,7 +29,7 @@ import 'theme.dart';
/// See also:
///
/// * [FlatButton]
/// * [DropDownButton]
/// * [DropdownButton]
/// * [FloatingActionButton]
/// * <https://www.google.com/design/spec/components/buttons.html>
class RaisedButton extends StatelessWidget {
......
......@@ -8,15 +8,15 @@ import 'package:flutter/material.dart';
void main() {
testWidgets('Drop down screen edges', (WidgetTester tester) async {
int value = 4;
List<DropDownMenuItem<int>> items = <DropDownMenuItem<int>>[];
List<DropdownMenuItem<int>> items = <DropdownMenuItem<int>>[];
for (int i = 0; i < 20; ++i)
items.add(new DropDownMenuItem<int>(value: i, child: new Text('$i')));
items.add(new DropdownMenuItem<int>(value: i, child: new Text('$i')));
void handleChanged(int newValue) {
value = newValue;
}
DropDownButton<int> button = new DropDownButton<int>(
DropdownButton<int> button = new DropdownButton<int>(
value: value,
onChanged: handleChanged,
items: items
......
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