diff --git a/CHANGELOG.md b/CHANGELOG.md index b5f1a1c..9a2998a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.8.11 + +- Adjustments on `Model`, now `widget` is `List` instead of plain `RenderWidget`. + ## 3.8.10 - Added new fields on `InboundProtocol` and `Model` to support Zigbee and ConfIoT related configurations diff --git a/lib/src/models/models.freezed.dart b/lib/src/models/models.freezed.dart index 61b56a9..9f269e8 100644 --- a/lib/src/models/models.freezed.dart +++ b/lib/src/models/models.freezed.dart @@ -32,7 +32,7 @@ mixin _$Model { Map? get peripheralParserSpec;/// [firmwares] is the list of firmwares for the model. List get firmwares;/// The icon of the model, if not exists, you must render the protocol icon @IconOrNullConverter() LayrzIcon? get icon;/// Indicates the rendering widget, useful to render visually the kind of device -@JsonKey(unknownEnumValue: RenderWidget.unknown) RenderWidget get widget; +@JsonKey(unknownEnumValue: RenderWidget.unknown) List get widget; /// Create a copy of Model /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -45,12 +45,12 @@ $ModelCopyWith get copyWith => _$ModelCopyWithImpl(this as Model, @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is Model&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.flespiId, flespiId) || other.flespiId == flespiId)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.protocolId, protocolId) || other.protocolId == protocolId)&&(identical(other.isGeneric, isGeneric) || other.isGeneric == isGeneric)&&const DeepCollectionEquality().equals(other.commandsStructure, commandsStructure)&&const DeepCollectionEquality().equals(other.configStructure, configStructure)&&(identical(other.confiotCapable, confiotCapable) || other.confiotCapable == confiotCapable)&&(identical(other.confiotLayout, confiotLayout) || other.confiotLayout == confiotLayout)&&(identical(other.confiotName, confiotName) || other.confiotName == confiotName)&&(identical(other.peripheralIdentifier, peripheralIdentifier) || other.peripheralIdentifier == peripheralIdentifier)&&const DeepCollectionEquality().equals(other.peripheralParserSpec, peripheralParserSpec)&&const DeepCollectionEquality().equals(other.firmwares, firmwares)&&(identical(other.icon, icon) || other.icon == icon)&&(identical(other.widget, widget) || other.widget == widget)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is Model&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.flespiId, flespiId) || other.flespiId == flespiId)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.protocolId, protocolId) || other.protocolId == protocolId)&&(identical(other.isGeneric, isGeneric) || other.isGeneric == isGeneric)&&const DeepCollectionEquality().equals(other.commandsStructure, commandsStructure)&&const DeepCollectionEquality().equals(other.configStructure, configStructure)&&(identical(other.confiotCapable, confiotCapable) || other.confiotCapable == confiotCapable)&&(identical(other.confiotLayout, confiotLayout) || other.confiotLayout == confiotLayout)&&(identical(other.confiotName, confiotName) || other.confiotName == confiotName)&&(identical(other.peripheralIdentifier, peripheralIdentifier) || other.peripheralIdentifier == peripheralIdentifier)&&const DeepCollectionEquality().equals(other.peripheralParserSpec, peripheralParserSpec)&&const DeepCollectionEquality().equals(other.firmwares, firmwares)&&(identical(other.icon, icon) || other.icon == icon)&&const DeepCollectionEquality().equals(other.widget, widget)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,name,flespiId,protocol,protocolId,isGeneric,const DeepCollectionEquality().hash(commandsStructure),const DeepCollectionEquality().hash(configStructure),confiotCapable,confiotLayout,confiotName,peripheralIdentifier,const DeepCollectionEquality().hash(peripheralParserSpec),const DeepCollectionEquality().hash(firmwares),icon,widget); +int get hashCode => Object.hash(runtimeType,id,name,flespiId,protocol,protocolId,isGeneric,const DeepCollectionEquality().hash(commandsStructure),const DeepCollectionEquality().hash(configStructure),confiotCapable,confiotLayout,confiotName,peripheralIdentifier,const DeepCollectionEquality().hash(peripheralParserSpec),const DeepCollectionEquality().hash(firmwares),icon,const DeepCollectionEquality().hash(widget)); @override String toString() { @@ -65,7 +65,7 @@ abstract mixin class $ModelCopyWith<$Res> { factory $ModelCopyWith(Model value, $Res Function(Model) _then) = _$ModelCopyWithImpl; @useResult $Res call({ - String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable,@JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares,@IconOrNullConverter() LayrzIcon? icon,@JsonKey(unknownEnumValue: RenderWidget.unknown) RenderWidget widget + String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable,@JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares,@IconOrNullConverter() LayrzIcon? icon,@JsonKey(unknownEnumValue: RenderWidget.unknown) List widget }); @@ -100,7 +100,7 @@ as String?,peripheralParserSpec: freezed == peripheralParserSpec ? _self.periphe as Map?,firmwares: null == firmwares ? _self.firmwares : firmwares // ignore: cast_nullable_to_non_nullable as List,icon: freezed == icon ? _self.icon : icon // ignore: cast_nullable_to_non_nullable as LayrzIcon?,widget: null == widget ? _self.widget : widget // ignore: cast_nullable_to_non_nullable -as RenderWidget, +as List, )); } /// Create a copy of Model @@ -197,7 +197,7 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable, @JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares, @IconOrNullConverter() LayrzIcon? icon, @JsonKey(unknownEnumValue: RenderWidget.unknown) RenderWidget widget)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable, @JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares, @IconOrNullConverter() LayrzIcon? icon, @JsonKey(unknownEnumValue: RenderWidget.unknown) List widget)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _Model() when $default != null: return $default(_that.id,_that.name,_that.flespiId,_that.protocol,_that.protocolId,_that.isGeneric,_that.commandsStructure,_that.configStructure,_that.confiotCapable,_that.confiotLayout,_that.confiotName,_that.peripheralIdentifier,_that.peripheralParserSpec,_that.firmwares,_that.icon,_that.widget);case _: @@ -218,7 +218,7 @@ return $default(_that.id,_that.name,_that.flespiId,_that.protocol,_that.protocol /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable, @JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares, @IconOrNullConverter() LayrzIcon? icon, @JsonKey(unknownEnumValue: RenderWidget.unknown) RenderWidget widget) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable, @JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares, @IconOrNullConverter() LayrzIcon? icon, @JsonKey(unknownEnumValue: RenderWidget.unknown) List widget) $default,) {final _that = this; switch (_that) { case _Model(): return $default(_that.id,_that.name,_that.flespiId,_that.protocol,_that.protocolId,_that.isGeneric,_that.commandsStructure,_that.configStructure,_that.confiotCapable,_that.confiotLayout,_that.confiotName,_that.peripheralIdentifier,_that.peripheralParserSpec,_that.firmwares,_that.icon,_that.widget);case _: @@ -238,7 +238,7 @@ return $default(_that.id,_that.name,_that.flespiId,_that.protocol,_that.protocol /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable, @JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares, @IconOrNullConverter() LayrzIcon? icon, @JsonKey(unknownEnumValue: RenderWidget.unknown) RenderWidget widget)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable, @JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares, @IconOrNullConverter() LayrzIcon? icon, @JsonKey(unknownEnumValue: RenderWidget.unknown) List widget)? $default,) {final _that = this; switch (_that) { case _Model() when $default != null: return $default(_that.id,_that.name,_that.flespiId,_that.protocol,_that.protocolId,_that.isGeneric,_that.commandsStructure,_that.configStructure,_that.confiotCapable,_that.confiotLayout,_that.confiotName,_that.peripheralIdentifier,_that.peripheralParserSpec,_that.firmwares,_that.icon,_that.widget);case _: @@ -253,7 +253,7 @@ return $default(_that.id,_that.name,_that.flespiId,_that.protocol,_that.protocol @JsonSerializable() class _Model implements Model { - const _Model({required this.id, required this.name, this.flespiId, this.protocol, this.protocolId, this.isGeneric, final List commandsStructure = const [], final List configStructure = const [], this.confiotCapable = false, @JsonKey(unknownEnumValue: ConfIoTLayout.standard) this.confiotLayout = ConfIoTLayout.standard, this.confiotName, this.peripheralIdentifier, final Map? peripheralParserSpec, final List firmwares = const [], @IconOrNullConverter() this.icon, @JsonKey(unknownEnumValue: RenderWidget.unknown) this.widget = RenderWidget.unknown}): _commandsStructure = commandsStructure,_configStructure = configStructure,_peripheralParserSpec = peripheralParserSpec,_firmwares = firmwares; + const _Model({required this.id, required this.name, this.flespiId, this.protocol, this.protocolId, this.isGeneric, final List commandsStructure = const [], final List configStructure = const [], this.confiotCapable = false, @JsonKey(unknownEnumValue: ConfIoTLayout.standard) this.confiotLayout = ConfIoTLayout.standard, this.confiotName, this.peripheralIdentifier, final Map? peripheralParserSpec, final List firmwares = const [], @IconOrNullConverter() this.icon, @JsonKey(unknownEnumValue: RenderWidget.unknown) final List widget = const []}): _commandsStructure = commandsStructure,_configStructure = configStructure,_peripheralParserSpec = peripheralParserSpec,_firmwares = firmwares,_widget = widget; factory _Model.fromJson(Map json) => _$ModelFromJson(json); /// [id] is the unique identifier of the model. @@ -318,7 +318,14 @@ class _Model implements Model { /// The icon of the model, if not exists, you must render the protocol icon @override@IconOrNullConverter() final LayrzIcon? icon; /// Indicates the rendering widget, useful to render visually the kind of device -@override@JsonKey(unknownEnumValue: RenderWidget.unknown) final RenderWidget widget; + final List _widget; +/// Indicates the rendering widget, useful to render visually the kind of device +@override@JsonKey(unknownEnumValue: RenderWidget.unknown) List get widget { + if (_widget is EqualUnmodifiableListView) return _widget; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_widget); +} + /// Create a copy of Model /// with the given fields replaced by the non-null parameter values. @@ -333,12 +340,12 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _Model&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.flespiId, flespiId) || other.flespiId == flespiId)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.protocolId, protocolId) || other.protocolId == protocolId)&&(identical(other.isGeneric, isGeneric) || other.isGeneric == isGeneric)&&const DeepCollectionEquality().equals(other._commandsStructure, _commandsStructure)&&const DeepCollectionEquality().equals(other._configStructure, _configStructure)&&(identical(other.confiotCapable, confiotCapable) || other.confiotCapable == confiotCapable)&&(identical(other.confiotLayout, confiotLayout) || other.confiotLayout == confiotLayout)&&(identical(other.confiotName, confiotName) || other.confiotName == confiotName)&&(identical(other.peripheralIdentifier, peripheralIdentifier) || other.peripheralIdentifier == peripheralIdentifier)&&const DeepCollectionEquality().equals(other._peripheralParserSpec, _peripheralParserSpec)&&const DeepCollectionEquality().equals(other._firmwares, _firmwares)&&(identical(other.icon, icon) || other.icon == icon)&&(identical(other.widget, widget) || other.widget == widget)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Model&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.flespiId, flespiId) || other.flespiId == flespiId)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.protocolId, protocolId) || other.protocolId == protocolId)&&(identical(other.isGeneric, isGeneric) || other.isGeneric == isGeneric)&&const DeepCollectionEquality().equals(other._commandsStructure, _commandsStructure)&&const DeepCollectionEquality().equals(other._configStructure, _configStructure)&&(identical(other.confiotCapable, confiotCapable) || other.confiotCapable == confiotCapable)&&(identical(other.confiotLayout, confiotLayout) || other.confiotLayout == confiotLayout)&&(identical(other.confiotName, confiotName) || other.confiotName == confiotName)&&(identical(other.peripheralIdentifier, peripheralIdentifier) || other.peripheralIdentifier == peripheralIdentifier)&&const DeepCollectionEquality().equals(other._peripheralParserSpec, _peripheralParserSpec)&&const DeepCollectionEquality().equals(other._firmwares, _firmwares)&&(identical(other.icon, icon) || other.icon == icon)&&const DeepCollectionEquality().equals(other._widget, _widget)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,name,flespiId,protocol,protocolId,isGeneric,const DeepCollectionEquality().hash(_commandsStructure),const DeepCollectionEquality().hash(_configStructure),confiotCapable,confiotLayout,confiotName,peripheralIdentifier,const DeepCollectionEquality().hash(_peripheralParserSpec),const DeepCollectionEquality().hash(_firmwares),icon,widget); +int get hashCode => Object.hash(runtimeType,id,name,flespiId,protocol,protocolId,isGeneric,const DeepCollectionEquality().hash(_commandsStructure),const DeepCollectionEquality().hash(_configStructure),confiotCapable,confiotLayout,confiotName,peripheralIdentifier,const DeepCollectionEquality().hash(_peripheralParserSpec),const DeepCollectionEquality().hash(_firmwares),icon,const DeepCollectionEquality().hash(_widget)); @override String toString() { @@ -353,7 +360,7 @@ abstract mixin class _$ModelCopyWith<$Res> implements $ModelCopyWith<$Res> { factory _$ModelCopyWith(_Model value, $Res Function(_Model) _then) = __$ModelCopyWithImpl; @override @useResult $Res call({ - String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable,@JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares,@IconOrNullConverter() LayrzIcon? icon,@JsonKey(unknownEnumValue: RenderWidget.unknown) RenderWidget widget + String id, String name, String? flespiId, InboundProtocol? protocol, String? protocolId, bool? isGeneric, List commandsStructure, List configStructure, bool confiotCapable,@JsonKey(unknownEnumValue: ConfIoTLayout.standard) ConfIoTLayout confiotLayout, String? confiotName, String? peripheralIdentifier, Map? peripheralParserSpec, List firmwares,@IconOrNullConverter() LayrzIcon? icon,@JsonKey(unknownEnumValue: RenderWidget.unknown) List widget }); @@ -387,8 +394,8 @@ as String?,peripheralIdentifier: freezed == peripheralIdentifier ? _self.periphe as String?,peripheralParserSpec: freezed == peripheralParserSpec ? _self._peripheralParserSpec : peripheralParserSpec // ignore: cast_nullable_to_non_nullable as Map?,firmwares: null == firmwares ? _self._firmwares : firmwares // ignore: cast_nullable_to_non_nullable as List,icon: freezed == icon ? _self.icon : icon // ignore: cast_nullable_to_non_nullable -as LayrzIcon?,widget: null == widget ? _self.widget : widget // ignore: cast_nullable_to_non_nullable -as RenderWidget, +as LayrzIcon?,widget: null == widget ? _self._widget : widget // ignore: cast_nullable_to_non_nullable +as List, )); } diff --git a/lib/src/models/models.g.dart b/lib/src/models/models.g.dart index 1e93369..7adc1f3 100644 --- a/lib/src/models/models.g.dart +++ b/lib/src/models/models.g.dart @@ -43,12 +43,16 @@ _Model _$ModelFromJson(Map json) => _Model( const [], icon: const IconOrNullConverter().fromJson(json['icon'] as String?), widget: - $enumDecodeNullable( - _$RenderWidgetEnumMap, - json['widget'], - unknownValue: RenderWidget.unknown, - ) ?? - RenderWidget.unknown, + (json['widget'] as List?) + ?.map( + (e) => $enumDecode( + _$RenderWidgetEnumMap, + e, + unknownValue: RenderWidget.unknown, + ), + ) + .toList() ?? + const [], ); Map _$ModelToJson(_Model instance) => { @@ -69,7 +73,7 @@ Map _$ModelToJson(_Model instance) => { 'peripheralParserSpec': instance.peripheralParserSpec, 'firmwares': instance.firmwares.map((e) => e.toJson()).toList(), 'icon': const IconOrNullConverter().toJson(instance.icon), - 'widget': instance.widget.toJson(), + 'widget': instance.widget.map((e) => e.toJson()).toList(), }; const _$ConfIoTLayoutEnumMap = { diff --git a/lib/src/models/src/model.dart b/lib/src/models/src/model.dart index ae2f503..459e77d 100644 --- a/lib/src/models/src/model.dart +++ b/lib/src/models/src/model.dart @@ -53,7 +53,7 @@ abstract class Model with _$Model { @IconOrNullConverter() LayrzIcon? icon, /// Indicates the rendering widget, useful to render visually the kind of device - @JsonKey(unknownEnumValue: RenderWidget.unknown) @Default(RenderWidget.unknown) RenderWidget widget, + @JsonKey(unknownEnumValue: RenderWidget.unknown) @Default([]) List widget, }) = _Model; factory Model.fromJson(Map json) => _$ModelFromJson(json); diff --git a/pubspec.yaml b/pubspec.yaml index 8cede15..983d6a7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ description: Layrz API models for Dart/Flutter. This package contains the models used by the Layrz API. name: layrz_models -version: "3.8.10" +version: "3.8.11" repository: https://github.com/goldenm-software/layrz_models environment: