Fixes a cursor offset mistake for Material on iOS (#27851)
* Fixes offset and unblocks roll
This commit is contained in:
parent
a5af29e83c
commit
1196dbe94a
@ -110,11 +110,6 @@ class CupertinoButton extends StatefulWidget {
|
|||||||
/// Defaults to round corners of 8 logical pixels.
|
/// Defaults to round corners of 8 logical pixels.
|
||||||
final BorderRadius borderRadius;
|
final BorderRadius borderRadius;
|
||||||
|
|
||||||
/// The shape of the button.
|
|
||||||
///
|
|
||||||
/// Defaults to a super ellipse with
|
|
||||||
// final ShapeBorder shape;
|
|
||||||
|
|
||||||
final bool _filled;
|
final bool _filled;
|
||||||
|
|
||||||
/// Whether the button is enabled or disabled. Buttons are disabled by default. To
|
/// Whether the button is enabled or disabled. Buttons are disabled by default. To
|
||||||
|
@ -778,7 +778,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
|
|||||||
//
|
//
|
||||||
// This value is in device pixels, not logical pixels as is typically used
|
// This value is in device pixels, not logical pixels as is typically used
|
||||||
// throughout the codebase.
|
// throughout the codebase.
|
||||||
const int _iOSHorizontalOffset = 2;
|
const int _iOSHorizontalOffset = -2;
|
||||||
cursorOffset = Offset(_iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0);
|
cursorOffset = Offset(_iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -4326,14 +4326,14 @@ void main() {
|
|||||||
|
|
||||||
expect(lastCharEndpoint.length, 1);
|
expect(lastCharEndpoint.length, 1);
|
||||||
// The last character is now on screen.
|
// The last character is now on screen.
|
||||||
expect(lastCharEndpoint[0].point.dx, moreOrLessEquals(797.3333129882812));
|
expect(lastCharEndpoint[0].point.dx, moreOrLessEquals(798.6666870117188));
|
||||||
|
|
||||||
final List<TextSelectionPoint> firstCharEndpoint = renderEditable.getEndpointsForSelection(
|
final List<TextSelectionPoint> firstCharEndpoint = renderEditable.getEndpointsForSelection(
|
||||||
const TextSelection.collapsed(offset: 0), // First character's position.
|
const TextSelection.collapsed(offset: 0), // First character's position.
|
||||||
);
|
);
|
||||||
expect(firstCharEndpoint.length, 1);
|
expect(firstCharEndpoint.length, 1);
|
||||||
// The first character is now offscreen to the left.
|
// The first character is now offscreen to the left.
|
||||||
expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-258.66668701171875));
|
expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-257.33331298828125));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets(
|
testWidgets(
|
||||||
|
@ -512,7 +512,9 @@ void main() {
|
|||||||
expect(controller.selection.baseOffset, text.length);
|
expect(controller.selection.baseOffset, text.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Floating cursor is painted', (WidgetTester tester) async {
|
testWidgets('Floating cursor is painted on iOS', (WidgetTester tester) async {
|
||||||
|
final TextEditingController controller = TextEditingController();
|
||||||
|
const TextStyle textStyle = TextStyle();
|
||||||
const String text = 'hello world this is fun and cool and awesome!';
|
const String text = 'hello world this is fun and cool and awesome!';
|
||||||
controller.text = text;
|
controller.text = text;
|
||||||
final FocusNode focusNode = FocusNode();
|
final FocusNode focusNode = FocusNode();
|
||||||
@ -544,7 +546,7 @@ void main() {
|
|||||||
editableTextState.updateFloatingCursor(
|
editableTextState.updateFloatingCursor(
|
||||||
RawFloatingCursorPoint(
|
RawFloatingCursorPoint(
|
||||||
state: FloatingCursorDragState.Update,
|
state: FloatingCursorDragState.Update,
|
||||||
offset: const Offset(20, 20),
|
offset: const Offset(20, 20)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
@ -552,41 +554,45 @@ void main() {
|
|||||||
expect(editable, paints
|
expect(editable, paints
|
||||||
..rrect(
|
..rrect(
|
||||||
rrect: RRect.fromRectAndRadius(
|
rrect: RRect.fromRectAndRadius(
|
||||||
Rect.fromLTRB(464.6666564941406, 2.0833332538604736, 466.6666564941406, 14.083333015441895),
|
Rect.fromLTRB(463.3333435058594, 2.0833332538604736, 465.3333435058594, 14.083333015441895),
|
||||||
const Radius.circular(2.0),
|
const Radius.circular(2.0)
|
||||||
),
|
),
|
||||||
color: const Color(0xff8e8e93))
|
color: const Color(0xff8e8e93),
|
||||||
|
)
|
||||||
..rrect(
|
..rrect(
|
||||||
rrect: RRect.fromRectAndRadius(
|
rrect: RRect.fromRectAndRadius(
|
||||||
Rect.fromLTRB(465.1666564941406, 1.0833336114883423, 468.1666564941406, 15.083333969116211),
|
Rect.fromLTRB(463.8333435058594, 1.0833336114883423, 466.8333435058594, 15.083333969116211),
|
||||||
const Radius.circular(1.0),
|
const Radius.circular(1.0),
|
||||||
),
|
),
|
||||||
color: const Color(0xbf2196f3))
|
color: const Color(0xbf2196f3),
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Moves the cursor right a few characters.
|
// Moves the cursor right a few characters.
|
||||||
editableTextState.updateFloatingCursor(
|
editableTextState.updateFloatingCursor(
|
||||||
RawFloatingCursorPoint(
|
RawFloatingCursorPoint(
|
||||||
state: FloatingCursorDragState.Update,
|
state: FloatingCursorDragState.Update,
|
||||||
offset: const Offset(-250, 20)));
|
offset: const Offset(-250, 20)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
expect(find.byType(EditableText), paints
|
expect(find.byType(EditableText), paints
|
||||||
..rrect(
|
..rrect(
|
||||||
rrect: RRect.fromRectAndRadius(
|
rrect: RRect.fromRectAndRadius(
|
||||||
Rect.fromLTRB(192.6666717529297, 2.0833332538604736, 194.6666717529297, 14.083333015441895),
|
Rect.fromLTRB(191.3333282470703, 2.0833332538604736, 193.3333282470703, 14.083333015441895),
|
||||||
const Radius.circular(2.0),
|
const Radius.circular(2.0)
|
||||||
),
|
),
|
||||||
color: const Color(0xff8e8e93))
|
color: const Color(0xff8e8e93)
|
||||||
|
)
|
||||||
..rrect(
|
..rrect(
|
||||||
rrect: RRect.fromRectAndRadius(
|
rrect: RRect.fromRectAndRadius(
|
||||||
Rect.fromLTRB(195.16665649414062, 1.0833336114883423, 198.16665649414062, 15.083333969116211),
|
Rect.fromLTRB(193.83334350585938, 1.0833336114883423, 196.83334350585938, 15.083333969116211),
|
||||||
const Radius.circular(1.0),
|
const Radius.circular(1.0)),
|
||||||
),
|
color: const Color(0xbf2196f3),
|
||||||
color: const Color(0xbf2196f3))
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.End));
|
editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.End));
|
||||||
|
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user