From a7f8c39030031359a049757578f0dc93a3b6841a Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 11 Sep 2024 12:48:23 +0300 Subject: [PATCH] feat(plans): add plans, refactor descriptions in recipes, diets, blogPost --- lib/app_router.dart | 9 + .../presentation/pages/blog_post_screen.dart | 26 +- .../presentation/pages/about_diet_screen.dart | 22 +- .../feed/presentation/pages/feed_screen.dart | 67 +- .../presentation/widgets/diets_widget.dart | 16 +- .../presentation/widgets/plan_widget.dart | 173 +++ .../presentation/widgets/recipes_widget.dart | 16 +- .../plans/models/plan_pagination_model.dart | 65 + .../models/plan_pagination_model.freezed.dart | 1251 +++++++++++++++++ .../plans/models/plan_pagination_model.g.dart | 95 ++ .../bloc/plans_cubit/plans_cubit.dart | 19 + .../bloc/plans_cubit/plans_state.dart | 19 + .../bloc/plans_cubit/plans_state.freezed.dart | 646 +++++++++ .../presentation/pages/about_plan_screen.dart | 20 + .../plans/repositories/plans_repository.dart | 16 + .../plans/services/plans_service.dart | 13 + .../plans/services/plans_service.g.dart | 86 ++ .../pages/about_recipes_screen.dart | 22 +- lib/locator_service.dart | 6 + lib/main.dart | 3 + pubspec.yaml | 4 +- 21 files changed, 2529 insertions(+), 65 deletions(-) create mode 100644 lib/features/feed/presentation/widgets/plan_widget.dart create mode 100644 lib/features/plans/models/plan_pagination_model.dart create mode 100644 lib/features/plans/models/plan_pagination_model.freezed.dart create mode 100644 lib/features/plans/models/plan_pagination_model.g.dart create mode 100644 lib/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart create mode 100644 lib/features/plans/presentation/bloc/plans_cubit/plans_state.dart create mode 100644 lib/features/plans/presentation/bloc/plans_cubit/plans_state.freezed.dart create mode 100644 lib/features/plans/presentation/pages/about_plan_screen.dart create mode 100644 lib/features/plans/repositories/plans_repository.dart create mode 100644 lib/features/plans/services/plans_service.dart create mode 100644 lib/features/plans/services/plans_service.g.dart diff --git a/lib/app_router.dart b/lib/app_router.dart index 6e4bac50..2851b3c6 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -15,6 +15,8 @@ import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart'; import 'package:eatvio_app/features/menu/presentation/pages/menu_screen.dart'; import 'package:eatvio_app/features/notifications/presentation/pages/notifications_screen.dart'; +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:eatvio_app/features/plans/presentation/pages/about_plan_screen.dart'; import 'package:eatvio_app/features/profile/presentation/pages/profile_screen.dart'; import 'package:eatvio_app/features/recipes/presentation/pages/about_recipes_screen.dart'; import 'package:eatvio_app/features/recipes/presentation/pages/recipe_create_screen.dart'; @@ -103,6 +105,13 @@ class AppRouter { ), ], ), + GoRoute( + path: '/about-plan-screen', + name: 'aboutPlanScreen', + builder: (context, state) => AboutPlanScreen( + planModel: state.extra as PlanModel, + ), + ), GoRoute( path: '/about-recipes-screen', name: 'aboutRecipesScreen', diff --git a/lib/features/blog_post/presentation/pages/blog_post_screen.dart b/lib/features/blog_post/presentation/pages/blog_post_screen.dart index 3114518a..1fcacce8 100644 --- a/lib/features/blog_post/presentation/pages/blog_post_screen.dart +++ b/lib/features/blog_post/presentation/pages/blog_post_screen.dart @@ -1,5 +1,4 @@ import 'dart:io'; - import 'package:cached_network_image/cached_network_image.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; @@ -9,6 +8,7 @@ import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; import 'package:share_plus/share_plus.dart'; @@ -228,22 +228,18 @@ class _BlogPostScreenState extends State { ), ), ), - if (widget.blogPost.description.isNotEmpty) SizedBox(height: 12), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Align( - alignment: Alignment.centerLeft, - child: Text( - widget.blogPost.description, - style: TextStyle( - color: Colors.black, - fontSize: 14, - fontWeight: FontWeight.w400, - height: 1, - ), + if (widget.blogPost.description.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Html( + data: widget.blogPost.description, + style: { + "*": Style( + color: Colors.black87, + ), + }, ), ), - ), SizedBox(height: 8), CachedNetworkImage( imageUrl: baseUrl + '/storage/' + (widget.blogPost.image), diff --git a/lib/features/diets/presentation/pages/about_diet_screen.dart b/lib/features/diets/presentation/pages/about_diet_screen.dart index 9262b194..e78dab2c 100644 --- a/lib/features/diets/presentation/pages/about_diet_screen.dart +++ b/lib/features/diets/presentation/pages/about_diet_screen.dart @@ -7,6 +7,7 @@ import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/commen import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; class AboutDietScreen extends StatefulWidget { @@ -261,19 +262,18 @@ class _AboutDietScreenState extends State { ], ), ), - SizedBox(height: 12), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Text( - widget.diet.details, - style: TextStyle( - color: Colors.black, - fontSize: 14, - fontWeight: FontWeight.w400, - height: 1.2, + if (widget.diet.details.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Html( + data: widget.diet.details, + style: { + "*": Style( + color: Colors.black87, + ), + }, ), ), - ), SizedBox(height: 12), CachedNetworkImage( imageUrl: baseUrl + '/storage/' + widget.diet.image, diff --git a/lib/features/feed/presentation/pages/feed_screen.dart b/lib/features/feed/presentation/pages/feed_screen.dart index e5f1afa6..957ea8a5 100644 --- a/lib/features/feed/presentation/pages/feed_screen.dart +++ b/lib/features/feed/presentation/pages/feed_screen.dart @@ -7,8 +7,11 @@ import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_state.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/blog_post_widget.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/diets_widget.dart'; +import 'package:eatvio_app/features/feed/presentation/widgets/plan_widget.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/recipes_widget.dart'; import 'package:eatvio_app/features/feed/presentation/widgets/tags_modal_widget.dart'; +import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart'; +import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_state.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -30,12 +33,14 @@ class _FeedScreenState extends State { final blogPostsScrollController = ScrollController(); final recipesScrollController = ScrollController(); final dietsScrollController = ScrollController(); + final plansScrollController = ScrollController(); @override void initState() { blogPostsScrollController.addListener(_onScrollBlogPosts); - recipesScrollController.addListener(_onScrollBlogRecipes); - dietsScrollController.addListener(_onScrollBlogDiets); + recipesScrollController.addListener(_onScrollRecipes); + dietsScrollController.addListener(_onScrollDiets); + plansScrollController.addListener(_onScrollPlans); super.initState(); } @@ -45,23 +50,18 @@ class _FeedScreenState extends State { } } - _onScrollBlogRecipes() { - if (blogPostsScrollController.offset >= blogPostsScrollController.position.maxScrollExtent && !blogPostsScrollController.position.outOfRange) { - context.read().loadNextPage(); - } - } + _onScrollRecipes() {} - _onScrollBlogDiets() { - if (blogPostsScrollController.offset >= blogPostsScrollController.position.maxScrollExtent && !blogPostsScrollController.position.outOfRange) { - context.read().loadNextPage(); - } - } + _onScrollDiets() {} + + _onScrollPlans() {} @override void dispose() { blogPostsScrollController.dispose(); recipesScrollController.dispose(); dietsScrollController.dispose(); + plansScrollController.dispose(); super.dispose(); } @@ -143,6 +143,8 @@ class _FeedScreenState extends State { return _buildAllRecipes(); else if (_selectedChipIndex == 2) return _buildDiets(); + else if (_selectedChipIndex == 3) + return _buildPlans(); else return Center(child: Text(chipsLabelList[_selectedChipIndex])); }, @@ -277,6 +279,47 @@ class _FeedScreenState extends State { ); } + _buildPlans() { + return RefreshIndicator( + onRefresh: () => context.read().getPlans(), + child: BlocBuilder( + builder: (BuildContext context, PlansState state) { + if (state is PlansStateLoaded) { + return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 8), + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) { + return PlanWidget(planModel: state.plansModel.data[index]); + }, + separatorBuilder: (context, index) { + return SizedBox(height: 8); + }, + itemCount: state.plansModel.data.length, + ); + } else if (state is PlansStateError) { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), + ), + ); + } else { + return Scaffold( + backgroundColor: Colors.grey.shade200, + body: Center( + child: CircularProgressIndicator(), + ), + ); + } + }, + ), + ); + } + _chipGroup() { return PreferredSize( preferredSize: Size(MediaQuery.of(context).size.width, 32), diff --git a/lib/features/feed/presentation/widgets/diets_widget.dart b/lib/features/feed/presentation/widgets/diets_widget.dart index 7bc9054e..c327c2a4 100644 --- a/lib/features/feed/presentation/widgets/diets_widget.dart +++ b/lib/features/feed/presentation/widgets/diets_widget.dart @@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; class DietsWidget extends StatefulWidget { @@ -123,14 +124,15 @@ class _DietsWidgetState extends State { ), ), ), - SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: Text( - widget.diet.details, - style: TextStyle( - color: Colors.black87, - ), + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Html( + data: widget.diet.details, + style: { + "*": Style( + color: Colors.black87, + ), + }, ), ), SizedBox(height: 12), diff --git a/lib/features/feed/presentation/widgets/plan_widget.dart b/lib/features/feed/presentation/widgets/plan_widget.dart new file mode 100644 index 00000000..fc4bb8cb --- /dev/null +++ b/lib/features/feed/presentation/widgets/plan_widget.dart @@ -0,0 +1,173 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:eatvio_app/core/constants/constants.dart'; +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_html/flutter_html.dart'; +import 'package:go_router/go_router.dart'; + +class PlanWidget extends StatelessWidget { + final PlanModel planModel; + + const PlanWidget({ + super.key, + required this.planModel, + }); + + @override + Widget build(BuildContext context) { + return InkWell( + borderRadius: BorderRadius.circular(12), + onTap: () => GoRouter.of(context).pushNamed( + 'aboutPlanScreen', + extra: planModel, + ), + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + ClipRRect( + borderRadius: BorderRadius.vertical(top: Radius.circular(12)), + child: CachedNetworkImage( + imageUrl: baseUrl + '/storage/' + planModel.image, + fit: BoxFit.fitWidth, + width: MediaQuery.of(context).size.width, + ), + ), + Positioned( + left: 8, + bottom: 8, + child: Wrap( + runSpacing: 8, + children: [ + _iconButton(Icons.timelapse_rounded, '${planModel.duration} дней'), + SizedBox(width: 8), + ], + ), + ), + Positioned( + left: 8, + top: 8, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.8), + borderRadius: BorderRadius.circular(16), + ), + child: Row( + children: [ + Icon( + Icons.favorite_rounded, + size: 16, + color: Colors.black, + ), + SizedBox(width: 4), + Text( + '0', + style: TextStyle( + fontSize: 12, + color: Colors.black, + fontWeight: FontWeight.w400, + ), + ), + ], + ), + ), + ), + Positioned( + right: 8, + top: 8, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.8), + borderRadius: BorderRadius.circular(16), + ), + child: Row( + children: [ + Icon( + Icons.visibility_rounded, + size: 16, + color: Colors.black, + ), + SizedBox(width: 4), + Text( + '0', + style: TextStyle( + fontSize: 12, + color: Colors.black, + fontWeight: FontWeight.w400, + ), + ), + ], + ), + ), + ), + ], + ), + SizedBox(height: 12), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Text( + planModel.name, + style: TextStyle( + fontWeight: FontWeight.w600, + color: Colors.black87, + ), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Html( + data: planModel.details, + style: { + "*": Style( + color: Colors.black87, + ), + }, + ), + ), + SizedBox(height: 12), + ], + ), + ), + ); + } + + _iconButton(IconData icon, [String? text]) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4), + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.8), + borderRadius: BorderRadius.circular(16), + ), + height: 32, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + icon, + size: 16, + color: Colors.black, + ), + if (text != null) SizedBox(width: 8), + if (text != null) + Text( + text, + style: TextStyle( + fontSize: 12, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ); + } +} diff --git a/lib/features/feed/presentation/widgets/recipes_widget.dart b/lib/features/feed/presentation/widgets/recipes_widget.dart index 54fb1b2d..151831f8 100644 --- a/lib/features/feed/presentation/widgets/recipes_widget.dart +++ b/lib/features/feed/presentation/widgets/recipes_widget.dart @@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; class RecipesWidget extends StatefulWidget { @@ -123,14 +124,15 @@ class _RecipesWidgetState extends State { ), ), ), - SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: Text( - widget.recipes.description, - style: TextStyle( - color: Colors.black87, - ), + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Html( + data: widget.recipes.description, + style: { + "*": Style( + color: Colors.black87, + ), + }, ), ), SizedBox(height: 12), diff --git a/lib/features/plans/models/plan_pagination_model.dart b/lib/features/plans/models/plan_pagination_model.dart new file mode 100644 index 00000000..767d959a --- /dev/null +++ b/lib/features/plans/models/plan_pagination_model.dart @@ -0,0 +1,65 @@ +import 'package:eatvio_app/core/models/base_models.dart'; +import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'plan_pagination_model.freezed.dart'; + +part 'plan_pagination_model.g.dart'; + +@freezed +class PlanPaginationModel with _$PlanPaginationModel { + const factory PlanPaginationModel({ + @JsonKey(name: "data") required List data, + @JsonKey(name: "links") required Links links, + @JsonKey(name: "meta") required Meta meta, + }) = _PlanPaginationModel; + + factory PlanPaginationModel.fromJson(Map json) => _$PlanPaginationModelFromJson(json); +} + +@freezed +class PlanModel with _$PlanModel { + const factory PlanModel({ + @JsonKey(name: "id") required int id, + @JsonKey(name: "name") required String name, + @JsonKey(name: "image") required String image, + @JsonKey(name: "duration") required int duration, + @JsonKey(name: "state") required String state, + @JsonKey(name: "type") required PlanType type, + @JsonKey(name: "details") required String details, + @JsonKey(name: "packets_count") required int packetsCount, + @JsonKey(name: "packet1_options") dynamic packet1Options, + @JsonKey(name: "packet2_options") dynamic packet2Options, + @JsonKey(name: "packet3_options") dynamic packet3Options, + @JsonKey(name: "author") required Author author, + @JsonKey(name: "total_likes") required int totalLikes, + @JsonKey(name: "total_views") required int totalViews, + @JsonKey(name: "total_comments") required int totalComments, + }) = _PlanModel; + + factory PlanModel.fromJson(Map json) => _$PlanModelFromJson(json); +} + +@freezed +class PacketOptions with _$PacketOptions { + const factory PacketOptions({ + @JsonKey(name: "items") required List items, + @JsonKey(name: "price") required dynamic price, + @JsonKey(name: "short") required String short, + @JsonKey(name: "description") required String description, + }) = _PacketOptions; + + factory PacketOptions.fromJson(Map json) => _$PacketOptionsFromJson(json); +} + +@freezed +class PlanType with _$PlanType { + const factory PlanType({ + @JsonKey(name: "fit") required bool fit, + @JsonKey(name: "slim") required bool slim, + @JsonKey(name: "behavior") required bool behavior, + @JsonKey(name: "wellness") required bool wellness, + }) = _PlanType; + + factory PlanType.fromJson(Map json) => _$PlanTypeFromJson(json); +} diff --git a/lib/features/plans/models/plan_pagination_model.freezed.dart b/lib/features/plans/models/plan_pagination_model.freezed.dart new file mode 100644 index 00000000..caa2ef10 --- /dev/null +++ b/lib/features/plans/models/plan_pagination_model.freezed.dart @@ -0,0 +1,1251 @@ +// 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 'plan_pagination_model.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'); + +PlanPaginationModel _$PlanPaginationModelFromJson(Map json) { + return _PlanPaginationModel.fromJson(json); +} + +/// @nodoc +mixin _$PlanPaginationModel { + @JsonKey(name: "data") + List get data => throw _privateConstructorUsedError; + @JsonKey(name: "links") + Links get links => throw _privateConstructorUsedError; + @JsonKey(name: "meta") + Meta get meta => throw _privateConstructorUsedError; + + /// Serializes this PlanPaginationModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PlanPaginationModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PlanPaginationModelCopyWith<$Res> { + factory $PlanPaginationModelCopyWith( + PlanPaginationModel value, $Res Function(PlanPaginationModel) then) = + _$PlanPaginationModelCopyWithImpl<$Res, PlanPaginationModel>; + @useResult + $Res call( + {@JsonKey(name: "data") List data, + @JsonKey(name: "links") Links links, + @JsonKey(name: "meta") Meta meta}); + + $LinksCopyWith<$Res> get links; + $MetaCopyWith<$Res> get meta; +} + +/// @nodoc +class _$PlanPaginationModelCopyWithImpl<$Res, $Val extends PlanPaginationModel> + implements $PlanPaginationModelCopyWith<$Res> { + _$PlanPaginationModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? links = null, + Object? meta = null, + }) { + return _then(_value.copyWith( + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as List, + links: null == links + ? _value.links + : links // ignore: cast_nullable_to_non_nullable + as Links, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, + ) as $Val); + } + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $LinksCopyWith<$Res> get links { + return $LinksCopyWith<$Res>(_value.links, (value) { + return _then(_value.copyWith(links: value) as $Val); + }); + } + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $MetaCopyWith<$Res> get meta { + return $MetaCopyWith<$Res>(_value.meta, (value) { + return _then(_value.copyWith(meta: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$PlanPaginationModelImplCopyWith<$Res> + implements $PlanPaginationModelCopyWith<$Res> { + factory _$$PlanPaginationModelImplCopyWith(_$PlanPaginationModelImpl value, + $Res Function(_$PlanPaginationModelImpl) then) = + __$$PlanPaginationModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "data") List data, + @JsonKey(name: "links") Links links, + @JsonKey(name: "meta") Meta meta}); + + @override + $LinksCopyWith<$Res> get links; + @override + $MetaCopyWith<$Res> get meta; +} + +/// @nodoc +class __$$PlanPaginationModelImplCopyWithImpl<$Res> + extends _$PlanPaginationModelCopyWithImpl<$Res, _$PlanPaginationModelImpl> + implements _$$PlanPaginationModelImplCopyWith<$Res> { + __$$PlanPaginationModelImplCopyWithImpl(_$PlanPaginationModelImpl _value, + $Res Function(_$PlanPaginationModelImpl) _then) + : super(_value, _then); + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + Object? links = null, + Object? meta = null, + }) { + return _then(_$PlanPaginationModelImpl( + data: null == data + ? _value._data + : data // ignore: cast_nullable_to_non_nullable + as List, + links: null == links + ? _value.links + : links // ignore: cast_nullable_to_non_nullable + as Links, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PlanPaginationModelImpl implements _PlanPaginationModel { + const _$PlanPaginationModelImpl( + {@JsonKey(name: "data") required final List data, + @JsonKey(name: "links") required this.links, + @JsonKey(name: "meta") required this.meta}) + : _data = data; + + factory _$PlanPaginationModelImpl.fromJson(Map json) => + _$$PlanPaginationModelImplFromJson(json); + + final List _data; + @override + @JsonKey(name: "data") + List get data { + if (_data is EqualUnmodifiableListView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_data); + } + + @override + @JsonKey(name: "links") + final Links links; + @override + @JsonKey(name: "meta") + final Meta meta; + + @override + String toString() { + return 'PlanPaginationModel(data: $data, links: $links, meta: $meta)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlanPaginationModelImpl && + const DeepCollectionEquality().equals(other._data, _data) && + (identical(other.links, links) || other.links == links) && + (identical(other.meta, meta) || other.meta == meta)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_data), links, meta); + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlanPaginationModelImplCopyWith<_$PlanPaginationModelImpl> get copyWith => + __$$PlanPaginationModelImplCopyWithImpl<_$PlanPaginationModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$PlanPaginationModelImplToJson( + this, + ); + } +} + +abstract class _PlanPaginationModel implements PlanPaginationModel { + const factory _PlanPaginationModel( + {@JsonKey(name: "data") required final List data, + @JsonKey(name: "links") required final Links links, + @JsonKey(name: "meta") required final Meta meta}) = + _$PlanPaginationModelImpl; + + factory _PlanPaginationModel.fromJson(Map json) = + _$PlanPaginationModelImpl.fromJson; + + @override + @JsonKey(name: "data") + List get data; + @override + @JsonKey(name: "links") + Links get links; + @override + @JsonKey(name: "meta") + Meta get meta; + + /// Create a copy of PlanPaginationModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlanPaginationModelImplCopyWith<_$PlanPaginationModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +PlanModel _$PlanModelFromJson(Map json) { + return _PlanModel.fromJson(json); +} + +/// @nodoc +mixin _$PlanModel { + @JsonKey(name: "id") + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "name") + String get name => throw _privateConstructorUsedError; + @JsonKey(name: "image") + String get image => throw _privateConstructorUsedError; + @JsonKey(name: "duration") + int get duration => throw _privateConstructorUsedError; + @JsonKey(name: "state") + String get state => throw _privateConstructorUsedError; + @JsonKey(name: "type") + PlanType get type => throw _privateConstructorUsedError; + @JsonKey(name: "details") + String get details => throw _privateConstructorUsedError; + @JsonKey(name: "packets_count") + int get packetsCount => throw _privateConstructorUsedError; + @JsonKey(name: "packet1_options") + dynamic get packet1Options => throw _privateConstructorUsedError; + @JsonKey(name: "packet2_options") + dynamic get packet2Options => throw _privateConstructorUsedError; + @JsonKey(name: "packet3_options") + dynamic get packet3Options => throw _privateConstructorUsedError; + @JsonKey(name: "author") + Author get author => throw _privateConstructorUsedError; + @JsonKey(name: "total_likes") + int get totalLikes => throw _privateConstructorUsedError; + @JsonKey(name: "total_views") + int get totalViews => throw _privateConstructorUsedError; + @JsonKey(name: "total_comments") + int get totalComments => throw _privateConstructorUsedError; + + /// Serializes this PlanModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PlanModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PlanModelCopyWith<$Res> { + factory $PlanModelCopyWith(PlanModel value, $Res Function(PlanModel) then) = + _$PlanModelCopyWithImpl<$Res, PlanModel>; + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "name") String name, + @JsonKey(name: "image") String image, + @JsonKey(name: "duration") int duration, + @JsonKey(name: "state") String state, + @JsonKey(name: "type") PlanType type, + @JsonKey(name: "details") String details, + @JsonKey(name: "packets_count") int packetsCount, + @JsonKey(name: "packet1_options") dynamic packet1Options, + @JsonKey(name: "packet2_options") dynamic packet2Options, + @JsonKey(name: "packet3_options") dynamic packet3Options, + @JsonKey(name: "author") Author author, + @JsonKey(name: "total_likes") int totalLikes, + @JsonKey(name: "total_views") int totalViews, + @JsonKey(name: "total_comments") int totalComments}); + + $PlanTypeCopyWith<$Res> get type; + $AuthorCopyWith<$Res> get author; +} + +/// @nodoc +class _$PlanModelCopyWithImpl<$Res, $Val extends PlanModel> + implements $PlanModelCopyWith<$Res> { + _$PlanModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + Object? image = null, + Object? duration = null, + Object? state = null, + Object? type = null, + Object? details = null, + Object? packetsCount = null, + Object? packet1Options = freezed, + Object? packet2Options = freezed, + Object? packet3Options = freezed, + Object? author = null, + Object? totalLikes = null, + Object? totalViews = null, + Object? totalComments = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + image: null == image + ? _value.image + : image // ignore: cast_nullable_to_non_nullable + as String, + duration: null == duration + ? _value.duration + : duration // ignore: cast_nullable_to_non_nullable + as int, + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as PlanType, + details: null == details + ? _value.details + : details // ignore: cast_nullable_to_non_nullable + as String, + packetsCount: null == packetsCount + ? _value.packetsCount + : packetsCount // ignore: cast_nullable_to_non_nullable + as int, + packet1Options: freezed == packet1Options + ? _value.packet1Options + : packet1Options // ignore: cast_nullable_to_non_nullable + as dynamic, + packet2Options: freezed == packet2Options + ? _value.packet2Options + : packet2Options // ignore: cast_nullable_to_non_nullable + as dynamic, + packet3Options: freezed == packet3Options + ? _value.packet3Options + : packet3Options // ignore: cast_nullable_to_non_nullable + as dynamic, + author: null == author + ? _value.author + : author // ignore: cast_nullable_to_non_nullable + as Author, + totalLikes: null == totalLikes + ? _value.totalLikes + : totalLikes // ignore: cast_nullable_to_non_nullable + as int, + totalViews: null == totalViews + ? _value.totalViews + : totalViews // ignore: cast_nullable_to_non_nullable + as int, + totalComments: null == totalComments + ? _value.totalComments + : totalComments // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $PlanTypeCopyWith<$Res> get type { + return $PlanTypeCopyWith<$Res>(_value.type, (value) { + return _then(_value.copyWith(type: value) as $Val); + }); + } + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $AuthorCopyWith<$Res> get author { + return $AuthorCopyWith<$Res>(_value.author, (value) { + return _then(_value.copyWith(author: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$PlanModelImplCopyWith<$Res> + implements $PlanModelCopyWith<$Res> { + factory _$$PlanModelImplCopyWith( + _$PlanModelImpl value, $Res Function(_$PlanModelImpl) then) = + __$$PlanModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "id") int id, + @JsonKey(name: "name") String name, + @JsonKey(name: "image") String image, + @JsonKey(name: "duration") int duration, + @JsonKey(name: "state") String state, + @JsonKey(name: "type") PlanType type, + @JsonKey(name: "details") String details, + @JsonKey(name: "packets_count") int packetsCount, + @JsonKey(name: "packet1_options") dynamic packet1Options, + @JsonKey(name: "packet2_options") dynamic packet2Options, + @JsonKey(name: "packet3_options") dynamic packet3Options, + @JsonKey(name: "author") Author author, + @JsonKey(name: "total_likes") int totalLikes, + @JsonKey(name: "total_views") int totalViews, + @JsonKey(name: "total_comments") int totalComments}); + + @override + $PlanTypeCopyWith<$Res> get type; + @override + $AuthorCopyWith<$Res> get author; +} + +/// @nodoc +class __$$PlanModelImplCopyWithImpl<$Res> + extends _$PlanModelCopyWithImpl<$Res, _$PlanModelImpl> + implements _$$PlanModelImplCopyWith<$Res> { + __$$PlanModelImplCopyWithImpl( + _$PlanModelImpl _value, $Res Function(_$PlanModelImpl) _then) + : super(_value, _then); + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + Object? image = null, + Object? duration = null, + Object? state = null, + Object? type = null, + Object? details = null, + Object? packetsCount = null, + Object? packet1Options = freezed, + Object? packet2Options = freezed, + Object? packet3Options = freezed, + Object? author = null, + Object? totalLikes = null, + Object? totalViews = null, + Object? totalComments = null, + }) { + return _then(_$PlanModelImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + image: null == image + ? _value.image + : image // ignore: cast_nullable_to_non_nullable + as String, + duration: null == duration + ? _value.duration + : duration // ignore: cast_nullable_to_non_nullable + as int, + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as PlanType, + details: null == details + ? _value.details + : details // ignore: cast_nullable_to_non_nullable + as String, + packetsCount: null == packetsCount + ? _value.packetsCount + : packetsCount // ignore: cast_nullable_to_non_nullable + as int, + packet1Options: freezed == packet1Options + ? _value.packet1Options + : packet1Options // ignore: cast_nullable_to_non_nullable + as dynamic, + packet2Options: freezed == packet2Options + ? _value.packet2Options + : packet2Options // ignore: cast_nullable_to_non_nullable + as dynamic, + packet3Options: freezed == packet3Options + ? _value.packet3Options + : packet3Options // ignore: cast_nullable_to_non_nullable + as dynamic, + author: null == author + ? _value.author + : author // ignore: cast_nullable_to_non_nullable + as Author, + totalLikes: null == totalLikes + ? _value.totalLikes + : totalLikes // ignore: cast_nullable_to_non_nullable + as int, + totalViews: null == totalViews + ? _value.totalViews + : totalViews // ignore: cast_nullable_to_non_nullable + as int, + totalComments: null == totalComments + ? _value.totalComments + : totalComments // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PlanModelImpl implements _PlanModel { + const _$PlanModelImpl( + {@JsonKey(name: "id") required this.id, + @JsonKey(name: "name") required this.name, + @JsonKey(name: "image") required this.image, + @JsonKey(name: "duration") required this.duration, + @JsonKey(name: "state") required this.state, + @JsonKey(name: "type") required this.type, + @JsonKey(name: "details") required this.details, + @JsonKey(name: "packets_count") required this.packetsCount, + @JsonKey(name: "packet1_options") this.packet1Options, + @JsonKey(name: "packet2_options") this.packet2Options, + @JsonKey(name: "packet3_options") this.packet3Options, + @JsonKey(name: "author") required this.author, + @JsonKey(name: "total_likes") required this.totalLikes, + @JsonKey(name: "total_views") required this.totalViews, + @JsonKey(name: "total_comments") required this.totalComments}); + + factory _$PlanModelImpl.fromJson(Map json) => + _$$PlanModelImplFromJson(json); + + @override + @JsonKey(name: "id") + final int id; + @override + @JsonKey(name: "name") + final String name; + @override + @JsonKey(name: "image") + final String image; + @override + @JsonKey(name: "duration") + final int duration; + @override + @JsonKey(name: "state") + final String state; + @override + @JsonKey(name: "type") + final PlanType type; + @override + @JsonKey(name: "details") + final String details; + @override + @JsonKey(name: "packets_count") + final int packetsCount; + @override + @JsonKey(name: "packet1_options") + final dynamic packet1Options; + @override + @JsonKey(name: "packet2_options") + final dynamic packet2Options; + @override + @JsonKey(name: "packet3_options") + final dynamic packet3Options; + @override + @JsonKey(name: "author") + final Author author; + @override + @JsonKey(name: "total_likes") + final int totalLikes; + @override + @JsonKey(name: "total_views") + final int totalViews; + @override + @JsonKey(name: "total_comments") + final int totalComments; + + @override + String toString() { + return 'PlanModel(id: $id, name: $name, image: $image, duration: $duration, state: $state, type: $type, details: $details, packetsCount: $packetsCount, packet1Options: $packet1Options, packet2Options: $packet2Options, packet3Options: $packet3Options, author: $author, totalLikes: $totalLikes, totalViews: $totalViews, totalComments: $totalComments)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlanModelImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.image, image) || other.image == image) && + (identical(other.duration, duration) || + other.duration == duration) && + (identical(other.state, state) || other.state == state) && + (identical(other.type, type) || other.type == type) && + (identical(other.details, details) || other.details == details) && + (identical(other.packetsCount, packetsCount) || + other.packetsCount == packetsCount) && + const DeepCollectionEquality() + .equals(other.packet1Options, packet1Options) && + const DeepCollectionEquality() + .equals(other.packet2Options, packet2Options) && + const DeepCollectionEquality() + .equals(other.packet3Options, packet3Options) && + (identical(other.author, author) || other.author == author) && + (identical(other.totalLikes, totalLikes) || + other.totalLikes == totalLikes) && + (identical(other.totalViews, totalViews) || + other.totalViews == totalViews) && + (identical(other.totalComments, totalComments) || + other.totalComments == totalComments)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + id, + name, + image, + duration, + state, + type, + details, + packetsCount, + const DeepCollectionEquality().hash(packet1Options), + const DeepCollectionEquality().hash(packet2Options), + const DeepCollectionEquality().hash(packet3Options), + author, + totalLikes, + totalViews, + totalComments); + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlanModelImplCopyWith<_$PlanModelImpl> get copyWith => + __$$PlanModelImplCopyWithImpl<_$PlanModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$PlanModelImplToJson( + this, + ); + } +} + +abstract class _PlanModel implements PlanModel { + const factory _PlanModel( + {@JsonKey(name: "id") required final int id, + @JsonKey(name: "name") required final String name, + @JsonKey(name: "image") required final String image, + @JsonKey(name: "duration") required final int duration, + @JsonKey(name: "state") required final String state, + @JsonKey(name: "type") required final PlanType type, + @JsonKey(name: "details") required final String details, + @JsonKey(name: "packets_count") required final int packetsCount, + @JsonKey(name: "packet1_options") final dynamic packet1Options, + @JsonKey(name: "packet2_options") final dynamic packet2Options, + @JsonKey(name: "packet3_options") final dynamic packet3Options, + @JsonKey(name: "author") required final Author author, + @JsonKey(name: "total_likes") required final int totalLikes, + @JsonKey(name: "total_views") required final int totalViews, + @JsonKey(name: "total_comments") required final int totalComments}) = + _$PlanModelImpl; + + factory _PlanModel.fromJson(Map json) = + _$PlanModelImpl.fromJson; + + @override + @JsonKey(name: "id") + int get id; + @override + @JsonKey(name: "name") + String get name; + @override + @JsonKey(name: "image") + String get image; + @override + @JsonKey(name: "duration") + int get duration; + @override + @JsonKey(name: "state") + String get state; + @override + @JsonKey(name: "type") + PlanType get type; + @override + @JsonKey(name: "details") + String get details; + @override + @JsonKey(name: "packets_count") + int get packetsCount; + @override + @JsonKey(name: "packet1_options") + dynamic get packet1Options; + @override + @JsonKey(name: "packet2_options") + dynamic get packet2Options; + @override + @JsonKey(name: "packet3_options") + dynamic get packet3Options; + @override + @JsonKey(name: "author") + Author get author; + @override + @JsonKey(name: "total_likes") + int get totalLikes; + @override + @JsonKey(name: "total_views") + int get totalViews; + @override + @JsonKey(name: "total_comments") + int get totalComments; + + /// Create a copy of PlanModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlanModelImplCopyWith<_$PlanModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +PacketOptions _$PacketOptionsFromJson(Map json) { + return _PacketOptions.fromJson(json); +} + +/// @nodoc +mixin _$PacketOptions { + @JsonKey(name: "items") + List get items => throw _privateConstructorUsedError; + @JsonKey(name: "price") + dynamic get price => throw _privateConstructorUsedError; + @JsonKey(name: "short") + String get short => throw _privateConstructorUsedError; + @JsonKey(name: "description") + String get description => throw _privateConstructorUsedError; + + /// Serializes this PacketOptions to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PacketOptionsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PacketOptionsCopyWith<$Res> { + factory $PacketOptionsCopyWith( + PacketOptions value, $Res Function(PacketOptions) then) = + _$PacketOptionsCopyWithImpl<$Res, PacketOptions>; + @useResult + $Res call( + {@JsonKey(name: "items") List items, + @JsonKey(name: "price") dynamic price, + @JsonKey(name: "short") String short, + @JsonKey(name: "description") String description}); +} + +/// @nodoc +class _$PacketOptionsCopyWithImpl<$Res, $Val extends PacketOptions> + implements $PacketOptionsCopyWith<$Res> { + _$PacketOptionsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? items = null, + Object? price = freezed, + Object? short = null, + Object? description = null, + }) { + return _then(_value.copyWith( + items: null == items + ? _value.items + : items // ignore: cast_nullable_to_non_nullable + as List, + price: freezed == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as dynamic, + short: null == short + ? _value.short + : short // ignore: cast_nullable_to_non_nullable + as String, + description: null == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PacketOptionsImplCopyWith<$Res> + implements $PacketOptionsCopyWith<$Res> { + factory _$$PacketOptionsImplCopyWith( + _$PacketOptionsImpl value, $Res Function(_$PacketOptionsImpl) then) = + __$$PacketOptionsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "items") List items, + @JsonKey(name: "price") dynamic price, + @JsonKey(name: "short") String short, + @JsonKey(name: "description") String description}); +} + +/// @nodoc +class __$$PacketOptionsImplCopyWithImpl<$Res> + extends _$PacketOptionsCopyWithImpl<$Res, _$PacketOptionsImpl> + implements _$$PacketOptionsImplCopyWith<$Res> { + __$$PacketOptionsImplCopyWithImpl( + _$PacketOptionsImpl _value, $Res Function(_$PacketOptionsImpl) _then) + : super(_value, _then); + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? items = null, + Object? price = freezed, + Object? short = null, + Object? description = null, + }) { + return _then(_$PacketOptionsImpl( + items: null == items + ? _value._items + : items // ignore: cast_nullable_to_non_nullable + as List, + price: freezed == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as dynamic, + short: null == short + ? _value.short + : short // ignore: cast_nullable_to_non_nullable + as String, + description: null == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PacketOptionsImpl implements _PacketOptions { + const _$PacketOptionsImpl( + {@JsonKey(name: "items") required final List items, + @JsonKey(name: "price") required this.price, + @JsonKey(name: "short") required this.short, + @JsonKey(name: "description") required this.description}) + : _items = items; + + factory _$PacketOptionsImpl.fromJson(Map json) => + _$$PacketOptionsImplFromJson(json); + + final List _items; + @override + @JsonKey(name: "items") + List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); + } + + @override + @JsonKey(name: "price") + final dynamic price; + @override + @JsonKey(name: "short") + final String short; + @override + @JsonKey(name: "description") + final String description; + + @override + String toString() { + return 'PacketOptions(items: $items, price: $price, short: $short, description: $description)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PacketOptionsImpl && + const DeepCollectionEquality().equals(other._items, _items) && + const DeepCollectionEquality().equals(other.price, price) && + (identical(other.short, short) || other.short == short) && + (identical(other.description, description) || + other.description == description)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_items), + const DeepCollectionEquality().hash(price), + short, + description); + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PacketOptionsImplCopyWith<_$PacketOptionsImpl> get copyWith => + __$$PacketOptionsImplCopyWithImpl<_$PacketOptionsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$PacketOptionsImplToJson( + this, + ); + } +} + +abstract class _PacketOptions implements PacketOptions { + const factory _PacketOptions( + {@JsonKey(name: "items") required final List items, + @JsonKey(name: "price") required final dynamic price, + @JsonKey(name: "short") required final String short, + @JsonKey(name: "description") required final String description}) = + _$PacketOptionsImpl; + + factory _PacketOptions.fromJson(Map json) = + _$PacketOptionsImpl.fromJson; + + @override + @JsonKey(name: "items") + List get items; + @override + @JsonKey(name: "price") + dynamic get price; + @override + @JsonKey(name: "short") + String get short; + @override + @JsonKey(name: "description") + String get description; + + /// Create a copy of PacketOptions + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PacketOptionsImplCopyWith<_$PacketOptionsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +PlanType _$PlanTypeFromJson(Map json) { + return _PlanType.fromJson(json); +} + +/// @nodoc +mixin _$PlanType { + @JsonKey(name: "fit") + bool get fit => throw _privateConstructorUsedError; + @JsonKey(name: "slim") + bool get slim => throw _privateConstructorUsedError; + @JsonKey(name: "behavior") + bool get behavior => throw _privateConstructorUsedError; + @JsonKey(name: "wellness") + bool get wellness => throw _privateConstructorUsedError; + + /// Serializes this PlanType to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PlanTypeCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PlanTypeCopyWith<$Res> { + factory $PlanTypeCopyWith(PlanType value, $Res Function(PlanType) then) = + _$PlanTypeCopyWithImpl<$Res, PlanType>; + @useResult + $Res call( + {@JsonKey(name: "fit") bool fit, + @JsonKey(name: "slim") bool slim, + @JsonKey(name: "behavior") bool behavior, + @JsonKey(name: "wellness") bool wellness}); +} + +/// @nodoc +class _$PlanTypeCopyWithImpl<$Res, $Val extends PlanType> + implements $PlanTypeCopyWith<$Res> { + _$PlanTypeCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? fit = null, + Object? slim = null, + Object? behavior = null, + Object? wellness = null, + }) { + return _then(_value.copyWith( + fit: null == fit + ? _value.fit + : fit // ignore: cast_nullable_to_non_nullable + as bool, + slim: null == slim + ? _value.slim + : slim // ignore: cast_nullable_to_non_nullable + as bool, + behavior: null == behavior + ? _value.behavior + : behavior // ignore: cast_nullable_to_non_nullable + as bool, + wellness: null == wellness + ? _value.wellness + : wellness // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PlanTypeImplCopyWith<$Res> + implements $PlanTypeCopyWith<$Res> { + factory _$$PlanTypeImplCopyWith( + _$PlanTypeImpl value, $Res Function(_$PlanTypeImpl) then) = + __$$PlanTypeImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "fit") bool fit, + @JsonKey(name: "slim") bool slim, + @JsonKey(name: "behavior") bool behavior, + @JsonKey(name: "wellness") bool wellness}); +} + +/// @nodoc +class __$$PlanTypeImplCopyWithImpl<$Res> + extends _$PlanTypeCopyWithImpl<$Res, _$PlanTypeImpl> + implements _$$PlanTypeImplCopyWith<$Res> { + __$$PlanTypeImplCopyWithImpl( + _$PlanTypeImpl _value, $Res Function(_$PlanTypeImpl) _then) + : super(_value, _then); + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? fit = null, + Object? slim = null, + Object? behavior = null, + Object? wellness = null, + }) { + return _then(_$PlanTypeImpl( + fit: null == fit + ? _value.fit + : fit // ignore: cast_nullable_to_non_nullable + as bool, + slim: null == slim + ? _value.slim + : slim // ignore: cast_nullable_to_non_nullable + as bool, + behavior: null == behavior + ? _value.behavior + : behavior // ignore: cast_nullable_to_non_nullable + as bool, + wellness: null == wellness + ? _value.wellness + : wellness // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PlanTypeImpl implements _PlanType { + const _$PlanTypeImpl( + {@JsonKey(name: "fit") required this.fit, + @JsonKey(name: "slim") required this.slim, + @JsonKey(name: "behavior") required this.behavior, + @JsonKey(name: "wellness") required this.wellness}); + + factory _$PlanTypeImpl.fromJson(Map json) => + _$$PlanTypeImplFromJson(json); + + @override + @JsonKey(name: "fit") + final bool fit; + @override + @JsonKey(name: "slim") + final bool slim; + @override + @JsonKey(name: "behavior") + final bool behavior; + @override + @JsonKey(name: "wellness") + final bool wellness; + + @override + String toString() { + return 'PlanType(fit: $fit, slim: $slim, behavior: $behavior, wellness: $wellness)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlanTypeImpl && + (identical(other.fit, fit) || other.fit == fit) && + (identical(other.slim, slim) || other.slim == slim) && + (identical(other.behavior, behavior) || + other.behavior == behavior) && + (identical(other.wellness, wellness) || + other.wellness == wellness)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, fit, slim, behavior, wellness); + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlanTypeImplCopyWith<_$PlanTypeImpl> get copyWith => + __$$PlanTypeImplCopyWithImpl<_$PlanTypeImpl>(this, _$identity); + + @override + Map toJson() { + return _$$PlanTypeImplToJson( + this, + ); + } +} + +abstract class _PlanType implements PlanType { + const factory _PlanType( + {@JsonKey(name: "fit") required final bool fit, + @JsonKey(name: "slim") required final bool slim, + @JsonKey(name: "behavior") required final bool behavior, + @JsonKey(name: "wellness") required final bool wellness}) = + _$PlanTypeImpl; + + factory _PlanType.fromJson(Map json) = + _$PlanTypeImpl.fromJson; + + @override + @JsonKey(name: "fit") + bool get fit; + @override + @JsonKey(name: "slim") + bool get slim; + @override + @JsonKey(name: "behavior") + bool get behavior; + @override + @JsonKey(name: "wellness") + bool get wellness; + + /// Create a copy of PlanType + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlanTypeImplCopyWith<_$PlanTypeImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/plans/models/plan_pagination_model.g.dart b/lib/features/plans/models/plan_pagination_model.g.dart new file mode 100644 index 00000000..8f203fa8 --- /dev/null +++ b/lib/features/plans/models/plan_pagination_model.g.dart @@ -0,0 +1,95 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'plan_pagination_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$PlanPaginationModelImpl _$$PlanPaginationModelImplFromJson( + Map json) => + _$PlanPaginationModelImpl( + data: (json['data'] as List) + .map((e) => PlanModel.fromJson(e as Map)) + .toList(), + links: Links.fromJson(json['links'] as Map), + meta: Meta.fromJson(json['meta'] as Map), + ); + +Map _$$PlanPaginationModelImplToJson( + _$PlanPaginationModelImpl instance) => + { + 'data': instance.data, + 'links': instance.links, + 'meta': instance.meta, + }; + +_$PlanModelImpl _$$PlanModelImplFromJson(Map json) => + _$PlanModelImpl( + id: (json['id'] as num).toInt(), + name: json['name'] as String, + image: json['image'] as String, + duration: (json['duration'] as num).toInt(), + state: json['state'] as String, + type: PlanType.fromJson(json['type'] as Map), + details: json['details'] as String, + packetsCount: (json['packets_count'] as num).toInt(), + packet1Options: json['packet1_options'], + packet2Options: json['packet2_options'], + packet3Options: json['packet3_options'], + author: Author.fromJson(json['author'] as Map), + totalLikes: (json['total_likes'] as num).toInt(), + totalViews: (json['total_views'] as num).toInt(), + totalComments: (json['total_comments'] as num).toInt(), + ); + +Map _$$PlanModelImplToJson(_$PlanModelImpl instance) => + { + 'id': instance.id, + 'name': instance.name, + 'image': instance.image, + 'duration': instance.duration, + 'state': instance.state, + 'type': instance.type, + 'details': instance.details, + 'packets_count': instance.packetsCount, + 'packet1_options': instance.packet1Options, + 'packet2_options': instance.packet2Options, + 'packet3_options': instance.packet3Options, + 'author': instance.author, + 'total_likes': instance.totalLikes, + 'total_views': instance.totalViews, + 'total_comments': instance.totalComments, + }; + +_$PacketOptionsImpl _$$PacketOptionsImplFromJson(Map json) => + _$PacketOptionsImpl( + items: (json['items'] as List).map((e) => e as String).toList(), + price: json['price'], + short: json['short'] as String, + description: json['description'] as String, + ); + +Map _$$PacketOptionsImplToJson(_$PacketOptionsImpl instance) => + { + 'items': instance.items, + 'price': instance.price, + 'short': instance.short, + 'description': instance.description, + }; + +_$PlanTypeImpl _$$PlanTypeImplFromJson(Map json) => + _$PlanTypeImpl( + fit: json['fit'] as bool, + slim: json['slim'] as bool, + behavior: json['behavior'] as bool, + wellness: json['wellness'] as bool, + ); + +Map _$$PlanTypeImplToJson(_$PlanTypeImpl instance) => + { + 'fit': instance.fit, + 'slim': instance.slim, + 'behavior': instance.behavior, + 'wellness': instance.wellness, + }; diff --git a/lib/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart b/lib/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart new file mode 100644 index 00000000..fb885fe7 --- /dev/null +++ b/lib/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart @@ -0,0 +1,19 @@ +import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_state.dart'; +import 'package:eatvio_app/features/plans/repositories/plans_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class PlansCubit extends Cubit { + final PlansRepository plansRepository; + + PlansCubit({ + required this.plansRepository, + }) : super(PlansState.loading()); + + getPlans() async { + try { + emit(PlansState.loaded(plansModel: await plansRepository.getPlans())); + } catch (e) { + emit(PlansState.error(errorMessage: e.toString())); + } + } +} diff --git a/lib/features/plans/presentation/bloc/plans_cubit/plans_state.dart b/lib/features/plans/presentation/bloc/plans_cubit/plans_state.dart new file mode 100644 index 00000000..ca3193cf --- /dev/null +++ b/lib/features/plans/presentation/bloc/plans_cubit/plans_state.dart @@ -0,0 +1,19 @@ +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'plans_state.freezed.dart'; + +@freezed +abstract class PlansState with _$PlansState { + const factory PlansState() = _PlansState; + + const factory PlansState.loading() = PlansStateLoading; + + const factory PlansState.loaded({ + required PlanPaginationModel plansModel, + }) = PlansStateLoaded; + + const factory PlansState.error({ + required String errorMessage, + }) = PlansStateError; +} diff --git a/lib/features/plans/presentation/bloc/plans_cubit/plans_state.freezed.dart b/lib/features/plans/presentation/bloc/plans_cubit/plans_state.freezed.dart new file mode 100644 index 00000000..1bbe3cac --- /dev/null +++ b/lib/features/plans/presentation/bloc/plans_cubit/plans_state.freezed.dart @@ -0,0 +1,646 @@ +// 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 'plans_state.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'); + +/// @nodoc +mixin _$PlansState { + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PlansStateCopyWith<$Res> { + factory $PlansStateCopyWith( + PlansState value, $Res Function(PlansState) then) = + _$PlansStateCopyWithImpl<$Res, PlansState>; +} + +/// @nodoc +class _$PlansStateCopyWithImpl<$Res, $Val extends PlansState> + implements $PlansStateCopyWith<$Res> { + _$PlansStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$PlansStateImplCopyWith<$Res> { + factory _$$PlansStateImplCopyWith( + _$PlansStateImpl value, $Res Function(_$PlansStateImpl) then) = + __$$PlansStateImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PlansStateImplCopyWithImpl<$Res> + extends _$PlansStateCopyWithImpl<$Res, _$PlansStateImpl> + implements _$$PlansStateImplCopyWith<$Res> { + __$$PlansStateImplCopyWithImpl( + _$PlansStateImpl _value, $Res Function(_$PlansStateImpl) _then) + : super(_value, _then); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$PlansStateImpl implements _PlansState { + const _$PlansStateImpl(); + + @override + String toString() { + return 'PlansState()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$PlansStateImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) { + return $default(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return $default?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) { + return $default(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) { + return $default?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) { + if ($default != null) { + return $default(this); + } + return orElse(); + } +} + +abstract class _PlansState implements PlansState { + const factory _PlansState() = _$PlansStateImpl; +} + +/// @nodoc +abstract class _$$PlansStateLoadingImplCopyWith<$Res> { + factory _$$PlansStateLoadingImplCopyWith(_$PlansStateLoadingImpl value, + $Res Function(_$PlansStateLoadingImpl) then) = + __$$PlansStateLoadingImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$PlansStateLoadingImplCopyWithImpl<$Res> + extends _$PlansStateCopyWithImpl<$Res, _$PlansStateLoadingImpl> + implements _$$PlansStateLoadingImplCopyWith<$Res> { + __$$PlansStateLoadingImplCopyWithImpl(_$PlansStateLoadingImpl _value, + $Res Function(_$PlansStateLoadingImpl) _then) + : super(_value, _then); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$PlansStateLoadingImpl implements PlansStateLoading { + const _$PlansStateLoadingImpl(); + + @override + String toString() { + return 'PlansState.loading()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$PlansStateLoadingImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) { + return loading(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return loading?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) { + return loading(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) { + return loading?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(this); + } + return orElse(); + } +} + +abstract class PlansStateLoading implements PlansState { + const factory PlansStateLoading() = _$PlansStateLoadingImpl; +} + +/// @nodoc +abstract class _$$PlansStateLoadedImplCopyWith<$Res> { + factory _$$PlansStateLoadedImplCopyWith(_$PlansStateLoadedImpl value, + $Res Function(_$PlansStateLoadedImpl) then) = + __$$PlansStateLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call({PlanPaginationModel plansModel}); + + $PlanPaginationModelCopyWith<$Res> get plansModel; +} + +/// @nodoc +class __$$PlansStateLoadedImplCopyWithImpl<$Res> + extends _$PlansStateCopyWithImpl<$Res, _$PlansStateLoadedImpl> + implements _$$PlansStateLoadedImplCopyWith<$Res> { + __$$PlansStateLoadedImplCopyWithImpl(_$PlansStateLoadedImpl _value, + $Res Function(_$PlansStateLoadedImpl) _then) + : super(_value, _then); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? plansModel = null, + }) { + return _then(_$PlansStateLoadedImpl( + plansModel: null == plansModel + ? _value.plansModel + : plansModel // ignore: cast_nullable_to_non_nullable + as PlanPaginationModel, + )); + } + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $PlanPaginationModelCopyWith<$Res> get plansModel { + return $PlanPaginationModelCopyWith<$Res>(_value.plansModel, (value) { + return _then(_value.copyWith(plansModel: value)); + }); + } +} + +/// @nodoc + +class _$PlansStateLoadedImpl implements PlansStateLoaded { + const _$PlansStateLoadedImpl({required this.plansModel}); + + @override + final PlanPaginationModel plansModel; + + @override + String toString() { + return 'PlansState.loaded(plansModel: $plansModel)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlansStateLoadedImpl && + (identical(other.plansModel, plansModel) || + other.plansModel == plansModel)); + } + + @override + int get hashCode => Object.hash(runtimeType, plansModel); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlansStateLoadedImplCopyWith<_$PlansStateLoadedImpl> get copyWith => + __$$PlansStateLoadedImplCopyWithImpl<_$PlansStateLoadedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) { + return loaded(plansModel); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return loaded?.call(plansModel); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(plansModel); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) { + return loaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) { + return loaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(this); + } + return orElse(); + } +} + +abstract class PlansStateLoaded implements PlansState { + const factory PlansStateLoaded( + {required final PlanPaginationModel plansModel}) = _$PlansStateLoadedImpl; + + PlanPaginationModel get plansModel; + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlansStateLoadedImplCopyWith<_$PlansStateLoadedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PlansStateErrorImplCopyWith<$Res> { + factory _$$PlansStateErrorImplCopyWith(_$PlansStateErrorImpl value, + $Res Function(_$PlansStateErrorImpl) then) = + __$$PlansStateErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String errorMessage}); +} + +/// @nodoc +class __$$PlansStateErrorImplCopyWithImpl<$Res> + extends _$PlansStateCopyWithImpl<$Res, _$PlansStateErrorImpl> + implements _$$PlansStateErrorImplCopyWith<$Res> { + __$$PlansStateErrorImplCopyWithImpl( + _$PlansStateErrorImpl _value, $Res Function(_$PlansStateErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? errorMessage = null, + }) { + return _then(_$PlansStateErrorImpl( + errorMessage: null == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PlansStateErrorImpl implements PlansStateError { + const _$PlansStateErrorImpl({required this.errorMessage}); + + @override + final String errorMessage; + + @override + String toString() { + return 'PlansState.error(errorMessage: $errorMessage)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlansStateErrorImpl && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash(runtimeType, errorMessage); + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PlansStateErrorImplCopyWith<_$PlansStateErrorImpl> get copyWith => + __$$PlansStateErrorImplCopyWithImpl<_$PlansStateErrorImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() loading, + required TResult Function(PlanPaginationModel plansModel) loaded, + required TResult Function(String errorMessage) error, + }) { + return error(errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? loading, + TResult? Function(PlanPaginationModel plansModel)? loaded, + TResult? Function(String errorMessage)? error, + }) { + return error?.call(errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? loading, + TResult Function(PlanPaginationModel plansModel)? loaded, + TResult Function(String errorMessage)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_PlansState value) $default, { + required TResult Function(PlansStateLoading value) loading, + required TResult Function(PlansStateLoaded value) loaded, + required TResult Function(PlansStateError value) error, + }) { + return error(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_PlansState value)? $default, { + TResult? Function(PlansStateLoading value)? loading, + TResult? Function(PlansStateLoaded value)? loaded, + TResult? Function(PlansStateError value)? error, + }) { + return error?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_PlansState value)? $default, { + TResult Function(PlansStateLoading value)? loading, + TResult Function(PlansStateLoaded value)? loaded, + TResult Function(PlansStateError value)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(this); + } + return orElse(); + } +} + +abstract class PlansStateError implements PlansState { + const factory PlansStateError({required final String errorMessage}) = + _$PlansStateErrorImpl; + + String get errorMessage; + + /// Create a copy of PlansState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PlansStateErrorImplCopyWith<_$PlansStateErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/plans/presentation/pages/about_plan_screen.dart b/lib/features/plans/presentation/pages/about_plan_screen.dart new file mode 100644 index 00000000..50f81867 --- /dev/null +++ b/lib/features/plans/presentation/pages/about_plan_screen.dart @@ -0,0 +1,20 @@ +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:flutter/material.dart'; + +class AboutPlanScreen extends StatelessWidget { + final PlanModel planModel; + + const AboutPlanScreen({ + super.key, + required this.planModel, + }); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(planModel.name), + ), + ); + } +} diff --git a/lib/features/plans/repositories/plans_repository.dart b/lib/features/plans/repositories/plans_repository.dart new file mode 100644 index 00000000..ee8e7fb7 --- /dev/null +++ b/lib/features/plans/repositories/plans_repository.dart @@ -0,0 +1,16 @@ +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:eatvio_app/features/plans/services/plans_service.dart'; + +class PlansRepository { + final PlansService plansService; + + const PlansRepository({required this.plansService}); + + Future getPlans() async { + try { + return await plansService.getPlans(); + } catch (e) { + rethrow; + } + } +} diff --git a/lib/features/plans/services/plans_service.dart b/lib/features/plans/services/plans_service.dart new file mode 100644 index 00000000..2b842047 --- /dev/null +++ b/lib/features/plans/services/plans_service.dart @@ -0,0 +1,13 @@ +import 'package:dio/dio.dart'; +import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart'; +import 'package:retrofit/retrofit.dart'; + +part 'plans_service.g.dart'; + +@RestApi() +abstract class PlansService { + factory PlansService(Dio dio, {String baseUrl}) = _PlansService; + + @GET('/api/plans/index') + Future getPlans(); +} diff --git a/lib/features/plans/services/plans_service.g.dart b/lib/features/plans/services/plans_service.g.dart new file mode 100644 index 00000000..bce687f0 --- /dev/null +++ b/lib/features/plans/services/plans_service.g.dart @@ -0,0 +1,86 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'plans_service.dart'; + +// ************************************************************************** +// RetrofitGenerator +// ************************************************************************** + +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element + +class _PlansService implements PlansService { + _PlansService( + this._dio, { + this.baseUrl, + this.errorLogger, + }); + + final Dio _dio; + + String? baseUrl; + + final ParseErrorLogger? errorLogger; + + @override + Future getPlans() async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + const Map? _data = null; + final _options = _setStreamType(Options( + method: 'GET', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/plans/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late PlanPaginationModel _value; + try { + _value = PlanPaginationModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + RequestOptions _setStreamType(RequestOptions requestOptions) { + if (T != dynamic && + !(requestOptions.responseType == ResponseType.bytes || + requestOptions.responseType == ResponseType.stream)) { + if (T == String) { + requestOptions.responseType = ResponseType.plain; + } else { + requestOptions.responseType = ResponseType.json; + } + } + return requestOptions; + } + + String _combineBaseUrls( + String dioBaseUrl, + String? baseUrl, + ) { + if (baseUrl == null || baseUrl.trim().isEmpty) { + return dioBaseUrl; + } + + final url = Uri.parse(baseUrl); + + if (url.isAbsolute) { + return url.toString(); + } + + return Uri.parse(dioBaseUrl).resolveUri(url).toString(); + } +} diff --git a/lib/features/recipes/presentation/pages/about_recipes_screen.dart b/lib/features/recipes/presentation/pages/about_recipes_screen.dart index c778b585..397147bd 100644 --- a/lib/features/recipes/presentation/pages/about_recipes_screen.dart +++ b/lib/features/recipes/presentation/pages/about_recipes_screen.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/commen import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart'; import 'package:eatvio_app/locator_service.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_html/flutter_html.dart'; import 'package:go_router/go_router.dart'; class AboutRecipesScreen extends StatefulWidget { @@ -247,19 +248,18 @@ class _AboutRecipesScreenState extends State { ], ), ), - SizedBox(height: 12), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Text( - widget.recipes.description, - style: TextStyle( - color: Colors.black, - fontSize: 14, - fontWeight: FontWeight.w400, - height: 1.2, + if (widget.recipes.description.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Html( + data: widget.recipes.description, + style: { + "*": Style( + color: Colors.black87, + ), + }, ), ), - ), SizedBox(height: 12), CachedNetworkImage( imageUrl: baseUrl + '/storage/' + widget.recipes.image, diff --git a/lib/locator_service.dart b/lib/locator_service.dart index 30e45db8..beafd9b2 100644 --- a/lib/locator_service.dart +++ b/lib/locator_service.dart @@ -20,6 +20,9 @@ import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart'; import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; import 'package:eatvio_app/features/feed/services/feed_service.dart'; +import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart'; +import 'package:eatvio_app/features/plans/repositories/plans_repository.dart'; +import 'package:eatvio_app/features/plans/services/plans_service.dart'; import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart'; import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; import 'package:eatvio_app/features/profile/services/profile_service.dart'; @@ -51,6 +54,7 @@ Future init() async { sl.registerFactory(() => DietsCubit(feedRepository: sl())); sl.registerFactory(() => CommentsCubit(feedRepository: sl())); sl.registerFactory(() => ChatSelectCubit(chatRepository: sl())); + sl.registerFactory(() => PlansCubit(plansRepository: sl())); // Repository sl.registerLazySingleton(() => ChatRepository(chatService: sl())); @@ -60,6 +64,7 @@ Future init() async { sl.registerLazySingleton(() => CalendarRepository(calendarService: sl())); sl.registerLazySingleton(() => ProfileRepository(profileService: sl())); sl.registerLazySingleton(() => RecipeRepository(recipeService: sl())); + sl.registerLazySingleton(() => PlansRepository(plansService: sl())); // Services sl.registerLazySingleton(() => ChatService(sl())); @@ -69,6 +74,7 @@ Future init() async { sl.registerLazySingleton(() => CalendarService(sl())); sl.registerLazySingleton(() => ProfileService(sl())); sl.registerLazySingleton(() => RecipeService(sl())); + sl.registerLazySingleton(() => PlansService(sl())); // External sl.registerLazySingleton( diff --git a/lib/main.dart b/lib/main.dart index 61ea707d..5a24fa1e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/diets_cubit/diets_cubit.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/recipes_cubit/recipes_cubit.dart'; +import 'package:eatvio_app/features/plans/presentation/bloc/plans_cubit/plans_cubit.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_cubit.dart'; import 'package:eatvio_app/locator_service.dart' as di; import 'package:eatvio_app/locator_service.dart'; @@ -19,6 +20,7 @@ import 'package:keyboard_dismisser/keyboard_dismisser.dart'; import 'core/app_export.dart'; var globalMessengerKey = GlobalKey(); + Future main() async { WidgetsFlutterBinding.ensureInitialized(); await di.init(); @@ -37,6 +39,7 @@ class MyApp extends StatelessWidget { BlocProvider(create: (context) => sl()..loadFeedBlogPostList()), BlocProvider(create: (context) => sl()..loadRecipesList()), BlocProvider(create: (context) => sl()..loadDiets()), + BlocProvider(create: (context) => sl()..getPlans()), BlocProvider(create: (context) => MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))..add(MyProfileInitialEvent())), BlocProvider(create: (context) => sl()..add(LoadDiary())), BlocProvider(create: (context) => sl()..loadCalendarList()), diff --git a/pubspec.yaml b/pubspec.yaml index c746bd94..491588d1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,7 +32,7 @@ dependencies: keyboard_dismisser: ^3.0.0 retrofit: ^4.2.0 get_it: ^7.7.0 - dio: ^5.6.0 + dio: ^5.7.0 dart_pusher_channels: ^1.2.3 photo_view: ^0.15.0 dismissible_page: ^1.0.2 @@ -41,7 +41,7 @@ dependencies: badges: ^3.1.2 google_fonts: ^6.2.1 location: ^6.0.2 - syncfusion_flutter_charts: ^26.2.13 + syncfusion_flutter_charts: ^26.2.14 table_calendar: ^3.1.2 flutter_keyboard_visibility: ^6.0.0 share_plus: ^10.0.0