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

Side by Side Diff: sky/sdk/lib/framework/components2/popup_menu.dart

Issue 1158813004: Style guide says enum values should be lowerCamelCase. (Closed) Base URL: https://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 'animated_component.dart'; 5 import 'animated_component.dart';
6 import '../animation/animated_value.dart'; 6 import '../animation/animated_value.dart';
7 import '../fn2.dart'; 7 import '../fn2.dart';
8 import '../theme/colors.dart'; 8 import '../theme/colors.dart';
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:math' as math; 10 import 'dart:math' as math;
11 import 'material.dart'; 11 import 'material.dart';
12 import 'popup_menu_item.dart'; 12 import 'popup_menu_item.dart';
13 13
14 const double _kMenuOpenDuration = 300.0; 14 const double _kMenuOpenDuration = 300.0;
15 const double _kMenuCloseDuration = 200.0; 15 const double _kMenuCloseDuration = 200.0;
16 const double _kMenuCloseDelay = 100.0; 16 const double _kMenuCloseDelay = 100.0;
17 17
18 enum MenuState { Hidden, Opening, Open, Closing } 18 enum MenuState { hidden, opening, open, closing }
19 19
20 class PopupMenuController { 20 class PopupMenuController {
21 AnimatedValue position = new AnimatedValue(0.0); 21 AnimatedValue position = new AnimatedValue(0.0);
22 MenuState _state = MenuState.Hidden; 22 MenuState _state = MenuState.hidden;
23 MenuState get state => _state; 23 MenuState get state => _state;
24 24
25 bool get canReact => (_state == MenuState.Opening) || (_state == MenuState.Ope n); 25 bool get canReact => (_state == MenuState.opening) || (_state == MenuState.ope n);
26 26
27 open() async { 27 open() async {
28 if (_state != MenuState.Hidden) 28 if (_state != MenuState.hidden)
29 return; 29 return;
30 _state = MenuState.Opening; 30 _state = MenuState.opening;
31 if (await position.animateTo(1.0, _kMenuOpenDuration) == 1.0) 31 if (await position.animateTo(1.0, _kMenuOpenDuration) == 1.0)
32 _state = MenuState.Open; 32 _state = MenuState.open;
33 } 33 }
34 34
35 Future _closeState; 35 Future _closeState;
36 close() async { 36 close() async {
37 var result = new Completer(); 37 var result = new Completer();
38 _closeState = result.future; 38 _closeState = result.future;
39 if ((_state == MenuState.Opening) || (_state == MenuState.Open)) { 39 if ((_state == MenuState.opening) || (_state == MenuState.open)) {
40 _state = MenuState.Closing; 40 _state = MenuState.closing;
41 await position.animateTo(0.0, _kMenuCloseDuration, initialDelay: _kMenuClo seDelay); 41 await position.animateTo(0.0, _kMenuCloseDuration, initialDelay: _kMenuClo seDelay);
42 _state = MenuState.Hidden; 42 _state = MenuState.hidden;
43 _closeState = null; 43 _closeState = null;
44 result.complete(); 44 result.complete();
45 return result.future; 45 return result.future;
46 } 46 }
47 assert(_closeState != null); 47 assert(_closeState != null);
48 return _closeState; 48 return _closeState;
49 } 49 }
50 } 50 }
51 51
52 class PopupMenu extends AnimatedComponent { 52 class PopupMenu extends AnimatedComponent {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 return new Material( 107 return new Material(
108 content: new Container( 108 content: new Container(
109 style: _style, 109 style: _style,
110 inlineStyle: _inlineStyle(), 110 inlineStyle: _inlineStyle(),
111 children: children 111 children: children
112 ), 112 ),
113 level: level); 113 level: level);
114 } 114 }
115 } 115 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/menu_item.dart ('k') | sky/sdk/lib/framework/components2/scaffold.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698