Repository navigation
feat(a2ui_flutter): add the v0.9 basic catalog #3088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
74a8af4
feat(a2ui_flutter): add the framework adapter core
andrewkolos 8bafd53
feat(a2ui_core): expose the v0.9 basic catalog's API
andrewkolos aa0ad11
feat(a2ui_flutter): add the v0.9 basic catalog
andrewkolos 3ef0786
Merge remote-tracking branch 'upstream/main' into feat/flutter-adapte…
andrewkolos 46a9772
Merge branch 'feat/flutter-adapter-core' into feat/flutter-adapter-ba…
andrewkolos 71689fc
fix(a2ui_flutter): key a node's subtree by its implementation
andrewkolos bef448f
test(a2ui_flutter): cover A2uiSurface.of and maybeOf
andrewkolos f8edeaa
fix(a2ui_flutter): forward the basic catalog's protocol version and i…
andrewkolos 119846f
Merge branch 'feat/flutter-adapter-core' into feat/flutter-adapter-ba…
andrewkolos 7a97d94
refactor(a2ui_flutter): rename WidgetCatalog to CatalogImplementation
andrewkolos fab5147
Merge branch 'feat/flutter-adapter-core' into feat/flutter-adapter-ba…
andrewkolos 2685d4f
refactor(a2ui_flutter): use CatalogImplementation in the basic catalog
andrewkolos effca52
feat(a2ui_flutter): apply a component's accessibility label and descr…
andrewkolos c2e6d9a
Merge branch 'feat/flutter-adapter-core' into feat/flutter-adapter-ba…
andrewkolos c00d8a6
fix(a2ui_flutter): adopt a2ui_core's renderer renames
andrewkolos 8a9940c
Merge remote-tracking branch 'upstream/main' into feat/flutter-adapte…
andrewkolos e2dbf97
Merge branch 'fix/flutter-adapter-core-renames' into feat/flutter-ada…
andrewkolos 9979705
fix(a2ui_flutter): use the http Apache license URL
andrewkolos 6ca94a2
Merge branch 'fix/flutter-adapter-core-renames' into feat/flutter-ada…
andrewkolos 8018e80
Merge remote-tracking branch 'upstream/main' into feat/flutter-adapte…
andrewkolos 69c0ac8
docs(a2ui_flutter): match the README's a2ui_core constraint to the pu…
andrewkolos d855ffd
docs(a2ui_flutter): drop accessibility from the README's unsupported …
andrewkolos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,19 @@ | ||
| // Copyright 2024 Google LLC | ||
| // | ||
| // Licensed 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 | ||
| // | ||
| // https://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. | ||
|
|
||
| /// Implementations of the A2UI v0.9 basic catalog. | ||
| library; | ||
|
|
||
| export 'src/catalog/basic/basic_catalog.dart'; | ||
| export 'src/catalog/basic/markdown.dart'; |
This file contains hidden or 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,44 @@ | ||
| // Copyright 2024 Google LLC | ||
| // | ||
| // Licensed 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 | ||
| // | ||
| // https://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:a2ui_core/a2ui_core.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import '../../component_implementation.dart'; | ||
| import '../../component_props.dart'; | ||
| import 'media.dart'; | ||
|
|
||
| /// Builds the basic `AudioPlayer` component: its `description`, if any, above | ||
| /// playback controls for the audio at an `http` or `https` `url`. | ||
| Widget buildAudioPlayer( | ||
| BuildContext context, | ||
| ComponentNode<ComponentImplementation> node, | ||
| ComponentProps props, | ||
| ChildWidgetBuilder buildChild, | ||
| ) { | ||
| final String? description = props.string('description'); | ||
| return LimitedBox( | ||
| maxWidth: 300, | ||
| child: Column( | ||
| mainAxisSize: MainAxisSize.min, | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| spacing: 4, | ||
| children: [ | ||
| if (description != null && description.isNotEmpty) | ||
| Text(description, style: Theme.of(context).textTheme.bodySmall), | ||
| MediaPlayer(url: props.string('url')), | ||
| ], | ||
| ), | ||
| ); | ||
| } |
182 changes: 182 additions & 0 deletions
182
dart/a2ui_flutter/lib/src/catalog/basic/basic_catalog.dart
This file contains hidden or 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,182 @@ | ||
| // Copyright 2024 Google LLC | ||
| // | ||
| // Licensed 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 | ||
| // | ||
| // https://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:a2ui_core/a2ui_core.dart'; | ||
|
|
||
| import '../../component_implementation.dart'; | ||
| import 'audio_player.dart'; | ||
| import 'button.dart'; | ||
| import 'card.dart'; | ||
| import 'check_box.dart'; | ||
| import 'choice_picker.dart'; | ||
| import 'column.dart'; | ||
| import 'date_time_input.dart'; | ||
| import 'divider.dart'; | ||
| import 'icon.dart'; | ||
| import 'image.dart'; | ||
| import 'list.dart'; | ||
| import 'modal.dart'; | ||
| import 'row.dart'; | ||
| import 'slider.dart'; | ||
| import 'tabs.dart'; | ||
| import 'text.dart'; | ||
| import 'text_field.dart'; | ||
| import 'theme.dart'; | ||
| import 'video.dart'; | ||
|
|
||
| /// The v0.9 basic catalog: every basic component, and the functions of | ||
| /// [BasicCatalog.v0_9] formatting for [locale], under the basic catalog's id, | ||
| /// theme schema, title, description, protocol version and instructions. | ||
| /// | ||
| /// An `openUrl` call, which fails without [openUrl], may run whenever a bound | ||
| /// property resolves, not only on a tap. | ||
| CatalogImplementation basicCatalog({ | ||
| String locale = 'en-US', | ||
| OpenUrlCallback? openUrl, | ||
| }) => CatalogImplementation( | ||
| id: BasicCatalog.v0_9Id, | ||
| components: BasicComponents.all, | ||
| functions: BasicCatalog.v0_9( | ||
| locale: locale, | ||
| openUrl: openUrl, | ||
| ).functions.values.toList(), | ||
| themeSchema: BasicComponents.api.themeSchema, | ||
| schemaId: BasicComponents.api.schemaId, | ||
| title: BasicComponents.api.title, | ||
| description: BasicComponents.api.description, | ||
| protocolVersion: BasicComponents.api.protocolVersion, | ||
| instructions: BasicComponents.api.instructions, | ||
| definitions: BasicComponents.api.definitions, | ||
| ); | ||
|
|
||
| /// The v0.9 basic catalog's component implementations. | ||
| abstract final class BasicComponents { | ||
| /// The basic catalog's specification: every component and function schema | ||
| /// and the theme schema. | ||
| static final CatalogApi api = BasicCatalog.v0_9(); | ||
|
|
||
| /// The basic `AudioPlayer` component. | ||
| static final ComponentImplementation audioPlayer = _implement( | ||
| 'AudioPlayer', | ||
| buildAudioPlayer, | ||
| ); | ||
|
|
||
| /// The basic `Button` component. | ||
| static final ComponentImplementation button = _implement( | ||
| 'Button', | ||
| buildButton, | ||
| ); | ||
|
|
||
| /// The basic `Card` component. | ||
| static final ComponentImplementation card = _implement('Card', buildCard); | ||
|
|
||
| /// The basic `CheckBox` component. | ||
| static final ComponentImplementation checkBox = _implement( | ||
| 'CheckBox', | ||
| buildCheckBox, | ||
| ); | ||
|
|
||
| /// The basic `ChoicePicker` component. | ||
| static final ComponentImplementation choicePicker = _implement( | ||
| 'ChoicePicker', | ||
| buildChoicePicker, | ||
| ); | ||
|
|
||
| /// The basic `Column` component. | ||
| static final ComponentImplementation column = _implement( | ||
| 'Column', | ||
| buildColumn, | ||
| ); | ||
|
|
||
| /// The basic `DateTimeInput` component. | ||
| static final ComponentImplementation dateTimeInput = _implement( | ||
| 'DateTimeInput', | ||
| buildDateTimeInput, | ||
| ); | ||
|
|
||
| /// The basic `Divider` component. | ||
| static final ComponentImplementation divider = _implement( | ||
| 'Divider', | ||
| buildDivider, | ||
| ); | ||
|
|
||
| /// The basic `Icon` component. | ||
| static final ComponentImplementation icon = _implement('Icon', buildIcon); | ||
|
|
||
| /// The basic `Image` component. | ||
| static final ComponentImplementation image = _implement('Image', buildImage); | ||
|
|
||
| /// The basic `List` component. | ||
| static final ComponentImplementation list = _implement('List', buildList); | ||
|
|
||
| /// The basic `Modal` component. | ||
| static final ComponentImplementation modal = _implement('Modal', buildModal); | ||
|
|
||
| /// The basic `Row` component. | ||
| static final ComponentImplementation row = _implement('Row', buildRow); | ||
|
|
||
| /// The basic `Slider` component. | ||
| static final ComponentImplementation slider = _implement( | ||
| 'Slider', | ||
| buildSlider, | ||
| ); | ||
|
|
||
| /// The basic `Tabs` component. | ||
| static final ComponentImplementation tabs = _implement('Tabs', buildTabs); | ||
|
|
||
| /// The basic `Text` component. | ||
| static final ComponentImplementation text = _implement('Text', buildText); | ||
|
|
||
| /// The basic `TextField` component. | ||
| static final ComponentImplementation textField = _implement( | ||
| 'TextField', | ||
| buildTextField, | ||
| ); | ||
|
|
||
| /// The basic `Video` component. | ||
| static final ComponentImplementation video = _implement('Video', buildVideo); | ||
|
|
||
| /// Every basic component. | ||
| static List<ComponentImplementation> get all => [ | ||
| audioPlayer, | ||
| button, | ||
| card, | ||
| checkBox, | ||
| choicePicker, | ||
| column, | ||
| dateTimeInput, | ||
| divider, | ||
| icon, | ||
| image, | ||
| list, | ||
| modal, | ||
| row, | ||
| slider, | ||
| tabs, | ||
| text, | ||
| textField, | ||
| video, | ||
| ]; | ||
|
|
||
| static ComponentImplementation _implement( | ||
| String name, | ||
| ComponentWidgetBuilder builder, | ||
| ) => ComponentImplementation( | ||
| name: name, | ||
| schema: api.components[name]!.schema, | ||
| builder: (context, node, props, buildChild) => BasicTheme( | ||
| builder: (context) => builder(context, node, props, buildChild), | ||
| ), | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also forward
protocolVersionandinstructionsfromBasicComponents.apihere to matchBasicCatalog.v0_9()ina2ui_core?