| 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:async'; | 5 import 'dart:async'; |
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
| 7 | 7 |
| 8 import '../painting/text_style.dart'; | 8 import '../painting/text_style.dart'; |
| 9 import '../rendering/object.dart'; | 9 import '../rendering/object.dart'; |
| 10 import '../widgets/basic.dart'; | 10 import '../widgets/basic.dart'; |
| 11 import 'editable_string.dart'; | 11 import 'editable_string.dart'; |
| 12 | 12 |
| 13 const _kCursorBlinkPeriod = 500; // milliseconds | 13 const _kCursorBlinkPeriod = 500; // milliseconds |
| 14 const _kCursorGap = 1.0; | 14 const _kCursorGap = 1.0; |
| 15 const _kCursorHeightOffset = 2.0; | 15 const _kCursorHeightOffset = 2.0; |
| 16 const _kCursorWidth = 1.0; | 16 const _kCursorWidth = 1.0; |
| 17 | 17 |
| 18 class EditableText extends Component { | 18 class EditableText extends StatefulComponent { |
| 19 | 19 |
| 20 EditableText({ | 20 EditableText({ |
| 21 String key, | 21 String key, |
| 22 this.value, | 22 this.value, |
| 23 this.focused: false, | 23 this.focused: false, |
| 24 this.style, | 24 this.style, |
| 25 this.cursorColor}) : super(key: key, stateful: true); | 25 this.cursorColor}) : super(key: key); |
| 26 | 26 |
| 27 EditableString value; | 27 EditableString value; |
| 28 bool focused; | 28 bool focused; |
| 29 TextStyle style; | 29 TextStyle style; |
| 30 Color cursorColor; | 30 Color cursorColor; |
| 31 | 31 |
| 32 void syncFields(EditableText source) { | 32 void syncFields(EditableText source) { |
| 33 value = source.value; | 33 value = source.value; |
| 34 focused = source.focused; | 34 focused = source.focused; |
| 35 style = source.style; | 35 style = source.style; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 Widget cursor = new Container( | 101 Widget cursor = new Container( |
| 102 height: style.fontSize, | 102 height: style.fontSize, |
| 103 width: _kCursorGap + _kCursorWidth, | 103 width: _kCursorGap + _kCursorWidth, |
| 104 child: new CustomPaint(callback: _paintCursor, token: _showCursor) | 104 child: new CustomPaint(callback: _paintCursor, token: _showCursor) |
| 105 ); | 105 ); |
| 106 | 106 |
| 107 return new Flex([text, cursor]); | 107 return new Flex([text, cursor]); |
| 108 } | 108 } |
| 109 } | 109 } |
| OLD | NEW |