| 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 'package:sky/editing/editable_string.dart'; |
| 6 import '../widgets/basic.dart'; | 6 import 'package:sky/editing/editable_text.dart'; |
| 7 import '../widgets/theme.dart'; | 7 import 'package:sky/mojo/keyboard.dart'; |
| 8 import 'editable_string.dart'; | 8 import 'package:sky/painting/text_style.dart'; |
| 9 import 'editable_text.dart'; | 9 import 'package:sky/widgets/basic.dart'; |
| 10 import 'keyboard.dart'; | 10 import 'package:sky/widgets/theme.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, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 ThemeData themeData = Theme.of(this); | 74 ThemeData themeData = Theme.of(this); |
| 75 Color focusHighlightColor = themeData.accentColor; | 75 Color focusHighlightColor = themeData.accentColor; |
| 76 Color cursorColor = themeData.accentColor; | 76 Color cursorColor = themeData.accentColor; |
| 77 if (themeData.primarySwatch != null) { | 77 if (themeData.primarySwatch != null) { |
| 78 cursorColor = Theme.of(this).primarySwatch[200]; | 78 cursorColor = Theme.of(this).primarySwatch[200]; |
| 79 focusHighlightColor = focused ? themeData.primarySwatch[400] : themeData.p
rimarySwatch[200]; | 79 focusHighlightColor = focused ? themeData.primarySwatch[400] : themeData.p
rimarySwatch[200]; |
| 80 } | 80 } |
| 81 | 81 |
| 82 textChildren.add(new EditableText( | 82 textChildren.add(new EditableText( |
| 83 value: _editableValue, | 83 value: _editableValue, |
| 84 focused: focused, | 84 focused: focused, |
| 85 style: textStyle, | 85 style: textStyle, |
| 86 cursorColor: cursorColor | 86 cursorColor: cursorColor |
| 87 )); | 87 )); |
| 88 | 88 |
| 89 Border focusHighlight = new Border(bottom: new BorderSide( | 89 Border focusHighlight = new Border(bottom: new BorderSide( |
| 90 color: focusHighlightColor, | 90 color: focusHighlightColor, |
| 91 width: focused ? 2.0 : 1.0 | 91 width: focused ? 2.0 : 1.0 |
| 92 )); | 92 )); |
| 93 | 93 |
| 94 Container input = new Container( | 94 Container input = new Container( |
| 95 child: new Stack(textChildren), | 95 child: new Stack(textChildren), |
| 96 padding: _kTextfieldPadding, | 96 padding: _kTextfieldPadding, |
| 97 decoration: new BoxDecoration(border: focusHighlight) | 97 decoration: new BoxDecoration(border: focusHighlight) |
| 98 ); | 98 ); |
| 99 | 99 |
| 100 return new Listener( | 100 return new Listener( |
| 101 child: input, | 101 child: input, |
| 102 onPointerDown: (_) => keyboard.showByRequest() | 102 onPointerDown: (_) => keyboard.showByRequest() |
| 103 ); | 103 ); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void didUnmount() { | 106 void didUnmount() { |
| 107 if (_isAttachedToKeyboard) | 107 if (_isAttachedToKeyboard) |
| 108 keyboard.hide(); | 108 keyboard.hide(); |
| 109 super.didUnmount(); | 109 super.didUnmount(); |
| 110 } | 110 } |
| 111 } | 111 } |
| OLD | NEW |