Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListView.reverse and GridView.reverse props #2335

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package/lib/src/controls/grid_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class _GridViewControlState extends State<GridViewControl> {
final runSpacing = widget.control.attrDouble("runSpacing", 10)!;
final padding = parseEdgeInsets(widget.control, "padding");
final childAspectRatio = widget.control.attrDouble("childAspectRatio", 1)!;
final reverse = widget.control.attrBool("reverse", false)!;

List<Control> visibleControls =
widget.children.where((c) => c.isVisible).toList();
Expand Down Expand Up @@ -84,6 +85,7 @@ class _GridViewControlState extends State<GridViewControl> {
Widget child = GridView.builder(
scrollDirection: horizontal ? Axis.horizontal : Axis.vertical,
controller: _controller,
reverse: reverse,
shrinkWrap: shrinkWrap,
padding: padding,
gridDelegate: gridDelegate,
Expand Down
3 changes: 3 additions & 0 deletions package/lib/src/controls/list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class _ListViewControlState extends State<ListViewControl> {
final firstItemPrototype =
widget.control.attrBool("firstItemPrototype", false)!;
final padding = parseEdgeInsets(widget.control, "padding");
final reverse = widget.control.attrBool("reverse", false)!;

List<Control> visibleControls =
widget.children.where((c) => c.isVisible).toList();
Expand All @@ -72,6 +73,7 @@ class _ListViewControlState extends State<ListViewControl> {
Widget child = spacing > 0
? ListView.separated(
controller: _controller,
reverse: reverse,
scrollDirection: horizontal ? Axis.horizontal : Axis.vertical,
shrinkWrap: shrinkWrap,
padding: padding,
Expand All @@ -94,6 +96,7 @@ class _ListViewControlState extends State<ListViewControl> {
)
: ListView.builder(
controller: _controller,
reverse: reverse,
scrollDirection: horizontal ? Axis.horizontal : Axis.vertical,
shrinkWrap: shrinkWrap,
padding: padding,
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/grid_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(
# ScrollableControl specific
#
auto_scroll: Optional[bool] = None,
reverse: Optional[bool] = None,
on_scroll_interval: OptionalNumber = None,
on_scroll: Any = None,
#
Expand Down Expand Up @@ -138,6 +139,7 @@ def __init__(
ScrollableControl.__init__(
self,
auto_scroll=auto_scroll,
reverse=reverse,
on_scroll_interval=on_scroll_interval,
on_scroll=on_scroll,
)
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __init__(
# ScrollableControl specific
#
auto_scroll: Optional[bool] = None,
reverse: Optional[bool] = None,
on_scroll_interval: OptionalNumber = None,
on_scroll: Any = None,
#
Expand Down Expand Up @@ -129,6 +130,7 @@ def __init__(
ScrollableControl.__init__(
self,
auto_scroll=auto_scroll,
reverse=reverse,
on_scroll_interval=on_scroll_interval,
on_scroll=on_scroll,
)
Expand Down
15 changes: 13 additions & 2 deletions sdk/python/packages/flet-core/src/flet_core/scrollable_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(
self,
scroll: Optional[ScrollMode] = None,
auto_scroll: Optional[bool] = None,
reverse: Optional[bool] = None,
on_scroll_interval: OptionalNumber = None,
on_scroll: Any = None,
):
Expand All @@ -26,6 +27,7 @@ def convert_on_scroll_event_data(e):

self.scroll = scroll
self.auto_scroll = auto_scroll
self.reverse = reverse
self.on_scroll_interval = on_scroll_interval
self.on_scroll = on_scroll

Expand Down Expand Up @@ -95,13 +97,22 @@ def __set_scroll(self, value: Optional[ScrollModeString]):

# auto_scroll
@property
def auto_scroll(self) -> Optional[bool]:
return self._get_attr("autoScroll")
def auto_scroll(self) -> Optional[str]:
return self._get_attr("autoScroll", data_type="bool", def_value=False)

@auto_scroll.setter
def auto_scroll(self, value: Optional[bool]):
self._set_attr("autoScroll", value)

# reverse
@property
def reverse(self) -> Optional[bool]:
return self._get_attr("reverse", data_type="bool", def_value=False)

@reverse.setter
def reverse(self, value: Optional[bool]):
self._set_attr("reverse", value)

# on_scroll_interval
@property
def on_scroll_interval(self) -> OptionalNumber:
Expand Down