提交 91f2cc00 编写于 作者: E Eric Seidel

Merge pull request #562 from eseidelGoogle/fitness

Fix crash when hitting "enter" key on keyboard during entry
...@@ -254,7 +254,13 @@ class AddItemDialog extends StatefulComponent { ...@@ -254,7 +254,13 @@ class AddItemDialog extends StatefulComponent {
this.navigator = source.navigator; this.navigator = source.navigator;
} }
String _addItemRoute; // TODO(jackson): Internationalize
static final Map<String, String> _labels = {
'/measurements/new': 'Measure',
'/meals/new': 'Eat',
};
String _addItemRoute = _labels.keys.first;
void _handleAddItemRouteChanged(String routeName) { void _handleAddItemRouteChanged(String routeName) {
setState(() { setState(() {
...@@ -263,15 +269,10 @@ class AddItemDialog extends StatefulComponent { ...@@ -263,15 +269,10 @@ class AddItemDialog extends StatefulComponent {
} }
Widget build() { Widget build() {
// TODO(jackson): Internationalize
Map<String, String> labels = {
'/meals/new': 'Eat',
'/measurements/new': 'Measure',
};
List<Widget> menuItems = []; List<Widget> menuItems = [];
for(String routeName in labels.keys) { for(String routeName in _labels.keys) {
menuItems.add(new DialogMenuItem([ menuItems.add(new DialogMenuItem([
new Flexible(child: new Text(labels[routeName])), new Flexible(child: new Text(_labels[routeName])),
new Radio(value: routeName, groupValue: _addItemRoute, onChanged: _handleAddItemRouteChanged), new Radio(value: routeName, groupValue: _addItemRoute, onChanged: _handleAddItemRouteChanged),
], onPressed: () => _handleAddItemRouteChanged(routeName))); ], onPressed: () => _handleAddItemRouteChanged(routeName)));
} }
......
...@@ -72,7 +72,8 @@ class MeasurementFragment extends StatefulComponent { ...@@ -72,7 +72,8 @@ class MeasurementFragment extends StatefulComponent {
double parsedWeight; double parsedWeight;
try { try {
parsedWeight = double.parse(_weight); parsedWeight = double.parse(_weight);
} on FormatException { } on FormatException catch(e) {
print("Exception $e");
setState(() { setState(() {
_errorMessage = "Save failed"; _errorMessage = "Save failed";
}); });
...@@ -130,6 +131,7 @@ class MeasurementFragment extends StatefulComponent { ...@@ -130,6 +131,7 @@ class MeasurementFragment extends StatefulComponent {
Widget buildSnackBar() { Widget buildSnackBar() {
if (_errorMessage == null) if (_errorMessage == null)
return null; return null;
// TODO(jackson): This doesn't show up, unclear why.
return new SnackBar(content: new Text(_errorMessage)); return new SnackBar(content: new Text(_errorMessage));
} }
......
...@@ -2,8 +2,8 @@ name: fitness ...@@ -2,8 +2,8 @@ name: fitness
dependencies: dependencies:
sky: any sky: any
sky_tools: any sky_tools: any
dependency_overrides:
path: "^1.3.6" path: "^1.3.6"
dependency_overrides:
material_design_icons: material_design_icons:
path: ../../sky/packages/material_design_icons path: ../../sky/packages/material_design_icons
sky: sky:
......
...@@ -72,7 +72,9 @@ class SnackBar extends Component { ...@@ -72,7 +72,9 @@ class SnackBar extends Component {
) )
) )
) )
]..addAll(actions); ];
if (actions != null)
children.addAll(actions);
return new SlideTransition( return new SlideTransition(
duration: _kSlideInDuration, duration: _kSlideInDuration,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册