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 'dart:sky' as sky; | 5 import 'dart:sky' as sky; |
6 | 6 |
7 import '../widgets/basic.dart'; | 7 import '../widgets/basic.dart'; |
8 import 'editable_string.dart'; | 8 import 'editable_string.dart'; |
9 import 'editable_text.dart'; | 9 import 'editable_text.dart'; |
10 import 'keyboard.dart'; | 10 import 'keyboard.dart'; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 void _handleTextUpdated() { | 63 void _handleTextUpdated() { |
64 scheduleBuild(); | 64 scheduleBuild(); |
65 if (_value != _editableValue.text) { | 65 if (_value != _editableValue.text) { |
66 _value = _editableValue.text; | 66 _value = _editableValue.text; |
67 if (onChanged != null) | 67 if (onChanged != null) |
68 onChanged(_value); | 68 onChanged(_value); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 UINode build() { | 72 Widget build() { |
73 if (focused && !_isAttachedToKeyboard) { | 73 if (focused && !_isAttachedToKeyboard) { |
74 keyboard.show(_editableValue.stub); | 74 keyboard.show(_editableValue.stub); |
75 _isAttachedToKeyboard = true; | 75 _isAttachedToKeyboard = true; |
76 } | 76 } |
77 | 77 |
78 List<UINode> children = []; | 78 List<Widget> children = []; |
79 | 79 |
80 if (placeholder != null && _value.isEmpty) { | 80 if (placeholder != null && _value.isEmpty) { |
81 children.add(new Container( | 81 children.add(new Container( |
82 // style: _placeholderStyle, | 82 // style: _placeholderStyle, |
83 child: new Text(placeholder) | 83 child: new Text(placeholder) |
84 )); | 84 )); |
85 } | 85 } |
86 | 86 |
87 children.add(new EditableText(value: _editableValue, focused: focused)); | 87 children.add(new EditableText(value: _editableValue, focused: focused)); |
88 | 88 |
89 return new EventListenerNode( | 89 return new EventListenerNode( |
90 // style: _style, | 90 // style: _style, |
91 // inlineStyle: focused ? _focusedInlineStyle : null, | 91 // inlineStyle: focused ? _focusedInlineStyle : null, |
92 new Stack(children), | 92 new Stack(children), |
93 onPointerDown: (sky.Event e) => keyboard.showByRequest() | 93 onPointerDown: (sky.Event e) => keyboard.showByRequest() |
94 ); | 94 ); |
95 } | 95 } |
96 | 96 |
97 void didUnmount() { | 97 void didUnmount() { |
98 if (_isAttachedToKeyboard) | 98 if (_isAttachedToKeyboard) |
99 keyboard.hide(); | 99 keyboard.hide(); |
100 super.didUnmount(); | 100 super.didUnmount(); |
101 } | 101 } |
102 | 102 |
103 } | 103 } |
OLD | NEW |