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
800a6e16
Commit
800a6e16
authored
Jan 17, 2019
by
Ian Hickson
Committed by
jslavitz
Jan 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quick fix for tap-to-show-keyboard regression (#26629)
* Fixes Android keyboard bug
parent
4c99958d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
43 deletions
+52
-43
force_press.dart
packages/flutter/lib/src/gestures/force_press.dart
+28
-22
monodrag.dart
packages/flutter/lib/src/gestures/monodrag.dart
+1
-1
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+19
-16
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+4
-4
No files found.
packages/flutter/lib/src/gestures/force_press.dart
View file @
800a6e16
...
...
@@ -98,22 +98,21 @@ typedef GestureForceInterpolation = double Function(double pressureMin, double p
/// force touch functionality, with the exception of the iPhone XR. In addition,
/// a small handful of Android devices have this functionality as well.
///
/// Reported pressure will always be in the range [0.0, 1.0], where 1.0 is
/// maximum pressure and 0.0 is minimum pressure. If using a non-linear
/// interpolation equation, the pressure reported will correspond with the
/// custom curve. (ie. if the interpolation maps t(0.5) -> 0.1, a value of 0.1
/// will be reported at a device pressure value of 0.5).
///
/// Reported pressure will always be in the range 0.0 to 1.0, where 1.0 is
/// maximum pressure and 0.0 is minimum pressure. If using a custom
/// [interpolation] callback, the pressure reported will correspond to that
/// custom curve.
class
ForcePressGestureRecognizer
extends
OneSequenceGestureRecognizer
{
/// Creates a force press gesture recognizer.
///
/// The [startPressure] defaults to 0.4, and [peakPressure] defaults to 0.85
/// where a value of 0.0 is no pressure and a value of 1.0 is maximum pressure.
///
/// [startPressure], [peakPressure] and [interpolation] must not be null.
/// [peakPressure] must be greater than [startPressure]. [interpolation] must
/// always return a value in the range [0.0, 1.0] where
/// pressureMin <= pressure <= pressureMax.
/// The [startPressure], [peakPressure] and [interpolation] arguments must not
/// be null. The [peakPressure] argument must be greater than [startPressure].
/// The [interpolation] callback must always return a value in the range 0.0
/// to 1.0 for values of `pressure` that are between `pressureMin` and
/// `pressureMax`.
ForcePressGestureRecognizer
({
this
.
startPressure
=
0.4
,
this
.
peakPressure
=
0.85
,
...
...
@@ -172,21 +171,22 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
final
double
peakPressure
;
/// The function used to convert the raw device pressure values into a value
/// in the range
[0, 1]
.
/// in the range
0.0 to 1.0
.
///
/// The function takes in the device's min
, max and raw touch
///
pressure and returns a value in the range [0.0, 1.0] denoting the
///
interpolated
touch pressure.
/// The function takes in the device's min
imum, maximum and raw touch pressure
///
and returns a value in the range 0.0 to 1.0 denoting the interpolated
/// touch pressure.
///
/// This function must always return values in the range [0, 1] when
/// pressureMin <= pressure <= pressureMax.
/// This function must always return values in the range 0.0 to 1.0 given a
/// pressure that is between the minimum and maximum pressures. It may return
/// [double.NaN] for values that it does not want to support.
///
/// By default, the
the function is a simple linear interpolation, however,
///
changing the function could be useful to accommodate variations in the way
/// d
ifferent devices respond to pressure,
change how animations from pressure
/// feedback are rendered
or for other custom functionality
.
/// By default, the
function is a linear interpolation; however, changing the
///
function could be useful to accommodate variations in the way different
/// d
evices respond to pressure, or to
change how animations from pressure
/// feedback are rendered.
///
/// For example, an ease
in curve can be used to determine the interpolated
/// For example, an ease
-
in curve can be used to determine the interpolated
/// value:
///
/// ```dart
...
...
@@ -216,7 +216,12 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
// A static pointer with changes in pressure creates PointerMoveEvent events.
if
(
event
is
PointerMoveEvent
||
event
is
PointerDownEvent
)
{
final
double
pressure
=
interpolation
(
event
.
pressureMin
,
event
.
pressureMax
,
event
.
pressure
);
assert
(
pressure
.
isNaN
?
true
:
(
pressure
<=
1.0
&&
pressure
>=
0.0
));
assert
(
event
.
pressure
<
event
.
pressureMin
||
// contract is undefined for underflowing pressures...
event
.
pressure
>
event
.
pressureMax
||
// contract is undefined for overflowing pressures...
pressure
.
isNaN
||
// and interpolation may return NaN for values it doesn't want to support...
(
pressure
<=
1.0
&&
pressure
>=
0.0
)
// but if everything is going well, it must be in the range 1.0..0.0.
);
_lastPosition
=
event
.
position
;
_lastPressure
=
pressure
;
...
...
@@ -300,6 +305,7 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
}
static
double
_inverseLerp
(
double
min
,
double
max
,
double
t
)
{
assert
(
min
<=
max
);
return
(
t
-
min
)
/
(
max
-
min
);
}
...
...
packages/flutter/lib/src/gestures/monodrag.dart
View file @
800a6e16
...
...
@@ -280,7 +280,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
properties
.
add
(
EnumProperty
<
DragStartBehavior
>(
'
Start B
ehavior'
,
dragStartBehavior
));
properties
.
add
(
EnumProperty
<
DragStartBehavior
>(
'
start b
ehavior'
,
dragStartBehavior
));
}
}
...
...
packages/flutter/lib/src/material/text_field.dart
View file @
800a6e16
...
...
@@ -613,16 +613,9 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
void
_handleForcePressStarted
(
ForcePressDetails
details
)
{
if
(
widget
.
selectionEnabled
)
{
switch
(
Theme
.
of
(
context
).
platform
)
{
case
TargetPlatform
.
iOS
:
// The cause is not technically double tap, but we would like to show
// the toolbar.
_renderEditable
.
selectWordsInRange
(
from:
details
.
globalPosition
,
cause:
SelectionChangedCause
.
doubleTap
);
break
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
break
;
}
}
}
...
...
@@ -724,6 +717,20 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
if
(
widget
.
maxLength
!=
null
&&
widget
.
maxLengthEnforced
)
formatters
.
add
(
LengthLimitingTextInputFormatter
(
widget
.
maxLength
));
bool
forcePressEnabled
;
TextSelectionControls
textSelectionControls
;
switch
(
themeData
.
platform
)
{
case
TargetPlatform
.
iOS
:
forcePressEnabled
=
true
;
textSelectionControls
=
cupertinoTextSelectionControls
;
break
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
forcePressEnabled
=
false
;
textSelectionControls
=
materialTextSelectionControls
;
break
;
}
Widget
child
=
RepaintBoundary
(
child:
EditableText
(
key:
_editableTextKey
,
...
...
@@ -740,11 +747,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
autocorrect:
widget
.
autocorrect
,
maxLines:
widget
.
maxLines
,
selectionColor:
themeData
.
textSelectionColor
,
selectionControls:
widget
.
selectionEnabled
?
(
themeData
.
platform
==
TargetPlatform
.
iOS
?
cupertinoTextSelectionControls
:
materialTextSelectionControls
)
:
null
,
selectionControls:
widget
.
selectionEnabled
?
textSelectionControls
:
null
,
onChanged:
widget
.
onChanged
,
onEditingComplete:
widget
.
onEditingComplete
,
onSubmitted:
widget
.
onSubmitted
,
...
...
@@ -789,7 +792,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
ignoring:
!(
widget
.
enabled
??
widget
.
decoration
?.
enabled
??
true
),
child:
TextSelectionGestureDetector
(
onTapDown:
_handleTapDown
,
onForcePressStart:
_handleForcePressStarted
,
onForcePressStart:
forcePressEnabled
?
_handleForcePressStarted
:
null
,
onSingleTapUp:
_handleSingleTapUp
,
onSingleTapCancel:
_handleSingleTapCancel
,
onSingleLongTapDown:
_handleSingleLongTapDown
,
...
...
packages/flutter/lib/src/widgets/text_selection.dart
View file @
800a6e16
...
...
@@ -761,8 +761,8 @@ class _TextSelectionGestureDetectorState extends State<TextSelectionGestureDetec
return
GestureDetector
(
onTapDown:
_handleTapDown
,
onTapUp:
_handleTapUp
,
onForcePressStart:
_forcePressStarted
,
onForcePressEnd:
_forcePressEnded
,
onForcePressStart:
widget
.
onForcePressStart
!=
null
?
_forcePressStarted
:
null
,
onForcePressEnd:
widget
.
onForcePressEnd
!=
null
?
_forcePressEnded
:
null
,
onTapCancel:
_handleTapCancel
,
onLongPress:
_handleLongPress
,
excludeFromSemantics:
true
,
...
...
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