Teach Block about padding.
It's common to want a scrolling viewport but with padding around the contents. Teaching Block about this makes the places that do this substantially simpler and further buries ScrollableViewport and BlockBody (they're now only used in scrollable.dart).
This commit is contained in:
@@ -84,19 +84,15 @@ class MealFragmentState extends State<MealFragment> {
|
||||
|
||||
Widget buildBody() {
|
||||
Meal meal = new Meal(when: new DateTime.now());
|
||||
// TODO(ianh): Fix Block such that we could use that here instead of rolling our own
|
||||
return new ScrollableViewport(
|
||||
child: new Container(
|
||||
padding: const EdgeDims.all(20.0),
|
||||
child: new BlockBody(<Widget>[
|
||||
new Text(meal.displayDate),
|
||||
new Input(
|
||||
key: descriptionKey,
|
||||
placeholder: 'Describe meal',
|
||||
onChanged: _handleDescriptionChanged
|
||||
),
|
||||
])
|
||||
)
|
||||
return new Block(<Widget>[
|
||||
new Text(meal.displayDate),
|
||||
new Input(
|
||||
key: descriptionKey,
|
||||
placeholder: 'Describe meal',
|
||||
onChanged: _handleDescriptionChanged
|
||||
),
|
||||
],
|
||||
padding: const EdgeDims.all(20.0)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,29 +90,25 @@ class SettingsFragmentState extends State<SettingsFragment> {
|
||||
}
|
||||
|
||||
Widget buildSettingsPane(BuildContext context) {
|
||||
// TODO(ianh): Make Block capable of doing this
|
||||
return new ScrollableViewport(
|
||||
child: new Container(
|
||||
padding: const EdgeDims.symmetric(vertical: 20.0),
|
||||
child: new BlockBody(<Widget>[
|
||||
new DrawerItem(
|
||||
onPressed: () { _handleBackupChanged(!(config.userData.backupMode == BackupMode.enabled)); },
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Back up data to the cloud')),
|
||||
new Switch(value: config.userData.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged),
|
||||
])
|
||||
),
|
||||
new DrawerItem(
|
||||
onPressed: () => _handleGoalWeightPressed(),
|
||||
child: new Column(<Widget>[
|
||||
new Text('Goal Weight'),
|
||||
new Text(goalWeightText, style: Theme.of(context).text.caption),
|
||||
],
|
||||
alignItems: FlexAlignItems.start
|
||||
)
|
||||
),
|
||||
])
|
||||
)
|
||||
return new Block(<Widget>[
|
||||
new DrawerItem(
|
||||
onPressed: () { _handleBackupChanged(!(config.userData.backupMode == BackupMode.enabled)); },
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Back up data to the cloud')),
|
||||
new Switch(value: config.userData.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged),
|
||||
])
|
||||
),
|
||||
new DrawerItem(
|
||||
onPressed: () => _handleGoalWeightPressed(),
|
||||
child: new Column(<Widget>[
|
||||
new Text('Goal Weight'),
|
||||
new Text(goalWeightText, style: Theme.of(context).text.caption),
|
||||
],
|
||||
alignItems: FlexAlignItems.start
|
||||
)
|
||||
),
|
||||
],
|
||||
padding: const EdgeDims.symmetric(vertical: 20.0)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,34 +81,31 @@ class StockSettingsState extends State<StockSettings> {
|
||||
Widget buildSettingsPane(BuildContext context) {
|
||||
// TODO(ianh): Once we have the gesture API hooked up, fix https://github.com/domokit/mojo/issues/281
|
||||
// (whereby tapping the widgets below causes both the widget and the menu item to fire their callbacks)
|
||||
return new ScrollableViewport(
|
||||
child: new Container(
|
||||
padding: const EdgeDims.symmetric(vertical: 20.0),
|
||||
child: new BlockBody(<Widget>[
|
||||
new DrawerItem(
|
||||
icon: 'action/thumb_up',
|
||||
onPressed: () => _confirmOptimismChange(),
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Everything is awesome')),
|
||||
new Checkbox(
|
||||
value: config.optimism == StockMode.optimistic,
|
||||
onChanged: (bool value) => _confirmOptimismChange()
|
||||
),
|
||||
])
|
||||
),
|
||||
new DrawerItem(
|
||||
icon: 'action/backup',
|
||||
onPressed: () { _handleBackupChanged(!(config.backup == BackupMode.enabled)); },
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Back up stock list to the cloud')),
|
||||
new Switch(
|
||||
value: config.backup == BackupMode.enabled,
|
||||
onChanged: _handleBackupChanged
|
||||
),
|
||||
])
|
||||
),
|
||||
])
|
||||
)
|
||||
return new Block(<Widget>[
|
||||
new DrawerItem(
|
||||
icon: 'action/thumb_up',
|
||||
onPressed: () => _confirmOptimismChange(),
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Everything is awesome')),
|
||||
new Checkbox(
|
||||
value: config.optimism == StockMode.optimistic,
|
||||
onChanged: (bool value) => _confirmOptimismChange()
|
||||
),
|
||||
])
|
||||
),
|
||||
new DrawerItem(
|
||||
icon: 'action/backup',
|
||||
onPressed: () { _handleBackupChanged(!(config.backup == BackupMode.enabled)); },
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Back up stock list to the cloud')),
|
||||
new Switch(
|
||||
value: config.backup == BackupMode.enabled,
|
||||
onChanged: _handleBackupChanged
|
||||
),
|
||||
])
|
||||
),
|
||||
],
|
||||
padding: const EdgeDims.symmetric(vertical: 20.0)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user