From dfa8011a5b8a6b3f867cf4b4072087f6fda449df Mon Sep 17 00:00:00 2001 From: Dominik Toton Date: Thu, 16 Jan 2025 14:39:07 +0100 Subject: [PATCH] chore: cleanup --- .../tiles/document_builder_section_tile.dart | 7 ++--- .../property/document_property_schema.dart | 29 +++++++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/catalyst_voices/apps/voices/lib/widgets/tiles/document_builder_section_tile.dart b/catalyst_voices/apps/voices/lib/widgets/tiles/document_builder_section_tile.dart index 360a950f0a8..fb3123584ef 100644 --- a/catalyst_voices/apps/voices/lib/widgets/tiles/document_builder_section_tile.dart +++ b/catalyst_voices/apps/voices/lib/widgets/tiles/document_builder_section_tile.dart @@ -105,7 +105,6 @@ class _DocumentBuilderSectionTileState void _saveChanges() { widget.onChanged(List.of(_pendingChanges)); - // ignore: unnecessary_lambdas setState(() { _pendingChanges.clear(); _isEditMode = false; @@ -133,12 +132,12 @@ class _DocumentBuilderSectionTileState } class _Header extends StatelessWidget { - final String? title; + final String title; final bool isEditMode; final VoidCallback? onToggleEditMode; const _Header({ - this.title, + required this.title, this.isEditMode = false, this.onToggleEditMode, }); @@ -149,7 +148,7 @@ class _Header extends StatelessWidget { children: [ Expanded( child: Text( - title ?? '', + title, style: Theme.of(context).textTheme.titleMedium, ), ), diff --git a/catalyst_voices/packages/internal/catalyst_voices_models/lib/src/document/schema/property/document_property_schema.dart b/catalyst_voices/packages/internal/catalyst_voices_models/lib/src/document/schema/property/document_property_schema.dart index 92f0ae9783f..73d52a5eb24 100644 --- a/catalyst_voices/packages/internal/catalyst_voices_models/lib/src/document/schema/property/document_property_schema.dart +++ b/catalyst_voices/packages/internal/catalyst_voices_models/lib/src/document/schema/property/document_property_schema.dart @@ -11,6 +11,22 @@ part 'document_number_schema.dart'; part 'document_object_schema.dart'; part 'document_string_schema.dart'; +/// A schema of [DocumentProperty]. +/// Defines the type, formatting, appearance and validation rules. +/// +/// There are two major types of properties, grouping properties: +/// - [DocumentObjectSchema] +/// - [DocumentListSchema] +/// +/// and properties with values: +/// +/// - [DocumentValueSchema] +/// - [DocumentBooleanSchema] +/// - [DocumentIntegerSchema] +/// - [DocumentNumberSchema] +/// - [DocumentStringSchema] +/// +/// Grouping properties have children, value properties have values. sealed class DocumentPropertySchema extends Equatable implements DocumentNode { @override final DocumentNodeId nodeId; @@ -35,10 +51,14 @@ sealed class DocumentPropertySchema extends Equatable implements DocumentNode { /// The most nested object ID in the schema. String get id => nodeId.lastPath; - /// new property for the list + /// Creates a new property from this schema with a default value. + /// + /// Specify the [parentNodeId] if the created property should + /// be moved to another node. By default it is created under + /// the same node that this schema points to. DocumentProperty createProperty([DocumentNodeId? parentNodeId]); - /// Moves the schema and it's children to a new nodeId + /// Moves the schema and it's children to the [nodeId]. DocumentPropertySchema withNodeId(DocumentNodeId nodeId); @override @@ -53,6 +73,7 @@ sealed class DocumentPropertySchema extends Equatable implements DocumentNode { ]; } +/// A schema property that can have a value. sealed class DocumentValueSchema extends DocumentPropertySchema { final T? defaultValue; @@ -83,6 +104,8 @@ sealed class DocumentValueSchema ); } + /// Casts the property linked to this schema so that + /// the property type is synced with schema type. DocumentValueProperty castProperty( DocumentValueProperty property, ) { @@ -94,6 +117,8 @@ sealed class DocumentValueSchema return property as DocumentValueProperty; } + /// Casts the property value linked to this schema so that + /// the property value type is synced with schema type. T? castValue(Object? value) { return value as T?; }