Skip to content

Commit

Permalink
feat: build DocumentTokenValueTile inside DocumentPropertyBuilderWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-molinski committed Jan 2, 2025
1 parent 395f2e2 commit 2433704
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:flutter/material.dart';

class DocumentPropertyTopBar extends StatelessWidget {
final String title;
final String? title;
final bool isEditMode;
final VoidCallback? onToggleEditMode;

const DocumentPropertyTopBar({
super.key,
required this.title,
this.title,
required this.isEditMode,
this.onToggleEditMode,
});
Expand All @@ -20,7 +20,7 @@ class DocumentPropertyTopBar extends StatelessWidget {
children: [
Expanded(
child: Text(
title,
title ?? '',
style: Theme.of(context).textTheme.titleMedium,
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:catalyst_voices/widgets/document_builder/document_token_value_tile.dart';
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:flutter/material.dart';

Expand All @@ -6,13 +7,19 @@ class DocumentPropertyBuilderWidget extends StatelessWidget {
/// A single field of the document that belongs to a section.
final DocumentProperty property;

// TODO(damian-molinski): Should come from SectionsController in context
// of ProposalBuilder.
/// Whether this property should be highlighted as selected.
final bool isSelected;

/// A callback that should be called with the latest [DocumentChange]
/// for the edited [property] when the user wants to save the changes.
final ValueChanged<DocumentChange> onChanged;

const DocumentPropertyBuilderWidget({
super.key,
required this.property,
this.isSelected = false,
required this.onChanged,
});

Expand All @@ -33,7 +40,18 @@ class DocumentPropertyBuilderWidget extends StatelessWidget {
SingleGroupedTagSelectorDefinition() => throw UnimplementedError(),
TagGroupDefinition() => throw UnimplementedError(),
TagSelectionDefinition() => throw UnimplementedError(),
TokenValueCardanoADADefinition() => throw UnimplementedError(),
TokenValueCardanoADADefinition() => DocumentTokenValueTile(
key: ObjectKey(property.schema.nodeId),
id: property.schema.nodeId,
title: property.schema.title,
description: property.schema.description,
initialValue: property.value is int ? property.value! as int : null,
currency: const Currency.ada(),
range: property.schema.range,
isSelected: isSelected,
isRequired: property.schema.isRequired,
onChanged: onChanged,
),
DurationInMonthsDefinition() => throw UnimplementedError(),
YesNoChoiceDefinition() => throw UnimplementedError(),
AgreementConfirmationDefinition() => throw UnimplementedError(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:flutter/material.dart';
class DocumentTokenValueTile extends StatefulWidget {
final DocumentNodeId id;
final String title;
final String description;
final String? description;
final int? initialValue;
final Currency currency;
final Range<int>? range;
Expand All @@ -23,7 +23,7 @@ class DocumentTokenValueTile extends StatefulWidget {
super.key,
required this.id,
required this.title,
required this.description,
this.description,
this.initialValue,
required this.currency,
this.range,
Expand Down

0 comments on commit 2433704

Please sign in to comment.