Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: sky/examples/stocks2/lib/stock_home.dart

Issue 1188993003: Use semantic names for callbacks instead of onGestureTap (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'package:sky/editing2/input.dart'; 5 import 'package:sky/editing2/input.dart';
6 import 'package:sky/theme2/colors.dart' as colors; 6 import 'package:sky/theme2/colors.dart' as colors;
7 import 'package:sky/theme2/typography.dart' as typography; 7 import 'package:sky/theme2/typography.dart' as typography;
8 import 'package:sky/widgets/basic.dart'; 8 import 'package:sky/widgets/basic.dart';
9 import 'package:sky/widgets/drawer.dart'; 9 import 'package:sky/widgets/drawer.dart';
10 import 'package:sky/widgets/drawer_header.dart'; 10 import 'package:sky/widgets/drawer_header.dart';
(...skipping 28 matching lines...) Expand all
39 }); 39 });
40 _drawerController = new DrawerController(_handleDrawerStatusChanged); 40 _drawerController = new DrawerController(_handleDrawerStatusChanged);
41 } 41 }
42 42
43 List<Stock> _stocks = []; 43 List<Stock> _stocks = [];
44 Navigator _navigator; 44 Navigator _navigator;
45 45
46 bool _isSearching = false; 46 bool _isSearching = false;
47 String _searchQuery; 47 String _searchQuery;
48 48
49 void _handleSearchBegin(_) { 49 void _handleSearchBegin() {
50 setState(() { 50 setState(() {
51 _isSearching = true; 51 _isSearching = true;
52 }); 52 });
53 } 53 }
54 54
55 void _handleSearchEnd(_) { 55 void _handleSearchEnd() {
56 setState(() { 56 setState(() {
57 _isSearching = false; 57 _isSearching = false;
58 _searchQuery = null; 58 _searchQuery = null;
59 }); 59 });
60 } 60 }
61 61
62 void _handleSearchQueryChanged(String query) { 62 void _handleSearchQueryChanged(String query) {
63 setState(() { 63 setState(() {
64 _searchQuery = query; 64 _searchQuery = query;
65 }); 65 });
66 } 66 }
67 67
68 DrawerController _drawerController; 68 DrawerController _drawerController;
69 bool _drawerShowing = false; 69 bool _drawerShowing = false;
70 70
71 void _handleDrawerStatusChanged(bool showing) { 71 void _handleDrawerStatusChanged(bool showing) {
72 setState(() { 72 setState(() {
73 _drawerShowing = showing; 73 _drawerShowing = showing;
74 }); 74 });
75 } 75 }
76 76
77 PopupMenuController _menuController; 77 PopupMenuController _menuController;
78 78
79 void _handleMenuShow(_) { 79 void _handleMenuShow() {
80 setState(() { 80 setState(() {
81 _menuController = new PopupMenuController(); 81 _menuController = new PopupMenuController();
82 _menuController.open(); 82 _menuController.open();
83 }); 83 });
84 } 84 }
85 85
86 void _handleMenuHide(_) { 86 void _handleMenuHide() {
87 setState(() { 87 setState(() {
88 _menuController.close().then((_) { 88 _menuController.close().then((_) {
89 setState(() { 89 setState(() {
90 _menuController = null; 90 _menuController = null;
91 }); 91 });
92 }); 92 });
93 }); 93 });
94 } 94 }
95 95
96 bool _autorefresh = false; 96 bool _autorefresh = false;
(...skipping 21 matching lines...) Expand all
118 icon: 'action/assessment', 118 icon: 'action/assessment',
119 children: [new Text('Stock List')]), 119 children: [new Text('Stock List')]),
120 new MenuItem( 120 new MenuItem(
121 key: 'Account Balance', 121 key: 'Account Balance',
122 icon: 'action/account_balance', 122 icon: 'action/account_balance',
123 children: [new Text('Account Balance')]), 123 children: [new Text('Account Balance')]),
124 new MenuDivider(key: 'div1'), 124 new MenuDivider(key: 'div1'),
125 new MenuItem( 125 new MenuItem(
126 key: 'Optimistic Menu Item', 126 key: 'Optimistic Menu Item',
127 icon: 'action/thumb_up', 127 icon: 'action/thumb_up',
128 onGestureTap: (event) => _handleStockModeChange(StockMode.optimistic), 128 onPressed: () => _handleStockModeChange(StockMode.optimistic),
129 children: [ 129 children: [
130 new Flexible(child: new Text('Optimistic')), 130 new Flexible(child: new Text('Optimistic')),
131 new Radio(key: 'optimistic-radio', value: StockMode.optimistic, grou pValue: _stockMode, onChanged: _handleStockModeChange) 131 new Radio(key: 'optimistic-radio', value: StockMode.optimistic, grou pValue: _stockMode, onChanged: _handleStockModeChange)
132 ]), 132 ]),
133 new MenuItem( 133 new MenuItem(
134 key: 'Pessimistic Menu Item', 134 key: 'Pessimistic Menu Item',
135 icon: 'action/thumb_down', 135 icon: 'action/thumb_down',
136 onGestureTap: (event) => _handleStockModeChange(StockMode.pessimistic) , 136 onPressed: () => _handleStockModeChange(StockMode.pessimistic),
137 children: [ 137 children: [
138 new Flexible(child: new Text('Pessimistic')), 138 new Flexible(child: new Text('Pessimistic')),
139 new Radio(key: 'pessimistic-radio', value: StockMode.pessimistic, gr oupValue: _stockMode, onChanged: _handleStockModeChange) 139 new Radio(key: 'pessimistic-radio', value: StockMode.pessimistic, gr oupValue: _stockMode, onChanged: _handleStockModeChange)
140 ]), 140 ]),
141 new MenuDivider(key: 'div2'), 141 new MenuDivider(key: 'div2'),
142 new MenuItem( 142 new MenuItem(
143 key: 'Settings', 143 key: 'Settings',
144 icon: 'action/settings', 144 icon: 'action/settings',
145 onGestureTap: (event) => _navigator.pushNamed('/settings'), 145 onPressed: () => _navigator.pushNamed('/settings'),
146 children: [new Text('Settings')]), 146 children: [new Text('Settings')]),
147 new MenuItem( 147 new MenuItem(
148 key: 'Help & Feedback', 148 key: 'Help & Feedback',
149 icon: 'action/help', 149 icon: 'action/help',
150 children: [new Text('Help & Feedback')]) 150 children: [new Text('Help & Feedback')])
151 ] 151 ]
152 ); 152 );
153 } 153 }
154 154
155 Widget buildToolBar() { 155 Widget buildToolBar() {
156 return new ToolBar( 156 return new ToolBar(
157 left: new IconButton( 157 left: new IconButton(
158 icon: 'navigation/menu_white', 158 icon: 'navigation/menu_white',
159 onGestureTap: (_) => _drawerController.toggle()), 159 onPressed: _drawerController.toggle),
160 center: new Text('Stocks', style: typography.white.title), 160 center: new Text('Stocks', style: typography.white.title),
161 right: [ 161 right: [
162 new IconButton( 162 new IconButton(
163 icon: 'action/search_white', 163 icon: 'action/search_white',
164 onGestureTap: _handleSearchBegin), 164 onPressed: _handleSearchBegin),
165 new IconButton( 165 new IconButton(
166 icon: 'navigation/more_vert_white', 166 icon: 'navigation/more_vert_white',
167 onGestureTap: _handleMenuShow) 167 onPressed: _handleMenuShow)
168 ], 168 ],
169 backgroundColor: colors.Purple[500] 169 backgroundColor: colors.Purple[500]
170 ); 170 );
171 } 171 }
172 172
173 // TODO(abarth): Should we factor this into a SearchBar in the framework? 173 // TODO(abarth): Should we factor this into a SearchBar in the framework?
174 Widget buildSearchBar() { 174 Widget buildSearchBar() {
175 return new ToolBar( 175 return new ToolBar(
176 left: new IconButton( 176 left: new IconButton(
177 icon: 'navigation/arrow_back_grey600', 177 icon: 'navigation/arrow_back_grey600',
178 onGestureTap: _handleSearchEnd), 178 onPressed: _handleSearchEnd),
179 center: new Input( 179 center: new Input(
180 focused: true, 180 focused: true,
181 placeholder: 'Search stocks', 181 placeholder: 'Search stocks',
182 onChanged: _handleSearchQueryChanged), 182 onChanged: _handleSearchQueryChanged),
183 backgroundColor: colors.Grey[50] 183 backgroundColor: colors.Grey[50]
184 ); 184 );
185 } 185 }
186 186
187 void addMenuToOverlays(List<Widget> overlays) { 187 void addMenuToOverlays(List<Widget> overlays) {
188 if (_menuController == null) 188 if (_menuController == null)
(...skipping 15 matching lines...) Expand all
204 floatingActionButton: new FloatingActionButton( 204 floatingActionButton: new FloatingActionButton(
205 child: new Icon(type: 'content/add_white', size: 24) 205 child: new Icon(type: 'content/add_white', size: 24)
206 ), 206 ),
207 drawer: _drawerShowing ? buildDrawer() : null 207 drawer: _drawerShowing ? buildDrawer() : null
208 ), 208 ),
209 ]; 209 ];
210 addMenuToOverlays(overlays); 210 addMenuToOverlays(overlays);
211 return new Stack(overlays); 211 return new Stack(overlays);
212 } 212 }
213 } 213 }
OLDNEW
« no previous file with comments | « no previous file | sky/examples/stocks2/lib/stock_settings.dart » ('j') | sky/sdk/lib/widgets/floating_action_button.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698