Commit a0c9ebc0 authored by Eric Seidel's avatar Eric Seidel

Teach the fitness app how to request a numeric keyboard

Unforutnately since Input won't show text if it doesn't start
with a letter, this actually makes the experiance slightly
worse, but this is definitely the right direction.

@abarth
parent be75ee72
...@@ -110,6 +110,7 @@ class MeasurementFragment extends StatefulComponent { ...@@ -110,6 +110,7 @@ class MeasurementFragment extends StatefulComponent {
new Input( new Input(
key: weightKey, key: weightKey,
placeholder: 'Enter weight', placeholder: 'Enter weight',
keyboardType: KeyboardType_NUMBER,
onChanged: _handleWeightChanged onChanged: _handleWeightChanged
), ),
]) ])
......
...@@ -10,6 +10,8 @@ import 'package:sky/widgets/basic.dart'; ...@@ -10,6 +10,8 @@ import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/focus.dart'; import 'package:sky/widgets/focus.dart';
import 'package:sky/widgets/theme.dart'; import 'package:sky/widgets/theme.dart';
export 'package:sky/mojo/keyboard.dart' show KeyboardType_TEXT, KeyboardType_NUMBER, KeyboardType_PHONE, KeyboardType_DATETIME;
typedef void StringValueChanged(String value); typedef void StringValueChanged(String value);
// TODO(eseidel): This isn't right, it's 16px on the bottom: // TODO(eseidel): This isn't right, it's 16px on the bottom:
...@@ -21,9 +23,11 @@ class Input extends StatefulComponent { ...@@ -21,9 +23,11 @@ class Input extends StatefulComponent {
Input({ Input({
GlobalKey key, GlobalKey key,
this.placeholder, this.placeholder,
this.onChanged this.onChanged,
this.keyboardType : KeyboardType_TEXT
}): super(key: key); }): super(key: key);
int keyboardType;
String placeholder; String placeholder;
StringValueChanged onChanged; StringValueChanged onChanged;
...@@ -42,6 +46,7 @@ class Input extends StatefulComponent { ...@@ -42,6 +46,7 @@ class Input extends StatefulComponent {
void syncFields(Input source) { void syncFields(Input source) {
placeholder = source.placeholder; placeholder = source.placeholder;
onChanged = source.onChanged; onChanged = source.onChanged;
keyboardType = source.keyboardType;
} }
void _handleTextUpdated() { void _handleTextUpdated() {
...@@ -59,7 +64,7 @@ class Input extends StatefulComponent { ...@@ -59,7 +64,7 @@ class Input extends StatefulComponent {
bool focused = Focus.at(this); bool focused = Focus.at(this);
if (focused && !_keyboardHandle.attached) { if (focused && !_keyboardHandle.attached) {
_keyboardHandle = keyboard.show(_editableValue.stub, KeyboardType_TEXT); _keyboardHandle = keyboard.show(_editableValue.stub, keyboardType);
} else if (!focused && _keyboardHandle.attached) { } else if (!focused && _keyboardHandle.attached) {
_keyboardHandle.release(); _keyboardHandle.release();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment