Commit 3d377305 authored by Hans Muller's avatar Hans Muller

updated per review feedback

parent 179d41e6
...@@ -21,7 +21,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -21,7 +21,7 @@ class ListDemoState extends State<ListDemo> {
ScaffoldFeatureController _bottomSheet; ScaffoldFeatureController _bottomSheet;
ListDemoItemSize _itemSize = ListDemoItemSize.threeLine; ListDemoItemSize _itemSize = ListDemoItemSize.threeLine;
bool _isDense = true; bool _dense = true;
bool _showAvatar = true; bool _showAvatar = true;
bool _showIcon = false; bool _showIcon = false;
bool _reverseSort = false; bool _reverseSort = false;
...@@ -47,7 +47,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -47,7 +47,7 @@ class ListDemoState extends State<ListDemo> {
alignItems: FlexAlignItems.stretch, alignItems: FlexAlignItems.stretch,
children: <Widget>[ children: <Widget>[
new ListItem( new ListItem(
isDense: true, dense: true,
primary: new Text('One-line'), primary: new Text('One-line'),
right: new Radio<ListDemoItemSize>( right: new Radio<ListDemoItemSize>(
value: ListDemoItemSize.oneLine, value: ListDemoItemSize.oneLine,
...@@ -56,7 +56,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -56,7 +56,7 @@ class ListDemoState extends State<ListDemo> {
) )
), ),
new ListItem( new ListItem(
isDense: true, dense: true,
primary: new Text('Two-line'), primary: new Text('Two-line'),
right: new Radio<ListDemoItemSize>( right: new Radio<ListDemoItemSize>(
value: ListDemoItemSize.twoLine, value: ListDemoItemSize.twoLine,
...@@ -65,7 +65,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -65,7 +65,7 @@ class ListDemoState extends State<ListDemo> {
) )
), ),
new ListItem( new ListItem(
isDense: true, dense: true,
primary: new Text('Three-line'), primary: new Text('Three-line'),
right: new Radio<ListDemoItemSize>( right: new Radio<ListDemoItemSize>(
value: ListDemoItemSize.threeLine, value: ListDemoItemSize.threeLine,
...@@ -74,7 +74,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -74,7 +74,7 @@ class ListDemoState extends State<ListDemo> {
) )
), ),
new ListItem( new ListItem(
isDense: true, dense: true,
primary: new Text('Show Avatar'), primary: new Text('Show Avatar'),
right: new Checkbox( right: new Checkbox(
value: _showAvatar, value: _showAvatar,
...@@ -87,7 +87,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -87,7 +87,7 @@ class ListDemoState extends State<ListDemo> {
) )
), ),
new ListItem( new ListItem(
isDense: true, dense: true,
primary: new Text('Show Icon'), primary: new Text('Show Icon'),
right: new Checkbox( right: new Checkbox(
value: _showIcon, value: _showIcon,
...@@ -100,13 +100,13 @@ class ListDemoState extends State<ListDemo> { ...@@ -100,13 +100,13 @@ class ListDemoState extends State<ListDemo> {
) )
), ),
new ListItem( new ListItem(
isDense: true, dense: true,
primary: new Text('Dense Layout'), primary: new Text('Dense Layout'),
right: new Checkbox( right: new Checkbox(
value: _isDense, value: _dense,
onChanged: (bool value) { onChanged: (bool value) {
setState(() { setState(() {
_isDense = value; _dense = value;
}); });
_bottomSheet?.setState(() { }); _bottomSheet?.setState(() { });
} }
...@@ -131,7 +131,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -131,7 +131,7 @@ class ListDemoState extends State<ListDemo> {
} }
return new ListItem( return new ListItem(
isThreeLine: _itemSize == ListDemoItemSize.threeLine, isThreeLine: _itemSize == ListDemoItemSize.threeLine,
isDense: _isDense, dense: _dense,
left: _showAvatar ? new CircleAvatar(child: new Text(item)) : null, left: _showAvatar ? new CircleAvatar(child: new Text(item)) : null,
primary: new Text('This item represents $item'), primary: new Text('This item represents $item'),
secondary: secondary, secondary: secondary,
...@@ -140,7 +140,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -140,7 +140,7 @@ class ListDemoState extends State<ListDemo> {
} }
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String layoutText = _isDense ? " \u2013 Dense" : ""; final String layoutText = _dense ? " \u2013 Dense" : "";
String itemSizeText; String itemSizeText;
switch(_itemSize) { switch(_itemSize) {
case ListDemoItemSize.oneLine: case ListDemoItemSize.oneLine:
...@@ -176,7 +176,7 @@ class ListDemoState extends State<ListDemo> { ...@@ -176,7 +176,7 @@ class ListDemoState extends State<ListDemo> {
] ]
), ),
body: new Block( body: new Block(
padding: new EdgeDims.all(_isDense ? 4.0 : 8.0), padding: new EdgeDims.all(_dense ? 4.0 : 8.0),
children: items.map((String item) => buildListItem(context, item)).toList() children: items.map((String item) => buildListItem(context, item)).toList()
) )
); );
......
...@@ -94,7 +94,7 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -94,7 +94,7 @@ class MenuDemoState extends State<MenuDemo> {
child: new Text('Context menu item one') child: new Text('Context menu item one')
), ),
new PopupMenuItem( new PopupMenuItem(
isDisabled: true, enabled: false,
child: new Text('A disabled menu item') child: new Text('A disabled menu item')
), ),
new PopupMenuItem( new PopupMenuItem(
...@@ -178,22 +178,22 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -178,22 +178,22 @@ class MenuDemoState extends State<MenuDemo> {
items: <PopupMenuItem>[ items: <PopupMenuItem>[
new CheckedPopupMenuItem( new CheckedPopupMenuItem(
value: _checkedValue1, value: _checkedValue1,
isChecked: isChecked(_checkedValue1), checked: isChecked(_checkedValue1),
child: new Text(_checkedValue1) child: new Text(_checkedValue1)
), ),
new CheckedPopupMenuItem( new CheckedPopupMenuItem(
isDisabled: true, enabled: false,
isChecked: isChecked(_checkedValue2), checked: isChecked(_checkedValue2),
child: new Text(_checkedValue2) child: new Text(_checkedValue2)
), ),
new CheckedPopupMenuItem( new CheckedPopupMenuItem(
value: _checkedValue3, value: _checkedValue3,
isChecked: isChecked(_checkedValue3), checked: isChecked(_checkedValue3),
child: new Text(_checkedValue3) child: new Text(_checkedValue3)
), ),
new CheckedPopupMenuItem( new CheckedPopupMenuItem(
value: _checkedValue4, value: _checkedValue4,
isChecked: isChecked(_checkedValue4), checked: isChecked(_checkedValue4),
child: new Text(_checkedValue4) child: new Text(_checkedValue4)
) )
] ]
......
...@@ -221,7 +221,7 @@ class StockHomeState extends State<StockHome> { ...@@ -221,7 +221,7 @@ class StockHomeState extends State<StockHome> {
items: <PopupMenuItem>[ items: <PopupMenuItem>[
new CheckedPopupMenuItem( new CheckedPopupMenuItem(
value: _StockMenuItem.autorefresh, value: _StockMenuItem.autorefresh,
isChecked: _autorefresh, checked: _autorefresh,
child: new Text('Autorefresh') child: new Text('Autorefresh')
), ),
new PopupMenuItem( new PopupMenuItem(
......
...@@ -11,7 +11,7 @@ import 'theme.dart'; ...@@ -11,7 +11,7 @@ import 'theme.dart';
/// Icons are defined with the [left] and [right] parameters. The first line of text /// Icons are defined with the [left] and [right] parameters. The first line of text
/// is not optional and is specified with [primary]. The value of [secondary] will /// is not optional and is specified with [primary]. The value of [secondary] will
/// occupy the space allocated for an aditional line of text, or two lines if /// occupy the space allocated for an aditional line of text, or two lines if
/// isThreeLine: true is specified. If isDense: true is specified then the overall /// isThreeLine: true is specified. If dense: true is specified then the overall
/// height of this list item and the size of the DefaultTextStyles that wrap /// height of this list item and the size of the DefaultTextStyles that wrap
/// the [primary] and [secondary] widget are reduced. /// the [primary] and [secondary] widget are reduced.
class ListItem extends StatelessComponent { class ListItem extends StatelessComponent {
...@@ -22,8 +22,8 @@ class ListItem extends StatelessComponent { ...@@ -22,8 +22,8 @@ class ListItem extends StatelessComponent {
this.secondary, this.secondary,
this.right, this.right,
this.isThreeLine: false, this.isThreeLine: false,
this.isDense: false, this.dense: false,
this.isDisabled: false, this.enabled: true,
this.onTap, this.onTap,
this.onLongPress this.onLongPress
}) : super(key: key) { }) : super(key: key) {
...@@ -36,26 +36,26 @@ class ListItem extends StatelessComponent { ...@@ -36,26 +36,26 @@ class ListItem extends StatelessComponent {
final Widget secondary; final Widget secondary;
final Widget right; final Widget right;
final bool isThreeLine; final bool isThreeLine;
final bool isDense; final bool dense;
final bool isDisabled; final bool enabled;
final GestureTapCallback onTap; final GestureTapCallback onTap;
final GestureLongPressCallback onLongPress; final GestureLongPressCallback onLongPress;
TextStyle primaryTextStyle(BuildContext context) { TextStyle primaryTextStyle(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final TextStyle style = theme.text.subhead; final TextStyle style = theme.text.subhead;
if (isDisabled) { if (!enabled) {
final Color color = theme.disabledColor; final Color color = theme.disabledColor;
return isDense ? style.copyWith(fontSize: 13.0, color: color) : style.copyWith(color: color); return dense ? style.copyWith(fontSize: 13.0, color: color) : style.copyWith(color: color);
} }
return isDense ? style.copyWith(fontSize: 13.0) : style; return dense ? style.copyWith(fontSize: 13.0) : style;
} }
TextStyle secondaryTextStyle(BuildContext context) { TextStyle secondaryTextStyle(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final Color color = theme.text.caption.color; final Color color = theme.text.caption.color;
final TextStyle style = theme.text.body1; final TextStyle style = theme.text.body1;
return isDense ? style.copyWith(color: color, fontSize: 12.0) : style.copyWith(color: color); return dense ? style.copyWith(color: color, fontSize: 12.0) : style.copyWith(color: color);
} }
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -63,15 +63,15 @@ class ListItem extends StatelessComponent { ...@@ -63,15 +63,15 @@ class ListItem extends StatelessComponent {
final bool isOneLine = !isThreeLine && !isTwoLine; final bool isOneLine = !isThreeLine && !isTwoLine;
double itemHeight; double itemHeight;
if (isOneLine) if (isOneLine)
itemHeight = isDense ? 48.0 : 56.0; itemHeight = dense ? 48.0 : 56.0;
else if (isTwoLine) else if (isTwoLine)
itemHeight = isDense ? 60.0 : 72.0; itemHeight = dense ? 60.0 : 72.0;
else else
itemHeight = isDense ? 76.0 : 88.0; itemHeight = dense ? 76.0 : 88.0;
double iconMarginTop = 0.0; double iconMarginTop = 0.0;
if (isThreeLine) if (isThreeLine)
iconMarginTop = isDense ? 8.0 : 16.0; iconMarginTop = dense ? 8.0 : 16.0;
// Overall, the list item is a Row() with these children. // Overall, the list item is a Row() with these children.
final List<Widget> children = <Widget>[]; final List<Widget> children = <Widget>[];
...@@ -120,8 +120,8 @@ class ListItem extends StatelessComponent { ...@@ -120,8 +120,8 @@ class ListItem extends StatelessComponent {
} }
return new InkWell( return new InkWell(
onTap: isDisabled ? null : onTap, onTap: enabled ? onTap : null,
onLongPress: isDisabled ? null : onLongPress, onLongPress: enabled ? onLongPress : null,
child: new Container( child: new Container(
height: itemHeight, height: itemHeight,
padding: const EdgeDims.symmetric(horizontal: 16.0), padding: const EdgeDims.symmetric(horizontal: 16.0),
......
...@@ -25,26 +25,25 @@ const double _kMenuMinWidth = 2.0 * _kMenuWidthStep; ...@@ -25,26 +25,25 @@ const double _kMenuMinWidth = 2.0 * _kMenuWidthStep;
const double _kMenuVerticalPadding = 8.0; const double _kMenuVerticalPadding = 8.0;
const double _kMenuWidthStep = 56.0; const double _kMenuWidthStep = 56.0;
const double _kMenuScreenPadding = 8.0; const double _kMenuScreenPadding = 8.0;
const double _kDisabledIconOpacity = 0.38;
class PopupMenuItem<T> extends StatelessComponent { class PopupMenuItem<T> extends StatelessComponent {
PopupMenuItem({ PopupMenuItem({
Key key, Key key,
this.value, this.value,
this.isDisabled: false, this.enabled: true,
this.hasDivider: false, this.hasDivider: false,
this.child this.child
}) : super(key: key); }) : super(key: key);
final T value; final T value;
final bool isDisabled; final bool enabled;
final bool hasDivider; final bool hasDivider;
final Widget child; final Widget child;
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
TextStyle style = theme.text.subhead; TextStyle style = theme.text.subhead;
if (isDisabled) if (!enabled)
style = style.copyWith(color: theme.disabledColor); style = style.copyWith(color: theme.disabledColor);
Widget item = new DefaultTextStyle( Widget item = new DefaultTextStyle(
...@@ -54,7 +53,7 @@ class PopupMenuItem<T> extends StatelessComponent { ...@@ -54,7 +53,7 @@ class PopupMenuItem<T> extends StatelessComponent {
child: child child: child
) )
); );
if (isDisabled) { if (!enabled) {
final bool isDark = theme.brightness == ThemeBrightness.dark; final bool isDark = theme.brightness == ThemeBrightness.dark;
item = new IconTheme( item = new IconTheme(
data: new IconThemeData(opacity: isDark ? 0.5 : 0.38), data: new IconThemeData(opacity: isDark ? 0.5 : 0.38),
...@@ -79,16 +78,16 @@ class CheckedPopupMenuItem<T> extends PopupMenuItem<T> { ...@@ -79,16 +78,16 @@ class CheckedPopupMenuItem<T> extends PopupMenuItem<T> {
CheckedPopupMenuItem({ CheckedPopupMenuItem({
Key key, Key key,
T value, T value,
isChecked: false, checked: false,
bool isDisabled: false, bool enabled: true,
Widget child Widget child
}) : super( }) : super(
key: key, key: key,
value: value, value: value,
isDisabled: isDisabled, enabled: enabled,
child: new ListItem( child: new ListItem(
isDisabled: isDisabled, enabled: enabled,
left: new Icon(icon: isChecked ? 'action/done' : null), left: new Icon(icon: checked ? 'action/done' : null),
primary: child primary: child
) )
); );
...@@ -113,7 +112,7 @@ class _PopupMenu<T> extends StatelessComponent { ...@@ -113,7 +112,7 @@ class _PopupMenu<T> extends StatelessComponent {
parent: route.animation, parent: route.animation,
curve: new Interval(start, end) curve: new Interval(start, end)
); );
final bool isDisabled = route.items[i].isDisabled; final bool enabled = route.items[i].enabled;
Widget item = route.items[i]; Widget item = route.items[i];
if (route.initialValue != null && route.initialValue == route.items[i].value) { if (route.initialValue != null && route.initialValue == route.items[i].value) {
item = new Container( item = new Container(
...@@ -124,7 +123,7 @@ class _PopupMenu<T> extends StatelessComponent { ...@@ -124,7 +123,7 @@ class _PopupMenu<T> extends StatelessComponent {
children.add(new FadeTransition( children.add(new FadeTransition(
opacity: opacity, opacity: opacity,
child: new InkWell( child: new InkWell(
onTap: isDisabled ? null : () { Navigator.pop(context, route.items[i].value); }, onTap: enabled ? () { Navigator.pop(context, route.items[i].value); } : null,
child: item child: item
) )
)); ));
......
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