From be6e8c90024bd5256f5fe4e2e8ea1da6e95735e4 Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Mon, 20 Jun 2022 00:18:02 +0300 Subject: [PATCH] Add dependencies to ComponentEntry --- lib/models/project.dart | 2 + lib/models/project.freezed.dart | 66 +++++++++++++++++++++++++-------- lib/models/project.g.dart | 5 +++ lib/state/project.dart | 1 + 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/lib/models/project.dart b/lib/models/project.dart index b83e9c2..6b80539 100644 --- a/lib/models/project.dart +++ b/lib/models/project.dart @@ -27,6 +27,8 @@ class ComponentEntry with _$ComponentEntry { List? logicExpression, @JsonKey(defaultValue: false) required bool visualDesigned, + @JsonKey(defaultValue: []) + required List dependencies, }) = _ComponentEntry; factory ComponentEntry.fromJson(Map json) => _$ComponentEntryFromJson(json); diff --git a/lib/models/project.freezed.dart b/lib/models/project.freezed.dart index cf77fd3..0c2cb28 100644 --- a/lib/models/project.freezed.dart +++ b/lib/models/project.freezed.dart @@ -170,6 +170,8 @@ mixin _$ComponentEntry { List? get logicExpression => throw _privateConstructorUsedError; @JsonKey(defaultValue: false) bool get visualDesigned => throw _privateConstructorUsedError; + @JsonKey(defaultValue: []) + List get dependencies => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -190,7 +192,8 @@ abstract class $ComponentEntryCopyWith<$Res> { List outputs, @JsonKey(includeIfNull: false) List? truthTable, @JsonKey(includeIfNull: false) List? logicExpression, - @JsonKey(defaultValue: false) bool visualDesigned}); + @JsonKey(defaultValue: false) bool visualDesigned, + @JsonKey(defaultValue: []) List dependencies}); } /// @nodoc @@ -212,6 +215,7 @@ class _$ComponentEntryCopyWithImpl<$Res> Object? truthTable = freezed, Object? logicExpression = freezed, Object? visualDesigned = freezed, + Object? dependencies = freezed, }) { return _then(_value.copyWith( componentId: componentId == freezed @@ -246,6 +250,10 @@ class _$ComponentEntryCopyWithImpl<$Res> ? _value.visualDesigned : visualDesigned // ignore: cast_nullable_to_non_nullable as bool, + dependencies: dependencies == freezed + ? _value.dependencies + : dependencies // ignore: cast_nullable_to_non_nullable + as List, )); } } @@ -265,7 +273,8 @@ abstract class _$$_ComponentEntryCopyWith<$Res> List outputs, @JsonKey(includeIfNull: false) List? truthTable, @JsonKey(includeIfNull: false) List? logicExpression, - @JsonKey(defaultValue: false) bool visualDesigned}); + @JsonKey(defaultValue: false) bool visualDesigned, + @JsonKey(defaultValue: []) List dependencies}); } /// @nodoc @@ -289,6 +298,7 @@ class __$$_ComponentEntryCopyWithImpl<$Res> Object? truthTable = freezed, Object? logicExpression = freezed, Object? visualDesigned = freezed, + Object? dependencies = freezed, }) { return _then(_$_ComponentEntry( componentId: componentId == freezed @@ -323,6 +333,10 @@ class __$$_ComponentEntryCopyWithImpl<$Res> ? _value.visualDesigned : visualDesigned // ignore: cast_nullable_to_non_nullable as bool, + dependencies: dependencies == freezed + ? _value._dependencies + : dependencies // ignore: cast_nullable_to_non_nullable + as List, )); } } @@ -338,11 +352,13 @@ class _$_ComponentEntry implements _ComponentEntry { required final List outputs, @JsonKey(includeIfNull: false) final List? truthTable, @JsonKey(includeIfNull: false) final List? logicExpression, - @JsonKey(defaultValue: false) required this.visualDesigned}) + @JsonKey(defaultValue: false) required this.visualDesigned, + @JsonKey(defaultValue: []) required final List dependencies}) : _inputs = inputs, _outputs = outputs, _truthTable = truthTable, - _logicExpression = logicExpression; + _logicExpression = logicExpression, + _dependencies = dependencies; factory _$_ComponentEntry.fromJson(Map json) => _$$_ComponentEntryFromJson(json); @@ -391,10 +407,17 @@ class _$_ComponentEntry implements _ComponentEntry { @override @JsonKey(defaultValue: false) final bool visualDesigned; + final List _dependencies; + @override + @JsonKey(defaultValue: []) + List get dependencies { + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_dependencies); + } @override String toString() { - return 'ComponentEntry(componentId: $componentId, componentName: $componentName, componentDescription: $componentDescription, inputs: $inputs, outputs: $outputs, truthTable: $truthTable, logicExpression: $logicExpression, visualDesigned: $visualDesigned)'; + return 'ComponentEntry(componentId: $componentId, componentName: $componentName, componentDescription: $componentDescription, inputs: $inputs, outputs: $outputs, truthTable: $truthTable, logicExpression: $logicExpression, visualDesigned: $visualDesigned, dependencies: $dependencies)'; } @override @@ -415,7 +438,9 @@ class _$_ComponentEntry implements _ComponentEntry { const DeepCollectionEquality() .equals(other._logicExpression, _logicExpression) && const DeepCollectionEquality() - .equals(other.visualDesigned, visualDesigned)); + .equals(other.visualDesigned, visualDesigned) && + const DeepCollectionEquality() + .equals(other._dependencies, _dependencies)); } @JsonKey(ignore: true) @@ -429,7 +454,8 @@ class _$_ComponentEntry implements _ComponentEntry { const DeepCollectionEquality().hash(_outputs), const DeepCollectionEquality().hash(_truthTable), const DeepCollectionEquality().hash(_logicExpression), - const DeepCollectionEquality().hash(visualDesigned)); + const DeepCollectionEquality().hash(visualDesigned), + const DeepCollectionEquality().hash(_dependencies)); @JsonKey(ignore: true) @override @@ -444,15 +470,20 @@ class _$_ComponentEntry implements _ComponentEntry { abstract class _ComponentEntry implements ComponentEntry { const factory _ComponentEntry( - {required final String componentId, - required final String componentName, - @JsonKey(includeIfNull: false) final String? componentDescription, - required final List inputs, - required final List outputs, - @JsonKey(includeIfNull: false) final List? truthTable, - @JsonKey(includeIfNull: false) final List? logicExpression, - @JsonKey(defaultValue: false) required final bool visualDesigned}) = - _$_ComponentEntry; + {required final String componentId, + required final String componentName, + @JsonKey(includeIfNull: false) + final String? componentDescription, + required final List inputs, + required final List outputs, + @JsonKey(includeIfNull: false) + final List? truthTable, + @JsonKey(includeIfNull: false) + final List? logicExpression, + @JsonKey(defaultValue: false) + required final bool visualDesigned, + @JsonKey(defaultValue: []) + required final List dependencies}) = _$_ComponentEntry; factory _ComponentEntry.fromJson(Map json) = _$_ComponentEntry.fromJson; @@ -478,6 +509,9 @@ abstract class _ComponentEntry implements ComponentEntry { @JsonKey(defaultValue: false) bool get visualDesigned => throw _privateConstructorUsedError; @override + @JsonKey(defaultValue: []) + List get dependencies => throw _privateConstructorUsedError; + @override @JsonKey(ignore: true) _$$_ComponentEntryCopyWith<_$_ComponentEntry> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/models/project.g.dart b/lib/models/project.g.dart index f2a8137..7152826 100644 --- a/lib/models/project.g.dart +++ b/lib/models/project.g.dart @@ -34,6 +34,10 @@ _$_ComponentEntry _$$_ComponentEntryFromJson(Map json) => ?.map((e) => e as String) .toList(), visualDesigned: json['visualDesigned'] as bool? ?? false, + dependencies: (json['dependencies'] as List?) + ?.map((e) => e as String) + .toList() ?? + [], ); Map _$$_ComponentEntryToJson(_$_ComponentEntry instance) { @@ -54,5 +58,6 @@ Map _$$_ComponentEntryToJson(_$_ComponentEntry instance) { writeNotNull('truthTable', instance.truthTable); writeNotNull('logicExpression', instance.logicExpression); val['visualDesigned'] = instance.visualDesigned; + val['dependencies'] = instance.dependencies; return val; } diff --git a/lib/state/project.dart b/lib/state/project.dart index 2c03db7..191f77b 100644 --- a/lib/state/project.dart +++ b/lib/state/project.dart @@ -77,6 +77,7 @@ class ProjectState extends ChangeNotifier { inputs: [], outputs: [], visualDesigned: false, + dependencies: [], ); await _updateIndex(index.copyWith(components: index.components + [newComponent])); return newComponent;