From bda521bf6d5c654182064f97d6fac84c4b6d9628 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 20 Feb 2025 15:12:31 +0530 Subject: [PATCH 1/5] feat: Adding SliverAppBar & CustomScrollView --- .../stac_gallery/assets/json/home_screen.json | 34 + .../assets/json/sliver_app_bar_example.json | 54 + packages/stac/lib/src/framework/stac.dart | 4 + packages/stac/lib/src/parsers/parsers.dart | 2 + .../stac_custom_scroll_view.dart | 31 + .../stac_custom_scroll_view.freezed.dart | 473 +++++++ .../stac_custom_scroll_view.g.dart | 96 ++ .../stac_custom_scroll_view_parser.dart | 40 + .../stac_sliver_app_bar.dart | 55 + .../stac_sliver_app_bar.freezed.dart | 1096 +++++++++++++++++ .../stac_sliver_app_bar.g.dart | 117 ++ .../stac_sliver_app_bar_parser.dart | 61 + packages/stac/lib/src/utils/widget_type.dart | 2 + 13 files changed, 2065 insertions(+) create mode 100644 examples/stac_gallery/assets/json/sliver_app_bar_example.json create mode 100644 packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.dart create mode 100644 packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.freezed.dart create mode 100644 packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.g.dart create mode 100644 packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart create mode 100644 packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart create mode 100644 packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.freezed.dart create mode 100644 packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.g.dart create mode 100644 packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart diff --git a/examples/stac_gallery/assets/json/home_screen.json b/examples/stac_gallery/assets/json/home_screen.json index 82e302fd..a6c77f7e 100644 --- a/examples/stac_gallery/assets/json/home_screen.json +++ b/examples/stac_gallery/assets/json/home_screen.json @@ -1523,6 +1523,40 @@ } } }, + { + "type": "listTile", + "leading": { + "type": "icon", + "iconType": "cupertino", + "icon": "app_fill" + }, + "title": { + "type": "text", + "data": "Stac Sliver App Bar", + "align": "center", + "style": { + "fontSize": 21 + } + }, + "subtitle": { + "type": "text", + "data": "A Material Design Sliver App Bar widget", + "align": "center", + "style": { + "fontSize": 12 + } + }, + "isThreeLine": true, + "style": "list", + "onTap": { + "actionType": "navigate", + "navigationStyle": "push", + "widgetJson": { + "type": "exampleScreen", + "assetPath": "assets/json/sliver_app_bar_example.json" + } + } + }, { "type": "listTile", "leading": { diff --git a/examples/stac_gallery/assets/json/sliver_app_bar_example.json b/examples/stac_gallery/assets/json/sliver_app_bar_example.json new file mode 100644 index 00000000..47387009 --- /dev/null +++ b/examples/stac_gallery/assets/json/sliver_app_bar_example.json @@ -0,0 +1,54 @@ +{ + "type": "scaffold", + "body": { + "type": "customScrollView", + "slivers": [ + { + "type": "sliverAppBar", + "title": { + "type": "text", + "data": "SliverAppBar" + }, + "leading": { + "type": "iconButton", + "icon": { + "type": "icon", + "iconType": "material", + "icon": "menu" + }, + "onPressed": {} + }, + "backgroundColor": "primary", + "actions": [ + { + "type": "iconButton", + "icon": { + "type": "icon", + "iconType": "cupertino", + "icon": "heart_solid" + }, + "onPressed": {} + }, + { + "type": "iconButton", + "icon": { + "type": "icon", + "iconType": "material", + "icon": "search" + }, + "onPressed": {} + }, + { + "type": "iconButton", + "icon": { + "type": "icon", + "iconType": "material", + "icon": "more_horiz" + }, + "onPressed": {} + } + ] + } + ] + } +} \ No newline at end of file diff --git a/packages/stac/lib/src/framework/stac.dart b/packages/stac/lib/src/framework/stac.dart index a907338f..291c59a0 100644 --- a/packages/stac/lib/src/framework/stac.dart +++ b/packages/stac/lib/src/framework/stac.dart @@ -8,6 +8,8 @@ import 'package:stac/src/action_parsers/action_parsers.dart'; import 'package:stac/src/action_parsers/stac_network_request/stac_network_request_parser.dart'; import 'package:stac/src/framework/stac_registry.dart'; import 'package:stac/src/parsers/parsers.dart'; +import 'package:stac/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart'; +import 'package:stac/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart'; import 'package:stac/src/services/stac_network_service.dart'; import 'package:stac/src/utils/log.dart'; import 'package:stac_framework/stac_framework.dart'; @@ -37,6 +39,7 @@ class Stac { const StacCenterParser(), const StacRowParser(), const StacColumnParser(), + const StacCustomScrollViewParser(), const StacStackParser(), const StacPositionedParser(), const StacIconButtonParser(), @@ -89,6 +92,7 @@ class Stac { const StacRadioParser(), const StacRadioGroupParser(), const StacSliderParser(), + const StacSliverAppBarParser(), const StacOpacityParser(), const StacPlaceholderParser(), const StacAspectRatioParser(), diff --git a/packages/stac/lib/src/parsers/parsers.dart b/packages/stac/lib/src/parsers/parsers.dart index dd31b699..32a6f4ce 100644 --- a/packages/stac/lib/src/parsers/parsers.dart +++ b/packages/stac/lib/src/parsers/parsers.dart @@ -27,6 +27,7 @@ export 'package:stac/src/parsers/stac_circular_progress_indicator/stac_circular_ export 'package:stac/src/parsers/stac_colored_box/stac_colored_box.dart'; export 'package:stac/src/parsers/stac_column/stac_column.dart'; export 'package:stac/src/parsers/stac_container/stac_container.dart'; +export 'package:stac/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.dart'; export 'package:stac/src/parsers/stac_default_bottom_navigation_controller/stac_default_bottom_navigation_controller.dart'; export 'package:stac/src/parsers/stac_default_tab_controller/stac_default_tab_controller.dart'; export 'package:stac/src/parsers/stac_dialog_theme/stac_dialog_theme.dart'; @@ -74,6 +75,7 @@ export 'package:stac/src/parsers/stac_single_child_scroll_view/stac_single_child export 'package:stac/src/parsers/stac_size/stac_size.dart'; export 'package:stac/src/parsers/stac_sized_box/stac_sized_box.dart'; export 'package:stac/src/parsers/stac_slider/stac_slider.dart'; +export 'package:stac/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart'; export 'package:stac/src/parsers/stac_spacer/stac_spacer.dart'; export 'package:stac/src/parsers/stac_stack/stac_stack.dart'; export 'package:stac/src/parsers/stac_switch/stac_switch.dart'; diff --git a/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.dart b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.dart new file mode 100644 index 00000000..c22de090 --- /dev/null +++ b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.dart @@ -0,0 +1,31 @@ +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/utils/stac_scroll_physics.dart'; + +part 'stac_custom_scroll_view.freezed.dart'; +part 'stac_custom_scroll_view.g.dart'; + +@freezed +class StacCustomScrollView with _$StacCustomScrollView { + const factory StacCustomScrollView({ + @Default([]) List> slivers, + @Default(Axis.vertical) Axis scrollDirection, + @Default(false) bool reverse, + bool? primary, + StacScrollPhysics? physics, + @Default(false) bool shrinkWrap, + @Default(0.0) double anchor, + double? cacheExtent, + int? semanticChildCount, + @Default(DragStartBehavior.start) DragStartBehavior dragStartBehavior, + @Default(ScrollViewKeyboardDismissBehavior.manual) + ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, + String? restorationId, + @Default(Clip.hardEdge) Clip clipBehavior, + @Default(HitTestBehavior.opaque) HitTestBehavior hitTestBehavior, + }) = _StacCustomScrollView; + + factory StacCustomScrollView.fromJson(Map json) => + _$StacCustomScrollViewFromJson(json); +} diff --git a/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.freezed.dart b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.freezed.dart new file mode 100644 index 00000000..a2f97596 --- /dev/null +++ b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.freezed.dart @@ -0,0 +1,473 @@ +// 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_custom_scroll_view.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +StacCustomScrollView _$StacCustomScrollViewFromJson(Map json) { + return _StacCustomScrollView.fromJson(json); +} + +/// @nodoc +mixin _$StacCustomScrollView { + List> get slivers => throw _privateConstructorUsedError; + Axis get scrollDirection => throw _privateConstructorUsedError; + bool get reverse => throw _privateConstructorUsedError; + bool? get primary => throw _privateConstructorUsedError; + StacScrollPhysics? get physics => throw _privateConstructorUsedError; + bool get shrinkWrap => throw _privateConstructorUsedError; + double get anchor => throw _privateConstructorUsedError; + double? get cacheExtent => throw _privateConstructorUsedError; + int? get semanticChildCount => throw _privateConstructorUsedError; + DragStartBehavior get dragStartBehavior => throw _privateConstructorUsedError; + ScrollViewKeyboardDismissBehavior get keyboardDismissBehavior => + throw _privateConstructorUsedError; + String? get restorationId => throw _privateConstructorUsedError; + Clip get clipBehavior => throw _privateConstructorUsedError; + HitTestBehavior get hitTestBehavior => throw _privateConstructorUsedError; + + /// Serializes this StacCustomScrollView to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of StacCustomScrollView + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $StacCustomScrollViewCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StacCustomScrollViewCopyWith<$Res> { + factory $StacCustomScrollViewCopyWith(StacCustomScrollView value, + $Res Function(StacCustomScrollView) then) = + _$StacCustomScrollViewCopyWithImpl<$Res, StacCustomScrollView>; + @useResult + $Res call( + {List> slivers, + Axis scrollDirection, + bool reverse, + bool? primary, + StacScrollPhysics? physics, + bool shrinkWrap, + double anchor, + double? cacheExtent, + int? semanticChildCount, + DragStartBehavior dragStartBehavior, + ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, + String? restorationId, + Clip clipBehavior, + HitTestBehavior hitTestBehavior}); +} + +/// @nodoc +class _$StacCustomScrollViewCopyWithImpl<$Res, + $Val extends StacCustomScrollView> + implements $StacCustomScrollViewCopyWith<$Res> { + _$StacCustomScrollViewCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of StacCustomScrollView + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? slivers = null, + Object? scrollDirection = null, + Object? reverse = null, + Object? primary = freezed, + Object? physics = freezed, + Object? shrinkWrap = null, + Object? anchor = null, + Object? cacheExtent = freezed, + Object? semanticChildCount = freezed, + Object? dragStartBehavior = null, + Object? keyboardDismissBehavior = null, + Object? restorationId = freezed, + Object? clipBehavior = null, + Object? hitTestBehavior = null, + }) { + return _then(_value.copyWith( + slivers: null == slivers + ? _value.slivers + : slivers // ignore: cast_nullable_to_non_nullable + as List>, + scrollDirection: null == scrollDirection + ? _value.scrollDirection + : scrollDirection // ignore: cast_nullable_to_non_nullable + as Axis, + reverse: null == reverse + ? _value.reverse + : reverse // ignore: cast_nullable_to_non_nullable + as bool, + primary: freezed == primary + ? _value.primary + : primary // ignore: cast_nullable_to_non_nullable + as bool?, + physics: freezed == physics + ? _value.physics + : physics // ignore: cast_nullable_to_non_nullable + as StacScrollPhysics?, + shrinkWrap: null == shrinkWrap + ? _value.shrinkWrap + : shrinkWrap // ignore: cast_nullable_to_non_nullable + as bool, + anchor: null == anchor + ? _value.anchor + : anchor // ignore: cast_nullable_to_non_nullable + as double, + cacheExtent: freezed == cacheExtent + ? _value.cacheExtent + : cacheExtent // ignore: cast_nullable_to_non_nullable + as double?, + semanticChildCount: freezed == semanticChildCount + ? _value.semanticChildCount + : semanticChildCount // ignore: cast_nullable_to_non_nullable + as int?, + dragStartBehavior: null == dragStartBehavior + ? _value.dragStartBehavior + : dragStartBehavior // ignore: cast_nullable_to_non_nullable + as DragStartBehavior, + keyboardDismissBehavior: null == keyboardDismissBehavior + ? _value.keyboardDismissBehavior + : keyboardDismissBehavior // ignore: cast_nullable_to_non_nullable + as ScrollViewKeyboardDismissBehavior, + restorationId: freezed == restorationId + ? _value.restorationId + : restorationId // ignore: cast_nullable_to_non_nullable + as String?, + clipBehavior: null == clipBehavior + ? _value.clipBehavior + : clipBehavior // ignore: cast_nullable_to_non_nullable + as Clip, + hitTestBehavior: null == hitTestBehavior + ? _value.hitTestBehavior + : hitTestBehavior // ignore: cast_nullable_to_non_nullable + as HitTestBehavior, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$StacCustomScrollViewImplCopyWith<$Res> + implements $StacCustomScrollViewCopyWith<$Res> { + factory _$$StacCustomScrollViewImplCopyWith(_$StacCustomScrollViewImpl value, + $Res Function(_$StacCustomScrollViewImpl) then) = + __$$StacCustomScrollViewImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {List> slivers, + Axis scrollDirection, + bool reverse, + bool? primary, + StacScrollPhysics? physics, + bool shrinkWrap, + double anchor, + double? cacheExtent, + int? semanticChildCount, + DragStartBehavior dragStartBehavior, + ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, + String? restorationId, + Clip clipBehavior, + HitTestBehavior hitTestBehavior}); +} + +/// @nodoc +class __$$StacCustomScrollViewImplCopyWithImpl<$Res> + extends _$StacCustomScrollViewCopyWithImpl<$Res, _$StacCustomScrollViewImpl> + implements _$$StacCustomScrollViewImplCopyWith<$Res> { + __$$StacCustomScrollViewImplCopyWithImpl(_$StacCustomScrollViewImpl _value, + $Res Function(_$StacCustomScrollViewImpl) _then) + : super(_value, _then); + + /// Create a copy of StacCustomScrollView + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? slivers = null, + Object? scrollDirection = null, + Object? reverse = null, + Object? primary = freezed, + Object? physics = freezed, + Object? shrinkWrap = null, + Object? anchor = null, + Object? cacheExtent = freezed, + Object? semanticChildCount = freezed, + Object? dragStartBehavior = null, + Object? keyboardDismissBehavior = null, + Object? restorationId = freezed, + Object? clipBehavior = null, + Object? hitTestBehavior = null, + }) { + return _then(_$StacCustomScrollViewImpl( + slivers: null == slivers + ? _value._slivers + : slivers // ignore: cast_nullable_to_non_nullable + as List>, + scrollDirection: null == scrollDirection + ? _value.scrollDirection + : scrollDirection // ignore: cast_nullable_to_non_nullable + as Axis, + reverse: null == reverse + ? _value.reverse + : reverse // ignore: cast_nullable_to_non_nullable + as bool, + primary: freezed == primary + ? _value.primary + : primary // ignore: cast_nullable_to_non_nullable + as bool?, + physics: freezed == physics + ? _value.physics + : physics // ignore: cast_nullable_to_non_nullable + as StacScrollPhysics?, + shrinkWrap: null == shrinkWrap + ? _value.shrinkWrap + : shrinkWrap // ignore: cast_nullable_to_non_nullable + as bool, + anchor: null == anchor + ? _value.anchor + : anchor // ignore: cast_nullable_to_non_nullable + as double, + cacheExtent: freezed == cacheExtent + ? _value.cacheExtent + : cacheExtent // ignore: cast_nullable_to_non_nullable + as double?, + semanticChildCount: freezed == semanticChildCount + ? _value.semanticChildCount + : semanticChildCount // ignore: cast_nullable_to_non_nullable + as int?, + dragStartBehavior: null == dragStartBehavior + ? _value.dragStartBehavior + : dragStartBehavior // ignore: cast_nullable_to_non_nullable + as DragStartBehavior, + keyboardDismissBehavior: null == keyboardDismissBehavior + ? _value.keyboardDismissBehavior + : keyboardDismissBehavior // ignore: cast_nullable_to_non_nullable + as ScrollViewKeyboardDismissBehavior, + restorationId: freezed == restorationId + ? _value.restorationId + : restorationId // ignore: cast_nullable_to_non_nullable + as String?, + clipBehavior: null == clipBehavior + ? _value.clipBehavior + : clipBehavior // ignore: cast_nullable_to_non_nullable + as Clip, + hitTestBehavior: null == hitTestBehavior + ? _value.hitTestBehavior + : hitTestBehavior // ignore: cast_nullable_to_non_nullable + as HitTestBehavior, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StacCustomScrollViewImpl implements _StacCustomScrollView { + const _$StacCustomScrollViewImpl( + {final List> slivers = const [], + this.scrollDirection = Axis.vertical, + this.reverse = false, + this.primary, + this.physics, + this.shrinkWrap = false, + this.anchor = 0.0, + this.cacheExtent, + this.semanticChildCount, + this.dragStartBehavior = DragStartBehavior.start, + this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, + this.restorationId, + this.clipBehavior = Clip.hardEdge, + this.hitTestBehavior = HitTestBehavior.opaque}) + : _slivers = slivers; + + factory _$StacCustomScrollViewImpl.fromJson(Map json) => + _$$StacCustomScrollViewImplFromJson(json); + + final List> _slivers; + @override + @JsonKey() + List> get slivers { + if (_slivers is EqualUnmodifiableListView) return _slivers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_slivers); + } + + @override + @JsonKey() + final Axis scrollDirection; + @override + @JsonKey() + final bool reverse; + @override + final bool? primary; + @override + final StacScrollPhysics? physics; + @override + @JsonKey() + final bool shrinkWrap; + @override + @JsonKey() + final double anchor; + @override + final double? cacheExtent; + @override + final int? semanticChildCount; + @override + @JsonKey() + final DragStartBehavior dragStartBehavior; + @override + @JsonKey() + final ScrollViewKeyboardDismissBehavior keyboardDismissBehavior; + @override + final String? restorationId; + @override + @JsonKey() + final Clip clipBehavior; + @override + @JsonKey() + final HitTestBehavior hitTestBehavior; + + @override + String toString() { + return 'StacCustomScrollView(slivers: $slivers, scrollDirection: $scrollDirection, reverse: $reverse, primary: $primary, physics: $physics, shrinkWrap: $shrinkWrap, anchor: $anchor, cacheExtent: $cacheExtent, semanticChildCount: $semanticChildCount, dragStartBehavior: $dragStartBehavior, keyboardDismissBehavior: $keyboardDismissBehavior, restorationId: $restorationId, clipBehavior: $clipBehavior, hitTestBehavior: $hitTestBehavior)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StacCustomScrollViewImpl && + const DeepCollectionEquality().equals(other._slivers, _slivers) && + (identical(other.scrollDirection, scrollDirection) || + other.scrollDirection == scrollDirection) && + (identical(other.reverse, reverse) || other.reverse == reverse) && + (identical(other.primary, primary) || other.primary == primary) && + (identical(other.physics, physics) || other.physics == physics) && + (identical(other.shrinkWrap, shrinkWrap) || + other.shrinkWrap == shrinkWrap) && + (identical(other.anchor, anchor) || other.anchor == anchor) && + (identical(other.cacheExtent, cacheExtent) || + other.cacheExtent == cacheExtent) && + (identical(other.semanticChildCount, semanticChildCount) || + other.semanticChildCount == semanticChildCount) && + (identical(other.dragStartBehavior, dragStartBehavior) || + other.dragStartBehavior == dragStartBehavior) && + (identical( + other.keyboardDismissBehavior, keyboardDismissBehavior) || + other.keyboardDismissBehavior == keyboardDismissBehavior) && + (identical(other.restorationId, restorationId) || + other.restorationId == restorationId) && + (identical(other.clipBehavior, clipBehavior) || + other.clipBehavior == clipBehavior) && + (identical(other.hitTestBehavior, hitTestBehavior) || + other.hitTestBehavior == hitTestBehavior)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_slivers), + scrollDirection, + reverse, + primary, + physics, + shrinkWrap, + anchor, + cacheExtent, + semanticChildCount, + dragStartBehavior, + keyboardDismissBehavior, + restorationId, + clipBehavior, + hitTestBehavior); + + /// Create a copy of StacCustomScrollView + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StacCustomScrollViewImplCopyWith<_$StacCustomScrollViewImpl> + get copyWith => + __$$StacCustomScrollViewImplCopyWithImpl<_$StacCustomScrollViewImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$StacCustomScrollViewImplToJson( + this, + ); + } +} + +abstract class _StacCustomScrollView implements StacCustomScrollView { + const factory _StacCustomScrollView( + {final List> slivers, + final Axis scrollDirection, + final bool reverse, + final bool? primary, + final StacScrollPhysics? physics, + final bool shrinkWrap, + final double anchor, + final double? cacheExtent, + final int? semanticChildCount, + final DragStartBehavior dragStartBehavior, + final ScrollViewKeyboardDismissBehavior keyboardDismissBehavior, + final String? restorationId, + final Clip clipBehavior, + final HitTestBehavior hitTestBehavior}) = _$StacCustomScrollViewImpl; + + factory _StacCustomScrollView.fromJson(Map json) = + _$StacCustomScrollViewImpl.fromJson; + + @override + List> get slivers; + @override + Axis get scrollDirection; + @override + bool get reverse; + @override + bool? get primary; + @override + StacScrollPhysics? get physics; + @override + bool get shrinkWrap; + @override + double get anchor; + @override + double? get cacheExtent; + @override + int? get semanticChildCount; + @override + DragStartBehavior get dragStartBehavior; + @override + ScrollViewKeyboardDismissBehavior get keyboardDismissBehavior; + @override + String? get restorationId; + @override + Clip get clipBehavior; + @override + HitTestBehavior get hitTestBehavior; + + /// Create a copy of StacCustomScrollView + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StacCustomScrollViewImplCopyWith<_$StacCustomScrollViewImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.g.dart b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.g.dart new file mode 100644 index 00000000..119f5315 --- /dev/null +++ b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view.g.dart @@ -0,0 +1,96 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_custom_scroll_view.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$StacCustomScrollViewImpl _$$StacCustomScrollViewImplFromJson( + Map json) => + _$StacCustomScrollViewImpl( + slivers: (json['slivers'] as List?) + ?.map((e) => e as Map) + .toList() ?? + const [], + scrollDirection: + $enumDecodeNullable(_$AxisEnumMap, json['scrollDirection']) ?? + Axis.vertical, + reverse: json['reverse'] as bool? ?? false, + primary: json['primary'] as bool?, + physics: $enumDecodeNullable(_$StacScrollPhysicsEnumMap, json['physics']), + shrinkWrap: json['shrinkWrap'] as bool? ?? false, + anchor: (json['anchor'] as num?)?.toDouble() ?? 0.0, + cacheExtent: (json['cacheExtent'] as num?)?.toDouble(), + semanticChildCount: (json['semanticChildCount'] as num?)?.toInt(), + dragStartBehavior: $enumDecodeNullable( + _$DragStartBehaviorEnumMap, json['dragStartBehavior']) ?? + DragStartBehavior.start, + keyboardDismissBehavior: $enumDecodeNullable( + _$ScrollViewKeyboardDismissBehaviorEnumMap, + json['keyboardDismissBehavior']) ?? + ScrollViewKeyboardDismissBehavior.manual, + restorationId: json['restorationId'] as String?, + clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']) ?? + Clip.hardEdge, + hitTestBehavior: $enumDecodeNullable( + _$HitTestBehaviorEnumMap, json['hitTestBehavior']) ?? + HitTestBehavior.opaque, + ); + +Map _$$StacCustomScrollViewImplToJson( + _$StacCustomScrollViewImpl instance) => + { + 'slivers': instance.slivers, + 'scrollDirection': _$AxisEnumMap[instance.scrollDirection]!, + 'reverse': instance.reverse, + 'primary': instance.primary, + 'physics': _$StacScrollPhysicsEnumMap[instance.physics], + 'shrinkWrap': instance.shrinkWrap, + 'anchor': instance.anchor, + 'cacheExtent': instance.cacheExtent, + 'semanticChildCount': instance.semanticChildCount, + 'dragStartBehavior': + _$DragStartBehaviorEnumMap[instance.dragStartBehavior]!, + 'keyboardDismissBehavior': _$ScrollViewKeyboardDismissBehaviorEnumMap[ + instance.keyboardDismissBehavior]!, + 'restorationId': instance.restorationId, + 'clipBehavior': _$ClipEnumMap[instance.clipBehavior]!, + 'hitTestBehavior': _$HitTestBehaviorEnumMap[instance.hitTestBehavior]!, + }; + +const _$AxisEnumMap = { + Axis.horizontal: 'horizontal', + Axis.vertical: 'vertical', +}; + +const _$StacScrollPhysicsEnumMap = { + StacScrollPhysics.never: 'never', + StacScrollPhysics.bouncing: 'bouncing', + StacScrollPhysics.clamping: 'clamping', + StacScrollPhysics.fixed: 'fixed', + StacScrollPhysics.page: 'page', +}; + +const _$DragStartBehaviorEnumMap = { + DragStartBehavior.down: 'down', + DragStartBehavior.start: 'start', +}; + +const _$ScrollViewKeyboardDismissBehaviorEnumMap = { + ScrollViewKeyboardDismissBehavior.manual: 'manual', + ScrollViewKeyboardDismissBehavior.onDrag: 'onDrag', +}; + +const _$ClipEnumMap = { + Clip.none: 'none', + Clip.hardEdge: 'hardEdge', + Clip.antiAlias: 'antiAlias', + Clip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', +}; + +const _$HitTestBehaviorEnumMap = { + HitTestBehavior.deferToChild: 'deferToChild', + HitTestBehavior.opaque: 'opaque', + HitTestBehavior.translucent: 'translucent', +}; diff --git a/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart new file mode 100644 index 00000000..957cd586 --- /dev/null +++ b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; + +import '../../../stac.dart'; +import '../../utils/widget_type.dart'; +import 'stac_custom_scroll_view.dart'; + +class StacCustomScrollViewParser extends StacParser { + const StacCustomScrollViewParser({this.controller}); + + final ScrollController? controller; + + @override + String get type => WidgetType.customScrollView.name; + + @override + StacCustomScrollView getModel(Map json) => + StacCustomScrollView.fromJson(json); + + @override + Widget parse(BuildContext context, StacCustomScrollView model) { + return CustomScrollView( + slivers: model.slivers + .map((e) => Stac.fromJson(e, context) ?? const SizedBox.shrink()) + .toList(), + scrollDirection: model.scrollDirection, + reverse: model.reverse, + primary: model.primary, + physics: model.physics?.parse, + shrinkWrap: model.shrinkWrap, + anchor: model.anchor, + cacheExtent: model.cacheExtent, + semanticChildCount: model.semanticChildCount, + dragStartBehavior: model.dragStartBehavior, + keyboardDismissBehavior: model.keyboardDismissBehavior, + restorationId: model.restorationId, + clipBehavior: model.clipBehavior, + hitTestBehavior: model.hitTestBehavior, + ); + } +} diff --git a/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart new file mode 100644 index 00000000..04ccf150 --- /dev/null +++ b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stac/src/parsers/stac_icon_theme_data/stac_icon_theme_data.dart'; +import 'package:stac/src/parsers/stac_shape_border/stac_shape_border.dart'; + +import '../../../stac.dart'; +import '../stac_system_ui_olverlay_style/stac_system_ui_overlay_style.dart'; + +part 'stac_sliver_app_bar.freezed.dart'; +part 'stac_sliver_app_bar.g.dart'; + +@freezed +class StacSliverAppBar with _$StacSliverAppBar { + const factory StacSliverAppBar({ + Map? leading, + @Default(true) bool automaticallyImplyLeading, + Map? title, + List>? actions, + Map? flexibleSpace, + Map? bottom, + double? elevation, + double? scrolledUnderElevation, + String? shadowColor, + String? surfaceTintColor, + @Default(false) bool forceElevated, + String? backgroundColor, + String? foregroundColor, + StacIconThemeData? iconTheme, + StacIconThemeData? actionsIconTheme, + @Default(true) bool primary, + bool? centerTitle, + @Default(false) bool excludeHeaderSemantics, + double? titleSpacing, + double? collapsedHeight, + double? expandedHeight, + @Default(false) bool floating, + @Default(true) bool pinned, + @Default(false) bool snap, + @Default(false) bool stretch, + @Default(100.0) double stretchTriggerOffset, + StacShapeBorder? shape, + // StacAsyncCallback? onStretchTrigger, TODO: Implement StacAsyncCallback + @Default(64.0) double toolbarHeight, + double? leadingWidth, + StacTextStyle? toolbarTextStyle, + StacTextStyle? titleTextStyle, + StacSystemUIOverlayStyle? systemOverlayStyle, + @Default(false) bool forceMaterialTransparency, + Clip? clipBehavior, + StacEdgeInsets? actionsPadding, + }) = _StacSliverAppBar; + + factory StacSliverAppBar.fromJson(Map json) => + _$StacSliverAppBarFromJson(json); +} diff --git a/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.freezed.dart b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.freezed.dart new file mode 100644 index 00000000..2a6ef4a5 --- /dev/null +++ b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.freezed.dart @@ -0,0 +1,1096 @@ +// 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_sliver_app_bar.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +StacSliverAppBar _$StacSliverAppBarFromJson(Map json) { + return _StacSliverAppBar.fromJson(json); +} + +/// @nodoc +mixin _$StacSliverAppBar { + Map? get leading => throw _privateConstructorUsedError; + bool get automaticallyImplyLeading => throw _privateConstructorUsedError; + Map? get title => throw _privateConstructorUsedError; + List>? get actions => throw _privateConstructorUsedError; + Map? get flexibleSpace => throw _privateConstructorUsedError; + Map? get bottom => throw _privateConstructorUsedError; + double? get elevation => throw _privateConstructorUsedError; + double? get scrolledUnderElevation => throw _privateConstructorUsedError; + String? get shadowColor => throw _privateConstructorUsedError; + String? get surfaceTintColor => throw _privateConstructorUsedError; + bool get forceElevated => throw _privateConstructorUsedError; + String? get backgroundColor => throw _privateConstructorUsedError; + String? get foregroundColor => throw _privateConstructorUsedError; + StacIconThemeData? get iconTheme => throw _privateConstructorUsedError; + StacIconThemeData? get actionsIconTheme => throw _privateConstructorUsedError; + bool get primary => throw _privateConstructorUsedError; + bool? get centerTitle => throw _privateConstructorUsedError; + bool get excludeHeaderSemantics => throw _privateConstructorUsedError; + double? get titleSpacing => throw _privateConstructorUsedError; + double? get collapsedHeight => throw _privateConstructorUsedError; + double? get expandedHeight => throw _privateConstructorUsedError; + bool get floating => throw _privateConstructorUsedError; + bool get pinned => throw _privateConstructorUsedError; + bool get snap => throw _privateConstructorUsedError; + bool get stretch => throw _privateConstructorUsedError; + double get stretchTriggerOffset => throw _privateConstructorUsedError; + StacShapeBorder? get shape => + throw _privateConstructorUsedError; // StacAsyncCallback? onStretchTrigger, TODO: Implement StacAsyncCallback + double get toolbarHeight => throw _privateConstructorUsedError; + double? get leadingWidth => throw _privateConstructorUsedError; + StacTextStyle? get toolbarTextStyle => throw _privateConstructorUsedError; + StacTextStyle? get titleTextStyle => throw _privateConstructorUsedError; + StacSystemUIOverlayStyle? get systemOverlayStyle => + throw _privateConstructorUsedError; + bool get forceMaterialTransparency => throw _privateConstructorUsedError; + Clip? get clipBehavior => throw _privateConstructorUsedError; + StacEdgeInsets? get actionsPadding => throw _privateConstructorUsedError; + + /// Serializes this StacSliverAppBar to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $StacSliverAppBarCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StacSliverAppBarCopyWith<$Res> { + factory $StacSliverAppBarCopyWith( + StacSliverAppBar value, $Res Function(StacSliverAppBar) then) = + _$StacSliverAppBarCopyWithImpl<$Res, StacSliverAppBar>; + @useResult + $Res call( + {Map? leading, + bool automaticallyImplyLeading, + Map? title, + List>? actions, + Map? flexibleSpace, + Map? bottom, + double? elevation, + double? scrolledUnderElevation, + String? shadowColor, + String? surfaceTintColor, + bool forceElevated, + String? backgroundColor, + String? foregroundColor, + StacIconThemeData? iconTheme, + StacIconThemeData? actionsIconTheme, + bool primary, + bool? centerTitle, + bool excludeHeaderSemantics, + double? titleSpacing, + double? collapsedHeight, + double? expandedHeight, + bool floating, + bool pinned, + bool snap, + bool stretch, + double stretchTriggerOffset, + StacShapeBorder? shape, + double toolbarHeight, + double? leadingWidth, + StacTextStyle? toolbarTextStyle, + StacTextStyle? titleTextStyle, + StacSystemUIOverlayStyle? systemOverlayStyle, + bool forceMaterialTransparency, + Clip? clipBehavior, + StacEdgeInsets? actionsPadding}); + + $StacIconThemeDataCopyWith<$Res>? get iconTheme; + $StacIconThemeDataCopyWith<$Res>? get actionsIconTheme; + $StacShapeBorderCopyWith<$Res>? get shape; + $StacTextStyleCopyWith<$Res>? get toolbarTextStyle; + $StacTextStyleCopyWith<$Res>? get titleTextStyle; + $StacSystemUIOverlayStyleCopyWith<$Res>? get systemOverlayStyle; + $StacEdgeInsetsCopyWith<$Res>? get actionsPadding; +} + +/// @nodoc +class _$StacSliverAppBarCopyWithImpl<$Res, $Val extends StacSliverAppBar> + implements $StacSliverAppBarCopyWith<$Res> { + _$StacSliverAppBarCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? leading = freezed, + Object? automaticallyImplyLeading = null, + Object? title = freezed, + Object? actions = freezed, + Object? flexibleSpace = freezed, + Object? bottom = freezed, + Object? elevation = freezed, + Object? scrolledUnderElevation = freezed, + Object? shadowColor = freezed, + Object? surfaceTintColor = freezed, + Object? forceElevated = null, + Object? backgroundColor = freezed, + Object? foregroundColor = freezed, + Object? iconTheme = freezed, + Object? actionsIconTheme = freezed, + Object? primary = null, + Object? centerTitle = freezed, + Object? excludeHeaderSemantics = null, + Object? titleSpacing = freezed, + Object? collapsedHeight = freezed, + Object? expandedHeight = freezed, + Object? floating = null, + Object? pinned = null, + Object? snap = null, + Object? stretch = null, + Object? stretchTriggerOffset = null, + Object? shape = freezed, + Object? toolbarHeight = null, + Object? leadingWidth = freezed, + Object? toolbarTextStyle = freezed, + Object? titleTextStyle = freezed, + Object? systemOverlayStyle = freezed, + Object? forceMaterialTransparency = null, + Object? clipBehavior = freezed, + Object? actionsPadding = freezed, + }) { + return _then(_value.copyWith( + leading: freezed == leading + ? _value.leading + : leading // ignore: cast_nullable_to_non_nullable + as Map?, + automaticallyImplyLeading: null == automaticallyImplyLeading + ? _value.automaticallyImplyLeading + : automaticallyImplyLeading // ignore: cast_nullable_to_non_nullable + as bool, + title: freezed == title + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as Map?, + actions: freezed == actions + ? _value.actions + : actions // ignore: cast_nullable_to_non_nullable + as List>?, + flexibleSpace: freezed == flexibleSpace + ? _value.flexibleSpace + : flexibleSpace // ignore: cast_nullable_to_non_nullable + as Map?, + bottom: freezed == bottom + ? _value.bottom + : bottom // ignore: cast_nullable_to_non_nullable + as Map?, + elevation: freezed == elevation + ? _value.elevation + : elevation // ignore: cast_nullable_to_non_nullable + as double?, + scrolledUnderElevation: freezed == scrolledUnderElevation + ? _value.scrolledUnderElevation + : scrolledUnderElevation // ignore: cast_nullable_to_non_nullable + as double?, + shadowColor: freezed == shadowColor + ? _value.shadowColor + : shadowColor // ignore: cast_nullable_to_non_nullable + as String?, + surfaceTintColor: freezed == surfaceTintColor + ? _value.surfaceTintColor + : surfaceTintColor // ignore: cast_nullable_to_non_nullable + as String?, + forceElevated: null == forceElevated + ? _value.forceElevated + : forceElevated // ignore: cast_nullable_to_non_nullable + as bool, + backgroundColor: freezed == backgroundColor + ? _value.backgroundColor + : backgroundColor // ignore: cast_nullable_to_non_nullable + as String?, + foregroundColor: freezed == foregroundColor + ? _value.foregroundColor + : foregroundColor // ignore: cast_nullable_to_non_nullable + as String?, + iconTheme: freezed == iconTheme + ? _value.iconTheme + : iconTheme // ignore: cast_nullable_to_non_nullable + as StacIconThemeData?, + actionsIconTheme: freezed == actionsIconTheme + ? _value.actionsIconTheme + : actionsIconTheme // ignore: cast_nullable_to_non_nullable + as StacIconThemeData?, + primary: null == primary + ? _value.primary + : primary // ignore: cast_nullable_to_non_nullable + as bool, + centerTitle: freezed == centerTitle + ? _value.centerTitle + : centerTitle // ignore: cast_nullable_to_non_nullable + as bool?, + excludeHeaderSemantics: null == excludeHeaderSemantics + ? _value.excludeHeaderSemantics + : excludeHeaderSemantics // ignore: cast_nullable_to_non_nullable + as bool, + titleSpacing: freezed == titleSpacing + ? _value.titleSpacing + : titleSpacing // ignore: cast_nullable_to_non_nullable + as double?, + collapsedHeight: freezed == collapsedHeight + ? _value.collapsedHeight + : collapsedHeight // ignore: cast_nullable_to_non_nullable + as double?, + expandedHeight: freezed == expandedHeight + ? _value.expandedHeight + : expandedHeight // ignore: cast_nullable_to_non_nullable + as double?, + floating: null == floating + ? _value.floating + : floating // ignore: cast_nullable_to_non_nullable + as bool, + pinned: null == pinned + ? _value.pinned + : pinned // ignore: cast_nullable_to_non_nullable + as bool, + snap: null == snap + ? _value.snap + : snap // ignore: cast_nullable_to_non_nullable + as bool, + stretch: null == stretch + ? _value.stretch + : stretch // ignore: cast_nullable_to_non_nullable + as bool, + stretchTriggerOffset: null == stretchTriggerOffset + ? _value.stretchTriggerOffset + : stretchTriggerOffset // ignore: cast_nullable_to_non_nullable + as double, + shape: freezed == shape + ? _value.shape + : shape // ignore: cast_nullable_to_non_nullable + as StacShapeBorder?, + toolbarHeight: null == toolbarHeight + ? _value.toolbarHeight + : toolbarHeight // ignore: cast_nullable_to_non_nullable + as double, + leadingWidth: freezed == leadingWidth + ? _value.leadingWidth + : leadingWidth // ignore: cast_nullable_to_non_nullable + as double?, + toolbarTextStyle: freezed == toolbarTextStyle + ? _value.toolbarTextStyle + : toolbarTextStyle // ignore: cast_nullable_to_non_nullable + as StacTextStyle?, + titleTextStyle: freezed == titleTextStyle + ? _value.titleTextStyle + : titleTextStyle // ignore: cast_nullable_to_non_nullable + as StacTextStyle?, + systemOverlayStyle: freezed == systemOverlayStyle + ? _value.systemOverlayStyle + : systemOverlayStyle // ignore: cast_nullable_to_non_nullable + as StacSystemUIOverlayStyle?, + forceMaterialTransparency: null == forceMaterialTransparency + ? _value.forceMaterialTransparency + : forceMaterialTransparency // ignore: cast_nullable_to_non_nullable + as bool, + clipBehavior: freezed == clipBehavior + ? _value.clipBehavior + : clipBehavior // ignore: cast_nullable_to_non_nullable + as Clip?, + actionsPadding: freezed == actionsPadding + ? _value.actionsPadding + : actionsPadding // ignore: cast_nullable_to_non_nullable + as StacEdgeInsets?, + ) as $Val); + } + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $StacIconThemeDataCopyWith<$Res>? get iconTheme { + if (_value.iconTheme == null) { + return null; + } + + return $StacIconThemeDataCopyWith<$Res>(_value.iconTheme!, (value) { + return _then(_value.copyWith(iconTheme: value) as $Val); + }); + } + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $StacIconThemeDataCopyWith<$Res>? get actionsIconTheme { + if (_value.actionsIconTheme == null) { + return null; + } + + return $StacIconThemeDataCopyWith<$Res>(_value.actionsIconTheme!, (value) { + return _then(_value.copyWith(actionsIconTheme: value) as $Val); + }); + } + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $StacShapeBorderCopyWith<$Res>? get shape { + if (_value.shape == null) { + return null; + } + + return $StacShapeBorderCopyWith<$Res>(_value.shape!, (value) { + return _then(_value.copyWith(shape: value) as $Val); + }); + } + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $StacTextStyleCopyWith<$Res>? get toolbarTextStyle { + if (_value.toolbarTextStyle == null) { + return null; + } + + return $StacTextStyleCopyWith<$Res>(_value.toolbarTextStyle!, (value) { + return _then(_value.copyWith(toolbarTextStyle: value) as $Val); + }); + } + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $StacTextStyleCopyWith<$Res>? get titleTextStyle { + if (_value.titleTextStyle == null) { + return null; + } + + return $StacTextStyleCopyWith<$Res>(_value.titleTextStyle!, (value) { + return _then(_value.copyWith(titleTextStyle: value) as $Val); + }); + } + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $StacSystemUIOverlayStyleCopyWith<$Res>? get systemOverlayStyle { + if (_value.systemOverlayStyle == null) { + return null; + } + + return $StacSystemUIOverlayStyleCopyWith<$Res>(_value.systemOverlayStyle!, + (value) { + return _then(_value.copyWith(systemOverlayStyle: value) as $Val); + }); + } + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $StacEdgeInsetsCopyWith<$Res>? get actionsPadding { + if (_value.actionsPadding == null) { + return null; + } + + return $StacEdgeInsetsCopyWith<$Res>(_value.actionsPadding!, (value) { + return _then(_value.copyWith(actionsPadding: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$StacSliverAppBarImplCopyWith<$Res> + implements $StacSliverAppBarCopyWith<$Res> { + factory _$$StacSliverAppBarImplCopyWith(_$StacSliverAppBarImpl value, + $Res Function(_$StacSliverAppBarImpl) then) = + __$$StacSliverAppBarImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {Map? leading, + bool automaticallyImplyLeading, + Map? title, + List>? actions, + Map? flexibleSpace, + Map? bottom, + double? elevation, + double? scrolledUnderElevation, + String? shadowColor, + String? surfaceTintColor, + bool forceElevated, + String? backgroundColor, + String? foregroundColor, + StacIconThemeData? iconTheme, + StacIconThemeData? actionsIconTheme, + bool primary, + bool? centerTitle, + bool excludeHeaderSemantics, + double? titleSpacing, + double? collapsedHeight, + double? expandedHeight, + bool floating, + bool pinned, + bool snap, + bool stretch, + double stretchTriggerOffset, + StacShapeBorder? shape, + double toolbarHeight, + double? leadingWidth, + StacTextStyle? toolbarTextStyle, + StacTextStyle? titleTextStyle, + StacSystemUIOverlayStyle? systemOverlayStyle, + bool forceMaterialTransparency, + Clip? clipBehavior, + StacEdgeInsets? actionsPadding}); + + @override + $StacIconThemeDataCopyWith<$Res>? get iconTheme; + @override + $StacIconThemeDataCopyWith<$Res>? get actionsIconTheme; + @override + $StacShapeBorderCopyWith<$Res>? get shape; + @override + $StacTextStyleCopyWith<$Res>? get toolbarTextStyle; + @override + $StacTextStyleCopyWith<$Res>? get titleTextStyle; + @override + $StacSystemUIOverlayStyleCopyWith<$Res>? get systemOverlayStyle; + @override + $StacEdgeInsetsCopyWith<$Res>? get actionsPadding; +} + +/// @nodoc +class __$$StacSliverAppBarImplCopyWithImpl<$Res> + extends _$StacSliverAppBarCopyWithImpl<$Res, _$StacSliverAppBarImpl> + implements _$$StacSliverAppBarImplCopyWith<$Res> { + __$$StacSliverAppBarImplCopyWithImpl(_$StacSliverAppBarImpl _value, + $Res Function(_$StacSliverAppBarImpl) _then) + : super(_value, _then); + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? leading = freezed, + Object? automaticallyImplyLeading = null, + Object? title = freezed, + Object? actions = freezed, + Object? flexibleSpace = freezed, + Object? bottom = freezed, + Object? elevation = freezed, + Object? scrolledUnderElevation = freezed, + Object? shadowColor = freezed, + Object? surfaceTintColor = freezed, + Object? forceElevated = null, + Object? backgroundColor = freezed, + Object? foregroundColor = freezed, + Object? iconTheme = freezed, + Object? actionsIconTheme = freezed, + Object? primary = null, + Object? centerTitle = freezed, + Object? excludeHeaderSemantics = null, + Object? titleSpacing = freezed, + Object? collapsedHeight = freezed, + Object? expandedHeight = freezed, + Object? floating = null, + Object? pinned = null, + Object? snap = null, + Object? stretch = null, + Object? stretchTriggerOffset = null, + Object? shape = freezed, + Object? toolbarHeight = null, + Object? leadingWidth = freezed, + Object? toolbarTextStyle = freezed, + Object? titleTextStyle = freezed, + Object? systemOverlayStyle = freezed, + Object? forceMaterialTransparency = null, + Object? clipBehavior = freezed, + Object? actionsPadding = freezed, + }) { + return _then(_$StacSliverAppBarImpl( + leading: freezed == leading + ? _value._leading + : leading // ignore: cast_nullable_to_non_nullable + as Map?, + automaticallyImplyLeading: null == automaticallyImplyLeading + ? _value.automaticallyImplyLeading + : automaticallyImplyLeading // ignore: cast_nullable_to_non_nullable + as bool, + title: freezed == title + ? _value._title + : title // ignore: cast_nullable_to_non_nullable + as Map?, + actions: freezed == actions + ? _value._actions + : actions // ignore: cast_nullable_to_non_nullable + as List>?, + flexibleSpace: freezed == flexibleSpace + ? _value._flexibleSpace + : flexibleSpace // ignore: cast_nullable_to_non_nullable + as Map?, + bottom: freezed == bottom + ? _value._bottom + : bottom // ignore: cast_nullable_to_non_nullable + as Map?, + elevation: freezed == elevation + ? _value.elevation + : elevation // ignore: cast_nullable_to_non_nullable + as double?, + scrolledUnderElevation: freezed == scrolledUnderElevation + ? _value.scrolledUnderElevation + : scrolledUnderElevation // ignore: cast_nullable_to_non_nullable + as double?, + shadowColor: freezed == shadowColor + ? _value.shadowColor + : shadowColor // ignore: cast_nullable_to_non_nullable + as String?, + surfaceTintColor: freezed == surfaceTintColor + ? _value.surfaceTintColor + : surfaceTintColor // ignore: cast_nullable_to_non_nullable + as String?, + forceElevated: null == forceElevated + ? _value.forceElevated + : forceElevated // ignore: cast_nullable_to_non_nullable + as bool, + backgroundColor: freezed == backgroundColor + ? _value.backgroundColor + : backgroundColor // ignore: cast_nullable_to_non_nullable + as String?, + foregroundColor: freezed == foregroundColor + ? _value.foregroundColor + : foregroundColor // ignore: cast_nullable_to_non_nullable + as String?, + iconTheme: freezed == iconTheme + ? _value.iconTheme + : iconTheme // ignore: cast_nullable_to_non_nullable + as StacIconThemeData?, + actionsIconTheme: freezed == actionsIconTheme + ? _value.actionsIconTheme + : actionsIconTheme // ignore: cast_nullable_to_non_nullable + as StacIconThemeData?, + primary: null == primary + ? _value.primary + : primary // ignore: cast_nullable_to_non_nullable + as bool, + centerTitle: freezed == centerTitle + ? _value.centerTitle + : centerTitle // ignore: cast_nullable_to_non_nullable + as bool?, + excludeHeaderSemantics: null == excludeHeaderSemantics + ? _value.excludeHeaderSemantics + : excludeHeaderSemantics // ignore: cast_nullable_to_non_nullable + as bool, + titleSpacing: freezed == titleSpacing + ? _value.titleSpacing + : titleSpacing // ignore: cast_nullable_to_non_nullable + as double?, + collapsedHeight: freezed == collapsedHeight + ? _value.collapsedHeight + : collapsedHeight // ignore: cast_nullable_to_non_nullable + as double?, + expandedHeight: freezed == expandedHeight + ? _value.expandedHeight + : expandedHeight // ignore: cast_nullable_to_non_nullable + as double?, + floating: null == floating + ? _value.floating + : floating // ignore: cast_nullable_to_non_nullable + as bool, + pinned: null == pinned + ? _value.pinned + : pinned // ignore: cast_nullable_to_non_nullable + as bool, + snap: null == snap + ? _value.snap + : snap // ignore: cast_nullable_to_non_nullable + as bool, + stretch: null == stretch + ? _value.stretch + : stretch // ignore: cast_nullable_to_non_nullable + as bool, + stretchTriggerOffset: null == stretchTriggerOffset + ? _value.stretchTriggerOffset + : stretchTriggerOffset // ignore: cast_nullable_to_non_nullable + as double, + shape: freezed == shape + ? _value.shape + : shape // ignore: cast_nullable_to_non_nullable + as StacShapeBorder?, + toolbarHeight: null == toolbarHeight + ? _value.toolbarHeight + : toolbarHeight // ignore: cast_nullable_to_non_nullable + as double, + leadingWidth: freezed == leadingWidth + ? _value.leadingWidth + : leadingWidth // ignore: cast_nullable_to_non_nullable + as double?, + toolbarTextStyle: freezed == toolbarTextStyle + ? _value.toolbarTextStyle + : toolbarTextStyle // ignore: cast_nullable_to_non_nullable + as StacTextStyle?, + titleTextStyle: freezed == titleTextStyle + ? _value.titleTextStyle + : titleTextStyle // ignore: cast_nullable_to_non_nullable + as StacTextStyle?, + systemOverlayStyle: freezed == systemOverlayStyle + ? _value.systemOverlayStyle + : systemOverlayStyle // ignore: cast_nullable_to_non_nullable + as StacSystemUIOverlayStyle?, + forceMaterialTransparency: null == forceMaterialTransparency + ? _value.forceMaterialTransparency + : forceMaterialTransparency // ignore: cast_nullable_to_non_nullable + as bool, + clipBehavior: freezed == clipBehavior + ? _value.clipBehavior + : clipBehavior // ignore: cast_nullable_to_non_nullable + as Clip?, + actionsPadding: freezed == actionsPadding + ? _value.actionsPadding + : actionsPadding // ignore: cast_nullable_to_non_nullable + as StacEdgeInsets?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StacSliverAppBarImpl implements _StacSliverAppBar { + const _$StacSliverAppBarImpl( + {final Map? leading, + this.automaticallyImplyLeading = true, + final Map? title, + final List>? actions, + final Map? flexibleSpace, + final Map? bottom, + this.elevation, + this.scrolledUnderElevation, + this.shadowColor, + this.surfaceTintColor, + this.forceElevated = false, + this.backgroundColor, + this.foregroundColor, + this.iconTheme, + this.actionsIconTheme, + this.primary = true, + this.centerTitle, + this.excludeHeaderSemantics = false, + this.titleSpacing, + this.collapsedHeight, + this.expandedHeight, + this.floating = false, + this.pinned = true, + this.snap = false, + this.stretch = false, + this.stretchTriggerOffset = 100.0, + this.shape, + this.toolbarHeight = 64.0, + this.leadingWidth, + this.toolbarTextStyle, + this.titleTextStyle, + this.systemOverlayStyle, + this.forceMaterialTransparency = false, + this.clipBehavior, + this.actionsPadding}) + : _leading = leading, + _title = title, + _actions = actions, + _flexibleSpace = flexibleSpace, + _bottom = bottom; + + factory _$StacSliverAppBarImpl.fromJson(Map json) => + _$$StacSliverAppBarImplFromJson(json); + + final Map? _leading; + @override + Map? get leading { + final value = _leading; + if (value == null) return null; + if (_leading is EqualUnmodifiableMapView) return _leading; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + @JsonKey() + final bool automaticallyImplyLeading; + final Map? _title; + @override + Map? get title { + final value = _title; + if (value == null) return null; + if (_title is EqualUnmodifiableMapView) return _title; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + final List>? _actions; + @override + List>? get actions { + final value = _actions; + if (value == null) return null; + if (_actions is EqualUnmodifiableListView) return _actions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final Map? _flexibleSpace; + @override + Map? get flexibleSpace { + final value = _flexibleSpace; + if (value == null) return null; + if (_flexibleSpace is EqualUnmodifiableMapView) return _flexibleSpace; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + final Map? _bottom; + @override + Map? get bottom { + final value = _bottom; + if (value == null) return null; + if (_bottom is EqualUnmodifiableMapView) return _bottom; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + final double? elevation; + @override + final double? scrolledUnderElevation; + @override + final String? shadowColor; + @override + final String? surfaceTintColor; + @override + @JsonKey() + final bool forceElevated; + @override + final String? backgroundColor; + @override + final String? foregroundColor; + @override + final StacIconThemeData? iconTheme; + @override + final StacIconThemeData? actionsIconTheme; + @override + @JsonKey() + final bool primary; + @override + final bool? centerTitle; + @override + @JsonKey() + final bool excludeHeaderSemantics; + @override + final double? titleSpacing; + @override + final double? collapsedHeight; + @override + final double? expandedHeight; + @override + @JsonKey() + final bool floating; + @override + @JsonKey() + final bool pinned; + @override + @JsonKey() + final bool snap; + @override + @JsonKey() + final bool stretch; + @override + @JsonKey() + final double stretchTriggerOffset; + @override + final StacShapeBorder? shape; +// StacAsyncCallback? onStretchTrigger, TODO: Implement StacAsyncCallback + @override + @JsonKey() + final double toolbarHeight; + @override + final double? leadingWidth; + @override + final StacTextStyle? toolbarTextStyle; + @override + final StacTextStyle? titleTextStyle; + @override + final StacSystemUIOverlayStyle? systemOverlayStyle; + @override + @JsonKey() + final bool forceMaterialTransparency; + @override + final Clip? clipBehavior; + @override + final StacEdgeInsets? actionsPadding; + + @override + String toString() { + return 'StacSliverAppBar(leading: $leading, automaticallyImplyLeading: $automaticallyImplyLeading, title: $title, actions: $actions, flexibleSpace: $flexibleSpace, bottom: $bottom, elevation: $elevation, scrolledUnderElevation: $scrolledUnderElevation, shadowColor: $shadowColor, surfaceTintColor: $surfaceTintColor, forceElevated: $forceElevated, backgroundColor: $backgroundColor, foregroundColor: $foregroundColor, iconTheme: $iconTheme, actionsIconTheme: $actionsIconTheme, primary: $primary, centerTitle: $centerTitle, excludeHeaderSemantics: $excludeHeaderSemantics, titleSpacing: $titleSpacing, collapsedHeight: $collapsedHeight, expandedHeight: $expandedHeight, floating: $floating, pinned: $pinned, snap: $snap, stretch: $stretch, stretchTriggerOffset: $stretchTriggerOffset, shape: $shape, toolbarHeight: $toolbarHeight, leadingWidth: $leadingWidth, toolbarTextStyle: $toolbarTextStyle, titleTextStyle: $titleTextStyle, systemOverlayStyle: $systemOverlayStyle, forceMaterialTransparency: $forceMaterialTransparency, clipBehavior: $clipBehavior, actionsPadding: $actionsPadding)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StacSliverAppBarImpl && + const DeepCollectionEquality().equals(other._leading, _leading) && + (identical(other.automaticallyImplyLeading, + automaticallyImplyLeading) || + other.automaticallyImplyLeading == automaticallyImplyLeading) && + const DeepCollectionEquality().equals(other._title, _title) && + const DeepCollectionEquality().equals(other._actions, _actions) && + const DeepCollectionEquality() + .equals(other._flexibleSpace, _flexibleSpace) && + const DeepCollectionEquality().equals(other._bottom, _bottom) && + (identical(other.elevation, elevation) || + other.elevation == elevation) && + (identical(other.scrolledUnderElevation, scrolledUnderElevation) || + other.scrolledUnderElevation == scrolledUnderElevation) && + (identical(other.shadowColor, shadowColor) || + other.shadowColor == shadowColor) && + (identical(other.surfaceTintColor, surfaceTintColor) || + other.surfaceTintColor == surfaceTintColor) && + (identical(other.forceElevated, forceElevated) || + other.forceElevated == forceElevated) && + (identical(other.backgroundColor, backgroundColor) || + other.backgroundColor == backgroundColor) && + (identical(other.foregroundColor, foregroundColor) || + other.foregroundColor == foregroundColor) && + (identical(other.iconTheme, iconTheme) || + other.iconTheme == iconTheme) && + (identical(other.actionsIconTheme, actionsIconTheme) || + other.actionsIconTheme == actionsIconTheme) && + (identical(other.primary, primary) || other.primary == primary) && + (identical(other.centerTitle, centerTitle) || + other.centerTitle == centerTitle) && + (identical(other.excludeHeaderSemantics, excludeHeaderSemantics) || + other.excludeHeaderSemantics == excludeHeaderSemantics) && + (identical(other.titleSpacing, titleSpacing) || + other.titleSpacing == titleSpacing) && + (identical(other.collapsedHeight, collapsedHeight) || + other.collapsedHeight == collapsedHeight) && + (identical(other.expandedHeight, expandedHeight) || + other.expandedHeight == expandedHeight) && + (identical(other.floating, floating) || + other.floating == floating) && + (identical(other.pinned, pinned) || other.pinned == pinned) && + (identical(other.snap, snap) || other.snap == snap) && + (identical(other.stretch, stretch) || other.stretch == stretch) && + (identical(other.stretchTriggerOffset, stretchTriggerOffset) || + other.stretchTriggerOffset == stretchTriggerOffset) && + (identical(other.shape, shape) || other.shape == shape) && + (identical(other.toolbarHeight, toolbarHeight) || + other.toolbarHeight == toolbarHeight) && + (identical(other.leadingWidth, leadingWidth) || + other.leadingWidth == leadingWidth) && + (identical(other.toolbarTextStyle, toolbarTextStyle) || + other.toolbarTextStyle == toolbarTextStyle) && + (identical(other.titleTextStyle, titleTextStyle) || + other.titleTextStyle == titleTextStyle) && + (identical(other.systemOverlayStyle, systemOverlayStyle) || + other.systemOverlayStyle == systemOverlayStyle) && + (identical(other.forceMaterialTransparency, + forceMaterialTransparency) || + other.forceMaterialTransparency == forceMaterialTransparency) && + (identical(other.clipBehavior, clipBehavior) || + other.clipBehavior == clipBehavior) && + (identical(other.actionsPadding, actionsPadding) || + other.actionsPadding == actionsPadding)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hashAll([ + runtimeType, + const DeepCollectionEquality().hash(_leading), + automaticallyImplyLeading, + const DeepCollectionEquality().hash(_title), + const DeepCollectionEquality().hash(_actions), + const DeepCollectionEquality().hash(_flexibleSpace), + const DeepCollectionEquality().hash(_bottom), + elevation, + scrolledUnderElevation, + shadowColor, + surfaceTintColor, + forceElevated, + backgroundColor, + foregroundColor, + iconTheme, + actionsIconTheme, + primary, + centerTitle, + excludeHeaderSemantics, + titleSpacing, + collapsedHeight, + expandedHeight, + floating, + pinned, + snap, + stretch, + stretchTriggerOffset, + shape, + toolbarHeight, + leadingWidth, + toolbarTextStyle, + titleTextStyle, + systemOverlayStyle, + forceMaterialTransparency, + clipBehavior, + actionsPadding + ]); + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$StacSliverAppBarImplCopyWith<_$StacSliverAppBarImpl> get copyWith => + __$$StacSliverAppBarImplCopyWithImpl<_$StacSliverAppBarImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$StacSliverAppBarImplToJson( + this, + ); + } +} + +abstract class _StacSliverAppBar implements StacSliverAppBar { + const factory _StacSliverAppBar( + {final Map? leading, + final bool automaticallyImplyLeading, + final Map? title, + final List>? actions, + final Map? flexibleSpace, + final Map? bottom, + final double? elevation, + final double? scrolledUnderElevation, + final String? shadowColor, + final String? surfaceTintColor, + final bool forceElevated, + final String? backgroundColor, + final String? foregroundColor, + final StacIconThemeData? iconTheme, + final StacIconThemeData? actionsIconTheme, + final bool primary, + final bool? centerTitle, + final bool excludeHeaderSemantics, + final double? titleSpacing, + final double? collapsedHeight, + final double? expandedHeight, + final bool floating, + final bool pinned, + final bool snap, + final bool stretch, + final double stretchTriggerOffset, + final StacShapeBorder? shape, + final double toolbarHeight, + final double? leadingWidth, + final StacTextStyle? toolbarTextStyle, + final StacTextStyle? titleTextStyle, + final StacSystemUIOverlayStyle? systemOverlayStyle, + final bool forceMaterialTransparency, + final Clip? clipBehavior, + final StacEdgeInsets? actionsPadding}) = _$StacSliverAppBarImpl; + + factory _StacSliverAppBar.fromJson(Map json) = + _$StacSliverAppBarImpl.fromJson; + + @override + Map? get leading; + @override + bool get automaticallyImplyLeading; + @override + Map? get title; + @override + List>? get actions; + @override + Map? get flexibleSpace; + @override + Map? get bottom; + @override + double? get elevation; + @override + double? get scrolledUnderElevation; + @override + String? get shadowColor; + @override + String? get surfaceTintColor; + @override + bool get forceElevated; + @override + String? get backgroundColor; + @override + String? get foregroundColor; + @override + StacIconThemeData? get iconTheme; + @override + StacIconThemeData? get actionsIconTheme; + @override + bool get primary; + @override + bool? get centerTitle; + @override + bool get excludeHeaderSemantics; + @override + double? get titleSpacing; + @override + double? get collapsedHeight; + @override + double? get expandedHeight; + @override + bool get floating; + @override + bool get pinned; + @override + bool get snap; + @override + bool get stretch; + @override + double get stretchTriggerOffset; + @override + StacShapeBorder? + get shape; // StacAsyncCallback? onStretchTrigger, TODO: Implement StacAsyncCallback + @override + double get toolbarHeight; + @override + double? get leadingWidth; + @override + StacTextStyle? get toolbarTextStyle; + @override + StacTextStyle? get titleTextStyle; + @override + StacSystemUIOverlayStyle? get systemOverlayStyle; + @override + bool get forceMaterialTransparency; + @override + Clip? get clipBehavior; + @override + StacEdgeInsets? get actionsPadding; + + /// Create a copy of StacSliverAppBar + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$StacSliverAppBarImplCopyWith<_$StacSliverAppBarImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.g.dart b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.g.dart new file mode 100644 index 00000000..a1f3b276 --- /dev/null +++ b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.g.dart @@ -0,0 +1,117 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stac_sliver_app_bar.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$StacSliverAppBarImpl _$$StacSliverAppBarImplFromJson( + Map json) => + _$StacSliverAppBarImpl( + leading: json['leading'] as Map?, + automaticallyImplyLeading: + json['automaticallyImplyLeading'] as bool? ?? true, + title: json['title'] as Map?, + actions: (json['actions'] as List?) + ?.map((e) => e as Map) + .toList(), + flexibleSpace: json['flexibleSpace'] as Map?, + bottom: json['bottom'] as Map?, + elevation: (json['elevation'] as num?)?.toDouble(), + scrolledUnderElevation: + (json['scrolledUnderElevation'] as num?)?.toDouble(), + shadowColor: json['shadowColor'] as String?, + surfaceTintColor: json['surfaceTintColor'] as String?, + forceElevated: json['forceElevated'] as bool? ?? false, + backgroundColor: json['backgroundColor'] as String?, + foregroundColor: json['foregroundColor'] as String?, + iconTheme: json['iconTheme'] == null + ? null + : StacIconThemeData.fromJson( + json['iconTheme'] as Map), + actionsIconTheme: json['actionsIconTheme'] == null + ? null + : StacIconThemeData.fromJson( + json['actionsIconTheme'] as Map), + primary: json['primary'] as bool? ?? true, + centerTitle: json['centerTitle'] as bool?, + excludeHeaderSemantics: json['excludeHeaderSemantics'] as bool? ?? false, + titleSpacing: (json['titleSpacing'] as num?)?.toDouble(), + collapsedHeight: (json['collapsedHeight'] as num?)?.toDouble(), + expandedHeight: (json['expandedHeight'] as num?)?.toDouble(), + floating: json['floating'] as bool? ?? false, + pinned: json['pinned'] as bool? ?? true, + snap: json['snap'] as bool? ?? false, + stretch: json['stretch'] as bool? ?? false, + stretchTriggerOffset: + (json['stretchTriggerOffset'] as num?)?.toDouble() ?? 100.0, + shape: json['shape'] == null + ? null + : StacShapeBorder.fromJson(json['shape'] as Map), + toolbarHeight: (json['toolbarHeight'] as num?)?.toDouble() ?? 64.0, + leadingWidth: (json['leadingWidth'] as num?)?.toDouble(), + toolbarTextStyle: json['toolbarTextStyle'] == null + ? null + : StacTextStyle.fromJson(json['toolbarTextStyle']), + titleTextStyle: json['titleTextStyle'] == null + ? null + : StacTextStyle.fromJson(json['titleTextStyle']), + systemOverlayStyle: json['systemOverlayStyle'] == null + ? null + : StacSystemUIOverlayStyle.fromJson( + json['systemOverlayStyle'] as Map), + forceMaterialTransparency: + json['forceMaterialTransparency'] as bool? ?? false, + clipBehavior: $enumDecodeNullable(_$ClipEnumMap, json['clipBehavior']), + actionsPadding: json['actionsPadding'] == null + ? null + : StacEdgeInsets.fromJson(json['actionsPadding']), + ); + +Map _$$StacSliverAppBarImplToJson( + _$StacSliverAppBarImpl instance) => + { + 'leading': instance.leading, + 'automaticallyImplyLeading': instance.automaticallyImplyLeading, + 'title': instance.title, + 'actions': instance.actions, + 'flexibleSpace': instance.flexibleSpace, + 'bottom': instance.bottom, + 'elevation': instance.elevation, + 'scrolledUnderElevation': instance.scrolledUnderElevation, + 'shadowColor': instance.shadowColor, + 'surfaceTintColor': instance.surfaceTintColor, + 'forceElevated': instance.forceElevated, + 'backgroundColor': instance.backgroundColor, + 'foregroundColor': instance.foregroundColor, + 'iconTheme': instance.iconTheme, + 'actionsIconTheme': instance.actionsIconTheme, + 'primary': instance.primary, + 'centerTitle': instance.centerTitle, + 'excludeHeaderSemantics': instance.excludeHeaderSemantics, + 'titleSpacing': instance.titleSpacing, + 'collapsedHeight': instance.collapsedHeight, + 'expandedHeight': instance.expandedHeight, + 'floating': instance.floating, + 'pinned': instance.pinned, + 'snap': instance.snap, + 'stretch': instance.stretch, + 'stretchTriggerOffset': instance.stretchTriggerOffset, + 'shape': instance.shape, + 'toolbarHeight': instance.toolbarHeight, + 'leadingWidth': instance.leadingWidth, + 'toolbarTextStyle': instance.toolbarTextStyle, + 'titleTextStyle': instance.titleTextStyle, + 'systemOverlayStyle': instance.systemOverlayStyle, + 'forceMaterialTransparency': instance.forceMaterialTransparency, + 'clipBehavior': _$ClipEnumMap[instance.clipBehavior], + 'actionsPadding': instance.actionsPadding, + }; + +const _$ClipEnumMap = { + Clip.none: 'none', + Clip.hardEdge: 'hardEdge', + Clip.antiAlias: 'antiAlias', + Clip.antiAliasWithSaveLayer: 'antiAliasWithSaveLayer', +}; diff --git a/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart new file mode 100644 index 00000000..7f1bcb20 --- /dev/null +++ b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'package:stac/src/parsers/stac_icon_theme_data/stac_icon_theme_data.dart'; +import 'package:stac/src/parsers/stac_shape_border/stac_shape_border.dart'; +import 'package:stac/src/parsers/stac_system_ui_olverlay_style/stac_system_ui_overlay_style.dart'; + +import '../../../stac.dart'; +import '../../utils/widget_type.dart'; + +class StacSliverAppBarParser extends StacParser { + const StacSliverAppBarParser(); + + @override + String get type => WidgetType.sliverAppBar.name; + + @override + StacSliverAppBar getModel(Map json) => + StacSliverAppBar.fromJson(json); + + @override + Widget parse(BuildContext context, StacSliverAppBar model) { + return SliverAppBar( + leading: Stac.fromJson(model.leading, context), + automaticallyImplyLeading: model.automaticallyImplyLeading, + title: Stac.fromJson(model.title, context), + actions: model.actions + ?.map((e) => Stac.fromJson(e, context) ?? const SizedBox.shrink()) + .toList(growable: false), + flexibleSpace: Stac.fromJson(model.flexibleSpace, context), + bottom: Stac.fromJson(model.bottom, context).toPreferredSizeWidget, + elevation: model.elevation, + scrolledUnderElevation: model.scrolledUnderElevation, + shadowColor: model.shadowColor.toColor(context), + surfaceTintColor: model.surfaceTintColor.toColor(context), + forceElevated: model.forceElevated, + backgroundColor: model.backgroundColor.toColor(context), + foregroundColor: model.foregroundColor.toColor(context), + iconTheme: model.iconTheme?.parse(context), + actionsIconTheme: model.actionsIconTheme?.parse(context), + primary: model.primary, + centerTitle: model.centerTitle, + excludeHeaderSemantics: model.excludeHeaderSemantics, + titleSpacing: model.titleSpacing, + collapsedHeight: model.collapsedHeight, + expandedHeight: model.expandedHeight, + floating: model.floating, + pinned: model.pinned, + snap: model.snap, + stretch: model.stretch, + stretchTriggerOffset: model.stretchTriggerOffset, + shape: model.shape?.parse(context), + toolbarHeight: model.toolbarHeight, + leadingWidth: model.leadingWidth, + toolbarTextStyle: model.toolbarTextStyle?.parse(context), + titleTextStyle: model.titleTextStyle?.parse(context), + systemOverlayStyle: model.systemOverlayStyle?.parse(context), + forceMaterialTransparency: model.forceMaterialTransparency, + clipBehavior: model.clipBehavior, + actionsPadding: model.actionsPadding?.parse, + ); + } +} diff --git a/packages/stac/lib/src/utils/widget_type.dart b/packages/stac/lib/src/utils/widget_type.dart index 2033b652..948de976 100644 --- a/packages/stac/lib/src/utils/widget_type.dart +++ b/packages/stac/lib/src/utils/widget_type.dart @@ -9,6 +9,7 @@ enum WidgetType { stack, positioned, container, + customScrollView, image, icon, iconButton, @@ -60,6 +61,7 @@ enum WidgetType { radio, radioGroup, slider, + sliverAppBar, opacity, placeholder, aspectRatio, From 3cabd71c46c5f56f4e93140f17706ba0bbc5b431 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 20 Feb 2025 15:32:26 +0530 Subject: [PATCH 2/5] removed unused import --- .../stac_custom_scroll_view/stac_custom_scroll_view_parser.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart index 957cd586..ddbee1a0 100644 --- a/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart +++ b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import '../../../stac.dart'; import '../../utils/widget_type.dart'; -import 'stac_custom_scroll_view.dart'; class StacCustomScrollViewParser extends StacParser { const StacCustomScrollViewParser({this.controller}); From 8536c9d272a6413fdb889d3b44b3a53b6e0628fb Mon Sep 17 00:00:00 2001 From: nikhil Date: Sat, 22 Feb 2025 10:36:09 +0530 Subject: [PATCH 3/5] add sliver app bar & custom scroll view documentation fixing formatting --- examples/counter_example/pubspec.lock | 2 +- examples/stac_gallery/pubspec.lock | 2 +- website/docs/widgets/custom_scroll_view.md | 47 ++++++++++++++ website/docs/widgets/sliver_app_bar.md | 75 ++++++++++++++++++++++ 4 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 website/docs/widgets/custom_scroll_view.md create mode 100644 website/docs/widgets/sliver_app_bar.md diff --git a/examples/counter_example/pubspec.lock b/examples/counter_example/pubspec.lock index 2906f7e4..22604bbb 100644 --- a/examples/counter_example/pubspec.lock +++ b/examples/counter_example/pubspec.lock @@ -539,7 +539,7 @@ packages: path: "../../packages/stac" relative: true source: path - version: "0.9.3" + version: "0.10.0" stac_framework: dependency: "direct overridden" description: diff --git a/examples/stac_gallery/pubspec.lock b/examples/stac_gallery/pubspec.lock index 865d912b..b139218f 100644 --- a/examples/stac_gallery/pubspec.lock +++ b/examples/stac_gallery/pubspec.lock @@ -547,7 +547,7 @@ packages: path: "../../packages/stac" relative: true source: path - version: "0.9.3" + version: "0.10.0" stac_framework: dependency: "direct overridden" description: diff --git a/website/docs/widgets/custom_scroll_view.md b/website/docs/widgets/custom_scroll_view.md new file mode 100644 index 00000000..1b03adca --- /dev/null +++ b/website/docs/widgets/custom_scroll_view.md @@ -0,0 +1,47 @@ +# CustomScrollView + +The Stac CustomScrollView allows you to build a Flutter CustomScrollView widget using JSON. +To know more about the CustomScrollView widget in Flutter, refer to +the [official documentation](https://api.flutter.dev/flutter/widgets/CustomScrollView-class.html). + +## Properties + +| Property | Type | Description | +|-------------------------|-------------------------------------|---------------------------------------------------------------------------------------------------------------------| +| slivers | `List>` | The slivers to place inside the viewport. | +| scrollDirection | `Axis` | The axis along which the scroll view scrolls. Defaults to `Axis.vertical`. | +| reverse | `bool` | Whether the scroll view scrolls in the reverse direction. Defaults to `false`. | +| padding | `StacEdgeInsets?` | The amount of space by which to inset the child. | +| primary | `bool?` | Whether this is the primary scroll view associated with the parent. | +| physics | `StacScrollPhysics?` | How the scroll view should respond to user input. | +| dragStartBehavior | `DragStartBehavior` | Determines the way that drag start behavior is handled. Defaults to `DragStartBehavior.start`. | +| clipBehavior | `Clip` | The content will be clipped (or not) according to this option. Defaults to `Clip.hardEdge`. | +| restorationId | `String?` | The restoration ID to save and restore the state of the scroll view. | +| keyboardDismissBehavior | `ScrollViewKeyboardDismissBehavior` | Configures how the scroll view should dismiss the keyboard. Defaults to `ScrollViewKeyboardDismissBehavior.manual`. | + +## Example JSON + +```json +{ + "type": "customScrollView", + "slivers": [ + { + "type": "sliverAppBar", + "title": { + "type": "text", + "data": "SliverAppBar" + }, + "leading": { + "type": "iconButton", + "icon": { + "type": "icon", + "iconType": "material", + "icon": "menu" + }, + "onPressed": {} + }, + "backgroundColor": "primary", + } + ] +} +``` \ No newline at end of file diff --git a/website/docs/widgets/sliver_app_bar.md b/website/docs/widgets/sliver_app_bar.md new file mode 100644 index 00000000..12db7bcf --- /dev/null +++ b/website/docs/widgets/sliver_app_bar.md @@ -0,0 +1,75 @@ +# SliverAppBar + +The Stac SliverAppBar allows you to build a Flutter sliver app bar widget using JSON. +To know more about the app bar widget in Flutter, refer to +the [official documentation](https://api.flutter.dev/flutter/material/SliverAppBar-class.html). + +## Properties + +| Property | Type | Description | +|------------------------|------------------------------|-------------------------------------------------------------------------------------------------| +| leading | `Map?` | The leading widget before the title. | +| title | `Map?` | The title widget. | +| titleTextStyle | `StacTextStyle?` | The text style for the title. | +| toolbarTextStyle | `StacTextStyle?` | The text style for the toolbar. | +| shadowColor | `String?` | The color of the shadow below the app bar. | +| backgroundColor | `String?` | The background color of the app bar. | +| foregroundColor | `String?` | The color of the app bar's foreground elements. | +| surfaceTintColor | `String?` | The surface tint color of the app bar. | +| actions | `List>` | The list of widgets to display in a row after the title. Defaults to an empty list. | +| bottom | `Map?` | The bottom widget of the app bar. | +| titleSpacing | `double?` | The spacing around the title. | +| toolbarOpacity | `double` | The opacity of the toolbar. Defaults to `1.0`. | +| bottomOpacity | `double` | The opacity of the bottom widget. Defaults to `1.0`. | +| toolbarHeight | `double?` | The height of the toolbar. | +| leadingWidth | `double?` | The width of the leading widget. | +| primary | `bool` | Whether this app bar is the primary app bar for the scaffold. Defaults to `true`. | +| centerTitle | `bool?` | Whether the title should be centered. | +| elevation | `double?` | The elevation of the app bar. | +| scrolledUnderElevation | `double?` | The elevation of the app bar when it is scrolled under. | +| flexibleSpace | `Map?` | This widget is stacked behind the toolbar and the tab bar. | +| expandedHeight | `double?` | The size of the app bar when it is fully expanded. | +| collapsedHeight | `double?` | The height of the app bar when it is collapsed. | +| titleSpacing | `double?` | The spacing around title content on the horizontal axis. | +| floating | `bool` | Makes the app bar visible as soon as the user scrolls towards the app bar. Defaults to `false`. | +| pinned | `bool` | Makes the app bar visible at the start of the scroll view. Defaults to `true`. | +| snap | `bool` | Controls the snap behaviour of AppBar. Defaults to `false`. | +| stretch | `bool` | Whether the app bar should stretch to fill the over-scroll area. Defaults to `false`. | +| stretchTriggerOffset | `double?` | The offset of overscroll required to activate `onStretchTrigger`. | +| shape | `Map?` | The shape of the app bar's Material as well as its shadow. | +| iconTheme | `Map?` | The color, opacity, and size to use for toolbar icons. | +| actionsIconTheme | `Map?` | The color, opacity, and size to use for the icons that appear in the app bar's actions. | +| actionsPadding | `Map?` | The padding between the actions and the end of the AppBar. | + +## Example JSON + +```json +{ + "type": "sliverAppBar", + "title": { + "type": "text", + "data": "SliverAppBar" + }, + "leading": { + "type": "iconButton", + "icon": { + "type": "icon", + "iconType": "material", + "icon": "menu" + }, + "onPressed": {} + }, + "backgroundColor": "primary", + "actions": [ + { + "type": "iconButton", + "icon": { + "type": "icon", + "iconType": "cupertino", + "icon": "heart_solid" + }, + "onPressed": {} + } + ] +} +``` \ No newline at end of file From 837f192eca1902566782786bde3047b3ac948d81 Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 26 Feb 2025 20:40:27 +0530 Subject: [PATCH 4/5] minor updates --- .../stac_custom_scroll_view_parser.dart | 10 +++------- .../stac_sliver_app_bar_parser.dart | 5 ++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart index ddbee1a0..f17fee0a 100644 --- a/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart +++ b/packages/stac/lib/src/parsers/stac_custom_scroll_view/stac_custom_scroll_view_parser.dart @@ -1,13 +1,9 @@ import 'package:flutter/material.dart'; - -import '../../../stac.dart'; -import '../../utils/widget_type.dart'; +import 'package:stac/src/utils/widget_type.dart'; +import 'package:stac/stac.dart'; class StacCustomScrollViewParser extends StacParser { - const StacCustomScrollViewParser({this.controller}); - - final ScrollController? controller; - + const StacCustomScrollViewParser(); @override String get type => WidgetType.customScrollView.name; diff --git a/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart index 7f1bcb20..62e8ee78 100644 --- a/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart +++ b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar_parser.dart @@ -2,9 +2,8 @@ import 'package:flutter/material.dart'; import 'package:stac/src/parsers/stac_icon_theme_data/stac_icon_theme_data.dart'; import 'package:stac/src/parsers/stac_shape_border/stac_shape_border.dart'; import 'package:stac/src/parsers/stac_system_ui_olverlay_style/stac_system_ui_overlay_style.dart'; - -import '../../../stac.dart'; -import '../../utils/widget_type.dart'; +import 'package:stac/src/utils/widget_type.dart'; +import 'package:stac/stac.dart'; class StacSliverAppBarParser extends StacParser { const StacSliverAppBarParser(); From 02901b284c38d8e3e629551138c6f484ae262613 Mon Sep 17 00:00:00 2001 From: nikhil Date: Wed, 26 Feb 2025 22:19:38 +0530 Subject: [PATCH 5/5] fixes --- .../src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart index 04ccf150..56581d1b 100644 --- a/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart +++ b/packages/stac/lib/src/parsers/stac_sliver_app_bar/stac_sliver_app_bar.dart @@ -2,9 +2,8 @@ import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:stac/src/parsers/stac_icon_theme_data/stac_icon_theme_data.dart'; import 'package:stac/src/parsers/stac_shape_border/stac_shape_border.dart'; - -import '../../../stac.dart'; -import '../stac_system_ui_olverlay_style/stac_system_ui_overlay_style.dart'; +import 'package:stac/src/parsers/stac_system_ui_olverlay_style/stac_system_ui_overlay_style.dart'; +import 'package:stac/stac.dart'; part 'stac_sliver_app_bar.freezed.dart'; part 'stac_sliver_app_bar.g.dart';