diff --git a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.dart b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.dart deleted file mode 100644 index 84465094..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'dart:ui'; - -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; - -export 'stac_circular_progress_indicator_parser.dart'; - -part 'stac_circular_progress_indicator.freezed.dart'; -part 'stac_circular_progress_indicator.g.dart'; - -@freezed -abstract class StacCircularProgressIndicator - with _$StacCircularProgressIndicator { - const factory StacCircularProgressIndicator({ - StacDouble? value, - String? backgroundColor, - String? color, - @Default(StacDouble(4.0)) StacDouble strokeWidth, - @Default(StacDouble.zero) StacDouble strokeAlign, - String? semanticsLabel, - String? semanticsValue, - StrokeCap? strokeCap, - }) = _StacCircularProgressIndicator; - - factory StacCircularProgressIndicator.fromJson(Map json) => - _$StacCircularProgressIndicatorFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.freezed.dart deleted file mode 100644 index 34107da0..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.freezed.dart +++ /dev/null @@ -1,309 +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_circular_progress_indicator.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacCircularProgressIndicator { - StacDouble? get value; - String? get backgroundColor; - String? get color; - StacDouble get strokeWidth; - StacDouble get strokeAlign; - String? get semanticsLabel; - String? get semanticsValue; - StrokeCap? get strokeCap; - - /// Create a copy of StacCircularProgressIndicator - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacCircularProgressIndicatorCopyWith - get copyWith => _$StacCircularProgressIndicatorCopyWithImpl< - StacCircularProgressIndicator>( - this as StacCircularProgressIndicator, _$identity); - - /// Serializes this StacCircularProgressIndicator to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacCircularProgressIndicator && - (identical(other.value, value) || other.value == value) && - (identical(other.backgroundColor, backgroundColor) || - other.backgroundColor == backgroundColor) && - (identical(other.color, color) || other.color == color) && - (identical(other.strokeWidth, strokeWidth) || - other.strokeWidth == strokeWidth) && - (identical(other.strokeAlign, strokeAlign) || - other.strokeAlign == strokeAlign) && - (identical(other.semanticsLabel, semanticsLabel) || - other.semanticsLabel == semanticsLabel) && - (identical(other.semanticsValue, semanticsValue) || - other.semanticsValue == semanticsValue) && - (identical(other.strokeCap, strokeCap) || - other.strokeCap == strokeCap)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, value, backgroundColor, color, - strokeWidth, strokeAlign, semanticsLabel, semanticsValue, strokeCap); - - @override - String toString() { - return 'StacCircularProgressIndicator(value: $value, backgroundColor: $backgroundColor, color: $color, strokeWidth: $strokeWidth, strokeAlign: $strokeAlign, semanticsLabel: $semanticsLabel, semanticsValue: $semanticsValue, strokeCap: $strokeCap)'; - } -} - -/// @nodoc -abstract mixin class $StacCircularProgressIndicatorCopyWith<$Res> { - factory $StacCircularProgressIndicatorCopyWith( - StacCircularProgressIndicator value, - $Res Function(StacCircularProgressIndicator) _then) = - _$StacCircularProgressIndicatorCopyWithImpl; - @useResult - $Res call( - {StacDouble? value, - String? backgroundColor, - String? color, - StacDouble strokeWidth, - StacDouble strokeAlign, - String? semanticsLabel, - String? semanticsValue, - StrokeCap? strokeCap}); -} - -/// @nodoc -class _$StacCircularProgressIndicatorCopyWithImpl<$Res> - implements $StacCircularProgressIndicatorCopyWith<$Res> { - _$StacCircularProgressIndicatorCopyWithImpl(this._self, this._then); - - final StacCircularProgressIndicator _self; - final $Res Function(StacCircularProgressIndicator) _then; - - /// Create a copy of StacCircularProgressIndicator - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? value = freezed, - Object? backgroundColor = freezed, - Object? color = freezed, - Object? strokeWidth = null, - Object? strokeAlign = null, - Object? semanticsLabel = freezed, - Object? semanticsValue = freezed, - Object? strokeCap = freezed, - }) { - return _then(_self.copyWith( - value: freezed == value - ? _self.value - : value // ignore: cast_nullable_to_non_nullable - as StacDouble?, - backgroundColor: freezed == backgroundColor - ? _self.backgroundColor - : backgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - color: freezed == color - ? _self.color - : color // ignore: cast_nullable_to_non_nullable - as String?, - strokeWidth: null == strokeWidth - ? _self.strokeWidth - : strokeWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - strokeAlign: null == strokeAlign - ? _self.strokeAlign - : strokeAlign // ignore: cast_nullable_to_non_nullable - as StacDouble, - semanticsLabel: freezed == semanticsLabel - ? _self.semanticsLabel - : semanticsLabel // ignore: cast_nullable_to_non_nullable - as String?, - semanticsValue: freezed == semanticsValue - ? _self.semanticsValue - : semanticsValue // ignore: cast_nullable_to_non_nullable - as String?, - strokeCap: freezed == strokeCap - ? _self.strokeCap - : strokeCap // ignore: cast_nullable_to_non_nullable - as StrokeCap?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacCircularProgressIndicator implements StacCircularProgressIndicator { - const _StacCircularProgressIndicator( - {this.value, - this.backgroundColor, - this.color, - this.strokeWidth = const StacDouble(4.0), - this.strokeAlign = StacDouble.zero, - this.semanticsLabel, - this.semanticsValue, - this.strokeCap}); - factory _StacCircularProgressIndicator.fromJson(Map json) => - _$StacCircularProgressIndicatorFromJson(json); - - @override - final StacDouble? value; - @override - final String? backgroundColor; - @override - final String? color; - @override - @JsonKey() - final StacDouble strokeWidth; - @override - @JsonKey() - final StacDouble strokeAlign; - @override - final String? semanticsLabel; - @override - final String? semanticsValue; - @override - final StrokeCap? strokeCap; - - /// Create a copy of StacCircularProgressIndicator - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacCircularProgressIndicatorCopyWith<_StacCircularProgressIndicator> - get copyWith => __$StacCircularProgressIndicatorCopyWithImpl< - _StacCircularProgressIndicator>(this, _$identity); - - @override - Map toJson() { - return _$StacCircularProgressIndicatorToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacCircularProgressIndicator && - (identical(other.value, value) || other.value == value) && - (identical(other.backgroundColor, backgroundColor) || - other.backgroundColor == backgroundColor) && - (identical(other.color, color) || other.color == color) && - (identical(other.strokeWidth, strokeWidth) || - other.strokeWidth == strokeWidth) && - (identical(other.strokeAlign, strokeAlign) || - other.strokeAlign == strokeAlign) && - (identical(other.semanticsLabel, semanticsLabel) || - other.semanticsLabel == semanticsLabel) && - (identical(other.semanticsValue, semanticsValue) || - other.semanticsValue == semanticsValue) && - (identical(other.strokeCap, strokeCap) || - other.strokeCap == strokeCap)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, value, backgroundColor, color, - strokeWidth, strokeAlign, semanticsLabel, semanticsValue, strokeCap); - - @override - String toString() { - return 'StacCircularProgressIndicator(value: $value, backgroundColor: $backgroundColor, color: $color, strokeWidth: $strokeWidth, strokeAlign: $strokeAlign, semanticsLabel: $semanticsLabel, semanticsValue: $semanticsValue, strokeCap: $strokeCap)'; - } -} - -/// @nodoc -abstract mixin class _$StacCircularProgressIndicatorCopyWith<$Res> - implements $StacCircularProgressIndicatorCopyWith<$Res> { - factory _$StacCircularProgressIndicatorCopyWith( - _StacCircularProgressIndicator value, - $Res Function(_StacCircularProgressIndicator) _then) = - __$StacCircularProgressIndicatorCopyWithImpl; - @override - @useResult - $Res call( - {StacDouble? value, - String? backgroundColor, - String? color, - StacDouble strokeWidth, - StacDouble strokeAlign, - String? semanticsLabel, - String? semanticsValue, - StrokeCap? strokeCap}); -} - -/// @nodoc -class __$StacCircularProgressIndicatorCopyWithImpl<$Res> - implements _$StacCircularProgressIndicatorCopyWith<$Res> { - __$StacCircularProgressIndicatorCopyWithImpl(this._self, this._then); - - final _StacCircularProgressIndicator _self; - final $Res Function(_StacCircularProgressIndicator) _then; - - /// Create a copy of StacCircularProgressIndicator - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? value = freezed, - Object? backgroundColor = freezed, - Object? color = freezed, - Object? strokeWidth = null, - Object? strokeAlign = null, - Object? semanticsLabel = freezed, - Object? semanticsValue = freezed, - Object? strokeCap = freezed, - }) { - return _then(_StacCircularProgressIndicator( - value: freezed == value - ? _self.value - : value // ignore: cast_nullable_to_non_nullable - as StacDouble?, - backgroundColor: freezed == backgroundColor - ? _self.backgroundColor - : backgroundColor // ignore: cast_nullable_to_non_nullable - as String?, - color: freezed == color - ? _self.color - : color // ignore: cast_nullable_to_non_nullable - as String?, - strokeWidth: null == strokeWidth - ? _self.strokeWidth - : strokeWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - strokeAlign: null == strokeAlign - ? _self.strokeAlign - : strokeAlign // ignore: cast_nullable_to_non_nullable - as StacDouble, - semanticsLabel: freezed == semanticsLabel - ? _self.semanticsLabel - : semanticsLabel // ignore: cast_nullable_to_non_nullable - as String?, - semanticsValue: freezed == semanticsValue - ? _self.semanticsValue - : semanticsValue // ignore: cast_nullable_to_non_nullable - as String?, - strokeCap: freezed == strokeCap - ? _self.strokeCap - : strokeCap // ignore: cast_nullable_to_non_nullable - as StrokeCap?, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.g.dart b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.g.dart deleted file mode 100644 index 483dea4e..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.g.dart +++ /dev/null @@ -1,43 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_circular_progress_indicator.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacCircularProgressIndicator _$StacCircularProgressIndicatorFromJson( - Map json) => - _StacCircularProgressIndicator( - value: json['value'] == null ? null : StacDouble.fromJson(json['value']), - backgroundColor: json['backgroundColor'] as String?, - color: json['color'] as String?, - strokeWidth: json['strokeWidth'] == null - ? const StacDouble(4.0) - : StacDouble.fromJson(json['strokeWidth']), - strokeAlign: json['strokeAlign'] == null - ? StacDouble.zero - : StacDouble.fromJson(json['strokeAlign']), - semanticsLabel: json['semanticsLabel'] as String?, - semanticsValue: json['semanticsValue'] as String?, - strokeCap: $enumDecodeNullable(_$StrokeCapEnumMap, json['strokeCap']), - ); - -Map _$StacCircularProgressIndicatorToJson( - _StacCircularProgressIndicator instance) => - { - 'value': instance.value, - 'backgroundColor': instance.backgroundColor, - 'color': instance.color, - 'strokeWidth': instance.strokeWidth, - 'strokeAlign': instance.strokeAlign, - 'semanticsLabel': instance.semanticsLabel, - 'semanticsValue': instance.semanticsValue, - 'strokeCap': _$StrokeCapEnumMap[instance.strokeCap], - }; - -const _$StrokeCapEnumMap = { - StrokeCap.butt: 'butt', - StrokeCap.round: 'round', - StrokeCap.square: 'square', -}; diff --git a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator_parser.dart index c8147751..02651bff 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator_parser.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; import 'package:stac/src/utils/widget_type.dart'; -import 'package:stac/stac.dart'; +import 'package:stac/src/utils/color_utils.dart'; +import 'package:stac_framework/stac_framework.dart'; +import 'package:stac_models/widgets/circular_progress_indicator/stac_circular_progress_indicator.dart'; class StacCircularProgressIndicatorParser extends StacParser { @@ -17,11 +18,11 @@ class StacCircularProgressIndicatorParser @override Widget parse(BuildContext context, StacCircularProgressIndicator model) { return CircularProgressIndicator( - value: model.value?.parse, - backgroundColor: model.backgroundColor.toColor(context), - color: model.color.toColor(context), - strokeWidth: model.strokeWidth.parse, - strokeAlign: model.strokeAlign.parse, + value: model.value, + backgroundColor: model.backgroundColor?.toColor(context), + color: model.color?.toColor(context), + strokeWidth: model.strokeWidth ?? 4.0, + strokeAlign: model.strokeAlign ?? 0.0, semanticsLabel: model.semanticsLabel, semanticsValue: model.semanticsValue, strokeCap: model.strokeCap, diff --git a/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval.dart b/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval.dart deleted file mode 100644 index 5c6892a6..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'dart:ui'; - -import 'package:freezed_annotation/freezed_annotation.dart'; - -export 'stac_clip_oval_parser.dart'; - -part 'stac_clip_oval.freezed.dart'; -part 'stac_clip_oval.g.dart'; - -@freezed -abstract class StacClipOval with _$StacClipOval { - const factory StacClipOval({ - @Default(Clip.antiAlias) Clip clipBehavior, - Map? child, - }) = _StacClipOval; - - factory StacClipOval.fromJson(Map json) => - _$StacClipOvalFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval.freezed.dart deleted file mode 100644 index 12e461a9..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval.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_clip_oval.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacClipOval { - Clip get clipBehavior; - Map? get child; - - /// Create a copy of StacClipOval - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacClipOvalCopyWith get copyWith => - _$StacClipOvalCopyWithImpl( - this as StacClipOval, _$identity); - - /// Serializes this StacClipOval to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacClipOval && - (identical(other.clipBehavior, clipBehavior) || - other.clipBehavior == clipBehavior) && - const DeepCollectionEquality().equals(other.child, child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, clipBehavior, const DeepCollectionEquality().hash(child)); - - @override - String toString() { - return 'StacClipOval(clipBehavior: $clipBehavior, child: $child)'; - } -} - -/// @nodoc -abstract mixin class $StacClipOvalCopyWith<$Res> { - factory $StacClipOvalCopyWith( - StacClipOval value, $Res Function(StacClipOval) _then) = - _$StacClipOvalCopyWithImpl; - @useResult - $Res call({Clip clipBehavior, Map? child}); -} - -/// @nodoc -class _$StacClipOvalCopyWithImpl<$Res> implements $StacClipOvalCopyWith<$Res> { - _$StacClipOvalCopyWithImpl(this._self, this._then); - - final StacClipOval _self; - final $Res Function(StacClipOval) _then; - - /// Create a copy of StacClipOval - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? clipBehavior = null, - Object? child = freezed, - }) { - return _then(_self.copyWith( - clipBehavior: null == clipBehavior - ? _self.clipBehavior - : clipBehavior // ignore: cast_nullable_to_non_nullable - as Clip, - child: freezed == child - ? _self.child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacClipOval implements StacClipOval { - const _StacClipOval( - {this.clipBehavior = Clip.antiAlias, final Map? child}) - : _child = child; - factory _StacClipOval.fromJson(Map json) => - _$StacClipOvalFromJson(json); - - @override - @JsonKey() - final Clip clipBehavior; - final Map? _child; - @override - Map? get child { - final value = _child; - if (value == null) return null; - if (_child is EqualUnmodifiableMapView) return _child; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - /// Create a copy of StacClipOval - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacClipOvalCopyWith<_StacClipOval> get copyWith => - __$StacClipOvalCopyWithImpl<_StacClipOval>(this, _$identity); - - @override - Map toJson() { - return _$StacClipOvalToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacClipOval && - (identical(other.clipBehavior, clipBehavior) || - other.clipBehavior == clipBehavior) && - const DeepCollectionEquality().equals(other._child, _child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, clipBehavior, const DeepCollectionEquality().hash(_child)); - - @override - String toString() { - return 'StacClipOval(clipBehavior: $clipBehavior, child: $child)'; - } -} - -/// @nodoc -abstract mixin class _$StacClipOvalCopyWith<$Res> - implements $StacClipOvalCopyWith<$Res> { - factory _$StacClipOvalCopyWith( - _StacClipOval value, $Res Function(_StacClipOval) _then) = - __$StacClipOvalCopyWithImpl; - @override - @useResult - $Res call({Clip clipBehavior, Map? child}); -} - -/// @nodoc -class __$StacClipOvalCopyWithImpl<$Res> - implements _$StacClipOvalCopyWith<$Res> { - __$StacClipOvalCopyWithImpl(this._self, this._then); - - final _StacClipOval _self; - final $Res Function(_StacClipOval) _then; - - /// Create a copy of StacClipOval - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? clipBehavior = null, - Object? child = freezed, - }) { - return _then(_StacClipOval( - clipBehavior: null == clipBehavior - ? _self.clipBehavior - : clipBehavior // ignore: cast_nullable_to_non_nullable - as Clip, - child: freezed == child - ? _self._child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval.g.dart b/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval.g.dart deleted file mode 100644 index 7809b2da..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval.g.dart +++ /dev/null @@ -1,27 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_clip_oval.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacClipOval _$StacClipOvalFromJson(Map json) => - _StacClipOval( - clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? - Clip.antiAlias, - child: json['child'] as Map?, - ); - -Map _$StacClipOvalToJson(_StacClipOval instance) => - { - 'clipBehavior': _$ClipEnumMap[instance.clipBehavior]!, - 'child': instance.child, - }; - -const _$ClipEnumMap = { - Clip.none: 'none', - Clip.hardEdge: 'hardEdge', - Clip.antiAlias: 'antiAlias', - Clip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', -}; diff --git a/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval_parser.dart index 89bb409b..5558807e 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_clip_oval/stac_clip_oval_parser.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:stac/src/framework/framework.dart'; -import 'package:stac/src/parsers/widgets/stac_clip_oval/stac_clip_oval.dart'; +import 'package:stac/src/parsers/core/stac_widget_parser.dart'; +import 'package:stac/src/parsers/types/type_parser.dart'; +import 'package:stac_models/widgets/clip_oval/stac_clip_oval.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -17,7 +18,8 @@ class StacClipOvalParser extends StacParser { @override Widget parse(BuildContext context, StacClipOval model) { return ClipOval( - clipBehavior: model.clipBehavior, - child: Stac.fromJson(model.child, context)); + clipBehavior: model.clipBehavior?.parse ?? Clip.antiAlias, + child: model.child?.parse(context), + ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.dart b/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.dart deleted file mode 100644 index 0568c5e2..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'dart:ui'; - -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac_models/types/stac_border_radius/stac_border_radius.dart'; - -export 'stac_clip_rrect_parser.dart'; - -part 'stac_clip_rrect.freezed.dart'; -part 'stac_clip_rrect.g.dart'; - -@freezed -abstract class StacClipRRect with _$StacClipRRect { - const factory StacClipRRect({ - @Default(StacBorderRadius()) StacBorderRadius borderRadius, - @Default(Clip.antiAlias) Clip clipBehavior, - Map? child, - }) = _StacClipRRect; - - factory StacClipRRect.fromJson(Map json) => - _$StacClipRRectFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.freezed.dart deleted file mode 100644 index 1caff9ca..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.freezed.dart +++ /dev/null @@ -1,215 +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_clip_rrect.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacClipRRect { - StacBorderRadius get borderRadius; - Clip get clipBehavior; - Map? get child; - - /// Create a copy of StacClipRRect - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacClipRRectCopyWith get copyWith => - _$StacClipRRectCopyWithImpl( - this as StacClipRRect, _$identity); - - /// Serializes this StacClipRRect to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacClipRRect && - (identical(other.borderRadius, borderRadius) || - other.borderRadius == borderRadius) && - (identical(other.clipBehavior, clipBehavior) || - other.clipBehavior == clipBehavior) && - const DeepCollectionEquality().equals(other.child, child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, borderRadius, clipBehavior, - const DeepCollectionEquality().hash(child)); - - @override - String toString() { - return 'StacClipRRect(borderRadius: $borderRadius, clipBehavior: $clipBehavior, child: $child)'; - } -} - -/// @nodoc -abstract mixin class $StacClipRRectCopyWith<$Res> { - factory $StacClipRRectCopyWith( - StacClipRRect value, $Res Function(StacClipRRect) _then) = - _$StacClipRRectCopyWithImpl; - @useResult - $Res call( - {StacBorderRadius borderRadius, - Clip clipBehavior, - Map? child}); -} - -/// @nodoc -class _$StacClipRRectCopyWithImpl<$Res> - implements $StacClipRRectCopyWith<$Res> { - _$StacClipRRectCopyWithImpl(this._self, this._then); - - final StacClipRRect _self; - final $Res Function(StacClipRRect) _then; - - /// Create a copy of StacClipRRect - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? borderRadius = null, - Object? clipBehavior = null, - Object? child = freezed, - }) { - return _then(_self.copyWith( - borderRadius: null == borderRadius - ? _self.borderRadius - : borderRadius // ignore: cast_nullable_to_non_nullable - as StacBorderRadius, - clipBehavior: null == clipBehavior - ? _self.clipBehavior - : clipBehavior // ignore: cast_nullable_to_non_nullable - as Clip, - child: freezed == child - ? _self.child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacClipRRect implements StacClipRRect { - const _StacClipRRect( - {this.borderRadius = const StacBorderRadius(), - this.clipBehavior = Clip.antiAlias, - final Map? child}) - : _child = child; - factory _StacClipRRect.fromJson(Map json) => - _$StacClipRRectFromJson(json); - - @override - @JsonKey() - final StacBorderRadius borderRadius; - @override - @JsonKey() - final Clip clipBehavior; - final Map? _child; - @override - Map? get child { - final value = _child; - if (value == null) return null; - if (_child is EqualUnmodifiableMapView) return _child; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - /// Create a copy of StacClipRRect - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacClipRRectCopyWith<_StacClipRRect> get copyWith => - __$StacClipRRectCopyWithImpl<_StacClipRRect>(this, _$identity); - - @override - Map toJson() { - return _$StacClipRRectToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacClipRRect && - (identical(other.borderRadius, borderRadius) || - other.borderRadius == borderRadius) && - (identical(other.clipBehavior, clipBehavior) || - other.clipBehavior == clipBehavior) && - const DeepCollectionEquality().equals(other._child, _child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, borderRadius, clipBehavior, - const DeepCollectionEquality().hash(_child)); - - @override - String toString() { - return 'StacClipRRect(borderRadius: $borderRadius, clipBehavior: $clipBehavior, child: $child)'; - } -} - -/// @nodoc -abstract mixin class _$StacClipRRectCopyWith<$Res> - implements $StacClipRRectCopyWith<$Res> { - factory _$StacClipRRectCopyWith( - _StacClipRRect value, $Res Function(_StacClipRRect) _then) = - __$StacClipRRectCopyWithImpl; - @override - @useResult - $Res call( - {StacBorderRadius borderRadius, - Clip clipBehavior, - Map? child}); -} - -/// @nodoc -class __$StacClipRRectCopyWithImpl<$Res> - implements _$StacClipRRectCopyWith<$Res> { - __$StacClipRRectCopyWithImpl(this._self, this._then); - - final _StacClipRRect _self; - final $Res Function(_StacClipRRect) _then; - - /// Create a copy of StacClipRRect - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? borderRadius = null, - Object? clipBehavior = null, - Object? child = freezed, - }) { - return _then(_StacClipRRect( - borderRadius: null == borderRadius - ? _self.borderRadius - : borderRadius // ignore: cast_nullable_to_non_nullable - as StacBorderRadius, - clipBehavior: null == clipBehavior - ? _self.clipBehavior - : clipBehavior // ignore: cast_nullable_to_non_nullable - as Clip, - child: freezed == child - ? _self._child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.g.dart b/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.g.dart deleted file mode 100644 index 2bddb624..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.g.dart +++ /dev/null @@ -1,31 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_clip_rrect.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacClipRRect _$StacClipRRectFromJson(Map json) => - _StacClipRRect( - borderRadius: json['borderRadius'] == null - ? const StacBorderRadius() - : StacBorderRadius.fromJson(json['borderRadius']), - clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? - Clip.antiAlias, - child: json['child'] as Map?, - ); - -Map _$StacClipRRectToJson(_StacClipRRect instance) => - { - 'borderRadius': instance.borderRadius, - 'clipBehavior': _$ClipEnumMap[instance.clipBehavior]!, - 'child': instance.child, - }; - -const _$ClipEnumMap = { - Clip.none: 'none', - Clip.hardEdge: 'hardEdge', - Clip.antiAlias: 'antiAlias', - Clip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', -}; diff --git a/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect_parser.dart index aa4fd02b..796980e4 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect_parser.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/core/stac_widget_parser.dart'; import 'package:stac/src/parsers/types/type_parser.dart'; -import 'package:stac/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.dart'; +import 'package:stac_models/widgets/clip_rrect/stac_clip_rrect.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -18,9 +18,9 @@ class StacClipRRectParser extends StacParser { @override Widget parse(BuildContext context, StacClipRRect model) { return ClipRRect( - borderRadius: model.borderRadius.parse, - clipBehavior: model.clipBehavior, - child: Stac.fromJson(model.child, context), + borderRadius: model.borderRadius?.parse ?? BorderRadius.zero, + clipBehavior: model.clipBehavior?.parse ?? Clip.antiAlias, + child: model.child?.parse(context), ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box.dart b/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box.dart deleted file mode 100644 index 9a9bfa30..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -export 'stac_colored_box_parser.dart'; - -part 'stac_colored_box.freezed.dart'; -part 'stac_colored_box.g.dart'; - -@freezed -abstract class StacColoredBox with _$StacColoredBox { - const factory StacColoredBox({ - required String color, - Map? child, - }) = _StacColoredBox; - - factory StacColoredBox.fromJson(Map json) => - _$StacColoredBoxFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box.freezed.dart deleted file mode 100644 index 0e13e845..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box.freezed.dart +++ /dev/null @@ -1,186 +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_colored_box.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacColoredBox { - String get color; - Map? get child; - - /// Create a copy of StacColoredBox - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacColoredBoxCopyWith get copyWith => - _$StacColoredBoxCopyWithImpl( - this as StacColoredBox, _$identity); - - /// Serializes this StacColoredBox to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacColoredBox && - (identical(other.color, color) || other.color == color) && - const DeepCollectionEquality().equals(other.child, child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, color, const DeepCollectionEquality().hash(child)); - - @override - String toString() { - return 'StacColoredBox(color: $color, child: $child)'; - } -} - -/// @nodoc -abstract mixin class $StacColoredBoxCopyWith<$Res> { - factory $StacColoredBoxCopyWith( - StacColoredBox value, $Res Function(StacColoredBox) _then) = - _$StacColoredBoxCopyWithImpl; - @useResult - $Res call({String color, Map? child}); -} - -/// @nodoc -class _$StacColoredBoxCopyWithImpl<$Res> - implements $StacColoredBoxCopyWith<$Res> { - _$StacColoredBoxCopyWithImpl(this._self, this._then); - - final StacColoredBox _self; - final $Res Function(StacColoredBox) _then; - - /// Create a copy of StacColoredBox - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? color = null, - Object? child = freezed, - }) { - return _then(_self.copyWith( - color: null == color - ? _self.color - : color // ignore: cast_nullable_to_non_nullable - as String, - child: freezed == child - ? _self.child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacColoredBox implements StacColoredBox { - const _StacColoredBox( - {required this.color, final Map? child}) - : _child = child; - factory _StacColoredBox.fromJson(Map json) => - _$StacColoredBoxFromJson(json); - - @override - final String color; - final Map? _child; - @override - Map? get child { - final value = _child; - if (value == null) return null; - if (_child is EqualUnmodifiableMapView) return _child; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - /// Create a copy of StacColoredBox - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacColoredBoxCopyWith<_StacColoredBox> get copyWith => - __$StacColoredBoxCopyWithImpl<_StacColoredBox>(this, _$identity); - - @override - Map toJson() { - return _$StacColoredBoxToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacColoredBox && - (identical(other.color, color) || other.color == color) && - const DeepCollectionEquality().equals(other._child, _child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, color, const DeepCollectionEquality().hash(_child)); - - @override - String toString() { - return 'StacColoredBox(color: $color, child: $child)'; - } -} - -/// @nodoc -abstract mixin class _$StacColoredBoxCopyWith<$Res> - implements $StacColoredBoxCopyWith<$Res> { - factory _$StacColoredBoxCopyWith( - _StacColoredBox value, $Res Function(_StacColoredBox) _then) = - __$StacColoredBoxCopyWithImpl; - @override - @useResult - $Res call({String color, Map? child}); -} - -/// @nodoc -class __$StacColoredBoxCopyWithImpl<$Res> - implements _$StacColoredBoxCopyWith<$Res> { - __$StacColoredBoxCopyWithImpl(this._self, this._then); - - final _StacColoredBox _self; - final $Res Function(_StacColoredBox) _then; - - /// Create a copy of StacColoredBox - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? color = null, - Object? child = freezed, - }) { - return _then(_StacColoredBox( - color: null == color - ? _self.color - : color // ignore: cast_nullable_to_non_nullable - as String, - child: freezed == child - ? _self._child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box_parser.dart index bc051f28..0829c264 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box_parser.dart @@ -1,10 +1,9 @@ import 'package:flutter/cupertino.dart'; -import 'package:stac/src/framework/framework.dart'; +import 'package:stac/src/parsers/core/stac_widget_parser.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; - -import 'stac_colored_box.dart'; +import 'package:stac_models/widgets/colored_box/stac_colored_box.dart'; class StacColoredBoxParser extends StacParser { const StacColoredBoxParser(); @@ -20,7 +19,7 @@ class StacColoredBoxParser extends StacParser { Widget parse(BuildContext context, StacColoredBox model) { return ColoredBox( color: model.color.toColor(context)!, - child: Stac.fromJson(model.child, context), + child: model.child.parse(context), ); } } diff --git a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.dart b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.dart deleted file mode 100644 index 49fa4889..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; - -export 'package:stac/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart'; - -part 'stac_placeholder.freezed.dart'; -part 'stac_placeholder.g.dart'; - -@freezed -abstract class StacPlaceholder with _$StacPlaceholder { - const factory StacPlaceholder({ - @Default(StacDouble(2.0)) StacDouble fallbackWidth, - @Default(StacDouble(400.0)) StacDouble fallbackHeight, - @Default(StacDouble(400.0)) StacDouble strokeWidth, - @Default('#455A64') String color, - Map? child, - }) = _StacPlaceholder; - - factory StacPlaceholder.fromJson(Map json) => - _$StacPlaceholderFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.freezed.dart deleted file mode 100644 index 9d7ee0aa..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.freezed.dart +++ /dev/null @@ -1,255 +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_placeholder.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacPlaceholder { - StacDouble get fallbackWidth; - StacDouble get fallbackHeight; - StacDouble get strokeWidth; - String get color; - Map? get child; - - /// Create a copy of StacPlaceholder - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacPlaceholderCopyWith get copyWith => - _$StacPlaceholderCopyWithImpl( - this as StacPlaceholder, _$identity); - - /// Serializes this StacPlaceholder to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacPlaceholder && - (identical(other.fallbackWidth, fallbackWidth) || - other.fallbackWidth == fallbackWidth) && - (identical(other.fallbackHeight, fallbackHeight) || - other.fallbackHeight == fallbackHeight) && - (identical(other.strokeWidth, strokeWidth) || - other.strokeWidth == strokeWidth) && - (identical(other.color, color) || other.color == color) && - const DeepCollectionEquality().equals(other.child, child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, fallbackWidth, fallbackHeight, - strokeWidth, color, const DeepCollectionEquality().hash(child)); - - @override - String toString() { - return 'StacPlaceholder(fallbackWidth: $fallbackWidth, fallbackHeight: $fallbackHeight, strokeWidth: $strokeWidth, color: $color, child: $child)'; - } -} - -/// @nodoc -abstract mixin class $StacPlaceholderCopyWith<$Res> { - factory $StacPlaceholderCopyWith( - StacPlaceholder value, $Res Function(StacPlaceholder) _then) = - _$StacPlaceholderCopyWithImpl; - @useResult - $Res call( - {StacDouble fallbackWidth, - StacDouble fallbackHeight, - StacDouble strokeWidth, - String color, - Map? child}); -} - -/// @nodoc -class _$StacPlaceholderCopyWithImpl<$Res> - implements $StacPlaceholderCopyWith<$Res> { - _$StacPlaceholderCopyWithImpl(this._self, this._then); - - final StacPlaceholder _self; - final $Res Function(StacPlaceholder) _then; - - /// Create a copy of StacPlaceholder - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? fallbackWidth = null, - Object? fallbackHeight = null, - Object? strokeWidth = null, - Object? color = null, - Object? child = freezed, - }) { - return _then(_self.copyWith( - fallbackWidth: null == fallbackWidth - ? _self.fallbackWidth - : fallbackWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - fallbackHeight: null == fallbackHeight - ? _self.fallbackHeight - : fallbackHeight // ignore: cast_nullable_to_non_nullable - as StacDouble, - strokeWidth: null == strokeWidth - ? _self.strokeWidth - : strokeWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - color: null == color - ? _self.color - : color // ignore: cast_nullable_to_non_nullable - as String, - child: freezed == child - ? _self.child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacPlaceholder implements StacPlaceholder { - const _StacPlaceholder( - {this.fallbackWidth = const StacDouble(2.0), - this.fallbackHeight = const StacDouble(400.0), - this.strokeWidth = const StacDouble(400.0), - this.color = '#455A64', - final Map? child}) - : _child = child; - factory _StacPlaceholder.fromJson(Map json) => - _$StacPlaceholderFromJson(json); - - @override - @JsonKey() - final StacDouble fallbackWidth; - @override - @JsonKey() - final StacDouble fallbackHeight; - @override - @JsonKey() - final StacDouble strokeWidth; - @override - @JsonKey() - final String color; - final Map? _child; - @override - Map? get child { - final value = _child; - if (value == null) return null; - if (_child is EqualUnmodifiableMapView) return _child; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - /// Create a copy of StacPlaceholder - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacPlaceholderCopyWith<_StacPlaceholder> get copyWith => - __$StacPlaceholderCopyWithImpl<_StacPlaceholder>(this, _$identity); - - @override - Map toJson() { - return _$StacPlaceholderToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacPlaceholder && - (identical(other.fallbackWidth, fallbackWidth) || - other.fallbackWidth == fallbackWidth) && - (identical(other.fallbackHeight, fallbackHeight) || - other.fallbackHeight == fallbackHeight) && - (identical(other.strokeWidth, strokeWidth) || - other.strokeWidth == strokeWidth) && - (identical(other.color, color) || other.color == color) && - const DeepCollectionEquality().equals(other._child, _child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, fallbackWidth, fallbackHeight, - strokeWidth, color, const DeepCollectionEquality().hash(_child)); - - @override - String toString() { - return 'StacPlaceholder(fallbackWidth: $fallbackWidth, fallbackHeight: $fallbackHeight, strokeWidth: $strokeWidth, color: $color, child: $child)'; - } -} - -/// @nodoc -abstract mixin class _$StacPlaceholderCopyWith<$Res> - implements $StacPlaceholderCopyWith<$Res> { - factory _$StacPlaceholderCopyWith( - _StacPlaceholder value, $Res Function(_StacPlaceholder) _then) = - __$StacPlaceholderCopyWithImpl; - @override - @useResult - $Res call( - {StacDouble fallbackWidth, - StacDouble fallbackHeight, - StacDouble strokeWidth, - String color, - Map? child}); -} - -/// @nodoc -class __$StacPlaceholderCopyWithImpl<$Res> - implements _$StacPlaceholderCopyWith<$Res> { - __$StacPlaceholderCopyWithImpl(this._self, this._then); - - final _StacPlaceholder _self; - final $Res Function(_StacPlaceholder) _then; - - /// Create a copy of StacPlaceholder - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? fallbackWidth = null, - Object? fallbackHeight = null, - Object? strokeWidth = null, - Object? color = null, - Object? child = freezed, - }) { - return _then(_StacPlaceholder( - fallbackWidth: null == fallbackWidth - ? _self.fallbackWidth - : fallbackWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - fallbackHeight: null == fallbackHeight - ? _self.fallbackHeight - : fallbackHeight // ignore: cast_nullable_to_non_nullable - as StacDouble, - strokeWidth: null == strokeWidth - ? _self.strokeWidth - : strokeWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - color: null == color - ? _self.color - : color // ignore: cast_nullable_to_non_nullable - as String, - child: freezed == child - ? _self._child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.g.dart b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.g.dart deleted file mode 100644 index f4f02114..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder.g.dart +++ /dev/null @@ -1,31 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_placeholder.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacPlaceholder _$StacPlaceholderFromJson(Map json) => - _StacPlaceholder( - fallbackWidth: json['fallbackWidth'] == null - ? const StacDouble(2.0) - : StacDouble.fromJson(json['fallbackWidth']), - fallbackHeight: json['fallbackHeight'] == null - ? const StacDouble(400.0) - : StacDouble.fromJson(json['fallbackHeight']), - strokeWidth: json['strokeWidth'] == null - ? const StacDouble(400.0) - : StacDouble.fromJson(json['strokeWidth']), - color: json['color'] as String? ?? '#455A64', - child: json['child'] as Map?, - ); - -Map _$StacPlaceholderToJson(_StacPlaceholder instance) => - { - 'fallbackWidth': instance.fallbackWidth, - 'fallbackHeight': instance.fallbackHeight, - 'strokeWidth': instance.strokeWidth, - 'color': instance.color, - 'child': instance.child, - }; diff --git a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart index c512fea9..393d579b 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:stac/src/framework/framework.dart'; -import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; -import 'package:stac/src/parsers/widgets/stac_placeholder/stac_placeholder.dart'; -import 'package:stac/src/utils/utils.dart'; +import 'package:stac/src/parsers/core/stac_widget_parser.dart'; +import 'package:stac_models/widgets/placeholder/stac_placeholder.dart'; +import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -19,11 +18,11 @@ class StacPlaceholderParser extends StacParser { @override Widget parse(BuildContext context, StacPlaceholder model) { return Placeholder( - fallbackWidth: model.fallbackWidth.parse, - fallbackHeight: model.fallbackHeight.parse, - strokeWidth: model.strokeWidth.parse, - color: model.color.toColor(context) ?? Color(0xFF455A64), - child: Stac.fromJson(model.child, context), + fallbackWidth: model.fallbackWidth ?? 2.0, + fallbackHeight: model.fallbackHeight ?? 400.0, + strokeWidth: model.strokeWidth ?? 400.0, + color: (model.color?.toColor(context)) ?? const Color(0xFF455A64), + child: model.child?.parse(context), ); } } diff --git a/packages/stac/lib/src/parsers/widgets/widgets.dart b/packages/stac/lib/src/parsers/widgets/widgets.dart index 08c77544..cfedc337 100644 --- a/packages/stac/lib/src/parsers/widgets/widgets.dart +++ b/packages/stac/lib/src/parsers/widgets/widgets.dart @@ -16,10 +16,10 @@ export 'package:stac/src/parsers/widgets/stac_center/stac_center_parser.dart'; export 'package:stac/src/parsers/widgets/stac_check_box/stac_check_box_parser.dart'; export 'package:stac/src/parsers/widgets/stac_chip/stac_chip_parser.dart'; export 'package:stac/src/parsers/widgets/stac_circle_avatar/stac_circle_avatar.dart'; -export 'package:stac/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator.dart'; -export 'package:stac/src/parsers/widgets/stac_clip_oval/stac_clip_oval.dart'; -export 'package:stac/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect.dart'; -export 'package:stac/src/parsers/widgets/stac_colored_box/stac_colored_box.dart'; +export 'package:stac/src/parsers/widgets/stac_circular_progress_indicator/stac_circular_progress_indicator_parser.dart'; +export 'package:stac/src/parsers/widgets/stac_clip_oval/stac_clip_oval_parser.dart'; +export 'package:stac/src/parsers/widgets/stac_clip_rrect/stac_clip_rrect_parser.dart'; +export 'package:stac/src/parsers/widgets/stac_colored_box/stac_colored_box_parser.dart'; export 'package:stac/src/parsers/widgets/stac_column/stac_column_parser.dart'; export 'package:stac/src/parsers/widgets/stac_conditional/stac_conditional.dart'; export 'package:stac/src/parsers/widgets/stac_container/stac_container_parser.dart'; @@ -62,7 +62,7 @@ export 'package:stac/src/parsers/widgets/stac_opacity/stac_opacity_parser.dart'; export 'package:stac/src/parsers/widgets/stac_outlined_button/stac_outlined_button_parser.dart'; export 'package:stac/src/parsers/widgets/stac_padding/stac_padding_parser.dart'; export 'package:stac/src/parsers/widgets/stac_page_view/stac_page_view.dart'; -export 'package:stac/src/parsers/widgets/stac_placeholder/stac_placeholder.dart'; +export 'package:stac/src/parsers/widgets/stac_placeholder/stac_placeholder_parser.dart'; export 'package:stac/src/parsers/widgets/stac_positioned/stac_positioned_parser.dart'; export 'package:stac/src/parsers/widgets/stac_radio/stac_radio_parser.dart'; export 'package:stac/src/parsers/widgets/stac_radio_group/stac_radio_group_parser.dart'; diff --git a/packages/stac_models/lib/widgets/circular_progress_indicator/stac_circular_progress_indicator.dart b/packages/stac_models/lib/widgets/circular_progress_indicator/stac_circular_progress_indicator.dart new file mode 100644 index 00000000..034b184a --- /dev/null +++ b/packages/stac_models/lib/widgets/circular_progress_indicator/stac_circular_progress_indicator.dart @@ -0,0 +1,92 @@ +import 'dart:ui'; + +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/converters/double_converter.dart'; +import 'package:stac_models/core/stac_widget.dart'; +import 'package:stac_models/painting/stac_color/stac_colors.dart'; + +part 'stac_circular_progress_indicator.g.dart'; + +/// A Stac model representing Flutter's [CircularProgressIndicator] widget. +/// +/// Displays a circular progress indicator. Can be determinate when [value] is +/// provided (0.0 to 1.0), or indeterminate when [value] is null. +/// +/// {@tool snippet} +/// Dart Example: +/// ```dart +/// StacCircularProgressIndicator( +/// value: 0.5, +/// color: StacColors.blue, +/// strokeWidth: 4.0, +/// ) +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// JSON Example: +/// ```json +/// { +/// "type": "circularProgressIndicator", +/// "value": 0.5, +/// "color": "#2196F3", +/// "strokeWidth": 4.0 +/// } +/// ``` +/// {@end-tool} +/// +/// See also: +/// * Flutter's CircularProgressIndicator documentation (`https://api.flutter.dev/flutter/material/CircularProgressIndicator-class.html`) +@JsonSerializable() +class StacCircularProgressIndicator extends StacWidget { + /// Creates a [StacCircularProgressIndicator]. + const StacCircularProgressIndicator({ + this.value, + this.backgroundColor, + this.color, + this.strokeWidth, + this.strokeAlign, + this.semanticsLabel, + this.semanticsValue, + this.strokeCap, + }); + + /// Progress value from 0.0 to 1.0 for determinate mode; null for indeterminate. + @DoubleConverter() + final double? value; + + /// Background color of the circular track. + final StacColor? backgroundColor; + + /// Foreground color of the progress indicator. + final StacColor? color; + + /// Width of the circular progress stroke. + @DoubleConverter() + final double? strokeWidth; + + /// Align of the stroke within the track. + @DoubleConverter() + final double? strokeAlign; + + /// Semantics label for accessibility. + final String? semanticsLabel; + + /// Semantics value for accessibility. + final String? semanticsValue; + + /// Stroke line cap style. + final StrokeCap? strokeCap; + + /// Widget type identifier. + @override + String get type => 'circularProgressIndicator'; + + /// Creates a [StacCircularProgressIndicator] from a JSON map. + factory StacCircularProgressIndicator.fromJson(Map json) => + _$StacCircularProgressIndicatorFromJson(json); + + /// Converts this [StacCircularProgressIndicator] instance to a JSON map. + @override + Map toJson() => _$StacCircularProgressIndicatorToJson(this); +} diff --git a/packages/stac_models/lib/widgets/circular_progress_indicator/stac_circular_progress_indicator.g.dart b/packages/stac_models/lib/widgets/circular_progress_indicator/stac_circular_progress_indicator.g.dart new file mode 100644 index 00000000..57681513 --- /dev/null +++ b/packages/stac_models/lib/widgets/circular_progress_indicator/stac_circular_progress_indicator.g.dart @@ -0,0 +1,40 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_circular_progress_indicator.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacCircularProgressIndicator _$StacCircularProgressIndicatorFromJson( + Map json, +) => StacCircularProgressIndicator( + value: const DoubleConverter().fromJson(json['value']), + backgroundColor: json['backgroundColor'] as String?, + color: json['color'] as String?, + strokeWidth: const DoubleConverter().fromJson(json['strokeWidth']), + strokeAlign: const DoubleConverter().fromJson(json['strokeAlign']), + semanticsLabel: json['semanticsLabel'] as String?, + semanticsValue: json['semanticsValue'] as String?, + strokeCap: $enumDecodeNullable(_$StrokeCapEnumMap, json['strokeCap']), +); + +Map _$StacCircularProgressIndicatorToJson( + StacCircularProgressIndicator instance, +) => { + 'value': const DoubleConverter().toJson(instance.value), + 'backgroundColor': instance.backgroundColor, + 'color': instance.color, + 'strokeWidth': const DoubleConverter().toJson(instance.strokeWidth), + 'strokeAlign': const DoubleConverter().toJson(instance.strokeAlign), + 'semanticsLabel': instance.semanticsLabel, + 'semanticsValue': instance.semanticsValue, + 'strokeCap': _$StrokeCapEnumMap[instance.strokeCap], + 'type': instance.type, +}; + +const _$StrokeCapEnumMap = { + StrokeCap.butt: 'butt', + StrokeCap.round: 'round', + StrokeCap.square: 'square', +}; diff --git a/packages/stac_models/lib/widgets/clip_oval/stac_clip_oval.dart b/packages/stac_models/lib/widgets/clip_oval/stac_clip_oval.dart new file mode 100644 index 00000000..cf1c7eaa --- /dev/null +++ b/packages/stac_models/lib/widgets/clip_oval/stac_clip_oval.dart @@ -0,0 +1,60 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_widget.dart'; +import 'package:stac_models/types/stac_clip.dart'; + +part 'stac_clip_oval.g.dart'; + +/// A Stac model representing Flutter's [ClipOval] widget. +/// +/// Clips its [child] using an oval (or circle if the bounds are a square). +/// +/// {@tool snippet} +/// Dart Example: +/// ```dart +/// StacClipOval( +/// clipBehavior: StacClip.antiAlias, +/// child: StacContainer(color: '#2196F3'), +/// ) +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// JSON Example: +/// ```json +/// { +/// "type": "clipOval", +/// "clipBehavior": "antiAlias", +/// "child": {"type": "container", "color": "#2196F3"} +/// } +/// ``` +/// {@end-tool} +/// +/// See also: +/// * Flutter's ClipOval documentation (`https://api.flutter.dev/flutter/widgets/ClipOval-class.html`) +@JsonSerializable(explicitToJson: true) +class StacClipOval extends StacWidget { + /// Creates a [StacClipOval]. + const StacClipOval({this.clipBehavior, this.child}); + + /// The clipping behavior to use. + /// + /// Type: [StacClip] + final StacClip? clipBehavior; + + /// The widget to be clipped by the oval. + /// + /// Type: [StacWidget] + final StacWidget? child; + + /// Widget type identifier. + @override + String get type => 'clipOval'; + + /// Creates a [StacClipOval] from a JSON map. + factory StacClipOval.fromJson(Map json) => + _$StacClipOvalFromJson(json); + + /// Converts this [StacClipOval] instance to a JSON map. + @override + Map toJson() => _$StacClipOvalToJson(this); +} diff --git a/packages/stac_models/lib/widgets/clip_oval/stac_clip_oval.g.dart b/packages/stac_models/lib/widgets/clip_oval/stac_clip_oval.g.dart new file mode 100644 index 00000000..f19485c7 --- /dev/null +++ b/packages/stac_models/lib/widgets/clip_oval/stac_clip_oval.g.dart @@ -0,0 +1,28 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_clip_oval.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacClipOval _$StacClipOvalFromJson(Map json) => StacClipOval( + clipBehavior: $enumDecodeNullable(_$StacClipEnumMap, json['clipBehavior']), + child: json['child'] == null + ? null + : StacWidget.fromJson(json['child'] as Map), +); + +Map _$StacClipOvalToJson(StacClipOval instance) => + { + 'clipBehavior': _$StacClipEnumMap[instance.clipBehavior], + 'child': instance.child?.toJson(), + 'type': instance.type, + }; + +const _$StacClipEnumMap = { + StacClip.none: 'none', + StacClip.hardEdge: 'hardEdge', + StacClip.antiAlias: 'antiAlias', + StacClip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', +}; diff --git a/packages/stac_models/lib/widgets/clip_rrect/stac_clip_rrect.dart b/packages/stac_models/lib/widgets/clip_rrect/stac_clip_rrect.dart new file mode 100644 index 00000000..24a923a2 --- /dev/null +++ b/packages/stac_models/lib/widgets/clip_rrect/stac_clip_rrect.dart @@ -0,0 +1,62 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_widget.dart'; +import 'package:stac_models/types/stac_border_radius/stac_border_radius.dart'; +import 'package:stac_models/types/stac_clip.dart'; + +part 'stac_clip_rrect.g.dart'; + +/// A Stac model representing Flutter's [ClipRRect] widget. +/// +/// Clips its [child] using a rounded-rectangle shape defined by [borderRadius]. +/// +/// {@tool snippet} +/// Dart Example: +/// ```dart +/// StacClipRRect( +/// borderRadius: StacBorderRadius.only(topLeft: 12, topRight: 12), +/// clipBehavior: StacClip.antiAlias, +/// child: StacContainer(color: '#FF0000'), +/// ) +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// JSON Example: +/// ```json +/// { +/// "type": "clipRRect", +/// "borderRadius": {"topLeft": 12, "topRight": 12}, +/// "clipBehavior": "antiAlias", +/// "child": {"type": "container", "color": "#FF0000"} +/// } +/// ``` +/// {@end-tool} +/// +/// See also: +/// * Flutter's ClipRRect documentation (`https://api.flutter.dev/flutter/widgets/ClipRRect-class.html`) +@JsonSerializable(explicitToJson: true) +class StacClipRRect extends StacWidget { + /// Creates a [StacClipRRect]. + const StacClipRRect({this.borderRadius, this.clipBehavior, this.child}); + + /// The border radius of the rounded-rectangle clip. + final StacBorderRadius? borderRadius; + + /// The clipping behavior to use. + final StacClip? clipBehavior; + + /// The widget to be clipped. + final StacWidget? child; + + /// Widget type identifier. + @override + String get type => 'clipRRect'; + + /// Creates a [StacClipRRect] from a JSON map. + factory StacClipRRect.fromJson(Map json) => + _$StacClipRRectFromJson(json); + + /// Converts this [StacClipRRect] instance to a JSON map. + @override + Map toJson() => _$StacClipRRectToJson(this); +} diff --git a/packages/stac_models/lib/widgets/clip_rrect/stac_clip_rrect.g.dart b/packages/stac_models/lib/widgets/clip_rrect/stac_clip_rrect.g.dart new file mode 100644 index 00000000..a30fbdfe --- /dev/null +++ b/packages/stac_models/lib/widgets/clip_rrect/stac_clip_rrect.g.dart @@ -0,0 +1,36 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_clip_rrect.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacClipRRect _$StacClipRRectFromJson(Map json) => + StacClipRRect( + borderRadius: json['borderRadius'] == null + ? null + : StacBorderRadius.fromJson(json['borderRadius']), + clipBehavior: $enumDecodeNullable( + _$StacClipEnumMap, + json['clipBehavior'], + ), + child: json['child'] == null + ? null + : StacWidget.fromJson(json['child'] as Map), + ); + +Map _$StacClipRRectToJson(StacClipRRect instance) => + { + 'borderRadius': instance.borderRadius?.toJson(), + 'clipBehavior': _$StacClipEnumMap[instance.clipBehavior], + 'child': instance.child?.toJson(), + 'type': instance.type, + }; + +const _$StacClipEnumMap = { + StacClip.none: 'none', + StacClip.hardEdge: 'hardEdge', + StacClip.antiAlias: 'antiAlias', + StacClip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', +}; diff --git a/packages/stac_models/lib/widgets/colored_box/stac_colored_box.dart b/packages/stac_models/lib/widgets/colored_box/stac_colored_box.dart new file mode 100644 index 00000000..cf50c85a --- /dev/null +++ b/packages/stac_models/lib/widgets/colored_box/stac_colored_box.dart @@ -0,0 +1,57 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_widget.dart'; +import 'package:stac_models/painting/stac_color/stac_colors.dart'; + +part 'stac_colored_box.g.dart'; + +/// A Stac model representing Flutter's [ColoredBox] widget. +/// +/// Paints its child with a solid background [color]. This is a lightweight +/// way to add a background color without additional layout or decoration. +/// +/// {@tool snippet} +/// Dart Example: +/// ```dart +/// StacColoredBox( +/// color: StacColors.blue, +/// child: StacText(data: 'Hello'), +/// ) +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// JSON Example: +/// ```json +/// { +/// "type": "coloredBox", +/// "color": "#FF2196F3", +/// "child": { "type": "text", "data": "Hello" } +/// } +/// ``` +/// {@end-tool} +/// +/// See also: +/// * Flutter's ColoredBox documentation (`https://api.flutter.dev/flutter/widgets/ColoredBox-class.html`) +@JsonSerializable() +class StacColoredBox extends StacWidget { + /// Creates a [StacColoredBox]. + const StacColoredBox({required this.color, this.child}); + + /// The background color to paint behind the [child]. + final StacColor color; + + /// The widget below this colored background. + final StacWidget? child; + + /// Widget type identifier. + @override + String get type => 'coloredBox'; + + /// Creates a [StacColoredBox] from a JSON map. + factory StacColoredBox.fromJson(Map json) => + _$StacColoredBoxFromJson(json); + + /// Converts this [StacColoredBox] instance to a JSON map. + @override + Map toJson() => _$StacColoredBoxToJson(this); +} diff --git a/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box.g.dart b/packages/stac_models/lib/widgets/colored_box/stac_colored_box.g.dart similarity index 50% rename from packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box.g.dart rename to packages/stac_models/lib/widgets/colored_box/stac_colored_box.g.dart index 6db120f0..3b719905 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_colored_box/stac_colored_box.g.dart +++ b/packages/stac_models/lib/widgets/colored_box/stac_colored_box.g.dart @@ -6,14 +6,17 @@ part of 'stac_colored_box.dart'; // JsonSerializableGenerator // ************************************************************************** -_StacColoredBox _$StacColoredBoxFromJson(Map json) => - _StacColoredBox( +StacColoredBox _$StacColoredBoxFromJson(Map json) => + StacColoredBox( color: json['color'] as String, - child: json['child'] as Map?, + child: json['child'] == null + ? null + : StacWidget.fromJson(json['child'] as Map), ); -Map _$StacColoredBoxToJson(_StacColoredBox instance) => +Map _$StacColoredBoxToJson(StacColoredBox instance) => { 'color': instance.color, - 'child': instance.child, + 'child': instance.child?.toJson(), + 'type': instance.type, }; diff --git a/packages/stac_models/lib/widgets/placeholder/stac_placeholder.dart b/packages/stac_models/lib/widgets/placeholder/stac_placeholder.dart new file mode 100644 index 00000000..62c6c0ed --- /dev/null +++ b/packages/stac_models/lib/widgets/placeholder/stac_placeholder.dart @@ -0,0 +1,73 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/converters/double_converter.dart'; +import 'package:stac_models/core/stac_widget.dart'; + +part 'stac_placeholder.g.dart'; + +/// A Stac model representing Flutter's [Placeholder] widget. +/// +/// Draws a simple box to visualize where a widget will be added in the future. +/// Useful during development to indicate unimplemented parts of the UI. +/// +/// Dart Example: +/// ```dart +/// StacPlaceholder( +/// fallbackWidth: 200, +/// fallbackHeight: 100, +/// strokeWidth: 2, +/// ) +/// ``` +/// +/// JSON Example: +/// ```json +/// { +/// "type": "placeholder", +/// "fallbackWidth": 200, +/// "fallbackHeight": 100, +/// "strokeWidth": 2 +/// } +/// ``` +/// +/// See also: +/// * Flutter's Placeholder documentation (`https://api.flutter.dev/flutter/widgets/Placeholder-class.html`) +@JsonSerializable(explicitToJson: true) +class StacPlaceholder extends StacWidget { + /// Creates a [StacPlaceholder]. + const StacPlaceholder({ + this.fallbackWidth, + this.fallbackHeight, + this.strokeWidth, + this.color, + this.child, + }); + + /// The width to use when the placeholder has unconstrained width. + @DoubleConverter() + final double? fallbackWidth; + + /// The height to use when the placeholder has unconstrained height. + @DoubleConverter() + final double? fallbackHeight; + + /// The stroke width used to draw the placeholder borders. + @DoubleConverter() + final double? strokeWidth; + + /// The color of the placeholder's stroke. + final String? color; + + /// Optional child to display inside the placeholder. + final StacWidget? child; + + /// Widget type identifier. + @override + String get type => 'placeholder'; + + /// Creates a [StacPlaceholder] from a JSON map. + factory StacPlaceholder.fromJson(Map json) => + _$StacPlaceholderFromJson(json); + + /// Converts this [StacPlaceholder] to a JSON map. + @override + Map toJson() => _$StacPlaceholderToJson(this); +} diff --git a/packages/stac_models/lib/widgets/placeholder/stac_placeholder.g.dart b/packages/stac_models/lib/widgets/placeholder/stac_placeholder.g.dart new file mode 100644 index 00000000..6a0e2cea --- /dev/null +++ b/packages/stac_models/lib/widgets/placeholder/stac_placeholder.g.dart @@ -0,0 +1,28 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_placeholder.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacPlaceholder _$StacPlaceholderFromJson(Map json) => + StacPlaceholder( + fallbackWidth: const DoubleConverter().fromJson(json['fallbackWidth']), + fallbackHeight: const DoubleConverter().fromJson(json['fallbackHeight']), + strokeWidth: const DoubleConverter().fromJson(json['strokeWidth']), + color: json['color'] as String?, + child: json['child'] == null + ? null + : StacWidget.fromJson(json['child'] as Map), + ); + +Map _$StacPlaceholderToJson(StacPlaceholder instance) => + { + 'fallbackWidth': const DoubleConverter().toJson(instance.fallbackWidth), + 'fallbackHeight': const DoubleConverter().toJson(instance.fallbackHeight), + 'strokeWidth': const DoubleConverter().toJson(instance.strokeWidth), + 'color': instance.color, + 'child': instance.child?.toJson(), + 'type': instance.type, + }; diff --git a/packages/stac_models/lib/widgets/widgets.dart b/packages/stac_models/lib/widgets/widgets.dart index 7c008221..e4f06ca5 100644 --- a/packages/stac_models/lib/widgets/widgets.dart +++ b/packages/stac_models/lib/widgets/widgets.dart @@ -7,6 +7,10 @@ export 'bottom_navigation_bar/stac_bottom_navigation_bar.dart'; export 'bottom_navigation_view/stac_bottom_navigation_view.dart'; export 'center/stac_center.dart'; export 'card/stac_card.dart'; +export 'colored_box/stac_colored_box.dart'; +export 'clip_rrect/stac_clip_rrect.dart'; +export 'clip_oval/stac_clip_oval.dart'; +export 'circular_progress_indicator/stac_circular_progress_indicator.dart'; export 'chip/stac_chip.dart'; export 'column/stac_column.dart'; export 'container/stac_container.dart'; @@ -31,6 +35,7 @@ export 'network_widget/stac_network_widget.dart'; export 'opacity/stac_opacity.dart'; export 'outlined_button/stac_outlined_button.dart'; export 'padding/stac_padding.dart'; +export 'placeholder/stac_placeholder.dart'; export 'positioned/stac_positioned.dart'; export 'refresh_indicator/stac_refresh_indicator.dart'; export 'custom_scroll_view/stac_custom_scroll_view.dart';