Icon should use an enum rather than an int for size

Material design icons are defined to work at specific sizes: 18, 24, 36, 48.
The current API doesn't reflect that and just takes a size int. If an invalid
size is chosen an error is printed to the console and no icon shows up.

Fixes #1816
This commit is contained in:
Adam Barth
2015-10-28 07:26:09 -07:00
parent 02a1ebabd7
commit eeea4ab7c7
10 changed files with 30 additions and 18 deletions

View File

@@ -20,7 +20,7 @@ class Field extends StatelessComponent {
return new Row(<Widget>[
new Padding(
padding: const EdgeDims.symmetric(horizontal: 16.0),
child: new Icon(type: icon, size: 24)
child: new Icon(type: icon)
),
new Flexible(
child: new Input(
@@ -43,7 +43,7 @@ class AddressBookHome extends StatelessComponent {
Widget buildFloatingActionButton(BuildContext context) {
return new FloatingActionButton(
child: new Icon(type: 'image/photo_camera', size: 24),
child: new Icon(type: 'image/photo_camera'),
backgroundColor: Theme.of(context).accentColor
);
}

View File

@@ -200,7 +200,7 @@ class FeedFragmentState extends State<FeedFragment> {
switch (_fitnessMode) {
case FitnessMode.feed:
return new FloatingActionButton(
child: new Icon(type: 'content/add', size: 24),
child: new Icon(type: 'content/add'),
onPressed: _handleActionButtonPressed
);
case FitnessMode.chart:

View File

@@ -254,7 +254,7 @@ class StockHomeState extends State<StockHome> {
Widget buildFloatingActionButton() {
return new FloatingActionButton(
child: new Icon(type: 'content/add', size: 24),
child: new Icon(type: 'content/add'),
backgroundColor: Colors.redAccent[200],
onPressed: _handleStockPurchased
);

View File

@@ -63,7 +63,7 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool>
child: new Row(<Widget>[
new Icon(
type: 'device/dvr',
size: 18
size: IconSize.s18
),
new Container(
width: 8.0

View File

@@ -289,7 +289,7 @@ class CardCollectionState extends State<CardCollection> {
child: new Container(
height: cardModel.height,
padding: const EdgeDims.all(8.0),
child: _editable ?
child: _editable ?
new Center(
child: new Input(
key: new GlobalObjectKey(cardModel),
@@ -329,11 +329,11 @@ class CardCollectionState extends State<CardCollection> {
backgroundMessage = "Unsupported dismissDirection";
}
Widget leftArrowIcon = new Icon(type: 'navigation/arrow_back', size: 36);
Widget leftArrowIcon = new Icon(type: 'navigation/arrow_back', size: IconSize.s36);
if (_dismissDirection == DismissDirection.right)
leftArrowIcon = new Opacity(opacity: 0.1, child: leftArrowIcon);
Widget rightArrowIcon = new Icon(type: 'navigation/arrow_forward', size: 36);
Widget rightArrowIcon = new Icon(type: 'navigation/arrow_forward', size: IconSize.s36);
if (_dismissDirection == DismissDirection.left)
rightArrowIcon = new Opacity(opacity: 0.1, child: rightArrowIcon);