Skip to content

Commit

Permalink
Merge pull request #18 from ValentinVignal/feat/horizontal-scrolling
Browse files Browse the repository at this point in the history
✨ [expandable_reorderable_list] Add `scrollDirection` parameter
GP4cK authored Aug 28, 2022
2 parents f4a3ca1 + 8396f34 commit 16ba552
Showing 6 changed files with 107 additions and 9 deletions.
12 changes: 8 additions & 4 deletions packages/expandable_reorderable_list/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
## 1.1.0

- Adds `scrollDirection` parameter.

## 1.0.0

- BREAKING: Replaces `SchedulerBinding.instance!` with `SchedulerBinding.instance`.

## 0.0.3

- Update the README to display gif examples.
- Updates the README to display gif examples.

## 0.0.2

- Provide a better documentation.
- Provides a better documentation.
- README.
- Add an example.
- Adds an example.

## 0.0.1

- Initial release.
- Initial release.
2 changes: 1 addition & 1 deletion packages/expandable_reorderable_list/example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0"
version: "1.1.0"
fake_async:
dependency: transitive
description:
Original file line number Diff line number Diff line change
@@ -92,6 +92,7 @@ class ExpandableReorderableList<K extends Key> extends StatefulWidget {
this.scrollController,
this.visibilityController,
this.modelsController,
this.scrollDirection = Axis.vertical,
Key? key,
}) : children = children ?? <ExpandableReorderableListItem<K>>[],
super(key: key);
@@ -131,6 +132,9 @@ class ExpandableReorderableList<K extends Key> extends StatefulWidget {
/// The model controller.
final ExpandableReorderableListItemModelController<K>? modelsController;

/// {@macro flutter.widgets.scroll_view.scrollDirection}
final Axis scrollDirection;

@override
_ExpandableReorderableListState<K> createState() =>
_ExpandableReorderableListState<K>();
@@ -376,13 +380,15 @@ class _ExpandableReorderableListState<K extends Key>
lead = _ExpandableReorderableListLeadTail(
key: const ObjectKey(_LeadTail.lead),
children: widget.leads,
axis: widget.scrollDirection,
);
}
tail = null;
if (widget.tails.isNotEmpty) {
tail = _ExpandableReorderableListLeadTail(
key: const ObjectKey(_LeadTail.tail),
children: widget.tails,
axis: widget.scrollDirection,
);
}
}
@@ -433,6 +439,7 @@ class _ExpandableReorderableListState<K extends Key>
child: SizeTransition(
sizeFactor: scaleAnimations[item.key]!,
child: item.builder(context, item.child, modelController),
axis: widget.scrollDirection,
),
);
}
@@ -456,11 +463,13 @@ class _ExpandableReorderableListState<K extends Key>
},
scrollController: widget.scrollController,
buildDefaultDragHandles: false,
scrollDirection: widget.scrollDirection,
)
: ListView.builder(
itemCount: itemCount,
itemBuilder: itemBuilder,
controller: widget.scrollController,
scrollDirection: widget.scrollDirection,
);
}
}
@@ -471,15 +480,25 @@ class _ExpandableReorderableListLeadTail extends StatelessWidget {
const _ExpandableReorderableListLeadTail({
required Key key,
this.children = const <Widget>[],
required this.axis,
}) : super(key: key);

/// The children.
final List<Widget> children;

/// The axis the leads or tails should be laid out.
final Axis axis;

@override
Widget build(BuildContext context) {
return Column(
children: children,
);
if (axis == Axis.vertical) {
return Column(
children: children,
);
} else {
return Row(
children: children,
);
}
}
}
2 changes: 1 addition & 1 deletion packages/expandable_reorderable_list/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ description: A wrapper around ReorderableListView that allows you to expand and
repository: https://github.com/Novade/flutter_packages/tree/master/packages/expandable_reorderable_list
issue_tracker: https://github.com/Novade/flutter_packages/issues

version: 1.0.0
version: 1.1.0

environment:
sdk: ">=2.12.0 <3.0.0"
Original file line number Diff line number Diff line change
@@ -76,6 +76,81 @@ void main() {
await tester.clearWidgetTree();
});

testWidgets(
'It should display a reorderable list scrollable in the horizontal direction',
(tester) async {
final widget = ExpandableReorderableList(
scrollDirection: Axis.horizontal,
children: [
ExpandableReorderableListItem(
child: Container(
color: Colors.red,
width: 50,
),
key: const Key('red'),
children: [
ExpandableReorderableListItem(
child: Container(
color: Colors.pink,
width: 50,
),
key: const Key('pink'),
),
ExpandableReorderableListItem(
child: Container(
color: Colors.purple,
width: 50,
),
key: const Key('purple'),
),
],
),
ExpandableReorderableListItem(
child: Container(
color: Colors.orange,
width: 50,
),
key: const Key('orange'),
children: [
ExpandableReorderableListItem(
child: Container(
color: Colors.yellow,
width: 50,
),
key: const Key('yellow'),
),
],
),
ExpandableReorderableListItem(
child: Container(
color: Colors.green,
width: 50,
),
key: const Key('green'),
),
],
onReorder: (_) {},
);
await tester.initWidgetTree();
await tester.pumpWidget(MaterialApp(home: widget));

expect(
find.byWidgetPredicate(
(widget) =>
widget is ReorderableListView &&
widget.header == null &&
widget.itemCount == 6,
),
findsOneWidget,
);
await expectLater(
find.byWidget(widget),
matchesGoldenFile(
'golden/expandable_reorderable_list_view.horizontal.png'));
await tester.clearWidgetTree();
},
);

testWidgets('It should display a list view when disabled', (tester) async {
final widget = MaterialApp(
home: ExpandableReorderableList(
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 16ba552

Please sign in to comment.