nausharipov commented on code in PR #23532:
URL: https://github.com/apache/beam/pull/23532#discussion_r990765733


##########
playground/frontend/lib/pages/playground/states/example_selector_state.dart:
##########
@@ -22,27 +22,61 @@ import 
'package:playground_components/playground_components.dart';
 class ExampleSelectorState with ChangeNotifier {
   final PlaygroundController _playgroundController;
   ExampleType _selectedFilterType;
-  String _filterText;
+  String _searchText;
   List<CategoryWithExamples> categories;
+  List<String> tags = [];
+  List<String> selectedTags = [];
 
   ExampleSelectorState(
     this._playgroundController,
     this.categories, [
     this._selectedFilterType = ExampleType.all,
-    this._filterText = '',
-  ]);
+    this._searchText = '',
+  ]) {
+    tags = _getTagsSortedByPopularity(categories);
+  }
 
   ExampleType get selectedFilterType => _selectedFilterType;
 
-  String get filterText => _filterText;
+  String get searchText => _searchText;
 
   void setSelectedFilterType(ExampleType type) {
     _selectedFilterType = type;
     notifyListeners();
   }
 
-  void setFilterText(String text) {
-    _filterText = text;
+  void addSelectedTag(String tag) {
+    selectedTags.add(tag);
+    notifyListeners();
+  }
+
+  void removeSelectedTag(String tag) {
+    selectedTags.remove(tag);
+    notifyListeners();
+  }
+
+  List<String> _getTagsSortedByPopularity(
+    List<CategoryWithExamples> categories,
+  ) {
+    Map<String, int> tagsPopularity = {};
+    for (var category in categories) {
+      for (var example in category.examples) {
+        for (var tag in example.tags) {
+          if (tagsPopularity[tag] != null) {

Review Comment:
   Saved parentheses for readability. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to