forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract playground components to a separate package (apache#22600)
- Loading branch information
1 parent
ad2d51d
commit 0ac6513
Showing
232 changed files
with
4,459 additions
and
4,768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
learning/tour-of-beam/frontend/lib/components/split_view/widget.dart
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
learning/tour-of-beam/frontend/lib/pages/tour/playground_demo.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:playground_components/playground_components.dart'; | ||
|
||
const String kApiClientURL = | ||
'https://backend-router-beta-dot-apache-beam-testing.appspot.com'; | ||
const String kApiJavaClientURL = | ||
'https://backend-java-beta-dot-apache-beam-testing.appspot.com'; | ||
const String kApiGoClientURL = | ||
'https://backend-go-beta-dot-apache-beam-testing.appspot.com'; | ||
const String kApiPythonClientURL = | ||
'https://backend-python-beta-dot-apache-beam-testing.appspot.com'; | ||
const String kApiScioClientURL = | ||
'https://backend-scio-beta-dot-apache-beam-testing.appspot.com'; | ||
|
||
class PlaygroundDemoWidget extends StatefulWidget { | ||
const PlaygroundDemoWidget({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<PlaygroundDemoWidget> createState() => _PlaygroundDemoWidgetState(); | ||
} | ||
|
||
class _PlaygroundDemoWidgetState extends State<PlaygroundDemoWidget> { | ||
late final PlaygroundController playgroundController; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
final exampleRepository = ExampleRepository( | ||
client: GrpcExampleClient(url: kApiClientURL), | ||
); | ||
|
||
final codeRepository = CodeRepository( | ||
client: GrpcCodeClient( | ||
url: kApiClientURL, | ||
runnerUrlsById: { | ||
Sdk.java.id: kApiJavaClientURL, | ||
Sdk.go.id: kApiGoClientURL, | ||
Sdk.python.id: kApiPythonClientURL, | ||
Sdk.scio.id: kApiScioClientURL, | ||
}, | ||
), | ||
); | ||
|
||
final exampleCache = ExampleCache( | ||
exampleRepository: exampleRepository, | ||
hasCatalog: true, | ||
); | ||
|
||
playgroundController = PlaygroundController( | ||
codeRepository: codeRepository, | ||
exampleCache: exampleCache, | ||
examplesLoader: ExamplesLoader(), | ||
); | ||
|
||
playgroundController.examplesLoader.load( | ||
ExamplesLoadingDescriptor( | ||
descriptors: [ | ||
CatalogDefaultExampleLoadingDescriptor(sdk: Sdk.java), | ||
], | ||
//initialSdk: Sdk.java, | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AnimatedBuilder( | ||
animation: playgroundController, | ||
builder: _buildOnChange, | ||
); | ||
} | ||
|
||
Widget _buildOnChange(BuildContext context, Widget? child) { | ||
final snippetController = playgroundController.snippetEditingController; | ||
if (snippetController == null) { | ||
return const LoadingIndicator(); | ||
} | ||
|
||
return Stack( | ||
children: [ | ||
SplitView( | ||
direction: Axis.vertical, | ||
first: SnippetEditor( | ||
controller: snippetController, | ||
isEditable: true, | ||
goToContextLine: false, | ||
), | ||
second: OutputWidget( | ||
playgroundController: playgroundController, | ||
graphDirection: Axis.horizontal, | ||
), | ||
), | ||
Positioned( | ||
top: 30, | ||
right: 30, | ||
child: Row( | ||
children: [ | ||
RunOrCancelButton(playgroundController: playgroundController), | ||
], | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.