This is an automated email from the ASF dual-hosted git repository.

pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new c5fbe47  Merge pull request #16304 from [BEAM-13491] [Playground] 
Examples' catalog doesn't close after selecting example
c5fbe47 is described below

commit c5fbe47101ce81502b7d9f842c20dcf9e396f3df
Author: Alexandr Zhuravlev <alexander.zhurav...@akvelon.com>
AuthorDate: Wed Dec 22 02:45:32 2021 +0400

    Merge pull request #16304 from [BEAM-13491] [Playground] Examples' catalog 
doesn't close after selecting example
    
    * [BEAM-13491] Improved example catalog (now it's closing when you choose 
an example)
    
    * [BEAM-13491] Created closeDropdown function
---
 .../example_list/category_expansion_panel.dart         | 10 +++++++++-
 .../examples/components/example_list/example_list.dart |  6 ++++++
 .../components/example_list/expansion_panel_item.dart  | 16 +++++++++++++++-
 .../lib/modules/examples/example_selector.dart         | 18 ++++++++++++------
 4 files changed, 42 insertions(+), 8 deletions(-)

diff --git 
a/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart
 
b/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart
index f5e51a5..ec7278b4 100644
--- 
a/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart
+++ 
b/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart
@@ -26,11 +26,15 @@ import 
'package:playground/modules/examples/components/example_list/expansion_pa
 class CategoryExpansionPanel extends StatelessWidget {
   final String categoryName;
   final List examples;
+  final AnimationController animationController;
+  final OverlayEntry? dropdown;
 
   const CategoryExpansionPanel({
     Key? key,
     required this.categoryName,
     required this.examples,
+    required this.animationController,
+    required this.dropdown,
   }) : super(key: key);
 
   @override
@@ -70,7 +74,11 @@ class CategoryExpansionPanel extends StatelessWidget {
     List<Widget> items = [];
     for (var example in examples) {
       items.add(
-        ExpansionPanelItem(example: example),
+        ExpansionPanelItem(
+          example: example,
+          animationController: animationController,
+          dropdown: dropdown,
+        ),
       );
     }
     return items;
diff --git 
a/playground/frontend/lib/modules/examples/components/example_list/example_list.dart
 
b/playground/frontend/lib/modules/examples/components/example_list/example_list.dart
index 72c5172..e635181 100644
--- 
a/playground/frontend/lib/modules/examples/components/example_list/example_list.dart
+++ 
b/playground/frontend/lib/modules/examples/components/example_list/example_list.dart
@@ -23,10 +23,14 @@ import 'package:provider/provider.dart';
 
 class ExampleList extends StatelessWidget {
   final ScrollController controller;
+  final AnimationController animationController;
+  final OverlayEntry? dropdown;
 
   const ExampleList({
     Key? key,
     required this.controller,
+    required this.animationController,
+    required this.dropdown,
   }) : super(key: key);
 
   @override
@@ -44,6 +48,8 @@ class ExampleList extends StatelessWidget {
               itemBuilder: (context, index) => CategoryExpansionPanel(
                 categoryName: state.categories[index].name,
                 examples: state.categories[index].examples,
+                animationController: animationController,
+                dropdown: dropdown,
               ),
               controller: controller,
               shrinkWrap: true,
diff --git 
a/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart
 
b/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart
index 5f2c041..fead89b 100644
--- 
a/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart
+++ 
b/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart
@@ -26,8 +26,15 @@ import 'package:provider/provider.dart';
 
 class ExpansionPanelItem extends StatelessWidget {
   final ExampleModel example;
+  final AnimationController animationController;
+  final OverlayEntry? dropdown;
 
-  const ExpansionPanelItem({Key? key, required this.example}) : super(key: 
key);
+  const ExpansionPanelItem({
+    Key? key,
+    required this.example,
+    required this.animationController,
+    required this.dropdown,
+  }) : super(key: key);
 
   @override
   Widget build(BuildContext context) {
@@ -37,6 +44,7 @@ class ExpansionPanelItem extends StatelessWidget {
         child: GestureDetector(
           onTap: () async {
             if (playgroundState.selectedExample != example) {
+              closeDropdown(exampleState);
               final exampleWithInfo = await exampleState.loadExampleInfo(
                 example,
                 playgroundState.sdk,
@@ -60,4 +68,10 @@ class ExpansionPanelItem extends StatelessWidget {
       ),
     );
   }
+
+  void closeDropdown(ExampleState exampleState) {
+    animationController.reverse();
+    dropdown?.remove();
+    exampleState.changeSelectorVisibility();
+  }
 }
diff --git a/playground/frontend/lib/modules/examples/example_selector.dart 
b/playground/frontend/lib/modules/examples/example_selector.dart
index 259b7c3..3181c06 100644
--- a/playground/frontend/lib/modules/examples/example_selector.dart
+++ b/playground/frontend/lib/modules/examples/example_selector.dart
@@ -124,11 +124,7 @@ class _ExampleSelectorState extends State<ExampleSelector>
           builder: (context, exampleState, playgroundState, child) => Stack(
             children: [
               GestureDetector(
-                onTap: () {
-                  animationController.reverse();
-                  examplesDropdown?.remove();
-                  exampleState.changeSelectorVisibility();
-                },
+                onTap: () => closeDropdown(exampleState),
                 child: Container(
                   color: Colors.transparent,
                   height: double.infinity,
@@ -159,7 +155,11 @@ class _ExampleSelectorState extends State<ExampleSelector>
                           children: [
                             SearchField(controller: textController),
                             const TypeFilter(),
-                            ExampleList(controller: scrollController),
+                            ExampleList(
+                              controller: scrollController,
+                              animationController: animationController,
+                              dropdown: examplesDropdown,
+                            ),
                           ],
                         ),
                       ),
@@ -183,4 +183,10 @@ class _ExampleSelectorState extends State<ExampleSelector>
     );
     return positionModel;
   }
+
+  void closeDropdown(ExampleState exampleState) {
+    animationController.reverse();
+    examplesDropdown?.remove();
+    exampleState.changeSelectorVisibility();
+  }
 }

Reply via email to