forked from firka/flutter
Convert Persistent Bottom Sheets to a Scaffold API
- `Scaffold.of(context).showBottomSheet(widget);` - Returns an object with .closed Future and .close() method. - Uses a StateRoute to handle back button. - Take the Navigator logic out of the BottomSheet widget. - Support showing a sheet while an old one is going away. - Add Navigator.remove().
This commit is contained in:
@@ -20,7 +20,6 @@ class StockHome extends StatefulComponent {
|
||||
class StockHomeState extends State<StockHome> {
|
||||
|
||||
final GlobalKey scaffoldKey = new GlobalKey();
|
||||
final GlobalKey<PlaceholderState> _bottomSheetPlaceholderKey = new GlobalKey<PlaceholderState>();
|
||||
bool _isSearching = false;
|
||||
String _searchQuery;
|
||||
|
||||
@@ -202,11 +201,7 @@ class StockHomeState extends State<StockHome> {
|
||||
Navigator.of(context).pushNamed('/stock/${stock.symbol}', mostValuableKeys: mostValuableKeys);
|
||||
},
|
||||
onShow: (Stock stock, Key arrowKey) {
|
||||
showBottomSheet(
|
||||
placeholderKey: _bottomSheetPlaceholderKey,
|
||||
context: context,
|
||||
child: new StockSymbolBottomSheet(stock: stock)
|
||||
);
|
||||
scaffoldKey.currentState.showBottomSheet((BuildContext context) => new StockSymbolBottomSheet(stock: stock));
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -256,12 +251,14 @@ class StockHomeState extends State<StockHome> {
|
||||
showModalBottomSheet(
|
||||
// TODO(ianh): Fill this out.
|
||||
context: context,
|
||||
child: new Column([
|
||||
new Input(
|
||||
key: companyNameKey,
|
||||
placeholder: 'Company Name'
|
||||
),
|
||||
])
|
||||
builder: (BuildContext context) {
|
||||
return new Column([
|
||||
new Input(
|
||||
key: companyNameKey,
|
||||
placeholder: 'Company Name'
|
||||
),
|
||||
]);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -278,7 +275,6 @@ class StockHomeState extends State<StockHome> {
|
||||
key: scaffoldKey,
|
||||
toolBar: _isSearching ? buildSearchBar() : buildToolBar(),
|
||||
body: buildTabNavigator(),
|
||||
bottomSheet: new Placeholder(key: _bottomSheetPlaceholderKey),
|
||||
floatingActionButton: buildFloatingActionButton()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ class StockSymbolBottomSheet extends StatelessComponent {
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
child: new StockSymbolView(stock: stock),
|
||||
padding: new EdgeDims.all(10.0),
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(top: new BorderSide(color: Colors.black26, width: 1.0))
|
||||
)
|
||||
),
|
||||
child: new StockSymbolView(stock: stock)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user