Skip to content

Commit

Permalink
Rename RawInputLine to RawInput, and RenderEditableLine to RenderEdit… (
Browse files Browse the repository at this point in the history
#6401)

They support multiline text now.
  • Loading branch information
mpcomplete committed Oct 19, 2016
1 parent 5bde9d2 commit 97dbd9e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 55 deletions.
10 changes: 5 additions & 5 deletions packages/flutter/lib/src/material/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ const Duration _kTransitionDuration = const Duration(milliseconds: 200);
const Curve _kTransitionCurve = Curves.fastOutSlowIn;

class _InputState extends State<Input> {
GlobalKey<RawInputLineState> _rawInputLineKey = new GlobalKey<RawInputLineState>();
GlobalKey<RawInputState> _rawInputKey = new GlobalKey<RawInputState>();

GlobalKey get focusKey => config.key is GlobalKey ? config.key : _rawInputLineKey;
GlobalKey get focusKey => config.key is GlobalKey ? config.key : _rawInputKey;

// Optional state to retain if we are inside a Form widget.
_FormFieldData _formData;
Expand Down Expand Up @@ -251,8 +251,8 @@ class _InputState extends State<Input> {
decoration: new BoxDecoration(
border: border,
),
child: new RawInputLine(
key: _rawInputLineKey,
child: new RawInput(
key: _rawInputKey,
value: value,
focusKey: focusKey,
style: textStyle,
Expand Down Expand Up @@ -305,7 +305,7 @@ class _InputState extends State<Input> {
return new RepaintBoundary(
child: new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _rawInputLineKey.currentState?.requestKeyboard(),
onTap: () => _rawInputKey.currentState?.requestKeyboard(),
child: new Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: child
Expand Down
10 changes: 5 additions & 5 deletions packages/flutter/lib/src/rendering/editable_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const double _kCaretWidth = 1.0; // pixels
final String _kZeroWidthSpace = new String.fromCharCode(0x200B);

/// Called when the user changes the selection (including cursor location).
typedef void SelectionChangedHandler(TextSelection selection, RenderEditableLine renderObject, bool longPress);
typedef void SelectionChangedHandler(TextSelection selection, RenderEditable renderObject, bool longPress);

/// Represents a global screen coordinate of the point in a selection, and the
/// text direction at that point.
Expand All @@ -36,12 +36,12 @@ class TextSelectionPoint {
final TextDirection direction;
}

typedef Offset RenderEditableLinePaintOffsetNeededCallback(ViewportDimensions dimensions, Rect caretRect);
typedef Offset RenderEditablePaintOffsetNeededCallback(ViewportDimensions dimensions, Rect caretRect);

/// A single line of editable text.
class RenderEditableLine extends RenderBox {
class RenderEditable extends RenderBox {
/// Creates a render object for a single line of editable text.
RenderEditableLine({
RenderEditable({
TextSpan text,
Color cursorColor,
bool showCursor: false,
Expand Down Expand Up @@ -71,7 +71,7 @@ class RenderEditableLine extends RenderBox {
SelectionChangedHandler onSelectionChanged;

/// Called when the inner or outer dimensions of this render object change.
RenderEditableLinePaintOffsetNeededCallback onPaintOffsetUpdateNeeded;
RenderEditablePaintOffsetNeededCallback onPaintOffsetUpdateNeeded;

/// The text to display
TextSpan get text => _textPainter.text;
Expand Down
32 changes: 16 additions & 16 deletions packages/flutter/lib/src/widgets/editable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'dart:async';

import 'package:flutter/rendering.dart' show RenderEditableLine, SelectionChangedHandler, RenderEditableLinePaintOffsetNeededCallback;
import 'package:flutter/rendering.dart' show RenderEditable, SelectionChangedHandler, RenderEditablePaintOffsetNeededCallback;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart';
import 'package:flutter_services/editing.dart' as mojom;
Expand Down Expand Up @@ -158,11 +158,11 @@ class InputValue {
/// [Input], which provides focus management and material design.
//
// TODO(mpcomplete): rename RawInput since it can span multiple lines.
class RawInputLine extends Scrollable {
class RawInput extends Scrollable {
/// Creates a basic single-line input control.
///
/// The [value] argument must not be null.
RawInputLine({
RawInput({
Key key,
@required this.value,
this.focusKey,
Expand Down Expand Up @@ -235,11 +235,11 @@ class RawInputLine extends Scrollable {
final ValueChanged<InputValue> onSubmitted;

@override
RawInputLineState createState() => new RawInputLineState();
RawInputState createState() => new RawInputState();
}

/// State for a [RawInputLine].
class RawInputLineState extends ScrollableState<RawInputLine> {
/// State for a [RawInput].
class RawInputState extends ScrollableState<RawInput> {
Timer _cursorTimer;
bool _showCursor = false;

Expand All @@ -264,7 +264,7 @@ class RawInputLineState extends ScrollableState<RawInputLine> {
}

@override
void didUpdateConfig(RawInputLine oldConfig) {
void didUpdateConfig(RawInput oldConfig) {
if (_keyboardClient.inputValue != config.value) {
_keyboardClient.inputValue = config.value;
if (_isAttachedToKeyboard)
Expand Down Expand Up @@ -359,9 +359,9 @@ class RawInputLineState extends ScrollableState<RawInputLine> {
config.onSubmitted(_keyboardClient.inputValue);
}

void _handleSelectionChanged(TextSelection selection, RenderEditableLine renderObject, bool longPress) {
void _handleSelectionChanged(TextSelection selection, RenderEditable renderObject, bool longPress) {
// Note that this will show the keyboard for all selection changes on the
// EditableLineWidget, not just changes triggered by user gestures.
// EditableWidget, not just changes triggered by user gestures.
requestKeyboard();

InputValue newInput = new InputValue(text: _keyboardClient.inputValue.text, selection: selection);
Expand Down Expand Up @@ -463,7 +463,7 @@ class RawInputLineState extends ScrollableState<RawInputLine> {
}

return new ClipRect(
child: new _EditableLineWidget(
child: new _Editable(
value: _keyboardClient.inputValue,
style: config.style,
cursorColor: config.cursorColor,
Expand All @@ -480,8 +480,8 @@ class RawInputLineState extends ScrollableState<RawInputLine> {
}
}

class _EditableLineWidget extends LeafRenderObjectWidget {
_EditableLineWidget({
class _Editable extends LeafRenderObjectWidget {
_Editable({
Key key,
this.value,
this.style,
Expand All @@ -506,11 +506,11 @@ class _EditableLineWidget extends LeafRenderObjectWidget {
final bool hideText;
final SelectionChangedHandler onSelectionChanged;
final Offset paintOffset;
final RenderEditableLinePaintOffsetNeededCallback onPaintOffsetUpdateNeeded;
final RenderEditablePaintOffsetNeededCallback onPaintOffsetUpdateNeeded;

@override
RenderEditableLine createRenderObject(BuildContext context) {
return new RenderEditableLine(
RenderEditable createRenderObject(BuildContext context) {
return new RenderEditable(
text: _styledTextSpan,
cursorColor: cursorColor,
showCursor: showCursor,
Expand All @@ -525,7 +525,7 @@ class _EditableLineWidget extends LeafRenderObjectWidget {
}

@override
void updateRenderObject(BuildContext context, RenderEditableLine renderObject) {
void updateRenderObject(BuildContext context, RenderEditable renderObject) {
renderObject
..text = _styledTextSpan
..cursorColor = cursorColor
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter/lib/src/widgets/raw_keyboard_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import 'framework.dart';
/// hardware buttons that are represented as keys. Typically used by games and
/// other apps that use keyboards for purposes other than text entry.
///
/// For text entry, consider using a [RawInputLine], which integrates with
/// For text entry, consider using a [RawInput], which integrates with
/// on-screen keyboards and input method editors (IMEs).
///
/// See also:
///
/// * [RawInputLine], which should be used instead of this widget for text
/// * [RawInput], which should be used instead of this widget for text
/// entry.
class RawKeyboardListener extends StatefulWidget {
/// Creates a widget that receives raw keyboard events.
///
/// For text entry, consider using a [RawInputLine], which integrates with
/// For text entry, consider using a [RawInput], which integrates with
/// on-screen keyboards and input method editors (IMEs).
RawKeyboardListener({
Key key,
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/widgets/text_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class TextSelectionOverlay implements TextSelectionDelegate {
// TODO(mpcomplete): what if the renderObject is removed or replaced, or
// moves? Not sure what cases I need to handle, or how to handle them.
/// The editable line in which the selected text is being displayed.
final RenderEditableLine renderObject;
final RenderEditable renderObject;

/// Called when the the selection changes.
///
Expand Down Expand Up @@ -301,7 +301,7 @@ class _TextSelectionHandleOverlay extends StatefulWidget {

final TextSelection selection;
final _TextSelectionHandlePosition position;
final RenderEditableLine renderObject;
final RenderEditable renderObject;
final ValueChanged<TextSelection> onSelectionHandleChanged;
final VoidCallback onSelectionHandleTapped;
final TextSelectionControls selectionControls;
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/widget/form_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void main() {
expect(mockKeyboard.currentState.text, equals(initialValue));

// initial value should also be visible in the raw input line
RawInputLineState editableText = tester.state(find.byType(RawInputLine));
RawInputState editableText = tester.state(find.byType(RawInput));
expect(editableText.config.value.text, equals(initialValue));

// sanity check, make sure we can still edit the text and everything updates
Expand Down
46 changes: 23 additions & 23 deletions packages/flutter/test/widget/input_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,27 @@ void main() {
..composingExtent = testValue.length);
}

// Returns the first RenderEditableLine.
RenderEditableLine findRenderEditableLine(WidgetTester tester) {
RenderObject root = tester.renderObject(find.byType(RawInputLine));
// Returns the first RenderEditable.
RenderEditable findRenderEditable(WidgetTester tester) {
RenderObject root = tester.renderObject(find.byType(RawInput));
expect(root, isNotNull);

RenderEditableLine renderLine;
RenderEditable renderEditable;
void recursiveFinder(RenderObject child) {
if (child is RenderEditableLine) {
renderLine = child;
if (child is RenderEditable) {
renderEditable = child;
return;
}
child.visitChildren(recursiveFinder);
}
root.visitChildren(recursiveFinder);
expect(renderLine, isNotNull);
return renderLine;
expect(renderEditable, isNotNull);
return renderEditable;
}

Point textOffsetToPosition(WidgetTester tester, int offset) {
RenderEditableLine renderLine = findRenderEditableLine(tester);
List<TextSelectionPoint> endpoints = renderLine.getEndpointsForSelection(
RenderEditable renderEditable = findRenderEditable(tester);
List<TextSelectionPoint> endpoints = renderEditable.getEndpointsForSelection(
new TextSelection.collapsed(offset: offset));
expect(endpoints.length, 1);
return endpoints[0].point + new Offset(0.0, -2.0);
Expand Down Expand Up @@ -157,7 +157,7 @@ void main() {

await tester.pumpWidget(builder());

RawInputLineState editableText = tester.state(find.byType(RawInputLine));
RawInputState editableText = tester.state(find.byType(RawInput));

// Check that the cursor visibility toggles after each blink interval.
Future<Null> checkCursorToggle() async {
Expand Down Expand Up @@ -296,8 +296,8 @@ void main() {

TextSelection selection = inputValue.selection;

RenderEditableLine renderLine = findRenderEditableLine(tester);
List<TextSelectionPoint> endpoints = renderLine.getEndpointsForSelection(
RenderEditable renderEditable = findRenderEditable(tester);
List<TextSelectionPoint> endpoints = renderEditable.getEndpointsForSelection(
selection);
expect(endpoints.length, 2);

Expand Down Expand Up @@ -363,8 +363,8 @@ void main() {
// Tap the selection handle to bring up the "paste / select all" menu.
await tester.tapAt(textOffsetToPosition(tester, testValue.indexOf('e')));
await tester.pumpWidget(builder());
RenderEditableLine renderLine = findRenderEditableLine(tester);
List<TextSelectionPoint> endpoints = renderLine.getEndpointsForSelection(
RenderEditable renderEditable = findRenderEditable(tester);
List<TextSelectionPoint> endpoints = renderEditable.getEndpointsForSelection(
inputValue.selection);
await tester.tapAt(endpoints[0].point + new Offset(1.0, 1.0));
await tester.pumpWidget(builder());
Expand All @@ -383,8 +383,8 @@ void main() {
// Tap again to bring back the menu.
await tester.tapAt(textOffsetToPosition(tester, testValue.indexOf('e')));
await tester.pumpWidget(builder());
renderLine = findRenderEditableLine(tester);
endpoints = renderLine.getEndpointsForSelection(inputValue.selection);
renderEditable = findRenderEditable(tester);
endpoints = renderEditable.getEndpointsForSelection(inputValue.selection);
await tester.tapAt(endpoints[0].point + new Offset(1.0, 1.0));
await tester.pumpWidget(builder());

Expand Down Expand Up @@ -427,8 +427,8 @@ void main() {
// Tap the selection handle to bring up the "paste / select all" menu.
await tester.tapAt(textOffsetToPosition(tester, testValue.indexOf('e')));
await tester.pumpWidget(builder());
RenderEditableLine renderLine = findRenderEditableLine(tester);
List<TextSelectionPoint> endpoints = renderLine.getEndpointsForSelection(
RenderEditable renderEditable = findRenderEditable(tester);
List<TextSelectionPoint> endpoints = renderEditable.getEndpointsForSelection(
inputValue.selection);
await tester.tapAt(endpoints[0].point + new Offset(1.0, 1.0));
await tester.pumpWidget(builder());
Expand Down Expand Up @@ -552,8 +552,8 @@ void main() {
expect(inputValue.selection.baseOffset, 76);
expect(inputValue.selection.extentOffset, 81);

RenderEditableLine renderLine = findRenderEditableLine(tester);
List<TextSelectionPoint> endpoints = renderLine.getEndpointsForSelection(
RenderEditable renderEditable = findRenderEditable(tester);
List<TextSelectionPoint> endpoints = renderEditable.getEndpointsForSelection(
inputValue.selection);
expect(endpoints.length, 2);

Expand Down Expand Up @@ -656,8 +656,8 @@ void main() {
await gesture.up();
await tester.pump();

RenderEditableLine renderLine = findRenderEditableLine(tester);
List<TextSelectionPoint> endpoints = renderLine.getEndpointsForSelection(
RenderEditable renderEditable = findRenderEditable(tester);
List<TextSelectionPoint> endpoints = renderEditable.getEndpointsForSelection(
inputValue.selection);
expect(endpoints.length, 2);

Expand Down

0 comments on commit 97dbd9e

Please sign in to comment.