DrawerItem, DrawerHeader should take a child instead of children

These widgets were designed in CSS where you need to specify a layout model for
your children. This patch updates them to the modern style of just taking a
unique child.

Fixes #755
This commit is contained in:
Adam Barth
2015-08-22 08:19:15 -07:00
parent 89c1144718
commit 18248543cb
6 changed files with 32 additions and 34 deletions

View File

@@ -100,26 +100,26 @@ class FeedFragment extends StatefulComponent {
onDismissed: _handleDrawerDismissed,
navigator: navigator,
children: [
new DrawerHeader(children: [new Text('Fitness')]),
new DrawerHeader(child: new Text('Fitness')),
new DrawerItem(
icon: 'action/view_list',
onPressed: () => _handleFitnessModeChange(FitnessMode.feed),
selected: _fitnessMode == FitnessMode.feed,
children: [new Text('Feed')]),
child: new Text('Feed')),
new DrawerItem(
icon: 'action/assessment',
onPressed: () => _handleFitnessModeChange(FitnessMode.chart),
selected: _fitnessMode == FitnessMode.chart,
children: [new Text('Chart')]),
child: new Text('Chart')),
new DrawerDivider(),
new DrawerItem(
icon: 'action/settings',
onPressed: _handleShowSettings,
children: [new Text('Settings')]),
child: new Text('Settings')),
new DrawerItem(
icon: 'action/help',
children: [new Text('Help & Feedback')])
]
child: new Text('Help & Feedback'))
]
);
}

View File

@@ -112,19 +112,17 @@ class SettingsFragment extends StatefulComponent {
child: new BlockBody([
new DrawerItem(
onPressed: () { _handleBackupChanged(!(userData.backupMode == BackupMode.enabled)); },
children: [
child: new Flex([
new Flexible(child: new Text('Back up data to the cloud')),
new Switch(value: userData.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged)
]
], direction: FlexDirection.horizontal)
),
new DrawerItem(
onPressed: () => _handleGoalWeightPressed(),
children: [
new Flex([
new Text('Goal Weight'),
new Text(goalWeightText, style: Theme.of(this).text.caption),
], direction: FlexDirection.vertical, alignItems: FlexAlignItems.start)
]
child: new Flex([
new Text('Goal Weight'),
new Text(goalWeightText, style: Theme.of(this).text.caption),
], direction: FlexDirection.vertical, alignItems: FlexAlignItems.start)
),
])
)

View File

@@ -122,37 +122,37 @@ class StockHome extends StatefulComponent {
onDismissed: _handleDrawerDismissed,
navigator: navigator,
children: [
new DrawerHeader(children: [new Text('Stocks')]),
new DrawerHeader(child: new Text('Stocks')),
new DrawerItem(
icon: 'action/assessment',
selected: true,
children: [new Text('Stock List')]),
child: new Text('Stock List')),
new DrawerItem(
icon: 'action/account_balance',
children: [new Text('Account Balance')]),
child: new Text('Account Balance')),
new DrawerDivider(),
new DrawerItem(
icon: 'action/thumb_up',
onPressed: () => _handleStockModeChange(StockMode.optimistic),
children: [
child: new Flex([
new Flexible(child: new Text('Optimistic')),
new Radio(value: StockMode.optimistic, groupValue: stockMode, onChanged: _handleStockModeChange)
]),
], direction: FlexDirection.horizontal)),
new DrawerItem(
icon: 'action/thumb_down',
onPressed: () => _handleStockModeChange(StockMode.pessimistic),
children: [
child: new Flex([
new Flexible(child: new Text('Pessimistic')),
new Radio(value: StockMode.pessimistic, groupValue: stockMode, onChanged: _handleStockModeChange)
]),
], direction: FlexDirection.horizontal)),
new DrawerDivider(),
new DrawerItem(
icon: 'action/settings',
onPressed: _handleShowSettings,
children: [new Text('Settings')]),
child: new Text('Settings')),
new DrawerItem(
icon: 'action/help',
children: [new Text('Help & Feedback')])
child: new Text('Help & Feedback'))
]
);
}

View File

@@ -102,18 +102,18 @@ class StockSettings extends StatefulComponent {
new DrawerItem(
icon: 'action/thumb_up',
onPressed: () => _confirmOptimismChange(),
children: [
child: new Flex([
new Flexible(child: new Text('Everything is awesome')),
new Checkbox(value: optimism == StockMode.optimistic, onChanged: (_) => _confirmOptimismChange())
]
], direction: FlexDirection.horizontal)
),
new DrawerItem(
icon: 'action/backup',
onPressed: () { _handleBackupChanged(!(backup == BackupMode.enabled)); },
children: [
child: new Flex([
new Flexible(child: new Text('Back up stock list to the cloud')),
new Switch(value: backup == BackupMode.enabled, onChanged: _handleBackupChanged)
]
], direction: FlexDirection.horizontal)
),
])
)