Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gemini/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ have_fun: false
code_review:
disable: false
# Set to -1 for unlimited comments.
max_review_comments: 6
max_review_comments: 20
# For now, use the default of MEDIUM for testing. Based on desired verbosity,
# we can change this to LOW or HIGH in the future.
comment_severity_threshold: MEDIUM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,10 @@ final checkboxFilterChipsInput = CatalogItem(
? selectedOptionsRef['path'] as String
: '${context.id}.value';

final ValueNotifier<List<Object?>?> notifier = context.dataContext
.subscribeToObjectArray({'path': path});

return ValueListenableBuilder<List<Object?>?>(
valueListenable: notifier,
builder: (buildContext, currentSelectedValues, child) {
return BoundList(
dataContext: context.dataContext,
value: {'path': path},
builder: (buildContext, currentSelectedValues) {
var effectiveSelections = currentSelectedValues;
if (effectiveSelections == null) {
if (selectedOptionsRef is List) {
Expand All @@ -145,7 +143,10 @@ final checkboxFilterChipsInput = CatalogItem(
icon: icon,
selectedOptions: selectedOptionsSet,
onChanged: (newSelectedOptions) {
context.dataContext.update(path, newSelectedOptions.toList());
context.dataContext.update(
DataPath(path),
newSelectedOptions.toList(),
);
},
);
},
Expand Down
12 changes: 5 additions & 7 deletions examples/travel_app/lib/src/catalog/date_input_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,17 @@ final dateInputChip = CatalogItem(
final path = value is Map && value.containsKey('path')
? value['path'] as String
: '${context.id}.value';
final ValueNotifier<String?> notifier = context.dataContext
.subscribeToString({'path': path});

return ValueListenableBuilder<String?>(
valueListenable: notifier,
builder: (buildContext, currentValue, child) {
return BoundString(
dataContext: context.dataContext,
value: {'path': path},
builder: (buildContext, currentValue) {
final String? effectiveValue =
currentValue ?? (value is String ? value : null);
return _DateInputChip(
initialValue: effectiveValue,
label: datePickerData.label,
onChanged: (newValue) {
context.dataContext.update(path, newValue);
context.dataContext.update(DataPath(path), newValue);
},
);
},
Expand Down
64 changes: 32 additions & 32 deletions examples/travel_app/lib/src/catalog/information_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,30 @@ final informationCard = CatalogItem(
? context.buildChild(cardData.imageChildId!)
: null;

final ValueNotifier<String?> titleNotifier = context.dataContext
.subscribeToString(cardData.title);
final ValueNotifier<String?> subtitleNotifier = context.dataContext
.subscribeToString(cardData.subtitle);
final ValueNotifier<String?> bodyNotifier = context.dataContext
.subscribeToString(cardData.body);

return _InformationCard(
imageChild: imageChild,
titleNotifier: titleNotifier,
subtitleNotifier: subtitleNotifier,
bodyNotifier: bodyNotifier,
title: cardData.title,
subtitle: cardData.subtitle,
body: cardData.body,
dataContext: context.dataContext,
);
},
);

class _InformationCard extends StatelessWidget {
const _InformationCard({
this.imageChild,
required this.titleNotifier,
required this.subtitleNotifier,
required this.bodyNotifier,
required this.title,
required this.subtitle,
required this.body,
required this.dataContext,
});

final Widget? imageChild;
final ValueNotifier<String?> titleNotifier;
final ValueNotifier<String?> subtitleNotifier;
final ValueNotifier<String?> bodyNotifier;
final Object title;
final Object? subtitle;
final Object body;
final DataContext dataContext;

@override
Widget build(BuildContext context) {
Expand All @@ -122,27 +118,31 @@ class _InformationCard extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ValueListenableBuilder<String?>(
valueListenable: titleNotifier,
builder: (context, title, _) => Text(
BoundString(
dataContext: dataContext,
value: title,
builder: (context, title) => Text(
title ?? '',
style: Theme.of(context).textTheme.headlineSmall,
),
),
ValueListenableBuilder<String?>(
valueListenable: subtitleNotifier,
builder: (context, subtitle, _) {
if (subtitle == null) return const SizedBox.shrink();
return Text(
subtitle,
style: Theme.of(context).textTheme.titleMedium,
);
},
),
if (subtitle != null)
BoundString(
dataContext: dataContext,
value: subtitle!,
builder: (context, subtitle) {
if (subtitle == null) return const SizedBox.shrink();
return Text(
subtitle,
style: Theme.of(context).textTheme.titleMedium,
);
},
),
const SizedBox(height: 8.0),
ValueListenableBuilder<String?>(
valueListenable: bodyNotifier,
builder: (context, body, _) =>
BoundString(
dataContext: dataContext,
value: body,
builder: (context, body) =>
MarkdownWidget(text: body ?? ''),
),
],
Expand Down
14 changes: 6 additions & 8 deletions examples/travel_app/lib/src/catalog/input_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ final inputGroup = CatalogItem(
itemContext.data as Map<String, Object?>,
);

final ValueNotifier<String?> notifier = itemContext.dataContext
.subscribeToString(inputGroupData.submitLabel);

final List<String> children = inputGroupData.children;
final JsonMap actionData = inputGroupData.action;
final event = actionData['event'] as JsonMap?;
Expand All @@ -127,12 +124,13 @@ final inputGroup = CatalogItem(
children: children.map(itemContext.buildChild).toList(),
),
const SizedBox(height: 16.0),
ValueListenableBuilder<String?>(
valueListenable: notifier,
builder: (builderContext, submitLabel, child) {
BoundString(
dataContext: itemContext.dataContext,
value: inputGroupData.submitLabel,
builder: (builderContext, submitLabel) {
return ElevatedButton(
onPressed: () {
final JsonMap resolvedContext = resolveContext(
onPressed: () async {
final JsonMap resolvedContext = await resolveContext(
itemContext.dataContext,
contextDefinition,
);
Expand Down
Loading