From 158ae47770ac3bcc31b33d69712faf3ab5562a50 Mon Sep 17 00:00:00 2001 From: Mithul Nayagam Date: Mon, 11 Aug 2025 18:08:18 +0530 Subject: [PATCH 1/8] added StacInkWell to DSL --- .../widgets/stac_inkwell/stac_inkwell.dart | 49 - .../stac_inkwell/stac_inkwell.freezed.dart | 1009 ----------------- .../widgets/stac_inkwell/stac_inkwell.g.dart | 125 -- .../stac_inkwell/stac_inkwell_parser.dart | 83 +- .../lib/widgets/ink_well/stac_ink_well.dart | 165 +++ .../lib/widgets/ink_well/stac_ink_well.g.dart | 149 +++ .../widgets/limited_box/stac_limited_box.dart | 2 +- packages/stac_models/lib/widgets/widgets.dart | 1 + 8 files changed, 347 insertions(+), 1236 deletions(-) delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.freezed.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.g.dart create mode 100644 packages/stac_models/lib/widgets/ink_well/stac_ink_well.dart create mode 100644 packages/stac_models/lib/widgets/ink_well/stac_ink_well.g.dart diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.dart deleted file mode 100644 index bf30db9a..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; -import 'package:stac/src/parsers/widgets/stac_mouse_cursor/stac_mouse_cursor.dart'; -import 'package:stac/stac.dart'; -import 'package:stac_models/types/stac_border/stac_border.dart'; -import 'package:stac_models/types/stac_border_radius/stac_border_radius.dart'; - -part 'stac_inkwell.freezed.dart'; -part 'stac_inkwell.g.dart'; - -@freezed -abstract class StacInkWell with _$StacInkWell { - const factory StacInkWell({ - Map? child, - Map? onTap, - Map? onDoubleTap, - Map? onLongPress, - Map? onTapDown, - Map? onTapUp, - Map? onTapCancel, - Map? onSecondaryTap, - Map? onSecondaryTapUp, - Map? onSecondaryTapDown, - Map? onSecondaryTapCancel, - Map? onHighlightChanged, - Map? onHover, - StacMouseCursor? mouseCursor, - String? focusColor, - String? hoverColor, - String? highlightColor, - String? overlayColor, - String? splashColor, - Map? splashFactory, - StacDouble? radius, - StacBorderRadius? borderRadius, - StacBorder? customBorder, - @Default(true) bool enableFeedback, - @Default(false) bool excludeFromSemantics, - Map? focusNode, - @Default(true) bool canRequestFocus, - Map? onFocusChange, - @Default(false) bool autofocus, - Map? statesController, - StacDuration? hoverDuration, - }) = _StacInkWell; - - factory StacInkWell.fromJson(Map json) => - _$StacInkWellFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.freezed.dart deleted file mode 100644 index b8161b37..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.freezed.dart +++ /dev/null @@ -1,1009 +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_inkwell.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacInkWell { - Map? get child; - Map? get onTap; - Map? get onDoubleTap; - Map? get onLongPress; - Map? get onTapDown; - Map? get onTapUp; - Map? get onTapCancel; - Map? get onSecondaryTap; - Map? get onSecondaryTapUp; - Map? get onSecondaryTapDown; - Map? get onSecondaryTapCancel; - Map? get onHighlightChanged; - Map? get onHover; - StacMouseCursor? get mouseCursor; - String? get focusColor; - String? get hoverColor; - String? get highlightColor; - String? get overlayColor; - String? get splashColor; - Map? get splashFactory; - StacDouble? get radius; - StacBorderRadius? get borderRadius; - StacBorder? get customBorder; - bool get enableFeedback; - bool get excludeFromSemantics; - Map? get focusNode; - bool get canRequestFocus; - Map? get onFocusChange; - bool get autofocus; - Map? get statesController; - StacDuration? get hoverDuration; - - /// Create a copy of StacInkWell - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacInkWellCopyWith get copyWith => - _$StacInkWellCopyWithImpl(this as StacInkWell, _$identity); - - /// Serializes this StacInkWell to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacInkWell && - const DeepCollectionEquality().equals(other.child, child) && - const DeepCollectionEquality().equals(other.onTap, onTap) && - const DeepCollectionEquality() - .equals(other.onDoubleTap, onDoubleTap) && - const DeepCollectionEquality() - .equals(other.onLongPress, onLongPress) && - const DeepCollectionEquality().equals(other.onTapDown, onTapDown) && - const DeepCollectionEquality().equals(other.onTapUp, onTapUp) && - const DeepCollectionEquality() - .equals(other.onTapCancel, onTapCancel) && - const DeepCollectionEquality() - .equals(other.onSecondaryTap, onSecondaryTap) && - const DeepCollectionEquality() - .equals(other.onSecondaryTapUp, onSecondaryTapUp) && - const DeepCollectionEquality() - .equals(other.onSecondaryTapDown, onSecondaryTapDown) && - const DeepCollectionEquality() - .equals(other.onSecondaryTapCancel, onSecondaryTapCancel) && - const DeepCollectionEquality() - .equals(other.onHighlightChanged, onHighlightChanged) && - const DeepCollectionEquality().equals(other.onHover, onHover) && - (identical(other.mouseCursor, mouseCursor) || - other.mouseCursor == mouseCursor) && - (identical(other.focusColor, focusColor) || - other.focusColor == focusColor) && - (identical(other.hoverColor, hoverColor) || - other.hoverColor == hoverColor) && - (identical(other.highlightColor, highlightColor) || - other.highlightColor == highlightColor) && - (identical(other.overlayColor, overlayColor) || - other.overlayColor == overlayColor) && - (identical(other.splashColor, splashColor) || - other.splashColor == splashColor) && - const DeepCollectionEquality() - .equals(other.splashFactory, splashFactory) && - (identical(other.radius, radius) || other.radius == radius) && - (identical(other.borderRadius, borderRadius) || - other.borderRadius == borderRadius) && - (identical(other.customBorder, customBorder) || - other.customBorder == customBorder) && - (identical(other.enableFeedback, enableFeedback) || - other.enableFeedback == enableFeedback) && - (identical(other.excludeFromSemantics, excludeFromSemantics) || - other.excludeFromSemantics == excludeFromSemantics) && - const DeepCollectionEquality().equals(other.focusNode, focusNode) && - (identical(other.canRequestFocus, canRequestFocus) || - other.canRequestFocus == canRequestFocus) && - const DeepCollectionEquality() - .equals(other.onFocusChange, onFocusChange) && - (identical(other.autofocus, autofocus) || - other.autofocus == autofocus) && - const DeepCollectionEquality() - .equals(other.statesController, statesController) && - (identical(other.hoverDuration, hoverDuration) || - other.hoverDuration == hoverDuration)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hashAll([ - runtimeType, - const DeepCollectionEquality().hash(child), - const DeepCollectionEquality().hash(onTap), - const DeepCollectionEquality().hash(onDoubleTap), - const DeepCollectionEquality().hash(onLongPress), - const DeepCollectionEquality().hash(onTapDown), - const DeepCollectionEquality().hash(onTapUp), - const DeepCollectionEquality().hash(onTapCancel), - const DeepCollectionEquality().hash(onSecondaryTap), - const DeepCollectionEquality().hash(onSecondaryTapUp), - const DeepCollectionEquality().hash(onSecondaryTapDown), - const DeepCollectionEquality().hash(onSecondaryTapCancel), - const DeepCollectionEquality().hash(onHighlightChanged), - const DeepCollectionEquality().hash(onHover), - mouseCursor, - focusColor, - hoverColor, - highlightColor, - overlayColor, - splashColor, - const DeepCollectionEquality().hash(splashFactory), - radius, - borderRadius, - customBorder, - enableFeedback, - excludeFromSemantics, - const DeepCollectionEquality().hash(focusNode), - canRequestFocus, - const DeepCollectionEquality().hash(onFocusChange), - autofocus, - const DeepCollectionEquality().hash(statesController), - hoverDuration - ]); - - @override - String toString() { - return 'StacInkWell(child: $child, onTap: $onTap, onDoubleTap: $onDoubleTap, onLongPress: $onLongPress, onTapDown: $onTapDown, onTapUp: $onTapUp, onTapCancel: $onTapCancel, onSecondaryTap: $onSecondaryTap, onSecondaryTapUp: $onSecondaryTapUp, onSecondaryTapDown: $onSecondaryTapDown, onSecondaryTapCancel: $onSecondaryTapCancel, onHighlightChanged: $onHighlightChanged, onHover: $onHover, mouseCursor: $mouseCursor, focusColor: $focusColor, hoverColor: $hoverColor, highlightColor: $highlightColor, overlayColor: $overlayColor, splashColor: $splashColor, splashFactory: $splashFactory, radius: $radius, borderRadius: $borderRadius, customBorder: $customBorder, enableFeedback: $enableFeedback, excludeFromSemantics: $excludeFromSemantics, focusNode: $focusNode, canRequestFocus: $canRequestFocus, onFocusChange: $onFocusChange, autofocus: $autofocus, statesController: $statesController, hoverDuration: $hoverDuration)'; - } -} - -/// @nodoc -abstract mixin class $StacInkWellCopyWith<$Res> { - factory $StacInkWellCopyWith( - StacInkWell value, $Res Function(StacInkWell) _then) = - _$StacInkWellCopyWithImpl; - @useResult - $Res call( - {Map? child, - Map? onTap, - Map? onDoubleTap, - Map? onLongPress, - Map? onTapDown, - Map? onTapUp, - Map? onTapCancel, - Map? onSecondaryTap, - Map? onSecondaryTapUp, - Map? onSecondaryTapDown, - Map? onSecondaryTapCancel, - Map? onHighlightChanged, - Map? onHover, - StacMouseCursor? mouseCursor, - String? focusColor, - String? hoverColor, - String? highlightColor, - String? overlayColor, - String? splashColor, - Map? splashFactory, - StacDouble? radius, - StacBorderRadius? borderRadius, - StacBorder? customBorder, - bool enableFeedback, - bool excludeFromSemantics, - Map? focusNode, - bool canRequestFocus, - Map? onFocusChange, - bool autofocus, - Map? statesController, - StacDuration? hoverDuration}); - - $StacDurationCopyWith<$Res>? get hoverDuration; -} - -/// @nodoc -class _$StacInkWellCopyWithImpl<$Res> implements $StacInkWellCopyWith<$Res> { - _$StacInkWellCopyWithImpl(this._self, this._then); - - final StacInkWell _self; - final $Res Function(StacInkWell) _then; - - /// Create a copy of StacInkWell - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? child = freezed, - Object? onTap = freezed, - Object? onDoubleTap = freezed, - Object? onLongPress = freezed, - Object? onTapDown = freezed, - Object? onTapUp = freezed, - Object? onTapCancel = freezed, - Object? onSecondaryTap = freezed, - Object? onSecondaryTapUp = freezed, - Object? onSecondaryTapDown = freezed, - Object? onSecondaryTapCancel = freezed, - Object? onHighlightChanged = freezed, - Object? onHover = freezed, - Object? mouseCursor = freezed, - Object? focusColor = freezed, - Object? hoverColor = freezed, - Object? highlightColor = freezed, - Object? overlayColor = freezed, - Object? splashColor = freezed, - Object? splashFactory = freezed, - Object? radius = freezed, - Object? borderRadius = freezed, - Object? customBorder = freezed, - Object? enableFeedback = null, - Object? excludeFromSemantics = null, - Object? focusNode = freezed, - Object? canRequestFocus = null, - Object? onFocusChange = freezed, - Object? autofocus = null, - Object? statesController = freezed, - Object? hoverDuration = freezed, - }) { - return _then(_self.copyWith( - child: freezed == child - ? _self.child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - onTap: freezed == onTap - ? _self.onTap - : onTap // ignore: cast_nullable_to_non_nullable - as Map?, - onDoubleTap: freezed == onDoubleTap - ? _self.onDoubleTap - : onDoubleTap // ignore: cast_nullable_to_non_nullable - as Map?, - onLongPress: freezed == onLongPress - ? _self.onLongPress - : onLongPress // ignore: cast_nullable_to_non_nullable - as Map?, - onTapDown: freezed == onTapDown - ? _self.onTapDown - : onTapDown // ignore: cast_nullable_to_non_nullable - as Map?, - onTapUp: freezed == onTapUp - ? _self.onTapUp - : onTapUp // ignore: cast_nullable_to_non_nullable - as Map?, - onTapCancel: freezed == onTapCancel - ? _self.onTapCancel - : onTapCancel // ignore: cast_nullable_to_non_nullable - as Map?, - onSecondaryTap: freezed == onSecondaryTap - ? _self.onSecondaryTap - : onSecondaryTap // ignore: cast_nullable_to_non_nullable - as Map?, - onSecondaryTapUp: freezed == onSecondaryTapUp - ? _self.onSecondaryTapUp - : onSecondaryTapUp // ignore: cast_nullable_to_non_nullable - as Map?, - onSecondaryTapDown: freezed == onSecondaryTapDown - ? _self.onSecondaryTapDown - : onSecondaryTapDown // ignore: cast_nullable_to_non_nullable - as Map?, - onSecondaryTapCancel: freezed == onSecondaryTapCancel - ? _self.onSecondaryTapCancel - : onSecondaryTapCancel // ignore: cast_nullable_to_non_nullable - as Map?, - onHighlightChanged: freezed == onHighlightChanged - ? _self.onHighlightChanged - : onHighlightChanged // ignore: cast_nullable_to_non_nullable - as Map?, - onHover: freezed == onHover - ? _self.onHover - : onHover // ignore: cast_nullable_to_non_nullable - as Map?, - mouseCursor: freezed == mouseCursor - ? _self.mouseCursor - : mouseCursor // ignore: cast_nullable_to_non_nullable - as StacMouseCursor?, - focusColor: freezed == focusColor - ? _self.focusColor - : focusColor // ignore: cast_nullable_to_non_nullable - as String?, - hoverColor: freezed == hoverColor - ? _self.hoverColor - : hoverColor // ignore: cast_nullable_to_non_nullable - as String?, - highlightColor: freezed == highlightColor - ? _self.highlightColor - : highlightColor // ignore: cast_nullable_to_non_nullable - as String?, - overlayColor: freezed == overlayColor - ? _self.overlayColor - : overlayColor // ignore: cast_nullable_to_non_nullable - as String?, - splashColor: freezed == splashColor - ? _self.splashColor - : splashColor // ignore: cast_nullable_to_non_nullable - as String?, - splashFactory: freezed == splashFactory - ? _self.splashFactory - : splashFactory // ignore: cast_nullable_to_non_nullable - as Map?, - radius: freezed == radius - ? _self.radius - : radius // ignore: cast_nullable_to_non_nullable - as StacDouble?, - borderRadius: freezed == borderRadius - ? _self.borderRadius - : borderRadius // ignore: cast_nullable_to_non_nullable - as StacBorderRadius?, - customBorder: freezed == customBorder - ? _self.customBorder - : customBorder // ignore: cast_nullable_to_non_nullable - as StacBorder?, - enableFeedback: null == enableFeedback - ? _self.enableFeedback - : enableFeedback // ignore: cast_nullable_to_non_nullable - as bool, - excludeFromSemantics: null == excludeFromSemantics - ? _self.excludeFromSemantics - : excludeFromSemantics // ignore: cast_nullable_to_non_nullable - as bool, - focusNode: freezed == focusNode - ? _self.focusNode - : focusNode // ignore: cast_nullable_to_non_nullable - as Map?, - canRequestFocus: null == canRequestFocus - ? _self.canRequestFocus - : canRequestFocus // ignore: cast_nullable_to_non_nullable - as bool, - onFocusChange: freezed == onFocusChange - ? _self.onFocusChange - : onFocusChange // ignore: cast_nullable_to_non_nullable - as Map?, - autofocus: null == autofocus - ? _self.autofocus - : autofocus // ignore: cast_nullable_to_non_nullable - as bool, - statesController: freezed == statesController - ? _self.statesController - : statesController // ignore: cast_nullable_to_non_nullable - as Map?, - hoverDuration: freezed == hoverDuration - ? _self.hoverDuration - : hoverDuration // ignore: cast_nullable_to_non_nullable - as StacDuration?, - )); - } - - /// Create a copy of StacInkWell - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacDurationCopyWith<$Res>? get hoverDuration { - if (_self.hoverDuration == null) { - return null; - } - - return $StacDurationCopyWith<$Res>(_self.hoverDuration!, (value) { - return _then(_self.copyWith(hoverDuration: value)); - }); - } -} - -/// @nodoc -@JsonSerializable() -class _StacInkWell implements StacInkWell { - const _StacInkWell( - {final Map? child, - final Map? onTap, - final Map? onDoubleTap, - final Map? onLongPress, - final Map? onTapDown, - final Map? onTapUp, - final Map? onTapCancel, - final Map? onSecondaryTap, - final Map? onSecondaryTapUp, - final Map? onSecondaryTapDown, - final Map? onSecondaryTapCancel, - final Map? onHighlightChanged, - final Map? onHover, - this.mouseCursor, - this.focusColor, - this.hoverColor, - this.highlightColor, - this.overlayColor, - this.splashColor, - final Map? splashFactory, - this.radius, - this.borderRadius, - this.customBorder, - this.enableFeedback = true, - this.excludeFromSemantics = false, - final Map? focusNode, - this.canRequestFocus = true, - final Map? onFocusChange, - this.autofocus = false, - final Map? statesController, - this.hoverDuration}) - : _child = child, - _onTap = onTap, - _onDoubleTap = onDoubleTap, - _onLongPress = onLongPress, - _onTapDown = onTapDown, - _onTapUp = onTapUp, - _onTapCancel = onTapCancel, - _onSecondaryTap = onSecondaryTap, - _onSecondaryTapUp = onSecondaryTapUp, - _onSecondaryTapDown = onSecondaryTapDown, - _onSecondaryTapCancel = onSecondaryTapCancel, - _onHighlightChanged = onHighlightChanged, - _onHover = onHover, - _splashFactory = splashFactory, - _focusNode = focusNode, - _onFocusChange = onFocusChange, - _statesController = statesController; - factory _StacInkWell.fromJson(Map json) => - _$StacInkWellFromJson(json); - - 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); - } - - final Map? _onTap; - @override - Map? get onTap { - final value = _onTap; - if (value == null) return null; - if (_onTap is EqualUnmodifiableMapView) return _onTap; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onDoubleTap; - @override - Map? get onDoubleTap { - final value = _onDoubleTap; - if (value == null) return null; - if (_onDoubleTap is EqualUnmodifiableMapView) return _onDoubleTap; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onLongPress; - @override - Map? get onLongPress { - final value = _onLongPress; - if (value == null) return null; - if (_onLongPress is EqualUnmodifiableMapView) return _onLongPress; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onTapDown; - @override - Map? get onTapDown { - final value = _onTapDown; - if (value == null) return null; - if (_onTapDown is EqualUnmodifiableMapView) return _onTapDown; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onTapUp; - @override - Map? get onTapUp { - final value = _onTapUp; - if (value == null) return null; - if (_onTapUp is EqualUnmodifiableMapView) return _onTapUp; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onTapCancel; - @override - Map? get onTapCancel { - final value = _onTapCancel; - if (value == null) return null; - if (_onTapCancel is EqualUnmodifiableMapView) return _onTapCancel; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onSecondaryTap; - @override - Map? get onSecondaryTap { - final value = _onSecondaryTap; - if (value == null) return null; - if (_onSecondaryTap is EqualUnmodifiableMapView) return _onSecondaryTap; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onSecondaryTapUp; - @override - Map? get onSecondaryTapUp { - final value = _onSecondaryTapUp; - if (value == null) return null; - if (_onSecondaryTapUp is EqualUnmodifiableMapView) return _onSecondaryTapUp; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onSecondaryTapDown; - @override - Map? get onSecondaryTapDown { - final value = _onSecondaryTapDown; - if (value == null) return null; - if (_onSecondaryTapDown is EqualUnmodifiableMapView) - return _onSecondaryTapDown; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onSecondaryTapCancel; - @override - Map? get onSecondaryTapCancel { - final value = _onSecondaryTapCancel; - if (value == null) return null; - if (_onSecondaryTapCancel is EqualUnmodifiableMapView) - return _onSecondaryTapCancel; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onHighlightChanged; - @override - Map? get onHighlightChanged { - final value = _onHighlightChanged; - if (value == null) return null; - if (_onHighlightChanged is EqualUnmodifiableMapView) - return _onHighlightChanged; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - final Map? _onHover; - @override - Map? get onHover { - final value = _onHover; - if (value == null) return null; - if (_onHover is EqualUnmodifiableMapView) return _onHover; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - final StacMouseCursor? mouseCursor; - @override - final String? focusColor; - @override - final String? hoverColor; - @override - final String? highlightColor; - @override - final String? overlayColor; - @override - final String? splashColor; - final Map? _splashFactory; - @override - Map? get splashFactory { - final value = _splashFactory; - if (value == null) return null; - if (_splashFactory is EqualUnmodifiableMapView) return _splashFactory; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - final StacDouble? radius; - @override - final StacBorderRadius? borderRadius; - @override - final StacBorder? customBorder; - @override - @JsonKey() - final bool enableFeedback; - @override - @JsonKey() - final bool excludeFromSemantics; - final Map? _focusNode; - @override - Map? get focusNode { - final value = _focusNode; - if (value == null) return null; - if (_focusNode is EqualUnmodifiableMapView) return _focusNode; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - @JsonKey() - final bool canRequestFocus; - final Map? _onFocusChange; - @override - Map? get onFocusChange { - final value = _onFocusChange; - if (value == null) return null; - if (_onFocusChange is EqualUnmodifiableMapView) return _onFocusChange; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - @JsonKey() - final bool autofocus; - final Map? _statesController; - @override - Map? get statesController { - final value = _statesController; - if (value == null) return null; - if (_statesController is EqualUnmodifiableMapView) return _statesController; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } - - @override - final StacDuration? hoverDuration; - - /// Create a copy of StacInkWell - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacInkWellCopyWith<_StacInkWell> get copyWith => - __$StacInkWellCopyWithImpl<_StacInkWell>(this, _$identity); - - @override - Map toJson() { - return _$StacInkWellToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacInkWell && - const DeepCollectionEquality().equals(other._child, _child) && - const DeepCollectionEquality().equals(other._onTap, _onTap) && - const DeepCollectionEquality() - .equals(other._onDoubleTap, _onDoubleTap) && - const DeepCollectionEquality() - .equals(other._onLongPress, _onLongPress) && - const DeepCollectionEquality() - .equals(other._onTapDown, _onTapDown) && - const DeepCollectionEquality().equals(other._onTapUp, _onTapUp) && - const DeepCollectionEquality() - .equals(other._onTapCancel, _onTapCancel) && - const DeepCollectionEquality() - .equals(other._onSecondaryTap, _onSecondaryTap) && - const DeepCollectionEquality() - .equals(other._onSecondaryTapUp, _onSecondaryTapUp) && - const DeepCollectionEquality() - .equals(other._onSecondaryTapDown, _onSecondaryTapDown) && - const DeepCollectionEquality() - .equals(other._onSecondaryTapCancel, _onSecondaryTapCancel) && - const DeepCollectionEquality() - .equals(other._onHighlightChanged, _onHighlightChanged) && - const DeepCollectionEquality().equals(other._onHover, _onHover) && - (identical(other.mouseCursor, mouseCursor) || - other.mouseCursor == mouseCursor) && - (identical(other.focusColor, focusColor) || - other.focusColor == focusColor) && - (identical(other.hoverColor, hoverColor) || - other.hoverColor == hoverColor) && - (identical(other.highlightColor, highlightColor) || - other.highlightColor == highlightColor) && - (identical(other.overlayColor, overlayColor) || - other.overlayColor == overlayColor) && - (identical(other.splashColor, splashColor) || - other.splashColor == splashColor) && - const DeepCollectionEquality() - .equals(other._splashFactory, _splashFactory) && - (identical(other.radius, radius) || other.radius == radius) && - (identical(other.borderRadius, borderRadius) || - other.borderRadius == borderRadius) && - (identical(other.customBorder, customBorder) || - other.customBorder == customBorder) && - (identical(other.enableFeedback, enableFeedback) || - other.enableFeedback == enableFeedback) && - (identical(other.excludeFromSemantics, excludeFromSemantics) || - other.excludeFromSemantics == excludeFromSemantics) && - const DeepCollectionEquality() - .equals(other._focusNode, _focusNode) && - (identical(other.canRequestFocus, canRequestFocus) || - other.canRequestFocus == canRequestFocus) && - const DeepCollectionEquality() - .equals(other._onFocusChange, _onFocusChange) && - (identical(other.autofocus, autofocus) || - other.autofocus == autofocus) && - const DeepCollectionEquality() - .equals(other._statesController, _statesController) && - (identical(other.hoverDuration, hoverDuration) || - other.hoverDuration == hoverDuration)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hashAll([ - runtimeType, - const DeepCollectionEquality().hash(_child), - const DeepCollectionEquality().hash(_onTap), - const DeepCollectionEquality().hash(_onDoubleTap), - const DeepCollectionEquality().hash(_onLongPress), - const DeepCollectionEquality().hash(_onTapDown), - const DeepCollectionEquality().hash(_onTapUp), - const DeepCollectionEquality().hash(_onTapCancel), - const DeepCollectionEquality().hash(_onSecondaryTap), - const DeepCollectionEquality().hash(_onSecondaryTapUp), - const DeepCollectionEquality().hash(_onSecondaryTapDown), - const DeepCollectionEquality().hash(_onSecondaryTapCancel), - const DeepCollectionEquality().hash(_onHighlightChanged), - const DeepCollectionEquality().hash(_onHover), - mouseCursor, - focusColor, - hoverColor, - highlightColor, - overlayColor, - splashColor, - const DeepCollectionEquality().hash(_splashFactory), - radius, - borderRadius, - customBorder, - enableFeedback, - excludeFromSemantics, - const DeepCollectionEquality().hash(_focusNode), - canRequestFocus, - const DeepCollectionEquality().hash(_onFocusChange), - autofocus, - const DeepCollectionEquality().hash(_statesController), - hoverDuration - ]); - - @override - String toString() { - return 'StacInkWell(child: $child, onTap: $onTap, onDoubleTap: $onDoubleTap, onLongPress: $onLongPress, onTapDown: $onTapDown, onTapUp: $onTapUp, onTapCancel: $onTapCancel, onSecondaryTap: $onSecondaryTap, onSecondaryTapUp: $onSecondaryTapUp, onSecondaryTapDown: $onSecondaryTapDown, onSecondaryTapCancel: $onSecondaryTapCancel, onHighlightChanged: $onHighlightChanged, onHover: $onHover, mouseCursor: $mouseCursor, focusColor: $focusColor, hoverColor: $hoverColor, highlightColor: $highlightColor, overlayColor: $overlayColor, splashColor: $splashColor, splashFactory: $splashFactory, radius: $radius, borderRadius: $borderRadius, customBorder: $customBorder, enableFeedback: $enableFeedback, excludeFromSemantics: $excludeFromSemantics, focusNode: $focusNode, canRequestFocus: $canRequestFocus, onFocusChange: $onFocusChange, autofocus: $autofocus, statesController: $statesController, hoverDuration: $hoverDuration)'; - } -} - -/// @nodoc -abstract mixin class _$StacInkWellCopyWith<$Res> - implements $StacInkWellCopyWith<$Res> { - factory _$StacInkWellCopyWith( - _StacInkWell value, $Res Function(_StacInkWell) _then) = - __$StacInkWellCopyWithImpl; - @override - @useResult - $Res call( - {Map? child, - Map? onTap, - Map? onDoubleTap, - Map? onLongPress, - Map? onTapDown, - Map? onTapUp, - Map? onTapCancel, - Map? onSecondaryTap, - Map? onSecondaryTapUp, - Map? onSecondaryTapDown, - Map? onSecondaryTapCancel, - Map? onHighlightChanged, - Map? onHover, - StacMouseCursor? mouseCursor, - String? focusColor, - String? hoverColor, - String? highlightColor, - String? overlayColor, - String? splashColor, - Map? splashFactory, - StacDouble? radius, - StacBorderRadius? borderRadius, - StacBorder? customBorder, - bool enableFeedback, - bool excludeFromSemantics, - Map? focusNode, - bool canRequestFocus, - Map? onFocusChange, - bool autofocus, - Map? statesController, - StacDuration? hoverDuration}); - - @override - $StacDurationCopyWith<$Res>? get hoverDuration; -} - -/// @nodoc -class __$StacInkWellCopyWithImpl<$Res> implements _$StacInkWellCopyWith<$Res> { - __$StacInkWellCopyWithImpl(this._self, this._then); - - final _StacInkWell _self; - final $Res Function(_StacInkWell) _then; - - /// Create a copy of StacInkWell - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? child = freezed, - Object? onTap = freezed, - Object? onDoubleTap = freezed, - Object? onLongPress = freezed, - Object? onTapDown = freezed, - Object? onTapUp = freezed, - Object? onTapCancel = freezed, - Object? onSecondaryTap = freezed, - Object? onSecondaryTapUp = freezed, - Object? onSecondaryTapDown = freezed, - Object? onSecondaryTapCancel = freezed, - Object? onHighlightChanged = freezed, - Object? onHover = freezed, - Object? mouseCursor = freezed, - Object? focusColor = freezed, - Object? hoverColor = freezed, - Object? highlightColor = freezed, - Object? overlayColor = freezed, - Object? splashColor = freezed, - Object? splashFactory = freezed, - Object? radius = freezed, - Object? borderRadius = freezed, - Object? customBorder = freezed, - Object? enableFeedback = null, - Object? excludeFromSemantics = null, - Object? focusNode = freezed, - Object? canRequestFocus = null, - Object? onFocusChange = freezed, - Object? autofocus = null, - Object? statesController = freezed, - Object? hoverDuration = freezed, - }) { - return _then(_StacInkWell( - child: freezed == child - ? _self._child - : child // ignore: cast_nullable_to_non_nullable - as Map?, - onTap: freezed == onTap - ? _self._onTap - : onTap // ignore: cast_nullable_to_non_nullable - as Map?, - onDoubleTap: freezed == onDoubleTap - ? _self._onDoubleTap - : onDoubleTap // ignore: cast_nullable_to_non_nullable - as Map?, - onLongPress: freezed == onLongPress - ? _self._onLongPress - : onLongPress // ignore: cast_nullable_to_non_nullable - as Map?, - onTapDown: freezed == onTapDown - ? _self._onTapDown - : onTapDown // ignore: cast_nullable_to_non_nullable - as Map?, - onTapUp: freezed == onTapUp - ? _self._onTapUp - : onTapUp // ignore: cast_nullable_to_non_nullable - as Map?, - onTapCancel: freezed == onTapCancel - ? _self._onTapCancel - : onTapCancel // ignore: cast_nullable_to_non_nullable - as Map?, - onSecondaryTap: freezed == onSecondaryTap - ? _self._onSecondaryTap - : onSecondaryTap // ignore: cast_nullable_to_non_nullable - as Map?, - onSecondaryTapUp: freezed == onSecondaryTapUp - ? _self._onSecondaryTapUp - : onSecondaryTapUp // ignore: cast_nullable_to_non_nullable - as Map?, - onSecondaryTapDown: freezed == onSecondaryTapDown - ? _self._onSecondaryTapDown - : onSecondaryTapDown // ignore: cast_nullable_to_non_nullable - as Map?, - onSecondaryTapCancel: freezed == onSecondaryTapCancel - ? _self._onSecondaryTapCancel - : onSecondaryTapCancel // ignore: cast_nullable_to_non_nullable - as Map?, - onHighlightChanged: freezed == onHighlightChanged - ? _self._onHighlightChanged - : onHighlightChanged // ignore: cast_nullable_to_non_nullable - as Map?, - onHover: freezed == onHover - ? _self._onHover - : onHover // ignore: cast_nullable_to_non_nullable - as Map?, - mouseCursor: freezed == mouseCursor - ? _self.mouseCursor - : mouseCursor // ignore: cast_nullable_to_non_nullable - as StacMouseCursor?, - focusColor: freezed == focusColor - ? _self.focusColor - : focusColor // ignore: cast_nullable_to_non_nullable - as String?, - hoverColor: freezed == hoverColor - ? _self.hoverColor - : hoverColor // ignore: cast_nullable_to_non_nullable - as String?, - highlightColor: freezed == highlightColor - ? _self.highlightColor - : highlightColor // ignore: cast_nullable_to_non_nullable - as String?, - overlayColor: freezed == overlayColor - ? _self.overlayColor - : overlayColor // ignore: cast_nullable_to_non_nullable - as String?, - splashColor: freezed == splashColor - ? _self.splashColor - : splashColor // ignore: cast_nullable_to_non_nullable - as String?, - splashFactory: freezed == splashFactory - ? _self._splashFactory - : splashFactory // ignore: cast_nullable_to_non_nullable - as Map?, - radius: freezed == radius - ? _self.radius - : radius // ignore: cast_nullable_to_non_nullable - as StacDouble?, - borderRadius: freezed == borderRadius - ? _self.borderRadius - : borderRadius // ignore: cast_nullable_to_non_nullable - as StacBorderRadius?, - customBorder: freezed == customBorder - ? _self.customBorder - : customBorder // ignore: cast_nullable_to_non_nullable - as StacBorder?, - enableFeedback: null == enableFeedback - ? _self.enableFeedback - : enableFeedback // ignore: cast_nullable_to_non_nullable - as bool, - excludeFromSemantics: null == excludeFromSemantics - ? _self.excludeFromSemantics - : excludeFromSemantics // ignore: cast_nullable_to_non_nullable - as bool, - focusNode: freezed == focusNode - ? _self._focusNode - : focusNode // ignore: cast_nullable_to_non_nullable - as Map?, - canRequestFocus: null == canRequestFocus - ? _self.canRequestFocus - : canRequestFocus // ignore: cast_nullable_to_non_nullable - as bool, - onFocusChange: freezed == onFocusChange - ? _self._onFocusChange - : onFocusChange // ignore: cast_nullable_to_non_nullable - as Map?, - autofocus: null == autofocus - ? _self.autofocus - : autofocus // ignore: cast_nullable_to_non_nullable - as bool, - statesController: freezed == statesController - ? _self._statesController - : statesController // ignore: cast_nullable_to_non_nullable - as Map?, - hoverDuration: freezed == hoverDuration - ? _self.hoverDuration - : hoverDuration // ignore: cast_nullable_to_non_nullable - as StacDuration?, - )); - } - - /// Create a copy of StacInkWell - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacDurationCopyWith<$Res>? get hoverDuration { - if (_self.hoverDuration == null) { - return null; - } - - return $StacDurationCopyWith<$Res>(_self.hoverDuration!, (value) { - return _then(_self.copyWith(hoverDuration: value)); - }); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.g.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.g.dart deleted file mode 100644 index 3139a64f..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell.g.dart +++ /dev/null @@ -1,125 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_inkwell.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacInkWell _$StacInkWellFromJson(Map json) => _StacInkWell( - child: json['child'] as Map?, - onTap: json['onTap'] as Map?, - onDoubleTap: json['onDoubleTap'] as Map?, - onLongPress: json['onLongPress'] as Map?, - onTapDown: json['onTapDown'] as Map?, - onTapUp: json['onTapUp'] as Map?, - onTapCancel: json['onTapCancel'] as Map?, - onSecondaryTap: json['onSecondaryTap'] as Map?, - onSecondaryTapUp: json['onSecondaryTapUp'] as Map?, - onSecondaryTapDown: json['onSecondaryTapDown'] as Map?, - onSecondaryTapCancel: - json['onSecondaryTapCancel'] as Map?, - onHighlightChanged: json['onHighlightChanged'] as Map?, - onHover: json['onHover'] as Map?, - mouseCursor: - $enumDecodeNullable(_$StacMouseCursorEnumMap, json['mouseCursor']), - focusColor: json['focusColor'] as String?, - hoverColor: json['hoverColor'] as String?, - highlightColor: json['highlightColor'] as String?, - overlayColor: json['overlayColor'] as String?, - splashColor: json['splashColor'] as String?, - splashFactory: json['splashFactory'] as Map?, - radius: - json['radius'] == null ? null : StacDouble.fromJson(json['radius']), - borderRadius: json['borderRadius'] == null - ? null - : StacBorderRadius.fromJson(json['borderRadius']), - customBorder: json['customBorder'] == null - ? null - : StacBorder.fromJson(json['customBorder'] as Map), - enableFeedback: json['enableFeedback'] as bool? ?? true, - excludeFromSemantics: json['excludeFromSemantics'] as bool? ?? false, - focusNode: json['focusNode'] as Map?, - canRequestFocus: json['canRequestFocus'] as bool? ?? true, - onFocusChange: json['onFocusChange'] as Map?, - autofocus: json['autofocus'] as bool? ?? false, - statesController: json['statesController'] as Map?, - hoverDuration: json['hoverDuration'] == null - ? null - : StacDuration.fromJson( - json['hoverDuration'] as Map), - ); - -Map _$StacInkWellToJson(_StacInkWell instance) => - { - 'child': instance.child, - 'onTap': instance.onTap, - 'onDoubleTap': instance.onDoubleTap, - 'onLongPress': instance.onLongPress, - 'onTapDown': instance.onTapDown, - 'onTapUp': instance.onTapUp, - 'onTapCancel': instance.onTapCancel, - 'onSecondaryTap': instance.onSecondaryTap, - 'onSecondaryTapUp': instance.onSecondaryTapUp, - 'onSecondaryTapDown': instance.onSecondaryTapDown, - 'onSecondaryTapCancel': instance.onSecondaryTapCancel, - 'onHighlightChanged': instance.onHighlightChanged, - 'onHover': instance.onHover, - 'mouseCursor': _$StacMouseCursorEnumMap[instance.mouseCursor], - 'focusColor': instance.focusColor, - 'hoverColor': instance.hoverColor, - 'highlightColor': instance.highlightColor, - 'overlayColor': instance.overlayColor, - 'splashColor': instance.splashColor, - 'splashFactory': instance.splashFactory, - 'radius': instance.radius, - 'borderRadius': instance.borderRadius, - 'customBorder': instance.customBorder, - 'enableFeedback': instance.enableFeedback, - 'excludeFromSemantics': instance.excludeFromSemantics, - 'focusNode': instance.focusNode, - 'canRequestFocus': instance.canRequestFocus, - 'onFocusChange': instance.onFocusChange, - 'autofocus': instance.autofocus, - 'statesController': instance.statesController, - 'hoverDuration': instance.hoverDuration, - }; - -const _$StacMouseCursorEnumMap = { - StacMouseCursor.none: 'none', - StacMouseCursor.basic: 'basic', - StacMouseCursor.click: 'click', - StacMouseCursor.forbidden: 'forbidden', - StacMouseCursor.wait: 'wait', - StacMouseCursor.progress: 'progress', - StacMouseCursor.contextMenu: 'contextMenu', - StacMouseCursor.help: 'help', - StacMouseCursor.text: 'text', - StacMouseCursor.verticalText: 'verticalText', - StacMouseCursor.cell: 'cell', - StacMouseCursor.precise: 'precise', - StacMouseCursor.move: 'move', - StacMouseCursor.grab: 'grab', - StacMouseCursor.grabbing: 'grabbing', - StacMouseCursor.noDrop: 'noDrop', - StacMouseCursor.alias: 'alias', - StacMouseCursor.copy: 'copy', - StacMouseCursor.disappearing: 'disappearing', - StacMouseCursor.allScroll: 'allScroll', - StacMouseCursor.resizeLeftRight: 'resizeLeftRight', - StacMouseCursor.resizeUpDown: 'resizeUpDown', - StacMouseCursor.resizeUpLeftDownRight: 'resizeUpLeftDownRight', - StacMouseCursor.resizeUpRightDownLeft: 'resizeUpRightDownLeft', - StacMouseCursor.resizeUp: 'resizeUp', - StacMouseCursor.resizeDown: 'resizeDown', - StacMouseCursor.resizeLeft: 'resizeLeft', - StacMouseCursor.resizeRight: 'resizeRight', - StacMouseCursor.resizeUpLeft: 'resizeUpLeft', - StacMouseCursor.resizeUpRight: 'resizeUpRight', - StacMouseCursor.resizeDownLeft: 'resizeDownLeft', - StacMouseCursor.resizeDownRight: 'resizeDownRight', - StacMouseCursor.resizeColumn: 'resizeColumn', - StacMouseCursor.resizeRow: 'resizeRow', - StacMouseCursor.zoomIn: 'zoomIn', - StacMouseCursor.zoomOut: 'zoomOut', -}; diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart index 023cb03a..c412ac49 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart @@ -1,9 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/core/stac_action_parser.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_double/stac_double.dart'; -import 'package:stac/src/parsers/widgets/stac_inkwell/stac_inkwell.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac/stac.dart'; +import 'package:stac_models/widgets/ink_well/stac_ink_well.dart'; class StacInkwellParser extends StacParser { const StacInkwellParser(); @@ -19,59 +20,37 @@ class StacInkwellParser extends StacParser { @override Widget parse(BuildContext context, StacInkWell model) { return InkWell( - onTap: model.onTap == null - ? null - : () => Stac.onCallFromJson(model.onTap, context), - onDoubleTap: model.onDoubleTap == null - ? null - : () => Stac.onCallFromJson(model.onDoubleTap, context), - onLongPress: model.onLongPress == null - ? null - : () => Stac.onCallFromJson(model.onLongPress, context), - onTapDown: model.onTapDown == null - ? null - : (_) => Stac.onCallFromJson(model.onTapDown, context), - onTapUp: model.onTapUp == null - ? null - : (_) => Stac.onCallFromJson(model.onTapUp, context), - onTapCancel: model.onTapCancel == null - ? null - : () => Stac.onCallFromJson(model.onTapCancel, context), - onSecondaryTap: model.onSecondaryTap == null - ? null - : () => Stac.onCallFromJson(model.onSecondaryTap, context), - onSecondaryTapUp: model.onSecondaryTapUp == null - ? null - : (_) => Stac.onCallFromJson(model.onSecondaryTapUp, context), - onSecondaryTapDown: model.onSecondaryTapDown == null - ? null - : (_) => Stac.onCallFromJson(model.onSecondaryTapDown, context), - onSecondaryTapCancel: model.onSecondaryTapCancel == null - ? null - : () => Stac.onCallFromJson(model.onSecondaryTapCancel, context), - onHighlightChanged: model.onHighlightChanged == null - ? null - : (_) => Stac.onCallFromJson(model.onHighlightChanged, context), - onHover: model.onHover == null - ? null - : (_) => Stac.onCallFromJson(model.onHover, context), - mouseCursor: model.mouseCursor?.value, - focusColor: model.focusColor.toColor(context), - hoverColor: model.hoverColor.toColor(context), - highlightColor: model.highlightColor.toColor(context), - overlayColor: - WidgetStateProperty.all(model.overlayColor?.toColor(context)), - splashColor: model.splashColor.toColor(context), - radius: model.radius?.parse, + onTap: () => model.onTap?.parse(context), + onDoubleTap: () => model.onDoubleTap?.parse(context), + onLongPress: () => model.onLongPress?.parse(context), + onTapCancel: () => model.onTapCancel?.parse(context), + onSecondaryTap: () => model.onSecondaryTap?.parse(context), + onSecondaryTapCancel: () => model.onSecondaryTapCancel?.parse(context), + onTapDown: (_) => model.onTapDown?.parse(context), + onTapUp: (_) => model.onTapUp?.parse(context), + onSecondaryTapUp: (_) => model.onSecondaryTapUp?.parse(context), + onSecondaryTapDown: (_) => model.onSecondaryTapDown?.parse(context), + onHighlightChanged: (_) => model.onHighlightChanged?.parse(context), + onHover: (_) => model.onHover?.parse(context), + onFocusChange: (_) => model.onFocusChange?.parse(context), + + mouseCursor: model.mouseCursor?.parse, + focusColor: model.focusColor?.toColor(context), + hoverColor: model.hoverColor?.toColor(context), + highlightColor: model.highlightColor?.toColor(context), + overlayColor: model.overlayColor == null + ? null + : MaterialStateProperty.all(model.overlayColor!.toColor(context)), + splashColor: model.splashColor?.toColor(context), + radius: model.radius, borderRadius: model.borderRadius?.parse, customBorder: model.customBorder?.parse(context), - enableFeedback: model.enableFeedback, - excludeFromSemantics: model.excludeFromSemantics, - canRequestFocus: model.canRequestFocus, - onFocusChange: (_) => Stac.onCallFromJson(model.onFocusChange, context), - autofocus: model.autofocus, + enableFeedback: model.enableFeedback ?? true, + excludeFromSemantics: model.excludeFromSemantics ?? false, + canRequestFocus: model.canRequestFocus ?? true, + autofocus: model.autofocus ?? false, hoverDuration: model.hoverDuration?.parse, - child: Stac.fromJson(model.child, context), + child: model.child.parse(context), ); } } diff --git a/packages/stac_models/lib/widgets/ink_well/stac_ink_well.dart b/packages/stac_models/lib/widgets/ink_well/stac_ink_well.dart new file mode 100644 index 00000000..6119d2bb --- /dev/null +++ b/packages/stac_models/lib/widgets/ink_well/stac_ink_well.dart @@ -0,0 +1,165 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_action.dart'; +import 'package:stac_models/core/stac_widget.dart'; +import 'package:stac_models/core/converters/double_converter.dart'; +import 'package:stac_models/painting/stac_color/stac_colors.dart'; +import 'package:stac_models/types/stac_border_radius/stac_border_radius.dart'; +import 'package:stac_models/types/stac_mouse_cursor.dart'; +import 'package:stac_models/types/stac_shape_border/stac_shape_border.dart'; +import 'package:stac_models/types/stac_duration/stac_duration.dart'; + +part 'stac_ink_well.g.dart'; + +/// A Stac model representing Flutter's [InkWell] widget. +/// +/// A rectangular area of a Material that responds to touch. +/// +/// ```dart +/// StacInkWell( +/// onTap: StacAction(type: 'navigate', args: {'path': '/details'}), +/// splashColor: StacColor(value: 0xFF00FF00), // Green splash +/// child: StacText(data: 'Tap Me'), +/// radius: 10.0, +/// ) +/// ``` +/// +/// ```json +/// { +/// "type": "inkWell", +/// "onTap": {"type": "navigate", "args": {"path": "/details"}}, +/// "splashColor": {"value": 4278255360}, +/// "child": {"type": "text", "data": "Tap Me"}, +/// "radius": 10.0 +/// } +/// ``` +@JsonSerializable() +class StacInkWell extends StacWidget { + /// Creates a [StacInkWell] with the given properties. + const StacInkWell({ + this.child, + this.onTap, + this.onDoubleTap, + this.onLongPress, + this.onTapDown, + this.onTapUp, + this.onTapCancel, + this.onSecondaryTap, + this.onSecondaryTapUp, + this.onSecondaryTapDown, + this.onSecondaryTapCancel, + this.onHighlightChanged, + this.onHover, + this.mouseCursor, + this.focusColor, + this.hoverColor, + this.highlightColor, + this.overlayColor, + this.splashColor, + this.radius, + this.borderRadius, + this.customBorder, + this.enableFeedback, + this.excludeFromSemantics, + this.canRequestFocus, + this.onFocusChange, + this.autofocus, + this.hoverDuration, + }); + + /// The widget below this widget in the tree. + final StacWidget? child; + + /// Called when the user taps this part of the material. + final StacAction? onTap; + + /// Called when the user double taps this part of the material. + final StacAction? onDoubleTap; + + /// Called when the user long-presses on this part of the material. + final StacAction? onLongPress; + + /// Called when the user taps down this part of the material. + final StacAction? onTapDown; + + /// Called when the user releases a tap that was previously in contact with this part of the material. + final StacAction? onTapUp; + + /// Called when the user cancels a tap that was previously in contact with this part of the material. + final StacAction? onTapCancel; + + /// Called when the user taps the secondary button on this part of the material. + final StacAction? onSecondaryTap; + + /// Called when the user releases a secondary button tap that was previously in contact with this part of the material. + final StacAction? onSecondaryTapUp; + + /// Called when the user taps down the secondary button on this part of the material. + final StacAction? onSecondaryTapDown; + + /// Called when the user cancels a secondary button tap that was previously in contact with this part of the material. + final StacAction? onSecondaryTapCancel; + + /// Called when the highlight state of this widget changes. + final StacAction? onHighlightChanged; + + /// Called when a pointer enters or exits the ink response area. + final StacAction? onHover; + + /// The cursor for a mouse pointer when it enters or is hovering over the widget. + final StacMouseCursor? mouseCursor; + + /// The color of the ink response when the widget has input focus. + final StacColor? focusColor; + + /// The color of the ink response when a pointer is hovering over it. + final StacColor? hoverColor; + + /// The highlight color of the ink response when pressed. + final StacColor? highlightColor; + + /// The overlay color of the ink response. + final StacColor? overlayColor; // Note: In Flutter this is MaterialStateProperty. StacColor simplifies this for now. + + /// The splash color of the ink response. + final StacColor? splashColor; + + /// The radius of the ink splash. + @DoubleConverter() + final double? radius; + + /// The border radius of the containing rectangle. + final StacBorderRadius? borderRadius; + + /// The custom border to match the ink response. + final StacShapeBorder? customBorder; + + /// Whether detected gestures should provide acoustic and/or haptic feedback. + final bool? enableFeedback; + + /// Whether to exclude the gestures introduced by this widget from the semantics tree. + final bool? excludeFromSemantics; + + /// Whether this widget can be focused. + final bool? canRequestFocus; + + /// Handler for focus state changes. + final StacAction? onFocusChange; + + /// Whether this widget should focus itself if nothing else is already focused. + final bool? autofocus; + + /// The duration for the hover state to be considered active. + final StacDuration? hoverDuration; + + /// Describes the type of this widget for JSON serialization. + @override + String get type => 'inkWell'; + + /// Creates a [StacInkWell] from a JSON map. + factory StacInkWell.fromJson(Map json) => + _$StacInkWellFromJson(json); + + /// Converts this [StacInkWell] instance to a JSON map. + @override + Map toJson() => _$StacInkWellToJson(this); +} diff --git a/packages/stac_models/lib/widgets/ink_well/stac_ink_well.g.dart b/packages/stac_models/lib/widgets/ink_well/stac_ink_well.g.dart new file mode 100644 index 00000000..857417b6 --- /dev/null +++ b/packages/stac_models/lib/widgets/ink_well/stac_ink_well.g.dart @@ -0,0 +1,149 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_ink_well.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacInkWell _$StacInkWellFromJson(Map json) => StacInkWell( + child: json['child'] == null + ? null + : StacWidget.fromJson(json['child'] as Map), + onTap: json['onTap'] == null + ? null + : StacAction.fromJson(json['onTap'] as Map), + onDoubleTap: json['onDoubleTap'] == null + ? null + : StacAction.fromJson(json['onDoubleTap'] as Map), + onLongPress: json['onLongPress'] == null + ? null + : StacAction.fromJson(json['onLongPress'] as Map), + onTapDown: json['onTapDown'] == null + ? null + : StacAction.fromJson(json['onTapDown'] as Map), + onTapUp: json['onTapUp'] == null + ? null + : StacAction.fromJson(json['onTapUp'] as Map), + onTapCancel: json['onTapCancel'] == null + ? null + : StacAction.fromJson(json['onTapCancel'] as Map), + onSecondaryTap: json['onSecondaryTap'] == null + ? null + : StacAction.fromJson(json['onSecondaryTap'] as Map), + onSecondaryTapUp: json['onSecondaryTapUp'] == null + ? null + : StacAction.fromJson(json['onSecondaryTapUp'] as Map), + onSecondaryTapDown: json['onSecondaryTapDown'] == null + ? null + : StacAction.fromJson(json['onSecondaryTapDown'] as Map), + onSecondaryTapCancel: json['onSecondaryTapCancel'] == null + ? null + : StacAction.fromJson( + json['onSecondaryTapCancel'] as Map, + ), + onHighlightChanged: json['onHighlightChanged'] == null + ? null + : StacAction.fromJson(json['onHighlightChanged'] as Map), + onHover: json['onHover'] == null + ? null + : StacAction.fromJson(json['onHover'] as Map), + mouseCursor: $enumDecodeNullable( + _$StacMouseCursorEnumMap, + json['mouseCursor'], + ), + focusColor: json['focusColor'] as String?, + hoverColor: json['hoverColor'] as String?, + highlightColor: json['highlightColor'] as String?, + overlayColor: json['overlayColor'] as String?, + splashColor: json['splashColor'] as String?, + radius: const DoubleConverter().fromJson(json['radius']), + borderRadius: json['borderRadius'] == null + ? null + : StacBorderRadius.fromJson(json['borderRadius']), + customBorder: json['customBorder'] == null + ? null + : StacShapeBorder.fromJson(json['customBorder'] as Map), + enableFeedback: json['enableFeedback'] as bool?, + excludeFromSemantics: json['excludeFromSemantics'] as bool?, + canRequestFocus: json['canRequestFocus'] as bool?, + onFocusChange: json['onFocusChange'] == null + ? null + : StacAction.fromJson(json['onFocusChange'] as Map), + autofocus: json['autofocus'] as bool?, + hoverDuration: json['hoverDuration'] == null + ? null + : StacDuration.fromJson(json['hoverDuration'] as Map), +); + +Map _$StacInkWellToJson(StacInkWell instance) => + { + 'child': instance.child?.toJson(), + 'onTap': instance.onTap?.toJson(), + 'onDoubleTap': instance.onDoubleTap?.toJson(), + 'onLongPress': instance.onLongPress?.toJson(), + 'onTapDown': instance.onTapDown?.toJson(), + 'onTapUp': instance.onTapUp?.toJson(), + 'onTapCancel': instance.onTapCancel?.toJson(), + 'onSecondaryTap': instance.onSecondaryTap?.toJson(), + 'onSecondaryTapUp': instance.onSecondaryTapUp?.toJson(), + 'onSecondaryTapDown': instance.onSecondaryTapDown?.toJson(), + 'onSecondaryTapCancel': instance.onSecondaryTapCancel?.toJson(), + 'onHighlightChanged': instance.onHighlightChanged?.toJson(), + 'onHover': instance.onHover?.toJson(), + 'mouseCursor': _$StacMouseCursorEnumMap[instance.mouseCursor], + 'focusColor': instance.focusColor, + 'hoverColor': instance.hoverColor, + 'highlightColor': instance.highlightColor, + 'overlayColor': instance.overlayColor, + 'splashColor': instance.splashColor, + 'radius': const DoubleConverter().toJson(instance.radius), + 'borderRadius': instance.borderRadius?.toJson(), + 'customBorder': instance.customBorder?.toJson(), + 'enableFeedback': instance.enableFeedback, + 'excludeFromSemantics': instance.excludeFromSemantics, + 'canRequestFocus': instance.canRequestFocus, + 'onFocusChange': instance.onFocusChange?.toJson(), + 'autofocus': instance.autofocus, + 'hoverDuration': instance.hoverDuration?.toJson(), + 'type': instance.type, + }; + +const _$StacMouseCursorEnumMap = { + StacMouseCursor.none: 'none', + StacMouseCursor.basic: 'basic', + StacMouseCursor.click: 'click', + StacMouseCursor.forbidden: 'forbidden', + StacMouseCursor.wait: 'wait', + StacMouseCursor.progress: 'progress', + StacMouseCursor.contextMenu: 'contextMenu', + StacMouseCursor.help: 'help', + StacMouseCursor.text: 'text', + StacMouseCursor.verticalText: 'verticalText', + StacMouseCursor.cell: 'cell', + StacMouseCursor.precise: 'precise', + StacMouseCursor.move: 'move', + StacMouseCursor.grab: 'grab', + StacMouseCursor.grabbing: 'grabbing', + StacMouseCursor.noDrop: 'noDrop', + StacMouseCursor.alias: 'alias', + StacMouseCursor.copy: 'copy', + StacMouseCursor.disappearing: 'disappearing', + StacMouseCursor.allScroll: 'allScroll', + StacMouseCursor.resizeLeftRight: 'resizeLeftRight', + StacMouseCursor.resizeUpDown: 'resizeUpDown', + StacMouseCursor.resizeUpLeftDownRight: 'resizeUpLeftDownRight', + StacMouseCursor.resizeUpRightDownLeft: 'resizeUpRightDownLeft', + StacMouseCursor.resizeUp: 'resizeUp', + StacMouseCursor.resizeDown: 'resizeDown', + StacMouseCursor.resizeLeft: 'resizeLeft', + StacMouseCursor.resizeRight: 'resizeRight', + StacMouseCursor.resizeUpLeft: 'resizeUpLeft', + StacMouseCursor.resizeUpRight: 'resizeUpRight', + StacMouseCursor.resizeDownLeft: 'resizeDownLeft', + StacMouseCursor.resizeDownRight: 'resizeDownRight', + StacMouseCursor.resizeColumn: 'resizeColumn', + StacMouseCursor.resizeRow: 'resizeRow', + StacMouseCursor.zoomIn: 'zoomIn', + StacMouseCursor.zoomOut: 'zoomOut', +}; diff --git a/packages/stac_models/lib/widgets/limited_box/stac_limited_box.dart b/packages/stac_models/lib/widgets/limited_box/stac_limited_box.dart index 9e0ba28c..bee8c132 100644 --- a/packages/stac_models/lib/widgets/limited_box/stac_limited_box.dart +++ b/packages/stac_models/lib/widgets/limited_box/stac_limited_box.dart @@ -53,7 +53,7 @@ class StacLimitedBox extends StacWidget { factory StacLimitedBox.fromJson(Map json) => _$StacLimitedBoxFromJson(json); - /// Converts this StacLimitedBox to JSON. + /// Converts this [StacLimitedBox] to JSON. @override Map toJson() => _$StacLimitedBoxToJson(this); } diff --git a/packages/stac_models/lib/widgets/widgets.dart b/packages/stac_models/lib/widgets/widgets.dart index 22eb2f3b..9f5bd204 100644 --- a/packages/stac_models/lib/widgets/widgets.dart +++ b/packages/stac_models/lib/widgets/widgets.dart @@ -18,6 +18,7 @@ export 'icon/stac_icon.dart'; export 'icon/stac_icons.dart'; export 'icon_button/stac_icon_button.dart'; export 'image/stac_image.dart'; +export 'ink_well/stac_ink_well.dart'; export 'limited_box/stac_limited_box.dart'; export 'opacity/stac_opacity.dart'; export 'outlined_button/stac_outlined_button.dart'; From d20fec468ba3f3191c8c37e01eb14e6a1af61a2e Mon Sep 17 00:00:00 2001 From: Mithul Nayagam Date: Mon, 11 Aug 2025 21:09:31 +0530 Subject: [PATCH 2/8] added StacTextField to DSL --- .../lib/src/parsers/types/type_parser.dart | 110 +++ .../stac_text_field/stac_text_field.dart | 46 -- .../stac_text_field.freezed.dart | 743 ------------------ .../stac_text_field/stac_text_field.g.dart | 144 ---- .../stac_text_field_parser.dart | 78 +- .../stac/lib/src/parsers/widgets/widgets.dart | 2 +- .../stac_models/lib/painting/painting.dart | 1 + .../stac_input_decoration.dart | 130 +++ .../stac_input_decoration.g.dart | 76 ++ .../lib/types/stac_text_input_types.dart | 94 +++ packages/stac_models/lib/types/types.dart | 1 + .../widgets/text_field/stac_text_field.dart | 233 ++++++ .../widgets/text_field/stac_text_field.g.dart | 235 ++++++ packages/stac_models/lib/widgets/widgets.dart | 1 + 14 files changed, 932 insertions(+), 962 deletions(-) delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.freezed.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.g.dart create mode 100644 packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.dart create mode 100644 packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.g.dart create mode 100644 packages/stac_models/lib/types/stac_text_input_types.dart create mode 100644 packages/stac_models/lib/widgets/text_field/stac_text_field.dart create mode 100644 packages/stac_models/lib/widgets/text_field/stac_text_field.g.dart diff --git a/packages/stac/lib/src/parsers/types/type_parser.dart b/packages/stac/lib/src/parsers/types/type_parser.dart index e29a6b9d..ec8b6d21 100644 --- a/packages/stac/lib/src/parsers/types/type_parser.dart +++ b/packages/stac/lib/src/parsers/types/type_parser.dart @@ -33,6 +33,9 @@ import 'package:stac_models/types/stac_text_types.dart'; import 'package:stac_models/types/stac_vertical_direction.dart'; import 'package:stac_models/types/stac_wrap_alignment.dart'; import 'package:stac_models/types/stac_wrap_cross_alignment.dart'; +import 'package:stac/src/parsers/painting/stac_text_style_parser.dart'; +import 'package:stac/src/parsers/painting/stac_edge_insets_parser.dart'; +import 'package:stac/src/parsers/core/stac_widget_parser.dart'; extension StacFloatingActionButtonLocationParser on StacFloatingActionButtonLocation { @@ -78,6 +81,113 @@ extension StacFloatingActionButtonLocationParser } } +extension StacInputDecorationParser on StacInputDecoration { + InputDecoration parse(BuildContext context) { + return InputDecoration( + icon: icon.parse(context), + labelText: labelText, + labelStyle: labelStyle?.parse(context), + hintText: hintText, + hintStyle: hintStyle?.parse(context), + helperText: helperText, + helperStyle: helperStyle?.parse(context), + errorText: errorText, + errorStyle: errorStyle?.parse(context), + prefixIcon: prefixIcon.parse(context), + prefixText: prefixText, + prefixStyle: prefixStyle?.parse(context), + suffixIcon: suffixIcon.parse(context), + suffixText: suffixText, + suffixStyle: suffixStyle?.parse(context), + isDense: isDense, + contentPadding: contentPadding?.parse, + filled: filled, + fillColor: fillColor?.toColor(context), + alignLabelWithHint: alignLabelWithHint, + ); + } +} + +// Kept for backward compatibility if nullable usage is needed elsewhere +// Removed nullable backward-compat InputDecoration parser extension + +extension StacTextInputTypeParser on StacTextInputType { + TextInputType get parse { + switch (this) { + case StacTextInputType.text: + return TextInputType.text; + case StacTextInputType.multiline: + return TextInputType.multiline; + case StacTextInputType.number: + return TextInputType.number; + case StacTextInputType.phone: + return TextInputType.phone; + case StacTextInputType.datetime: + return TextInputType.datetime; + case StacTextInputType.emailAddress: + return TextInputType.emailAddress; + case StacTextInputType.url: + return TextInputType.url; + case StacTextInputType.visiblePassword: + return TextInputType.visiblePassword; + case StacTextInputType.name: + return TextInputType.name; + case StacTextInputType.streetAddress: + return TextInputType.streetAddress; + case StacTextInputType.none: + return TextInputType.none; + } + } +} + +extension StacTextInputActionParser on StacTextInputAction { + TextInputAction get parse { + switch (this) { + case StacTextInputAction.none: + return TextInputAction.none; + case StacTextInputAction.unspecified: + return TextInputAction.unspecified; + case StacTextInputAction.done: + return TextInputAction.done; + case StacTextInputAction.go: + return TextInputAction.go; + case StacTextInputAction.search: + return TextInputAction.search; + case StacTextInputAction.send: + return TextInputAction.send; + case StacTextInputAction.next: + return TextInputAction.next; + case StacTextInputAction.previous: + return TextInputAction.previous; + case StacTextInputAction.continueAction: + return TextInputAction.continueAction; + case StacTextInputAction.join: + return TextInputAction.join; + case StacTextInputAction.route: + return TextInputAction.route; + case StacTextInputAction.emergencyCall: + return TextInputAction.emergencyCall; + case StacTextInputAction.newline: + return TextInputAction.newline; + } + } +} + +extension StacTextCapitalizationParser on StacTextCapitalization { + TextCapitalization get parse { + switch (this) { + case StacTextCapitalization.none: + return TextCapitalization.none; + case StacTextCapitalization.characters: + return TextCapitalization.characters; + case StacTextCapitalization.words: + return TextCapitalization.words; + case StacTextCapitalization.sentences: + return TextCapitalization.sentences; + } + } +} + extension StacAlignmentDirectionalParser on StacAlignmentDirectional { AlignmentDirectional get parse { switch (this) { diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.dart b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.dart deleted file mode 100644 index 4dd77b69..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; -import 'package:stac/src/parsers/widgets/stac_input_decoration/stac_input_decoration.dart'; -import 'package:stac/src/parsers/widgets/stac_input_formatters/stac_input_formatter.dart'; -import 'package:stac/src/utils/text_input_utils.dart'; -import 'package:stac_models/painting/stac_text_style/stac_text_style.dart'; - -export 'stac_text_field_parser.dart'; - -part 'stac_text_field.freezed.dart'; -part 'stac_text_field.g.dart'; - -@freezed -abstract class StacTextField with _$StacTextField { - const factory StacTextField({ - StacInputDecoration? decoration, - @Default('') String initialValue, - StacTextInputType? keyboardType, - TextInputAction? textInputAction, - @Default(TextCapitalization.none) TextCapitalization textCapitalization, - StacTextStyle? style, - @Default(TextAlign.start) TextAlign textAlign, - StacTextAlignVertical? textAlignVertical, - TextDirection? textDirection, - @Default(false) bool readOnly, - bool? showCursor, - @Default(false) expands, - @Default(false) bool autofocus, - @Default('•') String obscuringCharacter, - int? maxLines, - int? minLines, - int? maxLength, - @Default(false) bool obscureText, - @Default(true) bool enableSuggestions, - bool? enabled, - @Default(StacDouble(2)) StacDouble cursorWidth, - StacDouble? cursorHeight, - String? cursorColor, - String? hintText, - @Default([]) List inputFormatters, - }) = _StacTextField; - - factory StacTextField.fromJson(Map json) => - _$StacTextFieldFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.freezed.dart deleted file mode 100644 index 2f2145f6..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.freezed.dart +++ /dev/null @@ -1,743 +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_text_field.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacTextField { - StacInputDecoration? get decoration; - String get initialValue; - StacTextInputType? get keyboardType; - TextInputAction? get textInputAction; - TextCapitalization get textCapitalization; - StacTextStyle? get style; - TextAlign get textAlign; - StacTextAlignVertical? get textAlignVertical; - TextDirection? get textDirection; - bool get readOnly; - bool? get showCursor; - dynamic get expands; - bool get autofocus; - String get obscuringCharacter; - int? get maxLines; - int? get minLines; - int? get maxLength; - bool get obscureText; - bool get enableSuggestions; - bool? get enabled; - StacDouble get cursorWidth; - StacDouble? get cursorHeight; - String? get cursorColor; - String? get hintText; - List get inputFormatters; - - /// Create a copy of StacTextField - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacTextFieldCopyWith get copyWith => - _$StacTextFieldCopyWithImpl( - this as StacTextField, _$identity); - - /// Serializes this StacTextField to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacTextField && - (identical(other.decoration, decoration) || - other.decoration == decoration) && - (identical(other.initialValue, initialValue) || - other.initialValue == initialValue) && - (identical(other.keyboardType, keyboardType) || - other.keyboardType == keyboardType) && - (identical(other.textInputAction, textInputAction) || - other.textInputAction == textInputAction) && - (identical(other.textCapitalization, textCapitalization) || - other.textCapitalization == textCapitalization) && - (identical(other.style, style) || other.style == style) && - (identical(other.textAlign, textAlign) || - other.textAlign == textAlign) && - (identical(other.textAlignVertical, textAlignVertical) || - other.textAlignVertical == textAlignVertical) && - (identical(other.textDirection, textDirection) || - other.textDirection == textDirection) && - (identical(other.readOnly, readOnly) || - other.readOnly == readOnly) && - (identical(other.showCursor, showCursor) || - other.showCursor == showCursor) && - const DeepCollectionEquality().equals(other.expands, expands) && - (identical(other.autofocus, autofocus) || - other.autofocus == autofocus) && - (identical(other.obscuringCharacter, obscuringCharacter) || - other.obscuringCharacter == obscuringCharacter) && - (identical(other.maxLines, maxLines) || - other.maxLines == maxLines) && - (identical(other.minLines, minLines) || - other.minLines == minLines) && - (identical(other.maxLength, maxLength) || - other.maxLength == maxLength) && - (identical(other.obscureText, obscureText) || - other.obscureText == obscureText) && - (identical(other.enableSuggestions, enableSuggestions) || - other.enableSuggestions == enableSuggestions) && - (identical(other.enabled, enabled) || other.enabled == enabled) && - (identical(other.cursorWidth, cursorWidth) || - other.cursorWidth == cursorWidth) && - (identical(other.cursorHeight, cursorHeight) || - other.cursorHeight == cursorHeight) && - (identical(other.cursorColor, cursorColor) || - other.cursorColor == cursorColor) && - (identical(other.hintText, hintText) || - other.hintText == hintText) && - const DeepCollectionEquality() - .equals(other.inputFormatters, inputFormatters)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hashAll([ - runtimeType, - decoration, - initialValue, - keyboardType, - textInputAction, - textCapitalization, - style, - textAlign, - textAlignVertical, - textDirection, - readOnly, - showCursor, - const DeepCollectionEquality().hash(expands), - autofocus, - obscuringCharacter, - maxLines, - minLines, - maxLength, - obscureText, - enableSuggestions, - enabled, - cursorWidth, - cursorHeight, - cursorColor, - hintText, - const DeepCollectionEquality().hash(inputFormatters) - ]); - - @override - String toString() { - return 'StacTextField(decoration: $decoration, initialValue: $initialValue, keyboardType: $keyboardType, textInputAction: $textInputAction, textCapitalization: $textCapitalization, style: $style, textAlign: $textAlign, textAlignVertical: $textAlignVertical, textDirection: $textDirection, readOnly: $readOnly, showCursor: $showCursor, expands: $expands, autofocus: $autofocus, obscuringCharacter: $obscuringCharacter, maxLines: $maxLines, minLines: $minLines, maxLength: $maxLength, obscureText: $obscureText, enableSuggestions: $enableSuggestions, enabled: $enabled, cursorWidth: $cursorWidth, cursorHeight: $cursorHeight, cursorColor: $cursorColor, hintText: $hintText, inputFormatters: $inputFormatters)'; - } -} - -/// @nodoc -abstract mixin class $StacTextFieldCopyWith<$Res> { - factory $StacTextFieldCopyWith( - StacTextField value, $Res Function(StacTextField) _then) = - _$StacTextFieldCopyWithImpl; - @useResult - $Res call( - {StacInputDecoration? decoration, - String initialValue, - StacTextInputType? keyboardType, - TextInputAction? textInputAction, - TextCapitalization textCapitalization, - StacTextStyle? style, - TextAlign textAlign, - StacTextAlignVertical? textAlignVertical, - TextDirection? textDirection, - bool readOnly, - bool? showCursor, - dynamic expands, - bool autofocus, - String obscuringCharacter, - int? maxLines, - int? minLines, - int? maxLength, - bool obscureText, - bool enableSuggestions, - bool? enabled, - StacDouble cursorWidth, - StacDouble? cursorHeight, - String? cursorColor, - String? hintText, - List inputFormatters}); - - $StacInputDecorationCopyWith<$Res>? get decoration; -} - -/// @nodoc -class _$StacTextFieldCopyWithImpl<$Res> - implements $StacTextFieldCopyWith<$Res> { - _$StacTextFieldCopyWithImpl(this._self, this._then); - - final StacTextField _self; - final $Res Function(StacTextField) _then; - - /// Create a copy of StacTextField - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? decoration = freezed, - Object? initialValue = null, - Object? keyboardType = freezed, - Object? textInputAction = freezed, - Object? textCapitalization = null, - Object? style = freezed, - Object? textAlign = null, - Object? textAlignVertical = freezed, - Object? textDirection = freezed, - Object? readOnly = null, - Object? showCursor = freezed, - Object? expands = freezed, - Object? autofocus = null, - Object? obscuringCharacter = null, - Object? maxLines = freezed, - Object? minLines = freezed, - Object? maxLength = freezed, - Object? obscureText = null, - Object? enableSuggestions = null, - Object? enabled = freezed, - Object? cursorWidth = null, - Object? cursorHeight = freezed, - Object? cursorColor = freezed, - Object? hintText = freezed, - Object? inputFormatters = null, - }) { - return _then(_self.copyWith( - decoration: freezed == decoration - ? _self.decoration - : decoration // ignore: cast_nullable_to_non_nullable - as StacInputDecoration?, - initialValue: null == initialValue - ? _self.initialValue - : initialValue // ignore: cast_nullable_to_non_nullable - as String, - keyboardType: freezed == keyboardType - ? _self.keyboardType - : keyboardType // ignore: cast_nullable_to_non_nullable - as StacTextInputType?, - textInputAction: freezed == textInputAction - ? _self.textInputAction - : textInputAction // ignore: cast_nullable_to_non_nullable - as TextInputAction?, - textCapitalization: null == textCapitalization - ? _self.textCapitalization - : textCapitalization // ignore: cast_nullable_to_non_nullable - as TextCapitalization, - style: freezed == style - ? _self.style - : style // ignore: cast_nullable_to_non_nullable - as StacTextStyle?, - textAlign: null == textAlign - ? _self.textAlign - : textAlign // ignore: cast_nullable_to_non_nullable - as TextAlign, - textAlignVertical: freezed == textAlignVertical - ? _self.textAlignVertical - : textAlignVertical // ignore: cast_nullable_to_non_nullable - as StacTextAlignVertical?, - textDirection: freezed == textDirection - ? _self.textDirection - : textDirection // ignore: cast_nullable_to_non_nullable - as TextDirection?, - readOnly: null == readOnly - ? _self.readOnly - : readOnly // ignore: cast_nullable_to_non_nullable - as bool, - showCursor: freezed == showCursor - ? _self.showCursor - : showCursor // ignore: cast_nullable_to_non_nullable - as bool?, - expands: freezed == expands - ? _self.expands - : expands // ignore: cast_nullable_to_non_nullable - as dynamic, - autofocus: null == autofocus - ? _self.autofocus - : autofocus // ignore: cast_nullable_to_non_nullable - as bool, - obscuringCharacter: null == obscuringCharacter - ? _self.obscuringCharacter - : obscuringCharacter // ignore: cast_nullable_to_non_nullable - as String, - maxLines: freezed == maxLines - ? _self.maxLines - : maxLines // ignore: cast_nullable_to_non_nullable - as int?, - minLines: freezed == minLines - ? _self.minLines - : minLines // ignore: cast_nullable_to_non_nullable - as int?, - maxLength: freezed == maxLength - ? _self.maxLength - : maxLength // ignore: cast_nullable_to_non_nullable - as int?, - obscureText: null == obscureText - ? _self.obscureText - : obscureText // ignore: cast_nullable_to_non_nullable - as bool, - enableSuggestions: null == enableSuggestions - ? _self.enableSuggestions - : enableSuggestions // ignore: cast_nullable_to_non_nullable - as bool, - enabled: freezed == enabled - ? _self.enabled - : enabled // ignore: cast_nullable_to_non_nullable - as bool?, - cursorWidth: null == cursorWidth - ? _self.cursorWidth - : cursorWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - cursorHeight: freezed == cursorHeight - ? _self.cursorHeight - : cursorHeight // ignore: cast_nullable_to_non_nullable - as StacDouble?, - cursorColor: freezed == cursorColor - ? _self.cursorColor - : cursorColor // ignore: cast_nullable_to_non_nullable - as String?, - hintText: freezed == hintText - ? _self.hintText - : hintText // ignore: cast_nullable_to_non_nullable - as String?, - inputFormatters: null == inputFormatters - ? _self.inputFormatters - : inputFormatters // ignore: cast_nullable_to_non_nullable - as List, - )); - } - - /// Create a copy of StacTextField - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacInputDecorationCopyWith<$Res>? get decoration { - if (_self.decoration == null) { - return null; - } - - return $StacInputDecorationCopyWith<$Res>(_self.decoration!, (value) { - return _then(_self.copyWith(decoration: value)); - }); - } -} - -/// @nodoc -@JsonSerializable() -class _StacTextField implements StacTextField { - const _StacTextField( - {this.decoration, - this.initialValue = '', - this.keyboardType, - this.textInputAction, - this.textCapitalization = TextCapitalization.none, - this.style, - this.textAlign = TextAlign.start, - this.textAlignVertical, - this.textDirection, - this.readOnly = false, - this.showCursor, - this.expands = false, - this.autofocus = false, - this.obscuringCharacter = '•', - this.maxLines, - this.minLines, - this.maxLength, - this.obscureText = false, - this.enableSuggestions = true, - this.enabled, - this.cursorWidth = const StacDouble(2), - this.cursorHeight, - this.cursorColor, - this.hintText, - final List inputFormatters = const []}) - : _inputFormatters = inputFormatters; - factory _StacTextField.fromJson(Map json) => - _$StacTextFieldFromJson(json); - - @override - final StacInputDecoration? decoration; - @override - @JsonKey() - final String initialValue; - @override - final StacTextInputType? keyboardType; - @override - final TextInputAction? textInputAction; - @override - @JsonKey() - final TextCapitalization textCapitalization; - @override - final StacTextStyle? style; - @override - @JsonKey() - final TextAlign textAlign; - @override - final StacTextAlignVertical? textAlignVertical; - @override - final TextDirection? textDirection; - @override - @JsonKey() - final bool readOnly; - @override - final bool? showCursor; - @override - @JsonKey() - final dynamic expands; - @override - @JsonKey() - final bool autofocus; - @override - @JsonKey() - final String obscuringCharacter; - @override - final int? maxLines; - @override - final int? minLines; - @override - final int? maxLength; - @override - @JsonKey() - final bool obscureText; - @override - @JsonKey() - final bool enableSuggestions; - @override - final bool? enabled; - @override - @JsonKey() - final StacDouble cursorWidth; - @override - final StacDouble? cursorHeight; - @override - final String? cursorColor; - @override - final String? hintText; - final List _inputFormatters; - @override - @JsonKey() - List get inputFormatters { - if (_inputFormatters is EqualUnmodifiableListView) return _inputFormatters; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_inputFormatters); - } - - /// Create a copy of StacTextField - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacTextFieldCopyWith<_StacTextField> get copyWith => - __$StacTextFieldCopyWithImpl<_StacTextField>(this, _$identity); - - @override - Map toJson() { - return _$StacTextFieldToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacTextField && - (identical(other.decoration, decoration) || - other.decoration == decoration) && - (identical(other.initialValue, initialValue) || - other.initialValue == initialValue) && - (identical(other.keyboardType, keyboardType) || - other.keyboardType == keyboardType) && - (identical(other.textInputAction, textInputAction) || - other.textInputAction == textInputAction) && - (identical(other.textCapitalization, textCapitalization) || - other.textCapitalization == textCapitalization) && - (identical(other.style, style) || other.style == style) && - (identical(other.textAlign, textAlign) || - other.textAlign == textAlign) && - (identical(other.textAlignVertical, textAlignVertical) || - other.textAlignVertical == textAlignVertical) && - (identical(other.textDirection, textDirection) || - other.textDirection == textDirection) && - (identical(other.readOnly, readOnly) || - other.readOnly == readOnly) && - (identical(other.showCursor, showCursor) || - other.showCursor == showCursor) && - const DeepCollectionEquality().equals(other.expands, expands) && - (identical(other.autofocus, autofocus) || - other.autofocus == autofocus) && - (identical(other.obscuringCharacter, obscuringCharacter) || - other.obscuringCharacter == obscuringCharacter) && - (identical(other.maxLines, maxLines) || - other.maxLines == maxLines) && - (identical(other.minLines, minLines) || - other.minLines == minLines) && - (identical(other.maxLength, maxLength) || - other.maxLength == maxLength) && - (identical(other.obscureText, obscureText) || - other.obscureText == obscureText) && - (identical(other.enableSuggestions, enableSuggestions) || - other.enableSuggestions == enableSuggestions) && - (identical(other.enabled, enabled) || other.enabled == enabled) && - (identical(other.cursorWidth, cursorWidth) || - other.cursorWidth == cursorWidth) && - (identical(other.cursorHeight, cursorHeight) || - other.cursorHeight == cursorHeight) && - (identical(other.cursorColor, cursorColor) || - other.cursorColor == cursorColor) && - (identical(other.hintText, hintText) || - other.hintText == hintText) && - const DeepCollectionEquality() - .equals(other._inputFormatters, _inputFormatters)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hashAll([ - runtimeType, - decoration, - initialValue, - keyboardType, - textInputAction, - textCapitalization, - style, - textAlign, - textAlignVertical, - textDirection, - readOnly, - showCursor, - const DeepCollectionEquality().hash(expands), - autofocus, - obscuringCharacter, - maxLines, - minLines, - maxLength, - obscureText, - enableSuggestions, - enabled, - cursorWidth, - cursorHeight, - cursorColor, - hintText, - const DeepCollectionEquality().hash(_inputFormatters) - ]); - - @override - String toString() { - return 'StacTextField(decoration: $decoration, initialValue: $initialValue, keyboardType: $keyboardType, textInputAction: $textInputAction, textCapitalization: $textCapitalization, style: $style, textAlign: $textAlign, textAlignVertical: $textAlignVertical, textDirection: $textDirection, readOnly: $readOnly, showCursor: $showCursor, expands: $expands, autofocus: $autofocus, obscuringCharacter: $obscuringCharacter, maxLines: $maxLines, minLines: $minLines, maxLength: $maxLength, obscureText: $obscureText, enableSuggestions: $enableSuggestions, enabled: $enabled, cursorWidth: $cursorWidth, cursorHeight: $cursorHeight, cursorColor: $cursorColor, hintText: $hintText, inputFormatters: $inputFormatters)'; - } -} - -/// @nodoc -abstract mixin class _$StacTextFieldCopyWith<$Res> - implements $StacTextFieldCopyWith<$Res> { - factory _$StacTextFieldCopyWith( - _StacTextField value, $Res Function(_StacTextField) _then) = - __$StacTextFieldCopyWithImpl; - @override - @useResult - $Res call( - {StacInputDecoration? decoration, - String initialValue, - StacTextInputType? keyboardType, - TextInputAction? textInputAction, - TextCapitalization textCapitalization, - StacTextStyle? style, - TextAlign textAlign, - StacTextAlignVertical? textAlignVertical, - TextDirection? textDirection, - bool readOnly, - bool? showCursor, - dynamic expands, - bool autofocus, - String obscuringCharacter, - int? maxLines, - int? minLines, - int? maxLength, - bool obscureText, - bool enableSuggestions, - bool? enabled, - StacDouble cursorWidth, - StacDouble? cursorHeight, - String? cursorColor, - String? hintText, - List inputFormatters}); - - @override - $StacInputDecorationCopyWith<$Res>? get decoration; -} - -/// @nodoc -class __$StacTextFieldCopyWithImpl<$Res> - implements _$StacTextFieldCopyWith<$Res> { - __$StacTextFieldCopyWithImpl(this._self, this._then); - - final _StacTextField _self; - final $Res Function(_StacTextField) _then; - - /// Create a copy of StacTextField - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? decoration = freezed, - Object? initialValue = null, - Object? keyboardType = freezed, - Object? textInputAction = freezed, - Object? textCapitalization = null, - Object? style = freezed, - Object? textAlign = null, - Object? textAlignVertical = freezed, - Object? textDirection = freezed, - Object? readOnly = null, - Object? showCursor = freezed, - Object? expands = freezed, - Object? autofocus = null, - Object? obscuringCharacter = null, - Object? maxLines = freezed, - Object? minLines = freezed, - Object? maxLength = freezed, - Object? obscureText = null, - Object? enableSuggestions = null, - Object? enabled = freezed, - Object? cursorWidth = null, - Object? cursorHeight = freezed, - Object? cursorColor = freezed, - Object? hintText = freezed, - Object? inputFormatters = null, - }) { - return _then(_StacTextField( - decoration: freezed == decoration - ? _self.decoration - : decoration // ignore: cast_nullable_to_non_nullable - as StacInputDecoration?, - initialValue: null == initialValue - ? _self.initialValue - : initialValue // ignore: cast_nullable_to_non_nullable - as String, - keyboardType: freezed == keyboardType - ? _self.keyboardType - : keyboardType // ignore: cast_nullable_to_non_nullable - as StacTextInputType?, - textInputAction: freezed == textInputAction - ? _self.textInputAction - : textInputAction // ignore: cast_nullable_to_non_nullable - as TextInputAction?, - textCapitalization: null == textCapitalization - ? _self.textCapitalization - : textCapitalization // ignore: cast_nullable_to_non_nullable - as TextCapitalization, - style: freezed == style - ? _self.style - : style // ignore: cast_nullable_to_non_nullable - as StacTextStyle?, - textAlign: null == textAlign - ? _self.textAlign - : textAlign // ignore: cast_nullable_to_non_nullable - as TextAlign, - textAlignVertical: freezed == textAlignVertical - ? _self.textAlignVertical - : textAlignVertical // ignore: cast_nullable_to_non_nullable - as StacTextAlignVertical?, - textDirection: freezed == textDirection - ? _self.textDirection - : textDirection // ignore: cast_nullable_to_non_nullable - as TextDirection?, - readOnly: null == readOnly - ? _self.readOnly - : readOnly // ignore: cast_nullable_to_non_nullable - as bool, - showCursor: freezed == showCursor - ? _self.showCursor - : showCursor // ignore: cast_nullable_to_non_nullable - as bool?, - expands: freezed == expands - ? _self.expands - : expands // ignore: cast_nullable_to_non_nullable - as dynamic, - autofocus: null == autofocus - ? _self.autofocus - : autofocus // ignore: cast_nullable_to_non_nullable - as bool, - obscuringCharacter: null == obscuringCharacter - ? _self.obscuringCharacter - : obscuringCharacter // ignore: cast_nullable_to_non_nullable - as String, - maxLines: freezed == maxLines - ? _self.maxLines - : maxLines // ignore: cast_nullable_to_non_nullable - as int?, - minLines: freezed == minLines - ? _self.minLines - : minLines // ignore: cast_nullable_to_non_nullable - as int?, - maxLength: freezed == maxLength - ? _self.maxLength - : maxLength // ignore: cast_nullable_to_non_nullable - as int?, - obscureText: null == obscureText - ? _self.obscureText - : obscureText // ignore: cast_nullable_to_non_nullable - as bool, - enableSuggestions: null == enableSuggestions - ? _self.enableSuggestions - : enableSuggestions // ignore: cast_nullable_to_non_nullable - as bool, - enabled: freezed == enabled - ? _self.enabled - : enabled // ignore: cast_nullable_to_non_nullable - as bool?, - cursorWidth: null == cursorWidth - ? _self.cursorWidth - : cursorWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - cursorHeight: freezed == cursorHeight - ? _self.cursorHeight - : cursorHeight // ignore: cast_nullable_to_non_nullable - as StacDouble?, - cursorColor: freezed == cursorColor - ? _self.cursorColor - : cursorColor // ignore: cast_nullable_to_non_nullable - as String?, - hintText: freezed == hintText - ? _self.hintText - : hintText // ignore: cast_nullable_to_non_nullable - as String?, - inputFormatters: null == inputFormatters - ? _self._inputFormatters - : inputFormatters // ignore: cast_nullable_to_non_nullable - as List, - )); - } - - /// Create a copy of StacTextField - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacInputDecorationCopyWith<$Res>? get decoration { - if (_self.decoration == null) { - return null; - } - - return $StacInputDecorationCopyWith<$Res>(_self.decoration!, (value) { - return _then(_self.copyWith(decoration: value)); - }); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.g.dart b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.g.dart deleted file mode 100644 index 0e09d45c..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field.g.dart +++ /dev/null @@ -1,144 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_text_field.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacTextField _$StacTextFieldFromJson(Map json) => - _StacTextField( - decoration: json['decoration'] == null - ? null - : StacInputDecoration.fromJson( - json['decoration'] as Map), - initialValue: json['initialValue'] as String? ?? '', - keyboardType: - $enumDecodeNullable(_$StacTextInputTypeEnumMap, json['keyboardType']), - textInputAction: $enumDecodeNullable( - _$TextInputActionEnumMap, json['textInputAction']), - textCapitalization: $enumDecodeNullable( - _$TextCapitalizationEnumMap, json['textCapitalization']) ?? - TextCapitalization.none, - style: json['style'] == null - ? null - : StacTextStyle.fromJson(json['style'] as Map), - textAlign: $enumDecodeNullable(_$TextAlignEnumMap, json['textAlign']) ?? - TextAlign.start, - textAlignVertical: $enumDecodeNullable( - _$StacTextAlignVerticalEnumMap, json['textAlignVertical']), - textDirection: - $enumDecodeNullable(_$TextDirectionEnumMap, json['textDirection']), - readOnly: json['readOnly'] as bool? ?? false, - showCursor: json['showCursor'] as bool?, - expands: json['expands'] ?? false, - autofocus: json['autofocus'] as bool? ?? false, - obscuringCharacter: json['obscuringCharacter'] as String? ?? '•', - maxLines: (json['maxLines'] as num?)?.toInt(), - minLines: (json['minLines'] as num?)?.toInt(), - maxLength: (json['maxLength'] as num?)?.toInt(), - obscureText: json['obscureText'] as bool? ?? false, - enableSuggestions: json['enableSuggestions'] as bool? ?? true, - enabled: json['enabled'] as bool?, - cursorWidth: json['cursorWidth'] == null - ? const StacDouble(2) - : StacDouble.fromJson(json['cursorWidth']), - cursorHeight: json['cursorHeight'] == null - ? null - : StacDouble.fromJson(json['cursorHeight']), - cursorColor: json['cursorColor'] as String?, - hintText: json['hintText'] as String?, - inputFormatters: (json['inputFormatters'] as List?) - ?.map( - (e) => StacInputFormatter.fromJson(e as Map)) - .toList() ?? - const [], - ); - -Map _$StacTextFieldToJson(_StacTextField instance) => - { - 'decoration': instance.decoration, - 'initialValue': instance.initialValue, - 'keyboardType': _$StacTextInputTypeEnumMap[instance.keyboardType], - 'textInputAction': _$TextInputActionEnumMap[instance.textInputAction], - 'textCapitalization': - _$TextCapitalizationEnumMap[instance.textCapitalization]!, - 'style': instance.style, - 'textAlign': _$TextAlignEnumMap[instance.textAlign]!, - 'textAlignVertical': - _$StacTextAlignVerticalEnumMap[instance.textAlignVertical], - 'textDirection': _$TextDirectionEnumMap[instance.textDirection], - 'readOnly': instance.readOnly, - 'showCursor': instance.showCursor, - 'expands': instance.expands, - 'autofocus': instance.autofocus, - 'obscuringCharacter': instance.obscuringCharacter, - 'maxLines': instance.maxLines, - 'minLines': instance.minLines, - 'maxLength': instance.maxLength, - 'obscureText': instance.obscureText, - 'enableSuggestions': instance.enableSuggestions, - 'enabled': instance.enabled, - 'cursorWidth': instance.cursorWidth, - 'cursorHeight': instance.cursorHeight, - 'cursorColor': instance.cursorColor, - 'hintText': instance.hintText, - 'inputFormatters': instance.inputFormatters, - }; - -const _$StacTextInputTypeEnumMap = { - StacTextInputType.text: 'text', - StacTextInputType.multiline: 'multiline', - StacTextInputType.number: 'number', - StacTextInputType.phone: 'phone', - StacTextInputType.datetime: 'datetime', - StacTextInputType.emailAddress: 'emailAddress', - StacTextInputType.url: 'url', - StacTextInputType.visiblePassword: 'visiblePassword', - StacTextInputType.name: 'name', - StacTextInputType.streetAddress: 'streetAddress', - StacTextInputType.none: 'none', -}; - -const _$TextInputActionEnumMap = { - TextInputAction.none: 'none', - TextInputAction.unspecified: 'unspecified', - TextInputAction.done: 'done', - TextInputAction.go: 'go', - TextInputAction.search: 'search', - TextInputAction.send: 'send', - TextInputAction.next: 'next', - TextInputAction.previous: 'previous', - TextInputAction.continueAction: 'continueAction', - TextInputAction.join: 'join', - TextInputAction.route: 'route', - TextInputAction.emergencyCall: 'emergencyCall', - TextInputAction.newline: 'newline', -}; - -const _$TextCapitalizationEnumMap = { - TextCapitalization.words: 'words', - TextCapitalization.sentences: 'sentences', - TextCapitalization.characters: 'characters', - TextCapitalization.none: 'none', -}; - -const _$TextAlignEnumMap = { - TextAlign.left: 'left', - TextAlign.right: 'right', - TextAlign.center: 'center', - TextAlign.justify: 'justify', - TextAlign.start: 'start', - TextAlign.end: 'end', -}; - -const _$StacTextAlignVerticalEnumMap = { - StacTextAlignVertical.top: 'top', - StacTextAlignVertical.center: 'center', - StacTextAlignVertical.bottom: 'bottom', -}; - -const _$TextDirectionEnumMap = { - TextDirection.rtl: 'rtl', - TextDirection.ltr: 'ltr', -}; diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart index a9146be4..4d478a24 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart @@ -1,14 +1,16 @@ import 'package:flutter/material.dart'; +import 'package:flutter/gestures.dart'; import 'package:stac/src/parsers/painting/stac_text_style_parser.dart'; -import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; -import 'package:stac/src/parsers/widgets/stac_input_decoration/stac_input_decoration.dart'; -import 'package:stac/src/parsers/widgets/stac_input_formatters/stac_input_formatter.dart'; -import 'package:stac/src/parsers/widgets/stac_text_field/stac_text_field.dart'; +// Removed unused imports +import 'package:stac_models/widgets/text_field/stac_text_field.dart' as models; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; +import 'package:stac/src/parsers/types/type_parser.dart'; +import 'package:stac/src/parsers/core/stac_action_parser.dart'; +import 'package:stac/src/parsers/painting/stac_edge_insets_parser.dart'; -class StacTextFieldParser extends StacParser { +class StacTextFieldParser extends StacParser { const StacTextFieldParser({ this.controller, this.focusNode, @@ -18,45 +20,65 @@ class StacTextFieldParser extends StacParser { final FocusNode? focusNode; @override - StacTextField getModel(Map json) => - StacTextField.fromJson(json); + models.StacTextField getModel(Map json) => + models.StacTextField.fromJson(json); @override String get type => WidgetType.textField.name; @override - Widget parse(BuildContext context, StacTextField model) { - controller?.text = model.initialValue; + Widget parse(BuildContext context, models.StacTextField model) { + if ((model.initialValue ?? '').isNotEmpty) { + controller?.text = model.initialValue!; + } return TextField( - controller: controller ?? TextEditingController(text: model.initialValue), + controller: + controller ?? TextEditingController(text: model.initialValue ?? ''), focusNode: focusNode, - keyboardType: model.keyboardType?.value, - textInputAction: model.textInputAction, - textCapitalization: model.textCapitalization, - textAlign: model.textAlign, - textAlignVertical: model.textAlignVertical?.value, - textDirection: model.textDirection, - readOnly: model.readOnly, + keyboardType: model.keyboardType?.parse, + textInputAction: model.textInputAction?.parse, + textCapitalization: + model.textCapitalization?.parse ?? TextCapitalization.none, + textAlign: model.textAlign?.parse ?? TextAlign.start, + textDirection: model.textDirection?.parse, + readOnly: model.readOnly ?? false, showCursor: model.showCursor, - autofocus: model.autofocus, - obscuringCharacter: model.obscuringCharacter, + autofocus: model.autofocus ?? false, + obscuringCharacter: model.obscuringCharacter ?? '•', maxLines: model.maxLines, minLines: model.minLines, maxLength: model.maxLength, - obscureText: model.obscureText, - enableSuggestions: model.enableSuggestions, + obscureText: model.obscureText ?? false, + enableSuggestions: model.enableSuggestions ?? true, enabled: model.enabled, - expands: model.expands, - cursorWidth: model.cursorWidth.parse, - cursorHeight: model.cursorHeight?.parse, + expands: model.expands ?? false, + cursorWidth: model.cursorWidth ?? 2.0, + cursorHeight: model.cursorHeight, cursorColor: model.cursorColor?.toColor(context), style: model.style?.parse(context), decoration: model.decoration?.parse(context), - inputFormatters: model.inputFormatters - .map((StacInputFormatter formatter) => - formatter.type.format(formatter.rule ?? "")) - .toList(), + scrollPadding: model.scrollPadding?.parse ?? const EdgeInsets.all(20.0), + enableInteractiveSelection: model.enableInteractiveSelection, + mouseCursor: model.mouseCursor?.parse, + dragStartBehavior: + model.dragStartBehavior?.parse ?? DragStartBehavior.start, + scrollPhysics: model.scrollPhysics?.parse, + restorationId: model.restorationId, + clipBehavior: model.clipBehavior?.parse ?? Clip.hardEdge, + autofillHints: model.autofillHints, + onTap: model.onTap == null ? null : () => model.onTap!.parse(context), + onChanged: model.onChanged == null + ? null + : (value) => model.onChanged!.parse(context), + onEditingComplete: model.onEditingComplete == null + ? null + : () => model.onEditingComplete!.parse(context), + onSubmitted: model.onSubmitted == null + ? null + : (value) => model.onSubmitted!.parse(context), ); } } + +// moved to type_parser.dart diff --git a/packages/stac/lib/src/parsers/widgets/widgets.dart b/packages/stac/lib/src/parsers/widgets/widgets.dart index 8a605c97..99c202f9 100644 --- a/packages/stac/lib/src/parsers/widgets/widgets.dart +++ b/packages/stac/lib/src/parsers/widgets/widgets.dart @@ -83,7 +83,7 @@ export 'package:stac/src/parsers/widgets/stac_tab_bar_view/stac_tab_bar_view.dar export 'package:stac/src/parsers/widgets/stac_table/stac_table.dart'; export 'package:stac/src/parsers/widgets/stac_table_cell/stac_table_cell.dart'; export 'package:stac/src/parsers/widgets/stac_text_button/stac_text_button_parser.dart'; -export 'package:stac/src/parsers/widgets/stac_text_field/stac_text_field.dart'; +export 'package:stac/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart'; export 'package:stac/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart'; export 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; export 'package:stac/src/parsers/widgets/stac_vertical_divider/stac_vertical_divider_parser.dart'; diff --git a/packages/stac_models/lib/painting/painting.dart b/packages/stac_models/lib/painting/painting.dart index 1adbd6c3..4ba7a6e7 100644 --- a/packages/stac_models/lib/painting/painting.dart +++ b/packages/stac_models/lib/painting/painting.dart @@ -7,3 +7,4 @@ export 'stac_edge_insets/stac_edge_insets.dart'; export 'stac_system_ui_overlay_style/stac_system_ui_overlay_style.dart'; export 'stac_text_span/stac_text_span.dart'; export 'stac_text_style/stac_text_style.dart'; +export 'stac_input_decoration/stac_input_decoration.dart'; diff --git a/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.dart b/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.dart new file mode 100644 index 00000000..429c4b21 --- /dev/null +++ b/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.dart @@ -0,0 +1,130 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_widget.dart'; +import 'package:stac_models/painting/painting.dart'; + +part 'stac_input_decoration.g.dart'; + +/// Stac model that represents Flutter's [InputDecoration]. +/// +/// Provides labels, hints, helper/error text, and optional prefix/suffix +/// widgets for inputs like [TextField]. +/// +/// {@tool snippet} +/// Dart Example: +/// ```dart +/// StacInputDecoration( +/// labelText: 'Email', +/// hintText: 'name@example.com', +/// prefixText: '@', +/// ) +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// JSON Example: +/// ```json +/// { +/// "labelText": "Email", +/// "hintText": "name@example.com", +/// "prefixText": "@" +/// } +/// ``` +/// {@end-tool} +/// +/// See also: +/// * Flutter's [InputDecoration documentation](https://api.flutter.dev/flutter/material/InputDecoration-class.html) +@JsonSerializable(explicitToJson: true) +class StacInputDecoration extends StacElement { + const StacInputDecoration({ + this.icon, + this.labelText, + this.labelStyle, + this.hintText, + this.hintStyle, + this.helperText, + this.helperStyle, + this.errorText, + this.errorStyle, + this.prefixIcon, + this.prefixText, + this.prefixStyle, + this.suffixIcon, + this.suffixText, + this.suffixStyle, + this.isDense, + this.contentPadding, + this.filled, + this.fillColor, + this.alignLabelWithHint, + }); + + /// A widget to display before the decoration's container. + final StacWidget? icon; + + /// Optional label text to display above/beside the input. + final String? labelText; + + /// Text style for [labelText]. + final StacTextStyle? labelStyle; + + /// Optional placeholder text. + final String? hintText; + + /// Text style for [hintText]. + final StacTextStyle? hintStyle; + + /// Optional helper and error texts. + final String? helperText; + + /// Text style for [helperText]. + final StacTextStyle? helperStyle; + final String? errorText; + + /// Text style for [errorText]. + final StacTextStyle? errorStyle; + + /// Optional prefix/suffix widgets and texts. + final StacWidget? prefixIcon; + final String? prefixText; + + /// Text style for [prefixText]. + final StacTextStyle? prefixStyle; + + /// A widget to display after the editable part of the text field. + final StacWidget? suffixIcon; + + /// Optional text to display after the editable part of the text field. + final String? suffixText; + + /// Text style for [suffixText]. + final StacTextStyle? suffixStyle; + + /// Whether the decoration uses less vertical space. + final bool? isDense; + + /// Padding for the decoration's container. + final StacEdgeInsets? contentPadding; + + /// Whether the decoration's background is filled with [fillColor]. + final bool? filled; + + /// Background color used when [filled] is true. + final StacColor? fillColor; + + /// Whether to align the floating label with the input's hint/center. + /// Useful for multi-line inputs so the label isn't vertically centered. + final bool? alignLabelWithHint; + + /// Creates a [StacInputDecoration] from a JSON map. + /// + /// The [json] argument must be a valid JSON representation of a + /// [StacInputDecoration]. + factory StacInputDecoration.fromJson(Map json) => + _$StacInputDecorationFromJson(json); + + /// Converts this [StacInputDecoration] instance to a JSON map. + @override + Map toJson() => _$StacInputDecorationToJson(this); +} + + diff --git a/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.g.dart b/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.g.dart new file mode 100644 index 00000000..c7acf9d3 --- /dev/null +++ b/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.g.dart @@ -0,0 +1,76 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_input_decoration.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacInputDecoration _$StacInputDecorationFromJson(Map json) => + StacInputDecoration( + icon: json['icon'] == null + ? null + : StacWidget.fromJson(json['icon'] as Map), + labelText: json['labelText'] as String?, + labelStyle: json['labelStyle'] == null + ? null + : StacTextStyle.fromJson(json['labelStyle'] as Map), + hintText: json['hintText'] as String?, + hintStyle: json['hintStyle'] == null + ? null + : StacTextStyle.fromJson(json['hintStyle'] as Map), + helperText: json['helperText'] as String?, + helperStyle: json['helperStyle'] == null + ? null + : StacTextStyle.fromJson(json['helperStyle'] as Map), + errorText: json['errorText'] as String?, + errorStyle: json['errorStyle'] == null + ? null + : StacTextStyle.fromJson(json['errorStyle'] as Map), + prefixIcon: json['prefixIcon'] == null + ? null + : StacWidget.fromJson(json['prefixIcon'] as Map), + prefixText: json['prefixText'] as String?, + prefixStyle: json['prefixStyle'] == null + ? null + : StacTextStyle.fromJson(json['prefixStyle'] as Map), + suffixIcon: json['suffixIcon'] == null + ? null + : StacWidget.fromJson(json['suffixIcon'] as Map), + suffixText: json['suffixText'] as String?, + suffixStyle: json['suffixStyle'] == null + ? null + : StacTextStyle.fromJson(json['suffixStyle'] as Map), + isDense: json['isDense'] as bool?, + contentPadding: json['contentPadding'] == null + ? null + : StacEdgeInsets.fromJson(json['contentPadding']), + filled: json['filled'] as bool?, + fillColor: json['fillColor'] as String?, + alignLabelWithHint: json['alignLabelWithHint'] as bool?, + ); + +Map _$StacInputDecorationToJson( + StacInputDecoration instance, +) => { + 'icon': instance.icon?.toJson(), + 'labelText': instance.labelText, + 'labelStyle': instance.labelStyle?.toJson(), + 'hintText': instance.hintText, + 'hintStyle': instance.hintStyle?.toJson(), + 'helperText': instance.helperText, + 'helperStyle': instance.helperStyle?.toJson(), + 'errorText': instance.errorText, + 'errorStyle': instance.errorStyle?.toJson(), + 'prefixIcon': instance.prefixIcon?.toJson(), + 'prefixText': instance.prefixText, + 'prefixStyle': instance.prefixStyle?.toJson(), + 'suffixIcon': instance.suffixIcon?.toJson(), + 'suffixText': instance.suffixText, + 'suffixStyle': instance.suffixStyle?.toJson(), + 'isDense': instance.isDense, + 'contentPadding': instance.contentPadding?.toJson(), + 'filled': instance.filled, + 'fillColor': instance.fillColor, + 'alignLabelWithHint': instance.alignLabelWithHint, +}; diff --git a/packages/stac_models/lib/types/stac_text_input_types.dart b/packages/stac_models/lib/types/stac_text_input_types.dart new file mode 100644 index 00000000..ac8b8ecd --- /dev/null +++ b/packages/stac_models/lib/types/stac_text_input_types.dart @@ -0,0 +1,94 @@ +/// JSON-friendly keyboard type values for [TextField]. +/// Mirrors Flutter's [TextInputType] at a high level. +enum StacTextInputType { + /// Default text keyboard for general text input. + text, + + /// Text keyboard configured for multi-line entry (enables return/newline). + multiline, + + /// Numeric keyboard for entering numbers (may show decimal/negatives per OS). + number, + + /// Phone keypad optimized for dialing. + phone, + + /// Date/time related input keyboard (platform-specific). + datetime, + + /// Email-optimized keyboard (e.g., includes @ and . shortcuts). + emailAddress, + + /// URL-optimized keyboard (e.g., includes / and . shortcuts). + url, + + /// Password entry with visually distinct layout; pair with obscureText. + visiblePassword, + + /// Name entry keyboard (platform-optimized for names). + name, + + /// Street address entry keyboard (platform-optimized for addresses). + streetAddress, + + /// No particular keyboard, let platform decide. + none, +} + +/// IME action button to display/trigger on the soft keyboard. +/// Mirrors Flutter's [TextInputAction]. +enum StacTextInputAction { + /// No action button. + none, + + /// Let the platform decide. + unspecified, + + /// Complete text entry (e.g., close keyboard). + done, + + /// Proceed to the target destination or submit. + go, + + /// Perform a search. + search, + + /// Send the current input (e.g., message/email). + send, + + /// Move to the next field. + next, + + /// Move to the previous field. + previous, + + /// Continue the current flow. + continueAction, + + /// Join or connect (e.g., meeting/game). + join, + + /// Begin route/directions. + route, + + /// Place an emergency call. + emergencyCall, + + /// Insert a newline (for multi-line fields). + newline, +} + +/// How to auto-capitalize user input. Mirrors Flutter's [TextCapitalization]. +enum StacTextCapitalization { + /// Do not auto-capitalize. + none, + + /// Capitalize all characters. + characters, + + /// Capitalize the first letter of each word. + words, + + /// Capitalize the first letter of each sentence. + sentences, +} diff --git a/packages/stac_models/lib/types/types.dart b/packages/stac_models/lib/types/types.dart index edb8d8da..36c09c4d 100644 --- a/packages/stac_models/lib/types/types.dart +++ b/packages/stac_models/lib/types/types.dart @@ -17,4 +17,5 @@ export 'stac_scroll_physics.dart'; export 'stac_scroll_view_keyboard_dismiss_behavior.dart'; export 'stac_shadow/stac_shadow.dart'; export 'stac_size/stac_size.dart'; +export 'stac_text_input_types.dart'; export 'stac_visual_density/stac_visual_density.dart'; diff --git a/packages/stac_models/lib/widgets/text_field/stac_text_field.dart b/packages/stac_models/lib/widgets/text_field/stac_text_field.dart new file mode 100644 index 00000000..6ab65231 --- /dev/null +++ b/packages/stac_models/lib/widgets/text_field/stac_text_field.dart @@ -0,0 +1,233 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/converters/double_converter.dart'; +import 'package:stac_models/core/stac_action.dart'; +import 'package:stac_models/core/stac_widget.dart'; +import 'package:stac_models/painting/painting.dart'; +import 'package:stac_models/types/types.dart'; +import 'package:stac_models/types/stac_text_types.dart'; +import 'package:stac_models/types/stac_clip.dart'; + +part 'stac_text_field.g.dart'; + +/// A Stac model representing Flutter's [TextField] widget. +/// +/// A material design text field that allows users to enter and edit text. +/// Can be configured for single-line or multi-line input, different keyboard +/// types, obscured input for passwords, and more. Visuals like label, hint, +/// prefix/suffix can be provided via [decoration]. +/// +/// {@tool snippet} +/// Dart Example: +/// ```dart +/// StacTextField( +/// initialValue: 'John Doe', +/// keyboardType: StacTextInputType.text, +/// textInputAction: StacTextInputAction.done, +/// decoration: StacInputDecoration( +/// labelText: 'Name', +/// hintText: 'Enter your full name', +/// ), +/// ) +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// JSON Example: +/// ```json +/// { +/// "type": "textField", +/// "initialValue": "John Doe", +/// "keyboardType": "text", +/// "textInputAction": "done", +/// "decoration": { +/// "labelText": "Name", +/// "hintText": "Enter your full name" +/// }, +/// "autofillHints": ["name"] +/// } +/// ``` +/// {@end-tool} +/// +/// See also: +/// * Flutter's [TextField documentation](https://api.flutter.dev/flutter/material/TextField-class.html) +@JsonSerializable(explicitToJson: true) +class StacTextField extends StacWidget { + const StacTextField({ + this.initialValue, + this.decoration, + this.keyboardType, + this.textInputAction, + this.textCapitalization, + this.style, + this.textAlign, + this.textDirection, + this.readOnly, + this.showCursor, + this.autofocus, + this.obscuringCharacter, + this.obscureText, + this.autocorrect, + this.enableSuggestions, + this.maxLines, + this.minLines, + this.expands, + this.maxLength, + this.enabled, + this.cursorColor, + this.cursorWidth, + this.cursorHeight, + this.scrollPadding, + this.enableInteractiveSelection, + this.mouseCursor, + this.dragStartBehavior, + this.scrollPhysics, + this.restorationId, + this.clipBehavior, + this.autofillHints, + this.onTap, + this.onChanged, + this.onEditingComplete, + this.onSubmitted, + }); + + /// Initial text to display in the field. + final String? initialValue; + + /// Visual decoration and labeling for the text field. + final StacInputDecoration? decoration; + + /// The type of keyboard to use for editing the text. + final StacTextInputType? keyboardType; + + /// The type of action button to use for the keyboard. + final StacTextInputAction? textInputAction; + + /// Configures how the platform keyboard will select an uppercase or lowercase + /// keyboard. If null, Flutter's default behavior applies. + final StacTextCapitalization? textCapitalization; + + /// The style to use for the text being edited. + final StacTextStyle? style; + + /// How the text should be aligned horizontally. + final StacTextAlign? textAlign; + + /// The directionality of the text. + final StacTextDirection? textDirection; + + /// Whether the text can be changed. + /// If false, the field is non-interactive/read-only. + final bool? readOnly; + + /// Whether to show the cursor. + /// If null, Flutter decides based on focus and platform. + final bool? showCursor; + + /// Whether this text field should focus itself if nothing else is already + /// focused. + final bool? autofocus; + + /// Character used for obscuring text if [obscureText] is true. + /// If null, Flutter's default obscuring character is used. + final String? obscuringCharacter; + + /// Whether to hide the text being edited (e.g., for passwords). + final bool? obscureText; + + /// Whether to enable autocorrect. If null, Flutter's default applies. + final bool? autocorrect; + + /// Whether to show input suggestions as the user types. + /// If null, Flutter's default applies. + final bool? enableSuggestions; + + /// The maximum number of lines for the text to span, wrapping if necessary. + /// If null, behaves as a single-line field unless [expands] or [minLines] imply otherwise. + final int? maxLines; + + /// The minimum number of lines to occupy. If null, Flutter's default applies. + final int? minLines; + + /// Whether this widget's height is the sum of [minLines] and [maxLines], or + /// whether it should grow to fill its parent. + final bool? expands; + + /// The maximum number of characters to allow in the text field. + /// If null, there is no enforced character limit. + final int? maxLength; + + /// If false, the text field is disabled and will not respond to input. + /// If null, Flutter's default applies (enabled). + final bool? enabled; + + /// The color to use when painting the cursor. + final StacColor? cursorColor; + + /// How thick the cursor will be. + /// If null, Flutter's default applies. + @DoubleConverter() + final double? cursorWidth; + + /// How tall the cursor will be. + /// If null, Flutter's default applies. + @DoubleConverter() + final double? cursorHeight; + + /// Padding inset used when ensuring the field is visible while scrolling. + final StacEdgeInsets? scrollPadding; + + /// Whether to allow the user to interactively select text in the field. + /// If null, Flutter's default applies. + final bool? enableInteractiveSelection; + + /// The cursor for a mouse pointer when it enters or hovers over the field. + final StacMouseCursor? mouseCursor; + + /// Determines the way that drag start behavior is handled. + /// If null, Flutter's default applies. + final StacDragStartBehavior? dragStartBehavior; + + /// How the embedded scroll view should respond to user input. + final StacScrollPhysics? scrollPhysics; + + /// Restoration ID to save and restore state (e.g., selection, scroll offset). + final String? restorationId; + + /// How to clip the text field's content. + /// Defaults to [Clip.hardEdge] in Flutter. + final StacClip? clipBehavior; + + /// Autofill hint strings to help the platform identify expected input. + final List? autofillHints; + + /// Called when the user taps on the field. + final StacAction? onTap; + + /// Called when the text changes. + final StacAction? onChanged; + + /// Called when the user indicates that they are done editing the text in the + /// field (e.g., focus lost or explicit completion). + final StacAction? onEditingComplete; + + /// Called when the user indicates that they are done editing the text in the + /// field submitted through the IME action. + final StacAction? onSubmitted; + + /// Widget type identifier. + /// + /// Used to identify this widget type during JSON serialization. + @override + String get type => 'textField'; + + /// Creates a [StacTextField] from a JSON map. + /// + /// The [json] argument must be a valid JSON representation of a + /// [StacTextField]. + factory StacTextField.fromJson(Map json) => + _$StacTextFieldFromJson(json); + + /// Converts this [StacTextField] instance to a JSON map. + @override + Map toJson() => _$StacTextFieldToJson(this); +} diff --git a/packages/stac_models/lib/widgets/text_field/stac_text_field.g.dart b/packages/stac_models/lib/widgets/text_field/stac_text_field.g.dart new file mode 100644 index 00000000..c648129b --- /dev/null +++ b/packages/stac_models/lib/widgets/text_field/stac_text_field.g.dart @@ -0,0 +1,235 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_text_field.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacTextField _$StacTextFieldFromJson( + Map json, +) => StacTextField( + initialValue: json['initialValue'] as String?, + decoration: json['decoration'] == null + ? null + : StacInputDecoration.fromJson( + json['decoration'] as Map, + ), + keyboardType: $enumDecodeNullable( + _$StacTextInputTypeEnumMap, + json['keyboardType'], + ), + textInputAction: $enumDecodeNullable( + _$StacTextInputActionEnumMap, + json['textInputAction'], + ), + textCapitalization: $enumDecodeNullable( + _$StacTextCapitalizationEnumMap, + json['textCapitalization'], + ), + style: json['style'] == null + ? null + : StacTextStyle.fromJson(json['style'] as Map), + textAlign: $enumDecodeNullable(_$StacTextAlignEnumMap, json['textAlign']), + textDirection: $enumDecodeNullable( + _$StacTextDirectionEnumMap, + json['textDirection'], + ), + readOnly: json['readOnly'] as bool?, + showCursor: json['showCursor'] as bool?, + autofocus: json['autofocus'] as bool?, + obscuringCharacter: json['obscuringCharacter'] as String?, + obscureText: json['obscureText'] as bool?, + autocorrect: json['autocorrect'] as bool?, + enableSuggestions: json['enableSuggestions'] as bool?, + maxLines: (json['maxLines'] as num?)?.toInt(), + minLines: (json['minLines'] as num?)?.toInt(), + expands: json['expands'] as bool?, + maxLength: (json['maxLength'] as num?)?.toInt(), + enabled: json['enabled'] as bool?, + cursorColor: json['cursorColor'] as String?, + cursorWidth: const DoubleConverter().fromJson(json['cursorWidth']), + cursorHeight: const DoubleConverter().fromJson(json['cursorHeight']), + scrollPadding: json['scrollPadding'] == null + ? null + : StacEdgeInsets.fromJson(json['scrollPadding']), + enableInteractiveSelection: json['enableInteractiveSelection'] as bool?, + mouseCursor: $enumDecodeNullable( + _$StacMouseCursorEnumMap, + json['mouseCursor'], + ), + dragStartBehavior: $enumDecodeNullable( + _$StacDragStartBehaviorEnumMap, + json['dragStartBehavior'], + ), + scrollPhysics: $enumDecodeNullable( + _$StacScrollPhysicsEnumMap, + json['scrollPhysics'], + ), + restorationId: json['restorationId'] as String?, + clipBehavior: $enumDecodeNullable(_$StacClipEnumMap, json['clipBehavior']), + autofillHints: (json['autofillHints'] as List?) + ?.map((e) => e as String) + .toList(), + onTap: json['onTap'] == null + ? null + : StacAction.fromJson(json['onTap'] as Map), + onChanged: json['onChanged'] == null + ? null + : StacAction.fromJson(json['onChanged'] as Map), + onEditingComplete: json['onEditingComplete'] == null + ? null + : StacAction.fromJson(json['onEditingComplete'] as Map), + onSubmitted: json['onSubmitted'] == null + ? null + : StacAction.fromJson(json['onSubmitted'] as Map), +); + +Map _$StacTextFieldToJson(StacTextField instance) => + { + 'initialValue': instance.initialValue, + 'decoration': instance.decoration?.toJson(), + 'keyboardType': _$StacTextInputTypeEnumMap[instance.keyboardType], + 'textInputAction': _$StacTextInputActionEnumMap[instance.textInputAction], + 'textCapitalization': + _$StacTextCapitalizationEnumMap[instance.textCapitalization], + 'style': instance.style?.toJson(), + 'textAlign': _$StacTextAlignEnumMap[instance.textAlign], + 'textDirection': _$StacTextDirectionEnumMap[instance.textDirection], + 'readOnly': instance.readOnly, + 'showCursor': instance.showCursor, + 'autofocus': instance.autofocus, + 'obscuringCharacter': instance.obscuringCharacter, + 'obscureText': instance.obscureText, + 'autocorrect': instance.autocorrect, + 'enableSuggestions': instance.enableSuggestions, + 'maxLines': instance.maxLines, + 'minLines': instance.minLines, + 'expands': instance.expands, + 'maxLength': instance.maxLength, + 'enabled': instance.enabled, + 'cursorColor': instance.cursorColor, + 'cursorWidth': const DoubleConverter().toJson(instance.cursorWidth), + 'cursorHeight': const DoubleConverter().toJson(instance.cursorHeight), + 'scrollPadding': instance.scrollPadding?.toJson(), + 'enableInteractiveSelection': instance.enableInteractiveSelection, + 'mouseCursor': _$StacMouseCursorEnumMap[instance.mouseCursor], + 'dragStartBehavior': + _$StacDragStartBehaviorEnumMap[instance.dragStartBehavior], + 'scrollPhysics': _$StacScrollPhysicsEnumMap[instance.scrollPhysics], + 'restorationId': instance.restorationId, + 'clipBehavior': _$StacClipEnumMap[instance.clipBehavior], + 'autofillHints': instance.autofillHints, + 'onTap': instance.onTap?.toJson(), + 'onChanged': instance.onChanged?.toJson(), + 'onEditingComplete': instance.onEditingComplete?.toJson(), + 'onSubmitted': instance.onSubmitted?.toJson(), + 'type': instance.type, + }; + +const _$StacTextInputTypeEnumMap = { + StacTextInputType.text: 'text', + StacTextInputType.multiline: 'multiline', + StacTextInputType.number: 'number', + StacTextInputType.phone: 'phone', + StacTextInputType.datetime: 'datetime', + StacTextInputType.emailAddress: 'emailAddress', + StacTextInputType.url: 'url', + StacTextInputType.visiblePassword: 'visiblePassword', +}; + +const _$StacTextInputActionEnumMap = { + StacTextInputAction.none: 'none', + StacTextInputAction.unspecified: 'unspecified', + StacTextInputAction.done: 'done', + StacTextInputAction.go: 'go', + StacTextInputAction.search: 'search', + StacTextInputAction.send: 'send', + StacTextInputAction.next: 'next', + StacTextInputAction.previous: 'previous', + StacTextInputAction.continueAction: 'continueAction', + StacTextInputAction.join: 'join', + StacTextInputAction.route: 'route', + StacTextInputAction.emergencyCall: 'emergencyCall', + StacTextInputAction.newline: 'newline', +}; + +const _$StacTextCapitalizationEnumMap = { + StacTextCapitalization.none: 'none', + StacTextCapitalization.characters: 'characters', + StacTextCapitalization.words: 'words', + StacTextCapitalization.sentences: 'sentences', +}; + +const _$StacTextAlignEnumMap = { + StacTextAlign.left: 'left', + StacTextAlign.right: 'right', + StacTextAlign.center: 'center', + StacTextAlign.justify: 'justify', + StacTextAlign.start: 'start', + StacTextAlign.end: 'end', +}; + +const _$StacTextDirectionEnumMap = { + StacTextDirection.rtl: 'rtl', + StacTextDirection.ltr: 'ltr', +}; + +const _$StacMouseCursorEnumMap = { + StacMouseCursor.none: 'none', + StacMouseCursor.basic: 'basic', + StacMouseCursor.click: 'click', + StacMouseCursor.forbidden: 'forbidden', + StacMouseCursor.wait: 'wait', + StacMouseCursor.progress: 'progress', + StacMouseCursor.contextMenu: 'contextMenu', + StacMouseCursor.help: 'help', + StacMouseCursor.text: 'text', + StacMouseCursor.verticalText: 'verticalText', + StacMouseCursor.cell: 'cell', + StacMouseCursor.precise: 'precise', + StacMouseCursor.move: 'move', + StacMouseCursor.grab: 'grab', + StacMouseCursor.grabbing: 'grabbing', + StacMouseCursor.noDrop: 'noDrop', + StacMouseCursor.alias: 'alias', + StacMouseCursor.copy: 'copy', + StacMouseCursor.disappearing: 'disappearing', + StacMouseCursor.allScroll: 'allScroll', + StacMouseCursor.resizeLeftRight: 'resizeLeftRight', + StacMouseCursor.resizeUpDown: 'resizeUpDown', + StacMouseCursor.resizeUpLeftDownRight: 'resizeUpLeftDownRight', + StacMouseCursor.resizeUpRightDownLeft: 'resizeUpRightDownLeft', + StacMouseCursor.resizeUp: 'resizeUp', + StacMouseCursor.resizeDown: 'resizeDown', + StacMouseCursor.resizeLeft: 'resizeLeft', + StacMouseCursor.resizeRight: 'resizeRight', + StacMouseCursor.resizeUpLeft: 'resizeUpLeft', + StacMouseCursor.resizeUpRight: 'resizeUpRight', + StacMouseCursor.resizeDownLeft: 'resizeDownLeft', + StacMouseCursor.resizeDownRight: 'resizeDownRight', + StacMouseCursor.resizeColumn: 'resizeColumn', + StacMouseCursor.resizeRow: 'resizeRow', + StacMouseCursor.zoomIn: 'zoomIn', + StacMouseCursor.zoomOut: 'zoomOut', +}; + +const _$StacDragStartBehaviorEnumMap = { + StacDragStartBehavior.down: 'down', + StacDragStartBehavior.start: 'start', +}; + +const _$StacScrollPhysicsEnumMap = { + StacScrollPhysics.never: 'never', + StacScrollPhysics.bouncing: 'bouncing', + StacScrollPhysics.clamping: 'clamping', + StacScrollPhysics.fixed: 'fixed', + StacScrollPhysics.page: 'page', +}; + +const _$StacClipEnumMap = { + StacClip.none: 'none', + StacClip.hardEdge: 'hardEdge', + StacClip.antiAlias: 'antiAlias', + StacClip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', +}; diff --git a/packages/stac_models/lib/widgets/widgets.dart b/packages/stac_models/lib/widgets/widgets.dart index 9f5bd204..1391b4e1 100644 --- a/packages/stac_models/lib/widgets/widgets.dart +++ b/packages/stac_models/lib/widgets/widgets.dart @@ -34,6 +34,7 @@ export 'spacer/stac_spacer.dart'; export 'stack/stac_stack.dart'; export 'text/stac_text.dart'; export 'text_button/stac_text_button.dart'; +export 'text_field/stac_text_field.dart'; export 'vertical_divider/stac_vertical_divider.dart'; export 'visibility/stac_visibility.dart'; export 'wrap/stac_wrap.dart'; From 32382300fe85d3ed260c6d10809490f526e931cd Mon Sep 17 00:00:00 2001 From: Mithul Nayagam Date: Tue, 12 Aug 2025 17:49:45 +0530 Subject: [PATCH 3/8] added StacTextFormField to DSL --- .../lib/src/parsers/types/type_parser.dart | 63 +- .../stac_text_form_field.dart | 62 - .../stac_text_form_field.freezed.dart | 1019 ----------------- .../stac_text_form_field.g.dart | 210 ---- .../stac_text_form_field_parser.dart | 61 +- .../stac_system_ui_overlay_style.dart | 3 +- .../lib/types/stac_autovalidate_mode.dart | 11 + .../lib/types/stac_brightness.dart | 11 + .../stac_form_field_validator.dart | 27 + .../stac_form_field_validator.g.dart | 18 + .../stac_input_formatter.dart | 36 + .../stac_input_formatter.g.dart | 24 + .../types/stac_max_length_enforcement.dart | 8 + .../lib/types/stac_smart_dashes_type.dart | 8 + .../lib/types/stac_smart_quotes_type.dart | 8 + packages/stac_models/lib/types/types.dart | 8 + .../widgets/text_field/stac_text_field.g.dart | 3 + .../text_form_field/stac_text_form_field.dart | 203 ++++ .../stac_text_form_field.g.dart | 205 ++++ packages/stac_models/lib/widgets/widgets.dart | 1 + 20 files changed, 665 insertions(+), 1324 deletions(-) delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.freezed.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.g.dart create mode 100644 packages/stac_models/lib/types/stac_autovalidate_mode.dart create mode 100644 packages/stac_models/lib/types/stac_brightness.dart create mode 100644 packages/stac_models/lib/types/stac_form_field_validator/stac_form_field_validator.dart create mode 100644 packages/stac_models/lib/types/stac_form_field_validator/stac_form_field_validator.g.dart create mode 100644 packages/stac_models/lib/types/stac_input_formatter/stac_input_formatter.dart create mode 100644 packages/stac_models/lib/types/stac_input_formatter/stac_input_formatter.g.dart create mode 100644 packages/stac_models/lib/types/stac_max_length_enforcement.dart create mode 100644 packages/stac_models/lib/types/stac_smart_dashes_type.dart create mode 100644 packages/stac_models/lib/types/stac_smart_quotes_type.dart create mode 100644 packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.dart create mode 100644 packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.g.dart diff --git a/packages/stac/lib/src/parsers/types/type_parser.dart b/packages/stac/lib/src/parsers/types/type_parser.dart index ec8b6d21..458b451c 100644 --- a/packages/stac/lib/src/parsers/types/type_parser.dart +++ b/packages/stac/lib/src/parsers/types/type_parser.dart @@ -1,6 +1,7 @@ import 'dart:math' as math; import 'package:flutter/gestures.dart'; +import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac_models/stac_models.dart'; @@ -29,13 +30,13 @@ import 'package:stac_models/types/stac_offset/stac_offset.dart'; import 'package:stac_models/types/stac_rect/stac_rect.dart'; import 'package:stac_models/types/stac_shape_border/stac_shape_border.dart'; import 'package:stac_models/types/stac_stack_fit.dart'; -import 'package:stac_models/types/stac_text_types.dart'; import 'package:stac_models/types/stac_vertical_direction.dart'; import 'package:stac_models/types/stac_wrap_alignment.dart'; import 'package:stac_models/types/stac_wrap_cross_alignment.dart'; import 'package:stac/src/parsers/painting/stac_text_style_parser.dart'; import 'package:stac/src/parsers/painting/stac_edge_insets_parser.dart'; import 'package:stac/src/parsers/core/stac_widget_parser.dart'; +import 'package:stac/src/utils/input_formatters.dart'; extension StacFloatingActionButtonLocationParser on StacFloatingActionButtonLocation { @@ -749,6 +750,51 @@ extension StacBrightnessParser on StacBrightness { } } +extension StacSmartDashesTypeParser on StacSmartDashesType { + SmartDashesType get parse { + switch (this) { + case StacSmartDashesType.disabled: + return SmartDashesType.disabled; + case StacSmartDashesType.enabled: + return SmartDashesType.enabled; + } + } +} + +extension StacSmartQuotesTypeParser on StacSmartQuotesType { + SmartQuotesType get parse { + switch (this) { + case StacSmartQuotesType.disabled: + return SmartQuotesType.disabled; + case StacSmartQuotesType.enabled: + return SmartQuotesType.enabled; + } + } +} + +extension StacMaxLengthEnforcementParser on StacMaxLengthEnforcement { + MaxLengthEnforcement get parse { + switch (this) { + case StacMaxLengthEnforcement.none: + return MaxLengthEnforcement.none; + case StacMaxLengthEnforcement.enforced: + return MaxLengthEnforcement.enforced; + } + } +} + +/// Maps [StacInputFormatterType] to core [InputFormatterType]. +extension StacInputFormatterTypeCoreParser on StacInputFormatterType { + InputFormatterType get toCore { + switch (this) { + case StacInputFormatterType.allow: + return InputFormatterType.allow; + case StacInputFormatterType.deny: + return InputFormatterType.deny; + } + } +} + extension StacStackFitParser on StacStackFit { StackFit get parse { switch (this) { @@ -1097,3 +1143,18 @@ extension StacShadowParser on StacShadow { ); } } + +/// Extends [StacAutovalidateMode] to provide parsing functionality. +extension StacAutovalidateModeParser on StacAutovalidateMode { + /// Parses this [StacAutovalidateMode] into a Flutter [AutovalidateMode]. + AutovalidateMode get parse { + switch (this) { + case StacAutovalidateMode.disabled: + return AutovalidateMode.disabled; + case StacAutovalidateMode.always: + return AutovalidateMode.always; + case StacAutovalidateMode.onUserInteraction: + return AutovalidateMode.onUserInteraction; + } + } +} diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart deleted file mode 100644 index 0b695723..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; -import 'package:stac/src/parsers/widgets/stac_form_field_validator/stac_form_validator.dart'; -import 'package:stac/src/parsers/widgets/stac_input_decoration/stac_input_decoration.dart'; -import 'package:stac/src/parsers/widgets/stac_input_formatters/stac_input_formatter.dart'; -import 'package:stac/src/utils/text_input_utils.dart'; -import 'package:stac_models/painting/stac_edge_insets/stac_edge_insets.dart'; -import 'package:stac_models/painting/stac_text_style/stac_text_style.dart'; - -export 'stac_text_form_field_parser.dart'; - -part 'stac_text_form_field.freezed.dart'; -part 'stac_text_form_field.g.dart'; - -@freezed -abstract class StacTextFormField with _$StacTextFormField { - const factory StacTextFormField({ - String? id, - String? compareId, - StacInputDecoration? decoration, - String? initialValue, - StacTextInputType? keyboardType, - TextInputAction? textInputAction, - @Default(TextCapitalization.none) TextCapitalization textCapitalization, - StacTextStyle? style, - @Default(TextAlign.start) TextAlign textAlign, - StacTextAlignVertical? textAlignVertical, - TextDirection? textDirection, - @Default(false) bool readOnly, - bool? showCursor, - @Default(false) bool autofocus, - @Default('•') String obscuringCharacter, - int? maxLines, - int? minLines, - int? maxLength, - bool? obscureText, - @Default(true) bool autocorrect, - SmartDashesType? smartDashesType, - SmartQuotesType? smartQuotesType, - MaxLengthEnforcement? maxLengthEnforcement, - @Default(false) bool expands, - Brightness? keyboardAppearance, - @Default(StacEdgeInsets(bottom: 20, top: 20, left: 20, right: 20)) - StacEdgeInsets scrollPadding, - String? restorationId, - @Default(true) bool enableIMEPersonalizedLearning, - @Default(true) bool enableSuggestions, - bool? enabled, - @Default(StacDouble(2)) StacDouble cursorWidth, - StacDouble? cursorHeight, - String? cursorColor, - String? hintText, - AutovalidateMode? autovalidateMode, - @Default([]) List inputFormatters, - @Default([]) List validatorRules, - }) = _StacTextFormField; - - factory StacTextFormField.fromJson(Map json) => - _$StacTextFormFieldFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.freezed.dart deleted file mode 100644 index d04cc886..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.freezed.dart +++ /dev/null @@ -1,1019 +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_text_form_field.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacTextFormField { - String? get id; - String? get compareId; - StacInputDecoration? get decoration; - String? get initialValue; - StacTextInputType? get keyboardType; - TextInputAction? get textInputAction; - TextCapitalization get textCapitalization; - StacTextStyle? get style; - TextAlign get textAlign; - StacTextAlignVertical? get textAlignVertical; - TextDirection? get textDirection; - bool get readOnly; - bool? get showCursor; - bool get autofocus; - String get obscuringCharacter; - int? get maxLines; - int? get minLines; - int? get maxLength; - bool? get obscureText; - bool get autocorrect; - SmartDashesType? get smartDashesType; - SmartQuotesType? get smartQuotesType; - MaxLengthEnforcement? get maxLengthEnforcement; - bool get expands; - Brightness? get keyboardAppearance; - StacEdgeInsets get scrollPadding; - String? get restorationId; - bool get enableIMEPersonalizedLearning; - bool get enableSuggestions; - bool? get enabled; - StacDouble get cursorWidth; - StacDouble? get cursorHeight; - String? get cursorColor; - String? get hintText; - AutovalidateMode? get autovalidateMode; - List get inputFormatters; - List get validatorRules; - - /// Create a copy of StacTextFormField - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacTextFormFieldCopyWith get copyWith => - _$StacTextFormFieldCopyWithImpl( - this as StacTextFormField, _$identity); - - /// Serializes this StacTextFormField to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacTextFormField && - (identical(other.id, id) || other.id == id) && - (identical(other.compareId, compareId) || - other.compareId == compareId) && - (identical(other.decoration, decoration) || - other.decoration == decoration) && - (identical(other.initialValue, initialValue) || - other.initialValue == initialValue) && - (identical(other.keyboardType, keyboardType) || - other.keyboardType == keyboardType) && - (identical(other.textInputAction, textInputAction) || - other.textInputAction == textInputAction) && - (identical(other.textCapitalization, textCapitalization) || - other.textCapitalization == textCapitalization) && - (identical(other.style, style) || other.style == style) && - (identical(other.textAlign, textAlign) || - other.textAlign == textAlign) && - (identical(other.textAlignVertical, textAlignVertical) || - other.textAlignVertical == textAlignVertical) && - (identical(other.textDirection, textDirection) || - other.textDirection == textDirection) && - (identical(other.readOnly, readOnly) || - other.readOnly == readOnly) && - (identical(other.showCursor, showCursor) || - other.showCursor == showCursor) && - (identical(other.autofocus, autofocus) || - other.autofocus == autofocus) && - (identical(other.obscuringCharacter, obscuringCharacter) || - other.obscuringCharacter == obscuringCharacter) && - (identical(other.maxLines, maxLines) || - other.maxLines == maxLines) && - (identical(other.minLines, minLines) || - other.minLines == minLines) && - (identical(other.maxLength, maxLength) || - other.maxLength == maxLength) && - (identical(other.obscureText, obscureText) || - other.obscureText == obscureText) && - (identical(other.autocorrect, autocorrect) || - other.autocorrect == autocorrect) && - (identical(other.smartDashesType, smartDashesType) || - other.smartDashesType == smartDashesType) && - (identical(other.smartQuotesType, smartQuotesType) || - other.smartQuotesType == smartQuotesType) && - (identical(other.maxLengthEnforcement, maxLengthEnforcement) || - other.maxLengthEnforcement == maxLengthEnforcement) && - (identical(other.expands, expands) || other.expands == expands) && - (identical(other.keyboardAppearance, keyboardAppearance) || - other.keyboardAppearance == keyboardAppearance) && - (identical(other.scrollPadding, scrollPadding) || - other.scrollPadding == scrollPadding) && - (identical(other.restorationId, restorationId) || - other.restorationId == restorationId) && - (identical(other.enableIMEPersonalizedLearning, - enableIMEPersonalizedLearning) || - other.enableIMEPersonalizedLearning == - enableIMEPersonalizedLearning) && - (identical(other.enableSuggestions, enableSuggestions) || - other.enableSuggestions == enableSuggestions) && - (identical(other.enabled, enabled) || other.enabled == enabled) && - (identical(other.cursorWidth, cursorWidth) || - other.cursorWidth == cursorWidth) && - (identical(other.cursorHeight, cursorHeight) || - other.cursorHeight == cursorHeight) && - (identical(other.cursorColor, cursorColor) || - other.cursorColor == cursorColor) && - (identical(other.hintText, hintText) || - other.hintText == hintText) && - (identical(other.autovalidateMode, autovalidateMode) || - other.autovalidateMode == autovalidateMode) && - const DeepCollectionEquality() - .equals(other.inputFormatters, inputFormatters) && - const DeepCollectionEquality() - .equals(other.validatorRules, validatorRules)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hashAll([ - runtimeType, - id, - compareId, - decoration, - initialValue, - keyboardType, - textInputAction, - textCapitalization, - style, - textAlign, - textAlignVertical, - textDirection, - readOnly, - showCursor, - autofocus, - obscuringCharacter, - maxLines, - minLines, - maxLength, - obscureText, - autocorrect, - smartDashesType, - smartQuotesType, - maxLengthEnforcement, - expands, - keyboardAppearance, - scrollPadding, - restorationId, - enableIMEPersonalizedLearning, - enableSuggestions, - enabled, - cursorWidth, - cursorHeight, - cursorColor, - hintText, - autovalidateMode, - const DeepCollectionEquality().hash(inputFormatters), - const DeepCollectionEquality().hash(validatorRules) - ]); - - @override - String toString() { - return 'StacTextFormField(id: $id, compareId: $compareId, decoration: $decoration, initialValue: $initialValue, keyboardType: $keyboardType, textInputAction: $textInputAction, textCapitalization: $textCapitalization, style: $style, textAlign: $textAlign, textAlignVertical: $textAlignVertical, textDirection: $textDirection, readOnly: $readOnly, showCursor: $showCursor, autofocus: $autofocus, obscuringCharacter: $obscuringCharacter, maxLines: $maxLines, minLines: $minLines, maxLength: $maxLength, obscureText: $obscureText, autocorrect: $autocorrect, smartDashesType: $smartDashesType, smartQuotesType: $smartQuotesType, maxLengthEnforcement: $maxLengthEnforcement, expands: $expands, keyboardAppearance: $keyboardAppearance, scrollPadding: $scrollPadding, restorationId: $restorationId, enableIMEPersonalizedLearning: $enableIMEPersonalizedLearning, enableSuggestions: $enableSuggestions, enabled: $enabled, cursorWidth: $cursorWidth, cursorHeight: $cursorHeight, cursorColor: $cursorColor, hintText: $hintText, autovalidateMode: $autovalidateMode, inputFormatters: $inputFormatters, validatorRules: $validatorRules)'; - } -} - -/// @nodoc -abstract mixin class $StacTextFormFieldCopyWith<$Res> { - factory $StacTextFormFieldCopyWith( - StacTextFormField value, $Res Function(StacTextFormField) _then) = - _$StacTextFormFieldCopyWithImpl; - @useResult - $Res call( - {String? id, - String? compareId, - StacInputDecoration? decoration, - String? initialValue, - StacTextInputType? keyboardType, - TextInputAction? textInputAction, - TextCapitalization textCapitalization, - StacTextStyle? style, - TextAlign textAlign, - StacTextAlignVertical? textAlignVertical, - TextDirection? textDirection, - bool readOnly, - bool? showCursor, - bool autofocus, - String obscuringCharacter, - int? maxLines, - int? minLines, - int? maxLength, - bool? obscureText, - bool autocorrect, - SmartDashesType? smartDashesType, - SmartQuotesType? smartQuotesType, - MaxLengthEnforcement? maxLengthEnforcement, - bool expands, - Brightness? keyboardAppearance, - StacEdgeInsets scrollPadding, - String? restorationId, - bool enableIMEPersonalizedLearning, - bool enableSuggestions, - bool? enabled, - StacDouble cursorWidth, - StacDouble? cursorHeight, - String? cursorColor, - String? hintText, - AutovalidateMode? autovalidateMode, - List inputFormatters, - List validatorRules}); - - $StacInputDecorationCopyWith<$Res>? get decoration; -} - -/// @nodoc -class _$StacTextFormFieldCopyWithImpl<$Res> - implements $StacTextFormFieldCopyWith<$Res> { - _$StacTextFormFieldCopyWithImpl(this._self, this._then); - - final StacTextFormField _self; - final $Res Function(StacTextFormField) _then; - - /// Create a copy of StacTextFormField - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? compareId = freezed, - Object? decoration = freezed, - Object? initialValue = freezed, - Object? keyboardType = freezed, - Object? textInputAction = freezed, - Object? textCapitalization = null, - Object? style = freezed, - Object? textAlign = null, - Object? textAlignVertical = freezed, - Object? textDirection = freezed, - Object? readOnly = null, - Object? showCursor = freezed, - Object? autofocus = null, - Object? obscuringCharacter = null, - Object? maxLines = freezed, - Object? minLines = freezed, - Object? maxLength = freezed, - Object? obscureText = freezed, - Object? autocorrect = null, - Object? smartDashesType = freezed, - Object? smartQuotesType = freezed, - Object? maxLengthEnforcement = freezed, - Object? expands = null, - Object? keyboardAppearance = freezed, - Object? scrollPadding = null, - Object? restorationId = freezed, - Object? enableIMEPersonalizedLearning = null, - Object? enableSuggestions = null, - Object? enabled = freezed, - Object? cursorWidth = null, - Object? cursorHeight = freezed, - Object? cursorColor = freezed, - Object? hintText = freezed, - Object? autovalidateMode = freezed, - Object? inputFormatters = null, - Object? validatorRules = null, - }) { - return _then(_self.copyWith( - id: freezed == id - ? _self.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - compareId: freezed == compareId - ? _self.compareId - : compareId // ignore: cast_nullable_to_non_nullable - as String?, - decoration: freezed == decoration - ? _self.decoration - : decoration // ignore: cast_nullable_to_non_nullable - as StacInputDecoration?, - initialValue: freezed == initialValue - ? _self.initialValue - : initialValue // ignore: cast_nullable_to_non_nullable - as String?, - keyboardType: freezed == keyboardType - ? _self.keyboardType - : keyboardType // ignore: cast_nullable_to_non_nullable - as StacTextInputType?, - textInputAction: freezed == textInputAction - ? _self.textInputAction - : textInputAction // ignore: cast_nullable_to_non_nullable - as TextInputAction?, - textCapitalization: null == textCapitalization - ? _self.textCapitalization - : textCapitalization // ignore: cast_nullable_to_non_nullable - as TextCapitalization, - style: freezed == style - ? _self.style - : style // ignore: cast_nullable_to_non_nullable - as StacTextStyle?, - textAlign: null == textAlign - ? _self.textAlign - : textAlign // ignore: cast_nullable_to_non_nullable - as TextAlign, - textAlignVertical: freezed == textAlignVertical - ? _self.textAlignVertical - : textAlignVertical // ignore: cast_nullable_to_non_nullable - as StacTextAlignVertical?, - textDirection: freezed == textDirection - ? _self.textDirection - : textDirection // ignore: cast_nullable_to_non_nullable - as TextDirection?, - readOnly: null == readOnly - ? _self.readOnly - : readOnly // ignore: cast_nullable_to_non_nullable - as bool, - showCursor: freezed == showCursor - ? _self.showCursor - : showCursor // ignore: cast_nullable_to_non_nullable - as bool?, - autofocus: null == autofocus - ? _self.autofocus - : autofocus // ignore: cast_nullable_to_non_nullable - as bool, - obscuringCharacter: null == obscuringCharacter - ? _self.obscuringCharacter - : obscuringCharacter // ignore: cast_nullable_to_non_nullable - as String, - maxLines: freezed == maxLines - ? _self.maxLines - : maxLines // ignore: cast_nullable_to_non_nullable - as int?, - minLines: freezed == minLines - ? _self.minLines - : minLines // ignore: cast_nullable_to_non_nullable - as int?, - maxLength: freezed == maxLength - ? _self.maxLength - : maxLength // ignore: cast_nullable_to_non_nullable - as int?, - obscureText: freezed == obscureText - ? _self.obscureText - : obscureText // ignore: cast_nullable_to_non_nullable - as bool?, - autocorrect: null == autocorrect - ? _self.autocorrect - : autocorrect // ignore: cast_nullable_to_non_nullable - as bool, - smartDashesType: freezed == smartDashesType - ? _self.smartDashesType - : smartDashesType // ignore: cast_nullable_to_non_nullable - as SmartDashesType?, - smartQuotesType: freezed == smartQuotesType - ? _self.smartQuotesType - : smartQuotesType // ignore: cast_nullable_to_non_nullable - as SmartQuotesType?, - maxLengthEnforcement: freezed == maxLengthEnforcement - ? _self.maxLengthEnforcement - : maxLengthEnforcement // ignore: cast_nullable_to_non_nullable - as MaxLengthEnforcement?, - expands: null == expands - ? _self.expands - : expands // ignore: cast_nullable_to_non_nullable - as bool, - keyboardAppearance: freezed == keyboardAppearance - ? _self.keyboardAppearance - : keyboardAppearance // ignore: cast_nullable_to_non_nullable - as Brightness?, - scrollPadding: null == scrollPadding - ? _self.scrollPadding - : scrollPadding // ignore: cast_nullable_to_non_nullable - as StacEdgeInsets, - restorationId: freezed == restorationId - ? _self.restorationId - : restorationId // ignore: cast_nullable_to_non_nullable - as String?, - enableIMEPersonalizedLearning: null == enableIMEPersonalizedLearning - ? _self.enableIMEPersonalizedLearning - : enableIMEPersonalizedLearning // ignore: cast_nullable_to_non_nullable - as bool, - enableSuggestions: null == enableSuggestions - ? _self.enableSuggestions - : enableSuggestions // ignore: cast_nullable_to_non_nullable - as bool, - enabled: freezed == enabled - ? _self.enabled - : enabled // ignore: cast_nullable_to_non_nullable - as bool?, - cursorWidth: null == cursorWidth - ? _self.cursorWidth - : cursorWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - cursorHeight: freezed == cursorHeight - ? _self.cursorHeight - : cursorHeight // ignore: cast_nullable_to_non_nullable - as StacDouble?, - cursorColor: freezed == cursorColor - ? _self.cursorColor - : cursorColor // ignore: cast_nullable_to_non_nullable - as String?, - hintText: freezed == hintText - ? _self.hintText - : hintText // ignore: cast_nullable_to_non_nullable - as String?, - autovalidateMode: freezed == autovalidateMode - ? _self.autovalidateMode - : autovalidateMode // ignore: cast_nullable_to_non_nullable - as AutovalidateMode?, - inputFormatters: null == inputFormatters - ? _self.inputFormatters - : inputFormatters // ignore: cast_nullable_to_non_nullable - as List, - validatorRules: null == validatorRules - ? _self.validatorRules - : validatorRules // ignore: cast_nullable_to_non_nullable - as List, - )); - } - - /// Create a copy of StacTextFormField - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacInputDecorationCopyWith<$Res>? get decoration { - if (_self.decoration == null) { - return null; - } - - return $StacInputDecorationCopyWith<$Res>(_self.decoration!, (value) { - return _then(_self.copyWith(decoration: value)); - }); - } -} - -/// @nodoc -@JsonSerializable() -class _StacTextFormField implements StacTextFormField { - const _StacTextFormField( - {this.id, - this.compareId, - this.decoration, - this.initialValue, - this.keyboardType, - this.textInputAction, - this.textCapitalization = TextCapitalization.none, - this.style, - this.textAlign = TextAlign.start, - this.textAlignVertical, - this.textDirection, - this.readOnly = false, - this.showCursor, - this.autofocus = false, - this.obscuringCharacter = '•', - this.maxLines, - this.minLines, - this.maxLength, - this.obscureText, - this.autocorrect = true, - this.smartDashesType, - this.smartQuotesType, - this.maxLengthEnforcement, - this.expands = false, - this.keyboardAppearance, - this.scrollPadding = - const StacEdgeInsets(bottom: 20, top: 20, left: 20, right: 20), - this.restorationId, - this.enableIMEPersonalizedLearning = true, - this.enableSuggestions = true, - this.enabled, - this.cursorWidth = const StacDouble(2), - this.cursorHeight, - this.cursorColor, - this.hintText, - this.autovalidateMode, - final List inputFormatters = const [], - final List validatorRules = const []}) - : _inputFormatters = inputFormatters, - _validatorRules = validatorRules; - factory _StacTextFormField.fromJson(Map json) => - _$StacTextFormFieldFromJson(json); - - @override - final String? id; - @override - final String? compareId; - @override - final StacInputDecoration? decoration; - @override - final String? initialValue; - @override - final StacTextInputType? keyboardType; - @override - final TextInputAction? textInputAction; - @override - @JsonKey() - final TextCapitalization textCapitalization; - @override - final StacTextStyle? style; - @override - @JsonKey() - final TextAlign textAlign; - @override - final StacTextAlignVertical? textAlignVertical; - @override - final TextDirection? textDirection; - @override - @JsonKey() - final bool readOnly; - @override - final bool? showCursor; - @override - @JsonKey() - final bool autofocus; - @override - @JsonKey() - final String obscuringCharacter; - @override - final int? maxLines; - @override - final int? minLines; - @override - final int? maxLength; - @override - final bool? obscureText; - @override - @JsonKey() - final bool autocorrect; - @override - final SmartDashesType? smartDashesType; - @override - final SmartQuotesType? smartQuotesType; - @override - final MaxLengthEnforcement? maxLengthEnforcement; - @override - @JsonKey() - final bool expands; - @override - final Brightness? keyboardAppearance; - @override - @JsonKey() - final StacEdgeInsets scrollPadding; - @override - final String? restorationId; - @override - @JsonKey() - final bool enableIMEPersonalizedLearning; - @override - @JsonKey() - final bool enableSuggestions; - @override - final bool? enabled; - @override - @JsonKey() - final StacDouble cursorWidth; - @override - final StacDouble? cursorHeight; - @override - final String? cursorColor; - @override - final String? hintText; - @override - final AutovalidateMode? autovalidateMode; - final List _inputFormatters; - @override - @JsonKey() - List get inputFormatters { - if (_inputFormatters is EqualUnmodifiableListView) return _inputFormatters; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_inputFormatters); - } - - final List _validatorRules; - @override - @JsonKey() - List get validatorRules { - if (_validatorRules is EqualUnmodifiableListView) return _validatorRules; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_validatorRules); - } - - /// Create a copy of StacTextFormField - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacTextFormFieldCopyWith<_StacTextFormField> get copyWith => - __$StacTextFormFieldCopyWithImpl<_StacTextFormField>(this, _$identity); - - @override - Map toJson() { - return _$StacTextFormFieldToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacTextFormField && - (identical(other.id, id) || other.id == id) && - (identical(other.compareId, compareId) || - other.compareId == compareId) && - (identical(other.decoration, decoration) || - other.decoration == decoration) && - (identical(other.initialValue, initialValue) || - other.initialValue == initialValue) && - (identical(other.keyboardType, keyboardType) || - other.keyboardType == keyboardType) && - (identical(other.textInputAction, textInputAction) || - other.textInputAction == textInputAction) && - (identical(other.textCapitalization, textCapitalization) || - other.textCapitalization == textCapitalization) && - (identical(other.style, style) || other.style == style) && - (identical(other.textAlign, textAlign) || - other.textAlign == textAlign) && - (identical(other.textAlignVertical, textAlignVertical) || - other.textAlignVertical == textAlignVertical) && - (identical(other.textDirection, textDirection) || - other.textDirection == textDirection) && - (identical(other.readOnly, readOnly) || - other.readOnly == readOnly) && - (identical(other.showCursor, showCursor) || - other.showCursor == showCursor) && - (identical(other.autofocus, autofocus) || - other.autofocus == autofocus) && - (identical(other.obscuringCharacter, obscuringCharacter) || - other.obscuringCharacter == obscuringCharacter) && - (identical(other.maxLines, maxLines) || - other.maxLines == maxLines) && - (identical(other.minLines, minLines) || - other.minLines == minLines) && - (identical(other.maxLength, maxLength) || - other.maxLength == maxLength) && - (identical(other.obscureText, obscureText) || - other.obscureText == obscureText) && - (identical(other.autocorrect, autocorrect) || - other.autocorrect == autocorrect) && - (identical(other.smartDashesType, smartDashesType) || - other.smartDashesType == smartDashesType) && - (identical(other.smartQuotesType, smartQuotesType) || - other.smartQuotesType == smartQuotesType) && - (identical(other.maxLengthEnforcement, maxLengthEnforcement) || - other.maxLengthEnforcement == maxLengthEnforcement) && - (identical(other.expands, expands) || other.expands == expands) && - (identical(other.keyboardAppearance, keyboardAppearance) || - other.keyboardAppearance == keyboardAppearance) && - (identical(other.scrollPadding, scrollPadding) || - other.scrollPadding == scrollPadding) && - (identical(other.restorationId, restorationId) || - other.restorationId == restorationId) && - (identical(other.enableIMEPersonalizedLearning, - enableIMEPersonalizedLearning) || - other.enableIMEPersonalizedLearning == - enableIMEPersonalizedLearning) && - (identical(other.enableSuggestions, enableSuggestions) || - other.enableSuggestions == enableSuggestions) && - (identical(other.enabled, enabled) || other.enabled == enabled) && - (identical(other.cursorWidth, cursorWidth) || - other.cursorWidth == cursorWidth) && - (identical(other.cursorHeight, cursorHeight) || - other.cursorHeight == cursorHeight) && - (identical(other.cursorColor, cursorColor) || - other.cursorColor == cursorColor) && - (identical(other.hintText, hintText) || - other.hintText == hintText) && - (identical(other.autovalidateMode, autovalidateMode) || - other.autovalidateMode == autovalidateMode) && - const DeepCollectionEquality() - .equals(other._inputFormatters, _inputFormatters) && - const DeepCollectionEquality() - .equals(other._validatorRules, _validatorRules)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hashAll([ - runtimeType, - id, - compareId, - decoration, - initialValue, - keyboardType, - textInputAction, - textCapitalization, - style, - textAlign, - textAlignVertical, - textDirection, - readOnly, - showCursor, - autofocus, - obscuringCharacter, - maxLines, - minLines, - maxLength, - obscureText, - autocorrect, - smartDashesType, - smartQuotesType, - maxLengthEnforcement, - expands, - keyboardAppearance, - scrollPadding, - restorationId, - enableIMEPersonalizedLearning, - enableSuggestions, - enabled, - cursorWidth, - cursorHeight, - cursorColor, - hintText, - autovalidateMode, - const DeepCollectionEquality().hash(_inputFormatters), - const DeepCollectionEquality().hash(_validatorRules) - ]); - - @override - String toString() { - return 'StacTextFormField(id: $id, compareId: $compareId, decoration: $decoration, initialValue: $initialValue, keyboardType: $keyboardType, textInputAction: $textInputAction, textCapitalization: $textCapitalization, style: $style, textAlign: $textAlign, textAlignVertical: $textAlignVertical, textDirection: $textDirection, readOnly: $readOnly, showCursor: $showCursor, autofocus: $autofocus, obscuringCharacter: $obscuringCharacter, maxLines: $maxLines, minLines: $minLines, maxLength: $maxLength, obscureText: $obscureText, autocorrect: $autocorrect, smartDashesType: $smartDashesType, smartQuotesType: $smartQuotesType, maxLengthEnforcement: $maxLengthEnforcement, expands: $expands, keyboardAppearance: $keyboardAppearance, scrollPadding: $scrollPadding, restorationId: $restorationId, enableIMEPersonalizedLearning: $enableIMEPersonalizedLearning, enableSuggestions: $enableSuggestions, enabled: $enabled, cursorWidth: $cursorWidth, cursorHeight: $cursorHeight, cursorColor: $cursorColor, hintText: $hintText, autovalidateMode: $autovalidateMode, inputFormatters: $inputFormatters, validatorRules: $validatorRules)'; - } -} - -/// @nodoc -abstract mixin class _$StacTextFormFieldCopyWith<$Res> - implements $StacTextFormFieldCopyWith<$Res> { - factory _$StacTextFormFieldCopyWith( - _StacTextFormField value, $Res Function(_StacTextFormField) _then) = - __$StacTextFormFieldCopyWithImpl; - @override - @useResult - $Res call( - {String? id, - String? compareId, - StacInputDecoration? decoration, - String? initialValue, - StacTextInputType? keyboardType, - TextInputAction? textInputAction, - TextCapitalization textCapitalization, - StacTextStyle? style, - TextAlign textAlign, - StacTextAlignVertical? textAlignVertical, - TextDirection? textDirection, - bool readOnly, - bool? showCursor, - bool autofocus, - String obscuringCharacter, - int? maxLines, - int? minLines, - int? maxLength, - bool? obscureText, - bool autocorrect, - SmartDashesType? smartDashesType, - SmartQuotesType? smartQuotesType, - MaxLengthEnforcement? maxLengthEnforcement, - bool expands, - Brightness? keyboardAppearance, - StacEdgeInsets scrollPadding, - String? restorationId, - bool enableIMEPersonalizedLearning, - bool enableSuggestions, - bool? enabled, - StacDouble cursorWidth, - StacDouble? cursorHeight, - String? cursorColor, - String? hintText, - AutovalidateMode? autovalidateMode, - List inputFormatters, - List validatorRules}); - - @override - $StacInputDecorationCopyWith<$Res>? get decoration; -} - -/// @nodoc -class __$StacTextFormFieldCopyWithImpl<$Res> - implements _$StacTextFormFieldCopyWith<$Res> { - __$StacTextFormFieldCopyWithImpl(this._self, this._then); - - final _StacTextFormField _self; - final $Res Function(_StacTextFormField) _then; - - /// Create a copy of StacTextFormField - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? id = freezed, - Object? compareId = freezed, - Object? decoration = freezed, - Object? initialValue = freezed, - Object? keyboardType = freezed, - Object? textInputAction = freezed, - Object? textCapitalization = null, - Object? style = freezed, - Object? textAlign = null, - Object? textAlignVertical = freezed, - Object? textDirection = freezed, - Object? readOnly = null, - Object? showCursor = freezed, - Object? autofocus = null, - Object? obscuringCharacter = null, - Object? maxLines = freezed, - Object? minLines = freezed, - Object? maxLength = freezed, - Object? obscureText = freezed, - Object? autocorrect = null, - Object? smartDashesType = freezed, - Object? smartQuotesType = freezed, - Object? maxLengthEnforcement = freezed, - Object? expands = null, - Object? keyboardAppearance = freezed, - Object? scrollPadding = null, - Object? restorationId = freezed, - Object? enableIMEPersonalizedLearning = null, - Object? enableSuggestions = null, - Object? enabled = freezed, - Object? cursorWidth = null, - Object? cursorHeight = freezed, - Object? cursorColor = freezed, - Object? hintText = freezed, - Object? autovalidateMode = freezed, - Object? inputFormatters = null, - Object? validatorRules = null, - }) { - return _then(_StacTextFormField( - id: freezed == id - ? _self.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - compareId: freezed == compareId - ? _self.compareId - : compareId // ignore: cast_nullable_to_non_nullable - as String?, - decoration: freezed == decoration - ? _self.decoration - : decoration // ignore: cast_nullable_to_non_nullable - as StacInputDecoration?, - initialValue: freezed == initialValue - ? _self.initialValue - : initialValue // ignore: cast_nullable_to_non_nullable - as String?, - keyboardType: freezed == keyboardType - ? _self.keyboardType - : keyboardType // ignore: cast_nullable_to_non_nullable - as StacTextInputType?, - textInputAction: freezed == textInputAction - ? _self.textInputAction - : textInputAction // ignore: cast_nullable_to_non_nullable - as TextInputAction?, - textCapitalization: null == textCapitalization - ? _self.textCapitalization - : textCapitalization // ignore: cast_nullable_to_non_nullable - as TextCapitalization, - style: freezed == style - ? _self.style - : style // ignore: cast_nullable_to_non_nullable - as StacTextStyle?, - textAlign: null == textAlign - ? _self.textAlign - : textAlign // ignore: cast_nullable_to_non_nullable - as TextAlign, - textAlignVertical: freezed == textAlignVertical - ? _self.textAlignVertical - : textAlignVertical // ignore: cast_nullable_to_non_nullable - as StacTextAlignVertical?, - textDirection: freezed == textDirection - ? _self.textDirection - : textDirection // ignore: cast_nullable_to_non_nullable - as TextDirection?, - readOnly: null == readOnly - ? _self.readOnly - : readOnly // ignore: cast_nullable_to_non_nullable - as bool, - showCursor: freezed == showCursor - ? _self.showCursor - : showCursor // ignore: cast_nullable_to_non_nullable - as bool?, - autofocus: null == autofocus - ? _self.autofocus - : autofocus // ignore: cast_nullable_to_non_nullable - as bool, - obscuringCharacter: null == obscuringCharacter - ? _self.obscuringCharacter - : obscuringCharacter // ignore: cast_nullable_to_non_nullable - as String, - maxLines: freezed == maxLines - ? _self.maxLines - : maxLines // ignore: cast_nullable_to_non_nullable - as int?, - minLines: freezed == minLines - ? _self.minLines - : minLines // ignore: cast_nullable_to_non_nullable - as int?, - maxLength: freezed == maxLength - ? _self.maxLength - : maxLength // ignore: cast_nullable_to_non_nullable - as int?, - obscureText: freezed == obscureText - ? _self.obscureText - : obscureText // ignore: cast_nullable_to_non_nullable - as bool?, - autocorrect: null == autocorrect - ? _self.autocorrect - : autocorrect // ignore: cast_nullable_to_non_nullable - as bool, - smartDashesType: freezed == smartDashesType - ? _self.smartDashesType - : smartDashesType // ignore: cast_nullable_to_non_nullable - as SmartDashesType?, - smartQuotesType: freezed == smartQuotesType - ? _self.smartQuotesType - : smartQuotesType // ignore: cast_nullable_to_non_nullable - as SmartQuotesType?, - maxLengthEnforcement: freezed == maxLengthEnforcement - ? _self.maxLengthEnforcement - : maxLengthEnforcement // ignore: cast_nullable_to_non_nullable - as MaxLengthEnforcement?, - expands: null == expands - ? _self.expands - : expands // ignore: cast_nullable_to_non_nullable - as bool, - keyboardAppearance: freezed == keyboardAppearance - ? _self.keyboardAppearance - : keyboardAppearance // ignore: cast_nullable_to_non_nullable - as Brightness?, - scrollPadding: null == scrollPadding - ? _self.scrollPadding - : scrollPadding // ignore: cast_nullable_to_non_nullable - as StacEdgeInsets, - restorationId: freezed == restorationId - ? _self.restorationId - : restorationId // ignore: cast_nullable_to_non_nullable - as String?, - enableIMEPersonalizedLearning: null == enableIMEPersonalizedLearning - ? _self.enableIMEPersonalizedLearning - : enableIMEPersonalizedLearning // ignore: cast_nullable_to_non_nullable - as bool, - enableSuggestions: null == enableSuggestions - ? _self.enableSuggestions - : enableSuggestions // ignore: cast_nullable_to_non_nullable - as bool, - enabled: freezed == enabled - ? _self.enabled - : enabled // ignore: cast_nullable_to_non_nullable - as bool?, - cursorWidth: null == cursorWidth - ? _self.cursorWidth - : cursorWidth // ignore: cast_nullable_to_non_nullable - as StacDouble, - cursorHeight: freezed == cursorHeight - ? _self.cursorHeight - : cursorHeight // ignore: cast_nullable_to_non_nullable - as StacDouble?, - cursorColor: freezed == cursorColor - ? _self.cursorColor - : cursorColor // ignore: cast_nullable_to_non_nullable - as String?, - hintText: freezed == hintText - ? _self.hintText - : hintText // ignore: cast_nullable_to_non_nullable - as String?, - autovalidateMode: freezed == autovalidateMode - ? _self.autovalidateMode - : autovalidateMode // ignore: cast_nullable_to_non_nullable - as AutovalidateMode?, - inputFormatters: null == inputFormatters - ? _self._inputFormatters - : inputFormatters // ignore: cast_nullable_to_non_nullable - as List, - validatorRules: null == validatorRules - ? _self._validatorRules - : validatorRules // ignore: cast_nullable_to_non_nullable - as List, - )); - } - - /// Create a copy of StacTextFormField - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $StacInputDecorationCopyWith<$Res>? get decoration { - if (_self.decoration == null) { - return null; - } - - return $StacInputDecorationCopyWith<$Res>(_self.decoration!, (value) { - return _then(_self.copyWith(decoration: value)); - }); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.g.dart b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.g.dart deleted file mode 100644 index 22703015..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field.g.dart +++ /dev/null @@ -1,210 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_text_form_field.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacTextFormField _$StacTextFormFieldFromJson(Map json) => - _StacTextFormField( - id: json['id'] as String?, - compareId: json['compareId'] as String?, - decoration: json['decoration'] == null - ? null - : StacInputDecoration.fromJson( - json['decoration'] as Map), - initialValue: json['initialValue'] as String?, - keyboardType: - $enumDecodeNullable(_$StacTextInputTypeEnumMap, json['keyboardType']), - textInputAction: $enumDecodeNullable( - _$TextInputActionEnumMap, json['textInputAction']), - textCapitalization: $enumDecodeNullable( - _$TextCapitalizationEnumMap, json['textCapitalization']) ?? - TextCapitalization.none, - style: json['style'] == null - ? null - : StacTextStyle.fromJson(json['style'] as Map), - textAlign: $enumDecodeNullable(_$TextAlignEnumMap, json['textAlign']) ?? - TextAlign.start, - textAlignVertical: $enumDecodeNullable( - _$StacTextAlignVerticalEnumMap, json['textAlignVertical']), - textDirection: - $enumDecodeNullable(_$TextDirectionEnumMap, json['textDirection']), - readOnly: json['readOnly'] as bool? ?? false, - showCursor: json['showCursor'] as bool?, - autofocus: json['autofocus'] as bool? ?? false, - obscuringCharacter: json['obscuringCharacter'] as String? ?? '•', - maxLines: (json['maxLines'] as num?)?.toInt(), - minLines: (json['minLines'] as num?)?.toInt(), - maxLength: (json['maxLength'] as num?)?.toInt(), - obscureText: json['obscureText'] as bool?, - autocorrect: json['autocorrect'] as bool? ?? true, - smartDashesType: $enumDecodeNullable( - _$SmartDashesTypeEnumMap, json['smartDashesType']), - smartQuotesType: $enumDecodeNullable( - _$SmartQuotesTypeEnumMap, json['smartQuotesType']), - maxLengthEnforcement: $enumDecodeNullable( - _$MaxLengthEnforcementEnumMap, json['maxLengthEnforcement']), - expands: json['expands'] as bool? ?? false, - keyboardAppearance: - $enumDecodeNullable(_$BrightnessEnumMap, json['keyboardAppearance']), - scrollPadding: json['scrollPadding'] == null - ? const StacEdgeInsets(bottom: 20, top: 20, left: 20, right: 20) - : StacEdgeInsets.fromJson(json['scrollPadding']), - restorationId: json['restorationId'] as String?, - enableIMEPersonalizedLearning: - json['enableIMEPersonalizedLearning'] as bool? ?? true, - enableSuggestions: json['enableSuggestions'] as bool? ?? true, - enabled: json['enabled'] as bool?, - cursorWidth: json['cursorWidth'] == null - ? const StacDouble(2) - : StacDouble.fromJson(json['cursorWidth']), - cursorHeight: json['cursorHeight'] == null - ? null - : StacDouble.fromJson(json['cursorHeight']), - cursorColor: json['cursorColor'] as String?, - hintText: json['hintText'] as String?, - autovalidateMode: $enumDecodeNullable( - _$AutovalidateModeEnumMap, json['autovalidateMode']), - inputFormatters: (json['inputFormatters'] as List?) - ?.map( - (e) => StacInputFormatter.fromJson(e as Map)) - .toList() ?? - const [], - validatorRules: (json['validatorRules'] as List?) - ?.map((e) => - StacFormFieldValidator.fromJson(e as Map)) - .toList() ?? - const [], - ); - -Map _$StacTextFormFieldToJson(_StacTextFormField instance) => - { - 'id': instance.id, - 'compareId': instance.compareId, - 'decoration': instance.decoration, - 'initialValue': instance.initialValue, - 'keyboardType': _$StacTextInputTypeEnumMap[instance.keyboardType], - 'textInputAction': _$TextInputActionEnumMap[instance.textInputAction], - 'textCapitalization': - _$TextCapitalizationEnumMap[instance.textCapitalization]!, - 'style': instance.style, - 'textAlign': _$TextAlignEnumMap[instance.textAlign]!, - 'textAlignVertical': - _$StacTextAlignVerticalEnumMap[instance.textAlignVertical], - 'textDirection': _$TextDirectionEnumMap[instance.textDirection], - 'readOnly': instance.readOnly, - 'showCursor': instance.showCursor, - 'autofocus': instance.autofocus, - 'obscuringCharacter': instance.obscuringCharacter, - 'maxLines': instance.maxLines, - 'minLines': instance.minLines, - 'maxLength': instance.maxLength, - 'obscureText': instance.obscureText, - 'autocorrect': instance.autocorrect, - 'smartDashesType': _$SmartDashesTypeEnumMap[instance.smartDashesType], - 'smartQuotesType': _$SmartQuotesTypeEnumMap[instance.smartQuotesType], - 'maxLengthEnforcement': - _$MaxLengthEnforcementEnumMap[instance.maxLengthEnforcement], - 'expands': instance.expands, - 'keyboardAppearance': _$BrightnessEnumMap[instance.keyboardAppearance], - 'scrollPadding': instance.scrollPadding, - 'restorationId': instance.restorationId, - 'enableIMEPersonalizedLearning': instance.enableIMEPersonalizedLearning, - 'enableSuggestions': instance.enableSuggestions, - 'enabled': instance.enabled, - 'cursorWidth': instance.cursorWidth, - 'cursorHeight': instance.cursorHeight, - 'cursorColor': instance.cursorColor, - 'hintText': instance.hintText, - 'autovalidateMode': _$AutovalidateModeEnumMap[instance.autovalidateMode], - 'inputFormatters': instance.inputFormatters, - 'validatorRules': instance.validatorRules, - }; - -const _$StacTextInputTypeEnumMap = { - StacTextInputType.text: 'text', - StacTextInputType.multiline: 'multiline', - StacTextInputType.number: 'number', - StacTextInputType.phone: 'phone', - StacTextInputType.datetime: 'datetime', - StacTextInputType.emailAddress: 'emailAddress', - StacTextInputType.url: 'url', - StacTextInputType.visiblePassword: 'visiblePassword', - StacTextInputType.name: 'name', - StacTextInputType.streetAddress: 'streetAddress', - StacTextInputType.none: 'none', -}; - -const _$TextInputActionEnumMap = { - TextInputAction.none: 'none', - TextInputAction.unspecified: 'unspecified', - TextInputAction.done: 'done', - TextInputAction.go: 'go', - TextInputAction.search: 'search', - TextInputAction.send: 'send', - TextInputAction.next: 'next', - TextInputAction.previous: 'previous', - TextInputAction.continueAction: 'continueAction', - TextInputAction.join: 'join', - TextInputAction.route: 'route', - TextInputAction.emergencyCall: 'emergencyCall', - TextInputAction.newline: 'newline', -}; - -const _$TextCapitalizationEnumMap = { - TextCapitalization.words: 'words', - TextCapitalization.sentences: 'sentences', - TextCapitalization.characters: 'characters', - TextCapitalization.none: 'none', -}; - -const _$TextAlignEnumMap = { - TextAlign.left: 'left', - TextAlign.right: 'right', - TextAlign.center: 'center', - TextAlign.justify: 'justify', - TextAlign.start: 'start', - TextAlign.end: 'end', -}; - -const _$StacTextAlignVerticalEnumMap = { - StacTextAlignVertical.top: 'top', - StacTextAlignVertical.center: 'center', - StacTextAlignVertical.bottom: 'bottom', -}; - -const _$TextDirectionEnumMap = { - TextDirection.rtl: 'rtl', - TextDirection.ltr: 'ltr', -}; - -const _$SmartDashesTypeEnumMap = { - SmartDashesType.disabled: 'disabled', - SmartDashesType.enabled: 'enabled', -}; - -const _$SmartQuotesTypeEnumMap = { - SmartQuotesType.disabled: 'disabled', - SmartQuotesType.enabled: 'enabled', -}; - -const _$MaxLengthEnforcementEnumMap = { - MaxLengthEnforcement.none: 'none', - MaxLengthEnforcement.enforced: 'enforced', - MaxLengthEnforcement.truncateAfterCompositionEnds: - 'truncateAfterCompositionEnds', -}; - -const _$BrightnessEnumMap = { - Brightness.dark: 'dark', - Brightness.light: 'light', -}; - -const _$AutovalidateModeEnumMap = { - AutovalidateMode.disabled: 'disabled', - AutovalidateMode.always: 'always', - AutovalidateMode.onUserInteraction: 'onUserInteraction', - AutovalidateMode.onUnfocus: 'onUnfocus', -}; diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart index 0507b580..5a48445d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/types/type_parser.dart'; import 'package:stac/src/parsers/painting/stac_edge_insets_parser.dart'; import 'package:stac/src/parsers/painting/stac_text_style_parser.dart'; -import 'package:stac/src/parsers/parsers.dart'; -import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart'; +import 'package:stac/src/parsers/widgets/stac_form/stac_form_scope.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/input_validations.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; import 'package:stac_logger/stac_logger.dart'; +import 'package:stac_models/widgets/text_form_field/stac_text_form_field.dart'; class StacTextFormFieldParser extends StacParser { const StacTextFormFieldParser(); @@ -62,41 +63,41 @@ class _TextFormFieldWidgetState extends State<_TextFormFieldWidget> { widget.formScope?.formData[widget.model.id!] = value; } }, - keyboardType: widget.model.keyboardType?.value, - textInputAction: widget.model.textInputAction, - textCapitalization: widget.model.textCapitalization, - textAlign: widget.model.textAlign, - textAlignVertical: widget.model.textAlignVertical?.value, - textDirection: widget.model.textDirection, - readOnly: widget.model.readOnly, + keyboardType: widget.model.keyboardType?.parse, + textInputAction: widget.model.textInputAction?.parse, + textCapitalization: + widget.model.textCapitalization?.parse ?? TextCapitalization.none, + textAlign: widget.model.textAlign?.parse ?? TextAlign.start, + textDirection: widget.model.textDirection?.parse, + readOnly: widget.model.readOnly ?? false, showCursor: widget.model.showCursor, - autofocus: widget.model.autofocus, - autovalidateMode: widget.model.autovalidateMode, - obscuringCharacter: widget.model.obscuringCharacter, + autofocus: widget.model.autofocus ?? false, + autovalidateMode: widget.model.autovalidateMode?.parse, + obscuringCharacter: widget.model.obscuringCharacter ?? '•', maxLines: widget.model.maxLines, minLines: widget.model.minLines, maxLength: widget.model.maxLength, obscureText: _obscureText, - autocorrect: widget.model.autocorrect, - smartDashesType: widget.model.smartDashesType, - smartQuotesType: widget.model.smartQuotesType, - maxLengthEnforcement: widget.model.maxLengthEnforcement, - expands: widget.model.expands, - keyboardAppearance: widget.model.keyboardAppearance, - scrollPadding: widget.model.scrollPadding.parse, + autocorrect: widget.model.autocorrect ?? true, + smartDashesType: widget.model.smartDashesType?.parse, + smartQuotesType: widget.model.smartQuotesType?.parse, + maxLengthEnforcement: widget.model.maxLengthEnforcement?.parse, + expands: widget.model.expands ?? false, + keyboardAppearance: widget.model.keyboardAppearance?.parse, + scrollPadding: + widget.model.scrollPadding?.parse ?? const EdgeInsets.all(20), restorationId: widget.model.restorationId, - enableIMEPersonalizedLearning: widget.model.enableIMEPersonalizedLearning, - enableSuggestions: widget.model.enableSuggestions, + enableIMEPersonalizedLearning: + widget.model.enableIMEPersonalizedLearning ?? true, + enableSuggestions: widget.model.enableSuggestions ?? true, enabled: widget.model.enabled, - cursorWidth: widget.model.cursorWidth.parse, - cursorHeight: widget.model.cursorHeight?.parse, + cursorWidth: widget.model.cursorWidth ?? 2.0, + cursorHeight: widget.model.cursorHeight, cursorColor: widget.model.cursorColor?.toColor(context), style: widget.model.style?.parse(context), - decoration: widget.model.decoration.parse(context), - inputFormatters: widget.model.inputFormatters - .map((StacInputFormatter formatter) => - formatter.type.format(formatter.rule ?? "")) - .toList(), + decoration: widget.model.decoration?.parse(context), + inputFormatters: + widget.model.inputFormatters?.map((f) => f.parse()).toList(), validator: (value) { return _validate( value, @@ -107,8 +108,8 @@ class _TextFormFieldWidgetState extends State<_TextFormFieldWidget> { } String? _validate(String? value, StacTextFormField model) { - if (value != null && widget.model.validatorRules.isNotEmpty) { - for (StacFormFieldValidator validator in widget.model.validatorRules) { + if (value != null && (widget.model.validatorRules?.isNotEmpty ?? false)) { + for (final validator in widget.model.validatorRules!) { try { final validationType = InputValidationType.values.firstWhere( (e) => e.name == validator.rule, diff --git a/packages/stac_models/lib/painting/stac_system_ui_overlay_style/stac_system_ui_overlay_style.dart b/packages/stac_models/lib/painting/stac_system_ui_overlay_style/stac_system_ui_overlay_style.dart index e4a9f395..e20ee039 100644 --- a/packages/stac_models/lib/painting/stac_system_ui_overlay_style/stac_system_ui_overlay_style.dart +++ b/packages/stac_models/lib/painting/stac_system_ui_overlay_style/stac_system_ui_overlay_style.dart @@ -1,5 +1,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:stac_models/core/stac_widget.dart'; +import 'package:stac_models/types/stac_brightness.dart'; part 'stac_system_ui_overlay_style.g.dart'; @@ -31,5 +32,3 @@ class StacSystemUIOverlayStyle extends StacElement { @override Map toJson() => _$StacSystemUIOverlayStyleToJson(this); } - -enum StacBrightness { light, dark, system } diff --git a/packages/stac_models/lib/types/stac_autovalidate_mode.dart b/packages/stac_models/lib/types/stac_autovalidate_mode.dart new file mode 100644 index 00000000..da63505d --- /dev/null +++ b/packages/stac_models/lib/types/stac_autovalidate_mode.dart @@ -0,0 +1,11 @@ +/// Mirrors Flutter's [AutovalidateMode] for form fields. +enum StacAutovalidateMode { + /// Validation is disabled. + disabled, + + /// Validation occurs after every build. + always, + + /// Validation occurs after user interaction. + onUserInteraction, +} diff --git a/packages/stac_models/lib/types/stac_brightness.dart b/packages/stac_models/lib/types/stac_brightness.dart new file mode 100644 index 00000000..514de0b0 --- /dev/null +++ b/packages/stac_models/lib/types/stac_brightness.dart @@ -0,0 +1,11 @@ +/// Mirrors Flutter's [Brightness]. +enum StacBrightness { + /// Light mode. + light, + + /// Dark mode. + dark, + + /// System default (treated as light/dark based on platform theme). + system, +} diff --git a/packages/stac_models/lib/types/stac_form_field_validator/stac_form_field_validator.dart b/packages/stac_models/lib/types/stac_form_field_validator/stac_form_field_validator.dart new file mode 100644 index 00000000..57fc8f2b --- /dev/null +++ b/packages/stac_models/lib/types/stac_form_field_validator/stac_form_field_validator.dart @@ -0,0 +1,27 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_widget.dart'; + +part 'stac_form_field_validator.g.dart'; + +/// A Stac model representing a declarative form field validator. +/// +/// The `rule` is a string understood by the parser; `message` is shown +/// when the validation fails. +@JsonSerializable() +class StacFormFieldValidator extends StacElement { + const StacFormFieldValidator({required this.rule, this.message}); + + /// Identifier of the validation logic to apply. + final String rule; + + /// Error message to display when validation fails. + final String? message; + + /// Creates a [StacFormFieldValidator] from a JSON map. + factory StacFormFieldValidator.fromJson(Map json) => + _$StacFormFieldValidatorFromJson(json); + + /// Converts this [StacFormFieldValidator] to a JSON map. + @override + Map toJson() => _$StacFormFieldValidatorToJson(this); +} diff --git a/packages/stac_models/lib/types/stac_form_field_validator/stac_form_field_validator.g.dart b/packages/stac_models/lib/types/stac_form_field_validator/stac_form_field_validator.g.dart new file mode 100644 index 00000000..95f976ed --- /dev/null +++ b/packages/stac_models/lib/types/stac_form_field_validator/stac_form_field_validator.g.dart @@ -0,0 +1,18 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_form_field_validator.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacFormFieldValidator _$StacFormFieldValidatorFromJson( + Map json, +) => StacFormFieldValidator( + rule: json['rule'] as String, + message: json['message'] as String?, +); + +Map _$StacFormFieldValidatorToJson( + StacFormFieldValidator instance, +) => {'rule': instance.rule, 'message': instance.message}; diff --git a/packages/stac_models/lib/types/stac_input_formatter/stac_input_formatter.dart b/packages/stac_models/lib/types/stac_input_formatter/stac_input_formatter.dart new file mode 100644 index 00000000..0998c24f --- /dev/null +++ b/packages/stac_models/lib/types/stac_input_formatter/stac_input_formatter.dart @@ -0,0 +1,36 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/core/stac_widget.dart'; + +part 'stac_input_formatter.g.dart'; + +/// A Stac model representing a text input formatter rule. +/// +/// Used by inputs like `TextFormField` to restrict or allow characters +/// as the user types. +@JsonSerializable() +class StacInputFormatter extends StacElement { + const StacInputFormatter({required this.type, this.rule}); + + /// Formatter behavior: allow or deny based on a regular expression rule. + final StacInputFormatterType type; + + /// Regular expression string used by the formatter. + final String? rule; + + /// Creates a [StacInputFormatter] from a JSON map. + factory StacInputFormatter.fromJson(Map json) => + _$StacInputFormatterFromJson(json); + + /// Converts this [StacInputFormatter] to a JSON map. + @override + Map toJson() => _$StacInputFormatterToJson(this); +} + +/// Mirrors the behavior of `InputFormatterType` used by platform formatters. +enum StacInputFormatterType { + /// Allow characters that match the provided regex [rule]. + allow, + + /// Deny characters that match the provided regex [rule]. + deny, +} diff --git a/packages/stac_models/lib/types/stac_input_formatter/stac_input_formatter.g.dart b/packages/stac_models/lib/types/stac_input_formatter/stac_input_formatter.g.dart new file mode 100644 index 00000000..b0460a02 --- /dev/null +++ b/packages/stac_models/lib/types/stac_input_formatter/stac_input_formatter.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_input_formatter.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacInputFormatter _$StacInputFormatterFromJson(Map json) => + StacInputFormatter( + type: $enumDecode(_$StacInputFormatterTypeEnumMap, json['type']), + rule: json['rule'] as String?, + ); + +Map _$StacInputFormatterToJson(StacInputFormatter instance) => + { + 'type': _$StacInputFormatterTypeEnumMap[instance.type]!, + 'rule': instance.rule, + }; + +const _$StacInputFormatterTypeEnumMap = { + StacInputFormatterType.allow: 'allow', + StacInputFormatterType.deny: 'deny', +}; diff --git a/packages/stac_models/lib/types/stac_max_length_enforcement.dart b/packages/stac_models/lib/types/stac_max_length_enforcement.dart new file mode 100644 index 00000000..8a011482 --- /dev/null +++ b/packages/stac_models/lib/types/stac_max_length_enforcement.dart @@ -0,0 +1,8 @@ +/// Mirrors Flutter's [MaxLengthEnforcement] for text input. +enum StacMaxLengthEnforcement { + /// Characters past the limit are still allowed, but the error is shown. + none, + + /// Enforces the character limit at the platform level. + enforced, +} diff --git a/packages/stac_models/lib/types/stac_smart_dashes_type.dart b/packages/stac_models/lib/types/stac_smart_dashes_type.dart new file mode 100644 index 00000000..5a49ab92 --- /dev/null +++ b/packages/stac_models/lib/types/stac_smart_dashes_type.dart @@ -0,0 +1,8 @@ +/// Mirrors Flutter's [SmartDashesType] for text input. +enum StacSmartDashesType { + /// Smart dashes are disabled. + disabled, + + /// Smart dashes are enabled when appropriate. + enabled, +} diff --git a/packages/stac_models/lib/types/stac_smart_quotes_type.dart b/packages/stac_models/lib/types/stac_smart_quotes_type.dart new file mode 100644 index 00000000..fc3385de --- /dev/null +++ b/packages/stac_models/lib/types/stac_smart_quotes_type.dart @@ -0,0 +1,8 @@ +/// Mirrors Flutter's [SmartQuotesType] for text input. +enum StacSmartQuotesType { + /// Smart quotes are disabled. + disabled, + + /// Smart quotes are enabled when appropriate. + enabled, +} diff --git a/packages/stac_models/lib/types/types.dart b/packages/stac_models/lib/types/types.dart index 36c09c4d..8de9cc97 100644 --- a/packages/stac_models/lib/types/types.dart +++ b/packages/stac_models/lib/types/types.dart @@ -19,3 +19,11 @@ export 'stac_shadow/stac_shadow.dart'; export 'stac_size/stac_size.dart'; export 'stac_text_input_types.dart'; export 'stac_visual_density/stac_visual_density.dart'; +export 'stac_text_types.dart'; +export 'stac_smart_dashes_type.dart'; +export 'stac_smart_quotes_type.dart'; +export 'stac_max_length_enforcement.dart'; +export 'stac_brightness.dart'; +export 'stac_autovalidate_mode.dart'; +export 'stac_input_formatter/stac_input_formatter.dart'; +export 'stac_form_field_validator/stac_form_field_validator.dart'; diff --git a/packages/stac_models/lib/widgets/text_field/stac_text_field.g.dart b/packages/stac_models/lib/widgets/text_field/stac_text_field.g.dart index c648129b..a15923fc 100644 --- a/packages/stac_models/lib/widgets/text_field/stac_text_field.g.dart +++ b/packages/stac_models/lib/widgets/text_field/stac_text_field.g.dart @@ -136,6 +136,9 @@ const _$StacTextInputTypeEnumMap = { StacTextInputType.emailAddress: 'emailAddress', StacTextInputType.url: 'url', StacTextInputType.visiblePassword: 'visiblePassword', + StacTextInputType.name: 'name', + StacTextInputType.streetAddress: 'streetAddress', + StacTextInputType.none: 'none', }; const _$StacTextInputActionEnumMap = { diff --git a/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.dart b/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.dart new file mode 100644 index 00000000..1961c2d1 --- /dev/null +++ b/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.dart @@ -0,0 +1,203 @@ +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/painting.dart'; +import 'package:stac_models/types/stac_autovalidate_mode.dart'; +import 'package:stac_models/types/stac_brightness.dart'; +import 'package:stac_models/types/stac_form_field_validator/stac_form_field_validator.dart'; +import 'package:stac_models/types/stac_input_formatter/stac_input_formatter.dart'; +import 'package:stac_models/types/stac_max_length_enforcement.dart'; +import 'package:stac_models/types/stac_smart_dashes_type.dart'; +import 'package:stac_models/types/stac_smart_quotes_type.dart'; +import 'package:stac_models/types/stac_text_input_types.dart'; +import 'package:stac_models/types/stac_text_types.dart'; + +part 'stac_text_form_field.g.dart'; + +/// A Stac model representing Flutter's [TextFormField] widget. +/// +/// A convenience widget that wraps a [TextField] and integrates with form +/// validation and saving. Supports initial text, keyboard configuration, +/// cursor styling, decoration and more. Includes an optional `id` used by +/// higher-level form logic to store current field value. +/// +/// {@tool snippet} +/// Dart Example: +/// ```dart +/// StacTextFormField( +/// id: 'email', +/// decoration: StacInputDecoration(labelText: 'Email'), +/// keyboardType: StacTextInputType.emailAddress, +/// autovalidateMode: StacAutovalidateMode.onUserInteraction, +/// ) +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// JSON Example: +/// ```json +/// { +/// "type": "textFormField", +/// "id": "email", +/// "decoration": {"labelText": "Email"}, +/// "keyboardType": "emailAddress", +/// "autovalidateMode": "onUserInteraction" +/// } +/// ``` +/// {@end-tool} +/// +/// See also: +/// * Flutter's [TextFormField documentation](https://api.flutter.dev/flutter/material/TextFormField-class.html) +@JsonSerializable(explicitToJson: true) +class StacTextFormField extends StacWidget { + const StacTextFormField({ + this.id, + this.decoration, + this.initialValue, + this.keyboardType, + this.textInputAction, + this.textCapitalization, + this.style, + this.textAlign, + this.textDirection, + this.readOnly, + this.showCursor, + this.autofocus, + this.obscuringCharacter, + this.maxLines, + this.minLines, + this.maxLength, + this.obscureText, + this.autocorrect, + this.smartDashesType, + this.smartQuotesType, + this.maxLengthEnforcement, + this.expands, + this.keyboardAppearance, + this.scrollPadding, + this.restorationId, + this.enableIMEPersonalizedLearning, + this.enableSuggestions, + this.enabled, + this.cursorWidth, + this.cursorHeight, + this.cursorColor, + this.autovalidateMode, + this.inputFormatters, + this.validatorRules, + }); + + /// Identifier used by the form scope to store/read this field's value. + final String? id; + + /// Visual decoration and labeling for the text field. + final StacInputDecoration? decoration; + + /// Initial text to display in the field. + final String? initialValue; + + /// Keyboard configuration. + final StacTextInputType? keyboardType; + + /// IME action button configuration. + final StacTextInputAction? textInputAction; + + /// Auto-capitalization behavior. + final StacTextCapitalization? textCapitalization; + + /// Text style for the input text. + final StacTextStyle? style; + + /// Horizontal text alignment. + final StacTextAlign? textAlign; + + /// Text direction. + final StacTextDirection? textDirection; + + /// Whether the field is read-only. + final bool? readOnly; + + /// Whether to show the cursor. + final bool? showCursor; + + /// Whether to focus automatically. + final bool? autofocus; + + /// Character used when [obscureText] is true. + final String? obscuringCharacter; + + /// Maximum and minimum lines. + final int? maxLines; + final int? minLines; + + /// Maximum number of characters allowed. + final int? maxLength; + + /// Obscure text (e.g., for passwords). + final bool? obscureText; + + /// Whether to enable autocorrect. + final bool? autocorrect; + + /// Smart dashes behavior. + final StacSmartDashesType? smartDashesType; + + /// Smart quotes behavior. + final StacSmartQuotesType? smartQuotesType; + + /// Max length enforcement strategy. + final StacMaxLengthEnforcement? maxLengthEnforcement; + + /// Expand to fill parent vertically. + final bool? expands; + + /// Keyboard brightness. + final StacBrightness? keyboardAppearance; + + /// Scroll padding when ensuring visibility. + final StacEdgeInsets? scrollPadding; + + /// Restoration ID. + final String? restorationId; + + /// Whether to enable personalized learning. + final bool? enableIMEPersonalizedLearning; + + /// Whether to enable input suggestions. + final bool? enableSuggestions; + + /// Whether the field is interactive. + final bool? enabled; + + /// Width of the text cursor in logical pixels. + @DoubleConverter() + final double? cursorWidth; + + /// Height of the text cursor in logical pixels. + @DoubleConverter() + final double? cursorHeight; + + /// Color of the text cursor. + final StacColor? cursorColor; + + /// Autovalidation behavior. + final StacAutovalidateMode? autovalidateMode; + + /// Input text formatting rules applied as the user types. + final List? inputFormatters; + + /// Declarative validation rules for the form field. + final List? validatorRules; + + /// Widget type identifier. + @override + String get type => 'textFormField'; + + /// Creates a [StacTextFormField] from a JSON map. + factory StacTextFormField.fromJson(Map json) => + _$StacTextFormFieldFromJson(json); + + /// Converts this [StacTextFormField] instance to a JSON map. + @override + Map toJson() => _$StacTextFormFieldToJson(this); +} diff --git a/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.g.dart b/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.g.dart new file mode 100644 index 00000000..be17b70d --- /dev/null +++ b/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.g.dart @@ -0,0 +1,205 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_text_form_field.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacTextFormField _$StacTextFormFieldFromJson( + Map json, +) => StacTextFormField( + id: json['id'] as String?, + decoration: json['decoration'] == null + ? null + : StacInputDecoration.fromJson( + json['decoration'] as Map, + ), + initialValue: json['initialValue'] as String?, + keyboardType: $enumDecodeNullable( + _$StacTextInputTypeEnumMap, + json['keyboardType'], + ), + textInputAction: $enumDecodeNullable( + _$StacTextInputActionEnumMap, + json['textInputAction'], + ), + textCapitalization: $enumDecodeNullable( + _$StacTextCapitalizationEnumMap, + json['textCapitalization'], + ), + style: json['style'] == null + ? null + : StacTextStyle.fromJson(json['style'] as Map), + textAlign: $enumDecodeNullable(_$StacTextAlignEnumMap, json['textAlign']), + textDirection: $enumDecodeNullable( + _$StacTextDirectionEnumMap, + json['textDirection'], + ), + readOnly: json['readOnly'] as bool?, + showCursor: json['showCursor'] as bool?, + autofocus: json['autofocus'] as bool?, + obscuringCharacter: json['obscuringCharacter'] as String?, + maxLines: (json['maxLines'] as num?)?.toInt(), + minLines: (json['minLines'] as num?)?.toInt(), + maxLength: (json['maxLength'] as num?)?.toInt(), + obscureText: json['obscureText'] as bool?, + autocorrect: json['autocorrect'] as bool?, + smartDashesType: $enumDecodeNullable( + _$StacSmartDashesTypeEnumMap, + json['smartDashesType'], + ), + smartQuotesType: $enumDecodeNullable( + _$StacSmartQuotesTypeEnumMap, + json['smartQuotesType'], + ), + maxLengthEnforcement: $enumDecodeNullable( + _$StacMaxLengthEnforcementEnumMap, + json['maxLengthEnforcement'], + ), + expands: json['expands'] as bool?, + keyboardAppearance: $enumDecodeNullable( + _$StacBrightnessEnumMap, + json['keyboardAppearance'], + ), + scrollPadding: json['scrollPadding'] == null + ? null + : StacEdgeInsets.fromJson(json['scrollPadding']), + restorationId: json['restorationId'] as String?, + enableIMEPersonalizedLearning: json['enableIMEPersonalizedLearning'] as bool?, + enableSuggestions: json['enableSuggestions'] as bool?, + enabled: json['enabled'] as bool?, + cursorWidth: const DoubleConverter().fromJson(json['cursorWidth']), + cursorHeight: const DoubleConverter().fromJson(json['cursorHeight']), + cursorColor: json['cursorColor'] as String?, + autovalidateMode: $enumDecodeNullable( + _$StacAutovalidateModeEnumMap, + json['autovalidateMode'], + ), + inputFormatters: (json['inputFormatters'] as List?) + ?.map((e) => StacInputFormatter.fromJson(e as Map)) + .toList(), + validatorRules: (json['validatorRules'] as List?) + ?.map((e) => StacFormFieldValidator.fromJson(e as Map)) + .toList(), +); + +Map _$StacTextFormFieldToJson( + StacTextFormField instance, +) => { + 'id': instance.id, + 'decoration': instance.decoration?.toJson(), + 'initialValue': instance.initialValue, + 'keyboardType': _$StacTextInputTypeEnumMap[instance.keyboardType], + 'textInputAction': _$StacTextInputActionEnumMap[instance.textInputAction], + 'textCapitalization': + _$StacTextCapitalizationEnumMap[instance.textCapitalization], + 'style': instance.style?.toJson(), + 'textAlign': _$StacTextAlignEnumMap[instance.textAlign], + 'textDirection': _$StacTextDirectionEnumMap[instance.textDirection], + 'readOnly': instance.readOnly, + 'showCursor': instance.showCursor, + 'autofocus': instance.autofocus, + 'obscuringCharacter': instance.obscuringCharacter, + 'maxLines': instance.maxLines, + 'minLines': instance.minLines, + 'maxLength': instance.maxLength, + 'obscureText': instance.obscureText, + 'autocorrect': instance.autocorrect, + 'smartDashesType': _$StacSmartDashesTypeEnumMap[instance.smartDashesType], + 'smartQuotesType': _$StacSmartQuotesTypeEnumMap[instance.smartQuotesType], + 'maxLengthEnforcement': + _$StacMaxLengthEnforcementEnumMap[instance.maxLengthEnforcement], + 'expands': instance.expands, + 'keyboardAppearance': _$StacBrightnessEnumMap[instance.keyboardAppearance], + 'scrollPadding': instance.scrollPadding?.toJson(), + 'restorationId': instance.restorationId, + 'enableIMEPersonalizedLearning': instance.enableIMEPersonalizedLearning, + 'enableSuggestions': instance.enableSuggestions, + 'enabled': instance.enabled, + 'cursorWidth': const DoubleConverter().toJson(instance.cursorWidth), + 'cursorHeight': const DoubleConverter().toJson(instance.cursorHeight), + 'cursorColor': instance.cursorColor, + 'autovalidateMode': _$StacAutovalidateModeEnumMap[instance.autovalidateMode], + 'inputFormatters': instance.inputFormatters?.map((e) => e.toJson()).toList(), + 'validatorRules': instance.validatorRules?.map((e) => e.toJson()).toList(), + 'type': instance.type, +}; + +const _$StacTextInputTypeEnumMap = { + StacTextInputType.text: 'text', + StacTextInputType.multiline: 'multiline', + StacTextInputType.number: 'number', + StacTextInputType.phone: 'phone', + StacTextInputType.datetime: 'datetime', + StacTextInputType.emailAddress: 'emailAddress', + StacTextInputType.url: 'url', + StacTextInputType.visiblePassword: 'visiblePassword', + StacTextInputType.name: 'name', + StacTextInputType.streetAddress: 'streetAddress', + StacTextInputType.none: 'none', +}; + +const _$StacTextInputActionEnumMap = { + StacTextInputAction.none: 'none', + StacTextInputAction.unspecified: 'unspecified', + StacTextInputAction.done: 'done', + StacTextInputAction.go: 'go', + StacTextInputAction.search: 'search', + StacTextInputAction.send: 'send', + StacTextInputAction.next: 'next', + StacTextInputAction.previous: 'previous', + StacTextInputAction.continueAction: 'continueAction', + StacTextInputAction.join: 'join', + StacTextInputAction.route: 'route', + StacTextInputAction.emergencyCall: 'emergencyCall', + StacTextInputAction.newline: 'newline', +}; + +const _$StacTextCapitalizationEnumMap = { + StacTextCapitalization.none: 'none', + StacTextCapitalization.characters: 'characters', + StacTextCapitalization.words: 'words', + StacTextCapitalization.sentences: 'sentences', +}; + +const _$StacTextAlignEnumMap = { + StacTextAlign.left: 'left', + StacTextAlign.right: 'right', + StacTextAlign.center: 'center', + StacTextAlign.justify: 'justify', + StacTextAlign.start: 'start', + StacTextAlign.end: 'end', +}; + +const _$StacTextDirectionEnumMap = { + StacTextDirection.rtl: 'rtl', + StacTextDirection.ltr: 'ltr', +}; + +const _$StacSmartDashesTypeEnumMap = { + StacSmartDashesType.disabled: 'disabled', + StacSmartDashesType.enabled: 'enabled', +}; + +const _$StacSmartQuotesTypeEnumMap = { + StacSmartQuotesType.disabled: 'disabled', + StacSmartQuotesType.enabled: 'enabled', +}; + +const _$StacMaxLengthEnforcementEnumMap = { + StacMaxLengthEnforcement.none: 'none', + StacMaxLengthEnforcement.enforced: 'enforced', +}; + +const _$StacBrightnessEnumMap = { + StacBrightness.light: 'light', + StacBrightness.dark: 'dark', + StacBrightness.system: 'system', +}; + +const _$StacAutovalidateModeEnumMap = { + StacAutovalidateMode.disabled: 'disabled', + StacAutovalidateMode.always: 'always', + StacAutovalidateMode.onUserInteraction: 'onUserInteraction', +}; diff --git a/packages/stac_models/lib/widgets/widgets.dart b/packages/stac_models/lib/widgets/widgets.dart index 1391b4e1..566dea19 100644 --- a/packages/stac_models/lib/widgets/widgets.dart +++ b/packages/stac_models/lib/widgets/widgets.dart @@ -35,6 +35,7 @@ export 'stack/stac_stack.dart'; export 'text/stac_text.dart'; export 'text_button/stac_text_button.dart'; export 'text_field/stac_text_field.dart'; +export 'text_form_field/stac_text_form_field.dart'; export 'vertical_divider/stac_vertical_divider.dart'; export 'visibility/stac_visibility.dart'; export 'wrap/stac_wrap.dart'; From d480669de1387fe355baaebc5644504dc1d34537 Mon Sep 17 00:00:00 2001 From: Mithul Nayagam Date: Tue, 12 Aug 2025 18:25:22 +0530 Subject: [PATCH 4/8] Added StacForm to DSL --- .../parsers/widgets/stac_form/stac_form.dart | 18 -- .../widgets/stac_form/stac_form.freezed.dart | 181 ------------------ .../widgets/stac_form/stac_form.g.dart | 25 --- .../widgets/stac_form/stac_form_parser.dart | 9 +- .../stac/lib/src/parsers/widgets/widgets.dart | 4 +- .../lib/widgets/form/stac_form.dart | 66 +++++++ .../lib/widgets/form/stac_form.g.dart | 29 +++ packages/stac_models/lib/widgets/widgets.dart | 1 + 8 files changed, 103 insertions(+), 230 deletions(-) delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_form/stac_form.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_form/stac_form.freezed.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_form/stac_form.g.dart create mode 100644 packages/stac_models/lib/widgets/form/stac_form.dart create mode 100644 packages/stac_models/lib/widgets/form/stac_form.g.dart diff --git a/packages/stac/lib/src/parsers/widgets/stac_form/stac_form.dart b/packages/stac/lib/src/parsers/widgets/stac_form/stac_form.dart deleted file mode 100644 index 3b1f2713..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_form/stac_form.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -export 'stac_form_parser.dart'; - -part 'stac_form.freezed.dart'; -part 'stac_form.g.dart'; - -@freezed -abstract class StacForm with _$StacForm { - const factory StacForm({ - AutovalidateMode? autovalidateMode, - required Map child, - }) = _StacForm; - - factory StacForm.fromJson(Map json) => - _$StacFormFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_form/stac_form.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_form/stac_form.freezed.dart deleted file mode 100644 index cfcd0ed5..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_form/stac_form.freezed.dart +++ /dev/null @@ -1,181 +0,0 @@ -// dart format width=80 -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'stac_form.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacForm { - AutovalidateMode? get autovalidateMode; - Map get child; - - /// Create a copy of StacForm - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacFormCopyWith get copyWith => - _$StacFormCopyWithImpl(this as StacForm, _$identity); - - /// Serializes this StacForm to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacForm && - (identical(other.autovalidateMode, autovalidateMode) || - other.autovalidateMode == autovalidateMode) && - const DeepCollectionEquality().equals(other.child, child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, autovalidateMode, - const DeepCollectionEquality().hash(child)); - - @override - String toString() { - return 'StacForm(autovalidateMode: $autovalidateMode, child: $child)'; - } -} - -/// @nodoc -abstract mixin class $StacFormCopyWith<$Res> { - factory $StacFormCopyWith(StacForm value, $Res Function(StacForm) _then) = - _$StacFormCopyWithImpl; - @useResult - $Res call({AutovalidateMode? autovalidateMode, Map child}); -} - -/// @nodoc -class _$StacFormCopyWithImpl<$Res> implements $StacFormCopyWith<$Res> { - _$StacFormCopyWithImpl(this._self, this._then); - - final StacForm _self; - final $Res Function(StacForm) _then; - - /// Create a copy of StacForm - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? autovalidateMode = freezed, - Object? child = null, - }) { - return _then(_self.copyWith( - autovalidateMode: freezed == autovalidateMode - ? _self.autovalidateMode - : autovalidateMode // ignore: cast_nullable_to_non_nullable - as AutovalidateMode?, - child: null == child - ? _self.child - : child // ignore: cast_nullable_to_non_nullable - as Map, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacForm implements StacForm { - const _StacForm( - {this.autovalidateMode, required final Map child}) - : _child = child; - factory _StacForm.fromJson(Map json) => - _$StacFormFromJson(json); - - @override - final AutovalidateMode? autovalidateMode; - final Map _child; - @override - Map get child { - if (_child is EqualUnmodifiableMapView) return _child; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_child); - } - - /// Create a copy of StacForm - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacFormCopyWith<_StacForm> get copyWith => - __$StacFormCopyWithImpl<_StacForm>(this, _$identity); - - @override - Map toJson() { - return _$StacFormToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacForm && - (identical(other.autovalidateMode, autovalidateMode) || - other.autovalidateMode == autovalidateMode) && - const DeepCollectionEquality().equals(other._child, _child)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, autovalidateMode, - const DeepCollectionEquality().hash(_child)); - - @override - String toString() { - return 'StacForm(autovalidateMode: $autovalidateMode, child: $child)'; - } -} - -/// @nodoc -abstract mixin class _$StacFormCopyWith<$Res> - implements $StacFormCopyWith<$Res> { - factory _$StacFormCopyWith(_StacForm value, $Res Function(_StacForm) _then) = - __$StacFormCopyWithImpl; - @override - @useResult - $Res call({AutovalidateMode? autovalidateMode, Map child}); -} - -/// @nodoc -class __$StacFormCopyWithImpl<$Res> implements _$StacFormCopyWith<$Res> { - __$StacFormCopyWithImpl(this._self, this._then); - - final _StacForm _self; - final $Res Function(_StacForm) _then; - - /// Create a copy of StacForm - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? autovalidateMode = freezed, - Object? child = null, - }) { - return _then(_StacForm( - autovalidateMode: freezed == autovalidateMode - ? _self.autovalidateMode - : autovalidateMode // ignore: cast_nullable_to_non_nullable - as AutovalidateMode?, - child: null == 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_form/stac_form.g.dart b/packages/stac/lib/src/parsers/widgets/stac_form/stac_form.g.dart deleted file mode 100644 index ca7c8baa..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_form/stac_form.g.dart +++ /dev/null @@ -1,25 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_form.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacForm _$StacFormFromJson(Map json) => _StacForm( - autovalidateMode: $enumDecodeNullable( - _$AutovalidateModeEnumMap, json['autovalidateMode']), - child: json['child'] as Map, - ); - -Map _$StacFormToJson(_StacForm instance) => { - 'autovalidateMode': _$AutovalidateModeEnumMap[instance.autovalidateMode], - 'child': instance.child, - }; - -const _$AutovalidateModeEnumMap = { - AutovalidateMode.disabled: 'disabled', - AutovalidateMode.always: 'always', - AutovalidateMode.onUserInteraction: 'onUserInteraction', - AutovalidateMode.onUnfocus: 'onUnfocus', -}; diff --git a/packages/stac/lib/src/parsers/widgets/stac_form/stac_form_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_form/stac_form_parser.dart index cfec091a..8e3bca4a 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_form/stac_form_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_form/stac_form_parser.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:stac/src/framework/framework.dart'; -import 'package:stac/src/parsers/widgets/stac_form/stac_form.dart'; +import 'package:stac_models/widgets/form/stac_form.dart'; import 'package:stac/src/parsers/widgets/stac_form/stac_form_scope.dart'; +import 'package:stac/src/parsers/core/stac_widget_parser.dart'; +import 'package:stac/src/parsers/types/type_parser.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -47,8 +48,8 @@ class _FormWidgetState extends State<_FormWidget> { builder: (context) { return Form( key: StacFormScope.of(context)?.formKey, - child: - Stac.fromJson(widget.model.child, context) ?? const SizedBox(), + autovalidateMode: widget.model.autovalidateMode?.parse, + child: widget.model.child?.parse(context) ?? const SizedBox(), ); }, ), diff --git a/packages/stac/lib/src/parsers/widgets/widgets.dart b/packages/stac/lib/src/parsers/widgets/widgets.dart index 99c202f9..4b599fcd 100644 --- a/packages/stac/lib/src/parsers/widgets/widgets.dart +++ b/packages/stac/lib/src/parsers/widgets/widgets.dart @@ -40,7 +40,7 @@ export 'package:stac/src/parsers/widgets/stac_fitted_box/stac_fitted_box_parser. export 'package:stac/src/parsers/widgets/stac_flexible/stac_flexible_parser.dart'; export 'package:stac/src/parsers/widgets/stac_floating_action_button/stac_floating_action_button_parser.dart'; export 'package:stac/src/parsers/widgets/stac_font_weight/stac_font_weight.dart'; -export 'package:stac/src/parsers/widgets/stac_form/stac_form.dart'; +export 'package:stac/src/parsers/widgets/stac_form/stac_form_parser.dart'; export 'package:stac/src/parsers/widgets/stac_form/stac_form_scope.dart'; export 'package:stac/src/parsers/widgets/stac_form_field_validator/stac_form_validator.dart'; export 'package:stac/src/parsers/widgets/stac_fractionally_sized_box/stac_fractionally_sized_box_parser.dart'; @@ -84,7 +84,7 @@ export 'package:stac/src/parsers/widgets/stac_table/stac_table.dart'; export 'package:stac/src/parsers/widgets/stac_table_cell/stac_table_cell.dart'; export 'package:stac/src/parsers/widgets/stac_text_button/stac_text_button_parser.dart'; export 'package:stac/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart'; -export 'package:stac/src/parsers/widgets/stac_text_form_field/stac_text_form_field.dart'; +export 'package:stac/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart'; export 'package:stac/src/parsers/widgets/stac_text_style/stac_text_style.dart'; export 'package:stac/src/parsers/widgets/stac_vertical_divider/stac_vertical_divider_parser.dart'; export 'package:stac/src/parsers/widgets/stac_visibility/stac_visibility_parser.dart'; diff --git a/packages/stac_models/lib/widgets/form/stac_form.dart b/packages/stac_models/lib/widgets/form/stac_form.dart new file mode 100644 index 00000000..23428ef1 --- /dev/null +++ b/packages/stac_models/lib/widgets/form/stac_form.dart @@ -0,0 +1,66 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/stac_models.dart'; + +part 'stac_form.g.dart'; + +/// A Stac model representing a form scope used to coordinate input fields and actions. +/// +/// This widget establishes a [StacFormScope] at runtime so input widgets can +/// register and retrieve values (e.g., via the `getFormValue` action), and so +/// actions like validation can be performed consistently across fields. +/// +/// {@tool snippet} +/// Dart Example: +/// ```dart +/// StacForm( +/// autovalidateMode: StacAutovalidateMode.onUserInteraction, +/// child: StacColumn(children: [ +/// StacTextFormField(id: 'username'), +/// StacTextFormField(id: 'password'), +/// ]), +/// ) +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// JSON Example: +/// ```json +/// { +/// "type": "form", +/// "autovalidateMode": "always", +/// "child": { +/// "type": "column", +/// "children": [ +/// { "type": "textFormField", "id": "username" }, +/// { "type": "textFormField", "id": "password" } +/// ] +/// } +/// } +/// ``` +/// {@end-tool} +/// +/// See also: +/// * Flutter's [Form documentation](https://api.flutter.dev/flutter/widgets/Form-class.html) +@JsonSerializable() +class StacForm extends StacWidget { + /// Creates a [StacForm]. + const StacForm({this.autovalidateMode, this.child}); + + /// The mode to control auto validation of fields within the form. + final StacAutovalidateMode? autovalidateMode; + + /// The widget subtree to display inside the form scope. + final StacWidget? child; + + /// Widget type identifier. + @override + String get type => 'form'; + + /// Creates a [StacForm] from a JSON map. + factory StacForm.fromJson(Map json) => + _$StacFormFromJson(json); + + /// Converts this [StacForm] instance to a JSON map. + @override + Map toJson() => _$StacFormToJson(this); +} diff --git a/packages/stac_models/lib/widgets/form/stac_form.g.dart b/packages/stac_models/lib/widgets/form/stac_form.g.dart new file mode 100644 index 00000000..fd39ebbc --- /dev/null +++ b/packages/stac_models/lib/widgets/form/stac_form.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_form.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacForm _$StacFormFromJson(Map json) => StacForm( + autovalidateMode: $enumDecodeNullable( + _$StacAutovalidateModeEnumMap, + json['autovalidateMode'], + ), + child: json['child'] == null + ? null + : StacWidget.fromJson(json['child'] as Map), +); + +Map _$StacFormToJson(StacForm instance) => { + 'autovalidateMode': _$StacAutovalidateModeEnumMap[instance.autovalidateMode], + 'child': instance.child?.toJson(), + 'type': instance.type, +}; + +const _$StacAutovalidateModeEnumMap = { + StacAutovalidateMode.disabled: 'disabled', + StacAutovalidateMode.always: 'always', + StacAutovalidateMode.onUserInteraction: 'onUserInteraction', +}; diff --git a/packages/stac_models/lib/widgets/widgets.dart b/packages/stac_models/lib/widgets/widgets.dart index 566dea19..b1956f53 100644 --- a/packages/stac_models/lib/widgets/widgets.dart +++ b/packages/stac_models/lib/widgets/widgets.dart @@ -13,6 +13,7 @@ export 'filled_button/stac_filled_button.dart'; export 'fitted_box/stac_fitted_box.dart'; export 'flexible/stac_flexible.dart'; export 'floating_action_button/stac_floating_action_button.dart'; +export 'form/stac_form.dart'; export 'fractionally_sized_box/stac_fractionally_sized_box.dart'; export 'icon/stac_icon.dart'; export 'icon/stac_icons.dart'; From 2db23bfe3fec37d908b59ea9b83a0a7bcd903a7b Mon Sep 17 00:00:00 2001 From: Mithul Nayagam Date: Tue, 12 Aug 2025 18:25:49 +0530 Subject: [PATCH 5/8] Added StacNetworkWidget to DSL --- .../stac_network_widget.dart | 17 -- .../stac_network_widget.freezed.dart | 160 ------------------ .../stac_network_widget.g.dart | 18 -- .../stac_network_widget_parser.dart | 2 +- .../stac/lib/src/parsers/widgets/widgets.dart | 2 +- .../network_widget/stac_network_widget.dart | 56 ++++++ .../network_widget/stac_network_widget.g.dart | 20 +++ packages/stac_models/lib/widgets/widgets.dart | 1 + 8 files changed, 79 insertions(+), 197 deletions(-) delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.freezed.dart delete mode 100644 packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.g.dart create mode 100644 packages/stac_models/lib/widgets/network_widget/stac_network_widget.dart create mode 100644 packages/stac_models/lib/widgets/network_widget/stac_network_widget.g.dart diff --git a/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.dart b/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.dart deleted file mode 100644 index e5a5d596..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:stac_models/actions/network_request/stac_network_request.dart'; - -export 'stac_network_widget_parser.dart'; - -part 'stac_network_widget.freezed.dart'; -part 'stac_network_widget.g.dart'; - -@freezed -abstract class StacNetworkWidget with _$StacNetworkWidget { - const factory StacNetworkWidget({ - required StacNetworkRequest request, - }) = _StacNetworkWidget; - - factory StacNetworkWidget.fromJson(Map json) => - _$StacNetworkWidgetFromJson(json); -} diff --git a/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.freezed.dart b/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.freezed.dart deleted file mode 100644 index 5ebac071..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.freezed.dart +++ /dev/null @@ -1,160 +0,0 @@ -// dart format width=80 -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'stac_network_widget.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$StacNetworkWidget { - StacNetworkRequest get request; - - /// Create a copy of StacNetworkWidget - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $StacNetworkWidgetCopyWith get copyWith => - _$StacNetworkWidgetCopyWithImpl( - this as StacNetworkWidget, _$identity); - - /// Serializes this StacNetworkWidget to a JSON map. - Map toJson(); - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is StacNetworkWidget && - (identical(other.request, request) || other.request == request)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, request); - - @override - String toString() { - return 'StacNetworkWidget(request: $request)'; - } -} - -/// @nodoc -abstract mixin class $StacNetworkWidgetCopyWith<$Res> { - factory $StacNetworkWidgetCopyWith( - StacNetworkWidget value, $Res Function(StacNetworkWidget) _then) = - _$StacNetworkWidgetCopyWithImpl; - @useResult - $Res call({StacNetworkRequest request}); -} - -/// @nodoc -class _$StacNetworkWidgetCopyWithImpl<$Res> - implements $StacNetworkWidgetCopyWith<$Res> { - _$StacNetworkWidgetCopyWithImpl(this._self, this._then); - - final StacNetworkWidget _self; - final $Res Function(StacNetworkWidget) _then; - - /// Create a copy of StacNetworkWidget - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? request = null, - }) { - return _then(_self.copyWith( - request: null == request - ? _self.request - : request // ignore: cast_nullable_to_non_nullable - as StacNetworkRequest, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _StacNetworkWidget implements StacNetworkWidget { - const _StacNetworkWidget({required this.request}); - factory _StacNetworkWidget.fromJson(Map json) => - _$StacNetworkWidgetFromJson(json); - - @override - final StacNetworkRequest request; - - /// Create a copy of StacNetworkWidget - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$StacNetworkWidgetCopyWith<_StacNetworkWidget> get copyWith => - __$StacNetworkWidgetCopyWithImpl<_StacNetworkWidget>(this, _$identity); - - @override - Map toJson() { - return _$StacNetworkWidgetToJson( - this, - ); - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _StacNetworkWidget && - (identical(other.request, request) || other.request == request)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, request); - - @override - String toString() { - return 'StacNetworkWidget(request: $request)'; - } -} - -/// @nodoc -abstract mixin class _$StacNetworkWidgetCopyWith<$Res> - implements $StacNetworkWidgetCopyWith<$Res> { - factory _$StacNetworkWidgetCopyWith( - _StacNetworkWidget value, $Res Function(_StacNetworkWidget) _then) = - __$StacNetworkWidgetCopyWithImpl; - @override - @useResult - $Res call({StacNetworkRequest request}); -} - -/// @nodoc -class __$StacNetworkWidgetCopyWithImpl<$Res> - implements _$StacNetworkWidgetCopyWith<$Res> { - __$StacNetworkWidgetCopyWithImpl(this._self, this._then); - - final _StacNetworkWidget _self; - final $Res Function(_StacNetworkWidget) _then; - - /// Create a copy of StacNetworkWidget - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? request = null, - }) { - return _then(_StacNetworkWidget( - request: null == request - ? _self.request - : request // ignore: cast_nullable_to_non_nullable - as StacNetworkRequest, - )); - } -} - -// dart format on diff --git a/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.g.dart b/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.g.dart deleted file mode 100644 index 78516c54..00000000 --- a/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget.g.dart +++ /dev/null @@ -1,18 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'stac_network_widget.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_StacNetworkWidget _$StacNetworkWidgetFromJson(Map json) => - _StacNetworkWidget( - request: - StacNetworkRequest.fromJson(json['request'] as Map), - ); - -Map _$StacNetworkWidgetToJson(_StacNetworkWidget instance) => - { - 'request': instance.request, - }; diff --git a/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget_parser.dart index 000c2ee5..14c6e74d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_network_widget/stac_network_widget_parser.dart @@ -1,6 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:stac/src/framework/framework.dart'; -import 'package:stac/src/parsers/widgets/stac_network_widget/stac_network_widget.dart'; +import 'package:stac_models/widgets/network_widget/stac_network_widget.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; diff --git a/packages/stac/lib/src/parsers/widgets/widgets.dart b/packages/stac/lib/src/parsers/widgets/widgets.dart index 4b599fcd..82fba82c 100644 --- a/packages/stac/lib/src/parsers/widgets/widgets.dart +++ b/packages/stac/lib/src/parsers/widgets/widgets.dart @@ -57,7 +57,7 @@ export 'package:stac/src/parsers/widgets/stac_limited_box/stac_limited_box_parse export 'package:stac/src/parsers/widgets/stac_linear_progress_indicator/stac_linear_progress_indicator.dart'; export 'package:stac/src/parsers/widgets/stac_list_tile/stac_list_tile_parser.dart'; export 'package:stac/src/parsers/widgets/stac_list_view/stac_list_view_parser.dart'; -export 'package:stac/src/parsers/widgets/stac_network_widget/stac_network_widget.dart'; +export 'package:stac/src/parsers/widgets/stac_network_widget/stac_network_widget_parser.dart'; 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'; diff --git a/packages/stac_models/lib/widgets/network_widget/stac_network_widget.dart b/packages/stac_models/lib/widgets/network_widget/stac_network_widget.dart new file mode 100644 index 00000000..a81e22bf --- /dev/null +++ b/packages/stac_models/lib/widgets/network_widget/stac_network_widget.dart @@ -0,0 +1,56 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:stac_models/actions/network_request/stac_network_request.dart'; +import 'package:stac_models/core/stac_widget.dart'; + +part 'stac_network_widget.g.dart'; + +/// A Stac model representing a network-driven widget. +/// +/// This widget triggers a [StacNetworkRequest] to fetch a Stac UI JSON from a +/// URL and renders it. +/// +/// {@tool snippet} +/// Dart Example: +/// ```dart +/// StacNetworkWidget( +/// request: StacNetworkRequest( +/// url: 'https://example.com/data', +/// method: 'get', +/// ), +/// ) +/// ``` +/// {@end-tool} +/// +/// {@tool snippet} +/// JSON Example: +/// ```json +/// { +/// "type": "networkWidget", +/// "request": { +/// "actionType": "networkRequest", +/// "url": "https://example.com/data", +/// "method": "get" +/// } +/// } +/// ``` +/// {@end-tool} +@JsonSerializable() +class StacNetworkWidget extends StacWidget { + /// Creates a [StacNetworkWidget]. + const StacNetworkWidget({required this.request}); + + /// The network request to execute. + final StacNetworkRequest request; + + /// Widget type identifier. + @override + String get type => 'networkWidget'; + + /// Creates a [StacNetworkWidget] from a JSON map. + factory StacNetworkWidget.fromJson(Map json) => + _$StacNetworkWidgetFromJson(json); + + /// Converts this [StacNetworkWidget] instance to a JSON map. + @override + Map toJson() => _$StacNetworkWidgetToJson(this); +} diff --git a/packages/stac_models/lib/widgets/network_widget/stac_network_widget.g.dart b/packages/stac_models/lib/widgets/network_widget/stac_network_widget.g.dart new file mode 100644 index 00000000..107ff2d0 --- /dev/null +++ b/packages/stac_models/lib/widgets/network_widget/stac_network_widget.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_network_widget.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StacNetworkWidget _$StacNetworkWidgetFromJson(Map json) => + StacNetworkWidget( + request: StacNetworkRequest.fromJson( + json['request'] as Map, + ), + ); + +Map _$StacNetworkWidgetToJson(StacNetworkWidget instance) => + { + 'request': instance.request.toJson(), + 'type': instance.type, + }; diff --git a/packages/stac_models/lib/widgets/widgets.dart b/packages/stac_models/lib/widgets/widgets.dart index b1956f53..25f3a474 100644 --- a/packages/stac_models/lib/widgets/widgets.dart +++ b/packages/stac_models/lib/widgets/widgets.dart @@ -21,6 +21,7 @@ export 'icon_button/stac_icon_button.dart'; export 'image/stac_image.dart'; export 'ink_well/stac_ink_well.dart'; export 'limited_box/stac_limited_box.dart'; +export 'network_widget/stac_network_widget.dart'; export 'opacity/stac_opacity.dart'; export 'outlined_button/stac_outlined_button.dart'; export 'padding/stac_padding.dart'; From 138858975262d0792b9e85b12095dcc5e46a9633 Mon Sep 17 00:00:00 2001 From: Mithul Nayagam Date: Tue, 12 Aug 2025 18:28:37 +0530 Subject: [PATCH 6/8] formatting and minor fixes --- .../widgets/stac_inkwell/stac_inkwell_parser.dart | 1 - .../stac_text_field/stac_text_field_parser.dart | 13 +++++-------- .../stac_input_decoration.dart | 12 +++++------- .../lib/widgets/ink_well/stac_ink_well.dart | 3 ++- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart index c412ac49..c4541094 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart @@ -33,7 +33,6 @@ class StacInkwellParser extends StacParser { onHighlightChanged: (_) => model.onHighlightChanged?.parse(context), onHover: (_) => model.onHover?.parse(context), onFocusChange: (_) => model.onFocusChange?.parse(context), - mouseCursor: model.mouseCursor?.parse, focusColor: model.focusColor?.toColor(context), hoverColor: model.hoverColor?.toColor(context), diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart index 4d478a24..821aaa4d 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_field/stac_text_field_parser.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/gestures.dart'; import 'package:stac/src/parsers/painting/stac_text_style_parser.dart'; -// Removed unused imports -import 'package:stac_models/widgets/text_field/stac_text_field.dart' as models; +import 'package:stac_models/widgets/text_field/stac_text_field.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac/src/utils/widget_type.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -10,7 +9,7 @@ import 'package:stac/src/parsers/types/type_parser.dart'; import 'package:stac/src/parsers/core/stac_action_parser.dart'; import 'package:stac/src/parsers/painting/stac_edge_insets_parser.dart'; -class StacTextFieldParser extends StacParser { +class StacTextFieldParser extends StacParser { const StacTextFieldParser({ this.controller, this.focusNode, @@ -20,14 +19,14 @@ class StacTextFieldParser extends StacParser { final FocusNode? focusNode; @override - models.StacTextField getModel(Map json) => - models.StacTextField.fromJson(json); + StacTextField getModel(Map json) => + StacTextField.fromJson(json); @override String get type => WidgetType.textField.name; @override - Widget parse(BuildContext context, models.StacTextField model) { + Widget parse(BuildContext context, StacTextField model) { if ((model.initialValue ?? '').isNotEmpty) { controller?.text = model.initialValue!; } @@ -80,5 +79,3 @@ class StacTextFieldParser extends StacParser { ); } } - -// moved to type_parser.dart diff --git a/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.dart b/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.dart index 429c4b21..b2b712e2 100644 --- a/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.dart +++ b/packages/stac_models/lib/painting/stac_input_decoration/stac_input_decoration.dart @@ -63,30 +63,30 @@ class StacInputDecoration extends StacElement { /// Optional label text to display above/beside the input. final String? labelText; - + /// Text style for [labelText]. final StacTextStyle? labelStyle; /// Optional placeholder text. final String? hintText; - + /// Text style for [hintText]. final StacTextStyle? hintStyle; /// Optional helper and error texts. final String? helperText; - + /// Text style for [helperText]. final StacTextStyle? helperStyle; final String? errorText; - + /// Text style for [errorText]. final StacTextStyle? errorStyle; /// Optional prefix/suffix widgets and texts. final StacWidget? prefixIcon; final String? prefixText; - + /// Text style for [prefixText]. final StacTextStyle? prefixStyle; @@ -126,5 +126,3 @@ class StacInputDecoration extends StacElement { @override Map toJson() => _$StacInputDecorationToJson(this); } - - diff --git a/packages/stac_models/lib/widgets/ink_well/stac_ink_well.dart b/packages/stac_models/lib/widgets/ink_well/stac_ink_well.dart index 6119d2bb..bf89f65e 100644 --- a/packages/stac_models/lib/widgets/ink_well/stac_ink_well.dart +++ b/packages/stac_models/lib/widgets/ink_well/stac_ink_well.dart @@ -118,7 +118,8 @@ class StacInkWell extends StacWidget { final StacColor? highlightColor; /// The overlay color of the ink response. - final StacColor? overlayColor; // Note: In Flutter this is MaterialStateProperty. StacColor simplifies this for now. + final StacColor? + overlayColor; // Note: In Flutter this is MaterialStateProperty. StacColor simplifies this for now. /// The splash color of the ink response. final StacColor? splashColor; From 9eafda04db16ff4deaaea3841ec3462332204a66 Mon Sep 17 00:00:00 2001 From: Mithul Nayagam Date: Tue, 12 Aug 2025 18:35:09 +0530 Subject: [PATCH 7/8] formatting and minor fixes --- examples/stac_gallery/bin/stac_cli.dart | 1 - examples/stac_gallery/stac/home_screen.dart | 1 - .../lib/src/parsers/painting/stac_text_style_parser.dart | 1 - packages/stac/lib/src/parsers/types/type_parser.dart | 2 +- .../parsers/widgets/stac_inkwell/stac_inkwell_parser.dart | 2 +- .../stac_text_form_field/stac_text_form_field_parser.dart | 6 ++++-- .../stac_models/lib/widgets/text_field/stac_text_field.dart | 5 ++++- .../lib/widgets/text_form_field/stac_text_form_field.dart | 4 +++- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/stac_gallery/bin/stac_cli.dart b/examples/stac_gallery/bin/stac_cli.dart index bb72d01b..af38a6bd 100644 --- a/examples/stac_gallery/bin/stac_cli.dart +++ b/examples/stac_gallery/bin/stac_cli.dart @@ -1,6 +1,5 @@ import 'package:stac_models/stac_models.dart'; import 'package:stac_models/types/stac_border/stac_border.dart'; -import 'package:stac_models/types/stac_text_types.dart'; final double fontSize = 20; diff --git a/examples/stac_gallery/stac/home_screen.dart b/examples/stac_gallery/stac/home_screen.dart index 0137370a..e8cc111a 100644 --- a/examples/stac_gallery/stac/home_screen.dart +++ b/examples/stac_gallery/stac/home_screen.dart @@ -1,5 +1,4 @@ import 'package:stac_models/stac_models.dart'; -import 'package:stac_models/types/stac_text_types.dart'; StacWidget homeScreen() { return StacScaffold( diff --git a/packages/stac/lib/src/parsers/painting/stac_text_style_parser.dart b/packages/stac/lib/src/parsers/painting/stac_text_style_parser.dart index 89e15ee8..59525338 100644 --- a/packages/stac/lib/src/parsers/painting/stac_text_style_parser.dart +++ b/packages/stac/lib/src/parsers/painting/stac_text_style_parser.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:stac/src/parsers/types/type_parser.dart'; import 'package:stac/src/utils/color_utils.dart'; import 'package:stac_models/stac_models.dart'; -import 'package:stac_models/types/stac_text_types.dart'; extension StacTextStyleParser on StacTextStyle { TextStyle parse(BuildContext context) { diff --git a/packages/stac/lib/src/parsers/types/type_parser.dart b/packages/stac/lib/src/parsers/types/type_parser.dart index 458b451c..e0f5e133 100644 --- a/packages/stac/lib/src/parsers/types/type_parser.dart +++ b/packages/stac/lib/src/parsers/types/type_parser.dart @@ -785,7 +785,7 @@ extension StacMaxLengthEnforcementParser on StacMaxLengthEnforcement { /// Maps [StacInputFormatterType] to core [InputFormatterType]. extension StacInputFormatterTypeCoreParser on StacInputFormatterType { - InputFormatterType get toCore { + InputFormatterType get parse { switch (this) { case StacInputFormatterType.allow: return InputFormatterType.allow; diff --git a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart index c4541094..be9f2bf6 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_inkwell/stac_inkwell_parser.dart @@ -39,7 +39,7 @@ class StacInkwellParser extends StacParser { highlightColor: model.highlightColor?.toColor(context), overlayColor: model.overlayColor == null ? null - : MaterialStateProperty.all(model.overlayColor!.toColor(context)), + : WidgetStateProperty.all(model.overlayColor!.toColor(context)), splashColor: model.splashColor?.toColor(context), radius: model.radius, borderRadius: model.borderRadius?.parse, diff --git a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart index 5a48445d..af41929c 100644 --- a/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart +++ b/packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart @@ -96,8 +96,10 @@ class _TextFormFieldWidgetState extends State<_TextFormFieldWidget> { cursorColor: widget.model.cursorColor?.toColor(context), style: widget.model.style?.parse(context), decoration: widget.model.decoration?.parse(context), - inputFormatters: - widget.model.inputFormatters?.map((f) => f.parse()).toList(), + inputFormatters: widget.model.inputFormatters + ?.map((inputFormatter) => + inputFormatter.type.parse.format(inputFormatter.rule ?? "")) + .toList(), validator: (value) { return _validate( value, diff --git a/packages/stac_models/lib/widgets/text_field/stac_text_field.dart b/packages/stac_models/lib/widgets/text_field/stac_text_field.dart index 6ab65231..0a068ff4 100644 --- a/packages/stac_models/lib/widgets/text_field/stac_text_field.dart +++ b/packages/stac_models/lib/widgets/text_field/stac_text_field.dart @@ -3,7 +3,10 @@ import 'package:stac_models/core/converters/double_converter.dart'; import 'package:stac_models/core/stac_action.dart'; import 'package:stac_models/core/stac_widget.dart'; import 'package:stac_models/painting/painting.dart'; -import 'package:stac_models/types/types.dart'; +import 'package:stac_models/types/stac_drag_start_behavior.dart'; +import 'package:stac_models/types/stac_mouse_cursor.dart'; +import 'package:stac_models/types/stac_scroll_physics.dart'; +import 'package:stac_models/types/stac_text_input_types.dart'; import 'package:stac_models/types/stac_text_types.dart'; import 'package:stac_models/types/stac_clip.dart'; diff --git a/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.dart b/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.dart index 1961c2d1..21b27eb9 100644 --- a/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.dart +++ b/packages/stac_models/lib/widgets/text_form_field/stac_text_form_field.dart @@ -126,8 +126,10 @@ class StacTextFormField extends StacWidget { /// Character used when [obscureText] is true. final String? obscuringCharacter; - /// Maximum and minimum lines. + /// Maximum lines. final int? maxLines; + + /// Minimum lines. final int? minLines; /// Maximum number of characters allowed. From 8706b9ad5473422bbbd18658d8f5e30d60e7f7d2 Mon Sep 17 00:00:00 2001 From: Mithul Nayagam <113115383+Potatomonsta@users.noreply.github.com> Date: Wed, 13 Aug 2025 16:55:40 +0530 Subject: [PATCH 8/8] Update type_parser.dart removed comments --- packages/stac/lib/src/parsers/types/type_parser.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/stac/lib/src/parsers/types/type_parser.dart b/packages/stac/lib/src/parsers/types/type_parser.dart index e0f5e133..be630774 100644 --- a/packages/stac/lib/src/parsers/types/type_parser.dart +++ b/packages/stac/lib/src/parsers/types/type_parser.dart @@ -109,9 +109,6 @@ extension StacInputDecorationParser on StacInputDecoration { } } -// Kept for backward compatibility if nullable usage is needed elsewhere -// Removed nullable backward-compat InputDecoration parser extension - extension StacTextInputTypeParser on StacTextInputType { TextInputType get parse { switch (this) {