diff --git a/packages/stac/lib/src/framework/stac.dart b/packages/stac/lib/src/framework/stac.dart index c6c15007..8fe762f1 100644 --- a/packages/stac/lib/src/framework/stac.dart +++ b/packages/stac/lib/src/framework/stac.dart @@ -5,6 +5,8 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:stac/src/framework/stac_registry.dart'; +import 'package:stac/src/parsers/actions/stac_form_validate/stac_form_validate_parser.dart'; +import 'package:stac/src/parsers/actions/stac_get_form_value/stac_get_form_value_parser.dart'; import 'package:stac/src/parsers/actions/stac_network_request/stac_network_request_parser.dart'; import 'package:stac/src/parsers/parsers.dart'; import 'package:stac/src/parsers/widgets/stac_app_bar/stac_app_bar_parser.dart'; diff --git a/packages/stac/lib/src/parsers/actions/actions.dart b/packages/stac/lib/src/parsers/actions/actions.dart index b9550bfd..cd6d6050 100644 --- a/packages/stac/lib/src/parsers/actions/actions.dart +++ b/packages/stac/lib/src/parsers/actions/actions.dart @@ -1,7 +1,5 @@ export 'package:stac/src/parsers/actions/stac_delay_action/stac_delay_action.dart'; export 'package:stac/src/parsers/actions/stac_dialog_action/stac_dialog_action.dart'; -export 'package:stac/src/parsers/actions/stac_form_validate/stac_form_validate.dart'; -export 'package:stac/src/parsers/actions/stac_get_form_value/stac_get_form_value.dart'; export 'package:stac/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action_parser.dart'; export 'package:stac/src/parsers/actions/stac_multi_action/stac_multi_action.dart'; export 'package:stac/src/parsers/actions/stac_navigate_action/stac_navigate_action_parser.dart'; diff --git a/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate.dart b/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate.dart deleted file mode 100644 index 4f17d01d..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -export 'stac_form_validate_parser.dart'; - -part 'stac_form_validate.freezed.dart'; -part 'stac_form_validate.g.dart'; - -@freezed -abstract class StacFormValidate with _$StacFormValidate { - const factory StacFormValidate({ - Map? isValid, - Map? isNotValid, - }) = _StacFormValidate; - - factory StacFormValidate.fromJson(Map json) => - _$StacFormValidateFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate.freezed.dart b/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate.freezed.dart deleted file mode 100644 index 2e2aea65..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate.freezed.dart +++ /dev/null @@ -1,202 +0,0 @@ -// dart format width=80 -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'stac_form_validate.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacFormValidate { - Map? get isValid; - Map? get isNotValid; - - /// Create a copy of StacFormValidate - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacFormValidateCopyWith get copyWith => - _$StacFormValidateCopyWithImpl( - this as StacFormValidate, _$identity); - - /// Serializes this StacFormValidate to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacFormValidate && - const DeepCollectionEquality().equals(other.isValid, isValid) && - const DeepCollectionEquality() - .equals(other.isNotValid, isNotValid)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(isValid), - const DeepCollectionEquality().hash(isNotValid)); - - @override - String toString() { - return 'StacFormValidate(isValid: $isValid, isNotValid: $isNotValid)'; - } -} - -/// @nodoc -abstract mixin class $StacFormValidateCopyWith<$Res> { - factory $StacFormValidateCopyWith( - StacFormValidate value, $Res Function(StacFormValidate) _then) = - _$StacFormValidateCopyWithImpl; - @useResult - $Res call({Map? isValid, Map? isNotValid}); -} - -/// @nodoc -class _$StacFormValidateCopyWithImpl<$Res> - implements $StacFormValidateCopyWith<$Res> { - _$StacFormValidateCopyWithImpl(this._self, this._then); - - final StacFormValidate _self; - final $Res Function(StacFormValidate) _then; - - /// Create a copy of StacFormValidate - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? isValid = freezed, - Object? isNotValid = freezed, - }) { - return _then(_self.copyWith( - isValid: freezed == isValid - ? _self.isValid - : isValid // ignore: cast_nullable_to_non_nullable - as Map?, - isNotValid: freezed == isNotValid - ? _self.isNotValid - : isNotValid // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacFormValidate implements StacFormValidate { - const _StacFormValidate( - {final Map? isValid, - final Map? isNotValid}) - : _isValid = isValid, - _isNotValid = isNotValid; - factory _StacFormValidate.fromJson(Map json) => - _$StacFormValidateFromJson(json); - - final Map? _isValid; - @override - Map? get isValid { - final value = _isValid; - if (value == null) return null; - if (_isValid is EqualUnmodifiableMapView) return _isValid; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _isNotValid; - @override - Map? get isNotValid { - final value = _isNotValid; - if (value == null) return null; - if (_isNotValid is EqualUnmodifiableMapView) return _isNotValid; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - /// Create a copy of StacFormValidate - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacFormValidateCopyWith<_StacFormValidate> get copyWith => - __$StacFormValidateCopyWithImpl<_StacFormValidate>(this, _$identity); - - @override - Map toJson() { - return _$StacFormValidateToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacFormValidate && - const DeepCollectionEquality().equals(other._isValid, _isValid) && - const DeepCollectionEquality() - .equals(other._isNotValid, _isNotValid)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_isValid), - const DeepCollectionEquality().hash(_isNotValid)); - - @override - String toString() { - return 'StacFormValidate(isValid: $isValid, isNotValid: $isNotValid)'; - } -} - -/// @nodoc -abstract mixin class _$StacFormValidateCopyWith<$Res> - implements $StacFormValidateCopyWith<$Res> { - factory _$StacFormValidateCopyWith( - _StacFormValidate value, $Res Function(_StacFormValidate) _then) = - __$StacFormValidateCopyWithImpl; - @override - @useResult - $Res call({Map? isValid, Map? isNotValid}); -} - -/// @nodoc -class __$StacFormValidateCopyWithImpl<$Res> - implements _$StacFormValidateCopyWith<$Res> { - __$StacFormValidateCopyWithImpl(this._self, this._then); - - final _StacFormValidate _self; - final $Res Function(_StacFormValidate) _then; - - /// Create a copy of StacFormValidate - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? isValid = freezed, - Object? isNotValid = freezed, - }) { - return _then(_StacFormValidate( - isValid: freezed == isValid - ? _self._isValid - : isValid // ignore: cast_nullable_to_non_nullable - as Map?, - isNotValid: freezed == isNotValid - ? _self._isNotValid - : isNotValid // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate.g.dart b/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate.g.dart deleted file mode 100644 index b9611ffe..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate.g.dart +++ /dev/null @@ -1,19 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_form_validate.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacFormValidate _$StacFormValidateFromJson(Map json) => - _StacFormValidate( - isValid: json['isValid'] as Map?, - isNotValid: json['isNotValid'] as Map?, - ); - -Map _$StacFormValidateToJson(_StacFormValidate instance) => - { - 'isValid': instance.isValid, - 'isNotValid': instance.isNotValid, - }; diff --git a/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate_parser.dart b/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate_parser.dart index ca75b875..1151b07d 100644 --- a/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate_parser.dart +++ b/packages/stac/lib/src/parsers/actions/stac_form_validate/stac_form_validate_parser.dart @@ -1,12 +1,11 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/core/stac_action_parser.dart'; import 'package:stac/src/parsers/widgets/stac_form/stac_form_scope.dart'; import 'package:stac/src/utils/action_type.dart'; import 'package:stac_framework/stac_framework.dart'; - -import 'stac_form_validate.dart'; +import 'package:stac_models/actions/form_validate/stac_form_validate.dart'; class StacFormValidateParser extends StacActionParser { const StacFormValidateParser(); @@ -24,9 +23,9 @@ class StacFormValidateParser extends StacActionParser { StacFormScope.of(context)?.formKey.currentState?.validate() ?? false; if (isValid) { - return Stac.onCallFromJson(model.isValid, context); + return model.isValid?.parse(context); } else { - return Stac.onCallFromJson(model.isNotValid, context); + return model.isNotValid?.parse(context); } } } diff --git a/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value.dart b/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value.dart deleted file mode 100644 index 8b5fc79c..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -export 'stac_get_form_value_parser.dart'; - -part 'stac_get_form_value.freezed.dart'; -part 'stac_get_form_value.g.dart'; - -@freezed -abstract class StacGetFormValue with _$StacGetFormValue { - const factory StacGetFormValue({ - required String id, - }) = _StacGetFormValue; - - factory StacGetFormValue.fromJson(Map json) => - _$StacGetFormValueFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value.freezed.dart b/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value.freezed.dart deleted file mode 100644 index a7c53fcf..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value.freezed.dart +++ /dev/null @@ -1,160 +0,0 @@ -// dart format width=80 -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'stac_get_form_value.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacGetFormValue { - String get id; - - /// Create a copy of StacGetFormValue - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacGetFormValueCopyWith get copyWith => - _$StacGetFormValueCopyWithImpl( - this as StacGetFormValue, _$identity); - - /// Serializes this StacGetFormValue to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacGetFormValue && - (identical(other.id, id) || other.id == id)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, id); - - @override - String toString() { - return 'StacGetFormValue(id: $id)'; - } -} - -/// @nodoc -abstract mixin class $StacGetFormValueCopyWith<$Res> { - factory $StacGetFormValueCopyWith( - StacGetFormValue value, $Res Function(StacGetFormValue) _then) = - _$StacGetFormValueCopyWithImpl; - @useResult - $Res call({String id}); -} - -/// @nodoc -class _$StacGetFormValueCopyWithImpl<$Res> - implements $StacGetFormValueCopyWith<$Res> { - _$StacGetFormValueCopyWithImpl(this._self, this._then); - - final StacGetFormValue _self; - final $Res Function(StacGetFormValue) _then; - - /// Create a copy of StacGetFormValue - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - }) { - return _then(_self.copyWith( - id: null == id - ? _self.id - : id // ignore: cast_nullable_to_non_nullable - as String, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacGetFormValue implements StacGetFormValue { - const _StacGetFormValue({required this.id}); - factory _StacGetFormValue.fromJson(Map json) => - _$StacGetFormValueFromJson(json); - - @override - final String id; - - /// Create a copy of StacGetFormValue - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacGetFormValueCopyWith<_StacGetFormValue> get copyWith => - __$StacGetFormValueCopyWithImpl<_StacGetFormValue>(this, _$identity); - - @override - Map toJson() { - return _$StacGetFormValueToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacGetFormValue && - (identical(other.id, id) || other.id == id)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, id); - - @override - String toString() { - return 'StacGetFormValue(id: $id)'; - } -} - -/// @nodoc -abstract mixin class _$StacGetFormValueCopyWith<$Res> - implements $StacGetFormValueCopyWith<$Res> { - factory _$StacGetFormValueCopyWith( - _StacGetFormValue value, $Res Function(_StacGetFormValue) _then) = - __$StacGetFormValueCopyWithImpl; - @override - @useResult - $Res call({String id}); -} - -/// @nodoc -class __$StacGetFormValueCopyWithImpl<$Res> - implements _$StacGetFormValueCopyWith<$Res> { - __$StacGetFormValueCopyWithImpl(this._self, this._then); - - final _StacGetFormValue _self; - final $Res Function(_StacGetFormValue) _then; - - /// Create a copy of StacGetFormValue - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? id = null, - }) { - return _then(_StacGetFormValue( - id: null == id - ? _self.id - : id // ignore: cast_nullable_to_non_nullable - as String, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value.g.dart b/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value.g.dart deleted file mode 100644 index ad91c79a..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value.g.dart +++ /dev/null @@ -1,17 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_get_form_value.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacGetFormValue _$StacGetFormValueFromJson(Map json) => - _StacGetFormValue( - id: json['id'] as String, - ); - -Map _$StacGetFormValueToJson(_StacGetFormValue instance) => - { - 'id': instance.id, - }; diff --git a/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value_parser.dart b/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value_parser.dart index 182fe2a8..c4242c83 100644 --- a/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value_parser.dart +++ b/packages/stac/lib/src/parsers/actions/stac_get_form_value/stac_get_form_value_parser.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:stac/src/parsers/actions/stac_get_form_value/stac_get_form_value.dart'; import 'package:stac/src/parsers/widgets/stac_form/stac_form_scope.dart'; import 'package:stac/src/utils/action_type.dart'; import 'package:stac_framework/stac_framework.dart'; +import 'package:stac_models/actions/get_form_value/stac_get_form_value.dart'; class StacGetFormValueParser extends StacActionParser { const StacGetFormValueParser(); diff --git a/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action.dart b/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action.dart deleted file mode 100644 index 5c9ef394..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'stac_set_value_action.freezed.dart'; -part 'stac_set_value_action.g.dart'; - -@freezed -abstract class StacSetValueAction with _$StacSetValueAction { - const factory StacSetValueAction({ - @Default([]) List> values, - Map? action, - }) = _StacSetValueAction; - - factory StacSetValueAction.fromJson(Map json) => - _$StacSetValueActionFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action.freezed.dart b/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action.freezed.dart deleted file mode 100644 index 8b33d51a..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action.freezed.dart +++ /dev/null @@ -1,199 +0,0 @@ -// dart format width=80 -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'stac_set_value_action.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacSetValueAction { - List> get values; - Map? get action; - - /// Create a copy of StacSetValueAction - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacSetValueActionCopyWith get copyWith => - _$StacSetValueActionCopyWithImpl( - this as StacSetValueAction, _$identity); - - /// Serializes this StacSetValueAction to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacSetValueAction && - const DeepCollectionEquality().equals(other.values, values) && - const DeepCollectionEquality().equals(other.action, action)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(values), - const DeepCollectionEquality().hash(action)); - - @override - String toString() { - return 'StacSetValueAction(values: $values, action: $action)'; - } -} - -/// @nodoc -abstract mixin class $StacSetValueActionCopyWith<$Res> { - factory $StacSetValueActionCopyWith( - StacSetValueAction value, $Res Function(StacSetValueAction) _then) = - _$StacSetValueActionCopyWithImpl; - @useResult - $Res call({List> values, Map? action}); -} - -/// @nodoc -class _$StacSetValueActionCopyWithImpl<$Res> - implements $StacSetValueActionCopyWith<$Res> { - _$StacSetValueActionCopyWithImpl(this._self, this._then); - - final StacSetValueAction _self; - final $Res Function(StacSetValueAction) _then; - - /// Create a copy of StacSetValueAction - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? values = null, - Object? action = freezed, - }) { - return _then(_self.copyWith( - values: null == values - ? _self.values - : values // ignore: cast_nullable_to_non_nullable - as List>, - action: freezed == action - ? _self.action - : action // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacSetValueAction implements StacSetValueAction { - const _StacSetValueAction( - {final List> values = const [], - final Map? action}) - : _values = values, - _action = action; - factory _StacSetValueAction.fromJson(Map json) => - _$StacSetValueActionFromJson(json); - - final List> _values; - @override - @JsonKey() - List> get values { - if (_values is EqualUnmodifiableListView) return _values; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_values); - } - - final Map? _action; - @override - Map? get action { - final value = _action; - if (value == null) return null; - if (_action is EqualUnmodifiableMapView) return _action; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - /// Create a copy of StacSetValueAction - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacSetValueActionCopyWith<_StacSetValueAction> get copyWith => - __$StacSetValueActionCopyWithImpl<_StacSetValueAction>(this, _$identity); - - @override - Map toJson() { - return _$StacSetValueActionToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacSetValueAction && - const DeepCollectionEquality().equals(other._values, _values) && - const DeepCollectionEquality().equals(other._action, _action)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_values), - const DeepCollectionEquality().hash(_action)); - - @override - String toString() { - return 'StacSetValueAction(values: $values, action: $action)'; - } -} - -/// @nodoc -abstract mixin class _$StacSetValueActionCopyWith<$Res> - implements $StacSetValueActionCopyWith<$Res> { - factory _$StacSetValueActionCopyWith( - _StacSetValueAction value, $Res Function(_StacSetValueAction) _then) = - __$StacSetValueActionCopyWithImpl; - @override - @useResult - $Res call({List> values, Map? action}); -} - -/// @nodoc -class __$StacSetValueActionCopyWithImpl<$Res> - implements _$StacSetValueActionCopyWith<$Res> { - __$StacSetValueActionCopyWithImpl(this._self, this._then); - - final _StacSetValueAction _self; - final $Res Function(_StacSetValueAction) _then; - - /// Create a copy of StacSetValueAction - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? values = null, - Object? action = freezed, - }) { - return _then(_StacSetValueAction( - values: null == values - ? _self._values - : values // ignore: cast_nullable_to_non_nullable - as List>, - action: freezed == action - ? _self._action - : action // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action_parser.dart b/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action_parser.dart index 919b1dc0..dc42982f 100644 --- a/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action_parser.dart +++ b/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action_parser.dart @@ -1,9 +1,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:stac/src/parsers/actions/stac_set_value/stac_set_value_action.dart'; import 'package:stac/src/utils/action_type.dart'; import 'package:stac/stac.dart'; +import 'package:stac_models/actions/set_value/stac_set_value_action.dart'; class StacSetValueActionParser extends StacActionParser { const StacSetValueActionParser(); @@ -20,7 +20,7 @@ class StacSetValueActionParser extends StacActionParser { BuildContext context, StacSetValueAction model, ) async { - for (final value in model.values) { + for (final value in model.values ?? []) { StacRegistry.instance.setValue(value['key'] as String, value['value']); } return Stac.onCallFromJson(model.action, context); diff --git a/packages/stac/lib/src/parsers/core/stac_action_parser.dart b/packages/stac/lib/src/parsers/core/stac_action_parser.dart index 62e429ca..6dbe1e75 100644 --- a/packages/stac/lib/src/parsers/core/stac_action_parser.dart +++ b/packages/stac/lib/src/parsers/core/stac_action_parser.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:stac/stac.dart'; import 'package:stac_models/stac_models.dart'; -extension StacActionParser on StacAction? { +extension StacActionParserExtension on StacAction? { FutureOr parse(BuildContext context) { if (this == null) { return null; diff --git a/packages/stac/lib/src/parsers/widgets/stac_dynamic_view/stac_dynamic_view_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_dynamic_view/stac_dynamic_view_parser.dart index d4188ea5..9091ea58 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_dynamic_view/stac_dynamic_view_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_dynamic_view/stac_dynamic_view_parser.dart @@ -8,9 +8,7 @@ import 'package:stac/src/services/stac_network_service.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; import 'package:stac_logger/stac_logger.dart'; -import 'package:stac_models/core/core.dart'; import 'package:stac_models/stac_models.dart'; -import 'package:stac_models/widgets/dynamic_view/stac_dynamic_view.dart'; class StacDynamicViewParser extends StacParser { const StacDynamicViewParser(); diff --git a/packages/stac_models/lib/actions/actions.dart b/packages/stac_models/lib/actions/actions.dart index dc8a04dd..d2c99883 100644 --- a/packages/stac_models/lib/actions/actions.dart +++ b/packages/stac_models/lib/actions/actions.dart @@ -1,2 +1,5 @@ +export 'form_validate/stac_form_validate.dart'; +export 'get_form_value/stac_get_form_value.dart'; export 'navigate/stac_navigate_action.dart'; export 'network_request/stac_network_request.dart'; +export 'set_value/stac_set_value_action.dart'; diff --git a/packages/stac_models/lib/actions/form_validate/stac_form_validate.dart b/packages/stac_models/lib/actions/form_validate/stac_form_validate.dart new file mode 100644 index 00000000..2cff7409 --- /dev/null +++ b/packages/stac_models/lib/actions/form_validate/stac_form_validate.dart @@ -0,0 +1,21 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_action.dart'; + +part 'stac_form_validate.g.dart'; + +@JsonSerializable() +class StacFormValidate extends StacAction { + const StacFormValidate({this.isValid, this.isNotValid}); + + final StacAction? isValid; + final StacAction? isNotValid; + + @override + String get actionType => 'validateForm'; + + factory StacFormValidate.fromJson(Map json) => + _$StacFormValidateFromJson(json); + + @override + Map toJson() => _$StacFormValidateToJson(this); +} diff --git a/packages/stac_models/lib/actions/form_validate/stac_form_validate.g.dart b/packages/stac_models/lib/actions/form_validate/stac_form_validate.g.dart new file mode 100644 index 00000000..4802c01a --- /dev/null +++ b/packages/stac_models/lib/actions/form_validate/stac_form_validate.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_form_validate.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacFormValidate _$StacFormValidateFromJson(Map json) => + StacFormValidate( + isValid: json['isValid'] == null + ? null + : StacAction.fromJson(json['isValid'] as Map), + isNotValid: json['isNotValid'] == null + ? null + : StacAction.fromJson(json['isNotValid'] as Map), + ); + +Map _$StacFormValidateToJson(StacFormValidate instance) => + { + 'isValid': instance.isValid?.toJson(), + 'isNotValid': instance.isNotValid?.toJson(), + 'actionType': instance.actionType, + }; diff --git a/packages/stac_models/lib/actions/get_form_value/stac_get_form_value.dart b/packages/stac_models/lib/actions/get_form_value/stac_get_form_value.dart new file mode 100644 index 00000000..3dc797c2 --- /dev/null +++ b/packages/stac_models/lib/actions/get_form_value/stac_get_form_value.dart @@ -0,0 +1,20 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_action.dart'; + +part 'stac_get_form_value.g.dart'; + +@JsonSerializable() +class StacGetFormValue extends StacAction { + const StacGetFormValue({required this.id}); + + final String id; + + @override + String get actionType => 'getFormValue'; + + factory StacGetFormValue.fromJson(Map json) => + _$StacGetFormValueFromJson(json); + + @override + Map toJson() => _$StacGetFormValueToJson(this); +} diff --git a/packages/stac_models/lib/actions/get_form_value/stac_get_form_value.g.dart b/packages/stac_models/lib/actions/get_form_value/stac_get_form_value.g.dart new file mode 100644 index 00000000..eb994912 --- /dev/null +++ b/packages/stac_models/lib/actions/get_form_value/stac_get_form_value.g.dart @@ -0,0 +1,13 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_get_form_value.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacGetFormValue _$StacGetFormValueFromJson(Map json) => + StacGetFormValue(id: json['id'] as String); + +Map _$StacGetFormValueToJson(StacGetFormValue instance) => + {'id': instance.id, 'actionType': instance.actionType}; diff --git a/packages/stac_models/lib/actions/set_value/stac_set_value_action.dart b/packages/stac_models/lib/actions/set_value/stac_set_value_action.dart new file mode 100644 index 00000000..4bb108a1 --- /dev/null +++ b/packages/stac_models/lib/actions/set_value/stac_set_value_action.dart @@ -0,0 +1,21 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_action.dart'; + +part 'stac_set_value_action.g.dart'; + +@JsonSerializable() +class StacSetValueAction extends StacAction { + const StacSetValueAction({this.values, this.action}); + + final List>? values; + final Map? action; + + @override + String get actionType => 'setValue'; + + factory StacSetValueAction.fromJson(Map json) => + _$StacSetValueActionFromJson(json); + + @override + Map toJson() => _$StacSetValueActionToJson(this); +} diff --git a/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action.g.dart b/packages/stac_models/lib/actions/set_value/stac_set_value_action.g.dart similarity index 61% rename from packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action.g.dart rename to packages/stac_models/lib/actions/set_value/stac_set_value_action.g.dart index 0606d6c1..d61bf187 100644 --- a/packages/stac/lib/src/parsers/actions/stac_set_value/stac_set_value_action.g.dart +++ b/packages/stac_models/lib/actions/set_value/stac_set_value_action.g.dart @@ -6,17 +6,17 @@ part of 'stac_set_value_action.dart'; // JsonSerializableGenerator // ************************************************************************** -_StacSetValueAction _$StacSetValueActionFromJson(Map json) => - _StacSetValueAction( +StacSetValueAction _$StacSetValueActionFromJson(Map json) => + StacSetValueAction( values: (json['values'] as List?) - ?.map((e) => e as Map) - .toList() ?? - const [], + ?.map((e) => e as Map) + .toList(), action: json['action'] as Map?, ); -Map _$StacSetValueActionToJson(_StacSetValueAction instance) => +Map _$StacSetValueActionToJson(StacSetValueAction instance) => { 'values': instance.values, 'action': instance.action, + 'actionType': instance.actionType, };