Eliminated DrawerItem, use ListTile instead (#8992)

This commit is contained in:
Hans Muller
2017-03-24 15:34:43 -07:00
committed by GitHub
parent 51ea62c143
commit 606f56221b
21 changed files with 774 additions and 653 deletions

View File

@@ -577,53 +577,41 @@ class GalleryDrawer extends StatelessWidget {
child: new ListView(
children: <Widget>[
new FancyDrawerHeader(),
new DrawerItem(
icon: new Icon(Icons.brightness_5),
onPressed: () { _changeTheme(context, true); },
new ListTile(
leading: new Icon(Icons.brightness_5),
title: new Text('Light'),
onTap: () { _changeTheme(context, true); },
selected: ComplexLayoutApp.of(context).lightTheme,
child: new Row(
children: <Widget>[
new Expanded(child: new Text('Light')),
new Radio<bool>(
value: true,
groupValue: ComplexLayoutApp.of(context).lightTheme,
onChanged: (bool value) { _changeTheme(context, value); }
)
]
)
trailing: new Radio<bool>(
value: true,
groupValue: ComplexLayoutApp.of(context).lightTheme,
onChanged: (bool value) { _changeTheme(context, value); }
),
),
new DrawerItem(
icon: new Icon(Icons.brightness_7),
onPressed: () { _changeTheme(context, false); },
new ListTile(
leading: new Icon(Icons.brightness_7),
title: new Text('Dark'),
onTap: () { _changeTheme(context, false); },
selected: !ComplexLayoutApp.of(context).lightTheme,
child: new Row(
children: <Widget>[
new Expanded(child: new Text('Dark')),
new Radio<bool>(
value: false,
groupValue: ComplexLayoutApp.of(context).lightTheme,
onChanged: (bool value) { _changeTheme(context, value); }
)
]
)
trailing: new Radio<bool>(
value: false,
groupValue: ComplexLayoutApp.of(context).lightTheme,
onChanged: (bool value) { _changeTheme(context, value); },
),
),
new Divider(),
new DrawerItem(
icon: new Icon(Icons.hourglass_empty),
new ListTile(
leading: new Icon(Icons.hourglass_empty),
title: new Text('Animate Slowly'),
selected: timeDilation != 1.0,
onPressed: () { ComplexLayoutApp.of(context).toggleAnimationSpeed(); },
child: new Row(
children: <Widget>[
new Expanded(child: new Text('Animate Slowly')),
new Checkbox(
value: timeDilation != 1.0,
onChanged: (bool value) { ComplexLayoutApp.of(context).toggleAnimationSpeed(); }
)
]
)
)
]
)
onTap: () { ComplexLayoutApp.of(context).toggleAnimationSpeed(); },
trailing: new Checkbox(
value: timeDilation != 1.0,
onChanged: (bool value) { ComplexLayoutApp.of(context).toggleAnimationSpeed(); }
),
),
],
),
);
}
}

View File

@@ -107,10 +107,10 @@ class CardCollectionState extends State<CardCollection> {
buildFontRadioItem("Center-align text", TextAlign.center, _textAlign, _changeTextAlign, icon: Icons.format_align_center, enabled: !_editable),
buildFontRadioItem("Right-align text", TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable),
new Divider(),
new DrawerItem(
icon: new Icon(Icons.dvr),
onPressed: () { debugDumpApp(); debugDumpRenderTree(); },
child: new Text('Dump App to Console'),
new ListTile(
leading: new Icon(Icons.dvr),
onTap: () { debugDumpApp(); debugDumpRenderTree(); },
title: new Text('Dump App to Console'),
),
],
),
@@ -167,67 +167,51 @@ class CardCollectionState extends State<CardCollection> {
}
Widget buildDrawerCheckbox(String label, bool value, void callback(), { bool enabled: true }) {
return new DrawerItem(
onPressed: enabled ? callback : null,
child: new Row(
children: <Widget>[
new Expanded(child: new Text(label)),
new Checkbox(
value: value,
onChanged: enabled ? (_) { callback(); } : null,
),
],
return new ListTile(
onTap: enabled ? callback : null,
title: new Text(label),
trailing: new Checkbox(
value: value,
onChanged: enabled ? (_) { callback(); } : null,
),
);
}
Widget buildDrawerColorRadioItem(String label, MaterialColor itemValue, MaterialColor currentValue, ValueChanged<MaterialColor> onChanged, { IconData icon, bool enabled: true }) {
return new DrawerItem(
icon: new Icon(icon),
onPressed: enabled ? () { onChanged(itemValue); } : null,
child: new Row(
children: <Widget>[
new Expanded(child: new Text(label)),
new Radio<MaterialColor>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null,
),
],
return new ListTile(
leading: new Icon(icon),
title: new Text(label),
onTap: enabled ? () { onChanged(itemValue); } : null,
trailing: new Radio<MaterialColor>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null,
),
);
}
Widget buildDrawerDirectionRadioItem(String label, DismissDirection itemValue, DismissDirection currentValue, ValueChanged<DismissDirection> onChanged, { IconData icon, bool enabled: true }) {
return new DrawerItem(
icon: new Icon(icon),
onPressed: enabled ? () { onChanged(itemValue); } : null,
child: new Row(
children: <Widget>[
new Expanded(child: new Text(label)),
new Radio<DismissDirection>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null,
),
],
return new ListTile(
leading: new Icon(icon),
title: new Text(label),
onTap: enabled ? () { onChanged(itemValue); } : null,
trailing: new Radio<DismissDirection>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null,
),
);
}
Widget buildFontRadioItem(String label, TextAlign itemValue, TextAlign currentValue, ValueChanged<TextAlign> onChanged, { IconData icon, bool enabled: true }) {
return new DrawerItem(
icon: new Icon(icon),
onPressed: enabled ? () { onChanged(itemValue); } : null,
child: new Row(
children: <Widget>[
new Expanded(child: new Text(label)),
new Radio<TextAlign>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null,
),
],
return new ListTile(
leading: new Icon(icon),
title: new Text(label),
onTap: enabled ? () { onChanged(itemValue); } : null,
trailing: new Radio<TextAlign>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null,
),
);
}

View File

@@ -85,27 +85,23 @@ class PageViewAppState extends State<PageViewApp> {
child: new ListView(
children: <Widget>[
new DrawerHeader(child: new Center(child: new Text('Options'))),
new DrawerItem(
icon: new Icon(Icons.more_horiz),
new ListTile(
leading: new Icon(Icons.more_horiz),
selected: scrollDirection == Axis.horizontal,
child: new Text('Horizontal Layout'),
onPressed: switchScrollDirection,
trailing: new Text('Horizontal Layout'),
onTap: switchScrollDirection,
),
new DrawerItem(
icon: new Icon(Icons.more_vert),
new ListTile(
leading: new Icon(Icons.more_vert),
selected: scrollDirection == Axis.vertical,
child: new Text('Vertical Layout'),
onPressed: switchScrollDirection,
trailing: new Text('Vertical Layout'),
onTap: switchScrollDirection,
),
new DrawerItem(
onPressed: toggleItemsWrap,
child: new Row(
children: <Widget>[
new Expanded(child: new Text('Scrolling wraps around')),
// TODO(abarth): Actually make this checkbox change this value.
new Checkbox(value: itemsWrap, onChanged: null),
],
),
new ListTile(
onTap: toggleItemsWrap,
title: new Text('Scrolling wraps around'),
// TODO(abarth): Actually make this checkbox change this value.
trailing: new Checkbox(value: itemsWrap, onChanged: null),
),
],
),