| 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 '../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 | 17 |
| 18 Input({Object key, | 18 Input({Object key, |
| 19 this.placeholder, | 19 this.placeholder, |
| 20 this.onChanged, | 20 this.onChanged, |
| 21 this.focused}) | 21 this.focused}) |
| 22 : super(key: key, stateful: true) { | 22 : super(key: key, stateful: true) { |
| 23 _editableValue = new EditableString(text: _value, | 23 _editableValue = new EditableString( |
| 24 onUpdated: _handleTextUpdated); | 24 text: _value, |
| 25 onDidUnmount(() { | 25 onUpdated: _handleTextUpdated |
| 26 if (_isAttachedToKeyboard) | 26 ); |
| 27 keyboard.hide(); | |
| 28 }); | |
| 29 } | 27 } |
| 30 | 28 |
| 31 // static final Style _style = new Style(''' | 29 // static final Style _style = new Style(''' |
| 32 // transform: translateX(0); | 30 // transform: translateX(0); |
| 33 // margin: 8px; | 31 // margin: 8px; |
| 34 // padding: 8px; | 32 // padding: 8px; |
| 35 // border-bottom: 1px solid ${Grey[200]}; | 33 // border-bottom: 1px solid ${Grey[200]}; |
| 36 // align-self: center; | 34 // align-self: center; |
| 37 // height: 1.2em; | 35 // height: 1.2em; |
| 38 // white-space: pre; | 36 // white-space: pre; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 new FlexContainer( | 93 new FlexContainer( |
| 96 direction: FlexDirection.vertical, | 94 direction: FlexDirection.vertical, |
| 97 // style: _style, | 95 // style: _style, |
| 98 // inlineStyle: focused ? _focusedInlineStyle : null, | 96 // inlineStyle: focused ? _focusedInlineStyle : null, |
| 99 children: children | 97 children: children |
| 100 ), | 98 ), |
| 101 onPointerDown: (sky.Event e) => keyboard.showByRequest() | 99 onPointerDown: (sky.Event e) => keyboard.showByRequest() |
| 102 ); | 100 ); |
| 103 } | 101 } |
| 104 | 102 |
| 103 void didUnmount() { |
| 104 if (_isAttachedToKeyboard) |
| 105 keyboard.hide(); |
| 106 super.didUnmount(); |
| 107 } |
| 108 |
| 105 } | 109 } |
| OLD | NEW |