Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
97dbd9ea
Commit
97dbd9ea
authored
Oct 19, 2016
by
Matt Perry
Committed by
GitHub
Oct 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename RawInputLine to RawInput, and RenderEditableLine to RenderEdit… (#6401)
They support multiline text now.
parent
5bde9d28
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
55 deletions
+55
-55
input.dart
packages/flutter/lib/src/material/input.dart
+5
-5
editable_line.dart
packages/flutter/lib/src/rendering/editable_line.dart
+5
-5
editable.dart
packages/flutter/lib/src/widgets/editable.dart
+16
-16
raw_keyboard_listener.dart
packages/flutter/lib/src/widgets/raw_keyboard_listener.dart
+3
-3
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+2
-2
form_test.dart
packages/flutter/test/widget/form_test.dart
+1
-1
input_test.dart
packages/flutter/test/widget/input_test.dart
+23
-23
No files found.
packages/flutter/lib/src/material/input.dart
View file @
97dbd9ea
...
...
@@ -142,9 +142,9 @@ const Duration _kTransitionDuration = const Duration(milliseconds: 200);
const
Curve
_kTransitionCurve
=
Curves
.
fastOutSlowIn
;
class
_InputState
extends
State
<
Input
>
{
GlobalKey
<
RawInput
LineState
>
_rawInputLineKey
=
new
GlobalKey
<
RawInputLine
State
>();
GlobalKey
<
RawInput
State
>
_rawInputKey
=
new
GlobalKey
<
RawInput
State
>();
GlobalKey
get
focusKey
=>
config
.
key
is
GlobalKey
?
config
.
key
:
_rawInput
Line
Key
;
GlobalKey
get
focusKey
=>
config
.
key
is
GlobalKey
?
config
.
key
:
_rawInputKey
;
// Optional state to retain if we are inside a Form widget.
_FormFieldData
_formData
;
...
...
@@ -251,8 +251,8 @@ class _InputState extends State<Input> {
decoration:
new
BoxDecoration
(
border:
border
,
),
child:
new
RawInput
Line
(
key:
_rawInput
Line
Key
,
child:
new
RawInput
(
key:
_rawInputKey
,
value:
value
,
focusKey:
focusKey
,
style:
textStyle
,
...
...
@@ -305,7 +305,7 @@ class _InputState extends State<Input> {
return
new
RepaintBoundary
(
child:
new
GestureDetector
(
behavior:
HitTestBehavior
.
opaque
,
onTap:
()
=>
_rawInput
Line
Key
.
currentState
?.
requestKeyboard
(),
onTap:
()
=>
_rawInputKey
.
currentState
?.
requestKeyboard
(),
child:
new
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
),
child:
child
...
...
packages/flutter/lib/src/rendering/editable_line.dart
View file @
97dbd9ea
...
...
@@ -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
,
RenderEditable
Line
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.
...
...
@@ -36,12 +36,12 @@ class TextSelectionPoint {
final
TextDirection
direction
;
}
typedef
Offset
RenderEditable
Line
PaintOffsetNeededCallback
(
ViewportDimensions
dimensions
,
Rect
caretRect
);
typedef
Offset
RenderEditablePaintOffsetNeededCallback
(
ViewportDimensions
dimensions
,
Rect
caretRect
);
/// A single line of editable text.
class
RenderEditable
Line
extends
RenderBox
{
class
RenderEditable
extends
RenderBox
{
/// Creates a render object for a single line of editable text.
RenderEditable
Line
({
RenderEditable
({
TextSpan
text
,
Color
cursorColor
,
bool
showCursor:
false
,
...
...
@@ -71,7 +71,7 @@ class RenderEditableLine extends RenderBox {
SelectionChangedHandler
onSelectionChanged
;
/// Called when the inner or outer dimensions of this render object change.
RenderEditable
Line
PaintOffsetNeededCallback
onPaintOffsetUpdateNeeded
;
RenderEditablePaintOffsetNeededCallback
onPaintOffsetUpdateNeeded
;
/// The text to display
TextSpan
get
text
=>
_textPainter
.
text
;
...
...
packages/flutter/lib/src/widgets/editable.dart
View file @
97dbd9ea
...
...
@@ -4,7 +4,7 @@
import
'dart:async'
;
import
'package:flutter/rendering.dart'
show
RenderEditable
Line
,
SelectionChangedHandler
,
RenderEditableLin
ePaintOffsetNeededCallback
;
import
'package:flutter/rendering.dart'
show
RenderEditable
,
SelectionChangedHandler
,
RenderEditabl
ePaintOffsetNeededCallback
;
import
'package:flutter/services.dart'
;
import
'package:meta/meta.dart'
;
import
'package:flutter_services/editing.dart'
as
mojom
;
...
...
@@ -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
RawInput
Line
extends
Scrollable
{
class
RawInput
extends
Scrollable
{
/// Creates a basic single-line input control.
///
/// The [value] argument must not be null.
RawInput
Line
({
RawInput
({
Key
key
,
@required
this
.
value
,
this
.
focusKey
,
...
...
@@ -235,11 +235,11 @@ class RawInputLine extends Scrollable {
final
ValueChanged
<
InputValue
>
onSubmitted
;
@override
RawInput
LineState
createState
()
=>
new
RawInputLine
State
();
RawInput
State
createState
()
=>
new
RawInput
State
();
}
/// State for a [RawInput
Line
].
class
RawInput
LineState
extends
ScrollableState
<
RawInputLine
>
{
/// State for a [RawInput].
class
RawInput
State
extends
ScrollableState
<
RawInput
>
{
Timer
_cursorTimer
;
bool
_showCursor
=
false
;
...
...
@@ -264,7 +264,7 @@ class RawInputLineState extends ScrollableState<RawInputLine> {
}
@override
void
didUpdateConfig
(
RawInput
Line
oldConfig
)
{
void
didUpdateConfig
(
RawInput
oldConfig
)
{
if
(
_keyboardClient
.
inputValue
!=
config
.
value
)
{
_keyboardClient
.
inputValue
=
config
.
value
;
if
(
_isAttachedToKeyboard
)
...
...
@@ -359,9 +359,9 @@ class RawInputLineState extends ScrollableState<RawInputLine> {
config
.
onSubmitted
(
_keyboardClient
.
inputValue
);
}
void
_handleSelectionChanged
(
TextSelection
selection
,
RenderEditable
Line
renderObject
,
bool
longPress
)
{
void
_handleSelectionChanged
(
TextSelection
selection
,
RenderEditable
renderObject
,
bool
longPress
)
{
// Note that this will show the keyboard for all selection changes on the
// Editable
Line
Widget, 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
);
...
...
@@ -463,7 +463,7 @@ class RawInputLineState extends ScrollableState<RawInputLine> {
}
return
new
ClipRect
(
child:
new
_Editable
LineWidget
(
child:
new
_Editable
(
value:
_keyboardClient
.
inputValue
,
style:
config
.
style
,
cursorColor:
config
.
cursorColor
,
...
...
@@ -480,8 +480,8 @@ class RawInputLineState extends ScrollableState<RawInputLine> {
}
}
class
_Editable
LineWidget
extends
LeafRenderObjectWidget
{
_Editable
LineWidget
({
class
_Editable
extends
LeafRenderObjectWidget
{
_Editable
({
Key
key
,
this
.
value
,
this
.
style
,
...
...
@@ -506,11 +506,11 @@ class _EditableLineWidget extends LeafRenderObjectWidget {
final
bool
hideText
;
final
SelectionChangedHandler
onSelectionChanged
;
final
Offset
paintOffset
;
final
RenderEditable
Line
PaintOffsetNeededCallback
onPaintOffsetUpdateNeeded
;
final
RenderEditablePaintOffsetNeededCallback
onPaintOffsetUpdateNeeded
;
@override
RenderEditable
Line
createRenderObject
(
BuildContext
context
)
{
return
new
RenderEditable
Line
(
RenderEditable
createRenderObject
(
BuildContext
context
)
{
return
new
RenderEditable
(
text:
_styledTextSpan
,
cursorColor:
cursorColor
,
showCursor:
showCursor
,
...
...
@@ -525,7 +525,7 @@ class _EditableLineWidget extends LeafRenderObjectWidget {
}
@override
void
updateRenderObject
(
BuildContext
context
,
RenderEditable
Line
renderObject
)
{
void
updateRenderObject
(
BuildContext
context
,
RenderEditable
renderObject
)
{
renderObject
..
text
=
_styledTextSpan
..
cursorColor
=
cursorColor
...
...
packages/flutter/lib/src/widgets/raw_keyboard_listener.dart
View file @
97dbd9ea
...
...
@@ -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 [RawInput
Line
], which integrates with
/// For text entry, consider using a [RawInput], which integrates with
/// on-screen keyboards and input method editors (IMEs).
///
/// See also:
///
/// * [RawInput
Line
], 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 [RawInput
Line
], which integrates with
/// For text entry, consider using a [RawInput], which integrates with
/// on-screen keyboards and input method editors (IMEs).
RawKeyboardListener
({
Key
key
,
...
...
packages/flutter/lib/src/widgets/text_selection.dart
View file @
97dbd9ea
...
...
@@ -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
RenderEditable
Line
renderObject
;
final
RenderEditable
renderObject
;
/// Called when the the selection changes.
///
...
...
@@ -301,7 +301,7 @@ class _TextSelectionHandleOverlay extends StatefulWidget {
final
TextSelection
selection
;
final
_TextSelectionHandlePosition
position
;
final
RenderEditable
Line
renderObject
;
final
RenderEditable
renderObject
;
final
ValueChanged
<
TextSelection
>
onSelectionHandleChanged
;
final
VoidCallback
onSelectionHandleTapped
;
final
TextSelectionControls
selectionControls
;
...
...
packages/flutter/test/widget/form_test.dart
View file @
97dbd9ea
...
...
@@ -190,7 +190,7 @@ void main() {
expect
(
mockKeyboard
.
currentState
.
text
,
equals
(
initialValue
));
// initial value should also be visible in the raw input line
RawInput
LineState
editableText
=
tester
.
state
(
find
.
byType
(
RawInputLine
));
RawInput
State
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
...
...
packages/flutter/test/widget/input_test.dart
View file @
97dbd9ea
...
...
@@ -73,27 +73,27 @@ void main() {
..
composingExtent
=
testValue
.
length
);
}
// Returns the first RenderEditable
Line
.
RenderEditable
Line
findRenderEditableLin
e
(
WidgetTester
tester
)
{
RenderObject
root
=
tester
.
renderObject
(
find
.
byType
(
RawInput
Line
));
// Returns the first RenderEditable.
RenderEditable
findRenderEditabl
e
(
WidgetTester
tester
)
{
RenderObject
root
=
tester
.
renderObject
(
find
.
byType
(
RawInput
));
expect
(
root
,
isNotNull
);
RenderEditable
Line
renderLin
e
;
RenderEditable
renderEditabl
e
;
void
recursiveFinder
(
RenderObject
child
)
{
if
(
child
is
RenderEditable
Line
)
{
render
Lin
e
=
child
;
if
(
child
is
RenderEditable
)
{
render
Editabl
e
=
child
;
return
;
}
child
.
visitChildren
(
recursiveFinder
);
}
root
.
visitChildren
(
recursiveFinder
);
expect
(
render
Lin
e
,
isNotNull
);
return
render
Lin
e
;
expect
(
render
Editabl
e
,
isNotNull
);
return
render
Editabl
e
;
}
Point
textOffsetToPosition
(
WidgetTester
tester
,
int
offset
)
{
RenderEditable
Line
renderLine
=
findRenderEditableLin
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Lin
e
.
getEndpointsForSelection
(
RenderEditable
renderEditable
=
findRenderEditabl
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Editabl
e
.
getEndpointsForSelection
(
new
TextSelection
.
collapsed
(
offset:
offset
));
expect
(
endpoints
.
length
,
1
);
return
endpoints
[
0
].
point
+
new
Offset
(
0.0
,
-
2.0
);
...
...
@@ -157,7 +157,7 @@ void main() {
await
tester
.
pumpWidget
(
builder
());
RawInput
LineState
editableText
=
tester
.
state
(
find
.
byType
(
RawInputLine
));
RawInput
State
editableText
=
tester
.
state
(
find
.
byType
(
RawInput
));
// Check that the cursor visibility toggles after each blink interval.
Future
<
Null
>
checkCursorToggle
()
async
{
...
...
@@ -296,8 +296,8 @@ void main() {
TextSelection
selection
=
inputValue
.
selection
;
RenderEditable
Line
renderLine
=
findRenderEditableLin
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Lin
e
.
getEndpointsForSelection
(
RenderEditable
renderEditable
=
findRenderEditabl
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Editabl
e
.
getEndpointsForSelection
(
selection
);
expect
(
endpoints
.
length
,
2
);
...
...
@@ -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
());
RenderEditable
Line
renderLine
=
findRenderEditableLin
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Lin
e
.
getEndpointsForSelection
(
RenderEditable
renderEditable
=
findRenderEditabl
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Editabl
e
.
getEndpointsForSelection
(
inputValue
.
selection
);
await
tester
.
tapAt
(
endpoints
[
0
].
point
+
new
Offset
(
1.0
,
1.0
));
await
tester
.
pumpWidget
(
builder
());
...
...
@@ -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
());
render
Line
=
findRenderEditableLin
e
(
tester
);
endpoints
=
render
Lin
e
.
getEndpointsForSelection
(
inputValue
.
selection
);
render
Editable
=
findRenderEditabl
e
(
tester
);
endpoints
=
render
Editabl
e
.
getEndpointsForSelection
(
inputValue
.
selection
);
await
tester
.
tapAt
(
endpoints
[
0
].
point
+
new
Offset
(
1.0
,
1.0
));
await
tester
.
pumpWidget
(
builder
());
...
...
@@ -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
());
RenderEditable
Line
renderLine
=
findRenderEditableLin
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Lin
e
.
getEndpointsForSelection
(
RenderEditable
renderEditable
=
findRenderEditabl
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Editabl
e
.
getEndpointsForSelection
(
inputValue
.
selection
);
await
tester
.
tapAt
(
endpoints
[
0
].
point
+
new
Offset
(
1.0
,
1.0
));
await
tester
.
pumpWidget
(
builder
());
...
...
@@ -552,8 +552,8 @@ void main() {
expect
(
inputValue
.
selection
.
baseOffset
,
76
);
expect
(
inputValue
.
selection
.
extentOffset
,
81
);
RenderEditable
Line
renderLine
=
findRenderEditableLin
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Lin
e
.
getEndpointsForSelection
(
RenderEditable
renderEditable
=
findRenderEditabl
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Editabl
e
.
getEndpointsForSelection
(
inputValue
.
selection
);
expect
(
endpoints
.
length
,
2
);
...
...
@@ -656,8 +656,8 @@ void main() {
await
gesture
.
up
();
await
tester
.
pump
();
RenderEditable
Line
renderLine
=
findRenderEditableLin
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Lin
e
.
getEndpointsForSelection
(
RenderEditable
renderEditable
=
findRenderEditabl
e
(
tester
);
List
<
TextSelectionPoint
>
endpoints
=
render
Editabl
e
.
getEndpointsForSelection
(
inputValue
.
selection
);
expect
(
endpoints
.
length
,
2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment