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

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

Issue 1172173002: Clean up a bunch of our Dart code. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: upstream merge 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 '../editing2/editable_string.dart'; 5 import '../editing2/editable_string.dart';
6 import '../editing2/editable_text.dart'; 6 import '../editing2/editable_text.dart';
7 import '../editing2/keyboard.dart'; 7 import '../editing2/keyboard.dart';
8 import '../fn2.dart'; 8 import '../fn2.dart';
9 import '../theme2/colors.dart'; 9 import '../theme2/colors.dart';
10 import '../theme2/typography.dart' as typography; 10 import '../theme2/typography.dart' as typography;
11 import '../rendering/flex.dart'; 11 import '../rendering/flex.dart';
12 import 'dart:sky' as sky; 12 import 'dart:sky' as sky;
13 13
14 typedef void ValueChanged(value); 14 typedef void ValueChanged(value);
15 15
16 class Input extends Component { 16 class Input extends Component {
17
18 Input({Object key,
19 this.placeholder,
20 this.onChanged,
21 this.focused})
22 : super(key: key, stateful: true) {
23 _editableValue = new EditableString(text: _value,
24 onUpdated: _handleTextUpdated);
25 onDidUnmount(() {
26 if (_isAttachedToKeyboard)
27 keyboard.hide();
28 });
29 }
30
17 // static final Style _style = new Style(''' 31 // static final Style _style = new Style('''
18 // transform: translateX(0); 32 // transform: translateX(0);
19 // margin: 8px; 33 // margin: 8px;
20 // padding: 8px; 34 // padding: 8px;
21 // border-bottom: 1px solid ${Grey[200]}; 35 // border-bottom: 1px solid ${Grey[200]};
22 // align-self: center; 36 // align-self: center;
23 // height: 1.2em; 37 // height: 1.2em;
24 // white-space: pre; 38 // white-space: pre;
25 // overflow: hidden;''' 39 // overflow: hidden;'''
26 // ); 40 // );
(...skipping 10 matching lines...) Expand all
37 // border-bottom: 2px solid ${Blue[500]};'''; 51 // border-bottom: 2px solid ${Blue[500]};''';
38 52
39 ValueChanged onChanged; 53 ValueChanged onChanged;
40 String placeholder; 54 String placeholder;
41 bool focused = false; 55 bool focused = false;
42 56
43 String _value = ''; 57 String _value = '';
44 bool _isAttachedToKeyboard = false; 58 bool _isAttachedToKeyboard = false;
45 EditableString _editableValue; 59 EditableString _editableValue;
46 60
47 Input({Object key,
48 this.placeholder,
49 this.onChanged,
50 this.focused})
51 : super(key: key, stateful: true) {
52 _editableValue = new EditableString(text: _value,
53 onUpdated: _handleTextUpdated);
54 onDidUnmount(() {
55 if (_isAttachedToKeyboard)
56 keyboard.hide();
57 });
58 }
59
60 void _handleTextUpdated() { 61 void _handleTextUpdated() {
61 scheduleBuild(); 62 scheduleBuild();
62 if (_value != _editableValue.text) { 63 if (_value != _editableValue.text) {
63 _value = _editableValue.text; 64 _value = _editableValue.text;
64 if (onChanged != null) 65 if (onChanged != null)
65 onChanged(_value); 66 onChanged(_value);
66 } 67 }
67 } 68 }
68 69
69 UINode build() { 70 UINode build() {
(...skipping 16 matching lines...) Expand all
86 return new EventListenerNode( 87 return new EventListenerNode(
87 new FlexContainer( 88 new FlexContainer(
88 direction: FlexDirection.vertical, 89 direction: FlexDirection.vertical,
89 // style: _style, 90 // style: _style,
90 // inlineStyle: focused ? _focusedInlineStyle : null, 91 // inlineStyle: focused ? _focusedInlineStyle : null,
91 children: children 92 children: children
92 ), 93 ),
93 onPointerDown: (sky.Event e) => keyboard.showByRequest() 94 onPointerDown: (sky.Event e) => keyboard.showByRequest()
94 ); 95 );
95 } 96 }
97
96 } 98 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/ink_well.dart ('k') | sky/sdk/lib/framework/components2/material.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698