Skip to content

Commit

Permalink
expand & collapse group (apache#23593)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhan.nausharipov committed Nov 9, 2022
1 parent 57800ee commit 28cb6b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ class ContentTreeController extends ChangeNotifier {
notifyListeners();
}

void updateExpandedIds(GroupModel group, {required bool isExpanding}) {
if (isExpanding) {
_expandedIds.add(group.id);
} else {
_expandedIds.remove(group.id);
}
void expandGroup(GroupModel group) {
_expandedIds.add(group.id);
notifyListeners();
}

void collapseGroup(GroupModel group) {
_expandedIds.remove(group.id);
notifyListeners();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ class _StatelessExpansionTile extends StatelessWidget {
initiallyExpanded: isExpanded,
tilePadding: EdgeInsets.zero,
onExpansionChanged: (isExpanding) {
contentTreeController.updateExpandedIds(
group,
isExpanding: isExpanding,
);
if (isExpanding) {
contentTreeController.expandGroup(group);
} else {
contentTreeController.collapseGroup(group);
}
},
title: GroupTitleWidget(
group: group,
Expand Down

0 comments on commit 28cb6b8

Please sign in to comment.