From 28cb6b8045409c6fd0915eedb89562c576cbd427 Mon Sep 17 00:00:00 2001 From: "darkhan.nausharipov" Date: Wed, 9 Nov 2022 16:09:02 +0600 Subject: [PATCH] expand & collapse group (#23593) --- .../lib/pages/tour/controllers/content_tree.dart | 13 +++++++------ .../frontend/lib/pages/tour/widgets/group.dart | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/learning/tour-of-beam/frontend/lib/pages/tour/controllers/content_tree.dart b/learning/tour-of-beam/frontend/lib/pages/tour/controllers/content_tree.dart index 9977cd3c5178..bfa63c94df4f 100644 --- a/learning/tour-of-beam/frontend/lib/pages/tour/controllers/content_tree.dart +++ b/learning/tour-of-beam/frontend/lib/pages/tour/controllers/content_tree.dart @@ -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(); } diff --git a/learning/tour-of-beam/frontend/lib/pages/tour/widgets/group.dart b/learning/tour-of-beam/frontend/lib/pages/tour/widgets/group.dart index d773ad9b40bb..67c3f9528599 100644 --- a/learning/tour-of-beam/frontend/lib/pages/tour/widgets/group.dart +++ b/learning/tour-of-beam/frontend/lib/pages/tour/widgets/group.dart @@ -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,