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
0377e80d
Unverified
Commit
0377e80d
authored
Sep 22, 2023
by
Tomasz Gucio
Committed by
GitHub
Sep 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Size CupertinoTextSelectionToolbar to children (#133386)
parent
85e52d43
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
253 additions
and
215 deletions
+253
-215
text_selection_toolbar.dart
...ges/flutter/lib/src/cupertino/text_selection_toolbar.dart
+222
-180
text_field_test.dart
packages/flutter/test/cupertino/text_field_test.dart
+9
-9
text_selection_test.dart
packages/flutter/test/cupertino/text_selection_test.dart
+2
-2
text_selection_toolbar_test.dart
...s/flutter/test/cupertino/text_selection_toolbar_test.dart
+20
-24
No files found.
packages/flutter/lib/src/cupertino/text_selection_toolbar.dart
View file @
0377e80d
This diff is collapsed.
Click to expand it.
packages/flutter/test/cupertino/text_field_test.dart
View file @
0377e80d
...
...
@@ -6837,7 +6837,7 @@ void main() {
includes:
<
Offset
>
[
// Expected center of the arrow. The arrow should stay clear of
// the edges of the selection toolbar.
Offset
(
26.0
,
bottomLeftSelectionPosition
.
dy
+
7.0
+
8.0
+
0.1
),
Offset
(
26.0
,
bottomLeftSelectionPosition
.
dy
+
8.0
+
0.1
),
],
),
),
...
...
@@ -6847,10 +6847,10 @@ void main() {
find
.
byType
(
CupertinoTextSelectionToolbar
),
paints
..
clipPath
(
pathMatcher:
PathBoundsMatcher
(
topMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
+
7
+
8
,
epsilon:
0.01
),
topMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
+
8
,
epsilon:
0.01
),
leftMatcher:
moreOrLessEquals
(
8
),
rightMatcher:
lessThanOrEqualTo
(
400
-
8
),
bottomMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
+
8
+
4
5
,
epsilon:
0.01
),
bottomMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
+
8
+
4
4
,
epsilon:
0.01
),
),
),
);
...
...
@@ -6898,7 +6898,7 @@ void main() {
],
includes:
<
Offset
>
[
// Expected center of the arrow.
Offset
(
400
-
26.0
,
bottomLeftSelectionPosition
.
dy
+
7
+
8
+
0.1
),
Offset
(
400
-
26.0
,
bottomLeftSelectionPosition
.
dy
+
8
+
0.1
),
],
),
),
...
...
@@ -6908,9 +6908,9 @@ void main() {
find
.
byType
(
CupertinoTextSelectionToolbar
),
paints
..
clipPath
(
pathMatcher:
PathBoundsMatcher
(
topMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
+
7
+
8
,
epsilon:
0.01
),
topMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
+
8
,
epsilon:
0.01
),
rightMatcher:
moreOrLessEquals
(
400.0
-
8
),
bottomMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
+
8
+
4
5
,
epsilon:
0.01
),
bottomMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
+
8
+
4
4
,
epsilon:
0.01
),
leftMatcher:
greaterThanOrEqualTo
(
8
),
),
),
...
...
@@ -6963,7 +6963,7 @@ void main() {
paints
..
clipPath
(
pathMatcher:
PathBoundsMatcher
(
bottomMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
-
8
-
lineHeight
,
epsilon:
0.01
),
topMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
-
8
-
lineHeight
-
4
5
,
epsilon:
0.01
),
topMatcher:
moreOrLessEquals
(
bottomLeftSelectionPosition
.
dy
-
8
-
lineHeight
-
4
4
,
epsilon:
0.01
),
rightMatcher:
lessThanOrEqualTo
(
400
-
8
),
leftMatcher:
greaterThanOrEqualTo
(
8
),
),
...
...
@@ -7032,7 +7032,7 @@ void main() {
paints
..
clipPath
(
pathMatcher:
PathBoundsMatcher
(
bottomMatcher:
moreOrLessEquals
(
selectionPosition
.
dy
-
8
-
lineHeight
,
epsilon:
0.01
),
topMatcher:
moreOrLessEquals
(
selectionPosition
.
dy
-
8
-
lineHeight
-
4
5
,
epsilon:
0.01
),
topMatcher:
moreOrLessEquals
(
selectionPosition
.
dy
-
8
-
lineHeight
-
4
4
,
epsilon:
0.01
),
rightMatcher:
lessThanOrEqualTo
(
400
-
8
),
leftMatcher:
greaterThanOrEqualTo
(
8
),
),
...
...
@@ -7105,7 +7105,7 @@ void main() {
paints
..
clipPath
(
pathMatcher:
PathBoundsMatcher
(
bottomMatcher:
moreOrLessEquals
(
selectionPosition
.
dy
-
8
-
lineHeight
,
epsilon:
0.01
),
topMatcher:
moreOrLessEquals
(
selectionPosition
.
dy
-
8
-
lineHeight
-
4
5
,
epsilon:
0.01
),
topMatcher:
moreOrLessEquals
(
selectionPosition
.
dy
-
8
-
lineHeight
-
4
4
,
epsilon:
0.01
),
rightMatcher:
lessThanOrEqualTo
(
400
-
8
),
leftMatcher:
greaterThanOrEqualTo
(
8
),
),
...
...
packages/flutter/test/cupertino/text_selection_test.dart
View file @
0377e80d
...
...
@@ -671,8 +671,8 @@ void main() {
final
Offset
textFieldOffset
=
tester
.
getTopLeft
(
find
.
byType
(
CupertinoTextField
));
// 7.0 + 4
5.0 + 8.0 - 8.0 = _kToolbarArrowSize + _kToolbarH
eight + _kToolbarContentDistance - padding
expect
(
selectionOffset
.
dy
+
7.0
+
4
5
.0
+
8.0
-
8.0
,
equals
(
textFieldOffset
.
dy
));
// 7.0 + 4
4.0 + 8.0 - 8.0 = _kToolbarArrowSize + text_button_h
eight + _kToolbarContentDistance - padding
expect
(
selectionOffset
.
dy
+
7.0
+
4
4
.0
+
8.0
-
8.0
,
equals
(
textFieldOffset
.
dy
));
},
skip:
isBrowser
,
// [intended] the selection menu isn't required by web
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
}),
...
...
packages/flutter/test/cupertino/text_selection_toolbar_test.dart
View file @
0377e80d
...
...
@@ -12,7 +12,7 @@ import '../widgets/editable_text_utils.dart' show textOffsetToPosition;
// These constants are copied from cupertino/text_selection_toolbar.dart.
const
double
_kArrowScreenPadding
=
26.0
;
const
double
_kToolbarContentDistance
=
8.0
;
const
double
_kToolbarHeight
=
45.0
;
const
Size
_kToolbarArrowSize
=
Size
(
14.0
,
7.0
)
;
// A custom text selection menu that just displays a single custom button.
class
_CustomCupertinoTextSelectionControls
extends
CupertinoTextSelectionControls
{
...
...
@@ -271,7 +271,7 @@ void main() {
testWidgetsWithLeakTracking
(
'positions itself at anchorAbove if it fits'
,
(
WidgetTester
tester
)
async
{
late
StateSetter
setState
;
const
double
height
=
_kToolbarHeight
;
const
double
height
=
50.0
;
const
double
anchorBelowY
=
500.0
;
double
anchorAboveY
=
0.0
;
const
double
paddingAbove
=
12.0
;
...
...
@@ -332,7 +332,7 @@ void main() {
});
await
tester
.
pump
();
toolbarY
=
tester
.
getTopLeft
(
findToolbar
()).
dy
;
expect
(
toolbarY
,
equals
(
anchorAboveY
-
height
-
_kToolbarContentDistance
));
expect
(
toolbarY
,
equals
(
anchorAboveY
-
height
+
_kToolbarArrowSize
.
height
-
_kToolbarContentDistance
));
},
skip:
kIsWeb
);
// [intended] We do not use Flutter-rendered context menu on the Web.
testWidgetsWithLeakTracking
(
'can create and use a custom toolbar'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -429,7 +429,7 @@ void main() {
testWidgetsWithLeakTracking
(
'draws a shadow below the toolbar in light mode'
,
(
WidgetTester
tester
)
async
{
late
StateSetter
setState
;
const
double
height
=
_kToolbarHeight
;
const
double
height
=
50.0
;
double
anchorAboveY
=
0.0
;
await
tester
.
pumpWidget
(
...
...
@@ -468,20 +468,15 @@ void main() {
),
);
// When the toolbar is below the content, the shadow hangs below the entire
// toolbar.
final
Finder
finder
=
find
.
descendant
(
of:
find
.
byType
(
CupertinoTextSelectionToolbar
),
matching:
find
.
byType
(
DecoratedBox
),
final
double
dividerWidth
=
1.0
/
tester
.
view
.
devicePixelRatio
;
expect
(
find
.
byType
(
CupertinoTextSelectionToolbar
),
paints
..
rrect
(
rrect:
RRect
.
fromLTRBR
(
8.0
,
515.0
,
158.0
+
2
*
dividerWidth
,
558.0
,
const
Radius
.
circular
(
8.0
)),
color:
const
Color
(
0x33000000
),
),
);
expect
(
finder
,
findsOneWidget
);
DecoratedBox
decoratedBox
=
tester
.
widget
(
finder
.
first
);
BoxDecoration
boxDecoration
=
decoratedBox
.
decoration
as
BoxDecoration
;
List
<
BoxShadow
>?
shadows
=
boxDecoration
.
boxShadow
;
expect
(
shadows
,
isNotNull
);
expect
(
shadows
,
hasLength
(
1
));
BoxShadow
shadow
=
boxDecoration
.
boxShadow
!.
first
;
expect
(
shadow
.
offset
.
dy
,
equals
(
7.0
));
// When the toolbar is above the content, the shadow sits around the arrow
// with no offset.
...
...
@@ -489,12 +484,13 @@ void main() {
anchorAboveY
=
80.0
;
});
await
tester
.
pump
();
decoratedBox
=
tester
.
widget
(
finder
.
first
);
boxDecoration
=
decoratedBox
.
decoration
as
BoxDecoration
;
shadows
=
boxDecoration
.
boxShadow
;
expect
(
shadows
,
isNotNull
);
expect
(
shadows
,
hasLength
(
1
));
shadow
=
boxDecoration
.
boxShadow
!.
first
;
expect
(
shadow
.
offset
.
dy
,
equals
(
0.0
));
expect
(
find
.
byType
(
CupertinoTextSelectionToolbar
),
paints
..
rrect
(
rrect:
RRect
.
fromLTRBR
(
8.0
,
29.0
,
158.0
+
2
*
dividerWidth
,
72.0
,
const
Radius
.
circular
(
8.0
)),
color:
const
Color
(
0x33000000
),
),
);
},
skip:
kIsWeb
);
// [intended] We do not use Flutter-rendered context menu on the Web.
}
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