Commit 1ec625ff authored by Adam Barth's avatar Adam Barth Committed by GitHub

Remove PageableList (#7997)

All clients have moved to PageView.
parent b4ec00c2
......@@ -170,7 +170,7 @@ final List<GalleryItem> kAllGalleryItems = <GalleryItem>[
),
new GalleryItem(
title: 'Page selector',
subtitle: 'Pageable list with indicator',
subtitle: 'PageView with indicator',
routeName: PageSelectorDemo.routeName,
buildRoute: (BuildContext context) => new PageSelectorDemo()
),
......
......@@ -590,13 +590,13 @@ class _TabBarState extends State<TabBar> {
}
}
/// A pageable list that displays the widget which corresponds to the currently
/// A page view that displays the widget which corresponds to the currently
/// selected tab. Typically used in conjuction with a [TabBar].
///
/// If a [TabController] is not provided, then there must be a [DefaultTabController]
/// ancestor.
class TabBarView extends StatefulWidget {
/// Creates a pageable list with one child per tab.
/// Creates a page view with one child per tab.
///
/// The length of [children] must be the same as the [controller]'s length.
TabBarView({
......@@ -744,7 +744,7 @@ class _TabBarViewState extends State<TabBarView> {
if (integralScrollOffset == _pageController.page) {
_offsetBias = 0.0;
// The animation duration is short since the tab indicator and this
// pageable list have already moved.
// page view have already moved.
_controller.animateTo(
integralScrollOffset.floor(),
duration: const Duration(milliseconds: 30)
......
This diff is collapsed.
......@@ -1239,7 +1239,6 @@ class ScrollNotification extends Notification {
///
/// * [Block], if your single child is a [Column].
/// * [ScrollableList], if you have many identically-sized children.
/// * [PageableList], if you have children that each take the entire screen.
/// * [ScrollableGrid], if your children are in a grid pattern.
/// * [LazyBlock], if you have many children of varying sizes.
class ScrollableViewport extends StatelessWidget {
......
......@@ -287,7 +287,7 @@ class _IterableWidgetProvider extends _WidgetProvider {
/// Signature of a callback that returns the sublist of widgets in the given range.
///
/// Used by [PageableList.itemBuilder], [ScrollableLazyList.itemBuilder], etc.
/// Used by [ScrollableLazyList.itemBuilder], etc.
typedef List<Widget> ItemListBuilder(BuildContext context, int start, int count);
/// A VirtualViewport that represents its children using [ItemListBuilder].
......
......@@ -40,7 +40,6 @@ export 'src/widgets/overlay.dart';
export 'src/widgets/overscroll_indicator.dart';
export 'src/widgets/page_storage.dart';
export 'src/widgets/page_view.dart';
export 'src/widgets/pageable_list.dart';
export 'src/widgets/pages.dart';
export 'src/widgets/performance_overlay.dart';
export 'src/widgets/placeholder.dart';
......
......@@ -21,23 +21,22 @@ Widget buildPage(int page) {
}
Widget buildFrame({
bool itemsWrap: false,
ViewportAnchor scrollAnchor: ViewportAnchor.start,
bool reverse: false,
List<int> pages: defaultPages
}) {
final PageableList list = new PageableList(
children: pages.map(buildPage),
itemsWrap: itemsWrap,
final PageView child = new PageView(
scrollDirection: Axis.horizontal,
scrollAnchor: scrollAnchor,
onPageChanged: (int page) { currentPage = page; }
reverse: reverse,
onPageChanged: (int page) { currentPage = page; },
children: pages.map(buildPage).toList(),
);
// The test framework forces the frame to be 800x600, so we need to create
// an outer container where we can change the size.
return new Center(
child: new Container(
width: pageSize.width, height: pageSize.height, child: list)
width: pageSize.width, height: pageSize.height, child: child,
),
);
}
......@@ -45,9 +44,8 @@ Future<Null> page(WidgetTester tester, Offset offset) {
return TestAsyncUtils.guard(() async {
String itemText = currentPage != null ? currentPage.toString() : '0';
await tester.scroll(find.text(itemText), offset);
// One frame to start the animation, a second to complete it.
await tester.pump();
await tester.pump(const Duration(seconds: 1));
await tester.pumpUntilNoTransientCallbacks();
});
}
......@@ -60,11 +58,11 @@ Future<Null> pageRight(WidgetTester tester) {
}
void main() {
testWidgets('PageableList default control', (WidgetTester tester) async {
await tester.pumpWidget(new Center(child: new PageableList()));
testWidgets('PageView default control', (WidgetTester tester) async {
await tester.pumpWidget(new Center(child: new PageView()));
});
testWidgets('PageableList with itemsWrap: false', (WidgetTester tester) async {
testWidgets('PageView control test', (WidgetTester tester) async {
currentPage = null;
await tester.pumpWidget(buildFrame());
expect(currentPage, isNull);
......@@ -92,74 +90,18 @@ void main() {
expect(currentPage, equals(0));
});
testWidgets('PageableList with end scroll anchor', (WidgetTester tester) async {
currentPage = 5;
await tester.pumpWidget(buildFrame(scrollAnchor: ViewportAnchor.end));
await pageRight(tester);
expect(currentPage, equals(4));
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsNothing);
expect(find.text('2'), findsNothing);
expect(find.text('3'), findsNothing);
expect(find.text('4'), findsOneWidget);
expect(find.text('5'), findsNothing);
await pageLeft(tester);
expect(currentPage, equals(5));
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsNothing);
expect(find.text('2'), findsNothing);
expect(find.text('3'), findsNothing);
expect(find.text('4'), findsNothing);
expect(find.text('5'), findsOneWidget);
await pageLeft(tester);
expect(currentPage, equals(5));
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsNothing);
expect(find.text('2'), findsNothing);
expect(find.text('3'), findsNothing);
expect(find.text('4'), findsNothing);
expect(find.text('5'), findsOneWidget);
});
testWidgets('PageableList with itemsWrap: true', (WidgetTester tester) async {
testWidgets('PageView with reverse', (WidgetTester tester) async {
currentPage = null;
await tester.pumpWidget(buildFrame(itemsWrap: true));
expect(currentPage, isNull);
await pageLeft(tester);
expect(currentPage, equals(1));
await pageRight(tester);
expect(currentPage, equals(0));
await pageRight(tester);
expect(currentPage, equals(5));
});
testWidgets('PageableList with end and itemsWrap: true', (WidgetTester tester) async {
currentPage = 5;
await tester.pumpWidget(buildFrame(itemsWrap: true, scrollAnchor: ViewportAnchor.end));
await tester.pumpWidget(buildFrame(reverse: true));
await pageRight(tester);
expect(currentPage, equals(4));
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsNothing);
expect(find.text('2'), findsNothing);
expect(find.text('3'), findsNothing);
expect(find.text('4'), findsOneWidget);
expect(find.text('5'), findsNothing);
await pageLeft(tester);
expect(currentPage, equals(5));
expect(currentPage, equals(1));
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsNothing);
expect(find.text('1'), findsOneWidget);
expect(find.text('2'), findsNothing);
expect(find.text('3'), findsNothing);
expect(find.text('4'), findsNothing);
expect(find.text('5'), findsOneWidget);
expect(find.text('5'), findsNothing);
await pageLeft(tester);
expect(currentPage, equals(0));
......@@ -172,71 +114,13 @@ void main() {
expect(find.text('5'), findsNothing);
await pageLeft(tester);
expect(currentPage, equals(1));
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
expect(find.text('2'), findsNothing);
expect(find.text('3'), findsNothing);
expect(find.text('4'), findsNothing);
expect(find.text('5'), findsNothing);
});
testWidgets('PageableList with two items', (WidgetTester tester) async {
currentPage = null;
await tester.pumpWidget(buildFrame(itemsWrap: true, pages: <int>[0, 1]));
expect(currentPage, isNull);
await pageLeft(tester);
expect(currentPage, equals(1));
await pageRight(tester);
expect(currentPage, equals(0));
await pageRight(tester);
expect(currentPage, equals(1));
});
testWidgets('PageableList with one item', (WidgetTester tester) async {
currentPage = null;
await tester.pumpWidget(buildFrame(itemsWrap: true, pages: <int>[0]));
expect(currentPage, isNull);
await pageLeft(tester);
expect(currentPage, equals(0));
await pageRight(tester);
expect(currentPage, equals(0));
await pageRight(tester);
expect(currentPage, equals(0));
});
testWidgets('PageableList with no items', (WidgetTester tester) async {
currentPage = null;
await tester.pumpWidget(buildFrame(itemsWrap: true, pages: <int>[]));
expect(currentPage, isNull);
});
testWidgets('PageableList resize parent', (WidgetTester tester) async {
await tester.pumpWidget(new Container());
currentPage = null;
await tester.pumpWidget(buildFrame(itemsWrap: true));
expect(currentPage, isNull);
await pageRight(tester);
expect(currentPage, equals(5));
Size boxSize = globalKeys[5].currentContext.size;
expect(boxSize.width, equals(pageSize.width));
expect(boxSize.height, equals(pageSize.height));
pageSize = new Size(pageSize.height, pageSize.width);
await tester.pumpWidget(buildFrame(itemsWrap: true));
expect(find.text('0'), findsNothing);
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
expect(find.text('2'), findsNothing);
expect(find.text('3'), findsNothing);
expect(find.text('4'), findsNothing);
expect(find.text('5'), findsOneWidget);
boxSize = globalKeys[5].currentContext.size;
expect(boxSize.width, equals(pageSize.width));
expect(boxSize.height, equals(pageSize.height));
expect(find.text('5'), findsNothing);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment