-
Notifications
You must be signed in to change notification settings - Fork 59
Create data class CatalogItemContext and provide surfaceId to widgetBuilder. #491
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 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0181fd6
Update catalog_item.dart
polina-c ea05c87
-
polina-c 7fa32c3
-
polina-c b03ecb8
-
polina-c 033ce22
Update slider.dart
polina-c 6b4dbeb
-
polina-c ea563b6
-
polina-c ce4982f
-
polina-c 78bf216
-
polina-c a15f73a
-
polina-c e6bf307
-
polina-c 86fbfcc
Update travel_carousel_test.dart
polina-c e908abc
-
polina-c bace9b2
-
polina-c 6bda331
-
polina-c 69d9ea4
-
polina-c 10a7b8e
Update image.dart
polina-c 20246c3
Update catalog_item.dart
polina-c 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
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 |
|---|---|---|
|
|
@@ -118,71 +118,64 @@ final inputGroup = CatalogItem( | |
| ], | ||
| name: 'InputGroup', | ||
| dataSchema: _schema, | ||
| widgetBuilder: | ||
| ({ | ||
| required data, | ||
| required id, | ||
| required buildChild, | ||
| required dispatchEvent, | ||
| required context, | ||
| required dataContext, | ||
| required getComponent, | ||
| }) { | ||
| final inputGroupData = _InputGroupData.fromMap( | ||
| data as Map<String, Object?>, | ||
| ); | ||
| widgetBuilder: (context) { | ||
| final inputGroupData = _InputGroupData.fromMap( | ||
| context.data as Map<String, Object?>, | ||
| ); | ||
|
|
||
| final notifier = dataContext.subscribeToString( | ||
| inputGroupData.submitLabel, | ||
| ); | ||
| final notifier = context.dataContext.subscribeToString( | ||
| inputGroupData.submitLabel, | ||
| ); | ||
|
|
||
| final children = inputGroupData.children; | ||
| final actionData = inputGroupData.action; | ||
| final name = actionData['name'] as String; | ||
| final contextDefinition = | ||
| (actionData['context'] as List<Object?>?) ?? <Object?>[]; | ||
| final children = inputGroupData.children; | ||
| final actionData = inputGroupData.action; | ||
| final name = actionData['name'] as String; | ||
| final contextDefinition = | ||
| (actionData['context'] as List<Object?>?) ?? <Object?>[]; | ||
|
|
||
| return Card( | ||
| color: Theme.of(context).colorScheme.primaryContainer, | ||
| child: Padding( | ||
| padding: const EdgeInsets.all(8.0), | ||
| child: Column( | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| Wrap( | ||
| runSpacing: 16.0, | ||
| spacing: 8.0, | ||
| children: children.map(buildChild).toList(), | ||
| ), | ||
| const SizedBox(height: 16.0), | ||
| ValueListenableBuilder<String?>( | ||
| valueListenable: notifier, | ||
| builder: (context, submitLabel, child) { | ||
| return ElevatedButton( | ||
| onPressed: () { | ||
| final resolvedContext = resolveContext( | ||
| dataContext, | ||
| contextDefinition, | ||
| ); | ||
| dispatchEvent( | ||
| UserActionEvent( | ||
| name: name, | ||
| sourceComponentId: id, | ||
| context: resolvedContext, | ||
| ), | ||
| ); | ||
| }, | ||
| child: Text(submitLabel ?? ''), | ||
| style: ElevatedButton.styleFrom( | ||
| backgroundColor: Theme.of(context).colorScheme.primary, | ||
| foregroundColor: Colors.white, | ||
| return Card( | ||
| color: Theme.of(context.buildContext).colorScheme.primaryContainer, | ||
| child: Padding( | ||
| padding: const EdgeInsets.all(8.0), | ||
| child: Column( | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| Wrap( | ||
| runSpacing: 16.0, | ||
| spacing: 8.0, | ||
| children: children.map(context.buildChild).toList(), | ||
| ), | ||
| const SizedBox(height: 16.0), | ||
| ValueListenableBuilder<String?>( | ||
| valueListenable: notifier, | ||
| builder: (builderContext, submitLabel, child) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return ElevatedButton( | ||
| onPressed: () { | ||
| final resolvedContext = resolveContext( | ||
| context.dataContext, | ||
| contextDefinition, | ||
| ); | ||
| context.dispatchEvent( | ||
| UserActionEvent( | ||
| name: name, | ||
| sourceComponentId: context.id, | ||
| context: resolvedContext, | ||
| ), | ||
| ); | ||
| }, | ||
| ), | ||
| ], | ||
| child: Text(submitLabel ?? ''), | ||
| style: ElevatedButton.styleFrom( | ||
| backgroundColor: Theme.of( | ||
| builderContext, | ||
| ).colorScheme.primary, | ||
| foregroundColor: Colors.white, | ||
| ), | ||
| ); | ||
| }, | ||
| ), | ||
| ), | ||
| ); | ||
| }, | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| }, | ||
| ); | ||
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.
Because
contextusually refers to aBuildContext, can we change the name of this to be "catalogItemContext" or something else that is specific so people reading this can tell it's not aBuildContext?I think this will also help later where you have to come up with other names for the build context: you can go back to calling it
context, and the catalog item one can be something else. MaybeitemContext?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.
itemContext sounds good!
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.
I renamed it in main signature
will rename in other places in next PR