Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Side by Side Diff: sky/sdk/lib/framework/editing2/editable_text.dart

Issue 1175753003: Kill onDidMount()/onDidUnmount() in favour of just overriding the relevant methods. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: git pull Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/framework/components2/scrollable.dart ('k') | sky/sdk/lib/framework/fn2.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 '../fn2.dart'; 5 import '../fn2.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 {
11 11
12 EditableText({Object key, this.value, this.focused})
13 : super(key: key, stateful: true);
14
12 // static final Style _cursorStyle = new Style(''' 15 // static final Style _cursorStyle = new Style('''
13 // width: 2px; 16 // width: 2px;
14 // height: 1.2em; 17 // height: 1.2em;
15 // vertical-align: top; 18 // vertical-align: top;
16 // background-color: ${Blue[500]};''' 19 // background-color: ${Blue[500]};'''
17 // ); 20 // );
18 21
19 // static final Style _composingStyle = new Style(''' 22 // static final Style _composingStyle = new Style('''
20 // text-decoration: underline;''' 23 // text-decoration: underline;'''
21 // ); 24 // );
22 25
23 EditableString value; 26 EditableString value;
24 bool focused; 27 bool focused;
28
29 void syncFields(EditableText source) {
30 value = source.value;
31 focused = source.focused;
32 }
33
25 Timer _cursorTimer; 34 Timer _cursorTimer;
26 bool _showCursor = false; 35 bool _showCursor = false;
27 36
28 EditableText({Object key, this.value, this.focused})
29 : super(key: key, stateful: true) {
30 onDidUnmount(() {
31 if (_cursorTimer != null)
32 _stopCursorTimer();
33 });
34 }
35
36 void _cursorTick(Timer timer) { 37 void _cursorTick(Timer timer) {
37 setState(() { 38 setState(() {
38 _showCursor = !_showCursor; 39 _showCursor = !_showCursor;
39 }); 40 });
40 } 41 }
41 42
42 void _startCursorTimer() { 43 void _startCursorTimer() {
43 _showCursor = true; 44 _showCursor = true;
44 _cursorTimer = new Timer.periodic( 45 _cursorTimer = new Timer.periodic(
45 new Duration(milliseconds: 500), _cursorTick); 46 new Duration(milliseconds: 500), _cursorTick);
46 } 47 }
47 48
49 void didUnmount() {
50 if (_cursorTimer != null)
51 _stopCursorTimer();
52 }
abarth-chromium 2015/06/10 20:27:17 super.didUnmount()
53
48 void _stopCursorTimer() { 54 void _stopCursorTimer() {
49 _cursorTimer.cancel(); 55 _cursorTimer.cancel();
50 _cursorTimer = null; 56 _cursorTimer = null;
51 _showCursor = false; 57 _showCursor = false;
52 } 58 }
53 59
54 UINode build() { 60 UINode build() {
55 if (focused && _cursorTimer == null) 61 if (focused && _cursorTimer == null)
56 _startCursorTimer(); 62 _startCursorTimer();
57 else if (!focused && _cursorTimer != null) 63 else if (!focused && _cursorTimer != null)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // children.add(new Container( 96 // children.add(new Container(
91 // key: 'cursor', 97 // key: 'cursor',
92 // // style: _cursorStyle 98 // // style: _cursorStyle
93 // )); 99 // ));
94 100
95 return new Paragraph( 101 return new Paragraph(
96 text: hack 102 text: hack
97 ); 103 );
98 } 104 }
99 } 105 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/components2/scrollable.dart ('k') | sky/sdk/lib/framework/fn2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698