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
069aabfe
Unverified
Commit
069aabfe
authored
Apr 03, 2019
by
Dan Field
Committed by
GitHub
Apr 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Draggable Scrollable sheet (#30058)
* Draggable Scrollable sheet
parent
3c9ffbca
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
581 additions
and
0 deletions
+581
-0
draggable_scrollable_sheet.dart
...s/flutter/lib/src/widgets/draggable_scrollable_sheet.dart
+375
-0
widgets.dart
packages/flutter/lib/widgets.dart
+1
-0
draggable_scrollable_sheet_test.dart
...flutter/test/widgets/draggable_scrollable_sheet_test.dart
+205
-0
No files found.
packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart
0 → 100644
View file @
069aabfe
This diff is collapsed.
Click to expand it.
packages/flutter/lib/widgets.dart
View file @
069aabfe
...
@@ -30,6 +30,7 @@ export 'src/widgets/container.dart';
...
@@ -30,6 +30,7 @@ export 'src/widgets/container.dart';
export
'src/widgets/debug.dart'
;
export
'src/widgets/debug.dart'
;
export
'src/widgets/dismissible.dart'
;
export
'src/widgets/dismissible.dart'
;
export
'src/widgets/drag_target.dart'
;
export
'src/widgets/drag_target.dart'
;
export
'src/widgets/draggable_scrollable_sheet.dart'
;
export
'src/widgets/editable_text.dart'
;
export
'src/widgets/editable_text.dart'
;
export
'src/widgets/fade_in_image.dart'
;
export
'src/widgets/fade_in_image.dart'
;
export
'src/widgets/focus_manager.dart'
;
export
'src/widgets/focus_manager.dart'
;
...
...
packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart
0 → 100644
View file @
069aabfe
// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
Widget
_boilerplate
(
VoidCallback
onButtonPressed
)
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Stack
(
children:
<
Widget
>[
FlatButton
(
child:
const
Text
(
'TapHere'
),
onPressed:
onButtonPressed
,
),
DraggableScrollableSheet
(
maxChildSize:
1.0
,
minChildSize:
.
25
,
builder:
(
BuildContext
context
,
ScrollController
scrollController
)
{
return
Container
(
color:
const
Color
(
0xFFABCDEF
),
child:
ListView
.
builder
(
controller:
scrollController
,
itemCount:
100
,
itemBuilder:
(
BuildContext
context
,
int
index
)
=>
Text
(
'Item
$index
'
),
),
);
},
),
],
),
);
}
for
(
TargetPlatform
platform
in
TargetPlatform
.
values
)
{
group
(
'
$platform
Scroll Physics'
,
()
{
debugDefaultTargetPlatformOverride
=
platform
;
testWidgets
(
'Can be dragged up without covering its container'
,
(
WidgetTester
tester
)
async
{
int
taps
=
0
;
await
tester
.
pumpWidget
(
_boilerplate
(()
=>
taps
++));
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
1
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 31'
),
findsNothing
);
await
tester
.
drag
(
find
.
text
(
'Item 1'
),
const
Offset
(
0
,
-
200
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
2
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 31'
),
findsOneWidget
);
});
testWidgets
(
'Can be dragged down when not full height'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_boilerplate
(
null
));
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 36'
),
findsNothing
);
await
tester
.
drag
(
find
.
text
(
'Item 1'
),
const
Offset
(
0
,
325
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsNothing
);
expect
(
find
.
text
(
'Item 36'
),
findsNothing
);
});
testWidgets
(
'Can be dragged up and cover its container and scroll in single motion, and then dragged back down'
,
(
WidgetTester
tester
)
async
{
int
taps
=
0
;
await
tester
.
pumpWidget
(
_boilerplate
(()
=>
taps
++));
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
1
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 36'
),
findsNothing
);
await
tester
.
drag
(
find
.
text
(
'Item 1'
),
const
Offset
(
0
,
-
325
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
1
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 36'
),
findsOneWidget
);
await
tester
.
dragFrom
(
const
Offset
(
20
,
20
),
const
Offset
(
0
,
325
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
2
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 18'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 36'
),
findsNothing
);
});
testWidgets
(
'Can be flung up gently'
,
(
WidgetTester
tester
)
async
{
int
taps
=
0
;
await
tester
.
pumpWidget
(
_boilerplate
(()
=>
taps
++));
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
1
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 36'
),
findsNothing
);
expect
(
find
.
text
(
'Item 70'
),
findsNothing
);
await
tester
.
fling
(
find
.
text
(
'Item 1'
),
const
Offset
(
0
,
-
200
),
350
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
2
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 36'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 70'
),
findsNothing
);
});
testWidgets
(
'Can be flung up'
,
(
WidgetTester
tester
)
async
{
int
taps
=
0
;
await
tester
.
pumpWidget
(
_boilerplate
(()
=>
taps
++));
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
1
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 70'
),
findsNothing
);
await
tester
.
fling
(
find
.
text
(
'Item 1'
),
const
Offset
(
0
,
-
200
),
2000
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
1
);
expect
(
find
.
text
(
'Item 1'
),
findsNothing
);
expect
(
find
.
text
(
'Item 21'
),
findsNothing
);
expect
(
find
.
text
(
'Item 70'
),
findsOneWidget
);
});
testWidgets
(
'Can be flung down when not full height'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_boilerplate
(
null
));
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 36'
),
findsNothing
);
await
tester
.
fling
(
find
.
text
(
'Item 1'
),
const
Offset
(
0
,
325
),
2000
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsNothing
);
expect
(
find
.
text
(
'Item 36'
),
findsNothing
);
});
testWidgets
(
'Can be flung up and then back down'
,
(
WidgetTester
tester
)
async
{
int
taps
=
0
;
await
tester
.
pumpWidget
(
_boilerplate
(()
=>
taps
++));
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
1
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 70'
),
findsNothing
);
await
tester
.
fling
(
find
.
text
(
'Item 1'
),
const
Offset
(
0
,
-
200
),
2000
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
1
);
expect
(
find
.
text
(
'Item 1'
),
findsNothing
);
expect
(
find
.
text
(
'Item 21'
),
findsNothing
);
expect
(
find
.
text
(
'Item 70'
),
findsOneWidget
);
await
tester
.
fling
(
find
.
text
(
'Item 70'
),
const
Offset
(
0
,
200
),
2000
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
1
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 70'
),
findsNothing
);
await
tester
.
fling
(
find
.
text
(
'Item 1'
),
const
Offset
(
0
,
200
),
2000
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'TapHere'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'TapHere'
));
expect
(
taps
,
2
);
expect
(
find
.
text
(
'Item 1'
),
findsOneWidget
);
expect
(
find
.
text
(
'Item 21'
),
findsNothing
);
expect
(
find
.
text
(
'Item 70'
),
findsNothing
);
});
debugDefaultTargetPlatformOverride
=
null
;
});
}
}
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