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
722a085f
Unverified
Commit
722a085f
authored
Mar 31, 2021
by
Darren Austin
Committed by
GitHub
Mar 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly position the built-in drag handles on horizontal lists. (#79484)
parent
6fd2dcff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
19 deletions
+70
-19
reorderable_list.dart
packages/flutter/lib/src/material/reorderable_list.dart
+41
-18
reorderable_list_test.dart
packages/flutter/test/material/reorderable_list_test.dart
+29
-1
No files found.
packages/flutter/lib/src/material/reorderable_list.dart
View file @
722a085f
...
@@ -369,25 +369,48 @@ class _ReorderableListViewState extends State<ReorderableListView> {
...
@@ -369,25 +369,48 @@ class _ReorderableListViewState extends State<ReorderableListView> {
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
windows
:
case
TargetPlatform
.
windows
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
macOS
:
return
Stack
(
switch
(
widget
.
scrollDirection
)
{
key:
itemGlobalKey
,
case
Axis
.
horizontal
:
children:
<
Widget
>[
return
Stack
(
itemWithSemantics
,
key:
itemGlobalKey
,
Positioned
.
directional
(
children:
<
Widget
>[
textDirection:
Directionality
.
of
(
context
),
itemWithSemantics
,
top:
0
,
Positioned
.
directional
(
bottom:
0
,
textDirection:
Directionality
.
of
(
context
),
end:
8
,
start:
0
,
child:
Align
(
end:
0
,
alignment:
AlignmentDirectional
.
centerEnd
,
bottom:
8
,
child:
ReorderableDragStartListener
(
child:
Align
(
index:
index
,
alignment:
AlignmentDirectional
.
bottomCenter
,
child:
const
Icon
(
Icons
.
drag_handle
),
child:
ReorderableDragStartListener
(
index:
index
,
child:
const
Icon
(
Icons
.
drag_handle
),
),
),
),
),
),
],
),
);
],
case
Axis
.
vertical
:
);
return
Stack
(
key:
itemGlobalKey
,
children:
<
Widget
>[
itemWithSemantics
,
Positioned
.
directional
(
textDirection:
Directionality
.
of
(
context
),
top:
0
,
bottom:
0
,
end:
8
,
child:
Align
(
alignment:
AlignmentDirectional
.
centerEnd
,
child:
ReorderableDragStartListener
(
index:
index
,
child:
const
Icon
(
Icons
.
drag_handle
),
),
),
),
],
);
}
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
android
:
case
TargetPlatform
.
android
:
...
...
packages/flutter/test/material/reorderable_list_test.dart
View file @
722a085f
...
@@ -30,8 +30,14 @@ void main() {
...
@@ -30,8 +30,14 @@ void main() {
);
);
}
}
Widget
build
({
Widget
?
header
,
Axis
scrollDirection
=
Axis
.
vertical
,
TextDirection
textDirection
=
TextDirection
.
ltr
})
{
Widget
build
({
Widget
?
header
,
Axis
scrollDirection
=
Axis
.
vertical
,
TextDirection
textDirection
=
TextDirection
.
ltr
,
TargetPlatform
?
platform
,
})
{
return
MaterialApp
(
return
MaterialApp
(
theme:
ThemeData
(
platform:
platform
),
home:
Directionality
(
home:
Directionality
(
textDirection:
textDirection
,
textDirection:
textDirection
,
child:
SizedBox
(
child:
SizedBox
(
...
@@ -1309,6 +1315,28 @@ void main() {
...
@@ -1309,6 +1315,28 @@ void main() {
expect
(
getTestItemPosition
(),
startPosition
);
expect
(
getTestItemPosition
(),
startPosition
);
});
});
// TODO(djshuckerow): figure out how to write a test for scrolling the list.
// TODO(djshuckerow): figure out how to write a test for scrolling the list.
testWidgets
(
'Vertical list renders drag handle in correct position'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
build
(
platform:
TargetPlatform
.
macOS
));
final
Finder
listView
=
find
.
byType
(
ReorderableListView
);
final
Finder
item1
=
find
.
byKey
(
const
Key
(
'Item 1'
));
final
Finder
dragHandle
=
find
.
byIcon
(
Icons
.
drag_handle
).
first
;
// Should be centered vertically within the item and 8 pixels from the right edge of the list.
expect
(
tester
.
getCenter
(
dragHandle
).
dy
,
tester
.
getCenter
(
item1
).
dy
);
expect
(
tester
.
getTopRight
(
dragHandle
).
dx
,
tester
.
getSize
(
listView
).
width
-
8
);
});
testWidgets
(
'Horizontal list renders drag handle in correct position'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
build
(
scrollDirection:
Axis
.
horizontal
,
platform:
TargetPlatform
.
macOS
));
final
Finder
listView
=
find
.
byType
(
ReorderableListView
);
final
Finder
item1
=
find
.
byKey
(
const
Key
(
'Item 1'
));
final
Finder
dragHandle
=
find
.
byIcon
(
Icons
.
drag_handle
).
first
;
// Should be centered horizontally within the item and 8 pixels from the bottom of the list.
expect
(
tester
.
getCenter
(
dragHandle
).
dx
,
tester
.
getCenter
(
item1
).
dx
);
expect
(
tester
.
getBottomRight
(
dragHandle
).
dy
,
tester
.
getSize
(
listView
).
height
-
8
);
});
});
});
testWidgets
(
'ReorderableListView, can deal with the dragged item getting unmounted and rebuilt during drag'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ReorderableListView, can deal with the dragged item getting unmounted and rebuilt during drag'
,
(
WidgetTester
tester
)
async
{
...
...
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