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

Side by Side Diff: sky/sdk/lib/editing/input.dart

Issue 1233703003: add initState, rename animated_container (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: remove print statement Created 5 years, 5 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
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 '../painting/text_style.dart'; 5 import '../painting/text_style.dart';
6 import '../widgets/basic.dart'; 6 import '../widgets/basic.dart';
7 import '../widgets/theme.dart'; 7 import '../widgets/theme.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';
11 11
12 typedef void ValueChanged(value); 12 typedef void ValueChanged(value);
13 13
14 const double _kHintOpacity = 0.26; 14 const double _kHintOpacity = 0.26;
15 const EdgeDims _kTextfieldPadding = const EdgeDims.symmetric(vertical: 8.0); 15 const EdgeDims _kTextfieldPadding = const EdgeDims.symmetric(vertical: 8.0);
16 16
17 class Input extends StatefulComponent { 17 class Input extends StatefulComponent {
18 18
19 Input({String key, 19 Input({String key,
20 this.placeholder, 20 this.placeholder,
21 this.onChanged, 21 this.onChanged,
22 this.focused}) 22 this.focused})
23 : super(key: key) { 23 : super(key: key);
24 _editableValue = new EditableString(
25 text: _value,
26 onUpdated: _handleTextUpdated
27 );
28 }
29 24
30 String placeholder; 25 String placeholder;
31 ValueChanged onChanged; 26 ValueChanged onChanged;
32 bool focused = false; 27 bool focused = false;
33 28
29 void initState() {
30 _editableValue = new EditableString(
31 text: _value,
32 onUpdated: _handleTextUpdated
33 );
34 super.initState();
35 }
36
34 void syncFields(Input source) { 37 void syncFields(Input source) {
35 placeholder = source.placeholder; 38 placeholder = source.placeholder;
36 onChanged = source.onChanged; 39 onChanged = source.onChanged;
37 focused = source.focused; 40 focused = source.focused;
38 } 41 }
39 42
40 String _value = ''; 43 String _value = '';
41 bool _isAttachedToKeyboard = false; 44 bool _isAttachedToKeyboard = false;
42 EditableString _editableValue; 45 EditableString _editableValue;
43 46
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 onPointerDown: (_) => keyboard.showByRequest() 102 onPointerDown: (_) => keyboard.showByRequest()
100 ); 103 );
101 } 104 }
102 105
103 void didUnmount() { 106 void didUnmount() {
104 if (_isAttachedToKeyboard) 107 if (_isAttachedToKeyboard)
105 keyboard.hide(); 108 keyboard.hide();
106 super.didUnmount(); 109 super.didUnmount();
107 } 110 }
108 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698