diff --git a/learning/tour-of-beam/frontend/lib/pages/tour/screen.dart b/learning/tour-of-beam/frontend/lib/pages/tour/screen.dart index ed6ede87182e..6372271c9459 100644 --- a/learning/tour-of-beam/frontend/lib/pages/tour/screen.dart +++ b/learning/tour-of-beam/frontend/lib/pages/tour/screen.dart @@ -36,7 +36,11 @@ class TourScreen extends StatelessWidget { @override Widget build(BuildContext context) { return TobScaffold( - pageActions: [TobPipelineOptionsDropdown(tourNotifier: tourNotifier)], + pageActions: [ + TobPipelineOptionsDropdown( + playgroundController: tourNotifier.playgroundController, + ), + ], child: MediaQuery.of(context).size.width > ScreenBreakpoints.twoColumns ? _WideTour(tourNotifier) : _NarrowTour(tourNotifier), diff --git a/learning/tour-of-beam/frontend/lib/pages/tour/state.dart b/learning/tour-of-beam/frontend/lib/pages/tour/state.dart index 54d183ea1f48..7afb8992662b 100644 --- a/learning/tour-of-beam/frontend/lib/pages/tour/state.dart +++ b/learning/tour-of-beam/frontend/lib/pages/tour/state.dart @@ -145,6 +145,7 @@ class TourNotifier extends ChangeNotifier with PageStateMixin { Future _setPlaygroundSnippet(String? snippetId) async { if (snippetId == null) { + playgroundController.setEmpty(); return; } diff --git a/learning/tour-of-beam/frontend/lib/pages/tour/widgets/pipeline_options.dart b/learning/tour-of-beam/frontend/lib/pages/tour/widgets/pipeline_options.dart index ad085e26dd57..38caf036adaf 100644 --- a/learning/tour-of-beam/frontend/lib/pages/tour/widgets/pipeline_options.dart +++ b/learning/tour-of-beam/frontend/lib/pages/tour/widgets/pipeline_options.dart @@ -19,33 +19,27 @@ import 'package:flutter/widgets.dart'; import 'package:playground_components/playground_components.dart'; -import '../state.dart'; - class TobPipelineOptionsDropdown extends StatelessWidget { - final TourNotifier tourNotifier; + final PlaygroundController playgroundController; - const TobPipelineOptionsDropdown({required this.tourNotifier}); + const TobPipelineOptionsDropdown({ + required this.playgroundController, + }); @override Widget build(BuildContext context) { - final controller = tourNotifier.playgroundController; - return AnimatedBuilder( - animation: tourNotifier, + animation: playgroundController, builder: (_, __) { - return AnimatedBuilder( - animation: controller, - builder: (_, __) { - if (!tourNotifier.isUnitContainsSnippet) { - return const SizedBox.shrink(); - } + if (playgroundController.isEmpty) { + return const SizedBox.shrink(); + } - return PipelineOptionsDropdown( - pipelineOptions: - controller.snippetEditingController?.pipelineOptions ?? '', - setPipelineOptions: controller.setPipelineOptions, - ); - }, + final pipelineOptions = + playgroundController.snippetEditingController?.pipelineOptions; + return PipelineOptionsDropdown( + pipelineOptions: pipelineOptions ?? '', + setPipelineOptions: playgroundController.setPipelineOptions, ); }, ); diff --git a/learning/tour-of-beam/frontend/lib/pages/tour/widgets/playground_demo.dart b/learning/tour-of-beam/frontend/lib/pages/tour/widgets/playground_demo.dart index 9a8ed8d1cc44..0d3311a76e7d 100644 --- a/learning/tour-of-beam/frontend/lib/pages/tour/widgets/playground_demo.dart +++ b/learning/tour-of-beam/frontend/lib/pages/tour/widgets/playground_demo.dart @@ -76,6 +76,7 @@ class PlaygroundDemoWidget extends StatelessWidget { } void _handleError(BuildContext context, PlaygroundController controller) { + //TODO: https://github.com/apache/beam/issues/26319 PlaygroundComponents.toastNotifier.add( Toast( description: controller.codeRunner.result?.errorMessage ?? '', diff --git a/playground/frontend/lib/pages/standalone_playground/widgets/editor_textarea_wrapper.dart b/playground/frontend/lib/pages/standalone_playground/widgets/editor_textarea_wrapper.dart index 552064498ea1..4f37edb6333a 100644 --- a/playground/frontend/lib/pages/standalone_playground/widgets/editor_textarea_wrapper.dart +++ b/playground/frontend/lib/pages/standalone_playground/widgets/editor_textarea_wrapper.dart @@ -82,6 +82,7 @@ class CodeTextAreaWrapper extends StatelessWidget { } void _handleError(BuildContext context, PlaygroundController controller) { + //TODO: https://github.com/apache/beam/issues/26319 PlaygroundComponents.toastNotifier.add( Toast( description: controller.codeRunner.result?.errorMessage ?? '', diff --git a/playground/frontend/playground_components/lib/src/constants/sizes.dart b/playground/frontend/playground_components/lib/src/constants/sizes.dart index bfa0e06897ac..06b693a7d660 100644 --- a/playground/frontend/playground_components/lib/src/constants/sizes.dart +++ b/playground/frontend/playground_components/lib/src/constants/sizes.dart @@ -42,7 +42,6 @@ class BeamSizes { static const double dividerHeight = 1; static const double elevation = 2; static const double headerButtonHeight = 46; - static const double labelFontSize = 16; static const double loadingIndicator = 40; static const double splitViewSeparator = BeamSizes.size8; static const double tabBarHeight = 50; diff --git a/playground/frontend/playground_components/lib/src/controllers/example_loaders/examples_loader.dart b/playground/frontend/playground_components/lib/src/controllers/example_loaders/examples_loader.dart index 75342c3ec0fe..22792ad4a52e 100644 --- a/playground/frontend/playground_components/lib/src/controllers/example_loaders/examples_loader.dart +++ b/playground/frontend/playground_components/lib/src/controllers/example_loaders/examples_loader.dart @@ -53,6 +53,10 @@ class ExamplesLoader { _playgroundController = value; } + void clearDescriptor() { + _descriptor = null; + } + /// Loads examples from [descriptor]'s immediate list. /// /// Sets empty editor for SDKs of failed examples. diff --git a/playground/frontend/playground_components/lib/src/controllers/playground_controller.dart b/playground/frontend/playground_components/lib/src/controllers/playground_controller.dart index e3fca592449c..11ecb5b7d931 100644 --- a/playground/frontend/playground_components/lib/src/controllers/playground_controller.dart +++ b/playground/frontend/playground_components/lib/src/controllers/playground_controller.dart @@ -35,6 +35,7 @@ import '../models/example_loading_descriptors/user_shared_example_loading_descri import '../models/intents.dart'; import '../models/sdk.dart'; import '../models/shortcut.dart'; +import '../models/snippet_file.dart'; import '../repositories/code_repository.dart'; import '../services/symbols/loaders/map.dart'; import '../services/symbols/symbols_notifier.dart'; @@ -128,6 +129,11 @@ class PlaygroundController with ChangeNotifier { selectedExample?.type != ExampleType.test && [Sdk.java, Sdk.python].contains(sdk); + bool get isEmpty => + selectedExample == null || + selectedExample?.path == '' && + (selectedExample?.files.contains(SnippetFile.empty) ?? false); + /// If no SDK is selected, sets it to [sdk] and creates an empty state for it. void setEmptyIfNoSdk(Sdk sdk) { if (_sdk != null) { @@ -141,6 +147,15 @@ class PlaygroundController with ChangeNotifier { ); } + void setEmpty() { + examplesLoader.clearDescriptor(); + setExample( + Example.empty(Sdk.java), + descriptor: const EmptyExampleLoadingDescriptor(sdk: Sdk.java), + setCurrentSdk: false, + ); + } + /// If the state for [sdk] does not exists, creates an empty state for it. void setEmptyIfNotExists( Sdk sdk, {