Switch Material Design icons to using the iconfont

Rather than managing all the Material Design icons manually, we now
manage them using an icon font. The icon font contains glyphs for each
icon in an efficient vector format.

This patch updates the FLX tooling to include the MaterialIcons font and
updates the Icon widget to use the font instead of asset images.

Fixes #2313
Fixes #2218
Fixes #2009
Fixes #994
This commit is contained in:
Adam Barth
2016-03-01 20:27:35 -08:00
parent 6e2d654962
commit 870894fc68
46 changed files with 1234 additions and 382 deletions

View File

@@ -134,16 +134,16 @@ class CardCollectionState extends State<CardCollection> {
buildDrawerColorRadioItem("Amber", Colors.amber, _primaryColor, _selectColor),
buildDrawerColorRadioItem("Teal", Colors.teal, _primaryColor, _selectColor),
new Divider(),
buildDrawerDirectionRadioItem("Dismiss horizontally", DismissDirection.horizontal, _dismissDirection, _changeDismissDirection, icon: 'action/code'),
buildDrawerDirectionRadioItem("Dismiss left", DismissDirection.left, _dismissDirection, _changeDismissDirection, icon: 'navigation/arrow_back'),
buildDrawerDirectionRadioItem("Dismiss right", DismissDirection.right, _dismissDirection, _changeDismissDirection, icon: 'navigation/arrow_forward'),
buildDrawerDirectionRadioItem("Dismiss horizontally", DismissDirection.horizontal, _dismissDirection, _changeDismissDirection, icon: Icons.code),
buildDrawerDirectionRadioItem("Dismiss left", DismissDirection.left, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_back),
buildDrawerDirectionRadioItem("Dismiss right", DismissDirection.right, _dismissDirection, _changeDismissDirection, icon: Icons.arrow_forward),
new Divider(),
buildFontRadioItem("Left-align text", new TextStyle(textAlign: TextAlign.left), _textStyle, _changeTextStyle, icon: 'editor/format_align_left', enabled: !_editable),
buildFontRadioItem("Center-align text", new TextStyle(textAlign: TextAlign.center), _textStyle, _changeTextStyle, icon: 'editor/format_align_center', enabled: !_editable),
buildFontRadioItem("Right-align text", new TextStyle(textAlign: TextAlign.right), _textStyle, _changeTextStyle, icon: 'editor/format_align_right', enabled: !_editable),
buildFontRadioItem("Left-align text", new TextStyle(textAlign: TextAlign.left), _textStyle, _changeTextStyle, icon: Icons.format_align_left, enabled: !_editable),
buildFontRadioItem("Center-align text", new TextStyle(textAlign: TextAlign.center), _textStyle, _changeTextStyle, icon: Icons.format_align_center, enabled: !_editable),
buildFontRadioItem("Right-align text", new TextStyle(textAlign: TextAlign.right), _textStyle, _changeTextStyle, icon: Icons.format_align_right, enabled: !_editable),
new Divider(),
new DrawerItem(
icon: 'device/dvr',
icon: Icons.dvr,
onPressed: () { debugDumpApp(); debugDumpRenderTree(); },
child: new Text('Dump App to Console')
),
@@ -221,7 +221,7 @@ class CardCollectionState extends State<CardCollection> {
);
}
Widget buildDrawerColorRadioItem(String label, Map<int, Color> itemValue, Map<int, Color> currentValue, ValueChanged<Map<int, Color>> onChanged, { String icon, bool enabled: true }) {
Widget buildDrawerColorRadioItem(String label, Map<int, Color> itemValue, Map<int, Color> currentValue, ValueChanged<Map<int, Color>> onChanged, { IconData icon, bool enabled: true }) {
return new DrawerItem(
icon: icon,
onPressed: enabled ? () { onChanged(itemValue); } : null,
@@ -238,7 +238,7 @@ class CardCollectionState extends State<CardCollection> {
);
}
Widget buildDrawerDirectionRadioItem(String label, DismissDirection itemValue, DismissDirection currentValue, ValueChanged<DismissDirection> onChanged, { String icon, bool enabled: true }) {
Widget buildDrawerDirectionRadioItem(String label, DismissDirection itemValue, DismissDirection currentValue, ValueChanged<DismissDirection> onChanged, { IconData icon, bool enabled: true }) {
return new DrawerItem(
icon: icon,
onPressed: enabled ? () { onChanged(itemValue); } : null,
@@ -255,7 +255,7 @@ class CardCollectionState extends State<CardCollection> {
);
}
Widget buildFontRadioItem(String label, TextStyle itemValue, TextStyle currentValue, ValueChanged<TextStyle> onChanged, { String icon, bool enabled: true }) {
Widget buildFontRadioItem(String label, TextStyle itemValue, TextStyle currentValue, ValueChanged<TextStyle> onChanged, { IconData icon, bool enabled: true }) {
return new DrawerItem(
icon: icon,
onPressed: enabled ? () { onChanged(itemValue); } : null,
@@ -347,11 +347,11 @@ class CardCollectionState extends State<CardCollection> {
backgroundMessage = "Unsupported dismissDirection";
}
Widget leftArrowIcon = new Icon(icon: 'navigation/arrow_back', size: IconSize.s36);
Widget leftArrowIcon = new Icon(icon: Icons.arrow_back, size: 36.0);
if (_dismissDirection == DismissDirection.right)
leftArrowIcon = new Opacity(opacity: 0.1, child: leftArrowIcon);
Widget rightArrowIcon = new Icon(icon: 'navigation/arrow_forward', size: IconSize.s36);
Widget rightArrowIcon = new Icon(icon: Icons.arrow_forward, size: 36.0);
if (_dismissDirection == DismissDirection.left)
rightArrowIcon = new Opacity(opacity: 0.1, child: rightArrowIcon);

View File

@@ -1,26 +1,4 @@
name: widgets
uses-material-design: true
assets:
- assets/starcircle.png
material-design-icons:
- name: action/account_circle
- name: action/alarm
- name: action/android
- name: action/assessment
- name: action/code
- name: action/event
- name: action/face
- name: action/home
- name: action/language
- name: action/list
- name: content/add
- name: content/create
- name: device/dvr
- name: editor/format_align_center
- name: editor/format_align_left
- name: editor/format_align_right
- name: navigation/arrow_back
- name: navigation/arrow_forward
- name: navigation/menu
- name: navigation/more_horiz
- name: navigation/more_vert
- name: navigation/refresh

View File

@@ -52,8 +52,8 @@ class HeroDemo extends StatelessComponent {
Widget build(BuildContext context) {
return new Scaffold(
toolBar: new ToolBar(
left: new IconButton(icon: "navigation/menu"),
center: new Text("Diets")
left: new IconButton(icon: Icons.menu),
center: new Text('Diets')
),
body: new Center(
child: new GestureDetector(
@@ -105,11 +105,11 @@ class CrabPage extends StatelessComponent {
padding: new EdgeDims.only(top: ui.window.padding.top),
backgroundColor: const Color(0x00000000),
left: new IconButton(
icon: "navigation/arrow_back",
icon: Icons.arrow_back,
onPressed: () => Navigator.pop(context)
),
right: <Widget>[
new IconButton(icon: "navigation/more_vert")
new IconButton(icon: Icons.more_vert)
]
),
new Positioned(

View File

@@ -64,7 +64,7 @@ class PostDemoState extends State<PostDemo> {
floatingActionButton: new FloatingActionButton(
tooltip: 'Refresh',
child: new Icon(
icon: 'navigation/refresh'
icon: Icons.refresh
),
onPressed: _refresh
)

View File

@@ -81,13 +81,13 @@ class PageableListAppState extends State<PageableListApp> {
child: new Block(children: <Widget>[
new DrawerHeader(child: new Text('Options')),
new DrawerItem(
icon: 'navigation/more_horiz',
icon: Icons.more_horiz,
selected: scrollDirection == Axis.horizontal,
child: new Text('Horizontal Layout'),
onPressed: switchScrollDirection
),
new DrawerItem(
icon: 'navigation/more_vert',
icon: Icons.more_vert,
selected: scrollDirection == Axis.vertical,
child: new Text('Vertical Layout'),
onPressed: switchScrollDirection