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 '../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'; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 if (placeholder != null && _value.isEmpty) { | 62 if (placeholder != null && _value.isEmpty) { |
63 Widget child = new Opacity( | 63 Widget child = new Opacity( |
64 key: "placeholder", | 64 key: "placeholder", |
65 child: new Text(placeholder, style: textStyle), | 65 child: new Text(placeholder, style: textStyle), |
66 opacity: _kHintOpacity | 66 opacity: _kHintOpacity |
67 ); | 67 ); |
68 textChildren.add(child); | 68 textChildren.add(child); |
69 } | 69 } |
70 | 70 |
| 71 ThemeData themeData = Theme.of(this); |
| 72 Color focusHighlightColor = themeData.accentColor; |
| 73 Color cursorColor = themeData.accentColor; |
| 74 if (themeData.primarySwatch != null) { |
| 75 cursorColor = Theme.of(this).primarySwatch[200]; |
| 76 focusHighlightColor = focused ? themeData.primarySwatch[400] : themeData.p
rimarySwatch[200]; |
| 77 } |
| 78 |
71 textChildren.add(new EditableText( | 79 textChildren.add(new EditableText( |
72 value: _editableValue, | 80 value: _editableValue, |
73 focused: focused, | 81 focused: focused, |
74 style: textStyle, | 82 style: textStyle, |
75 cursorColor: Theme.of(this).primary[200] | 83 cursorColor: cursorColor |
76 )); | 84 )); |
77 | 85 |
78 Border focusHighlight = new Border(bottom: new BorderSide( | 86 Border focusHighlight = new Border(bottom: new BorderSide( |
79 color: focused ? Theme.of(this).primary[400] : Theme.of(this).primary[200]
, | 87 color: focusHighlightColor, |
80 width: focused ? 2.0 : 1.0 | 88 width: focused ? 2.0 : 1.0 |
81 )); | 89 )); |
82 | 90 |
83 Container input = new Container( | 91 Container input = new Container( |
84 child: new Stack(textChildren), | 92 child: new Stack(textChildren), |
85 padding: _kTextfieldPadding, | 93 padding: _kTextfieldPadding, |
86 decoration: new BoxDecoration(border: focusHighlight) | 94 decoration: new BoxDecoration(border: focusHighlight) |
87 ); | 95 ); |
88 | 96 |
89 return new Listener( | 97 return new Listener( |
90 child: input, | 98 child: input, |
91 onPointerDown: (_) => keyboard.showByRequest() | 99 onPointerDown: (_) => keyboard.showByRequest() |
92 ); | 100 ); |
93 } | 101 } |
94 | 102 |
95 void didUnmount() { | 103 void didUnmount() { |
96 if (_isAttachedToKeyboard) | 104 if (_isAttachedToKeyboard) |
97 keyboard.hide(); | 105 keyboard.hide(); |
98 super.didUnmount(); | 106 super.didUnmount(); |
99 } | 107 } |
100 } | 108 } |
OLD | NEW |