| 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 '../fn.dart'; | 5 import '../fn.dart'; |
| 6 import '../theme/colors.dart'; | 6 import '../theme/colors.dart'; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'editable_string.dart'; | 8 import 'editable_string.dart'; |
| 9 | 9 |
| 10 class EditableText extends Component { | 10 class EditableText extends Component { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 _cursorTimer = new Timer.periodic( | 49 _cursorTimer = new Timer.periodic( |
| 50 new Duration(milliseconds: 500), _cursorTick); | 50 new Duration(milliseconds: 500), _cursorTick); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void _stopCursorTimer() { | 53 void _stopCursorTimer() { |
| 54 _cursorTimer.cancel(); | 54 _cursorTimer.cancel(); |
| 55 _cursorTimer = null; | 55 _cursorTimer = null; |
| 56 _showCursor = false; | 56 _showCursor = false; |
| 57 } | 57 } |
| 58 | 58 |
| 59 Node build() { | 59 UINode build() { |
| 60 if (focused && _cursorTimer == null) | 60 if (focused && _cursorTimer == null) |
| 61 _startCursorTimer(); | 61 _startCursorTimer(); |
| 62 else if (!focused && _cursorTimer != null) | 62 else if (!focused && _cursorTimer != null) |
| 63 _stopCursorTimer(); | 63 _stopCursorTimer(); |
| 64 | 64 |
| 65 List<Node> children = new List<Node>(); | 65 List<UINode> children = new List<UINode>(); |
| 66 | 66 |
| 67 if (!value.composing.isValid) { | 67 if (!value.composing.isValid) { |
| 68 children.add(new Text(value.text)); | 68 children.add(new Text(value.text)); |
| 69 } else { | 69 } else { |
| 70 String beforeComposing = value.textBefore(value.composing); | 70 String beforeComposing = value.textBefore(value.composing); |
| 71 if (!beforeComposing.isEmpty) | 71 if (!beforeComposing.isEmpty) |
| 72 children.add(new Text(beforeComposing)); | 72 children.add(new Text(beforeComposing)); |
| 73 | 73 |
| 74 String composing = value.textInside(value.composing); | 74 String composing = value.textInside(value.composing); |
| 75 if (!composing.isEmpty) { | 75 if (!composing.isEmpty) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 87 | 87 |
| 88 if (_showCursor) | 88 if (_showCursor) |
| 89 children.add(new Container(key: 'cursor', style: _cusorStyle)); | 89 children.add(new Container(key: 'cursor', style: _cusorStyle)); |
| 90 | 90 |
| 91 return new Container( | 91 return new Container( |
| 92 style: _style, | 92 style: _style, |
| 93 children: children | 93 children: children |
| 94 ); | 94 ); |
| 95 } | 95 } |
| 96 } | 96 } |
| OLD | NEW |