diff --git a/packages/stac/lib/src/parsers/actions/actions.dart b/packages/stac/lib/src/parsers/actions/actions.dart index cd6d6050..7bb5aa07 100644 --- a/packages/stac/lib/src/parsers/actions/actions.dart +++ b/packages/stac/lib/src/parsers/actions/actions.dart @@ -1,8 +1,8 @@ -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_delay_action/stac_delay_action_parser.dart'; +export 'package:stac/src/parsers/actions/stac_dialog_action/stac_dialog_action_parser.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_multi_action/stac_multi_action_parser.dart'; export 'package:stac/src/parsers/actions/stac_navigate_action/stac_navigate_action_parser.dart'; export 'package:stac/src/parsers/actions/stac_none_action/stac_none_action_parser.dart'; export 'package:stac/src/parsers/actions/stac_set_value/stac_set_value_action_parser.dart'; -export 'package:stac/src/parsers/actions/stac_snack_bar/stac_snack_bar.dart'; +export 'package:stac/src/parsers/actions/stac_snack_bar/stac_snack_bar_parser.dart'; diff --git a/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action.dart b/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action.dart deleted file mode 100644 index cc4294ac..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -export 'stac_delay_action_parser.dart'; - -part 'stac_delay_action.freezed.dart'; -part 'stac_delay_action.g.dart'; - -@freezed -abstract class StacDelayAction with _$StacDelayAction { - const factory StacDelayAction({ - @Default(1000) int milliseconds, - }) = _StacDelayAction; - - factory StacDelayAction.fromJson(Map json) => - _$StacDelayActionFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action.freezed.dart b/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action.freezed.dart deleted file mode 100644 index 295f691b..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action.freezed.dart +++ /dev/null @@ -1,163 +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_delay_action.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacDelayAction { - int get milliseconds; - - /// Create a copy of StacDelayAction - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacDelayActionCopyWith get copyWith => - _$StacDelayActionCopyWithImpl( - this as StacDelayAction, _$identity); - - /// Serializes this StacDelayAction to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacDelayAction && - (identical(other.milliseconds, milliseconds) || - other.milliseconds == milliseconds)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, milliseconds); - - @override - String toString() { - return 'StacDelayAction(milliseconds: $milliseconds)'; - } -} - -/// @nodoc -abstract mixin class $StacDelayActionCopyWith<$Res> { - factory $StacDelayActionCopyWith( - StacDelayAction value, $Res Function(StacDelayAction) _then) = - _$StacDelayActionCopyWithImpl; - @useResult - $Res call({int milliseconds}); -} - -/// @nodoc -class _$StacDelayActionCopyWithImpl<$Res> - implements $StacDelayActionCopyWith<$Res> { - _$StacDelayActionCopyWithImpl(this._self, this._then); - - final StacDelayAction _self; - final $Res Function(StacDelayAction) _then; - - /// Create a copy of StacDelayAction - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? milliseconds = null, - }) { - return _then(_self.copyWith( - milliseconds: null == milliseconds - ? _self.milliseconds - : milliseconds // ignore: cast_nullable_to_non_nullable - as int, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacDelayAction implements StacDelayAction { - const _StacDelayAction({this.milliseconds = 1000}); - factory _StacDelayAction.fromJson(Map json) => - _$StacDelayActionFromJson(json); - - @override - @JsonKey() - final int milliseconds; - - /// Create a copy of StacDelayAction - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacDelayActionCopyWith<_StacDelayAction> get copyWith => - __$StacDelayActionCopyWithImpl<_StacDelayAction>(this, _$identity); - - @override - Map toJson() { - return _$StacDelayActionToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacDelayAction && - (identical(other.milliseconds, milliseconds) || - other.milliseconds == milliseconds)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, milliseconds); - - @override - String toString() { - return 'StacDelayAction(milliseconds: $milliseconds)'; - } -} - -/// @nodoc -abstract mixin class _$StacDelayActionCopyWith<$Res> - implements $StacDelayActionCopyWith<$Res> { - factory _$StacDelayActionCopyWith( - _StacDelayAction value, $Res Function(_StacDelayAction) _then) = - __$StacDelayActionCopyWithImpl; - @override - @useResult - $Res call({int milliseconds}); -} - -/// @nodoc -class __$StacDelayActionCopyWithImpl<$Res> - implements _$StacDelayActionCopyWith<$Res> { - __$StacDelayActionCopyWithImpl(this._self, this._then); - - final _StacDelayAction _self; - final $Res Function(_StacDelayAction) _then; - - /// Create a copy of StacDelayAction - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? milliseconds = null, - }) { - return _then(_StacDelayAction( - milliseconds: null == milliseconds - ? _self.milliseconds - : milliseconds // ignore: cast_nullable_to_non_nullable - as int, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action_parser.dart b/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action_parser.dart index 88f611ca..3636a8b3 100644 --- a/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action_parser.dart +++ b/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action_parser.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:stac/src/parsers/actions/stac_delay_action/stac_delay_action.dart'; +import 'package:stac_core/actions/delay/stac_delay_action.dart'; import 'package:stac/src/utils/action_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -17,6 +17,7 @@ class StacDelayActionParser extends StacActionParser { @override FutureOr onCall(BuildContext context, StacDelayAction model) { - return Future.delayed(Duration(milliseconds: model.milliseconds)); + final ms = model.milliseconds ?? 1000; + return Future.delayed(Duration(milliseconds: ms)); } } diff --git a/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action.dart b/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action.dart deleted file mode 100644 index 00d7fb05..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac_core/stac_core.dart'; - -export 'stac_dialog_action_parser.dart'; - -part 'stac_dialog_action.freezed.dart'; -part 'stac_dialog_action.g.dart'; - -@freezed -abstract class StacDialogAction with _$StacDialogAction { - const factory StacDialogAction({ - Map? widget, - StacNetworkRequest? request, - String? assetPath, - @Default(true) bool barrierDismissible, - String? barrierColor, - String? barrierLabel, - @Default(true) bool useSafeArea, - TraversalEdgeBehavior? traversalEdgeBehavior, - }) = _StacDialogAction; - - factory StacDialogAction.fromJson(Map json) => - _$StacDialogActionFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action.freezed.dart b/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action.freezed.dart deleted file mode 100644 index 819e22ba..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action.freezed.dart +++ /dev/null @@ -1,330 +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_dialog_action.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacDialogAction { - Map? get widget; - StacNetworkRequest? get request; - String? get assetPath; - bool get barrierDismissible; - String? get barrierColor; - String? get barrierLabel; - bool get useSafeArea; - TraversalEdgeBehavior? get traversalEdgeBehavior; - - /// Create a copy of StacDialogAction - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacDialogActionCopyWith get copyWith => - _$StacDialogActionCopyWithImpl( - this as StacDialogAction, _$identity); - - /// Serializes this StacDialogAction to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacDialogAction && - const DeepCollectionEquality().equals(other.widget, widget) && - (identical(other.request, request) || other.request == request) && - (identical(other.assetPath, assetPath) || - other.assetPath == assetPath) && - (identical(other.barrierDismissible, barrierDismissible) || - other.barrierDismissible == barrierDismissible) && - (identical(other.barrierColor, barrierColor) || - other.barrierColor == barrierColor) && - (identical(other.barrierLabel, barrierLabel) || - other.barrierLabel == barrierLabel) && - (identical(other.useSafeArea, useSafeArea) || - other.useSafeArea == useSafeArea) && - (identical(other.traversalEdgeBehavior, traversalEdgeBehavior) || - other.traversalEdgeBehavior == traversalEdgeBehavior)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(widget), - request, - assetPath, - barrierDismissible, - barrierColor, - barrierLabel, - useSafeArea, - traversalEdgeBehavior); - - @override - String toString() { - return 'StacDialogAction(widget: $widget, request: $request, assetPath: $assetPath, barrierDismissible: $barrierDismissible, barrierColor: $barrierColor, barrierLabel: $barrierLabel, useSafeArea: $useSafeArea, traversalEdgeBehavior: $traversalEdgeBehavior)'; - } -} - -/// @nodoc -abstract mixin class $StacDialogActionCopyWith<$Res> { - factory $StacDialogActionCopyWith( - StacDialogAction value, $Res Function(StacDialogAction) _then) = - _$StacDialogActionCopyWithImpl; - @useResult - $Res call( - {Map? widget, - StacNetworkRequest? request, - String? assetPath, - bool barrierDismissible, - String? barrierColor, - String? barrierLabel, - bool useSafeArea, - TraversalEdgeBehavior? traversalEdgeBehavior}); -} - -/// @nodoc -class _$StacDialogActionCopyWithImpl<$Res> - implements $StacDialogActionCopyWith<$Res> { - _$StacDialogActionCopyWithImpl(this._self, this._then); - - final StacDialogAction _self; - final $Res Function(StacDialogAction) _then; - - /// Create a copy of StacDialogAction - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? widget = freezed, - Object? request = freezed, - Object? assetPath = freezed, - Object? barrierDismissible = null, - Object? barrierColor = freezed, - Object? barrierLabel = freezed, - Object? useSafeArea = null, - Object? traversalEdgeBehavior = freezed, - }) { - return _then(_self.copyWith( - widget: freezed == widget - ? _self.widget - : widget // ignore: cast_nullable_to_non_nullable - as Map?, - request: freezed == request - ? _self.request - : request // ignore: cast_nullable_to_non_nullable - as StacNetworkRequest?, - assetPath: freezed == assetPath - ? _self.assetPath - : assetPath // ignore: cast_nullable_to_non_nullable - as String?, - barrierDismissible: null == barrierDismissible - ? _self.barrierDismissible - : barrierDismissible // ignore: cast_nullable_to_non_nullable - as bool, - barrierColor: freezed == barrierColor - ? _self.barrierColor - : barrierColor // ignore: cast_nullable_to_non_nullable - as String?, - barrierLabel: freezed == barrierLabel - ? _self.barrierLabel - : barrierLabel // ignore: cast_nullable_to_non_nullable - as String?, - useSafeArea: null == useSafeArea - ? _self.useSafeArea - : useSafeArea // ignore: cast_nullable_to_non_nullable - as bool, - traversalEdgeBehavior: freezed == traversalEdgeBehavior - ? _self.traversalEdgeBehavior - : traversalEdgeBehavior // ignore: cast_nullable_to_non_nullable - as TraversalEdgeBehavior?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacDialogAction implements StacDialogAction { - const _StacDialogAction( - {final Map? widget, - this.request, - this.assetPath, - this.barrierDismissible = true, - this.barrierColor, - this.barrierLabel, - this.useSafeArea = true, - this.traversalEdgeBehavior}) - : _widget = widget; - factory _StacDialogAction.fromJson(Map json) => - _$StacDialogActionFromJson(json); - - final Map? _widget; - @override - Map? get widget { - final value = _widget; - if (value == null) return null; - if (_widget is EqualUnmodifiableMapView) return _widget; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - final StacNetworkRequest? request; - @override - final String? assetPath; - @override - @JsonKey() - final bool barrierDismissible; - @override - final String? barrierColor; - @override - final String? barrierLabel; - @override - @JsonKey() - final bool useSafeArea; - @override - final TraversalEdgeBehavior? traversalEdgeBehavior; - - /// Create a copy of StacDialogAction - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacDialogActionCopyWith<_StacDialogAction> get copyWith => - __$StacDialogActionCopyWithImpl<_StacDialogAction>(this, _$identity); - - @override - Map toJson() { - return _$StacDialogActionToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacDialogAction && - const DeepCollectionEquality().equals(other._widget, _widget) && - (identical(other.request, request) || other.request == request) && - (identical(other.assetPath, assetPath) || - other.assetPath == assetPath) && - (identical(other.barrierDismissible, barrierDismissible) || - other.barrierDismissible == barrierDismissible) && - (identical(other.barrierColor, barrierColor) || - other.barrierColor == barrierColor) && - (identical(other.barrierLabel, barrierLabel) || - other.barrierLabel == barrierLabel) && - (identical(other.useSafeArea, useSafeArea) || - other.useSafeArea == useSafeArea) && - (identical(other.traversalEdgeBehavior, traversalEdgeBehavior) || - other.traversalEdgeBehavior == traversalEdgeBehavior)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_widget), - request, - assetPath, - barrierDismissible, - barrierColor, - barrierLabel, - useSafeArea, - traversalEdgeBehavior); - - @override - String toString() { - return 'StacDialogAction(widget: $widget, request: $request, assetPath: $assetPath, barrierDismissible: $barrierDismissible, barrierColor: $barrierColor, barrierLabel: $barrierLabel, useSafeArea: $useSafeArea, traversalEdgeBehavior: $traversalEdgeBehavior)'; - } -} - -/// @nodoc -abstract mixin class _$StacDialogActionCopyWith<$Res> - implements $StacDialogActionCopyWith<$Res> { - factory _$StacDialogActionCopyWith( - _StacDialogAction value, $Res Function(_StacDialogAction) _then) = - __$StacDialogActionCopyWithImpl; - @override - @useResult - $Res call( - {Map? widget, - StacNetworkRequest? request, - String? assetPath, - bool barrierDismissible, - String? barrierColor, - String? barrierLabel, - bool useSafeArea, - TraversalEdgeBehavior? traversalEdgeBehavior}); -} - -/// @nodoc -class __$StacDialogActionCopyWithImpl<$Res> - implements _$StacDialogActionCopyWith<$Res> { - __$StacDialogActionCopyWithImpl(this._self, this._then); - - final _StacDialogAction _self; - final $Res Function(_StacDialogAction) _then; - - /// Create a copy of StacDialogAction - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? widget = freezed, - Object? request = freezed, - Object? assetPath = freezed, - Object? barrierDismissible = null, - Object? barrierColor = freezed, - Object? barrierLabel = freezed, - Object? useSafeArea = null, - Object? traversalEdgeBehavior = freezed, - }) { - return _then(_StacDialogAction( - widget: freezed == widget - ? _self._widget - : widget // ignore: cast_nullable_to_non_nullable - as Map?, - request: freezed == request - ? _self.request - : request // ignore: cast_nullable_to_non_nullable - as StacNetworkRequest?, - assetPath: freezed == assetPath - ? _self.assetPath - : assetPath // ignore: cast_nullable_to_non_nullable - as String?, - barrierDismissible: null == barrierDismissible - ? _self.barrierDismissible - : barrierDismissible // ignore: cast_nullable_to_non_nullable - as bool, - barrierColor: freezed == barrierColor - ? _self.barrierColor - : barrierColor // ignore: cast_nullable_to_non_nullable - as String?, - barrierLabel: freezed == barrierLabel - ? _self.barrierLabel - : barrierLabel // ignore: cast_nullable_to_non_nullable - as String?, - useSafeArea: null == useSafeArea - ? _self.useSafeArea - : useSafeArea // ignore: cast_nullable_to_non_nullable - as bool, - traversalEdgeBehavior: freezed == traversalEdgeBehavior - ? _self.traversalEdgeBehavior - : traversalEdgeBehavior // ignore: cast_nullable_to_non_nullable - as TraversalEdgeBehavior?, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action.g.dart b/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action.g.dart deleted file mode 100644 index ada06d5e..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action.g.dart +++ /dev/null @@ -1,43 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_dialog_action.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacDialogAction _$StacDialogActionFromJson(Map json) => - _StacDialogAction( - widget: json['widget'] as Map?, - request: json['request'] == null - ? null - : StacNetworkRequest.fromJson( - json['request'] as Map), - assetPath: json['assetPath'] as String?, - barrierDismissible: json['barrierDismissible'] as bool? ?? true, - barrierColor: json['barrierColor'] as String?, - barrierLabel: json['barrierLabel'] as String?, - useSafeArea: json['useSafeArea'] as bool? ?? true, - traversalEdgeBehavior: $enumDecodeNullable( - _$TraversalEdgeBehaviorEnumMap, json['traversalEdgeBehavior']), - ); - -Map _$StacDialogActionToJson(_StacDialogAction instance) => - { - 'widget': instance.widget, - 'request': instance.request, - 'assetPath': instance.assetPath, - 'barrierDismissible': instance.barrierDismissible, - 'barrierColor': instance.barrierColor, - 'barrierLabel': instance.barrierLabel, - 'useSafeArea': instance.useSafeArea, - 'traversalEdgeBehavior': - _$TraversalEdgeBehaviorEnumMap[instance.traversalEdgeBehavior], - }; - -const _$TraversalEdgeBehaviorEnumMap = { - TraversalEdgeBehavior.closedLoop: 'closedLoop', - TraversalEdgeBehavior.leaveFlutterView: 'leaveFlutterView', - TraversalEdgeBehavior.parentScope: 'parentScope', - TraversalEdgeBehavior.stop: 'stop', -}; diff --git a/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action_parser.dart b/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action_parser.dart index 49baef6a..85d806ba 100644 --- a/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action_parser.dart +++ b/packages/stac/lib/src/parsers/actions/stac_dialog_action/stac_dialog_action_parser.dart @@ -1,7 +1,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:stac/src/parsers/actions/stac_dialog_action/stac_dialog_action.dart'; +import 'package:stac_core/actions/dialog/stac_dialog_action.dart'; +import 'package:stac/src/parsers/types/type_parser.dart'; import 'package:stac/src/framework/framework.dart'; import 'package:stac/src/utils/action_type.dart'; import 'package:stac/src/utils/color_utils.dart'; @@ -48,11 +49,11 @@ class StacDialogActionParser extends StacActionParser { return showDialog( context: context, builder: (_) => widget, - barrierDismissible: model.barrierDismissible, + barrierDismissible: model.barrierDismissible ?? true, barrierColor: model.barrierColor.toColor(context), barrierLabel: model.barrierLabel, - useSafeArea: model.useSafeArea, - traversalEdgeBehavior: model.traversalEdgeBehavior, + useSafeArea: model.useSafeArea ?? true, + traversalEdgeBehavior: model.traversalEdgeBehavior.parse, ); } } diff --git a/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.dart b/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.dart deleted file mode 100644 index 8dc96a43..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac_core/actions/network_request/stac_network_request.dart'; -import 'package:stac_core/types/stac_border/stac_border.dart'; -import 'package:stac_core/types/stac_box_constraints/stac_box_constraints.dart'; - -part 'stac_modal_bottom_sheet_action.freezed.dart'; -part 'stac_modal_bottom_sheet_action.g.dart'; - -@freezed -abstract class StacModalBottomSheetAction with _$StacModalBottomSheetAction { - const factory StacModalBottomSheetAction({ - Map? widget, - StacNetworkRequest? request, - String? assetPath, - String? backgroundColor, - String? barrierLabel, - double? elevation, - StacBorder? shape, - StacBoxConstraints? constraints, - String? barrierColor, - @Default(false) bool isScrollControlled, - @Default(false) bool useRootNavigator, - @Default(true) bool isDismissible, - @Default(true) bool enableDrag, - bool? showDragHandle, - @Default(false) bool useSafeArea, - }) = _StacModalBottomSheetAction; - - factory StacModalBottomSheetAction.fromJson(Map json) => - _$StacModalBottomSheetActionFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.freezed.dart b/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.freezed.dart deleted file mode 100644 index deeb76cb..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.freezed.dart +++ /dev/null @@ -1,488 +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_modal_bottom_sheet_action.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacModalBottomSheetAction { - Map? get widget; - StacNetworkRequest? get request; - String? get assetPath; - String? get backgroundColor; - String? get barrierLabel; - double? get elevation; - StacBorder? get shape; - StacBoxConstraints? get constraints; - String? get barrierColor; - bool get isScrollControlled; - bool get useRootNavigator; - bool get isDismissible; - bool get enableDrag; - bool? get showDragHandle; - bool get useSafeArea; - - /// Create a copy of StacModalBottomSheetAction - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacModalBottomSheetActionCopyWith - get copyWith => - _$StacModalBottomSheetActionCopyWithImpl( - this as StacModalBottomSheetAction, _$identity); - - /// Serializes this StacModalBottomSheetAction to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacModalBottomSheetAction && - const DeepCollectionEquality().equals(other.widget, widget) && - (identical(other.request, request) || other.request == request) && - (identical(other.assetPath, assetPath) || - other.assetPath == assetPath) && - (identical(other.backgroundColor, backgroundColor) || - other.backgroundColor == backgroundColor) && - (identical(other.barrierLabel, barrierLabel) || - other.barrierLabel == barrierLabel) && - (identical(other.elevation, elevation) || - other.elevation == elevation) && - (identical(other.shape, shape) || other.shape == shape) && - (identical(other.constraints, constraints) || - other.constraints == constraints) && - (identical(other.barrierColor, barrierColor) || - other.barrierColor == barrierColor) && - (identical(other.isScrollControlled, isScrollControlled) || - other.isScrollControlled == isScrollControlled) && - (identical(other.useRootNavigator, useRootNavigator) || - other.useRootNavigator == useRootNavigator) && - (identical(other.isDismissible, isDismissible) || - other.isDismissible == isDismissible) && - (identical(other.enableDrag, enableDrag) || - other.enableDrag == enableDrag) && - (identical(other.showDragHandle, showDragHandle) || - other.showDragHandle == showDragHandle) && - (identical(other.useSafeArea, useSafeArea) || - other.useSafeArea == useSafeArea)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(widget), - request, - assetPath, - backgroundColor, - barrierLabel, - elevation, - shape, - constraints, - barrierColor, - isScrollControlled, - useRootNavigator, - isDismissible, - enableDrag, - showDragHandle, - useSafeArea); - - @override - String toString() { - return 'StacModalBottomSheetAction(widget: $widget, request: $request, assetPath: $assetPath, backgroundColor: $backgroundColor, barrierLabel: $barrierLabel, elevation: $elevation, shape: $shape, constraints: $constraints, barrierColor: $barrierColor, isScrollControlled: $isScrollControlled, useRootNavigator: $useRootNavigator, isDismissible: $isDismissible, enableDrag: $enableDrag, showDragHandle: $showDragHandle, useSafeArea: $useSafeArea)'; - } -} - -/// @nodoc -abstract mixin class $StacModalBottomSheetActionCopyWith<$Res> { - factory $StacModalBottomSheetActionCopyWith(StacModalBottomSheetAction value, - $Res Function(StacModalBottomSheetAction) _then) = - _$StacModalBottomSheetActionCopyWithImpl; - @useResult - $Res call( - {Map? widget, - StacNetworkRequest? request, - String? assetPath, - String? backgroundColor, - String? barrierLabel, - double? elevation, - StacBorder? shape, - StacBoxConstraints? constraints, - String? barrierColor, - bool isScrollControlled, - bool useRootNavigator, - bool isDismissible, - bool enableDrag, - bool? showDragHandle, - bool useSafeArea}); -} - -/// @nodoc -class _$StacModalBottomSheetActionCopyWithImpl<$Res> - implements $StacModalBottomSheetActionCopyWith<$Res> { - _$StacModalBottomSheetActionCopyWithImpl(this._self, this._then); - - final StacModalBottomSheetAction _self; - final $Res Function(StacModalBottomSheetAction) _then; - - /// Create a copy of StacModalBottomSheetAction - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? widget = freezed, - Object? request = freezed, - Object? assetPath = freezed, - Object? backgroundColor = freezed, - Object? barrierLabel = freezed, - Object? elevation = freezed, - Object? shape = freezed, - Object? constraints = freezed, - Object? barrierColor = freezed, - Object? isScrollControlled = null, - Object? useRootNavigator = null, - Object? isDismissible = null, - Object? enableDrag = null, - Object? showDragHandle = freezed, - Object? useSafeArea = null, - }) { - return _then(_self.copyWith( - widget: freezed == widget - ? _self.widget - : widget // ignore: cast_nullable_to_non_nullable - as Map?, - request: freezed == request - ? _self.request - : request // ignore: cast_nullable_to_non_nullable - as StacNetworkRequest?, - assetPath: freezed == assetPath - ? _self.assetPath - : assetPath // ignore: cast_nullable_to_non_nullable - as String?, - backgroundColor: freezed == backgroundColor - ? _self.backgroundColor - : backgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - barrierLabel: freezed == barrierLabel - ? _self.barrierLabel - : barrierLabel // ignore: cast_nullable_to_non_nullable - as String?, - elevation: freezed == elevation - ? _self.elevation - : elevation // ignore: cast_nullable_to_non_nullable - as double?, - shape: freezed == shape - ? _self.shape - : shape // ignore: cast_nullable_to_non_nullable - as StacBorder?, - constraints: freezed == constraints - ? _self.constraints - : constraints // ignore: cast_nullable_to_non_nullable - as StacBoxConstraints?, - barrierColor: freezed == barrierColor - ? _self.barrierColor - : barrierColor // ignore: cast_nullable_to_non_nullable - as String?, - isScrollControlled: null == isScrollControlled - ? _self.isScrollControlled - : isScrollControlled // ignore: cast_nullable_to_non_nullable - as bool, - useRootNavigator: null == useRootNavigator - ? _self.useRootNavigator - : useRootNavigator // ignore: cast_nullable_to_non_nullable - as bool, - isDismissible: null == isDismissible - ? _self.isDismissible - : isDismissible // ignore: cast_nullable_to_non_nullable - as bool, - enableDrag: null == enableDrag - ? _self.enableDrag - : enableDrag // ignore: cast_nullable_to_non_nullable - as bool, - showDragHandle: freezed == showDragHandle - ? _self.showDragHandle - : showDragHandle // ignore: cast_nullable_to_non_nullable - as bool?, - useSafeArea: null == useSafeArea - ? _self.useSafeArea - : useSafeArea // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacModalBottomSheetAction implements StacModalBottomSheetAction { - const _StacModalBottomSheetAction( - {final Map? widget, - this.request, - this.assetPath, - this.backgroundColor, - this.barrierLabel, - this.elevation, - this.shape, - this.constraints, - this.barrierColor, - this.isScrollControlled = false, - this.useRootNavigator = false, - this.isDismissible = true, - this.enableDrag = true, - this.showDragHandle, - this.useSafeArea = false}) - : _widget = widget; - factory _StacModalBottomSheetAction.fromJson(Map json) => - _$StacModalBottomSheetActionFromJson(json); - - final Map? _widget; - @override - Map? get widget { - final value = _widget; - if (value == null) return null; - if (_widget is EqualUnmodifiableMapView) return _widget; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - final StacNetworkRequest? request; - @override - final String? assetPath; - @override - final String? backgroundColor; - @override - final String? barrierLabel; - @override - final double? elevation; - @override - final StacBorder? shape; - @override - final StacBoxConstraints? constraints; - @override - final String? barrierColor; - @override - @JsonKey() - final bool isScrollControlled; - @override - @JsonKey() - final bool useRootNavigator; - @override - @JsonKey() - final bool isDismissible; - @override - @JsonKey() - final bool enableDrag; - @override - final bool? showDragHandle; - @override - @JsonKey() - final bool useSafeArea; - - /// Create a copy of StacModalBottomSheetAction - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacModalBottomSheetActionCopyWith<_StacModalBottomSheetAction> - get copyWith => __$StacModalBottomSheetActionCopyWithImpl< - _StacModalBottomSheetAction>(this, _$identity); - - @override - Map toJson() { - return _$StacModalBottomSheetActionToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacModalBottomSheetAction && - const DeepCollectionEquality().equals(other._widget, _widget) && - (identical(other.request, request) || other.request == request) && - (identical(other.assetPath, assetPath) || - other.assetPath == assetPath) && - (identical(other.backgroundColor, backgroundColor) || - other.backgroundColor == backgroundColor) && - (identical(other.barrierLabel, barrierLabel) || - other.barrierLabel == barrierLabel) && - (identical(other.elevation, elevation) || - other.elevation == elevation) && - (identical(other.shape, shape) || other.shape == shape) && - (identical(other.constraints, constraints) || - other.constraints == constraints) && - (identical(other.barrierColor, barrierColor) || - other.barrierColor == barrierColor) && - (identical(other.isScrollControlled, isScrollControlled) || - other.isScrollControlled == isScrollControlled) && - (identical(other.useRootNavigator, useRootNavigator) || - other.useRootNavigator == useRootNavigator) && - (identical(other.isDismissible, isDismissible) || - other.isDismissible == isDismissible) && - (identical(other.enableDrag, enableDrag) || - other.enableDrag == enableDrag) && - (identical(other.showDragHandle, showDragHandle) || - other.showDragHandle == showDragHandle) && - (identical(other.useSafeArea, useSafeArea) || - other.useSafeArea == useSafeArea)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_widget), - request, - assetPath, - backgroundColor, - barrierLabel, - elevation, - shape, - constraints, - barrierColor, - isScrollControlled, - useRootNavigator, - isDismissible, - enableDrag, - showDragHandle, - useSafeArea); - - @override - String toString() { - return 'StacModalBottomSheetAction(widget: $widget, request: $request, assetPath: $assetPath, backgroundColor: $backgroundColor, barrierLabel: $barrierLabel, elevation: $elevation, shape: $shape, constraints: $constraints, barrierColor: $barrierColor, isScrollControlled: $isScrollControlled, useRootNavigator: $useRootNavigator, isDismissible: $isDismissible, enableDrag: $enableDrag, showDragHandle: $showDragHandle, useSafeArea: $useSafeArea)'; - } -} - -/// @nodoc -abstract mixin class _$StacModalBottomSheetActionCopyWith<$Res> - implements $StacModalBottomSheetActionCopyWith<$Res> { - factory _$StacModalBottomSheetActionCopyWith( - _StacModalBottomSheetAction value, - $Res Function(_StacModalBottomSheetAction) _then) = - __$StacModalBottomSheetActionCopyWithImpl; - @override - @useResult - $Res call( - {Map? widget, - StacNetworkRequest? request, - String? assetPath, - String? backgroundColor, - String? barrierLabel, - double? elevation, - StacBorder? shape, - StacBoxConstraints? constraints, - String? barrierColor, - bool isScrollControlled, - bool useRootNavigator, - bool isDismissible, - bool enableDrag, - bool? showDragHandle, - bool useSafeArea}); -} - -/// @nodoc -class __$StacModalBottomSheetActionCopyWithImpl<$Res> - implements _$StacModalBottomSheetActionCopyWith<$Res> { - __$StacModalBottomSheetActionCopyWithImpl(this._self, this._then); - - final _StacModalBottomSheetAction _self; - final $Res Function(_StacModalBottomSheetAction) _then; - - /// Create a copy of StacModalBottomSheetAction - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? widget = freezed, - Object? request = freezed, - Object? assetPath = freezed, - Object? backgroundColor = freezed, - Object? barrierLabel = freezed, - Object? elevation = freezed, - Object? shape = freezed, - Object? constraints = freezed, - Object? barrierColor = freezed, - Object? isScrollControlled = null, - Object? useRootNavigator = null, - Object? isDismissible = null, - Object? enableDrag = null, - Object? showDragHandle = freezed, - Object? useSafeArea = null, - }) { - return _then(_StacModalBottomSheetAction( - widget: freezed == widget - ? _self._widget - : widget // ignore: cast_nullable_to_non_nullable - as Map?, - request: freezed == request - ? _self.request - : request // ignore: cast_nullable_to_non_nullable - as StacNetworkRequest?, - assetPath: freezed == assetPath - ? _self.assetPath - : assetPath // ignore: cast_nullable_to_non_nullable - as String?, - backgroundColor: freezed == backgroundColor - ? _self.backgroundColor - : backgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - barrierLabel: freezed == barrierLabel - ? _self.barrierLabel - : barrierLabel // ignore: cast_nullable_to_non_nullable - as String?, - elevation: freezed == elevation - ? _self.elevation - : elevation // ignore: cast_nullable_to_non_nullable - as double?, - shape: freezed == shape - ? _self.shape - : shape // ignore: cast_nullable_to_non_nullable - as StacBorder?, - constraints: freezed == constraints - ? _self.constraints - : constraints // ignore: cast_nullable_to_non_nullable - as StacBoxConstraints?, - barrierColor: freezed == barrierColor - ? _self.barrierColor - : barrierColor // ignore: cast_nullable_to_non_nullable - as String?, - isScrollControlled: null == isScrollControlled - ? _self.isScrollControlled - : isScrollControlled // ignore: cast_nullable_to_non_nullable - as bool, - useRootNavigator: null == useRootNavigator - ? _self.useRootNavigator - : useRootNavigator // ignore: cast_nullable_to_non_nullable - as bool, - isDismissible: null == isDismissible - ? _self.isDismissible - : isDismissible // ignore: cast_nullable_to_non_nullable - as bool, - enableDrag: null == enableDrag - ? _self.enableDrag - : enableDrag // ignore: cast_nullable_to_non_nullable - as bool, - showDragHandle: freezed == showDragHandle - ? _self.showDragHandle - : showDragHandle // ignore: cast_nullable_to_non_nullable - as bool?, - useSafeArea: null == useSafeArea - ? _self.useSafeArea - : useSafeArea // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.g.dart b/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.g.dart deleted file mode 100644 index 5ee1400b..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.g.dart +++ /dev/null @@ -1,55 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_modal_bottom_sheet_action.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacModalBottomSheetAction _$StacModalBottomSheetActionFromJson( - Map json) => - _StacModalBottomSheetAction( - widget: json['widget'] as Map?, - request: json['request'] == null - ? null - : StacNetworkRequest.fromJson( - json['request'] as Map), - assetPath: json['assetPath'] as String?, - backgroundColor: json['backgroundColor'] as String?, - barrierLabel: json['barrierLabel'] as String?, - elevation: (json['elevation'] as num?)?.toDouble(), - shape: json['shape'] == null - ? null - : StacBorder.fromJson(json['shape'] as Map), - constraints: json['constraints'] == null - ? null - : StacBoxConstraints.fromJson( - json['constraints'] as Map), - barrierColor: json['barrierColor'] as String?, - isScrollControlled: json['isScrollControlled'] as bool? ?? false, - useRootNavigator: json['useRootNavigator'] as bool? ?? false, - isDismissible: json['isDismissible'] as bool? ?? true, - enableDrag: json['enableDrag'] as bool? ?? true, - showDragHandle: json['showDragHandle'] as bool?, - useSafeArea: json['useSafeArea'] as bool? ?? false, - ); - -Map _$StacModalBottomSheetActionToJson( - _StacModalBottomSheetAction instance) => - { - 'widget': instance.widget, - 'request': instance.request, - 'assetPath': instance.assetPath, - 'backgroundColor': instance.backgroundColor, - 'barrierLabel': instance.barrierLabel, - 'elevation': instance.elevation, - 'shape': instance.shape, - 'constraints': instance.constraints, - 'barrierColor': instance.barrierColor, - 'isScrollControlled': instance.isScrollControlled, - 'useRootNavigator': instance.useRootNavigator, - 'isDismissible': instance.isDismissible, - 'enableDrag': instance.enableDrag, - 'showDragHandle': instance.showDragHandle, - 'useSafeArea': instance.useSafeArea, - }; diff --git a/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action_parser.dart b/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action_parser.dart index 9d2f1f70..c8539426 100644 --- a/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action_parser.dart +++ b/packages/stac/lib/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action_parser.dart @@ -2,14 +2,13 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; -import 'package:stac/src/parsers/actions/stac_modal_bottom_sheet_action/stac_modal_bottom_sheet_action.dart'; +import 'package:stac/src/parsers/core/stac_widget_parser.dart'; +import 'package:stac_core/actions/modal_bottom_sheet/stac_modal_bottom_sheet_action.dart'; import 'package:stac/src/parsers/types/type_parser.dart'; import 'package:stac/src/utils/action_type.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac_framework/stac_framework.dart'; -export 'stac_modal_bottom_sheet_action.dart'; - class StacModalBottomSheetActionParser extends StacActionParser { const StacModalBottomSheetActionParser(); @@ -27,7 +26,7 @@ class StacModalBottomSheetActionParser return _showModalBottomSheet( context, model, - Stac.fromJson(model.widget, context) ?? const SizedBox(), + model.widget?.parse(context) ?? const SizedBox(), ); } else if (model.assetPath?.isNotEmpty ?? false) { return _showModalBottomSheet( @@ -58,12 +57,12 @@ class StacModalBottomSheetActionParser shape: model.shape?.parse(context), constraints: model.constraints?.parse, barrierColor: model.barrierColor.toColor(context), - isScrollControlled: model.isScrollControlled, - useRootNavigator: model.useRootNavigator, - isDismissible: model.isDismissible, - enableDrag: model.enableDrag, + isScrollControlled: model.isScrollControlled ?? false, + useRootNavigator: model.useRootNavigator ?? false, + isDismissible: model.isDismissible ?? true, + enableDrag: model.enableDrag ?? true, showDragHandle: model.showDragHandle, - useSafeArea: model.useSafeArea, + useSafeArea: model.useSafeArea ?? false, ); } } diff --git a/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action.dart b/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action.dart deleted file mode 100644 index 024743d4..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -export 'stac_multi_action_parser.dart'; - -part 'stac_multi_action.freezed.dart'; -part 'stac_multi_action.g.dart'; - -@freezed -abstract class StacMultiAction with _$StacMultiAction { - const factory StacMultiAction({ - required List?>? actions, - @Default(false) bool sync, - }) = _StacMultiAction; - - factory StacMultiAction.fromJson(Map json) => - _$StacMultiActionFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action.freezed.dart b/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action.freezed.dart deleted file mode 100644 index c3536752..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action.freezed.dart +++ /dev/null @@ -1,188 +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_multi_action.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacMultiAction { - List?>? get actions; - bool get sync; - - /// Create a copy of StacMultiAction - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacMultiActionCopyWith get copyWith => - _$StacMultiActionCopyWithImpl( - this as StacMultiAction, _$identity); - - /// Serializes this StacMultiAction to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacMultiAction && - const DeepCollectionEquality().equals(other.actions, actions) && - (identical(other.sync, sync) || other.sync == sync)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, const DeepCollectionEquality().hash(actions), sync); - - @override - String toString() { - return 'StacMultiAction(actions: $actions, sync: $sync)'; - } -} - -/// @nodoc -abstract mixin class $StacMultiActionCopyWith<$Res> { - factory $StacMultiActionCopyWith( - StacMultiAction value, $Res Function(StacMultiAction) _then) = - _$StacMultiActionCopyWithImpl; - @useResult - $Res call({List?>? actions, bool sync}); -} - -/// @nodoc -class _$StacMultiActionCopyWithImpl<$Res> - implements $StacMultiActionCopyWith<$Res> { - _$StacMultiActionCopyWithImpl(this._self, this._then); - - final StacMultiAction _self; - final $Res Function(StacMultiAction) _then; - - /// Create a copy of StacMultiAction - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? actions = freezed, - Object? sync = null, - }) { - return _then(_self.copyWith( - actions: freezed == actions - ? _self.actions - : actions // ignore: cast_nullable_to_non_nullable - as List?>?, - sync: null == sync - ? _self.sync - : sync // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacMultiAction implements StacMultiAction { - const _StacMultiAction( - {required final List?>? actions, this.sync = false}) - : _actions = actions; - factory _StacMultiAction.fromJson(Map json) => - _$StacMultiActionFromJson(json); - - final List?>? _actions; - @override - List?>? get actions { - final value = _actions; - if (value == null) return null; - if (_actions is EqualUnmodifiableListView) return _actions; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); - } - - @override - @JsonKey() - final bool sync; - - /// Create a copy of StacMultiAction - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacMultiActionCopyWith<_StacMultiAction> get copyWith => - __$StacMultiActionCopyWithImpl<_StacMultiAction>(this, _$identity); - - @override - Map toJson() { - return _$StacMultiActionToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacMultiAction && - const DeepCollectionEquality().equals(other._actions, _actions) && - (identical(other.sync, sync) || other.sync == sync)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, const DeepCollectionEquality().hash(_actions), sync); - - @override - String toString() { - return 'StacMultiAction(actions: $actions, sync: $sync)'; - } -} - -/// @nodoc -abstract mixin class _$StacMultiActionCopyWith<$Res> - implements $StacMultiActionCopyWith<$Res> { - factory _$StacMultiActionCopyWith( - _StacMultiAction value, $Res Function(_StacMultiAction) _then) = - __$StacMultiActionCopyWithImpl; - @override - @useResult - $Res call({List?>? actions, bool sync}); -} - -/// @nodoc -class __$StacMultiActionCopyWithImpl<$Res> - implements _$StacMultiActionCopyWith<$Res> { - __$StacMultiActionCopyWithImpl(this._self, this._then); - - final _StacMultiAction _self; - final $Res Function(_StacMultiAction) _then; - - /// Create a copy of StacMultiAction - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? actions = freezed, - Object? sync = null, - }) { - return _then(_StacMultiAction( - actions: freezed == actions - ? _self._actions - : actions // ignore: cast_nullable_to_non_nullable - as List?>?, - sync: null == sync - ? _self.sync - : sync // ignore: cast_nullable_to_non_nullable - as bool, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action_parser.dart b/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action_parser.dart index 7070cc6b..dfb46831 100644 --- a/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action_parser.dart +++ b/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action_parser.dart @@ -1,9 +1,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:stac/src/parsers/actions/stac_multi_action/stac_multi_action.dart'; +import 'package:stac/src/parsers/core/stac_action_parser.dart'; +import 'package:stac_core/actions/multi/stac_multi_action.dart'; import 'package:stac/src/utils/action_type.dart'; -import 'package:stac/src/framework/framework.dart'; import 'package:stac_framework/stac_framework.dart'; class StacMultiActionParser extends StacActionParser { @@ -19,10 +19,8 @@ class StacMultiActionParser extends StacActionParser { @override FutureOr onCall(BuildContext context, StacMultiAction model) async { final actions = model.actions ?? []; - for (var json in actions) { - model.sync - ? await Stac.onCallFromJson(json, context) - : Stac.onCallFromJson(json, context); + for (var action in actions) { + model.sync ? await action.parse(context) : action.parse(context); } } } diff --git a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar.dart b/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar.dart deleted file mode 100644 index 327a49d8..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.dart'; -import 'package:stac/src/parsers/widgets/stac_duration/stac_duration.dart'; -import 'package:stac_core/painting/stac_edge_insets/stac_edge_insets.dart'; -import 'package:stac_core/types/stac_shape_border/stac_shape_border.dart'; - -export 'stac_snack_bar_parser.dart'; - -part 'stac_snack_bar.freezed.dart'; -part 'stac_snack_bar.g.dart'; - -@freezed -abstract class StacSnackBar with _$StacSnackBar { - const factory StacSnackBar({ - required Map content, - String? backgroundColor, - double? elevation, - StacEdgeInsets? margin, - StacEdgeInsets? padding, - double? width, - StacShapeBorder? shape, - HitTestBehavior? hitTestBehavior, - SnackBarBehavior? behavior, - StacSnackBarAction? action, - double? actionOverflowThreshold, - bool? showCloseIcon, - String? closeIconColor, - @Default(StacDuration(milliseconds: 4000)) StacDuration duration, - Map? onVisible, - DismissDirection? dismissDirection, - @Default(Clip.hardEdge) Clip clipBehavior, - }) = _StacSnackBar; - - factory StacSnackBar.fromJson(Map json) => - _$StacSnackBarFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar.freezed.dart b/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar.freezed.dart deleted file mode 100644 index fd82f2b7..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar.freezed.dart +++ /dev/null @@ -1,583 +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_snack_bar.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacSnackBar { - Map get content; - String? get backgroundColor; - double? get elevation; - StacEdgeInsets? get margin; - StacEdgeInsets? get padding; - double? get width; - StacShapeBorder? get shape; - HitTestBehavior? get hitTestBehavior; - SnackBarBehavior? get behavior; - StacSnackBarAction? get action; - double? get actionOverflowThreshold; - bool? get showCloseIcon; - String? get closeIconColor; - StacDuration get duration; - Map? get onVisible; - DismissDirection? get dismissDirection; - Clip get clipBehavior; - - /// Create a copy of StacSnackBar - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacSnackBarCopyWith get copyWith => - _$StacSnackBarCopyWithImpl( - this as StacSnackBar, _$identity); - - /// Serializes this StacSnackBar to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacSnackBar && - const DeepCollectionEquality().equals(other.content, content) && - (identical(other.backgroundColor, backgroundColor) || - other.backgroundColor == backgroundColor) && - (identical(other.elevation, elevation) || - other.elevation == elevation) && - (identical(other.margin, margin) || other.margin == margin) && - (identical(other.padding, padding) || other.padding == padding) && - (identical(other.width, width) || other.width == width) && - (identical(other.shape, shape) || other.shape == shape) && - (identical(other.hitTestBehavior, hitTestBehavior) || - other.hitTestBehavior == hitTestBehavior) && - (identical(other.behavior, behavior) || - other.behavior == behavior) && - (identical(other.action, action) || other.action == action) && - (identical( - other.actionOverflowThreshold, actionOverflowThreshold) || - other.actionOverflowThreshold == actionOverflowThreshold) && - (identical(other.showCloseIcon, showCloseIcon) || - other.showCloseIcon == showCloseIcon) && - (identical(other.closeIconColor, closeIconColor) || - other.closeIconColor == closeIconColor) && - (identical(other.duration, duration) || - other.duration == duration) && - const DeepCollectionEquality().equals(other.onVisible, onVisible) && - (identical(other.dismissDirection, dismissDirection) || - other.dismissDirection == dismissDirection) && - (identical(other.clipBehavior, clipBehavior) || - other.clipBehavior == clipBehavior)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(content), - backgroundColor, - elevation, - margin, - padding, - width, - shape, - hitTestBehavior, - behavior, - action, - actionOverflowThreshold, - showCloseIcon, - closeIconColor, - duration, - const DeepCollectionEquality().hash(onVisible), - dismissDirection, - clipBehavior); - - @override - String toString() { - return 'StacSnackBar(content: $content, backgroundColor: $backgroundColor, elevation: $elevation, margin: $margin, padding: $padding, width: $width, shape: $shape, hitTestBehavior: $hitTestBehavior, behavior: $behavior, action: $action, actionOverflowThreshold: $actionOverflowThreshold, showCloseIcon: $showCloseIcon, closeIconColor: $closeIconColor, duration: $duration, onVisible: $onVisible, dismissDirection: $dismissDirection, clipBehavior: $clipBehavior)'; - } -} - -/// @nodoc -abstract mixin class $StacSnackBarCopyWith<$Res> { - factory $StacSnackBarCopyWith( - StacSnackBar value, $Res Function(StacSnackBar) _then) = - _$StacSnackBarCopyWithImpl; - @useResult - $Res call( - {Map content, - String? backgroundColor, - double? elevation, - StacEdgeInsets? margin, - StacEdgeInsets? padding, - double? width, - StacShapeBorder? shape, - HitTestBehavior? hitTestBehavior, - SnackBarBehavior? behavior, - StacSnackBarAction? action, - double? actionOverflowThreshold, - bool? showCloseIcon, - String? closeIconColor, - StacDuration duration, - Map? onVisible, - DismissDirection? dismissDirection, - Clip clipBehavior}); - - $StacSnackBarActionCopyWith<$Res>? get action; - $StacDurationCopyWith<$Res> get duration; -} - -/// @nodoc -class _$StacSnackBarCopyWithImpl<$Res> implements $StacSnackBarCopyWith<$Res> { - _$StacSnackBarCopyWithImpl(this._self, this._then); - - final StacSnackBar _self; - final $Res Function(StacSnackBar) _then; - - /// Create a copy of StacSnackBar - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? content = null, - Object? backgroundColor = freezed, - Object? elevation = freezed, - Object? margin = freezed, - Object? padding = freezed, - Object? width = freezed, - Object? shape = freezed, - Object? hitTestBehavior = freezed, - Object? behavior = freezed, - Object? action = freezed, - Object? actionOverflowThreshold = freezed, - Object? showCloseIcon = freezed, - Object? closeIconColor = freezed, - Object? duration = null, - Object? onVisible = freezed, - Object? dismissDirection = freezed, - Object? clipBehavior = null, - }) { - return _then(_self.copyWith( - content: null == content - ? _self.content - : content // ignore: cast_nullable_to_non_nullable - as Map, - backgroundColor: freezed == backgroundColor - ? _self.backgroundColor - : backgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - elevation: freezed == elevation - ? _self.elevation - : elevation // ignore: cast_nullable_to_non_nullable - as double?, - margin: freezed == margin - ? _self.margin - : margin // ignore: cast_nullable_to_non_nullable - as StacEdgeInsets?, - padding: freezed == padding - ? _self.padding - : padding // ignore: cast_nullable_to_non_nullable - as StacEdgeInsets?, - width: freezed == width - ? _self.width - : width // ignore: cast_nullable_to_non_nullable - as double?, - shape: freezed == shape - ? _self.shape - : shape // ignore: cast_nullable_to_non_nullable - as StacShapeBorder?, - hitTestBehavior: freezed == hitTestBehavior - ? _self.hitTestBehavior - : hitTestBehavior // ignore: cast_nullable_to_non_nullable - as HitTestBehavior?, - behavior: freezed == behavior - ? _self.behavior - : behavior // ignore: cast_nullable_to_non_nullable - as SnackBarBehavior?, - action: freezed == action - ? _self.action - : action // ignore: cast_nullable_to_non_nullable - as StacSnackBarAction?, - actionOverflowThreshold: freezed == actionOverflowThreshold - ? _self.actionOverflowThreshold - : actionOverflowThreshold // ignore: cast_nullable_to_non_nullable - as double?, - showCloseIcon: freezed == showCloseIcon - ? _self.showCloseIcon - : showCloseIcon // ignore: cast_nullable_to_non_nullable - as bool?, - closeIconColor: freezed == closeIconColor - ? _self.closeIconColor - : closeIconColor // ignore: cast_nullable_to_non_nullable - as String?, - duration: null == duration - ? _self.duration - : duration // ignore: cast_nullable_to_non_nullable - as StacDuration, - onVisible: freezed == onVisible - ? _self.onVisible - : onVisible // ignore: cast_nullable_to_non_nullable - as Map?, - dismissDirection: freezed == dismissDirection - ? _self.dismissDirection - : dismissDirection // ignore: cast_nullable_to_non_nullable - as DismissDirection?, - clipBehavior: null == clipBehavior - ? _self.clipBehavior - : clipBehavior // ignore: cast_nullable_to_non_nullable - as Clip, - )); - } - - /// Create a copy of StacSnackBar - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacSnackBarActionCopyWith<$Res>? get action { - if (_self.action == null) { - return null; - } - - return $StacSnackBarActionCopyWith<$Res>(_self.action!, (value) { - return _then(_self.copyWith(action: value)); - }); - } - - /// Create a copy of StacSnackBar - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacDurationCopyWith<$Res> get duration { - return $StacDurationCopyWith<$Res>(_self.duration, (value) { - return _then(_self.copyWith(duration: value)); - }); - } -} - -/// @nodoc -@JsonSerializable() -class _StacSnackBar implements StacSnackBar { - const _StacSnackBar( - {required final Map content, - this.backgroundColor, - this.elevation, - this.margin, - this.padding, - this.width, - this.shape, - this.hitTestBehavior, - this.behavior, - this.action, - this.actionOverflowThreshold, - this.showCloseIcon, - this.closeIconColor, - this.duration = const StacDuration(milliseconds: 4000), - final Map? onVisible, - this.dismissDirection, - this.clipBehavior = Clip.hardEdge}) - : _content = content, - _onVisible = onVisible; - factory _StacSnackBar.fromJson(Map json) => - _$StacSnackBarFromJson(json); - - final Map _content; - @override - Map get content { - if (_content is EqualUnmodifiableMapView) return _content; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_content); - } - - @override - final String? backgroundColor; - @override - final double? elevation; - @override - final StacEdgeInsets? margin; - @override - final StacEdgeInsets? padding; - @override - final double? width; - @override - final StacShapeBorder? shape; - @override - final HitTestBehavior? hitTestBehavior; - @override - final SnackBarBehavior? behavior; - @override - final StacSnackBarAction? action; - @override - final double? actionOverflowThreshold; - @override - final bool? showCloseIcon; - @override - final String? closeIconColor; - @override - @JsonKey() - final StacDuration duration; - final Map? _onVisible; - @override - Map? get onVisible { - final value = _onVisible; - if (value == null) return null; - if (_onVisible is EqualUnmodifiableMapView) return _onVisible; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - final DismissDirection? dismissDirection; - @override - @JsonKey() - final Clip clipBehavior; - - /// Create a copy of StacSnackBar - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacSnackBarCopyWith<_StacSnackBar> get copyWith => - __$StacSnackBarCopyWithImpl<_StacSnackBar>(this, _$identity); - - @override - Map toJson() { - return _$StacSnackBarToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacSnackBar && - const DeepCollectionEquality().equals(other._content, _content) && - (identical(other.backgroundColor, backgroundColor) || - other.backgroundColor == backgroundColor) && - (identical(other.elevation, elevation) || - other.elevation == elevation) && - (identical(other.margin, margin) || other.margin == margin) && - (identical(other.padding, padding) || other.padding == padding) && - (identical(other.width, width) || other.width == width) && - (identical(other.shape, shape) || other.shape == shape) && - (identical(other.hitTestBehavior, hitTestBehavior) || - other.hitTestBehavior == hitTestBehavior) && - (identical(other.behavior, behavior) || - other.behavior == behavior) && - (identical(other.action, action) || other.action == action) && - (identical( - other.actionOverflowThreshold, actionOverflowThreshold) || - other.actionOverflowThreshold == actionOverflowThreshold) && - (identical(other.showCloseIcon, showCloseIcon) || - other.showCloseIcon == showCloseIcon) && - (identical(other.closeIconColor, closeIconColor) || - other.closeIconColor == closeIconColor) && - (identical(other.duration, duration) || - other.duration == duration) && - const DeepCollectionEquality() - .equals(other._onVisible, _onVisible) && - (identical(other.dismissDirection, dismissDirection) || - other.dismissDirection == dismissDirection) && - (identical(other.clipBehavior, clipBehavior) || - other.clipBehavior == clipBehavior)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_content), - backgroundColor, - elevation, - margin, - padding, - width, - shape, - hitTestBehavior, - behavior, - action, - actionOverflowThreshold, - showCloseIcon, - closeIconColor, - duration, - const DeepCollectionEquality().hash(_onVisible), - dismissDirection, - clipBehavior); - - @override - String toString() { - return 'StacSnackBar(content: $content, backgroundColor: $backgroundColor, elevation: $elevation, margin: $margin, padding: $padding, width: $width, shape: $shape, hitTestBehavior: $hitTestBehavior, behavior: $behavior, action: $action, actionOverflowThreshold: $actionOverflowThreshold, showCloseIcon: $showCloseIcon, closeIconColor: $closeIconColor, duration: $duration, onVisible: $onVisible, dismissDirection: $dismissDirection, clipBehavior: $clipBehavior)'; - } -} - -/// @nodoc -abstract mixin class _$StacSnackBarCopyWith<$Res> - implements $StacSnackBarCopyWith<$Res> { - factory _$StacSnackBarCopyWith( - _StacSnackBar value, $Res Function(_StacSnackBar) _then) = - __$StacSnackBarCopyWithImpl; - @override - @useResult - $Res call( - {Map content, - String? backgroundColor, - double? elevation, - StacEdgeInsets? margin, - StacEdgeInsets? padding, - double? width, - StacShapeBorder? shape, - HitTestBehavior? hitTestBehavior, - SnackBarBehavior? behavior, - StacSnackBarAction? action, - double? actionOverflowThreshold, - bool? showCloseIcon, - String? closeIconColor, - StacDuration duration, - Map? onVisible, - DismissDirection? dismissDirection, - Clip clipBehavior}); - - @override - $StacSnackBarActionCopyWith<$Res>? get action; - @override - $StacDurationCopyWith<$Res> get duration; -} - -/// @nodoc -class __$StacSnackBarCopyWithImpl<$Res> - implements _$StacSnackBarCopyWith<$Res> { - __$StacSnackBarCopyWithImpl(this._self, this._then); - - final _StacSnackBar _self; - final $Res Function(_StacSnackBar) _then; - - /// Create a copy of StacSnackBar - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? content = null, - Object? backgroundColor = freezed, - Object? elevation = freezed, - Object? margin = freezed, - Object? padding = freezed, - Object? width = freezed, - Object? shape = freezed, - Object? hitTestBehavior = freezed, - Object? behavior = freezed, - Object? action = freezed, - Object? actionOverflowThreshold = freezed, - Object? showCloseIcon = freezed, - Object? closeIconColor = freezed, - Object? duration = null, - Object? onVisible = freezed, - Object? dismissDirection = freezed, - Object? clipBehavior = null, - }) { - return _then(_StacSnackBar( - content: null == content - ? _self._content - : content // ignore: cast_nullable_to_non_nullable - as Map, - backgroundColor: freezed == backgroundColor - ? _self.backgroundColor - : backgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - elevation: freezed == elevation - ? _self.elevation - : elevation // ignore: cast_nullable_to_non_nullable - as double?, - margin: freezed == margin - ? _self.margin - : margin // ignore: cast_nullable_to_non_nullable - as StacEdgeInsets?, - padding: freezed == padding - ? _self.padding - : padding // ignore: cast_nullable_to_non_nullable - as StacEdgeInsets?, - width: freezed == width - ? _self.width - : width // ignore: cast_nullable_to_non_nullable - as double?, - shape: freezed == shape - ? _self.shape - : shape // ignore: cast_nullable_to_non_nullable - as StacShapeBorder?, - hitTestBehavior: freezed == hitTestBehavior - ? _self.hitTestBehavior - : hitTestBehavior // ignore: cast_nullable_to_non_nullable - as HitTestBehavior?, - behavior: freezed == behavior - ? _self.behavior - : behavior // ignore: cast_nullable_to_non_nullable - as SnackBarBehavior?, - action: freezed == action - ? _self.action - : action // ignore: cast_nullable_to_non_nullable - as StacSnackBarAction?, - actionOverflowThreshold: freezed == actionOverflowThreshold - ? _self.actionOverflowThreshold - : actionOverflowThreshold // ignore: cast_nullable_to_non_nullable - as double?, - showCloseIcon: freezed == showCloseIcon - ? _self.showCloseIcon - : showCloseIcon // ignore: cast_nullable_to_non_nullable - as bool?, - closeIconColor: freezed == closeIconColor - ? _self.closeIconColor - : closeIconColor // ignore: cast_nullable_to_non_nullable - as String?, - duration: null == duration - ? _self.duration - : duration // ignore: cast_nullable_to_non_nullable - as StacDuration, - onVisible: freezed == onVisible - ? _self._onVisible - : onVisible // ignore: cast_nullable_to_non_nullable - as Map?, - dismissDirection: freezed == dismissDirection - ? _self.dismissDirection - : dismissDirection // ignore: cast_nullable_to_non_nullable - as DismissDirection?, - clipBehavior: null == clipBehavior - ? _self.clipBehavior - : clipBehavior // ignore: cast_nullable_to_non_nullable - as Clip, - )); - } - - /// Create a copy of StacSnackBar - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacSnackBarActionCopyWith<$Res>? get action { - if (_self.action == null) { - return null; - } - - return $StacSnackBarActionCopyWith<$Res>(_self.action!, (value) { - return _then(_self.copyWith(action: value)); - }); - } - - /// Create a copy of StacSnackBar - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacDurationCopyWith<$Res> get duration { - return $StacDurationCopyWith<$Res>(_self.duration, (value) { - return _then(_self.copyWith(duration: value)); - }); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar.g.dart b/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar.g.dart deleted file mode 100644 index b59e2f61..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar.g.dart +++ /dev/null @@ -1,92 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_snack_bar.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacSnackBar _$StacSnackBarFromJson(Map json) => - _StacSnackBar( - content: json['content'] as Map, - backgroundColor: json['backgroundColor'] as String?, - elevation: (json['elevation'] as num?)?.toDouble(), - margin: json['margin'] == null - ? null - : StacEdgeInsets.fromJson(json['margin']), - padding: json['padding'] == null - ? null - : StacEdgeInsets.fromJson(json['padding']), - width: (json['width'] as num?)?.toDouble(), - shape: json['shape'] == null - ? null - : StacShapeBorder.fromJson(json['shape'] as Map), - hitTestBehavior: $enumDecodeNullable( - _$HitTestBehaviorEnumMap, json['hitTestBehavior']), - behavior: - $enumDecodeNullable(_$SnackBarBehaviorEnumMap, json['behavior']), - action: json['action'] == null - ? null - : StacSnackBarAction.fromJson(json['action'] as Map), - actionOverflowThreshold: - (json['actionOverflowThreshold'] as num?)?.toDouble(), - showCloseIcon: json['showCloseIcon'] as bool?, - closeIconColor: json['closeIconColor'] as String?, - duration: json['duration'] == null - ? const StacDuration(milliseconds: 4000) - : StacDuration.fromJson(json['duration'] as Map), - onVisible: json['onVisible'] as Map?, - dismissDirection: $enumDecodeNullable( - _$DismissDirectionEnumMap, json['dismissDirection']), - clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? - Clip.hardEdge, - ); - -Map _$StacSnackBarToJson(_StacSnackBar instance) => - { - 'content': instance.content, - 'backgroundColor': instance.backgroundColor, - 'elevation': instance.elevation, - 'margin': instance.margin, - 'padding': instance.padding, - 'width': instance.width, - 'shape': instance.shape, - 'hitTestBehavior': _$HitTestBehaviorEnumMap[instance.hitTestBehavior], - 'behavior': _$SnackBarBehaviorEnumMap[instance.behavior], - 'action': instance.action, - 'actionOverflowThreshold': instance.actionOverflowThreshold, - 'showCloseIcon': instance.showCloseIcon, - 'closeIconColor': instance.closeIconColor, - 'duration': instance.duration, - 'onVisible': instance.onVisible, - 'dismissDirection': _$DismissDirectionEnumMap[instance.dismissDirection], - 'clipBehavior': _$ClipEnumMap[instance.clipBehavior]!, - }; - -const _$HitTestBehaviorEnumMap = { - HitTestBehavior.deferToChild: 'deferToChild', - HitTestBehavior.opaque: 'opaque', - HitTestBehavior.translucent: 'translucent', -}; - -const _$SnackBarBehaviorEnumMap = { - SnackBarBehavior.fixed: 'fixed', - SnackBarBehavior.floating: 'floating', -}; - -const _$DismissDirectionEnumMap = { - DismissDirection.vertical: 'vertical', - DismissDirection.horizontal: 'horizontal', - DismissDirection.endToStart: 'endToStart', - DismissDirection.startToEnd: 'startToEnd', - DismissDirection.up: 'up', - DismissDirection.down: 'down', - DismissDirection.none: 'none', -}; - -const _$ClipEnumMap = { - Clip.none: 'none', - Clip.hardEdge: 'hardEdge', - Clip.antiAlias: 'antiAlias', - Clip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', -}; diff --git a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.dart b/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.dart deleted file mode 100644 index a5d8bc65..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac/src/framework/framework.dart'; -import 'package:stac/src/utils/color_utils.dart'; - -part 'stac_snack_bar_action.freezed.dart'; -part 'stac_snack_bar_action.g.dart'; - -@freezed -abstract class StacSnackBarAction with _$StacSnackBarAction { - const factory StacSnackBarAction({ - String? textColor, - String? disabledTextColor, - String? backgroundColor, - String? disabledBackgroundColor, - required String label, - required Map onPressed, - }) = _StacSnackBarAction; - - factory StacSnackBarAction.fromJson(Map json) => - _$StacSnackBarActionFromJson(json); -} - -extension StacSnackBarActionParser on StacSnackBarAction { - SnackBarAction parse(BuildContext context) { - return SnackBarAction( - textColor: textColor?.toColor(context), - disabledTextColor: disabledTextColor?.toColor(context), - backgroundColor: backgroundColor?.toColor(context), - disabledBackgroundColor: disabledBackgroundColor?.toColor(context), - label: label, - onPressed: () => Stac.onCallFromJson(onPressed, context), - ); - } -} diff --git a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.freezed.dart b/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.freezed.dart deleted file mode 100644 index 9ee872ae..00000000 --- a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.freezed.dart +++ /dev/null @@ -1,284 +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_snack_bar_action.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacSnackBarAction { - String? get textColor; - String? get disabledTextColor; - String? get backgroundColor; - String? get disabledBackgroundColor; - String get label; - Map get onPressed; - - /// Create a copy of StacSnackBarAction - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacSnackBarActionCopyWith get copyWith => - _$StacSnackBarActionCopyWithImpl( - this as StacSnackBarAction, _$identity); - - /// Serializes this StacSnackBarAction to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacSnackBarAction && - (identical(other.textColor, textColor) || - other.textColor == textColor) && - (identical(other.disabledTextColor, disabledTextColor) || - other.disabledTextColor == disabledTextColor) && - (identical(other.backgroundColor, backgroundColor) || - other.backgroundColor == backgroundColor) && - (identical( - other.disabledBackgroundColor, disabledBackgroundColor) || - other.disabledBackgroundColor == disabledBackgroundColor) && - (identical(other.label, label) || other.label == label) && - const DeepCollectionEquality().equals(other.onPressed, onPressed)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - textColor, - disabledTextColor, - backgroundColor, - disabledBackgroundColor, - label, - const DeepCollectionEquality().hash(onPressed)); - - @override - String toString() { - return 'StacSnackBarAction(textColor: $textColor, disabledTextColor: $disabledTextColor, backgroundColor: $backgroundColor, disabledBackgroundColor: $disabledBackgroundColor, label: $label, onPressed: $onPressed)'; - } -} - -/// @nodoc -abstract mixin class $StacSnackBarActionCopyWith<$Res> { - factory $StacSnackBarActionCopyWith( - StacSnackBarAction value, $Res Function(StacSnackBarAction) _then) = - _$StacSnackBarActionCopyWithImpl; - @useResult - $Res call( - {String? textColor, - String? disabledTextColor, - String? backgroundColor, - String? disabledBackgroundColor, - String label, - Map onPressed}); -} - -/// @nodoc -class _$StacSnackBarActionCopyWithImpl<$Res> - implements $StacSnackBarActionCopyWith<$Res> { - _$StacSnackBarActionCopyWithImpl(this._self, this._then); - - final StacSnackBarAction _self; - final $Res Function(StacSnackBarAction) _then; - - /// Create a copy of StacSnackBarAction - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? textColor = freezed, - Object? disabledTextColor = freezed, - Object? backgroundColor = freezed, - Object? disabledBackgroundColor = freezed, - Object? label = null, - Object? onPressed = null, - }) { - return _then(_self.copyWith( - textColor: freezed == textColor - ? _self.textColor - : textColor // ignore: cast_nullable_to_non_nullable - as String?, - disabledTextColor: freezed == disabledTextColor - ? _self.disabledTextColor - : disabledTextColor // ignore: cast_nullable_to_non_nullable - as String?, - backgroundColor: freezed == backgroundColor - ? _self.backgroundColor - : backgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - disabledBackgroundColor: freezed == disabledBackgroundColor - ? _self.disabledBackgroundColor - : disabledBackgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - label: null == label - ? _self.label - : label // ignore: cast_nullable_to_non_nullable - as String, - onPressed: null == onPressed - ? _self.onPressed - : onPressed // ignore: cast_nullable_to_non_nullable - as Map, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacSnackBarAction implements StacSnackBarAction { - const _StacSnackBarAction( - {this.textColor, - this.disabledTextColor, - this.backgroundColor, - this.disabledBackgroundColor, - required this.label, - required final Map onPressed}) - : _onPressed = onPressed; - factory _StacSnackBarAction.fromJson(Map json) => - _$StacSnackBarActionFromJson(json); - - @override - final String? textColor; - @override - final String? disabledTextColor; - @override - final String? backgroundColor; - @override - final String? disabledBackgroundColor; - @override - final String label; - final Map _onPressed; - @override - Map get onPressed { - if (_onPressed is EqualUnmodifiableMapView) return _onPressed; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_onPressed); - } - - /// Create a copy of StacSnackBarAction - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacSnackBarActionCopyWith<_StacSnackBarAction> get copyWith => - __$StacSnackBarActionCopyWithImpl<_StacSnackBarAction>(this, _$identity); - - @override - Map toJson() { - return _$StacSnackBarActionToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacSnackBarAction && - (identical(other.textColor, textColor) || - other.textColor == textColor) && - (identical(other.disabledTextColor, disabledTextColor) || - other.disabledTextColor == disabledTextColor) && - (identical(other.backgroundColor, backgroundColor) || - other.backgroundColor == backgroundColor) && - (identical( - other.disabledBackgroundColor, disabledBackgroundColor) || - other.disabledBackgroundColor == disabledBackgroundColor) && - (identical(other.label, label) || other.label == label) && - const DeepCollectionEquality() - .equals(other._onPressed, _onPressed)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - textColor, - disabledTextColor, - backgroundColor, - disabledBackgroundColor, - label, - const DeepCollectionEquality().hash(_onPressed)); - - @override - String toString() { - return 'StacSnackBarAction(textColor: $textColor, disabledTextColor: $disabledTextColor, backgroundColor: $backgroundColor, disabledBackgroundColor: $disabledBackgroundColor, label: $label, onPressed: $onPressed)'; - } -} - -/// @nodoc -abstract mixin class _$StacSnackBarActionCopyWith<$Res> - implements $StacSnackBarActionCopyWith<$Res> { - factory _$StacSnackBarActionCopyWith( - _StacSnackBarAction value, $Res Function(_StacSnackBarAction) _then) = - __$StacSnackBarActionCopyWithImpl; - @override - @useResult - $Res call( - {String? textColor, - String? disabledTextColor, - String? backgroundColor, - String? disabledBackgroundColor, - String label, - Map onPressed}); -} - -/// @nodoc -class __$StacSnackBarActionCopyWithImpl<$Res> - implements _$StacSnackBarActionCopyWith<$Res> { - __$StacSnackBarActionCopyWithImpl(this._self, this._then); - - final _StacSnackBarAction _self; - final $Res Function(_StacSnackBarAction) _then; - - /// Create a copy of StacSnackBarAction - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? textColor = freezed, - Object? disabledTextColor = freezed, - Object? backgroundColor = freezed, - Object? disabledBackgroundColor = freezed, - Object? label = null, - Object? onPressed = null, - }) { - return _then(_StacSnackBarAction( - textColor: freezed == textColor - ? _self.textColor - : textColor // ignore: cast_nullable_to_non_nullable - as String?, - disabledTextColor: freezed == disabledTextColor - ? _self.disabledTextColor - : disabledTextColor // ignore: cast_nullable_to_non_nullable - as String?, - backgroundColor: freezed == backgroundColor - ? _self.backgroundColor - : backgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - disabledBackgroundColor: freezed == disabledBackgroundColor - ? _self.disabledBackgroundColor - : disabledBackgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - label: null == label - ? _self.label - : label // ignore: cast_nullable_to_non_nullable - as String, - onPressed: null == onPressed - ? _self._onPressed - : onPressed // ignore: cast_nullable_to_non_nullable - as Map, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_parser.dart b/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_parser.dart index 9b502625..3296bd0e 100644 --- a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_parser.dart +++ b/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_parser.dart @@ -2,16 +2,15 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:stac/src/framework/framework.dart'; -import 'package:stac/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.dart'; +import 'package:stac/src/parsers/core/stac_action_parser.dart'; +import 'package:stac_core/actions/snack_bar/stac_snack_bar.dart'; +import 'package:stac_core/actions/snack_bar/stac_snack_bar_action.dart'; import 'package:stac/src/parsers/painting/stac_edge_insets_parser.dart'; import 'package:stac/src/parsers/types/type_parser.dart'; -import 'package:stac/src/parsers/widgets/stac_duration/stac_duration.dart'; import 'package:stac/src/utils/action_type.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac_framework/stac_framework.dart'; -import 'stac_snack_bar.dart'; - class StacSnackBarParser extends StacActionParser { const StacSnackBarParser(); @@ -36,17 +35,30 @@ class StacSnackBarParser extends StacActionParser { padding: model.padding?.parse, width: model.width, shape: model.shape?.parse(context), - hitTestBehavior: model.hitTestBehavior, - behavior: model.behavior, - action: model.action?.parse(context), + hitTestBehavior: model.hitTestBehavior?.parse, + behavior: model.behavior?.parse, + action: _parseAction(context, model.action), actionOverflowThreshold: model.actionOverflowThreshold, showCloseIcon: model.showCloseIcon, closeIconColor: model.closeIconColor?.toColor(context), - duration: model.duration.parse, + duration: model.duration?.parse ?? const Duration(milliseconds: 4000), onVisible: () => Stac.onCallFromJson(model.onVisible, context), - dismissDirection: model.dismissDirection, - clipBehavior: model.clipBehavior, + dismissDirection: model.dismissDirection?.parse, + clipBehavior: model.clipBehavior.parse, ), ); } + + SnackBarAction? _parseAction( + BuildContext context, StacSnackBarAction? action) { + if (action == null) return null; + return SnackBarAction( + textColor: action.textColor?.toColor(context), + disabledTextColor: action.disabledTextColor?.toColor(context), + backgroundColor: action.backgroundColor?.toColor(context), + disabledBackgroundColor: action.disabledBackgroundColor?.toColor(context), + label: action.label, + onPressed: () => action.onPressed.parse(context), + ); + } } diff --git a/packages/stac/lib/src/parsers/types/type_parser.dart b/packages/stac/lib/src/parsers/types/type_parser.dart index 09f5f967..56c3a061 100644 --- a/packages/stac/lib/src/parsers/types/type_parser.dart +++ b/packages/stac/lib/src/parsers/types/type_parser.dart @@ -1405,6 +1405,81 @@ extension StacHitTestBehaviorParser on StacHitTestBehavior { } } +/// Extends [StacSnackBarBehavior] to map to Flutter's [SnackBarBehavior]. +extension StacSnackBarBehaviorParser on StacSnackBarBehavior? { + SnackBarBehavior? get parse { + switch (this) { + case StacSnackBarBehavior.fixed: + return SnackBarBehavior.fixed; + case StacSnackBarBehavior.floating: + return SnackBarBehavior.floating; + default: + return null; + } + } +} + +/// Extends [StacDismissDirection] to map to Flutter's [DismissDirection]. +extension StacDismissDirectionParser on StacDismissDirection? { + DismissDirection? get parse { + switch (this) { + case StacDismissDirection.horizontal: + return DismissDirection.horizontal; + case StacDismissDirection.vertical: + return DismissDirection.vertical; + case StacDismissDirection.down: + return DismissDirection.down; + case StacDismissDirection.up: + return DismissDirection.up; + case StacDismissDirection.endToStart: + return DismissDirection.endToStart; + case StacDismissDirection.startToEnd: + return DismissDirection.startToEnd; + default: + return null; + } + } +} + +/// Extends [StacClip] to map to Flutter's [Clip]. +extension StacClipNullableParser on StacClip? { + Clip get parse { + switch (this) { + case StacClip.none: + return Clip.none; + case StacClip.hardEdge: + return Clip.hardEdge; + case StacClip.antiAlias: + return Clip.antiAlias; + case StacClip.antiAliasWithSaveLayer: + return Clip.antiAliasWithSaveLayer; + default: + return Clip.hardEdge; + } + } +} + +/// Extends [StacDialogTraversalEdgeBehavior] to provide parsing functionality. +extension StacDialogTraversalEdgeBehaviorParser + on StacDialogTraversalEdgeBehavior? { + /// Parses this [StacDialogTraversalEdgeBehavior] into Flutter's + /// [TraversalEdgeBehavior]. + TraversalEdgeBehavior? get parse { + switch (this) { + case StacDialogTraversalEdgeBehavior.closedLoop: + return TraversalEdgeBehavior.closedLoop; + case StacDialogTraversalEdgeBehavior.leaveFlutterView: + return TraversalEdgeBehavior.leaveFlutterView; + case StacDialogTraversalEdgeBehavior.parentScope: + return TraversalEdgeBehavior.parentScope; + case StacDialogTraversalEdgeBehavior.stop: + return TraversalEdgeBehavior.stop; + default: + return null; + } + } +} + extension StacSwitchTypeParser on StacSwitchType { StacSwitchType get parse { switch (this) { diff --git a/packages/stac_core/lib/actions/actions.dart b/packages/stac_core/lib/actions/actions.dart index d2c99883..b70854a2 100644 --- a/packages/stac_core/lib/actions/actions.dart +++ b/packages/stac_core/lib/actions/actions.dart @@ -3,3 +3,9 @@ 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'; +export 'delay/stac_delay_action.dart'; +export 'dialog/stac_dialog_action.dart'; +export 'snack_bar/stac_snack_bar.dart'; +export 'snack_bar/stac_snack_bar_action.dart'; +export 'multi/stac_multi_action.dart'; +export 'modal_bottom_sheet/stac_modal_bottom_sheet_action.dart'; diff --git a/packages/stac_core/lib/actions/delay/stac_delay_action.dart b/packages/stac_core/lib/actions/delay/stac_delay_action.dart new file mode 100644 index 00000000..90a04fcf --- /dev/null +++ b/packages/stac_core/lib/actions/delay/stac_delay_action.dart @@ -0,0 +1,39 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_core/core/stac_action.dart'; + +part 'stac_delay_action.g.dart'; + +/// Simple delay action that waits for a number of milliseconds. +/// +/// Defaults are applied in the parser; the model accepts a nullable value. +/// +/// Dart example: +/// ```dart +/// const StacDelayAction(milliseconds: 500); +/// ``` +/// +/// JSON example: +/// ```json +/// { "actionType": "delay", "milliseconds": 500 } +/// ``` +@JsonSerializable() +class StacDelayAction extends StacAction { + const StacDelayAction({this.milliseconds}); + + /// Delay in milliseconds to wait. + /// + /// Type: `int?` (defaults applied in parser). + final int? milliseconds; + + /// Unique action type string used for routing. + @override + String get actionType => 'delay'; + + /// Creates a `StacDelayAction` from JSON. + factory StacDelayAction.fromJson(Map json) => + _$StacDelayActionFromJson(json); + + /// Converts this action to JSON. + @override + Map toJson() => _$StacDelayActionToJson(this); +} diff --git a/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action.g.dart b/packages/stac_core/lib/actions/delay/stac_delay_action.g.dart similarity index 66% rename from packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action.g.dart rename to packages/stac_core/lib/actions/delay/stac_delay_action.g.dart index 42556656..be35f878 100644 --- a/packages/stac/lib/src/parsers/actions/stac_delay_action/stac_delay_action.g.dart +++ b/packages/stac_core/lib/actions/delay/stac_delay_action.g.dart @@ -6,12 +6,13 @@ part of 'stac_delay_action.dart'; // JsonSerializableGenerator // ************************************************************************** -_StacDelayAction _$StacDelayActionFromJson(Map json) => - _StacDelayAction( +StacDelayAction _$StacDelayActionFromJson(Map json) => + StacDelayAction( milliseconds: (json['milliseconds'] as num?)?.toInt() ?? 1000, ); -Map _$StacDelayActionToJson(_StacDelayAction instance) => +Map _$StacDelayActionToJson(StacDelayAction instance) => { 'milliseconds': instance.milliseconds, + 'actionType': instance.actionType, }; diff --git a/packages/stac_core/lib/actions/dialog/stac_dialog_action.dart b/packages/stac_core/lib/actions/dialog/stac_dialog_action.dart new file mode 100644 index 00000000..8e9a49ec --- /dev/null +++ b/packages/stac_core/lib/actions/dialog/stac_dialog_action.dart @@ -0,0 +1,91 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_core/actions/network_request/stac_network_request.dart'; +import 'package:stac_core/core/stac_action.dart'; +import 'package:stac_core/types/stac_dialog_traversal_edge_behavior.dart'; + +part 'stac_dialog_action.g.dart'; + +/// Core model for the "showDialog" action. +/// +/// Presents a dialog built from STAC JSON. Defaults for dismissibility and +/// safe area are applied in the parser, not in this model. +/// +/// Dart example: +/// ```dart +/// const StacDialogAction( +/// assetPath: 'assets/dialog.json', +/// ); +/// ``` +/// +/// JSON example: +/// ```json +/// { +/// "actionType": "showDialog", +/// "widget": {"type": "text", "data": {"text": "Title"}} +/// } +/// ``` +@JsonSerializable() +class StacDialogAction extends StacAction { + const StacDialogAction({ + this.widget, + this.request, + this.assetPath, + this.barrierDismissible, + this.barrierColor, + this.barrierLabel, + this.useSafeArea, + this.traversalEdgeBehavior, + }); + + /// Dialog content widget JSON. + /// + /// Type: `Map?`. + final Map? widget; + + /// Network request to fetch dialog widget JSON. + /// + /// Type: `StacNetworkRequest?`. + final StacNetworkRequest? request; + + /// Asset path to dialog widget JSON. + /// + /// Type: `String?`. + final String? assetPath; + + /// Whether tapping the barrier dismisses the dialog. + /// + /// Type: `bool?` (defaults applied in parser). + final bool? barrierDismissible; + + /// Barrier color hex string. + /// + /// Type: `String?`. + final String? barrierColor; + + /// Semantics label for barrier. + /// + /// Type: `String?`. + final String? barrierLabel; + + /// Whether to use safe area for the dialog. + /// + /// Type: `bool?` (defaults applied in parser). + final bool? useSafeArea; + + /// Traversal behavior for focus traversal at edges. + /// + /// Type: `StacDialogTraversalEdgeBehavior?`. + final StacDialogTraversalEdgeBehavior? traversalEdgeBehavior; + + /// Unique action type string used for routing. + @override + String get actionType => 'showDialog'; + + /// Creates a `StacDialogAction` from JSON. + factory StacDialogAction.fromJson(Map json) => + _$StacDialogActionFromJson(json); + + /// Converts this action to JSON. + @override + Map toJson() => _$StacDialogActionToJson(this); +} diff --git a/packages/stac_core/lib/actions/dialog/stac_dialog_action.g.dart b/packages/stac_core/lib/actions/dialog/stac_dialog_action.g.dart new file mode 100644 index 00000000..463e4bb3 --- /dev/null +++ b/packages/stac_core/lib/actions/dialog/stac_dialog_action.g.dart @@ -0,0 +1,48 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_dialog_action.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacDialogAction _$StacDialogActionFromJson(Map json) => + StacDialogAction( + widget: json['widget'] as Map?, + request: json['request'] == null + ? null + : StacNetworkRequest.fromJson( + json['request'] as Map, + ), + assetPath: json['assetPath'] as String?, + barrierDismissible: json['barrierDismissible'] as bool? ?? true, + barrierColor: json['barrierColor'] as String?, + barrierLabel: json['barrierLabel'] as String?, + useSafeArea: json['useSafeArea'] as bool? ?? true, + traversalEdgeBehavior: $enumDecodeNullable( + _$StacDialogTraversalEdgeBehaviorEnumMap, + json['traversalEdgeBehavior'], + ), + ); + +Map _$StacDialogActionToJson( + StacDialogAction instance, +) => { + 'widget': instance.widget, + 'request': instance.request?.toJson(), + 'assetPath': instance.assetPath, + 'barrierDismissible': instance.barrierDismissible, + 'barrierColor': instance.barrierColor, + 'barrierLabel': instance.barrierLabel, + 'useSafeArea': instance.useSafeArea, + 'traversalEdgeBehavior': + _$StacDialogTraversalEdgeBehaviorEnumMap[instance.traversalEdgeBehavior], + 'actionType': instance.actionType, +}; + +const _$StacDialogTraversalEdgeBehaviorEnumMap = { + StacDialogTraversalEdgeBehavior.closedLoop: 'closedLoop', + StacDialogTraversalEdgeBehavior.leaveFlutterView: 'leaveFlutterView', + StacDialogTraversalEdgeBehavior.parentScope: 'parentScope', + StacDialogTraversalEdgeBehavior.stop: 'stop', +}; diff --git a/packages/stac_core/lib/actions/modal_bottom_sheet/stac_modal_bottom_sheet_action.dart b/packages/stac_core/lib/actions/modal_bottom_sheet/stac_modal_bottom_sheet_action.dart new file mode 100644 index 00000000..66dc29a3 --- /dev/null +++ b/packages/stac_core/lib/actions/modal_bottom_sheet/stac_modal_bottom_sheet_action.dart @@ -0,0 +1,136 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_core/actions/network_request/stac_network_request.dart'; +import 'package:stac_core/core/stac_widget.dart'; +import 'package:stac_core/types/stac_border/stac_border.dart'; +import 'package:stac_core/types/stac_box_constraints/stac_box_constraints.dart'; +import 'package:stac_core/core/stac_action.dart'; + +part 'stac_modal_bottom_sheet_action.g.dart'; + +/// Core model for the "showModalBottomSheet" action. +/// +/// Displays a Flutter `showModalBottomSheet` with content sourced from a STAC +/// widget. Defaults (scroll control, dismissibility, etc.) are applied in the +/// parser, not the model. +/// +/// Dart example: +/// ```dart +/// const StacModalBottomSheetAction( +/// widget: StacWidget.fromJson({"type": "text", "data": {"text": "Hello"}}), +/// ); +/// ``` +/// +/// JSON example: +/// ```json +/// { +/// "actionType": "showModalBottomSheet", +/// "widget": {"type": "text", "data": {"text": "Hello"}} +/// } +/// ``` +@JsonSerializable() +class StacModalBottomSheetAction extends StacAction { + const StacModalBottomSheetAction({ + this.widget, + this.request, + this.assetPath, + this.backgroundColor, + this.barrierLabel, + this.elevation, + this.shape, + this.constraints, + this.barrierColor, + this.isScrollControlled, + this.useRootNavigator, + this.isDismissible, + this.enableDrag, + this.showDragHandle, + this.useSafeArea, + }); + + /// Content widget to display inside the bottom sheet. + /// + /// Type: `StacWidget?`. + final StacWidget? widget; + + /// Network request to fetch widget content. + /// + /// Type: `StacNetworkRequest?`. + final StacNetworkRequest? request; + + /// Path to a local asset JSON for the widget. + /// + /// Type: `String?`. + final String? assetPath; + + /// Background color hex for the sheet. + /// + /// Type: `String?`. + final String? backgroundColor; + + /// Semantics label for the modal barrier. + /// + /// Type: `String?`. + final String? barrierLabel; + + /// Elevation of the bottom sheet. + /// + /// Type: `double?`. + final double? elevation; + + /// Shape border of the bottom sheet. + /// + /// Type: `StacBorder?`. + final StacBorder? shape; + + /// Box constraints applied to the sheet. + /// + /// Type: `StacBoxConstraints?`. + final StacBoxConstraints? constraints; + + /// Barrier color hex behind the sheet. + /// + /// Type: `String?`. + final String? barrierColor; + + /// Whether the sheet can take full height when scrolled. + /// + /// Type: `bool?` (defaults applied in parser). + final bool? isScrollControlled; + + /// Whether to use the root navigator. + /// + /// Type: `bool?` (defaults applied in parser). + final bool? useRootNavigator; + + /// Whether the sheet is dismissible by tapping the barrier. + /// + /// Type: `bool?` (defaults applied in parser). + final bool? isDismissible; + + /// Whether the sheet is draggable. + /// + /// Type: `bool?` (defaults applied in parser). + final bool? enableDrag; + + /// Whether to show the drag handle. + /// + /// Type: `bool?`. + final bool? showDragHandle; + + /// Whether to respect the safe area. + /// + /// Type: `bool?` (defaults applied in parser). + final bool? useSafeArea; + + /// Unique action type string used for routing. + @override + String get actionType => 'showModalBottomSheet'; + + /// Creates a `StacModalBottomSheetAction` from JSON. + factory StacModalBottomSheetAction.fromJson(Map json) => + _$StacModalBottomSheetActionFromJson(json); + + /// Converts this action to JSON. + @override + Map toJson() => _$StacModalBottomSheetActionToJson(this); +} diff --git a/packages/stac_core/lib/actions/modal_bottom_sheet/stac_modal_bottom_sheet_action.g.dart b/packages/stac_core/lib/actions/modal_bottom_sheet/stac_modal_bottom_sheet_action.g.dart new file mode 100644 index 00000000..f60f0e14 --- /dev/null +++ b/packages/stac_core/lib/actions/modal_bottom_sheet/stac_modal_bottom_sheet_action.g.dart @@ -0,0 +1,58 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_modal_bottom_sheet_action.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacModalBottomSheetAction _$StacModalBottomSheetActionFromJson( + Map json, +) => StacModalBottomSheetAction( + widget: json['widget'] == null + ? null + : StacWidget.fromJson(json['widget'] as Map), + request: json['request'] == null + ? null + : StacNetworkRequest.fromJson(json['request'] as Map), + assetPath: json['assetPath'] as String?, + backgroundColor: json['backgroundColor'] as String?, + barrierLabel: json['barrierLabel'] as String?, + elevation: (json['elevation'] as num?)?.toDouble(), + shape: json['shape'] == null + ? null + : StacBorder.fromJson(json['shape'] as Map), + constraints: json['constraints'] == null + ? null + : StacBoxConstraints.fromJson( + json['constraints'] as Map, + ), + barrierColor: json['barrierColor'] as String?, + isScrollControlled: json['isScrollControlled'] as bool? ?? false, + useRootNavigator: json['useRootNavigator'] as bool? ?? false, + isDismissible: json['isDismissible'] as bool? ?? true, + enableDrag: json['enableDrag'] as bool? ?? true, + showDragHandle: json['showDragHandle'] as bool?, + useSafeArea: json['useSafeArea'] as bool? ?? false, +); + +Map _$StacModalBottomSheetActionToJson( + StacModalBottomSheetAction instance, +) => { + 'widget': instance.widget?.toJson(), + 'request': instance.request?.toJson(), + 'assetPath': instance.assetPath, + 'backgroundColor': instance.backgroundColor, + 'barrierLabel': instance.barrierLabel, + 'elevation': instance.elevation, + 'shape': instance.shape?.toJson(), + 'constraints': instance.constraints?.toJson(), + 'barrierColor': instance.barrierColor, + 'isScrollControlled': instance.isScrollControlled, + 'useRootNavigator': instance.useRootNavigator, + 'isDismissible': instance.isDismissible, + 'enableDrag': instance.enableDrag, + 'showDragHandle': instance.showDragHandle, + 'useSafeArea': instance.useSafeArea, + 'actionType': instance.actionType, +}; diff --git a/packages/stac_core/lib/actions/multi/stac_multi_action.dart b/packages/stac_core/lib/actions/multi/stac_multi_action.dart new file mode 100644 index 00000000..044d4e2a --- /dev/null +++ b/packages/stac_core/lib/actions/multi/stac_multi_action.dart @@ -0,0 +1,57 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_core/core/stac_action.dart'; + +part 'stac_multi_action.g.dart'; + +/// Executes multiple actions sequentially or concurrently. +/// +/// If `sync` is true, actions are awaited one-by-one; otherwise they are +/// fired without awaiting. +/// +/// Dart example: +/// ```dart +/// StacMultiAction( +/// actions: [ +/// const StacSetValueAction(values: [{"key": "a", "value": 1}]), +/// const StacNetworkRequest(url: 'https://api.example.com') +/// ], +/// sync: true, +/// ); +/// ``` +/// +/// JSON example: +/// ```json +/// { +/// "actionType": "multiAction", +/// "actions": [ +/// {"actionType": "setValue", "values": [{"key": "a", "value": 1}]}, +/// {"actionType": "networkRequest", "url": "https://api.example.com"} +/// ], +/// "sync": true +/// } +/// ``` +@JsonSerializable() +class StacMultiAction extends StacAction { + const StacMultiAction({required this.actions, this.sync = false}); + + /// List of child actions to execute. + /// + /// Type: `List?`. + final List? actions; + + /// Whether to execute actions synchronously. + /// + /// Type: `bool`. + final bool sync; + + @override + String get actionType => 'multiAction'; + + /// Creates a `StacMultiAction` from JSON. + factory StacMultiAction.fromJson(Map json) => + _$StacMultiActionFromJson(json); + + /// Converts this action to JSON. + @override + Map toJson() => _$StacMultiActionToJson(this); +} diff --git a/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action.g.dart b/packages/stac_core/lib/actions/multi/stac_multi_action.g.dart similarity index 56% rename from packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action.g.dart rename to packages/stac_core/lib/actions/multi/stac_multi_action.g.dart index d6d7c97f..4148c390 100644 --- a/packages/stac/lib/src/parsers/actions/stac_multi_action/stac_multi_action.g.dart +++ b/packages/stac_core/lib/actions/multi/stac_multi_action.g.dart @@ -6,16 +6,17 @@ part of 'stac_multi_action.dart'; // JsonSerializableGenerator // ************************************************************************** -_StacMultiAction _$StacMultiActionFromJson(Map json) => - _StacMultiAction( +StacMultiAction _$StacMultiActionFromJson(Map json) => + StacMultiAction( actions: (json['actions'] as List?) - ?.map((e) => e as Map?) + ?.map((e) => StacAction.fromJson(e as Map)) .toList(), sync: json['sync'] as bool? ?? false, ); -Map _$StacMultiActionToJson(_StacMultiAction instance) => +Map _$StacMultiActionToJson(StacMultiAction instance) => { - 'actions': instance.actions, + 'actions': instance.actions?.map((e) => e.toJson()).toList(), 'sync': instance.sync, + 'actionType': instance.actionType, }; diff --git a/packages/stac_core/lib/actions/snack_bar/stac_snack_bar.dart b/packages/stac_core/lib/actions/snack_bar/stac_snack_bar.dart new file mode 100644 index 00000000..1c6ec07b --- /dev/null +++ b/packages/stac_core/lib/actions/snack_bar/stac_snack_bar.dart @@ -0,0 +1,155 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_core/actions/snack_bar/stac_snack_bar_action.dart'; +import 'package:stac_core/core/stac_action.dart'; +import 'package:stac_core/painting/stac_edge_insets/stac_edge_insets.dart'; +import 'package:stac_core/types/stac_hit_test_behavior.dart'; +import 'package:stac_core/types/stac_shape_border/stac_shape_border.dart'; +import 'package:stac_core/types/stac_snack_bar_behavior.dart'; +import 'package:stac_core/types/stac_dismiss_direction.dart'; +import 'package:stac_core/types/stac_clip.dart'; +import 'package:stac_core/types/stac_duration/stac_duration.dart'; + +part 'stac_snack_bar.g.dart'; + +/// Core model for the SnackBar action. +/// +/// Shows a Flutter `SnackBar` built from STAC JSON. Use with +/// `StacSnackBarParser` to render at runtime. +/// +/// Dart example: +/// ```dart +/// const StacSnackBar( +/// content: {"type": "text", "data": {"text": "Saved"}}, +/// behavior: StacSnackBarBehavior.floating, +/// ); +/// ``` +/// +/// JSON example: +/// ```json +/// { +/// "actionType": "showSnackBar", +/// "content": {"type": "text", "data": {"text": "Saved"}}, +/// "behavior": "floating" +/// } +/// ``` +@JsonSerializable() +class StacSnackBar extends StacAction { + const StacSnackBar({ + required this.content, + this.backgroundColor, + this.elevation, + this.margin, + this.padding, + this.width, + this.shape, + this.hitTestBehavior, + this.behavior, + this.action, + this.actionOverflowThreshold, + this.showCloseIcon, + this.closeIconColor, + this.duration, + this.onVisible, + this.dismissDirection, + this.clipBehavior, + }); + + /// Widget JSON rendered inside the SnackBar. + /// + /// Type: `Map`. + final Map content; + + /// Background color hex. + /// + /// Type: `String?`. + final String? backgroundColor; + + /// Elevation of the SnackBar. + /// + /// Type: `double?`. + final double? elevation; + + /// Outer margin. + /// + /// Type: `StacEdgeInsets?`. + final StacEdgeInsets? margin; + + /// Inner padding. + /// + /// Type: `StacEdgeInsets?`. + final StacEdgeInsets? padding; + + /// Fixed width. + /// + /// Type: `double?`. + final double? width; + + /// Shape border for the SnackBar. + /// + /// Type: `StacShapeBorder?`. + final StacShapeBorder? shape; + + /// Hit test behavior. + /// + /// Type: `StacHitTestBehavior?`. + final StacHitTestBehavior? hitTestBehavior; + + /// Behavior: fixed or floating. + /// + /// Type: `StacSnackBarBehavior?`. + final StacSnackBarBehavior? behavior; + + /// Optional action button. + /// + /// Type: `StacSnackBarAction?`. + final StacSnackBarAction? action; + + /// Threshold for overflowing actions. + /// + /// Type: `double?`. + final double? actionOverflowThreshold; + + /// Whether to show the close icon. + /// + /// Type: `bool?`. + final bool? showCloseIcon; + + /// Close icon color. + /// + /// Type: `String?`. + final String? closeIconColor; + + /// Display duration. + /// + /// Type: `StacDuration?`. + final StacDuration? duration; + + /// Callback action when SnackBar becomes visible. + /// + /// Type: `Map?`. + final Map? onVisible; + + /// Dismiss direction. + /// + /// Type: `StacDismissDirection?`. + final StacDismissDirection? dismissDirection; + + /// Clip behavior. + /// + /// Type: `StacClip?`. + final StacClip? clipBehavior; + + /// Unique action type string used for routing. + @override + String get actionType => 'showSnackBar'; + + /// Creates a `StacSnackBar` from JSON. + factory StacSnackBar.fromJson(Map json) => + _$StacSnackBarFromJson(json); + + /// Converts this action to JSON. + @override + Map toJson() => _$StacSnackBarToJson(this); +} + +// uses types from stac_core/types diff --git a/packages/stac_core/lib/actions/snack_bar/stac_snack_bar.g.dart b/packages/stac_core/lib/actions/snack_bar/stac_snack_bar.g.dart new file mode 100644 index 00000000..2f3db207 --- /dev/null +++ b/packages/stac_core/lib/actions/snack_bar/stac_snack_bar.g.dart @@ -0,0 +1,97 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_snack_bar.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacSnackBar _$StacSnackBarFromJson(Map json) => StacSnackBar( + content: json['content'] as Map, + backgroundColor: json['backgroundColor'] as String?, + elevation: (json['elevation'] as num?)?.toDouble(), + margin: json['margin'] == null + ? null + : StacEdgeInsets.fromJson(json['margin']), + padding: json['padding'] == null + ? null + : StacEdgeInsets.fromJson(json['padding']), + width: (json['width'] as num?)?.toDouble(), + shape: json['shape'] == null + ? null + : StacShapeBorder.fromJson(json['shape'] as Map), + hitTestBehavior: $enumDecodeNullable( + _$StacHitTestBehaviorEnumMap, + json['hitTestBehavior'], + ), + behavior: $enumDecodeNullable( + _$StacSnackBarBehaviorEnumMap, + json['behavior'], + ), + action: json['action'] == null + ? null + : StacSnackBarAction.fromJson(json['action'] as Map), + actionOverflowThreshold: (json['actionOverflowThreshold'] as num?) + ?.toDouble(), + showCloseIcon: json['showCloseIcon'] as bool?, + closeIconColor: json['closeIconColor'] as String?, + duration: json['duration'] == null + ? null + : StacDuration.fromJson(json['duration'] as Map), + onVisible: json['onVisible'] as Map?, + dismissDirection: $enumDecodeNullable( + _$StacDismissDirectionEnumMap, + json['dismissDirection'], + ), + clipBehavior: $enumDecodeNullable(_$StacClipEnumMap, json['clipBehavior']), +); + +Map _$StacSnackBarToJson( + StacSnackBar instance, +) => { + 'content': instance.content, + 'backgroundColor': instance.backgroundColor, + 'elevation': instance.elevation, + 'margin': instance.margin?.toJson(), + 'padding': instance.padding?.toJson(), + 'width': instance.width, + 'shape': instance.shape?.toJson(), + 'hitTestBehavior': _$StacHitTestBehaviorEnumMap[instance.hitTestBehavior], + 'behavior': _$StacSnackBarBehaviorEnumMap[instance.behavior], + 'action': instance.action?.toJson(), + 'actionOverflowThreshold': instance.actionOverflowThreshold, + 'showCloseIcon': instance.showCloseIcon, + 'closeIconColor': instance.closeIconColor, + 'duration': instance.duration?.toJson(), + 'onVisible': instance.onVisible, + 'dismissDirection': _$StacDismissDirectionEnumMap[instance.dismissDirection], + 'clipBehavior': _$StacClipEnumMap[instance.clipBehavior], + 'actionType': instance.actionType, +}; + +const _$StacHitTestBehaviorEnumMap = { + StacHitTestBehavior.deferToChild: 'deferToChild', + StacHitTestBehavior.opaque: 'opaque', + StacHitTestBehavior.translucent: 'translucent', +}; + +const _$StacSnackBarBehaviorEnumMap = { + StacSnackBarBehavior.fixed: 'fixed', + StacSnackBarBehavior.floating: 'floating', +}; + +const _$StacDismissDirectionEnumMap = { + StacDismissDirection.horizontal: 'horizontal', + StacDismissDirection.vertical: 'vertical', + StacDismissDirection.down: 'down', + StacDismissDirection.up: 'up', + StacDismissDirection.endToStart: 'endToStart', + StacDismissDirection.startToEnd: 'startToEnd', +}; + +const _$StacClipEnumMap = { + StacClip.none: 'none', + StacClip.hardEdge: 'hardEdge', + StacClip.antiAlias: 'antiAlias', + StacClip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', +}; diff --git a/packages/stac_core/lib/actions/snack_bar/stac_snack_bar_action.dart b/packages/stac_core/lib/actions/snack_bar/stac_snack_bar_action.dart new file mode 100644 index 00000000..fe08b50f --- /dev/null +++ b/packages/stac_core/lib/actions/snack_bar/stac_snack_bar_action.dart @@ -0,0 +1,77 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_core/core/core.dart'; + +part 'stac_snack_bar_action.g.dart'; + +/// Action button configuration for a SnackBar. +/// +/// Mirrors Flutter's `SnackBarAction` while keeping model types in core. +/// +/// Dart example: +/// ```dart +/// const StacSnackBarAction( +/// label: 'Retry', +/// onPressed: StacNetworkRequest(url: 'https://api.example.com/retry'), +/// ); +/// ``` +/// +/// JSON example: +/// ```json +/// { +/// "label": "Retry", +/// "onPressed": { "actionType": "networkRequest", "url": "https://api.example.com/retry" }, +/// "textColor": "#FFFFFFFF" +/// } +/// ``` +@JsonSerializable() +class StacSnackBarAction { + const StacSnackBarAction({ + this.textColor, + this.disabledTextColor, + this.backgroundColor, + this.disabledBackgroundColor, + required this.label, + required this.onPressed, + }); + + /// Text color for the action label. + /// + /// Type: `String?` (hex color). + final String? textColor; + + /// Text color when the action is disabled. + /// + /// Type: `String?` (hex color). + final String? disabledTextColor; + + /// Background color for the action button. + /// + /// Type: `String?` (hex color). + final String? backgroundColor; + + /// Background color when the action is disabled. + /// + /// Type: `String?` (hex color). + final String? disabledBackgroundColor; + + /// Visible label for the action button. + /// + /// Type: `String`. + final String label; + + /// Action to invoke when the button is pressed. + /// + /// Type: `StacAction?` (serialized with `toJson`). + final StacAction? onPressed; + + /// Creates a `StacSnackBarAction` from JSON. + /// + /// Type: `factory StacSnackBarAction.fromJson(Map json)`. + factory StacSnackBarAction.fromJson(Map json) => + _$StacSnackBarActionFromJson(json); + + /// Converts this action to JSON. + /// + /// Type: `Map toJson()`. + Map toJson() => _$StacSnackBarActionToJson(this); +} diff --git a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.g.dart b/packages/stac_core/lib/actions/snack_bar/stac_snack_bar_action.g.dart similarity index 69% rename from packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.g.dart rename to packages/stac_core/lib/actions/snack_bar/stac_snack_bar_action.g.dart index 7db97adf..e675ebbf 100644 --- a/packages/stac/lib/src/parsers/actions/stac_snack_bar/stac_snack_bar_action.g.dart +++ b/packages/stac_core/lib/actions/snack_bar/stac_snack_bar_action.g.dart @@ -6,22 +6,24 @@ part of 'stac_snack_bar_action.dart'; // JsonSerializableGenerator // ************************************************************************** -_StacSnackBarAction _$StacSnackBarActionFromJson(Map json) => - _StacSnackBarAction( +StacSnackBarAction _$StacSnackBarActionFromJson(Map json) => + StacSnackBarAction( textColor: json['textColor'] as String?, disabledTextColor: json['disabledTextColor'] as String?, backgroundColor: json['backgroundColor'] as String?, disabledBackgroundColor: json['disabledBackgroundColor'] as String?, label: json['label'] as String, - onPressed: json['onPressed'] as Map, + onPressed: json['onPressed'] == null + ? null + : StacAction.fromJson(json['onPressed'] as Map), ); -Map _$StacSnackBarActionToJson(_StacSnackBarAction instance) => +Map _$StacSnackBarActionToJson(StacSnackBarAction instance) => { 'textColor': instance.textColor, 'disabledTextColor': instance.disabledTextColor, 'backgroundColor': instance.backgroundColor, 'disabledBackgroundColor': instance.disabledBackgroundColor, 'label': instance.label, - 'onPressed': instance.onPressed, + 'onPressed': instance.onPressed?.toJson(), }; diff --git a/packages/stac_core/lib/types/stac_dialog_traversal_edge_behavior.dart b/packages/stac_core/lib/types/stac_dialog_traversal_edge_behavior.dart new file mode 100644 index 00000000..0bd5522b --- /dev/null +++ b/packages/stac_core/lib/types/stac_dialog_traversal_edge_behavior.dart @@ -0,0 +1,22 @@ +/// Dialog traversal behavior within focus traversal. +/// +/// Mirrors Flutter's [TraversalEdgeBehavior] for dialog focus traversal without +/// importing Flutter into core. Used by `StacDialogAction`. +/// +/// JSON example: +/// ```json +/// { "traversalEdgeBehavior": "closedLoop" } +/// ``` +enum StacDialogTraversalEdgeBehavior { + /// Focus wraps from the last to the first (and vice versa). + closedLoop, + + /// Focus can leave Flutter view. + leaveFlutterView, + + /// Delegate to parent focus scope. + parentScope, + + /// Stop focus traversal at the edge. + stop, +} diff --git a/packages/stac_core/lib/types/stac_dismiss_direction.dart b/packages/stac_core/lib/types/stac_dismiss_direction.dart new file mode 100644 index 00000000..c668da69 --- /dev/null +++ b/packages/stac_core/lib/types/stac_dismiss_direction.dart @@ -0,0 +1,11 @@ +/// Direction(s) in which a dismissible widget can be dismissed. +/// +/// Mirrors Flutter's [DismissDirection] without importing Flutter into core. +enum StacDismissDirection { + horizontal, + vertical, + down, + up, + endToStart, + startToEnd, +} diff --git a/packages/stac_core/lib/types/stac_snack_bar_behavior.dart b/packages/stac_core/lib/types/stac_snack_bar_behavior.dart new file mode 100644 index 00000000..58d5fcde --- /dev/null +++ b/packages/stac_core/lib/types/stac_snack_bar_behavior.dart @@ -0,0 +1,6 @@ +/// Behavior of a SnackBar's position. +/// +/// Mirrors Flutter's [SnackBarBehavior] without importing Flutter into core. +/// - `fixed`: SnackBar is anchored to the bottom. +/// - `floating`: SnackBar floats above content with margins. +enum StacSnackBarBehavior { fixed, floating } diff --git a/packages/stac_core/lib/types/types.dart b/packages/stac_core/lib/types/types.dart index 0a83fd89..f80c3c46 100644 --- a/packages/stac_core/lib/types/types.dart +++ b/packages/stac_core/lib/types/types.dart @@ -49,3 +49,6 @@ export 'stac_overflow_bar_alignment.dart'; export 'stac_table/stac_table_border.dart'; export 'stac_table/stac_table_column_width.dart'; export 'stac_table/stac_table_cell_vertical_alignment.dart'; +export 'stac_dialog_traversal_edge_behavior.dart'; +export 'stac_snack_bar_behavior.dart'; +export 'stac_dismiss_direction.dart';