Migrate Dropdown to ScrollConfiguration2 (#8135)

Also use the word "dropdown" consistently over "drop down".
This commit is contained in:
Adam Barth 2017-02-14 14:06:59 -08:00 committed by GitHub
parent 7231fd3ed6
commit 14743566ca
6 changed files with 19 additions and 25 deletions

View file

@ -55,7 +55,7 @@ new FlatButton(
// Member variable holding value.
String dropdownValue;
// Drop down button with string values.
// Dropdown button with string values.
new DropdownButton<String>(
value: dropdownValue,
onChanged: (String newValue) {

View file

@ -34,7 +34,7 @@ export 'src/material/divider.dart';
export 'src/material/drawer.dart';
export 'src/material/drawer_header.dart';
export 'src/material/drawer_item.dart';
export 'src/material/drop_down.dart';
export 'src/material/dropdown.dart';
export 'src/material/expand_icon.dart';
export 'src/material/expansion_panel.dart';
export 'src/material/flat_button.dart';

View file

@ -11,7 +11,7 @@ import 'package:flutter/widgets.dart';
import 'checkbox.dart';
import 'colors.dart';
import 'debug.dart';
import 'drop_down.dart';
import 'dropdown.dart';
import 'icon.dart';
import 'icon_theme.dart';
import 'icon_theme_data.dart';

View file

@ -79,23 +79,17 @@ 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 _DropdownScrollBehavior extends ScrollBehavior2 {
const _DropdownScrollBehavior();
@override
TargetPlatform get platform => _platform;
final TargetPlatform _platform;
TargetPlatform getPlatform(BuildContext context) => Theme.of(context).platform;
@override
ExtentScrollBehavior createScrollBehavior() => new OverscrollWhenScrollableBehavior(platform: platform);
Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) => child;
@override
Widget wrapScrollWidget(BuildContext context, Widget scrollWidget) {
return new ClampOverscrolls(edge: ScrollableEdge.both, child: scrollWidget);
}
@override
bool updateShouldNotify(ScrollConfigurationDelegate old) => platform != old.platform;
ScrollPhysics getScrollPhysics(BuildContext context) => const ClampingScrollPhysics();
}
class _DropdownMenu<T> extends StatefulWidget {
@ -182,8 +176,8 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
child: new Material(
type: MaterialType.transparency,
textStyle: route.style,
child: new ScrollConfiguration(
delegate: new _DropdownScrollConfigurationDelegate(Theme.of(context).platform),
child: new ScrollConfiguration2(
behavior: const _DropdownScrollBehavior(),
child: new Scrollbar(
child: new ListView(
controller: config.route.scrollController,
@ -406,7 +400,7 @@ class DropdownButtonHideUnderline extends InheritedWidget {
///
/// See also:
///
/// * [DropdownButtonHideUnderline], which prevents its descendant drop down buttons
/// * [DropdownButtonHideUnderline], which prevents its descendant dropdown buttons
/// from displaying their underlines.
/// * [RaisedButton], [FlatButton], ordinary buttons that trigger a single action.
/// * <https://material.google.com/components/buttons.html#buttons-dropdown-buttons>

View file

@ -13,7 +13,7 @@ import 'button_bar.dart';
import 'card.dart';
import 'data_table.dart';
import 'data_table_source.dart';
import 'drop_down.dart';
import 'dropdown.dart';
import 'icon.dart';
import 'icon_button.dart';
import 'icon_theme.dart';

View file

@ -59,7 +59,7 @@ bool sameGeometry(RenderBox box1, RenderBox box2) {
void main() {
testWidgets('Drop down button control test', (WidgetTester tester) async {
testWidgets('Dropdown button control test', (WidgetTester tester) async {
String value = 'one';
void didChangeValue(String newValue) {
value = newValue;
@ -98,7 +98,7 @@ void main() {
expect(value, equals('two'));
});
testWidgets('Drop down button with no app', (WidgetTester tester) async {
testWidgets('Dropdown button with no app', (WidgetTester tester) async {
String value = 'one';
void didChangeValue(String newValue) {
value = newValue;
@ -151,7 +151,7 @@ void main() {
expect(value, equals('two'));
});
testWidgets('Drop down screen edges', (WidgetTester tester) async {
testWidgets('Dropdown screen edges', (WidgetTester tester) async {
int value = 4;
List<DropdownMenuItem<int>> items = <DropdownMenuItem<int>>[];
for (int i = 0; i < 20; ++i)
@ -203,7 +203,7 @@ void main() {
await tester.pump(const Duration(seconds: 1)); // finish the menu animation
});
testWidgets('Drop down button aligns selected menu item', (WidgetTester tester) async {
testWidgets('Dropdown button aligns selected menu item', (WidgetTester tester) async {
Key buttonKey = new UniqueKey();
String value = 'two';
@ -237,7 +237,7 @@ void main() {
checkSelectedItemTextGeometry(tester, 'two');
});
testWidgets('Drop down button with isDense:true aligns selected menu item', (WidgetTester tester) async {
testWidgets('Dropdown button with isDense:true aligns selected menu item', (WidgetTester tester) async {
Key buttonKey = new UniqueKey();
String value = 'two';
@ -290,7 +290,7 @@ void main() {
RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
assert(buttonBox.attached);
// A DropDown button with a null value should be the same size as a
// A Dropdown button with a null value should be the same size as a
// one with a non-null value.
expect(buttonBox.localToGlobal(Point.origin), equals(buttonBoxNullValue.localToGlobal(Point.origin)));
expect(buttonBox.size, equals(buttonBoxNullValue.size));
@ -342,7 +342,7 @@ void main() {
RenderBox buttonBox = tester.renderObject(find.byKey(buttonKey));
assert(buttonBox.attached);
// A DropDown button with a null value and a hint should be the same size as a
// A Dropdown button with a null value and a hint should be the same size as a
// one with a non-null value.
expect(buttonBox.localToGlobal(Point.origin), equals(buttonBoxHintValue.localToGlobal(Point.origin)));
expect(buttonBox.size, equals(buttonBoxHintValue.size));