Commit 5d99f31c authored by Adam Barth's avatar Adam Barth

Merge pull request #767 from abarth/modernize_drawer_item

DrawerItem, DrawerHeader should take a child instead of children
parents 2873880f 18248543
...@@ -100,26 +100,26 @@ class FeedFragment extends StatefulComponent { ...@@ -100,26 +100,26 @@ class FeedFragment extends StatefulComponent {
onDismissed: _handleDrawerDismissed, onDismissed: _handleDrawerDismissed,
navigator: navigator, navigator: navigator,
children: [ children: [
new DrawerHeader(children: [new Text('Fitness')]), new DrawerHeader(child: new Text('Fitness')),
new DrawerItem( new DrawerItem(
icon: 'action/view_list', icon: 'action/view_list',
onPressed: () => _handleFitnessModeChange(FitnessMode.feed), onPressed: () => _handleFitnessModeChange(FitnessMode.feed),
selected: _fitnessMode == FitnessMode.feed, selected: _fitnessMode == FitnessMode.feed,
children: [new Text('Feed')]), child: new Text('Feed')),
new DrawerItem( new DrawerItem(
icon: 'action/assessment', icon: 'action/assessment',
onPressed: () => _handleFitnessModeChange(FitnessMode.chart), onPressed: () => _handleFitnessModeChange(FitnessMode.chart),
selected: _fitnessMode == FitnessMode.chart, selected: _fitnessMode == FitnessMode.chart,
children: [new Text('Chart')]), child: new Text('Chart')),
new DrawerDivider(), new DrawerDivider(),
new DrawerItem( new DrawerItem(
icon: 'action/settings', icon: 'action/settings',
onPressed: _handleShowSettings, onPressed: _handleShowSettings,
children: [new Text('Settings')]), child: new Text('Settings')),
new DrawerItem( new DrawerItem(
icon: 'action/help', icon: 'action/help',
children: [new Text('Help & Feedback')]) child: new Text('Help & Feedback'))
] ]
); );
} }
......
...@@ -104,19 +104,17 @@ class SettingsFragment extends StatefulComponent { ...@@ -104,19 +104,17 @@ class SettingsFragment extends StatefulComponent {
child: new BlockBody([ child: new BlockBody([
new DrawerItem( new DrawerItem(
onPressed: () { _handleBackupChanged(!(userData.backupMode == BackupMode.enabled)); }, onPressed: () { _handleBackupChanged(!(userData.backupMode == BackupMode.enabled)); },
children: [ child: new Flex([
new Flexible(child: new Text('Back up data to the cloud')), new Flexible(child: new Text('Back up data to the cloud')),
new Switch(value: userData.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged) new Switch(value: userData.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged)
] ], direction: FlexDirection.horizontal)
), ),
new DrawerItem( new DrawerItem(
onPressed: () => _handleGoalWeightPressed(), onPressed: () => _handleGoalWeightPressed(),
children: [ child: new Flex([
new Flex([ new Text('Goal Weight'),
new Text('Goal Weight'), new Text(goalWeightText, style: Theme.of(this).text.caption),
new Text(goalWeightText, style: Theme.of(this).text.caption), ], direction: FlexDirection.vertical, alignItems: FlexAlignItems.start)
], direction: FlexDirection.vertical, alignItems: FlexAlignItems.start)
]
), ),
]) ])
) )
......
...@@ -122,37 +122,37 @@ class StockHome extends StatefulComponent { ...@@ -122,37 +122,37 @@ class StockHome extends StatefulComponent {
onDismissed: _handleDrawerDismissed, onDismissed: _handleDrawerDismissed,
navigator: navigator, navigator: navigator,
children: [ children: [
new DrawerHeader(children: [new Text('Stocks')]), new DrawerHeader(child: new Text('Stocks')),
new DrawerItem( new DrawerItem(
icon: 'action/assessment', icon: 'action/assessment',
selected: true, selected: true,
children: [new Text('Stock List')]), child: new Text('Stock List')),
new DrawerItem( new DrawerItem(
icon: 'action/account_balance', icon: 'action/account_balance',
children: [new Text('Account Balance')]), child: new Text('Account Balance')),
new DrawerDivider(), new DrawerDivider(),
new DrawerItem( new DrawerItem(
icon: 'action/thumb_up', icon: 'action/thumb_up',
onPressed: () => _handleStockModeChange(StockMode.optimistic), onPressed: () => _handleStockModeChange(StockMode.optimistic),
children: [ child: new Flex([
new Flexible(child: new Text('Optimistic')), new Flexible(child: new Text('Optimistic')),
new Radio(value: StockMode.optimistic, groupValue: stockMode, onChanged: _handleStockModeChange) new Radio(value: StockMode.optimistic, groupValue: stockMode, onChanged: _handleStockModeChange)
]), ], direction: FlexDirection.horizontal)),
new DrawerItem( new DrawerItem(
icon: 'action/thumb_down', icon: 'action/thumb_down',
onPressed: () => _handleStockModeChange(StockMode.pessimistic), onPressed: () => _handleStockModeChange(StockMode.pessimistic),
children: [ child: new Flex([
new Flexible(child: new Text('Pessimistic')), new Flexible(child: new Text('Pessimistic')),
new Radio(value: StockMode.pessimistic, groupValue: stockMode, onChanged: _handleStockModeChange) new Radio(value: StockMode.pessimistic, groupValue: stockMode, onChanged: _handleStockModeChange)
]), ], direction: FlexDirection.horizontal)),
new DrawerDivider(), new DrawerDivider(),
new DrawerItem( new DrawerItem(
icon: 'action/settings', icon: 'action/settings',
onPressed: _handleShowSettings, onPressed: _handleShowSettings,
children: [new Text('Settings')]), child: new Text('Settings')),
new DrawerItem( new DrawerItem(
icon: 'action/help', icon: 'action/help',
children: [new Text('Help & Feedback')]) child: new Text('Help & Feedback'))
] ]
); );
} }
......
...@@ -102,18 +102,18 @@ class StockSettings extends StatefulComponent { ...@@ -102,18 +102,18 @@ class StockSettings extends StatefulComponent {
new DrawerItem( new DrawerItem(
icon: 'action/thumb_up', icon: 'action/thumb_up',
onPressed: () => _confirmOptimismChange(), onPressed: () => _confirmOptimismChange(),
children: [ child: new Flex([
new Flexible(child: new Text('Everything is awesome')), new Flexible(child: new Text('Everything is awesome')),
new Checkbox(value: optimism == StockMode.optimistic, onChanged: (_) => _confirmOptimismChange()) new Checkbox(value: optimism == StockMode.optimistic, onChanged: (_) => _confirmOptimismChange())
] ], direction: FlexDirection.horizontal)
), ),
new DrawerItem( new DrawerItem(
icon: 'action/backup', icon: 'action/backup',
onPressed: () { _handleBackupChanged(!(backup == BackupMode.enabled)); }, onPressed: () { _handleBackupChanged(!(backup == BackupMode.enabled)); },
children: [ child: new Flex([
new Flexible(child: new Text('Back up stock list to the cloud')), new Flexible(child: new Text('Back up stock list to the cloud')),
new Switch(value: backup == BackupMode.enabled, onChanged: _handleBackupChanged) new Switch(value: backup == BackupMode.enabled, onChanged: _handleBackupChanged)
] ], direction: FlexDirection.horizontal)
), ),
]) ])
) )
......
...@@ -12,9 +12,9 @@ import 'package:sky/widgets/theme.dart'; ...@@ -12,9 +12,9 @@ import 'package:sky/widgets/theme.dart';
class DrawerHeader extends Component { class DrawerHeader extends Component {
DrawerHeader({ Key key, this.children }) : super(key: key); DrawerHeader({ Key key, this.child }) : super(key: key);
final List<Widget> children; final Widget child;
Widget build() { Widget build() {
return new Container( return new Container(
...@@ -36,7 +36,7 @@ class DrawerHeader extends Component { ...@@ -36,7 +36,7 @@ class DrawerHeader extends Component {
padding: const EdgeDims.symmetric(horizontal: 16.0), padding: const EdgeDims.symmetric(horizontal: 16.0),
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: Theme.of(this).text.body2, style: Theme.of(this).text.body2,
child: new Flex(children, direction: FlexDirection.horizontal) child: child
) )
)], )],
direction: FlexDirection.vertical direction: FlexDirection.vertical
......
...@@ -17,17 +17,17 @@ import 'package:sky/widgets/framework.dart'; ...@@ -17,17 +17,17 @@ import 'package:sky/widgets/framework.dart';
typedef EventDisposition OnPressedFunction(); typedef EventDisposition OnPressedFunction();
class DrawerItem extends ButtonBase { class DrawerItem extends ButtonBase {
DrawerItem({ Key key, this.icon, this.children, this.onPressed, this.selected: false }) DrawerItem({ Key key, this.icon, this.child, this.onPressed, this.selected: false })
: super(key: key); : super(key: key);
String icon; String icon;
List<Widget> children; Widget child;
OnPressedFunction onPressed; OnPressedFunction onPressed;
bool selected; bool selected;
void syncConstructorArguments(DrawerItem source) { void syncConstructorArguments(DrawerItem source) {
icon = source.icon; icon = source.icon;
children = source.children; child = source.child;
onPressed = source.onPressed; onPressed = source.onPressed;
selected = source.selected; selected = source.selected;
super.syncConstructorArguments(source); super.syncConstructorArguments(source);
...@@ -75,7 +75,7 @@ class DrawerItem extends ButtonBase { ...@@ -75,7 +75,7 @@ class DrawerItem extends ButtonBase {
padding: const EdgeDims.symmetric(horizontal: 16.0), padding: const EdgeDims.symmetric(horizontal: 16.0),
child: new DefaultTextStyle( child: new DefaultTextStyle(
style: _getTextStyle(themeData), style: _getTextStyle(themeData),
child: new Flex(children, direction: FlexDirection.horizontal) child: child
) )
) )
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment