Commit ceddf0e5 authored by Adam Barth's avatar Adam Barth

Make the search box in the stocks app show a search field

The search field doesn't do anything, but it's there.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/998803002
parent 5d27d7b2
#!mojo mojo:sky_viewer #!mojo mojo:sky_viewer
<sky> <sky>
<import src="/sky/framework/debug/shake-to-reload.sky" />
<script> <script>
import 'stocksapp.dart'; import 'stocksapp.dart';
main() { main() {
......
...@@ -6,6 +6,7 @@ import '../../framework/components/drawer_header.dart'; ...@@ -6,6 +6,7 @@ import '../../framework/components/drawer_header.dart';
import '../../framework/components/fixed_height_scrollable.dart'; import '../../framework/components/fixed_height_scrollable.dart';
import '../../framework/components/floating_action_button.dart'; import '../../framework/components/floating_action_button.dart';
import '../../framework/components/icon.dart'; import '../../framework/components/icon.dart';
import '../../framework/components/input.dart';
import '../../framework/components/material.dart'; import '../../framework/components/material.dart';
import '../../framework/components/menu_divider.dart'; import '../../framework/components/menu_divider.dart';
import '../../framework/components/menu_item.dart'; import '../../framework/components/menu_item.dart';
...@@ -40,12 +41,19 @@ class StocksApp extends App { ...@@ -40,12 +41,19 @@ class StocksApp extends App {
); );
List<Stock> _sortedStocks; List<Stock> _sortedStocks;
bool _isSearching = false;
StocksApp() : super() { StocksApp() : super() {
_sortedStocks = oracle.stocks; _sortedStocks = oracle.stocks;
_sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol)); _sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol));
} }
void _handleSearchClick(_) {
setState(() {
_isSearching = !_isSearching;
});
}
Node build() { Node build() {
var drawer = new Drawer( var drawer = new Drawer(
animation: _drawerAnimation, animation: _drawerAnimation,
...@@ -78,6 +86,9 @@ class StocksApp extends App { ...@@ -78,6 +86,9 @@ class StocksApp extends App {
] ]
); );
Node title = _isSearching ?
new Input(focused: true) : new Text('I am a stocks app');
var toolbar = new Toolbar( var toolbar = new Toolbar(
children: [ children: [
new Icon(key: 'menu', style: _iconStyle, new Icon(key: 'menu', style: _iconStyle,
...@@ -86,11 +97,12 @@ class StocksApp extends App { ...@@ -86,11 +97,12 @@ class StocksApp extends App {
..events.listen('click', _drawerAnimation.toggle), ..events.listen('click', _drawerAnimation.toggle),
new Container( new Container(
style: _titleStyle, style: _titleStyle,
children: [new Text('I am a stocks app')] children: [title]
), ),
new Icon(key: 'search', style: _iconStyle, new Icon(key: 'search', style: _iconStyle,
size: 24, size: 24,
type: 'action/search_white'), type: 'action/search_white')
..events.listen('click', _handleSearchClick),
new Icon(key: 'more_white', style: _iconStyle, new Icon(key: 'more_white', style: _iconStyle,
size: 24, size: 24,
type: 'navigation/more_vert_white') type: 'navigation/more_vert_white')
......
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