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
7b19b4d3
Unverified
Commit
7b19b4d3
authored
Dec 14, 2022
by
Tomasz Gucio
Committed by
GitHub
Dec 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CupertinoTextSelectionToolbar showing unnecessary pagination (#104587)
parent
d8b7eb6e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
text_selection_toolbar.dart
...ges/flutter/lib/src/cupertino/text_selection_toolbar.dart
+3
-2
text_selection_toolbar_test.dart
...s/flutter/test/cupertino/text_selection_toolbar_test.dart
+27
-0
No files found.
packages/flutter/lib/src/cupertino/text_selection_toolbar.dart
View file @
7b19b4d3
...
...
@@ -103,7 +103,7 @@ class CupertinoTextSelectionToolbar extends StatelessWidget {
/// default Cupertino toolbar.
final
CupertinoToolbarBuilder
toolbarBuilder
;
// Add the vis
i
al vertical line spacer between children buttons.
// Add the vis
u
al vertical line spacer between children buttons.
static
List
<
Widget
>
_addChildrenSpacers
(
List
<
Widget
>
children
)
{
final
List
<
Widget
>
nextChildren
=
<
Widget
>[];
for
(
int
i
=
0
;
i
<
children
.
length
;
i
++)
{
...
...
@@ -801,8 +801,9 @@ class _RenderCupertinoTextSelectionToolbarItems extends RenderBox with Container
double
paginationButtonsWidth
=
0.0
;
if
(
currentPage
==
0
)
{
// If this is the last child, it's ok to fit without a forward button.
// Note childCount doesn't include slotted children which come before the list ones.
paginationButtonsWidth
=
i
==
childCount
-
1
?
0.0
:
_nextButton
!.
size
.
width
;
i
==
childCount
+
2
?
0.0
:
_nextButton
!.
size
.
width
;
}
else
{
paginationButtonsWidth
=
subsequentPageButtonsWidth
;
}
...
...
packages/flutter/test/cupertino/text_selection_toolbar_test.dart
View file @
7b19b4d3
...
...
@@ -181,6 +181,33 @@ void main() {
expect
(
findOverflowBackButton
(),
findsNothing
);
},
skip:
kIsWeb
);
// [intended] We do not use Flutter-rendered context menu on the Web.
testWidgets
(
'does not paginate if children fit with zero margin'
,
(
WidgetTester
tester
)
async
{
final
List
<
Widget
>
children
=
List
<
Widget
>.
generate
(
7
,
(
int
i
)
=>
const
TestBox
());
final
double
spacerWidth
=
1.0
/
tester
.
binding
.
window
.
devicePixelRatio
;
final
double
dividerWidth
=
1.0
/
tester
.
binding
.
window
.
devicePixelRatio
;
const
double
borderRadius
=
8.0
;
// Should match _kToolbarBorderRadius
final
double
width
=
7
*
TestBox
.
itemWidth
+
6
*
(
dividerWidth
+
2
*
spacerWidth
)
+
2
*
borderRadius
;
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
child:
SizedBox
(
width:
width
,
child:
CupertinoTextSelectionToolbar
(
anchorAbove:
const
Offset
(
50.0
,
100.0
),
anchorBelow:
const
Offset
(
50.0
,
200.0
),
children:
children
,
),
),
),
),
);
// All children fit on the screen, so they are all rendered.
expect
(
find
.
byType
(
TestBox
),
findsNWidgets
(
children
.
length
));
expect
(
findOverflowNextButton
(),
findsNothing
);
expect
(
findOverflowBackButton
(),
findsNothing
);
},
skip:
kIsWeb
);
// [intended] We do not use Flutter-rendered context menu on the Web.
testWidgets
(
'positions itself at anchorAbove if it fits'
,
(
WidgetTester
tester
)
async
{
late
StateSetter
setState
;
const
double
height
=
_kToolbarHeight
;
...
...
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