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

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

Issue 1182053012: Rename editing2/ and theme2/ to editing/ and theme/. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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/editing2/editable_text.dart ('k') | sky/sdk/lib/editing2/keyboard.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 import '../widgets/basic.dart';
6 import 'editable_string.dart';
7 import 'editable_text.dart';
8 import 'keyboard.dart';
9
10 typedef void ValueChanged(value);
11
12 class Input extends Component {
13
14 Input({String key,
15 this.placeholder,
16 this.onChanged,
17 this.focused})
18 : super(key: key, stateful: true) {
19 _editableValue = new EditableString(
20 text: _value,
21 onUpdated: _handleTextUpdated
22 );
23 }
24
25 // static final Style _style = new Style('''
26 // transform: translateX(0);
27 // margin: 8px;
28 // padding: 8px;
29 // border-bottom: 1px solid ${Grey[200]};
30 // align-self: center;
31 // height: 1.2em;
32 // white-space: pre;
33 // overflow: hidden;'''
34 // );
35
36 // static final Style _placeholderStyle = new Style('''
37 // top: 8px;
38 // left: 8px;
39 // position: absolute;
40 // ${typography.black.caption};'''
41 // );
42
43 // static final String _focusedInlineStyle = '''
44 // padding: 7px;
45 // border-bottom: 2px solid ${Blue[500]};''';
46
47 String placeholder;
48 ValueChanged onChanged;
49 bool focused = false;
50
51 void syncFields(Input source) {
52 placeholder = source.placeholder;
53 onChanged = source.onChanged;
54 focused = source.focused;
55 }
56
57 String _value = '';
58 bool _isAttachedToKeyboard = false;
59 EditableString _editableValue;
60
61 void _handleTextUpdated() {
62 scheduleBuild();
63 if (_value != _editableValue.text) {
64 _value = _editableValue.text;
65 if (onChanged != null)
66 onChanged(_value);
67 }
68 }
69
70 Widget build() {
71 if (focused && !_isAttachedToKeyboard) {
72 keyboard.show(_editableValue.stub);
73 _isAttachedToKeyboard = true;
74 }
75
76 List<Widget> children = [];
77
78 if (placeholder != null && _value.isEmpty) {
79 children.add(new Container(
80 // style: _placeholderStyle,
81 child: new Text(placeholder)
82 ));
83 }
84
85 children.add(new EditableText(value: _editableValue, focused: focused));
86
87 return new Listener(
88 // style: _style,
89 // inlineStyle: focused ? _focusedInlineStyle : null,
90 child: new Stack(children),
91 onPointerDown: (_) => keyboard.showByRequest()
92 );
93 }
94
95 void didUnmount() {
96 if (_isAttachedToKeyboard)
97 keyboard.hide();
98 super.didUnmount();
99 }
100
101 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/editing2/editable_text.dart ('k') | sky/sdk/lib/editing2/keyboard.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698