OLD | NEW |
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 '../editing/editable_string.dart'; | 5 import '../editing2/editable_string.dart'; |
6 import '../editing/editable_text.dart'; | 6 import '../editing2/editable_text.dart'; |
7 import '../editing/keyboard.dart'; | 7 import '../editing2/keyboard.dart'; |
8 import '../fn2.dart'; | 8 import '../fn2.dart'; |
9 import '../theme/colors.dart'; | 9 import '../theme2/colors.dart'; |
10 import '../theme/typography.dart' as typography; | 10 import '../theme2/typography.dart' as typography; |
| 11 import '../rendering/flex.dart'; |
11 import 'dart:sky' as sky; | 12 import 'dart:sky' as sky; |
12 | 13 |
13 typedef void ValueChanged(value); | 14 typedef void ValueChanged(value); |
14 | 15 |
15 class Input extends Component { | 16 class Input extends Component { |
16 static final Style _style = new Style(''' | 17 // static final Style _style = new Style(''' |
17 transform: translateX(0); | 18 // transform: translateX(0); |
18 margin: 8px; | 19 // margin: 8px; |
19 padding: 8px; | 20 // padding: 8px; |
20 border-bottom: 1px solid ${Grey[200]}; | 21 // border-bottom: 1px solid ${Grey[200]}; |
21 align-self: center; | 22 // align-self: center; |
22 height: 1.2em; | 23 // height: 1.2em; |
23 white-space: pre; | 24 // white-space: pre; |
24 overflow: hidden;''' | 25 // overflow: hidden;''' |
25 ); | 26 // ); |
26 | 27 |
27 static final Style _placeholderStyle = new Style(''' | 28 // static final Style _placeholderStyle = new Style(''' |
28 top: 8px; | 29 // top: 8px; |
29 left: 8px; | 30 // left: 8px; |
30 position: absolute; | 31 // position: absolute; |
31 ${typography.black.caption};''' | 32 // ${typography.black.caption};''' |
32 ); | 33 // ); |
33 | 34 |
34 static final String _focusedInlineStyle = ''' | 35 // static final String _focusedInlineStyle = ''' |
35 padding: 7px; | 36 // padding: 7px; |
36 border-bottom: 2px solid ${Blue[500]};'''; | 37 // border-bottom: 2px solid ${Blue[500]};'''; |
37 | 38 |
38 ValueChanged onChanged; | 39 ValueChanged onChanged; |
39 String placeholder; | 40 String placeholder; |
40 bool focused = false; | 41 bool focused = false; |
41 | 42 |
42 String _value = ''; | 43 String _value = ''; |
43 bool _isAttachedToKeyboard = false; | 44 bool _isAttachedToKeyboard = false; |
44 EditableString _editableValue; | 45 EditableString _editableValue; |
45 | 46 |
46 Input({Object key, | 47 Input({Object key, |
(...skipping 21 matching lines...) Expand all Loading... |
68 UINode build() { | 69 UINode build() { |
69 if (focused && !_isAttachedToKeyboard) { | 70 if (focused && !_isAttachedToKeyboard) { |
70 keyboard.show(_editableValue.stub); | 71 keyboard.show(_editableValue.stub); |
71 _isAttachedToKeyboard = true; | 72 _isAttachedToKeyboard = true; |
72 } | 73 } |
73 | 74 |
74 List<UINode> children = []; | 75 List<UINode> children = []; |
75 | 76 |
76 if (placeholder != null && _value.isEmpty) { | 77 if (placeholder != null && _value.isEmpty) { |
77 children.add(new Container( | 78 children.add(new Container( |
78 style: _placeholderStyle, | 79 // style: _placeholderStyle, |
79 children: [new Text(placeholder)] | 80 child: new Text(placeholder) |
80 )); | 81 )); |
81 } | 82 } |
82 | 83 |
83 children.add(new EditableText(value: _editableValue, focused: focused)); | 84 children.add(new EditableText(value: _editableValue, focused: focused)); |
84 | 85 |
85 return new EventListenerNode( | 86 return new EventListenerNode( |
86 new FlexContainer( | 87 new FlexContainer( |
87 direction: FlexDirection.vertical, | 88 direction: FlexDirection.vertical, |
88 style: _style, | 89 // style: _style, |
89 inlineStyle: focused ? _focusedInlineStyle : null, | 90 // inlineStyle: focused ? _focusedInlineStyle : null, |
90 children: children | 91 children: children |
91 ), | 92 ), |
92 onPointerDown: (sky.Event e) => keyboard.showByRequest() | 93 onPointerDown: (sky.Event e) => keyboard.showByRequest() |
93 ); | 94 ); |
94 } | 95 } |
95 } | 96 } |
OLD | NEW |