diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 54d180cb..0fd6fdd1 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -4,7 +4,7 @@ on: [ pull_request ] env: flutter_version: "3.22.0" - java_version: "12.x" + java_version: "17.x" flutter_channel: "stable" jobs: diff --git a/lib/app_router.dart b/lib/app_router.dart index 03a17959..c8f47968 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -16,6 +16,7 @@ import 'package:eatvio_app/features/feed/presentation/pages/feed_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'; +import 'package:eatvio_app/features/recipes/presentation/pages/recipe_edit_screen.dart'; import 'package:eatvio_app/features/registration/presentation/pages/registration_screen.dart'; import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; import 'package:eatvio_app/presentation/diets/diet_create_screen/diet_create_screen.dart'; @@ -102,6 +103,13 @@ class AppRouter { name: 'recipeCreateScreen', builder: (context, state) => RecipeCreateScreen(), ), + GoRoute( + path: '/recipe-edit-screen', + name: 'recipeEditScreen', + builder: (context, state) => RecipeEditScreen( + recipeID: state.extra as String, + ), + ), GoRoute( path: '/profile-screen', name: 'profileScreen', diff --git a/lib/core/initialization_cubit/initialization_state.freezed.dart b/lib/core/initialization_cubit/initialization_state.freezed.dart index 5d54500a..3364e440 100644 --- a/lib/core/initialization_cubit/initialization_state.freezed.dart +++ b/lib/core/initialization_cubit/initialization_state.freezed.dart @@ -24,7 +24,6 @@ mixin _$InitializationState { required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; - @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { @@ -71,31 +70,36 @@ mixin _$InitializationState { /// @nodoc abstract class $InitializationStateCopyWith<$Res> { - factory $InitializationStateCopyWith(InitializationState value, $Res Function(InitializationState) then) = + factory $InitializationStateCopyWith( + InitializationState value, $Res Function(InitializationState) then) = _$InitializationStateCopyWithImpl<$Res, InitializationState>; } /// @nodoc -class _$InitializationStateCopyWithImpl<$Res, $Val extends InitializationState> implements $InitializationStateCopyWith<$Res> { +class _$InitializationStateCopyWithImpl<$Res, $Val extends InitializationState> + implements $InitializationStateCopyWith<$Res> { _$InitializationStateCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; } /// @nodoc abstract class _$$InitializationStateImplCopyWith<$Res> { - factory _$$InitializationStateImplCopyWith(_$InitializationStateImpl value, $Res Function(_$InitializationStateImpl) then) = + factory _$$InitializationStateImplCopyWith(_$InitializationStateImpl value, + $Res Function(_$InitializationStateImpl) then) = __$$InitializationStateImplCopyWithImpl<$Res>; } /// @nodoc -class __$$InitializationStateImplCopyWithImpl<$Res> extends _$InitializationStateCopyWithImpl<$Res, _$InitializationStateImpl> +class __$$InitializationStateImplCopyWithImpl<$Res> + extends _$InitializationStateCopyWithImpl<$Res, _$InitializationStateImpl> implements _$$InitializationStateImplCopyWith<$Res> { - __$$InitializationStateImplCopyWithImpl(_$InitializationStateImpl _value, $Res Function(_$InitializationStateImpl) _then) : super(_value, _then); + __$$InitializationStateImplCopyWithImpl(_$InitializationStateImpl _value, + $Res Function(_$InitializationStateImpl) _then) + : super(_value, _then); } /// @nodoc @@ -110,7 +114,9 @@ class _$InitializationStateImpl implements _InitializationState { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$InitializationStateImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InitializationStateImpl); } @override @@ -197,14 +203,20 @@ abstract class _InitializationState implements InitializationState { /// @nodoc abstract class _$$InitializationStateLoadingImplCopyWith<$Res> { - factory _$$InitializationStateLoadingImplCopyWith(_$InitializationStateLoadingImpl value, $Res Function(_$InitializationStateLoadingImpl) then) = + factory _$$InitializationStateLoadingImplCopyWith( + _$InitializationStateLoadingImpl value, + $Res Function(_$InitializationStateLoadingImpl) then) = __$$InitializationStateLoadingImplCopyWithImpl<$Res>; } /// @nodoc -class __$$InitializationStateLoadingImplCopyWithImpl<$Res> extends _$InitializationStateCopyWithImpl<$Res, _$InitializationStateLoadingImpl> +class __$$InitializationStateLoadingImplCopyWithImpl<$Res> + extends _$InitializationStateCopyWithImpl<$Res, + _$InitializationStateLoadingImpl> implements _$$InitializationStateLoadingImplCopyWith<$Res> { - __$$InitializationStateLoadingImplCopyWithImpl(_$InitializationStateLoadingImpl _value, $Res Function(_$InitializationStateLoadingImpl) _then) + __$$InitializationStateLoadingImplCopyWithImpl( + _$InitializationStateLoadingImpl _value, + $Res Function(_$InitializationStateLoadingImpl) _then) : super(_value, _then); } @@ -220,7 +232,9 @@ class _$InitializationStateLoadingImpl implements InitializationStateLoading { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$InitializationStateLoadingImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InitializationStateLoadingImpl); } @override @@ -307,17 +321,22 @@ abstract class InitializationStateLoading implements InitializationState { /// @nodoc abstract class _$$InitializationStateSuccessImplCopyWith<$Res> { - factory _$$InitializationStateSuccessImplCopyWith(_$InitializationStateSuccessImpl value, $Res Function(_$InitializationStateSuccessImpl) then) = + factory _$$InitializationStateSuccessImplCopyWith( + _$InitializationStateSuccessImpl value, + $Res Function(_$InitializationStateSuccessImpl) then) = __$$InitializationStateSuccessImplCopyWithImpl<$Res>; - @useResult $Res call({PusherChannelsClient client}); } /// @nodoc -class __$$InitializationStateSuccessImplCopyWithImpl<$Res> extends _$InitializationStateCopyWithImpl<$Res, _$InitializationStateSuccessImpl> +class __$$InitializationStateSuccessImplCopyWithImpl<$Res> + extends _$InitializationStateCopyWithImpl<$Res, + _$InitializationStateSuccessImpl> implements _$$InitializationStateSuccessImplCopyWith<$Res> { - __$$InitializationStateSuccessImplCopyWithImpl(_$InitializationStateSuccessImpl _value, $Res Function(_$InitializationStateSuccessImpl) _then) + __$$InitializationStateSuccessImplCopyWithImpl( + _$InitializationStateSuccessImpl _value, + $Res Function(_$InitializationStateSuccessImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -350,7 +369,9 @@ class _$InitializationStateSuccessImpl implements InitializationStateSuccess { @override bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$InitializationStateSuccessImpl && (identical(other.client, client) || other.client == client)); + (other.runtimeType == runtimeType && + other is _$InitializationStateSuccessImpl && + (identical(other.client, client) || other.client == client)); } @override @@ -359,8 +380,9 @@ class _$InitializationStateSuccessImpl implements InitializationStateSuccess { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl> get copyWith => - __$$InitializationStateSuccessImplCopyWithImpl<_$InitializationStateSuccessImpl>(this, _$identity); + _$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl> + get copyWith => __$$InitializationStateSuccessImplCopyWithImpl< + _$InitializationStateSuccessImpl>(this, _$identity); @override @optionalTypeArgs @@ -438,27 +460,34 @@ class _$InitializationStateSuccessImpl implements InitializationStateSuccess { } abstract class InitializationStateSuccess implements InitializationState { - const factory InitializationStateSuccess({required final PusherChannelsClient client}) = _$InitializationStateSuccessImpl; + const factory InitializationStateSuccess( + {required final PusherChannelsClient client}) = + _$InitializationStateSuccessImpl; PusherChannelsClient get client; - @JsonKey(ignore: true) - _$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl> get copyWith => throw _privateConstructorUsedError; + _$$InitializationStateSuccessImplCopyWith<_$InitializationStateSuccessImpl> + get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class _$$InitializationStateErrorImplCopyWith<$Res> { - factory _$$InitializationStateErrorImplCopyWith(_$InitializationStateErrorImpl value, $Res Function(_$InitializationStateErrorImpl) then) = + factory _$$InitializationStateErrorImplCopyWith( + _$InitializationStateErrorImpl value, + $Res Function(_$InitializationStateErrorImpl) then) = __$$InitializationStateErrorImplCopyWithImpl<$Res>; - @useResult $Res call({String errorMessage}); } /// @nodoc -class __$$InitializationStateErrorImplCopyWithImpl<$Res> extends _$InitializationStateCopyWithImpl<$Res, _$InitializationStateErrorImpl> +class __$$InitializationStateErrorImplCopyWithImpl<$Res> + extends _$InitializationStateCopyWithImpl<$Res, + _$InitializationStateErrorImpl> implements _$$InitializationStateErrorImplCopyWith<$Res> { - __$$InitializationStateErrorImplCopyWithImpl(_$InitializationStateErrorImpl _value, $Res Function(_$InitializationStateErrorImpl) _then) + __$$InitializationStateErrorImplCopyWithImpl( + _$InitializationStateErrorImpl _value, + $Res Function(_$InitializationStateErrorImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -493,7 +522,8 @@ class _$InitializationStateErrorImpl implements InitializationStateError { return identical(this, other) || (other.runtimeType == runtimeType && other is _$InitializationStateErrorImpl && - (identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); } @override @@ -502,8 +532,9 @@ class _$InitializationStateErrorImpl implements InitializationStateError { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$InitializationStateErrorImplCopyWith<_$InitializationStateErrorImpl> get copyWith => - __$$InitializationStateErrorImplCopyWithImpl<_$InitializationStateErrorImpl>(this, _$identity); + _$$InitializationStateErrorImplCopyWith<_$InitializationStateErrorImpl> + get copyWith => __$$InitializationStateErrorImplCopyWithImpl< + _$InitializationStateErrorImpl>(this, _$identity); @override @optionalTypeArgs @@ -581,10 +612,11 @@ class _$InitializationStateErrorImpl implements InitializationStateError { } abstract class InitializationStateError implements InitializationState { - const factory InitializationStateError({required final String errorMessage}) = _$InitializationStateErrorImpl; + const factory InitializationStateError({required final String errorMessage}) = + _$InitializationStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) - _$$InitializationStateErrorImplCopyWith<_$InitializationStateErrorImpl> get copyWith => throw _privateConstructorUsedError; + _$$InitializationStateErrorImplCopyWith<_$InitializationStateErrorImpl> + get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart b/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart index 79d30b48..917785c7 100644 --- a/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart +++ b/lib/data/models/selectionPopupModel/selection_popup_model.freezed.dart @@ -17,33 +17,31 @@ final _privateConstructorUsedError = UnsupportedError( /// @nodoc mixin _$SelectionPopupModel { int? get id => throw _privateConstructorUsedError; - String get title => throw _privateConstructorUsedError; - dynamic get value => throw _privateConstructorUsedError; - bool get isSelected => throw _privateConstructorUsedError; @JsonKey(ignore: true) - $SelectionPopupModelCopyWith get copyWith => throw _privateConstructorUsedError; + $SelectionPopupModelCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $SelectionPopupModelCopyWith<$Res> { - factory $SelectionPopupModelCopyWith(SelectionPopupModel value, $Res Function(SelectionPopupModel) then) = + factory $SelectionPopupModelCopyWith( + SelectionPopupModel value, $Res Function(SelectionPopupModel) then) = _$SelectionPopupModelCopyWithImpl<$Res, SelectionPopupModel>; - @useResult $Res call({int? id, String title, dynamic value, bool isSelected}); } /// @nodoc -class _$SelectionPopupModelCopyWithImpl<$Res, $Val extends SelectionPopupModel> implements $SelectionPopupModelCopyWith<$Res> { +class _$SelectionPopupModelCopyWithImpl<$Res, $Val extends SelectionPopupModel> + implements $SelectionPopupModelCopyWith<$Res> { _$SelectionPopupModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -77,19 +75,23 @@ class _$SelectionPopupModelCopyWithImpl<$Res, $Val extends SelectionPopupModel> } /// @nodoc -abstract class _$$SelectionPopupModelImplCopyWith<$Res> implements $SelectionPopupModelCopyWith<$Res> { - factory _$$SelectionPopupModelImplCopyWith(_$SelectionPopupModelImpl value, $Res Function(_$SelectionPopupModelImpl) then) = +abstract class _$$SelectionPopupModelImplCopyWith<$Res> + implements $SelectionPopupModelCopyWith<$Res> { + factory _$$SelectionPopupModelImplCopyWith(_$SelectionPopupModelImpl value, + $Res Function(_$SelectionPopupModelImpl) then) = __$$SelectionPopupModelImplCopyWithImpl<$Res>; - @override @useResult $Res call({int? id, String title, dynamic value, bool isSelected}); } /// @nodoc -class __$$SelectionPopupModelImplCopyWithImpl<$Res> extends _$SelectionPopupModelCopyWithImpl<$Res, _$SelectionPopupModelImpl> +class __$$SelectionPopupModelImplCopyWithImpl<$Res> + extends _$SelectionPopupModelCopyWithImpl<$Res, _$SelectionPopupModelImpl> implements _$$SelectionPopupModelImplCopyWith<$Res> { - __$$SelectionPopupModelImplCopyWithImpl(_$SelectionPopupModelImpl _value, $Res Function(_$SelectionPopupModelImpl) _then) : super(_value, _then); + __$$SelectionPopupModelImplCopyWithImpl(_$SelectionPopupModelImpl _value, + $Res Function(_$SelectionPopupModelImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -123,7 +125,8 @@ class __$$SelectionPopupModelImplCopyWithImpl<$Res> extends _$SelectionPopupMode /// @nodoc class _$SelectionPopupModelImpl implements _SelectionPopupModel { - const _$SelectionPopupModelImpl({this.id, required this.title, this.value, this.isSelected = false}); + const _$SelectionPopupModelImpl( + {this.id, required this.title, this.value, this.isSelected = false}); @override final int? id; @@ -148,35 +151,39 @@ class _$SelectionPopupModelImpl implements _SelectionPopupModel { (identical(other.id, id) || other.id == id) && (identical(other.title, title) || other.title == title) && const DeepCollectionEquality().equals(other.value, value) && - (identical(other.isSelected, isSelected) || other.isSelected == isSelected)); + (identical(other.isSelected, isSelected) || + other.isSelected == isSelected)); } @override - int get hashCode => Object.hash(runtimeType, id, title, const DeepCollectionEquality().hash(value), isSelected); + int get hashCode => Object.hash(runtimeType, id, title, + const DeepCollectionEquality().hash(value), isSelected); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$SelectionPopupModelImplCopyWith<_$SelectionPopupModelImpl> get copyWith => - __$$SelectionPopupModelImplCopyWithImpl<_$SelectionPopupModelImpl>(this, _$identity); + __$$SelectionPopupModelImplCopyWithImpl<_$SelectionPopupModelImpl>( + this, _$identity); } abstract class _SelectionPopupModel implements SelectionPopupModel { - const factory _SelectionPopupModel({final int? id, required final String title, final dynamic value, final bool isSelected}) = _$SelectionPopupModelImpl; + const factory _SelectionPopupModel( + {final int? id, + required final String title, + final dynamic value, + final bool isSelected}) = _$SelectionPopupModelImpl; @override int? get id; - @override String get title; - @override dynamic get value; - @override bool get isSelected; - @override @JsonKey(ignore: true) - _$$SelectionPopupModelImplCopyWith<_$SelectionPopupModelImpl> get copyWith => throw _privateConstructorUsedError; + _$$SelectionPopupModelImplCopyWith<_$SelectionPopupModelImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.freezed.dart b/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.freezed.dart index e150ef99..02a1c4bd 100644 --- a/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.freezed.dart +++ b/lib/features/bottom_navigation_bar/presentation/bloc/new_messages_cubit/new_messages_state.freezed.dart @@ -24,7 +24,6 @@ mixin _$NewMessagesState { required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; - @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { @@ -71,30 +70,36 @@ mixin _$NewMessagesState { /// @nodoc abstract class $NewMessagesStateCopyWith<$Res> { - factory $NewMessagesStateCopyWith(NewMessagesState value, $Res Function(NewMessagesState) then) = _$NewMessagesStateCopyWithImpl<$Res, NewMessagesState>; + factory $NewMessagesStateCopyWith( + NewMessagesState value, $Res Function(NewMessagesState) then) = + _$NewMessagesStateCopyWithImpl<$Res, NewMessagesState>; } /// @nodoc -class _$NewMessagesStateCopyWithImpl<$Res, $Val extends NewMessagesState> implements $NewMessagesStateCopyWith<$Res> { +class _$NewMessagesStateCopyWithImpl<$Res, $Val extends NewMessagesState> + implements $NewMessagesStateCopyWith<$Res> { _$NewMessagesStateCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; } /// @nodoc abstract class _$$NewMessagesStateImplCopyWith<$Res> { - factory _$$NewMessagesStateImplCopyWith(_$NewMessagesStateImpl value, $Res Function(_$NewMessagesStateImpl) then) = + factory _$$NewMessagesStateImplCopyWith(_$NewMessagesStateImpl value, + $Res Function(_$NewMessagesStateImpl) then) = __$$NewMessagesStateImplCopyWithImpl<$Res>; } /// @nodoc -class __$$NewMessagesStateImplCopyWithImpl<$Res> extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateImpl> +class __$$NewMessagesStateImplCopyWithImpl<$Res> + extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateImpl> implements _$$NewMessagesStateImplCopyWith<$Res> { - __$$NewMessagesStateImplCopyWithImpl(_$NewMessagesStateImpl _value, $Res Function(_$NewMessagesStateImpl) _then) : super(_value, _then); + __$$NewMessagesStateImplCopyWithImpl(_$NewMessagesStateImpl _value, + $Res Function(_$NewMessagesStateImpl) _then) + : super(_value, _then); } /// @nodoc @@ -109,7 +114,8 @@ class _$NewMessagesStateImpl implements _NewMessagesState { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$NewMessagesStateImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$NewMessagesStateImpl); } @override @@ -196,14 +202,19 @@ abstract class _NewMessagesState implements NewMessagesState { /// @nodoc abstract class _$$NewMessagesStateEmptyImplCopyWith<$Res> { - factory _$$NewMessagesStateEmptyImplCopyWith(_$NewMessagesStateEmptyImpl value, $Res Function(_$NewMessagesStateEmptyImpl) then) = + factory _$$NewMessagesStateEmptyImplCopyWith( + _$NewMessagesStateEmptyImpl value, + $Res Function(_$NewMessagesStateEmptyImpl) then) = __$$NewMessagesStateEmptyImplCopyWithImpl<$Res>; } /// @nodoc -class __$$NewMessagesStateEmptyImplCopyWithImpl<$Res> extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateEmptyImpl> +class __$$NewMessagesStateEmptyImplCopyWithImpl<$Res> + extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateEmptyImpl> implements _$$NewMessagesStateEmptyImplCopyWith<$Res> { - __$$NewMessagesStateEmptyImplCopyWithImpl(_$NewMessagesStateEmptyImpl _value, $Res Function(_$NewMessagesStateEmptyImpl) _then) : super(_value, _then); + __$$NewMessagesStateEmptyImplCopyWithImpl(_$NewMessagesStateEmptyImpl _value, + $Res Function(_$NewMessagesStateEmptyImpl) _then) + : super(_value, _then); } /// @nodoc @@ -218,7 +229,9 @@ class _$NewMessagesStateEmptyImpl implements NewMessagesStateEmpty { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$NewMessagesStateEmptyImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$NewMessagesStateEmptyImpl); } @override @@ -305,17 +318,22 @@ abstract class NewMessagesStateEmpty implements NewMessagesState { /// @nodoc abstract class _$$NewMessagesStateLoadedImplCopyWith<$Res> { - factory _$$NewMessagesStateLoadedImplCopyWith(_$NewMessagesStateLoadedImpl value, $Res Function(_$NewMessagesStateLoadedImpl) then) = + factory _$$NewMessagesStateLoadedImplCopyWith( + _$NewMessagesStateLoadedImpl value, + $Res Function(_$NewMessagesStateLoadedImpl) then) = __$$NewMessagesStateLoadedImplCopyWithImpl<$Res>; - @useResult $Res call({int messagesCount}); } /// @nodoc -class __$$NewMessagesStateLoadedImplCopyWithImpl<$Res> extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateLoadedImpl> +class __$$NewMessagesStateLoadedImplCopyWithImpl<$Res> + extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateLoadedImpl> implements _$$NewMessagesStateLoadedImplCopyWith<$Res> { - __$$NewMessagesStateLoadedImplCopyWithImpl(_$NewMessagesStateLoadedImpl _value, $Res Function(_$NewMessagesStateLoadedImpl) _then) : super(_value, _then); + __$$NewMessagesStateLoadedImplCopyWithImpl( + _$NewMessagesStateLoadedImpl _value, + $Res Function(_$NewMessagesStateLoadedImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -349,7 +367,8 @@ class _$NewMessagesStateLoadedImpl implements NewMessagesStateLoaded { return identical(this, other) || (other.runtimeType == runtimeType && other is _$NewMessagesStateLoadedImpl && - (identical(other.messagesCount, messagesCount) || other.messagesCount == messagesCount)); + (identical(other.messagesCount, messagesCount) || + other.messagesCount == messagesCount)); } @override @@ -358,8 +377,9 @@ class _$NewMessagesStateLoadedImpl implements NewMessagesStateLoaded { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl> get copyWith => - __$$NewMessagesStateLoadedImplCopyWithImpl<_$NewMessagesStateLoadedImpl>(this, _$identity); + _$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl> + get copyWith => __$$NewMessagesStateLoadedImplCopyWithImpl< + _$NewMessagesStateLoadedImpl>(this, _$identity); @override @optionalTypeArgs @@ -437,27 +457,32 @@ class _$NewMessagesStateLoadedImpl implements NewMessagesStateLoaded { } abstract class NewMessagesStateLoaded implements NewMessagesState { - const factory NewMessagesStateLoaded({required final int messagesCount}) = _$NewMessagesStateLoadedImpl; + const factory NewMessagesStateLoaded({required final int messagesCount}) = + _$NewMessagesStateLoadedImpl; int get messagesCount; - @JsonKey(ignore: true) - _$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; + _$$NewMessagesStateLoadedImplCopyWith<_$NewMessagesStateLoadedImpl> + get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class _$$NewMessagesStateErrorImplCopyWith<$Res> { - factory _$$NewMessagesStateErrorImplCopyWith(_$NewMessagesStateErrorImpl value, $Res Function(_$NewMessagesStateErrorImpl) then) = + factory _$$NewMessagesStateErrorImplCopyWith( + _$NewMessagesStateErrorImpl value, + $Res Function(_$NewMessagesStateErrorImpl) then) = __$$NewMessagesStateErrorImplCopyWithImpl<$Res>; - @useResult $Res call({String errorMessage}); } /// @nodoc -class __$$NewMessagesStateErrorImplCopyWithImpl<$Res> extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateErrorImpl> +class __$$NewMessagesStateErrorImplCopyWithImpl<$Res> + extends _$NewMessagesStateCopyWithImpl<$Res, _$NewMessagesStateErrorImpl> implements _$$NewMessagesStateErrorImplCopyWith<$Res> { - __$$NewMessagesStateErrorImplCopyWithImpl(_$NewMessagesStateErrorImpl _value, $Res Function(_$NewMessagesStateErrorImpl) _then) : super(_value, _then); + __$$NewMessagesStateErrorImplCopyWithImpl(_$NewMessagesStateErrorImpl _value, + $Res Function(_$NewMessagesStateErrorImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -491,7 +516,8 @@ class _$NewMessagesStateErrorImpl implements NewMessagesStateError { return identical(this, other) || (other.runtimeType == runtimeType && other is _$NewMessagesStateErrorImpl && - (identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); } @override @@ -500,8 +526,9 @@ class _$NewMessagesStateErrorImpl implements NewMessagesStateError { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$NewMessagesStateErrorImplCopyWith<_$NewMessagesStateErrorImpl> get copyWith => - __$$NewMessagesStateErrorImplCopyWithImpl<_$NewMessagesStateErrorImpl>(this, _$identity); + _$$NewMessagesStateErrorImplCopyWith<_$NewMessagesStateErrorImpl> + get copyWith => __$$NewMessagesStateErrorImplCopyWithImpl< + _$NewMessagesStateErrorImpl>(this, _$identity); @override @optionalTypeArgs @@ -579,10 +606,11 @@ class _$NewMessagesStateErrorImpl implements NewMessagesStateError { } abstract class NewMessagesStateError implements NewMessagesState { - const factory NewMessagesStateError({required final String errorMessage}) = _$NewMessagesStateErrorImpl; + const factory NewMessagesStateError({required final String errorMessage}) = + _$NewMessagesStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) - _$$NewMessagesStateErrorImplCopyWith<_$NewMessagesStateErrorImpl> get copyWith => throw _privateConstructorUsedError; + _$$NewMessagesStateErrorImplCopyWith<_$NewMessagesStateErrorImpl> + get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.freezed.dart b/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.freezed.dart index b4b95e0c..0deeebbd 100644 --- a/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.freezed.dart +++ b/lib/features/bottom_navigation_bar/presentation/bloc/notifications_cubit/notifications_state.freezed.dart @@ -24,7 +24,6 @@ mixin _$NotificationsState { required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; - @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { @@ -71,31 +70,36 @@ mixin _$NotificationsState { /// @nodoc abstract class $NotificationsStateCopyWith<$Res> { - factory $NotificationsStateCopyWith(NotificationsState value, $Res Function(NotificationsState) then) = + factory $NotificationsStateCopyWith( + NotificationsState value, $Res Function(NotificationsState) then) = _$NotificationsStateCopyWithImpl<$Res, NotificationsState>; } /// @nodoc -class _$NotificationsStateCopyWithImpl<$Res, $Val extends NotificationsState> implements $NotificationsStateCopyWith<$Res> { +class _$NotificationsStateCopyWithImpl<$Res, $Val extends NotificationsState> + implements $NotificationsStateCopyWith<$Res> { _$NotificationsStateCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; } /// @nodoc abstract class _$$NotificationsStateImplCopyWith<$Res> { - factory _$$NotificationsStateImplCopyWith(_$NotificationsStateImpl value, $Res Function(_$NotificationsStateImpl) then) = + factory _$$NotificationsStateImplCopyWith(_$NotificationsStateImpl value, + $Res Function(_$NotificationsStateImpl) then) = __$$NotificationsStateImplCopyWithImpl<$Res>; } /// @nodoc -class __$$NotificationsStateImplCopyWithImpl<$Res> extends _$NotificationsStateCopyWithImpl<$Res, _$NotificationsStateImpl> +class __$$NotificationsStateImplCopyWithImpl<$Res> + extends _$NotificationsStateCopyWithImpl<$Res, _$NotificationsStateImpl> implements _$$NotificationsStateImplCopyWith<$Res> { - __$$NotificationsStateImplCopyWithImpl(_$NotificationsStateImpl _value, $Res Function(_$NotificationsStateImpl) _then) : super(_value, _then); + __$$NotificationsStateImplCopyWithImpl(_$NotificationsStateImpl _value, + $Res Function(_$NotificationsStateImpl) _then) + : super(_value, _then); } /// @nodoc @@ -110,7 +114,8 @@ class _$NotificationsStateImpl implements _NotificationsState { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$NotificationsStateImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$NotificationsStateImpl); } @override @@ -197,14 +202,21 @@ abstract class _NotificationsState implements NotificationsState { /// @nodoc abstract class _$$NotificationsStateEmptyImplCopyWith<$Res> { - factory _$$NotificationsStateEmptyImplCopyWith(_$NotificationsStateEmptyImpl value, $Res Function(_$NotificationsStateEmptyImpl) then) = + factory _$$NotificationsStateEmptyImplCopyWith( + _$NotificationsStateEmptyImpl value, + $Res Function(_$NotificationsStateEmptyImpl) then) = __$$NotificationsStateEmptyImplCopyWithImpl<$Res>; } /// @nodoc -class __$$NotificationsStateEmptyImplCopyWithImpl<$Res> extends _$NotificationsStateCopyWithImpl<$Res, _$NotificationsStateEmptyImpl> +class __$$NotificationsStateEmptyImplCopyWithImpl<$Res> + extends _$NotificationsStateCopyWithImpl<$Res, + _$NotificationsStateEmptyImpl> implements _$$NotificationsStateEmptyImplCopyWith<$Res> { - __$$NotificationsStateEmptyImplCopyWithImpl(_$NotificationsStateEmptyImpl _value, $Res Function(_$NotificationsStateEmptyImpl) _then) : super(_value, _then); + __$$NotificationsStateEmptyImplCopyWithImpl( + _$NotificationsStateEmptyImpl _value, + $Res Function(_$NotificationsStateEmptyImpl) _then) + : super(_value, _then); } /// @nodoc @@ -219,7 +231,9 @@ class _$NotificationsStateEmptyImpl implements NotificationsStateEmpty { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$NotificationsStateEmptyImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$NotificationsStateEmptyImpl); } @override @@ -306,17 +320,22 @@ abstract class NotificationsStateEmpty implements NotificationsState { /// @nodoc abstract class _$$NotificationsStateLoadedImplCopyWith<$Res> { - factory _$$NotificationsStateLoadedImplCopyWith(_$NotificationsStateLoadedImpl value, $Res Function(_$NotificationsStateLoadedImpl) then) = + factory _$$NotificationsStateLoadedImplCopyWith( + _$NotificationsStateLoadedImpl value, + $Res Function(_$NotificationsStateLoadedImpl) then) = __$$NotificationsStateLoadedImplCopyWithImpl<$Res>; - @useResult $Res call({int notificationsCount}); } /// @nodoc -class __$$NotificationsStateLoadedImplCopyWithImpl<$Res> extends _$NotificationsStateCopyWithImpl<$Res, _$NotificationsStateLoadedImpl> +class __$$NotificationsStateLoadedImplCopyWithImpl<$Res> + extends _$NotificationsStateCopyWithImpl<$Res, + _$NotificationsStateLoadedImpl> implements _$$NotificationsStateLoadedImplCopyWith<$Res> { - __$$NotificationsStateLoadedImplCopyWithImpl(_$NotificationsStateLoadedImpl _value, $Res Function(_$NotificationsStateLoadedImpl) _then) + __$$NotificationsStateLoadedImplCopyWithImpl( + _$NotificationsStateLoadedImpl _value, + $Res Function(_$NotificationsStateLoadedImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -351,7 +370,8 @@ class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { return identical(this, other) || (other.runtimeType == runtimeType && other is _$NotificationsStateLoadedImpl && - (identical(other.notificationsCount, notificationsCount) || other.notificationsCount == notificationsCount)); + (identical(other.notificationsCount, notificationsCount) || + other.notificationsCount == notificationsCount)); } @override @@ -360,8 +380,9 @@ class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl> get copyWith => - __$$NotificationsStateLoadedImplCopyWithImpl<_$NotificationsStateLoadedImpl>(this, _$identity); + _$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl> + get copyWith => __$$NotificationsStateLoadedImplCopyWithImpl< + _$NotificationsStateLoadedImpl>(this, _$identity); @override @optionalTypeArgs @@ -439,27 +460,34 @@ class _$NotificationsStateLoadedImpl implements NotificationsStateLoaded { } abstract class NotificationsStateLoaded implements NotificationsState { - const factory NotificationsStateLoaded({required final int notificationsCount}) = _$NotificationsStateLoadedImpl; + const factory NotificationsStateLoaded( + {required final int notificationsCount}) = _$NotificationsStateLoadedImpl; int get notificationsCount; - @JsonKey(ignore: true) - _$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; + _$$NotificationsStateLoadedImplCopyWith<_$NotificationsStateLoadedImpl> + get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class _$$NotificationsStateErrorImplCopyWith<$Res> { - factory _$$NotificationsStateErrorImplCopyWith(_$NotificationsStateErrorImpl value, $Res Function(_$NotificationsStateErrorImpl) then) = + factory _$$NotificationsStateErrorImplCopyWith( + _$NotificationsStateErrorImpl value, + $Res Function(_$NotificationsStateErrorImpl) then) = __$$NotificationsStateErrorImplCopyWithImpl<$Res>; - @useResult $Res call({String errorMessage}); } /// @nodoc -class __$$NotificationsStateErrorImplCopyWithImpl<$Res> extends _$NotificationsStateCopyWithImpl<$Res, _$NotificationsStateErrorImpl> +class __$$NotificationsStateErrorImplCopyWithImpl<$Res> + extends _$NotificationsStateCopyWithImpl<$Res, + _$NotificationsStateErrorImpl> implements _$$NotificationsStateErrorImplCopyWith<$Res> { - __$$NotificationsStateErrorImplCopyWithImpl(_$NotificationsStateErrorImpl _value, $Res Function(_$NotificationsStateErrorImpl) _then) : super(_value, _then); + __$$NotificationsStateErrorImplCopyWithImpl( + _$NotificationsStateErrorImpl _value, + $Res Function(_$NotificationsStateErrorImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -493,7 +521,8 @@ class _$NotificationsStateErrorImpl implements NotificationsStateError { return identical(this, other) || (other.runtimeType == runtimeType && other is _$NotificationsStateErrorImpl && - (identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); } @override @@ -502,8 +531,9 @@ class _$NotificationsStateErrorImpl implements NotificationsStateError { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$NotificationsStateErrorImplCopyWith<_$NotificationsStateErrorImpl> get copyWith => - __$$NotificationsStateErrorImplCopyWithImpl<_$NotificationsStateErrorImpl>(this, _$identity); + _$$NotificationsStateErrorImplCopyWith<_$NotificationsStateErrorImpl> + get copyWith => __$$NotificationsStateErrorImplCopyWithImpl< + _$NotificationsStateErrorImpl>(this, _$identity); @override @optionalTypeArgs @@ -581,10 +611,11 @@ class _$NotificationsStateErrorImpl implements NotificationsStateError { } abstract class NotificationsStateError implements NotificationsState { - const factory NotificationsStateError({required final String errorMessage}) = _$NotificationsStateErrorImpl; + const factory NotificationsStateError({required final String errorMessage}) = + _$NotificationsStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) - _$$NotificationsStateErrorImplCopyWith<_$NotificationsStateErrorImpl> get copyWith => throw _privateConstructorUsedError; + _$$NotificationsStateErrorImplCopyWith<_$NotificationsStateErrorImpl> + get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/calendar/services/calendar_service.g.dart b/lib/features/calendar/services/calendar_service.g.dart index 4dec81f0..903145dc 100644 --- a/lib/features/calendar/services/calendar_service.g.dart +++ b/lib/features/calendar/services/calendar_service.g.dart @@ -12,38 +12,47 @@ class _CalendarService implements CalendarService { _CalendarService( this._dio, { this.baseUrl, + this.errorLogger, }); final Dio _dio; String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future> getCalendar() async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType>(Options( + final _options = _setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/calendar/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - var _value = _result.data! - .map((dynamic i) => CalendarModel.fromJson(i as Map)) - .toList(); + .compose( + _dio.options, + '/api/calendar/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late List _value; + try { + _value = _result.data! + .map((dynamic i) => CalendarModel.fromJson(i as Map)) + .toList(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/features/chat/models/chat_message_model.freezed.dart b/lib/features/chat/models/chat_message_model.freezed.dart index 6dfda166..76a91cbc 100644 --- a/lib/features/chat/models/chat_message_model.freezed.dart +++ b/lib/features/chat/models/chat_message_model.freezed.dart @@ -21,28 +21,25 @@ ChatMessageModel _$ChatMessageModelFromJson(Map json) { /// @nodoc mixin _$ChatMessageModel { int get id => throw _privateConstructorUsedError; - String get data => throw _privateConstructorUsedError; - @JsonKey(name: 'media_data') List? get mediaData => throw _privateConstructorUsedError; - @JsonKey(name: 'author_id') int get authorId => throw _privateConstructorUsedError; - @JsonKey(name: 'updated_at') String get updatedAt => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $ChatMessageModelCopyWith get copyWith => throw _privateConstructorUsedError; + $ChatMessageModelCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $ChatMessageModelCopyWith<$Res> { - factory $ChatMessageModelCopyWith(ChatMessageModel value, $Res Function(ChatMessageModel) then) = _$ChatMessageModelCopyWithImpl<$Res, ChatMessageModel>; - + factory $ChatMessageModelCopyWith( + ChatMessageModel value, $Res Function(ChatMessageModel) then) = + _$ChatMessageModelCopyWithImpl<$Res, ChatMessageModel>; @useResult $Res call( {int id, @@ -53,12 +50,12 @@ abstract class $ChatMessageModelCopyWith<$Res> { } /// @nodoc -class _$ChatMessageModelCopyWithImpl<$Res, $Val extends ChatMessageModel> implements $ChatMessageModelCopyWith<$Res> { +class _$ChatMessageModelCopyWithImpl<$Res, $Val extends ChatMessageModel> + implements $ChatMessageModelCopyWith<$Res> { _$ChatMessageModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -97,10 +94,11 @@ class _$ChatMessageModelCopyWithImpl<$Res, $Val extends ChatMessageModel> implem } /// @nodoc -abstract class _$$ChatMessageModelImplCopyWith<$Res> implements $ChatMessageModelCopyWith<$Res> { - factory _$$ChatMessageModelImplCopyWith(_$ChatMessageModelImpl value, $Res Function(_$ChatMessageModelImpl) then) = +abstract class _$$ChatMessageModelImplCopyWith<$Res> + implements $ChatMessageModelCopyWith<$Res> { + factory _$$ChatMessageModelImplCopyWith(_$ChatMessageModelImpl value, + $Res Function(_$ChatMessageModelImpl) then) = __$$ChatMessageModelImplCopyWithImpl<$Res>; - @override @useResult $Res call( @@ -112,9 +110,12 @@ abstract class _$$ChatMessageModelImplCopyWith<$Res> implements $ChatMessageMode } /// @nodoc -class __$$ChatMessageModelImplCopyWithImpl<$Res> extends _$ChatMessageModelCopyWithImpl<$Res, _$ChatMessageModelImpl> +class __$$ChatMessageModelImplCopyWithImpl<$Res> + extends _$ChatMessageModelCopyWithImpl<$Res, _$ChatMessageModelImpl> implements _$$ChatMessageModelImplCopyWith<$Res> { - __$$ChatMessageModelImplCopyWithImpl(_$ChatMessageModelImpl _value, $Res Function(_$ChatMessageModelImpl) _then) : super(_value, _then); + __$$ChatMessageModelImplCopyWithImpl(_$ChatMessageModelImpl _value, + $Res Function(_$ChatMessageModelImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -161,14 +162,14 @@ class _$ChatMessageModelImpl implements _ChatMessageModel { @JsonKey(name: 'updated_at') required this.updatedAt}) : _mediaData = mediaData; - factory _$ChatMessageModelImpl.fromJson(Map json) => _$$ChatMessageModelImplFromJson(json); + factory _$ChatMessageModelImpl.fromJson(Map json) => + _$$ChatMessageModelImplFromJson(json); @override final int id; @override final String data; final List? _mediaData; - @override @JsonKey(name: 'media_data') List? get mediaData { @@ -198,19 +199,25 @@ class _$ChatMessageModelImpl implements _ChatMessageModel { other is _$ChatMessageModelImpl && (identical(other.id, id) || other.id == id) && (identical(other.data, data) || other.data == data) && - const DeepCollectionEquality().equals(other._mediaData, _mediaData) && - (identical(other.authorId, authorId) || other.authorId == authorId) && - (identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)); + const DeepCollectionEquality() + .equals(other._mediaData, _mediaData) && + (identical(other.authorId, authorId) || + other.authorId == authorId) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, data, const DeepCollectionEquality().hash(_mediaData), authorId, updatedAt); + int get hashCode => Object.hash(runtimeType, id, data, + const DeepCollectionEquality().hash(_mediaData), authorId, updatedAt); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$ChatMessageModelImplCopyWith<_$ChatMessageModelImpl> get copyWith => __$$ChatMessageModelImplCopyWithImpl<_$ChatMessageModelImpl>(this, _$identity); + _$$ChatMessageModelImplCopyWith<_$ChatMessageModelImpl> get copyWith => + __$$ChatMessageModelImplCopyWithImpl<_$ChatMessageModelImpl>( + this, _$identity); @override Map toJson() { @@ -222,33 +229,31 @@ class _$ChatMessageModelImpl implements _ChatMessageModel { abstract class _ChatMessageModel implements ChatMessageModel { const factory _ChatMessageModel( - {required final int id, - required final String data, - @JsonKey(name: 'media_data') required final List? mediaData, - @JsonKey(name: 'author_id') required final int authorId, - @JsonKey(name: 'updated_at') required final String updatedAt}) = _$ChatMessageModelImpl; + {required final int id, + required final String data, + @JsonKey(name: 'media_data') required final List? mediaData, + @JsonKey(name: 'author_id') required final int authorId, + @JsonKey(name: 'updated_at') required final String updatedAt}) = + _$ChatMessageModelImpl; - factory _ChatMessageModel.fromJson(Map json) = _$ChatMessageModelImpl.fromJson; + factory _ChatMessageModel.fromJson(Map json) = + _$ChatMessageModelImpl.fromJson; @override int get id; - @override String get data; - @override @JsonKey(name: 'media_data') List? get mediaData; - @override @JsonKey(name: 'author_id') int get authorId; - @override @JsonKey(name: 'updated_at') String get updatedAt; - @override @JsonKey(ignore: true) - _$$ChatMessageModelImplCopyWith<_$ChatMessageModelImpl> get copyWith => throw _privateConstructorUsedError; + _$$ChatMessageModelImplCopyWith<_$ChatMessageModelImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_message_model.g.dart b/lib/features/chat/models/chat_message_model.g.dart index 70531099..3a8d1827 100644 --- a/lib/features/chat/models/chat_message_model.g.dart +++ b/lib/features/chat/models/chat_message_model.g.dart @@ -6,7 +6,9 @@ part of 'chat_message_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ChatMessageModelImpl _$$ChatMessageModelImplFromJson(Map json) => _$ChatMessageModelImpl( +_$ChatMessageModelImpl _$$ChatMessageModelImplFromJson( + Map json) => + _$ChatMessageModelImpl( id: (json['id'] as num).toInt(), data: json['data'] as String, mediaData: json['media_data'] as List?, @@ -14,7 +16,9 @@ _$ChatMessageModelImpl _$$ChatMessageModelImplFromJson(Map json updatedAt: json['updated_at'] as String, ); -Map _$$ChatMessageModelImplToJson(_$ChatMessageModelImpl instance) => { +Map _$$ChatMessageModelImplToJson( + _$ChatMessageModelImpl instance) => + { 'id': instance.id, 'data': instance.data, 'media_data': instance.mediaData, diff --git a/lib/features/chat/models/chat_meta_model.freezed.dart b/lib/features/chat/models/chat_meta_model.freezed.dart index 206048fa..11ecb9e2 100644 --- a/lib/features/chat/models/chat_meta_model.freezed.dart +++ b/lib/features/chat/models/chat_meta_model.freezed.dart @@ -24,26 +24,27 @@ mixin _$ChatMetaModel { int get lastPage => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $ChatMetaModelCopyWith get copyWith => throw _privateConstructorUsedError; + $ChatMetaModelCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $ChatMetaModelCopyWith<$Res> { - factory $ChatMetaModelCopyWith(ChatMetaModel value, $Res Function(ChatMetaModel) then) = _$ChatMetaModelCopyWithImpl<$Res, ChatMetaModel>; - + factory $ChatMetaModelCopyWith( + ChatMetaModel value, $Res Function(ChatMetaModel) then) = + _$ChatMetaModelCopyWithImpl<$Res, ChatMetaModel>; @useResult $Res call({@JsonKey(name: "last_page") int lastPage}); } /// @nodoc -class _$ChatMetaModelCopyWithImpl<$Res, $Val extends ChatMetaModel> implements $ChatMetaModelCopyWith<$Res> { +class _$ChatMetaModelCopyWithImpl<$Res, $Val extends ChatMetaModel> + implements $ChatMetaModelCopyWith<$Res> { _$ChatMetaModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -62,17 +63,23 @@ class _$ChatMetaModelCopyWithImpl<$Res, $Val extends ChatMetaModel> implements $ } /// @nodoc -abstract class _$$ChatMetaModelImplCopyWith<$Res> implements $ChatMetaModelCopyWith<$Res> { - factory _$$ChatMetaModelImplCopyWith(_$ChatMetaModelImpl value, $Res Function(_$ChatMetaModelImpl) then) = __$$ChatMetaModelImplCopyWithImpl<$Res>; - +abstract class _$$ChatMetaModelImplCopyWith<$Res> + implements $ChatMetaModelCopyWith<$Res> { + factory _$$ChatMetaModelImplCopyWith( + _$ChatMetaModelImpl value, $Res Function(_$ChatMetaModelImpl) then) = + __$$ChatMetaModelImplCopyWithImpl<$Res>; @override @useResult $Res call({@JsonKey(name: "last_page") int lastPage}); } /// @nodoc -class __$$ChatMetaModelImplCopyWithImpl<$Res> extends _$ChatMetaModelCopyWithImpl<$Res, _$ChatMetaModelImpl> implements _$$ChatMetaModelImplCopyWith<$Res> { - __$$ChatMetaModelImplCopyWithImpl(_$ChatMetaModelImpl _value, $Res Function(_$ChatMetaModelImpl) _then) : super(_value, _then); +class __$$ChatMetaModelImplCopyWithImpl<$Res> + extends _$ChatMetaModelCopyWithImpl<$Res, _$ChatMetaModelImpl> + implements _$$ChatMetaModelImplCopyWith<$Res> { + __$$ChatMetaModelImplCopyWithImpl( + _$ChatMetaModelImpl _value, $Res Function(_$ChatMetaModelImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -91,9 +98,11 @@ class __$$ChatMetaModelImplCopyWithImpl<$Res> extends _$ChatMetaModelCopyWithImp /// @nodoc @JsonSerializable() class _$ChatMetaModelImpl implements _ChatMetaModel { - const _$ChatMetaModelImpl({@JsonKey(name: "last_page") required this.lastPage}); + const _$ChatMetaModelImpl( + {@JsonKey(name: "last_page") required this.lastPage}); - factory _$ChatMetaModelImpl.fromJson(Map json) => _$$ChatMetaModelImplFromJson(json); + factory _$ChatMetaModelImpl.fromJson(Map json) => + _$$ChatMetaModelImplFromJson(json); @override @JsonKey(name: "last_page") @@ -107,7 +116,10 @@ class _$ChatMetaModelImpl implements _ChatMetaModel { @override bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$ChatMetaModelImpl && (identical(other.lastPage, lastPage) || other.lastPage == lastPage)); + (other.runtimeType == runtimeType && + other is _$ChatMetaModelImpl && + (identical(other.lastPage, lastPage) || + other.lastPage == lastPage)); } @JsonKey(ignore: true) @@ -117,7 +129,8 @@ class _$ChatMetaModelImpl implements _ChatMetaModel { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$ChatMetaModelImplCopyWith<_$ChatMetaModelImpl> get copyWith => __$$ChatMetaModelImplCopyWithImpl<_$ChatMetaModelImpl>(this, _$identity); + _$$ChatMetaModelImplCopyWith<_$ChatMetaModelImpl> get copyWith => + __$$ChatMetaModelImplCopyWithImpl<_$ChatMetaModelImpl>(this, _$identity); @override Map toJson() { @@ -128,15 +141,18 @@ class _$ChatMetaModelImpl implements _ChatMetaModel { } abstract class _ChatMetaModel implements ChatMetaModel { - const factory _ChatMetaModel({@JsonKey(name: "last_page") required final int lastPage}) = _$ChatMetaModelImpl; + const factory _ChatMetaModel( + {@JsonKey(name: "last_page") required final int lastPage}) = + _$ChatMetaModelImpl; - factory _ChatMetaModel.fromJson(Map json) = _$ChatMetaModelImpl.fromJson; + factory _ChatMetaModel.fromJson(Map json) = + _$ChatMetaModelImpl.fromJson; @override @JsonKey(name: "last_page") int get lastPage; - @override @JsonKey(ignore: true) - _$$ChatMetaModelImplCopyWith<_$ChatMetaModelImpl> get copyWith => throw _privateConstructorUsedError; + _$$ChatMetaModelImplCopyWith<_$ChatMetaModelImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_meta_model.g.dart b/lib/features/chat/models/chat_meta_model.g.dart index bbd16d10..7126e2dd 100644 --- a/lib/features/chat/models/chat_meta_model.g.dart +++ b/lib/features/chat/models/chat_meta_model.g.dart @@ -6,10 +6,12 @@ part of 'chat_meta_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ChatMetaModelImpl _$$ChatMetaModelImplFromJson(Map json) => _$ChatMetaModelImpl( +_$ChatMetaModelImpl _$$ChatMetaModelImplFromJson(Map json) => + _$ChatMetaModelImpl( lastPage: (json['last_page'] as num).toInt(), ); -Map _$$ChatMetaModelImplToJson(_$ChatMetaModelImpl instance) => { +Map _$$ChatMetaModelImplToJson(_$ChatMetaModelImpl instance) => + { 'last_page': instance.lastPage, }; diff --git a/lib/features/chat/models/chat_room_model.freezed.dart b/lib/features/chat/models/chat_room_model.freezed.dart index 26066239..5a0b6e62 100644 --- a/lib/features/chat/models/chat_room_model.freezed.dart +++ b/lib/features/chat/models/chat_room_model.freezed.dart @@ -21,35 +21,39 @@ ChatRoomModel _$ChatRoomModelFromJson(Map json) { /// @nodoc mixin _$ChatRoomModel { String get id => throw _privateConstructorUsedError; - @JsonKey(name: 'chat_room_setting') - ChatRoomSettingsModel get chatRoomSettings => throw _privateConstructorUsedError; - + ChatRoomSettingsModel get chatRoomSettings => + throw _privateConstructorUsedError; Map get users => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $ChatRoomModelCopyWith get copyWith => throw _privateConstructorUsedError; + $ChatRoomModelCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $ChatRoomModelCopyWith<$Res> { - factory $ChatRoomModelCopyWith(ChatRoomModel value, $Res Function(ChatRoomModel) then) = _$ChatRoomModelCopyWithImpl<$Res, ChatRoomModel>; - + factory $ChatRoomModelCopyWith( + ChatRoomModel value, $Res Function(ChatRoomModel) then) = + _$ChatRoomModelCopyWithImpl<$Res, ChatRoomModel>; @useResult - $Res call({String id, @JsonKey(name: 'chat_room_setting') ChatRoomSettingsModel chatRoomSettings, Map users}); + $Res call( + {String id, + @JsonKey(name: 'chat_room_setting') + ChatRoomSettingsModel chatRoomSettings, + Map users}); $ChatRoomSettingsModelCopyWith<$Res> get chatRoomSettings; } /// @nodoc -class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel> implements $ChatRoomModelCopyWith<$Res> { +class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel> + implements $ChatRoomModelCopyWith<$Res> { _$ChatRoomModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -79,27 +83,38 @@ class _$ChatRoomModelCopyWithImpl<$Res, $Val extends ChatRoomModel> implements $ @override @pragma('vm:prefer-inline') $ChatRoomSettingsModelCopyWith<$Res> get chatRoomSettings { - return $ChatRoomSettingsModelCopyWith<$Res>(_value.chatRoomSettings, (value) { + return $ChatRoomSettingsModelCopyWith<$Res>(_value.chatRoomSettings, + (value) { return _then(_value.copyWith(chatRoomSettings: value) as $Val); }); } } /// @nodoc -abstract class _$$ChatRoomModelImplCopyWith<$Res> implements $ChatRoomModelCopyWith<$Res> { - factory _$$ChatRoomModelImplCopyWith(_$ChatRoomModelImpl value, $Res Function(_$ChatRoomModelImpl) then) = __$$ChatRoomModelImplCopyWithImpl<$Res>; - +abstract class _$$ChatRoomModelImplCopyWith<$Res> + implements $ChatRoomModelCopyWith<$Res> { + factory _$$ChatRoomModelImplCopyWith( + _$ChatRoomModelImpl value, $Res Function(_$ChatRoomModelImpl) then) = + __$$ChatRoomModelImplCopyWithImpl<$Res>; @override @useResult - $Res call({String id, @JsonKey(name: 'chat_room_setting') ChatRoomSettingsModel chatRoomSettings, Map users}); + $Res call( + {String id, + @JsonKey(name: 'chat_room_setting') + ChatRoomSettingsModel chatRoomSettings, + Map users}); @override $ChatRoomSettingsModelCopyWith<$Res> get chatRoomSettings; } /// @nodoc -class __$$ChatRoomModelImplCopyWithImpl<$Res> extends _$ChatRoomModelCopyWithImpl<$Res, _$ChatRoomModelImpl> implements _$$ChatRoomModelImplCopyWith<$Res> { - __$$ChatRoomModelImplCopyWithImpl(_$ChatRoomModelImpl _value, $Res Function(_$ChatRoomModelImpl) _then) : super(_value, _then); +class __$$ChatRoomModelImplCopyWithImpl<$Res> + extends _$ChatRoomModelCopyWithImpl<$Res, _$ChatRoomModelImpl> + implements _$$ChatRoomModelImplCopyWith<$Res> { + __$$ChatRoomModelImplCopyWithImpl( + _$ChatRoomModelImpl _value, $Res Function(_$ChatRoomModelImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -129,10 +144,13 @@ class __$$ChatRoomModelImplCopyWithImpl<$Res> extends _$ChatRoomModelCopyWithImp @JsonSerializable() class _$ChatRoomModelImpl implements _ChatRoomModel { const _$ChatRoomModelImpl( - {required this.id, @JsonKey(name: 'chat_room_setting') required this.chatRoomSettings, required final Map users}) + {required this.id, + @JsonKey(name: 'chat_room_setting') required this.chatRoomSettings, + required final Map users}) : _users = users; - factory _$ChatRoomModelImpl.fromJson(Map json) => _$$ChatRoomModelImplFromJson(json); + factory _$ChatRoomModelImpl.fromJson(Map json) => + _$$ChatRoomModelImplFromJson(json); @override final String id; @@ -140,7 +158,6 @@ class _$ChatRoomModelImpl implements _ChatRoomModel { @JsonKey(name: 'chat_room_setting') final ChatRoomSettingsModel chatRoomSettings; final Map _users; - @override Map get users { if (_users is EqualUnmodifiableMapView) return _users; @@ -159,18 +176,21 @@ class _$ChatRoomModelImpl implements _ChatRoomModel { (other.runtimeType == runtimeType && other is _$ChatRoomModelImpl && (identical(other.id, id) || other.id == id) && - (identical(other.chatRoomSettings, chatRoomSettings) || other.chatRoomSettings == chatRoomSettings) && + (identical(other.chatRoomSettings, chatRoomSettings) || + other.chatRoomSettings == chatRoomSettings) && const DeepCollectionEquality().equals(other._users, _users)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, chatRoomSettings, const DeepCollectionEquality().hash(_users)); + int get hashCode => Object.hash(runtimeType, id, chatRoomSettings, + const DeepCollectionEquality().hash(_users)); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$ChatRoomModelImplCopyWith<_$ChatRoomModelImpl> get copyWith => __$$ChatRoomModelImplCopyWithImpl<_$ChatRoomModelImpl>(this, _$identity); + _$$ChatRoomModelImplCopyWith<_$ChatRoomModelImpl> get copyWith => + __$$ChatRoomModelImplCopyWithImpl<_$ChatRoomModelImpl>(this, _$identity); @override Map toJson() { @@ -183,22 +203,22 @@ class _$ChatRoomModelImpl implements _ChatRoomModel { abstract class _ChatRoomModel implements ChatRoomModel { const factory _ChatRoomModel( {required final String id, - @JsonKey(name: 'chat_room_setting') required final ChatRoomSettingsModel chatRoomSettings, + @JsonKey(name: 'chat_room_setting') + required final ChatRoomSettingsModel chatRoomSettings, required final Map users}) = _$ChatRoomModelImpl; - factory _ChatRoomModel.fromJson(Map json) = _$ChatRoomModelImpl.fromJson; + factory _ChatRoomModel.fromJson(Map json) = + _$ChatRoomModelImpl.fromJson; @override String get id; - @override @JsonKey(name: 'chat_room_setting') ChatRoomSettingsModel get chatRoomSettings; - @override Map get users; - @override @JsonKey(ignore: true) - _$$ChatRoomModelImplCopyWith<_$ChatRoomModelImpl> get copyWith => throw _privateConstructorUsedError; + _$$ChatRoomModelImplCopyWith<_$ChatRoomModelImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_room_model.g.dart b/lib/features/chat/models/chat_room_model.g.dart index 6230d4f4..68d3195c 100644 --- a/lib/features/chat/models/chat_room_model.g.dart +++ b/lib/features/chat/models/chat_room_model.g.dart @@ -6,15 +6,19 @@ part of 'chat_room_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ChatRoomModelImpl _$$ChatRoomModelImplFromJson(Map json) => _$ChatRoomModelImpl( +_$ChatRoomModelImpl _$$ChatRoomModelImplFromJson(Map json) => + _$ChatRoomModelImpl( id: json['id'] as String, - chatRoomSettings: ChatRoomSettingsModel.fromJson(json['chat_room_setting'] as Map), + chatRoomSettings: ChatRoomSettingsModel.fromJson( + json['chat_room_setting'] as Map), users: (json['users'] as Map).map( - (k, e) => MapEntry(k, ChatUserModel.fromJson(e as Map)), + (k, e) => + MapEntry(k, ChatUserModel.fromJson(e as Map)), ), ); -Map _$$ChatRoomModelImplToJson(_$ChatRoomModelImpl instance) => { +Map _$$ChatRoomModelImplToJson(_$ChatRoomModelImpl instance) => + { 'id': instance.id, 'chat_room_setting': instance.chatRoomSettings, 'users': instance.users, diff --git a/lib/features/chat/models/chat_room_settings_model.freezed.dart b/lib/features/chat/models/chat_room_settings_model.freezed.dart index 48a11456..4f217556 100644 --- a/lib/features/chat/models/chat_room_settings_model.freezed.dart +++ b/lib/features/chat/models/chat_room_settings_model.freezed.dart @@ -14,36 +14,33 @@ 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'); -ChatRoomSettingsModel _$ChatRoomSettingsModelFromJson(Map json) { +ChatRoomSettingsModel _$ChatRoomSettingsModelFromJson( + Map json) { return _ChatRoomSettingsModel.fromJson(json); } /// @nodoc mixin _$ChatRoomSettingsModel { int get id => throw _privateConstructorUsedError; - @JsonKey(name: 'room_name') String get roomName => throw _privateConstructorUsedError; - String get state => throw _privateConstructorUsedError; - @JsonKey(name: 'access_level') String get accessLevel => throw _privateConstructorUsedError; - @JsonKey(name: 'updated_at') String get updatedAt => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $ChatRoomSettingsModelCopyWith get copyWith => throw _privateConstructorUsedError; + $ChatRoomSettingsModelCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $ChatRoomSettingsModelCopyWith<$Res> { - factory $ChatRoomSettingsModelCopyWith(ChatRoomSettingsModel value, $Res Function(ChatRoomSettingsModel) then) = + factory $ChatRoomSettingsModelCopyWith(ChatRoomSettingsModel value, + $Res Function(ChatRoomSettingsModel) then) = _$ChatRoomSettingsModelCopyWithImpl<$Res, ChatRoomSettingsModel>; - @useResult $Res call( {int id, @@ -54,12 +51,13 @@ abstract class $ChatRoomSettingsModelCopyWith<$Res> { } /// @nodoc -class _$ChatRoomSettingsModelCopyWithImpl<$Res, $Val extends ChatRoomSettingsModel> implements $ChatRoomSettingsModelCopyWith<$Res> { +class _$ChatRoomSettingsModelCopyWithImpl<$Res, + $Val extends ChatRoomSettingsModel> + implements $ChatRoomSettingsModelCopyWith<$Res> { _$ChatRoomSettingsModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -98,10 +96,12 @@ class _$ChatRoomSettingsModelCopyWithImpl<$Res, $Val extends ChatRoomSettingsMod } /// @nodoc -abstract class _$$ChatRoomSettingsModelImplCopyWith<$Res> implements $ChatRoomSettingsModelCopyWith<$Res> { - factory _$$ChatRoomSettingsModelImplCopyWith(_$ChatRoomSettingsModelImpl value, $Res Function(_$ChatRoomSettingsModelImpl) then) = +abstract class _$$ChatRoomSettingsModelImplCopyWith<$Res> + implements $ChatRoomSettingsModelCopyWith<$Res> { + factory _$$ChatRoomSettingsModelImplCopyWith( + _$ChatRoomSettingsModelImpl value, + $Res Function(_$ChatRoomSettingsModelImpl) then) = __$$ChatRoomSettingsModelImplCopyWithImpl<$Res>; - @override @useResult $Res call( @@ -113,9 +113,13 @@ abstract class _$$ChatRoomSettingsModelImplCopyWith<$Res> implements $ChatRoomSe } /// @nodoc -class __$$ChatRoomSettingsModelImplCopyWithImpl<$Res> extends _$ChatRoomSettingsModelCopyWithImpl<$Res, _$ChatRoomSettingsModelImpl> +class __$$ChatRoomSettingsModelImplCopyWithImpl<$Res> + extends _$ChatRoomSettingsModelCopyWithImpl<$Res, + _$ChatRoomSettingsModelImpl> implements _$$ChatRoomSettingsModelImplCopyWith<$Res> { - __$$ChatRoomSettingsModelImplCopyWithImpl(_$ChatRoomSettingsModelImpl _value, $Res Function(_$ChatRoomSettingsModelImpl) _then) : super(_value, _then); + __$$ChatRoomSettingsModelImplCopyWithImpl(_$ChatRoomSettingsModelImpl _value, + $Res Function(_$ChatRoomSettingsModelImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -161,7 +165,8 @@ class _$ChatRoomSettingsModelImpl implements _ChatRoomSettingsModel { @JsonKey(name: 'access_level') required this.accessLevel, @JsonKey(name: 'updated_at') required this.updatedAt}); - factory _$ChatRoomSettingsModelImpl.fromJson(Map json) => _$$ChatRoomSettingsModelImplFromJson(json); + factory _$ChatRoomSettingsModelImpl.fromJson(Map json) => + _$$ChatRoomSettingsModelImplFromJson(json); @override final int id; @@ -188,21 +193,26 @@ class _$ChatRoomSettingsModelImpl implements _ChatRoomSettingsModel { (other.runtimeType == runtimeType && other is _$ChatRoomSettingsModelImpl && (identical(other.id, id) || other.id == id) && - (identical(other.roomName, roomName) || other.roomName == roomName) && + (identical(other.roomName, roomName) || + other.roomName == roomName) && (identical(other.state, state) || other.state == state) && - (identical(other.accessLevel, accessLevel) || other.accessLevel == accessLevel) && - (identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)); + (identical(other.accessLevel, accessLevel) || + other.accessLevel == accessLevel) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, roomName, state, accessLevel, updatedAt); + int get hashCode => + Object.hash(runtimeType, id, roomName, state, accessLevel, updatedAt); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$ChatRoomSettingsModelImplCopyWith<_$ChatRoomSettingsModelImpl> get copyWith => - __$$ChatRoomSettingsModelImplCopyWithImpl<_$ChatRoomSettingsModelImpl>(this, _$identity); + _$$ChatRoomSettingsModelImplCopyWith<_$ChatRoomSettingsModelImpl> + get copyWith => __$$ChatRoomSettingsModelImplCopyWithImpl< + _$ChatRoomSettingsModelImpl>(this, _$identity); @override Map toJson() { @@ -214,33 +224,31 @@ class _$ChatRoomSettingsModelImpl implements _ChatRoomSettingsModel { abstract class _ChatRoomSettingsModel implements ChatRoomSettingsModel { const factory _ChatRoomSettingsModel( - {required final int id, - @JsonKey(name: 'room_name') required final String roomName, - required final String state, - @JsonKey(name: 'access_level') required final String accessLevel, - @JsonKey(name: 'updated_at') required final String updatedAt}) = _$ChatRoomSettingsModelImpl; + {required final int id, + @JsonKey(name: 'room_name') required final String roomName, + required final String state, + @JsonKey(name: 'access_level') required final String accessLevel, + @JsonKey(name: 'updated_at') required final String updatedAt}) = + _$ChatRoomSettingsModelImpl; - factory _ChatRoomSettingsModel.fromJson(Map json) = _$ChatRoomSettingsModelImpl.fromJson; + factory _ChatRoomSettingsModel.fromJson(Map json) = + _$ChatRoomSettingsModelImpl.fromJson; @override int get id; - @override @JsonKey(name: 'room_name') String get roomName; - @override String get state; - @override @JsonKey(name: 'access_level') String get accessLevel; - @override @JsonKey(name: 'updated_at') String get updatedAt; - @override @JsonKey(ignore: true) - _$$ChatRoomSettingsModelImplCopyWith<_$ChatRoomSettingsModelImpl> get copyWith => throw _privateConstructorUsedError; + _$$ChatRoomSettingsModelImplCopyWith<_$ChatRoomSettingsModelImpl> + get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_room_settings_model.g.dart b/lib/features/chat/models/chat_room_settings_model.g.dart index 1a2ef327..7b824334 100644 --- a/lib/features/chat/models/chat_room_settings_model.g.dart +++ b/lib/features/chat/models/chat_room_settings_model.g.dart @@ -6,7 +6,9 @@ part of 'chat_room_settings_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ChatRoomSettingsModelImpl _$$ChatRoomSettingsModelImplFromJson(Map json) => _$ChatRoomSettingsModelImpl( +_$ChatRoomSettingsModelImpl _$$ChatRoomSettingsModelImplFromJson( + Map json) => + _$ChatRoomSettingsModelImpl( id: (json['id'] as num).toInt(), roomName: json['room_name'] as String, state: json['state'] as String, @@ -14,7 +16,9 @@ _$ChatRoomSettingsModelImpl _$$ChatRoomSettingsModelImplFromJson(Map _$$ChatRoomSettingsModelImplToJson(_$ChatRoomSettingsModelImpl instance) => { +Map _$$ChatRoomSettingsModelImplToJson( + _$ChatRoomSettingsModelImpl instance) => + { 'id': instance.id, 'room_name': instance.roomName, 'state': instance.state, diff --git a/lib/features/chat/models/chat_user_model.freezed.dart b/lib/features/chat/models/chat_user_model.freezed.dart index 90774932..095c09e2 100644 --- a/lib/features/chat/models/chat_user_model.freezed.dart +++ b/lib/features/chat/models/chat_user_model.freezed.dart @@ -21,36 +21,38 @@ ChatUserModel _$ChatUserModelFromJson(Map json) { /// @nodoc mixin _$ChatUserModel { int get id => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - @JsonKey(name: 'profile_photo_path') String? get profilePhotoPath => throw _privateConstructorUsedError; - @JsonKey(name: 'profile_photo_url') String? get profilePhotoUrl => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $ChatUserModelCopyWith get copyWith => throw _privateConstructorUsedError; + $ChatUserModelCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $ChatUserModelCopyWith<$Res> { - factory $ChatUserModelCopyWith(ChatUserModel value, $Res Function(ChatUserModel) then) = _$ChatUserModelCopyWithImpl<$Res, ChatUserModel>; - + factory $ChatUserModelCopyWith( + ChatUserModel value, $Res Function(ChatUserModel) then) = + _$ChatUserModelCopyWithImpl<$Res, ChatUserModel>; @useResult - $Res call({int id, String name, @JsonKey(name: 'profile_photo_path') String? profilePhotoPath, @JsonKey(name: 'profile_photo_url') String? profilePhotoUrl}); + $Res call( + {int id, + String name, + @JsonKey(name: 'profile_photo_path') String? profilePhotoPath, + @JsonKey(name: 'profile_photo_url') String? profilePhotoUrl}); } /// @nodoc -class _$ChatUserModelCopyWithImpl<$Res, $Val extends ChatUserModel> implements $ChatUserModelCopyWith<$Res> { +class _$ChatUserModelCopyWithImpl<$Res, $Val extends ChatUserModel> + implements $ChatUserModelCopyWith<$Res> { _$ChatUserModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -84,17 +86,27 @@ class _$ChatUserModelCopyWithImpl<$Res, $Val extends ChatUserModel> implements $ } /// @nodoc -abstract class _$$ChatUserModelImplCopyWith<$Res> implements $ChatUserModelCopyWith<$Res> { - factory _$$ChatUserModelImplCopyWith(_$ChatUserModelImpl value, $Res Function(_$ChatUserModelImpl) then) = __$$ChatUserModelImplCopyWithImpl<$Res>; - +abstract class _$$ChatUserModelImplCopyWith<$Res> + implements $ChatUserModelCopyWith<$Res> { + factory _$$ChatUserModelImplCopyWith( + _$ChatUserModelImpl value, $Res Function(_$ChatUserModelImpl) then) = + __$$ChatUserModelImplCopyWithImpl<$Res>; @override @useResult - $Res call({int id, String name, @JsonKey(name: 'profile_photo_path') String? profilePhotoPath, @JsonKey(name: 'profile_photo_url') String? profilePhotoUrl}); + $Res call( + {int id, + String name, + @JsonKey(name: 'profile_photo_path') String? profilePhotoPath, + @JsonKey(name: 'profile_photo_url') String? profilePhotoUrl}); } /// @nodoc -class __$$ChatUserModelImplCopyWithImpl<$Res> extends _$ChatUserModelCopyWithImpl<$Res, _$ChatUserModelImpl> implements _$$ChatUserModelImplCopyWith<$Res> { - __$$ChatUserModelImplCopyWithImpl(_$ChatUserModelImpl _value, $Res Function(_$ChatUserModelImpl) _then) : super(_value, _then); +class __$$ChatUserModelImplCopyWithImpl<$Res> + extends _$ChatUserModelCopyWithImpl<$Res, _$ChatUserModelImpl> + implements _$$ChatUserModelImplCopyWith<$Res> { + __$$ChatUserModelImplCopyWithImpl( + _$ChatUserModelImpl _value, $Res Function(_$ChatUserModelImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -134,7 +146,8 @@ class _$ChatUserModelImpl implements _ChatUserModel { @JsonKey(name: 'profile_photo_path') this.profilePhotoPath, @JsonKey(name: 'profile_photo_url') this.profilePhotoUrl}); - factory _$ChatUserModelImpl.fromJson(Map json) => _$$ChatUserModelImplFromJson(json); + factory _$ChatUserModelImpl.fromJson(Map json) => + _$$ChatUserModelImplFromJson(json); @override final int id; @@ -159,18 +172,22 @@ class _$ChatUserModelImpl implements _ChatUserModel { other is _$ChatUserModelImpl && (identical(other.id, id) || other.id == id) && (identical(other.name, name) || other.name == name) && - (identical(other.profilePhotoPath, profilePhotoPath) || other.profilePhotoPath == profilePhotoPath) && - (identical(other.profilePhotoUrl, profilePhotoUrl) || other.profilePhotoUrl == profilePhotoUrl)); + (identical(other.profilePhotoPath, profilePhotoPath) || + other.profilePhotoPath == profilePhotoPath) && + (identical(other.profilePhotoUrl, profilePhotoUrl) || + other.profilePhotoUrl == profilePhotoUrl)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, name, profilePhotoPath, profilePhotoUrl); + int get hashCode => + Object.hash(runtimeType, id, name, profilePhotoPath, profilePhotoUrl); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$ChatUserModelImplCopyWith<_$ChatUserModelImpl> get copyWith => __$$ChatUserModelImplCopyWithImpl<_$ChatUserModelImpl>(this, _$identity); + _$$ChatUserModelImplCopyWith<_$ChatUserModelImpl> get copyWith => + __$$ChatUserModelImplCopyWithImpl<_$ChatUserModelImpl>(this, _$identity); @override Map toJson() { @@ -182,28 +199,27 @@ class _$ChatUserModelImpl implements _ChatUserModel { abstract class _ChatUserModel implements ChatUserModel { const factory _ChatUserModel( - {required final int id, - required final String name, - @JsonKey(name: 'profile_photo_path') final String? profilePhotoPath, - @JsonKey(name: 'profile_photo_url') final String? profilePhotoUrl}) = _$ChatUserModelImpl; + {required final int id, + required final String name, + @JsonKey(name: 'profile_photo_path') final String? profilePhotoPath, + @JsonKey(name: 'profile_photo_url') final String? profilePhotoUrl}) = + _$ChatUserModelImpl; - factory _ChatUserModel.fromJson(Map json) = _$ChatUserModelImpl.fromJson; + factory _ChatUserModel.fromJson(Map json) = + _$ChatUserModelImpl.fromJson; @override int get id; - @override String get name; - @override @JsonKey(name: 'profile_photo_path') String? get profilePhotoPath; - @override @JsonKey(name: 'profile_photo_url') String? get profilePhotoUrl; - @override @JsonKey(ignore: true) - _$$ChatUserModelImplCopyWith<_$ChatUserModelImpl> get copyWith => throw _privateConstructorUsedError; + _$$ChatUserModelImplCopyWith<_$ChatUserModelImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/chat_user_model.g.dart b/lib/features/chat/models/chat_user_model.g.dart index 06fa92a0..78e0f981 100644 --- a/lib/features/chat/models/chat_user_model.g.dart +++ b/lib/features/chat/models/chat_user_model.g.dart @@ -6,14 +6,16 @@ part of 'chat_user_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ChatUserModelImpl _$$ChatUserModelImplFromJson(Map json) => _$ChatUserModelImpl( +_$ChatUserModelImpl _$$ChatUserModelImplFromJson(Map json) => + _$ChatUserModelImpl( id: (json['id'] as num).toInt(), name: json['name'] as String, profilePhotoPath: json['profile_photo_path'] as String?, profilePhotoUrl: json['profile_photo_url'] as String?, ); -Map _$$ChatUserModelImplToJson(_$ChatUserModelImpl instance) => { +Map _$$ChatUserModelImplToJson(_$ChatUserModelImpl instance) => + { 'id': instance.id, 'name': instance.name, 'profile_photo_path': instance.profilePhotoPath, diff --git a/lib/features/chat/models/websocket_info_model.freezed.dart b/lib/features/chat/models/websocket_info_model.freezed.dart index 002f2ec5..cd383a2b 100644 --- a/lib/features/chat/models/websocket_info_model.freezed.dart +++ b/lib/features/chat/models/websocket_info_model.freezed.dart @@ -21,38 +21,39 @@ WebsocketInfoModel _$WebsocketInfoModelFromJson(Map json) { /// @nodoc mixin _$WebsocketInfoModel { String get key => throw _privateConstructorUsedError; - String get host => throw _privateConstructorUsedError; - String get port => throw _privateConstructorUsedError; - String get cluster => throw _privateConstructorUsedError; - @JsonKey(name: 'user_id') int get userId => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $WebsocketInfoModelCopyWith get copyWith => throw _privateConstructorUsedError; + $WebsocketInfoModelCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $WebsocketInfoModelCopyWith<$Res> { - factory $WebsocketInfoModelCopyWith(WebsocketInfoModel value, $Res Function(WebsocketInfoModel) then) = + factory $WebsocketInfoModelCopyWith( + WebsocketInfoModel value, $Res Function(WebsocketInfoModel) then) = _$WebsocketInfoModelCopyWithImpl<$Res, WebsocketInfoModel>; - @useResult - $Res call({String key, String host, String port, String cluster, @JsonKey(name: 'user_id') int userId}); + $Res call( + {String key, + String host, + String port, + String cluster, + @JsonKey(name: 'user_id') int userId}); } /// @nodoc -class _$WebsocketInfoModelCopyWithImpl<$Res, $Val extends WebsocketInfoModel> implements $WebsocketInfoModelCopyWith<$Res> { +class _$WebsocketInfoModelCopyWithImpl<$Res, $Val extends WebsocketInfoModel> + implements $WebsocketInfoModelCopyWith<$Res> { _$WebsocketInfoModelCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -91,19 +92,28 @@ class _$WebsocketInfoModelCopyWithImpl<$Res, $Val extends WebsocketInfoModel> im } /// @nodoc -abstract class _$$WebsocketInfoModelImplCopyWith<$Res> implements $WebsocketInfoModelCopyWith<$Res> { - factory _$$WebsocketInfoModelImplCopyWith(_$WebsocketInfoModelImpl value, $Res Function(_$WebsocketInfoModelImpl) then) = +abstract class _$$WebsocketInfoModelImplCopyWith<$Res> + implements $WebsocketInfoModelCopyWith<$Res> { + factory _$$WebsocketInfoModelImplCopyWith(_$WebsocketInfoModelImpl value, + $Res Function(_$WebsocketInfoModelImpl) then) = __$$WebsocketInfoModelImplCopyWithImpl<$Res>; - @override @useResult - $Res call({String key, String host, String port, String cluster, @JsonKey(name: 'user_id') int userId}); + $Res call( + {String key, + String host, + String port, + String cluster, + @JsonKey(name: 'user_id') int userId}); } /// @nodoc -class __$$WebsocketInfoModelImplCopyWithImpl<$Res> extends _$WebsocketInfoModelCopyWithImpl<$Res, _$WebsocketInfoModelImpl> +class __$$WebsocketInfoModelImplCopyWithImpl<$Res> + extends _$WebsocketInfoModelCopyWithImpl<$Res, _$WebsocketInfoModelImpl> implements _$$WebsocketInfoModelImplCopyWith<$Res> { - __$$WebsocketInfoModelImplCopyWithImpl(_$WebsocketInfoModelImpl _value, $Res Function(_$WebsocketInfoModelImpl) _then) : super(_value, _then); + __$$WebsocketInfoModelImplCopyWithImpl(_$WebsocketInfoModelImpl _value, + $Res Function(_$WebsocketInfoModelImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -143,9 +153,14 @@ class __$$WebsocketInfoModelImplCopyWithImpl<$Res> extends _$WebsocketInfoModelC @JsonSerializable() class _$WebsocketInfoModelImpl implements _WebsocketInfoModel { const _$WebsocketInfoModelImpl( - {required this.key, required this.host, required this.port, required this.cluster, @JsonKey(name: 'user_id') required this.userId}); + {required this.key, + required this.host, + required this.port, + required this.cluster, + @JsonKey(name: 'user_id') required this.userId}); - factory _$WebsocketInfoModelImpl.fromJson(Map json) => _$$WebsocketInfoModelImplFromJson(json); + factory _$WebsocketInfoModelImpl.fromJson(Map json) => + _$$WebsocketInfoModelImplFromJson(json); @override final String key; @@ -178,13 +193,15 @@ class _$WebsocketInfoModelImpl implements _WebsocketInfoModel { @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, key, host, port, cluster, userId); + int get hashCode => + Object.hash(runtimeType, key, host, port, cluster, userId); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$WebsocketInfoModelImplCopyWith<_$WebsocketInfoModelImpl> get copyWith => - __$$WebsocketInfoModelImplCopyWithImpl<_$WebsocketInfoModelImpl>(this, _$identity); + __$$WebsocketInfoModelImplCopyWithImpl<_$WebsocketInfoModelImpl>( + this, _$identity); @override Map toJson() { @@ -196,31 +213,29 @@ class _$WebsocketInfoModelImpl implements _WebsocketInfoModel { abstract class _WebsocketInfoModel implements WebsocketInfoModel { const factory _WebsocketInfoModel( - {required final String key, - required final String host, - required final String port, - required final String cluster, - @JsonKey(name: 'user_id') required final int userId}) = _$WebsocketInfoModelImpl; + {required final String key, + required final String host, + required final String port, + required final String cluster, + @JsonKey(name: 'user_id') required final int userId}) = + _$WebsocketInfoModelImpl; - factory _WebsocketInfoModel.fromJson(Map json) = _$WebsocketInfoModelImpl.fromJson; + factory _WebsocketInfoModel.fromJson(Map json) = + _$WebsocketInfoModelImpl.fromJson; @override String get key; - @override String get host; - @override String get port; - @override String get cluster; - @override @JsonKey(name: 'user_id') int get userId; - @override @JsonKey(ignore: true) - _$$WebsocketInfoModelImplCopyWith<_$WebsocketInfoModelImpl> get copyWith => throw _privateConstructorUsedError; + _$$WebsocketInfoModelImplCopyWith<_$WebsocketInfoModelImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/chat/models/websocket_info_model.g.dart b/lib/features/chat/models/websocket_info_model.g.dart index 91c386f8..b2bb1248 100644 --- a/lib/features/chat/models/websocket_info_model.g.dart +++ b/lib/features/chat/models/websocket_info_model.g.dart @@ -6,7 +6,9 @@ part of 'websocket_info_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$WebsocketInfoModelImpl _$$WebsocketInfoModelImplFromJson(Map json) => _$WebsocketInfoModelImpl( +_$WebsocketInfoModelImpl _$$WebsocketInfoModelImplFromJson( + Map json) => + _$WebsocketInfoModelImpl( key: json['key'] as String, host: json['host'] as String, port: json['port'] as String, @@ -14,7 +16,9 @@ _$WebsocketInfoModelImpl _$$WebsocketInfoModelImplFromJson(Map userId: (json['user_id'] as num).toInt(), ); -Map _$$WebsocketInfoModelImplToJson(_$WebsocketInfoModelImpl instance) => { +Map _$$WebsocketInfoModelImplToJson( + _$WebsocketInfoModelImpl instance) => + { 'key': instance.key, 'host': instance.host, 'port': instance.port, diff --git a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart index aaf9a4e9..4a558925 100644 --- a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart +++ b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart @@ -98,6 +98,7 @@ class ChatRoomCubit extends Cubit { privateChatChannel.subscribe(); privateChatChannel.bind('App\\Events\\ChatMessageUpdated').listen((event) { + print(jsonDecode(event.data)); List messagesList = [ ChatMessageModel.fromJson(jsonDecode(event.data)['message']), ...(state as ChatRoomStateLoaded).chatMessages, @@ -138,10 +139,14 @@ class ChatRoomCubit extends Cubit { sendMessage({ required String chatId, - required String data, - required List filesList, + String? data, + List? files, }) async { - await chatRepository.sendMessage(chatId: chatId, data: data); + await chatRepository.sendMessage( + chatId: chatId, + data: data, + files: files, + ); } @override diff --git a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.freezed.dart b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.freezed.dart index 0001c80c..43bf9df9 100644 --- a/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.freezed.dart +++ b/lib/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.freezed.dart @@ -20,16 +20,19 @@ mixin _$ChatRoomState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading) loaded, + required TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; - @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult? Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) => throw _privateConstructorUsedError; @@ -37,7 +40,9 @@ mixin _$ChatRoomState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) => @@ -71,28 +76,36 @@ mixin _$ChatRoomState { /// @nodoc abstract class $ChatRoomStateCopyWith<$Res> { - factory $ChatRoomStateCopyWith(ChatRoomState value, $Res Function(ChatRoomState) then) = _$ChatRoomStateCopyWithImpl<$Res, ChatRoomState>; + factory $ChatRoomStateCopyWith( + ChatRoomState value, $Res Function(ChatRoomState) then) = + _$ChatRoomStateCopyWithImpl<$Res, ChatRoomState>; } /// @nodoc -class _$ChatRoomStateCopyWithImpl<$Res, $Val extends ChatRoomState> implements $ChatRoomStateCopyWith<$Res> { +class _$ChatRoomStateCopyWithImpl<$Res, $Val extends ChatRoomState> + implements $ChatRoomStateCopyWith<$Res> { _$ChatRoomStateCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; } /// @nodoc abstract class _$$ChatRoomStateImplCopyWith<$Res> { - factory _$$ChatRoomStateImplCopyWith(_$ChatRoomStateImpl value, $Res Function(_$ChatRoomStateImpl) then) = __$$ChatRoomStateImplCopyWithImpl<$Res>; + factory _$$ChatRoomStateImplCopyWith( + _$ChatRoomStateImpl value, $Res Function(_$ChatRoomStateImpl) then) = + __$$ChatRoomStateImplCopyWithImpl<$Res>; } /// @nodoc -class __$$ChatRoomStateImplCopyWithImpl<$Res> extends _$ChatRoomStateCopyWithImpl<$Res, _$ChatRoomStateImpl> implements _$$ChatRoomStateImplCopyWith<$Res> { - __$$ChatRoomStateImplCopyWithImpl(_$ChatRoomStateImpl _value, $Res Function(_$ChatRoomStateImpl) _then) : super(_value, _then); +class __$$ChatRoomStateImplCopyWithImpl<$Res> + extends _$ChatRoomStateCopyWithImpl<$Res, _$ChatRoomStateImpl> + implements _$$ChatRoomStateImplCopyWith<$Res> { + __$$ChatRoomStateImplCopyWithImpl( + _$ChatRoomStateImpl _value, $Res Function(_$ChatRoomStateImpl) _then) + : super(_value, _then); } /// @nodoc @@ -107,7 +120,8 @@ class _$ChatRoomStateImpl implements _ChatRoomState { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$ChatRoomStateImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$ChatRoomStateImpl); } @override @@ -118,7 +132,9 @@ class _$ChatRoomStateImpl implements _ChatRoomState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading) loaded, + required TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return $default(); @@ -129,7 +145,9 @@ class _$ChatRoomStateImpl implements _ChatRoomState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult? Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return $default?.call(); @@ -140,7 +158,9 @@ class _$ChatRoomStateImpl implements _ChatRoomState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -194,14 +214,18 @@ abstract class _ChatRoomState implements ChatRoomState { /// @nodoc abstract class _$$ChatRoomStateLoadingImplCopyWith<$Res> { - factory _$$ChatRoomStateLoadingImplCopyWith(_$ChatRoomStateLoadingImpl value, $Res Function(_$ChatRoomStateLoadingImpl) then) = + factory _$$ChatRoomStateLoadingImplCopyWith(_$ChatRoomStateLoadingImpl value, + $Res Function(_$ChatRoomStateLoadingImpl) then) = __$$ChatRoomStateLoadingImplCopyWithImpl<$Res>; } /// @nodoc -class __$$ChatRoomStateLoadingImplCopyWithImpl<$Res> extends _$ChatRoomStateCopyWithImpl<$Res, _$ChatRoomStateLoadingImpl> +class __$$ChatRoomStateLoadingImplCopyWithImpl<$Res> + extends _$ChatRoomStateCopyWithImpl<$Res, _$ChatRoomStateLoadingImpl> implements _$$ChatRoomStateLoadingImplCopyWith<$Res> { - __$$ChatRoomStateLoadingImplCopyWithImpl(_$ChatRoomStateLoadingImpl _value, $Res Function(_$ChatRoomStateLoadingImpl) _then) : super(_value, _then); + __$$ChatRoomStateLoadingImplCopyWithImpl(_$ChatRoomStateLoadingImpl _value, + $Res Function(_$ChatRoomStateLoadingImpl) _then) + : super(_value, _then); } /// @nodoc @@ -216,7 +240,9 @@ class _$ChatRoomStateLoadingImpl implements ChatRoomStateLoading { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$ChatRoomStateLoadingImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatRoomStateLoadingImpl); } @override @@ -227,7 +253,9 @@ class _$ChatRoomStateLoadingImpl implements ChatRoomStateLoading { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading) loaded, + required TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return loading(); @@ -238,7 +266,9 @@ class _$ChatRoomStateLoadingImpl implements ChatRoomStateLoading { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult? Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return loading?.call(); @@ -249,7 +279,9 @@ class _$ChatRoomStateLoadingImpl implements ChatRoomStateLoading { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -303,19 +335,26 @@ abstract class ChatRoomStateLoading implements ChatRoomState { /// @nodoc abstract class _$$ChatRoomStateLoadedImplCopyWith<$Res> { - factory _$$ChatRoomStateLoadedImplCopyWith(_$ChatRoomStateLoadedImpl value, $Res Function(_$ChatRoomStateLoadedImpl) then) = + factory _$$ChatRoomStateLoadedImplCopyWith(_$ChatRoomStateLoadedImpl value, + $Res Function(_$ChatRoomStateLoadedImpl) then) = __$$ChatRoomStateLoadedImplCopyWithImpl<$Res>; - @useResult - $Res call({ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading}); + $Res call( + {ChatRoomModel chatRoom, + List chatMessages, + bool isTyping, + bool isLoading}); $ChatRoomModelCopyWith<$Res> get chatRoom; } /// @nodoc -class __$$ChatRoomStateLoadedImplCopyWithImpl<$Res> extends _$ChatRoomStateCopyWithImpl<$Res, _$ChatRoomStateLoadedImpl> +class __$$ChatRoomStateLoadedImplCopyWithImpl<$Res> + extends _$ChatRoomStateCopyWithImpl<$Res, _$ChatRoomStateLoadedImpl> implements _$$ChatRoomStateLoadedImplCopyWith<$Res> { - __$$ChatRoomStateLoadedImplCopyWithImpl(_$ChatRoomStateLoadedImpl _value, $Res Function(_$ChatRoomStateLoadedImpl) _then) : super(_value, _then); + __$$ChatRoomStateLoadedImplCopyWithImpl(_$ChatRoomStateLoadedImpl _value, + $Res Function(_$ChatRoomStateLoadedImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -357,13 +396,16 @@ class __$$ChatRoomStateLoadedImplCopyWithImpl<$Res> extends _$ChatRoomStateCopyW /// @nodoc class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded { - const _$ChatRoomStateLoadedImpl({required this.chatRoom, required final List chatMessages, required this.isTyping, required this.isLoading}) + const _$ChatRoomStateLoadedImpl( + {required this.chatRoom, + required final List chatMessages, + required this.isTyping, + required this.isLoading}) : _chatMessages = chatMessages; @override final ChatRoomModel chatRoom; final List _chatMessages; - @override List get chatMessages { if (_chatMessages is EqualUnmodifiableListView) return _chatMessages; @@ -386,27 +428,35 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ChatRoomStateLoadedImpl && - (identical(other.chatRoom, chatRoom) || other.chatRoom == chatRoom) && - const DeepCollectionEquality().equals(other._chatMessages, _chatMessages) && - (identical(other.isTyping, isTyping) || other.isTyping == isTyping) && - (identical(other.isLoading, isLoading) || other.isLoading == isLoading)); + (identical(other.chatRoom, chatRoom) || + other.chatRoom == chatRoom) && + const DeepCollectionEquality() + .equals(other._chatMessages, _chatMessages) && + (identical(other.isTyping, isTyping) || + other.isTyping == isTyping) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading)); } @override - int get hashCode => Object.hash(runtimeType, chatRoom, const DeepCollectionEquality().hash(_chatMessages), isTyping, isLoading); + int get hashCode => Object.hash(runtimeType, chatRoom, + const DeepCollectionEquality().hash(_chatMessages), isTyping, isLoading); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') _$$ChatRoomStateLoadedImplCopyWith<_$ChatRoomStateLoadedImpl> get copyWith => - __$$ChatRoomStateLoadedImplCopyWithImpl<_$ChatRoomStateLoadedImpl>(this, _$identity); + __$$ChatRoomStateLoadedImplCopyWithImpl<_$ChatRoomStateLoadedImpl>( + this, _$identity); @override @optionalTypeArgs TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading) loaded, + required TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return loaded(chatRoom, chatMessages, isTyping, isLoading); @@ -417,7 +467,9 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult? Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return loaded?.call(chatRoom, chatMessages, isTyping, isLoading); @@ -428,7 +480,9 @@ class _$ChatRoomStateLoadedImpl implements ChatRoomStateLoaded { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -484,30 +538,30 @@ abstract class ChatRoomStateLoaded implements ChatRoomState { required final bool isLoading}) = _$ChatRoomStateLoadedImpl; ChatRoomModel get chatRoom; - List get chatMessages; - bool get isTyping; - bool get isLoading; - @JsonKey(ignore: true) - _$$ChatRoomStateLoadedImplCopyWith<_$ChatRoomStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; + _$$ChatRoomStateLoadedImplCopyWith<_$ChatRoomStateLoadedImpl> get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class _$$ChatRoomStateErrorImplCopyWith<$Res> { - factory _$$ChatRoomStateErrorImplCopyWith(_$ChatRoomStateErrorImpl value, $Res Function(_$ChatRoomStateErrorImpl) then) = + factory _$$ChatRoomStateErrorImplCopyWith(_$ChatRoomStateErrorImpl value, + $Res Function(_$ChatRoomStateErrorImpl) then) = __$$ChatRoomStateErrorImplCopyWithImpl<$Res>; - @useResult $Res call({String errorMessage}); } /// @nodoc -class __$$ChatRoomStateErrorImplCopyWithImpl<$Res> extends _$ChatRoomStateCopyWithImpl<$Res, _$ChatRoomStateErrorImpl> +class __$$ChatRoomStateErrorImplCopyWithImpl<$Res> + extends _$ChatRoomStateCopyWithImpl<$Res, _$ChatRoomStateErrorImpl> implements _$$ChatRoomStateErrorImplCopyWith<$Res> { - __$$ChatRoomStateErrorImplCopyWithImpl(_$ChatRoomStateErrorImpl _value, $Res Function(_$ChatRoomStateErrorImpl) _then) : super(_value, _then); + __$$ChatRoomStateErrorImplCopyWithImpl(_$ChatRoomStateErrorImpl _value, + $Res Function(_$ChatRoomStateErrorImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -541,7 +595,8 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ChatRoomStateErrorImpl && - (identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); } @override @@ -551,14 +606,17 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError { @override @pragma('vm:prefer-inline') _$$ChatRoomStateErrorImplCopyWith<_$ChatRoomStateErrorImpl> get copyWith => - __$$ChatRoomStateErrorImplCopyWithImpl<_$ChatRoomStateErrorImpl>(this, _$identity); + __$$ChatRoomStateErrorImplCopyWithImpl<_$ChatRoomStateErrorImpl>( + this, _$identity); @override @optionalTypeArgs TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading) loaded, + required TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return error(errorMessage); @@ -569,7 +627,9 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult? Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return error?.call(errorMessage); @@ -580,7 +640,9 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(ChatRoomModel chatRoom, List chatMessages, bool isTyping, bool isLoading)? loaded, + TResult Function(ChatRoomModel chatRoom, + List chatMessages, bool isTyping, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -629,10 +691,11 @@ class _$ChatRoomStateErrorImpl implements ChatRoomStateError { } abstract class ChatRoomStateError implements ChatRoomState { - const factory ChatRoomStateError({required final String errorMessage}) = _$ChatRoomStateErrorImpl; + const factory ChatRoomStateError({required final String errorMessage}) = + _$ChatRoomStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) - _$$ChatRoomStateErrorImplCopyWith<_$ChatRoomStateErrorImpl> get copyWith => throw _privateConstructorUsedError; + _$$ChatRoomStateErrorImplCopyWith<_$ChatRoomStateErrorImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/chat/presentation/pages/chat_screen.dart b/lib/features/chat/presentation/pages/chat_screen.dart index e6822c50..25a8fd14 100644 --- a/lib/features/chat/presentation/pages/chat_screen.dart +++ b/lib/features/chat/presentation/pages/chat_screen.dart @@ -1,8 +1,11 @@ +import 'dart:io'; + import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart'; import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.dart'; import 'package:eatvio_app/features/chat/presentation/widgets/chat_bubble_widget.dart'; import 'package:eatvio_app/locator_service.dart'; +import 'package:file_picker/file_picker.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:lazy_load_scrollview/lazy_load_scrollview.dart'; @@ -124,6 +127,7 @@ class _ChatScreenState extends State { (context, index) { if (index < state.chatMessages.length) { return ChatBubbleWidget( + sendTime: state.chatMessages[index].updatedAt, text: state.chatMessages[index].data.trim(), isCurrentUser: state.chatRoom.users['to_chat_user']!.id != state.chatMessages[index].authorId, mediaData: state.chatMessages[index].mediaData ?? [], @@ -144,14 +148,33 @@ class _ChatScreenState extends State { ), ), ), - Padding( + Container( padding: EdgeInsets.symmetric(vertical: 8), + decoration: BoxDecoration( + border: Border( + top: BorderSide( + color: Colors.black.withOpacity(0.1), + ), + ), + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.end, children: [ SizedBox(width: 8), InkWell( - onTap: () {}, + onTap: () async { + FilePickerResult? result = await FilePicker.platform.pickFiles(); + + if (result != null) { + File file = File(result.files.single.path!); + context.read().sendMessage( + chatId: widget.chatId, + files: [file], + ); + } else { + // User canceled the picker + } + }, borderRadius: BorderRadius.circular(16), child: Ink( height: 32, @@ -171,17 +194,15 @@ class _ChatScreenState extends State { maxLines: 5, minLines: 1, keyboardType: TextInputType.multiline, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w400, - color: Colors.black, - ), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w400, color: Colors.black, height: 1), decoration: InputDecoration( - contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 4), + isDense: true, + contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8), hintText: 'Сообщение', hintStyle: TextStyle( fontSize: 16, fontWeight: FontWeight.w400, + height: 1, color: Color(0xFFAEAEB2), ), filled: true, @@ -217,7 +238,6 @@ class _ChatScreenState extends State { context.read().sendMessage( chatId: widget.chatId, data: textEditingController.text.trim(), - filesList: [], ); setState(() { textEditingController.clear(); diff --git a/lib/features/chat/presentation/widgets/chat_bubble_widget.dart b/lib/features/chat/presentation/widgets/chat_bubble_widget.dart index 555aa23b..f65fb3bc 100644 --- a/lib/features/chat/presentation/widgets/chat_bubble_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_bubble_widget.dart @@ -9,11 +9,13 @@ import 'package:url_launcher/url_launcher.dart'; class ChatBubbleWidget extends StatelessWidget { const ChatBubbleWidget({ super.key, + required this.sendTime, required this.text, required this.isCurrentUser, required this.mediaData, }); + final String sendTime; final String text; final bool isCurrentUser; final List mediaData; diff --git a/lib/features/chat/repositories/chat_repository.dart b/lib/features/chat/repositories/chat_repository.dart index c35847f2..f249f204 100644 --- a/lib/features/chat/repositories/chat_repository.dart +++ b/lib/features/chat/repositories/chat_repository.dart @@ -15,13 +15,13 @@ class ChatRepository { Future sendMessage({ required String chatId, String? data, - List? filesList, + List? files, }) async { try { await chatService.sendMessage( id: chatId, data: data, - filesList: filesList, + media_data: files, ); } catch (e) { print(e); diff --git a/lib/features/chat/services/chat_service.dart b/lib/features/chat/services/chat_service.dart index 888aaba0..49a8f810 100644 --- a/lib/features/chat/services/chat_service.dart +++ b/lib/features/chat/services/chat_service.dart @@ -18,10 +18,11 @@ abstract class ChatService { }); @POST('/api/chat/{id}/message/send') + @MultiPart() Future sendMessage({ @Path() required String id, @Part() String? data, - @Part() List? filesList, + @Part() List? media_data, }); @GET('/api/chat/show/{id}/messages?page={page}') diff --git a/lib/features/chat/services/chat_service.g.dart b/lib/features/chat/services/chat_service.g.dart index 2f0674be..48a9b016 100644 --- a/lib/features/chat/services/chat_service.g.dart +++ b/lib/features/chat/services/chat_service.g.dart @@ -12,37 +12,46 @@ class _ChatService implements ChatService { _ChatService( this._dio, { this.baseUrl, + this.errorLogger, }); final Dio _dio; String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future> getChatRoom({required String id}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType>(Options( + final _options = _setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/chat/show/${id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - var _value = _result.data!.map((k, dynamic v) => - MapEntry(k, ChatRoomModel.fromJson(v as Map))); + .compose( + _dio.options, + '/api/chat/show/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.map((k, dynamic v) => + MapEntry(k, ChatRoomModel.fromJson(v as Map))); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -50,7 +59,7 @@ class _ChatService implements ChatService { Future sendMessage({ required String id, String? data, - List? filesList, + List? media_data, }) async { final _extra = {}; final queryParameters = {}; @@ -63,18 +72,19 @@ class _ChatService implements ChatService { data, )); } - if (filesList != null) { - _data.files.addAll(filesList.map((i) => MapEntry( - 'filesList', + if (media_data != null) { + _data.files.addAll(media_data.map((i) => MapEntry( + 'media_data', MultipartFile.fromFileSync( i.path, filename: i.path.split(Platform.pathSeparator).last, )))); } - await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, + contentType: 'multipart/form-data', ) .compose( _dio.options, @@ -86,7 +96,8 @@ class _ChatService implements ChatService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); + ))); + await _dio.fetch(_options); } @override @@ -98,24 +109,30 @@ class _ChatService implements ChatService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/chat/show/${id}/messages?page=${page}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ChatMessagesModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/chat/show/${id}/messages?page=${page}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ChatMessagesModel _value; + try { + _value = ChatMessagesModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -125,24 +142,30 @@ class _ChatService implements ChatService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/profile/ws/params', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = WebsocketInfoModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/profile/ws/params', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late WebsocketInfoModel _value; + try { + _value = WebsocketInfoModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/features/diary/models/diary_model.dart b/lib/features/diary/models/diary_model.dart index 9beb22d7..d9abc3a9 100644 --- a/lib/features/diary/models/diary_model.dart +++ b/lib/features/diary/models/diary_model.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/features/diary/models/state.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import './meal.dart'; @@ -12,6 +13,7 @@ class DiaryModel with _$DiaryModel { required DateTime date, required int closed, required List meals, + required State state, String? comment, DateTime? wakeup, DateTime? retire, diff --git a/lib/features/diary/models/diary_model.freezed.dart b/lib/features/diary/models/diary_model.freezed.dart index 3fe59e15..a02a4621 100644 --- a/lib/features/diary/models/diary_model.freezed.dart +++ b/lib/features/diary/models/diary_model.freezed.dart @@ -24,6 +24,7 @@ mixin _$DiaryModel { DateTime get date => throw _privateConstructorUsedError; int get closed => throw _privateConstructorUsedError; List get meals => throw _privateConstructorUsedError; + State get state => throw _privateConstructorUsedError; String? get comment => throw _privateConstructorUsedError; DateTime? get wakeup => throw _privateConstructorUsedError; DateTime? get retire => throw _privateConstructorUsedError; @@ -45,9 +46,12 @@ abstract class $DiaryModelCopyWith<$Res> { DateTime date, int closed, List meals, + State state, String? comment, DateTime? wakeup, DateTime? retire}); + + $StateCopyWith<$Res> get state; } /// @nodoc @@ -67,6 +71,7 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> Object? date = null, Object? closed = null, Object? meals = null, + Object? state = null, Object? comment = freezed, Object? wakeup = freezed, Object? retire = freezed, @@ -88,6 +93,10 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> ? _value.meals : meals // ignore: cast_nullable_to_non_nullable as List, + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as State, comment: freezed == comment ? _value.comment : comment // ignore: cast_nullable_to_non_nullable @@ -102,6 +111,14 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> as DateTime?, ) as $Val); } + + @override + @pragma('vm:prefer-inline') + $StateCopyWith<$Res> get state { + return $StateCopyWith<$Res>(_value.state, (value) { + return _then(_value.copyWith(state: value) as $Val); + }); + } } /// @nodoc @@ -117,9 +134,13 @@ abstract class _$$DiaryModelImplCopyWith<$Res> DateTime date, int closed, List meals, + State state, String? comment, DateTime? wakeup, DateTime? retire}); + + @override + $StateCopyWith<$Res> get state; } /// @nodoc @@ -137,6 +158,7 @@ class __$$DiaryModelImplCopyWithImpl<$Res> Object? date = null, Object? closed = null, Object? meals = null, + Object? state = null, Object? comment = freezed, Object? wakeup = freezed, Object? retire = freezed, @@ -158,6 +180,10 @@ class __$$DiaryModelImplCopyWithImpl<$Res> ? _value._meals : meals // ignore: cast_nullable_to_non_nullable as List, + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as State, comment: freezed == comment ? _value.comment : comment // ignore: cast_nullable_to_non_nullable @@ -182,6 +208,7 @@ class _$DiaryModelImpl implements _DiaryModel { required this.date, required this.closed, required final List meals, + required this.state, this.comment, this.wakeup, this.retire}) @@ -204,6 +231,8 @@ class _$DiaryModelImpl implements _DiaryModel { return EqualUnmodifiableListView(_meals); } + @override + final State state; @override final String? comment; @override @@ -213,7 +242,7 @@ class _$DiaryModelImpl implements _DiaryModel { @override String toString() { - return 'DiaryModel(id: $id, date: $date, closed: $closed, meals: $meals, comment: $comment, wakeup: $wakeup, retire: $retire)'; + return 'DiaryModel(id: $id, date: $date, closed: $closed, meals: $meals, state: $state, comment: $comment, wakeup: $wakeup, retire: $retire)'; } @override @@ -225,6 +254,7 @@ class _$DiaryModelImpl implements _DiaryModel { (identical(other.date, date) || other.date == date) && (identical(other.closed, closed) || other.closed == closed) && const DeepCollectionEquality().equals(other._meals, _meals) && + (identical(other.state, state) || other.state == state) && (identical(other.comment, comment) || other.comment == comment) && (identical(other.wakeup, wakeup) || other.wakeup == wakeup) && (identical(other.retire, retire) || other.retire == retire)); @@ -232,8 +262,16 @@ class _$DiaryModelImpl implements _DiaryModel { @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, date, closed, - const DeepCollectionEquality().hash(_meals), comment, wakeup, retire); + int get hashCode => Object.hash( + runtimeType, + id, + date, + closed, + const DeepCollectionEquality().hash(_meals), + state, + comment, + wakeup, + retire); @JsonKey(ignore: true) @override @@ -255,6 +293,7 @@ abstract class _DiaryModel implements DiaryModel { required final DateTime date, required final int closed, required final List meals, + required final State state, final String? comment, final DateTime? wakeup, final DateTime? retire}) = _$DiaryModelImpl; @@ -271,6 +310,8 @@ abstract class _DiaryModel implements DiaryModel { @override List get meals; @override + State get state; + @override String? get comment; @override DateTime? get wakeup; diff --git a/lib/features/diary/models/diary_model.g.dart b/lib/features/diary/models/diary_model.g.dart index 1a13c7d5..29f98caa 100644 --- a/lib/features/diary/models/diary_model.g.dart +++ b/lib/features/diary/models/diary_model.g.dart @@ -14,6 +14,7 @@ _$DiaryModelImpl _$$DiaryModelImplFromJson(Map json) => meals: (json['meals'] as List) .map((e) => Meal.fromJson(e as Map)) .toList(), + state: State.fromJson(json['state'] as Map), comment: json['comment'] as String?, wakeup: json['wakeup'] == null ? null @@ -29,6 +30,7 @@ Map _$$DiaryModelImplToJson(_$DiaryModelImpl instance) => 'date': instance.date.toIso8601String(), 'closed': instance.closed, 'meals': instance.meals, + 'state': instance.state, 'comment': instance.comment, 'wakeup': instance.wakeup?.toIso8601String(), 'retire': instance.retire?.toIso8601String(), diff --git a/lib/features/diary/models/photo.freezed.dart b/lib/features/diary/models/photo.freezed.dart index 81cbdd37..2d9c70bd 100644 --- a/lib/features/diary/models/photo.freezed.dart +++ b/lib/features/diary/models/photo.freezed.dart @@ -21,33 +21,33 @@ Photo _$PhotoFromJson(Map json) { /// @nodoc mixin _$Photo { int get id => throw _privateConstructorUsedError; - @JsonKey(name: 'original_name') String get originalName => throw _privateConstructorUsedError; - String get path => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $PhotoCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class $PhotoCopyWith<$Res> { - factory $PhotoCopyWith(Photo value, $Res Function(Photo) then) = _$PhotoCopyWithImpl<$Res, Photo>; - + factory $PhotoCopyWith(Photo value, $Res Function(Photo) then) = + _$PhotoCopyWithImpl<$Res, Photo>; @useResult - $Res call({int id, @JsonKey(name: 'original_name') String originalName, String path}); + $Res call( + {int id, + @JsonKey(name: 'original_name') String originalName, + String path}); } /// @nodoc -class _$PhotoCopyWithImpl<$Res, $Val extends Photo> implements $PhotoCopyWith<$Res> { +class _$PhotoCopyWithImpl<$Res, $Val extends Photo> + implements $PhotoCopyWith<$Res> { _$PhotoCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -77,16 +77,24 @@ class _$PhotoCopyWithImpl<$Res, $Val extends Photo> implements $PhotoCopyWith<$R /// @nodoc abstract class _$$PhotoImplCopyWith<$Res> implements $PhotoCopyWith<$Res> { - factory _$$PhotoImplCopyWith(_$PhotoImpl value, $Res Function(_$PhotoImpl) then) = __$$PhotoImplCopyWithImpl<$Res>; - + factory _$$PhotoImplCopyWith( + _$PhotoImpl value, $Res Function(_$PhotoImpl) then) = + __$$PhotoImplCopyWithImpl<$Res>; @override @useResult - $Res call({int id, @JsonKey(name: 'original_name') String originalName, String path}); + $Res call( + {int id, + @JsonKey(name: 'original_name') String originalName, + String path}); } /// @nodoc -class __$$PhotoImplCopyWithImpl<$Res> extends _$PhotoCopyWithImpl<$Res, _$PhotoImpl> implements _$$PhotoImplCopyWith<$Res> { - __$$PhotoImplCopyWithImpl(_$PhotoImpl _value, $Res Function(_$PhotoImpl) _then) : super(_value, _then); +class __$$PhotoImplCopyWithImpl<$Res> + extends _$PhotoCopyWithImpl<$Res, _$PhotoImpl> + implements _$$PhotoImplCopyWith<$Res> { + __$$PhotoImplCopyWithImpl( + _$PhotoImpl _value, $Res Function(_$PhotoImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -115,9 +123,13 @@ class __$$PhotoImplCopyWithImpl<$Res> extends _$PhotoCopyWithImpl<$Res, _$PhotoI /// @nodoc @JsonSerializable() class _$PhotoImpl implements _Photo { - const _$PhotoImpl({required this.id, @JsonKey(name: 'original_name') required this.originalName, required this.path}); + const _$PhotoImpl( + {required this.id, + @JsonKey(name: 'original_name') required this.originalName, + required this.path}); - factory _$PhotoImpl.fromJson(Map json) => _$$PhotoImplFromJson(json); + factory _$PhotoImpl.fromJson(Map json) => + _$$PhotoImplFromJson(json); @override final int id; @@ -138,7 +150,8 @@ class _$PhotoImpl implements _Photo { (other.runtimeType == runtimeType && other is _$PhotoImpl && (identical(other.id, id) || other.id == id) && - (identical(other.originalName, originalName) || other.originalName == originalName) && + (identical(other.originalName, originalName) || + other.originalName == originalName) && (identical(other.path, path) || other.path == path)); } @@ -149,7 +162,8 @@ class _$PhotoImpl implements _Photo { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => __$$PhotoImplCopyWithImpl<_$PhotoImpl>(this, _$identity); + _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => + __$$PhotoImplCopyWithImpl<_$PhotoImpl>(this, _$identity); @override Map toJson() { @@ -160,21 +174,22 @@ class _$PhotoImpl implements _Photo { } abstract class _Photo implements Photo { - const factory _Photo({required final int id, @JsonKey(name: 'original_name') required final String originalName, required final String path}) = _$PhotoImpl; + const factory _Photo( + {required final int id, + @JsonKey(name: 'original_name') required final String originalName, + required final String path}) = _$PhotoImpl; factory _Photo.fromJson(Map json) = _$PhotoImpl.fromJson; @override int get id; - @override @JsonKey(name: 'original_name') String get originalName; - @override String get path; - @override @JsonKey(ignore: true) - _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => throw _privateConstructorUsedError; + _$$PhotoImplCopyWith<_$PhotoImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/diary/models/photo.g.dart b/lib/features/diary/models/photo.g.dart index 1efd15ed..cacf65ac 100644 --- a/lib/features/diary/models/photo.g.dart +++ b/lib/features/diary/models/photo.g.dart @@ -12,7 +12,8 @@ _$PhotoImpl _$$PhotoImplFromJson(Map json) => _$PhotoImpl( path: json['path'] as String, ); -Map _$$PhotoImplToJson(_$PhotoImpl instance) => { +Map _$$PhotoImplToJson(_$PhotoImpl instance) => + { 'id': instance.id, 'original_name': instance.originalName, 'path': instance.path, diff --git a/lib/features/diary/models/portion.dart b/lib/features/diary/models/portion.dart index 54a46dd6..59ad837d 100644 --- a/lib/features/diary/models/portion.dart +++ b/lib/features/diary/models/portion.dart @@ -10,6 +10,7 @@ class Portion with _$Portion { required String product_name, required int quantity, required String portion, + required bool from_diet, }) = _Portion; factory Portion.fromJson(Map json) => _$PortionFromJson(json); diff --git a/lib/features/diary/models/portion.freezed.dart b/lib/features/diary/models/portion.freezed.dart index a7a35a29..77627c29 100644 --- a/lib/features/diary/models/portion.freezed.dart +++ b/lib/features/diary/models/portion.freezed.dart @@ -24,6 +24,7 @@ mixin _$Portion { String get product_name => throw _privateConstructorUsedError; int get quantity => throw _privateConstructorUsedError; String get portion => throw _privateConstructorUsedError; + bool get from_diet => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -35,7 +36,12 @@ abstract class $PortionCopyWith<$Res> { factory $PortionCopyWith(Portion value, $Res Function(Portion) then) = _$PortionCopyWithImpl<$Res, Portion>; @useResult - $Res call({int id, String product_name, int quantity, String portion}); + $Res call( + {int id, + String product_name, + int quantity, + String portion, + bool from_diet}); } /// @nodoc @@ -55,6 +61,7 @@ class _$PortionCopyWithImpl<$Res, $Val extends Portion> Object? product_name = null, Object? quantity = null, Object? portion = null, + Object? from_diet = null, }) { return _then(_value.copyWith( id: null == id @@ -73,6 +80,10 @@ class _$PortionCopyWithImpl<$Res, $Val extends Portion> ? _value.portion : portion // ignore: cast_nullable_to_non_nullable as String, + from_diet: null == from_diet + ? _value.from_diet + : from_diet // ignore: cast_nullable_to_non_nullable + as bool, ) as $Val); } } @@ -84,7 +95,12 @@ abstract class _$$PortionImplCopyWith<$Res> implements $PortionCopyWith<$Res> { __$$PortionImplCopyWithImpl<$Res>; @override @useResult - $Res call({int id, String product_name, int quantity, String portion}); + $Res call( + {int id, + String product_name, + int quantity, + String portion, + bool from_diet}); } /// @nodoc @@ -102,6 +118,7 @@ class __$$PortionImplCopyWithImpl<$Res> Object? product_name = null, Object? quantity = null, Object? portion = null, + Object? from_diet = null, }) { return _then(_$PortionImpl( id: null == id @@ -120,6 +137,10 @@ class __$$PortionImplCopyWithImpl<$Res> ? _value.portion : portion // ignore: cast_nullable_to_non_nullable as String, + from_diet: null == from_diet + ? _value.from_diet + : from_diet // ignore: cast_nullable_to_non_nullable + as bool, )); } } @@ -131,7 +152,8 @@ class _$PortionImpl implements _Portion { {required this.id, required this.product_name, required this.quantity, - required this.portion}); + required this.portion, + required this.from_diet}); factory _$PortionImpl.fromJson(Map json) => _$$PortionImplFromJson(json); @@ -144,10 +166,12 @@ class _$PortionImpl implements _Portion { final int quantity; @override final String portion; + @override + final bool from_diet; @override String toString() { - return 'Portion(id: $id, product_name: $product_name, quantity: $quantity, portion: $portion)'; + return 'Portion(id: $id, product_name: $product_name, quantity: $quantity, portion: $portion, from_diet: $from_diet)'; } @override @@ -160,13 +184,15 @@ class _$PortionImpl implements _Portion { other.product_name == product_name) && (identical(other.quantity, quantity) || other.quantity == quantity) && - (identical(other.portion, portion) || other.portion == portion)); + (identical(other.portion, portion) || other.portion == portion) && + (identical(other.from_diet, from_diet) || + other.from_diet == from_diet)); } @JsonKey(ignore: true) @override int get hashCode => - Object.hash(runtimeType, id, product_name, quantity, portion); + Object.hash(runtimeType, id, product_name, quantity, portion, from_diet); @JsonKey(ignore: true) @override @@ -187,7 +213,8 @@ abstract class _Portion implements Portion { {required final int id, required final String product_name, required final int quantity, - required final String portion}) = _$PortionImpl; + required final String portion, + required final bool from_diet}) = _$PortionImpl; factory _Portion.fromJson(Map json) = _$PortionImpl.fromJson; @@ -200,6 +227,8 @@ abstract class _Portion implements Portion { @override String get portion; @override + bool get from_diet; + @override @JsonKey(ignore: true) _$$PortionImplCopyWith<_$PortionImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/features/diary/models/portion.g.dart b/lib/features/diary/models/portion.g.dart index c8bd109f..f3503e5c 100644 --- a/lib/features/diary/models/portion.g.dart +++ b/lib/features/diary/models/portion.g.dart @@ -12,6 +12,7 @@ _$PortionImpl _$$PortionImplFromJson(Map json) => product_name: json['product_name'] as String, quantity: (json['quantity'] as num).toInt(), portion: json['portion'] as String, + from_diet: json['from_diet'] as bool, ); Map _$$PortionImplToJson(_$PortionImpl instance) => @@ -20,4 +21,5 @@ Map _$$PortionImplToJson(_$PortionImpl instance) => 'product_name': instance.product_name, 'quantity': instance.quantity, 'portion': instance.portion, + 'from_diet': instance.from_diet, }; diff --git a/lib/features/diary/models/state.dart b/lib/features/diary/models/state.dart new file mode 100644 index 00000000..874592ed --- /dev/null +++ b/lib/features/diary/models/state.dart @@ -0,0 +1,14 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'state.freezed.dart'; +part 'state.g.dart'; + +@freezed +class State with _$State { + const factory State({ + required bool has_chosen_diet, + required bool has_chosen_plan, + }) = _State; + + factory State.fromJson(Map json) => _$StateFromJson(json); +} diff --git a/lib/features/diary/models/state.freezed.dart b/lib/features/diary/models/state.freezed.dart new file mode 100644 index 00000000..599ec29f --- /dev/null +++ b/lib/features/diary/models/state.freezed.dart @@ -0,0 +1,169 @@ +// 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 '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'); + +State _$StateFromJson(Map json) { + return _State.fromJson(json); +} + +/// @nodoc +mixin _$State { + bool get has_chosen_diet => throw _privateConstructorUsedError; + bool get has_chosen_plan => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StateCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StateCopyWith<$Res> { + factory $StateCopyWith(State value, $Res Function(State) then) = + _$StateCopyWithImpl<$Res, State>; + @useResult + $Res call({bool has_chosen_diet, bool has_chosen_plan}); +} + +/// @nodoc +class _$StateCopyWithImpl<$Res, $Val extends State> + implements $StateCopyWith<$Res> { + _$StateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? has_chosen_diet = null, + Object? has_chosen_plan = null, + }) { + return _then(_value.copyWith( + has_chosen_diet: null == has_chosen_diet + ? _value.has_chosen_diet + : has_chosen_diet // ignore: cast_nullable_to_non_nullable + as bool, + has_chosen_plan: null == has_chosen_plan + ? _value.has_chosen_plan + : has_chosen_plan // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$StateImplCopyWith<$Res> implements $StateCopyWith<$Res> { + factory _$$StateImplCopyWith( + _$StateImpl value, $Res Function(_$StateImpl) then) = + __$$StateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({bool has_chosen_diet, bool has_chosen_plan}); +} + +/// @nodoc +class __$$StateImplCopyWithImpl<$Res> + extends _$StateCopyWithImpl<$Res, _$StateImpl> + implements _$$StateImplCopyWith<$Res> { + __$$StateImplCopyWithImpl( + _$StateImpl _value, $Res Function(_$StateImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? has_chosen_diet = null, + Object? has_chosen_plan = null, + }) { + return _then(_$StateImpl( + has_chosen_diet: null == has_chosen_diet + ? _value.has_chosen_diet + : has_chosen_diet // ignore: cast_nullable_to_non_nullable + as bool, + has_chosen_plan: null == has_chosen_plan + ? _value.has_chosen_plan + : has_chosen_plan // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StateImpl implements _State { + const _$StateImpl( + {required this.has_chosen_diet, required this.has_chosen_plan}); + + factory _$StateImpl.fromJson(Map json) => + _$$StateImplFromJson(json); + + @override + final bool has_chosen_diet; + @override + final bool has_chosen_plan; + + @override + String toString() { + return 'State(has_chosen_diet: $has_chosen_diet, has_chosen_plan: $has_chosen_plan)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StateImpl && + (identical(other.has_chosen_diet, has_chosen_diet) || + other.has_chosen_diet == has_chosen_diet) && + (identical(other.has_chosen_plan, has_chosen_plan) || + other.has_chosen_plan == has_chosen_plan)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, has_chosen_diet, has_chosen_plan); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$StateImplCopyWith<_$StateImpl> get copyWith => + __$$StateImplCopyWithImpl<_$StateImpl>(this, _$identity); + + @override + Map toJson() { + return _$$StateImplToJson( + this, + ); + } +} + +abstract class _State implements State { + const factory _State( + {required final bool has_chosen_diet, + required final bool has_chosen_plan}) = _$StateImpl; + + factory _State.fromJson(Map json) = _$StateImpl.fromJson; + + @override + bool get has_chosen_diet; + @override + bool get has_chosen_plan; + @override + @JsonKey(ignore: true) + _$$StateImplCopyWith<_$StateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/diary/models/state.g.dart b/lib/features/diary/models/state.g.dart new file mode 100644 index 00000000..1b0da8f4 --- /dev/null +++ b/lib/features/diary/models/state.g.dart @@ -0,0 +1,18 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'state.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$StateImpl _$$StateImplFromJson(Map json) => _$StateImpl( + has_chosen_diet: json['has_chosen_diet'] as bool, + has_chosen_plan: json['has_chosen_plan'] as bool, + ); + +Map _$$StateImplToJson(_$StateImpl instance) => + { + 'has_chosen_diet': instance.has_chosen_diet, + 'has_chosen_plan': instance.has_chosen_plan, + }; diff --git a/lib/features/diary/presentation/bloc/diary_bloc.dart b/lib/features/diary/presentation/bloc/diary_bloc.dart index f71c51a0..ad146936 100644 --- a/lib/features/diary/presentation/bloc/diary_bloc.dart +++ b/lib/features/diary/presentation/bloc/diary_bloc.dart @@ -42,6 +42,7 @@ class DiaryBloc extends Bloc { on(_finishDay); on(_sendModeration); on(_clearInput); + on(_confirmPortion); } loadDiary( @@ -329,7 +330,6 @@ class DiaryBloc extends Bloc { ) async { if (state is DiaryStateLoaded) { var currentState = state as DiaryStateLoaded; - await diaryRepository.addPortion( currentState.diary.id, currentState.currentMeal.id, @@ -484,6 +484,26 @@ class DiaryBloc extends Bloc { SelectionPopupModel(id: 1, title: "грамм"), ]; } + + FutureOr _confirmPortion(ConfirmPortion event, Emitter emit) { + if (state is DiaryStateLoaded) { + var currentState = state as DiaryStateLoaded; + + final updatedPortions = currentState.portions.map((portion) { + if (portion.id == event.id) { + return portion.copyWith(from_diet: !portion.from_diet); + } + if (!portion.from_diet) add(RemovePortionEvent(portion.id)); + return portion; + }).toList(); + + final updatedState = currentState.copyWith(portions: updatedPortions); + + emit(updatedState); + + add(LoadDiary()); + } + } } int convertToInt(dynamic value) { diff --git a/lib/features/diary/presentation/bloc/diary_event.dart b/lib/features/diary/presentation/bloc/diary_event.dart index 3c190626..cfc1bedf 100644 --- a/lib/features/diary/presentation/bloc/diary_event.dart +++ b/lib/features/diary/presentation/bloc/diary_event.dart @@ -180,6 +180,14 @@ class RefreshEvent extends DiaryEvent { List get props => []; } +class ConfirmPortion extends DiaryEvent { + ConfirmPortion(this.id); + int id; + + @override + List get props => [id]; +} + class SendModeration extends DiaryEvent { SendModeration({ required this.name, diff --git a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart index b2dcfca3..6c9f3a12 100644 --- a/lib/features/diary/presentation/pages/diary_recommendations_scree.dart +++ b/lib/features/diary/presentation/pages/diary_recommendations_scree.dart @@ -54,10 +54,8 @@ class DiaryRecommendationsScreen extends StatelessWidget { ); } - Widget _buildDiaryRecommendations( - BuildContext context, DiaryStateLoaded state) { - final Portion product = - new Portion(id: 1, product_name: "", quantity: 1, portion: ""); + Widget _buildDiaryRecommendations(BuildContext context, DiaryStateLoaded state) { + final Portion product = new Portion(id: 1, product_name: "", quantity: 1, portion: "", from_diet: true); return Stack( alignment: Alignment.bottomCenter, children: [ @@ -88,13 +86,9 @@ class DiaryRecommendationsScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - 'Название продукта: ${product.product_name}', - style: TextStyle(fontSize: 24)), + Text('Название продукта: ${product.product_name}', style: TextStyle(fontSize: 24)), SizedBox(height: 16), - Text( - 'Количество: ${product.quantity} ${product.portion}', - style: TextStyle(fontSize: 18)), + Text('Количество: ${product.quantity} ${product.portion}', style: TextStyle(fontSize: 18)), // Добавьте другие детали о продукте по необходимости ], ), diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index 74a00edc..b3ac700c 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -154,8 +154,7 @@ class DiaryScreen extends StatelessWidget { trackOpacity: 0.1, gap: "8%", radius: "110%", - innerRadius: - '20%', // Измените значение по вашему усмотрению + innerRadius: '20%', // Измените значение по вашему усмотрению ) ], ), @@ -272,7 +271,7 @@ class DiaryScreen extends StatelessWidget { borderRadius: BorderRadius.circular(16), ), backgroundColor: appTheme.blueA400, - onPressed: () => addProduct, + onPressed: () => addProduct(context), label: Text( 'Добавить продукт', style: theme.textTheme.titleSmall, @@ -282,9 +281,7 @@ class DiaryScreen extends StatelessWidget { } addProduct(BuildContext context) { - return () { - context.read().add(AddPortionEvent()); - }; + context.read().add(AddPortionEvent()); } /// Section Widget @@ -338,9 +335,7 @@ class DiaryScreen extends StatelessWidget { borderRadius: BorderRadiusStyle.roundedBorder5, ), child: Center( - child: CircularProgressIndicator( - color: appTheme - .blueGray300), // Замените на свой прелоадер при необходимости + child: CircularProgressIndicator(color: appTheme.blueGray300), // Замените на свой прелоадер при необходимости ), ), ], @@ -366,8 +361,7 @@ class DiaryScreen extends StatelessWidget { _buildMeal(BuildContext context, DiaryStateLoaded state) { final digitsOnly = FilteringTextInputFormatter.digitsOnly; - List _options = - state.autocompleteList.map((Product item) => item.name).toList(); + List _options = state.autocompleteList.map((Product item) => item.name).toList(); FocusNode focusNodeName = FocusNode(); return Container( padding: EdgeInsets.symmetric( @@ -402,9 +396,7 @@ class DiaryScreen extends StatelessWidget { onTap: () => _selectMealTime(context, state), child: AbsorbPointer( child: CustomTextFormField( - hintText: state.mealTimeController - ?.format(context) - .toString(), + hintText: state.mealTimeController?.format(context).toString(), autofocus: false, ), ), @@ -540,9 +532,8 @@ class DiaryScreen extends StatelessWidget { SizedBox(height: 24.v), _buildAddProduct(context, state), SizedBox(height: 24.v), - ...state.portions - .map((portion) => _buildProduct(context, portion)) - .toList(), + if (!state.diary.state.has_chosen_diet) ...state.portions.map((portion) => _buildProduct(context, portion)).toList(), + if (state.diary.state.has_chosen_diet) ...state.portions.map((portion) => _buildProductDiet(context, portion)).toList(), SizedBox(height: 24.v), _buildCarousel(context, state), SizedBox(height: 24.v), @@ -691,8 +682,7 @@ class DiaryScreen extends StatelessWidget { popDialog(BuildContext dialogContext) { return () { - Navigator.of(dialogContext) - .pop(); // Dismiss the dialog on Cancel button press + Navigator.of(dialogContext).pop(); // Dismiss the dialog on Cancel button press }; } @@ -702,8 +692,7 @@ class DiaryScreen extends StatelessWidget { }; } - selectProduct(AutocompleteOnSelected onSelected, String option, - DiaryStateLoaded state) { + selectProduct(AutocompleteOnSelected onSelected, String option, DiaryStateLoaded state) { state.product_nameController.text = option; return () { onSelected(option); @@ -771,9 +760,7 @@ class DiaryScreen extends StatelessWidget { top: 5.v, ), child: Text( - portion.product_name.length > 8 - ? portion.product_name.substring(0, 8) - : portion.product_name, + portion.product_name.length > 8 ? portion.product_name.substring(0, 8) : portion.product_name, style: CustomTextStyles.titleMedium16, ), ), @@ -789,7 +776,7 @@ class DiaryScreen extends StatelessWidget { ), Spacer(), GestureDetector( - onTap: removePortion(context, portion), + onTap: () => removePortion(context, portion), child: Padding( padding: const EdgeInsets.only(right: 10), child: Icon( @@ -803,6 +790,53 @@ class DiaryScreen extends StatelessWidget { ); } + _buildProductDiet(BuildContext context, Portion portion) { + return Container( + margin: EdgeInsets.symmetric( + horizontal: 10.h, + vertical: 4.h, + ), + padding: EdgeInsets.symmetric( + horizontal: 8.h, + vertical: 6.v, + ), + decoration: AppDecoration.fillGray.copyWith( + borderRadius: BorderRadiusStyle.roundedBorder5, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + Checkbox( + value: !portion.from_diet, + onChanged: (bool? value) => context.read().add(ConfirmPortion(portion.id)), + ), + Padding( + padding: EdgeInsets.only( + left: 7.h, + top: 5.v, + ), + child: Text( + portion.product_name.length > 18 ? portion.product_name.substring(0, 18) : portion.product_name, + style: CustomTextStyles.titleMedium16, + ), + ), + Spacer(), + Padding( + padding: EdgeInsets.only( + left: 20.h, + top: 3.v, + bottom: 3.v, + ), + child: Text( + portion.quantity.toString() + ' ' + portion.portion.toString().tr, + ), + ), + ], + ), + ); + } + _buildPhoto(BuildContext context, Photo photo, DiaryStateLoaded state) { return Stack( children: [ @@ -861,9 +895,7 @@ class DiaryScreen extends StatelessWidget { removePhoto(BuildContext context, Photo photo) { return () { - context - .read() - .add(RemoveImageEvent(photo.id.toString(), photo.path)); + context.read().add(RemoveImageEvent(photo.id.toString(), photo.path)); }; } @@ -923,9 +955,7 @@ class DiaryScreen extends StatelessWidget { r"Подъем \ отход ко сну", style: CustomTextStyles.bodyMediumBlack900, ), - Icon(state.wakeupExpanded - ? Icons.arrow_drop_up - : Icons.arrow_drop_down), + Icon(state.wakeupExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), ], ), ), @@ -939,8 +969,7 @@ class DiaryScreen extends StatelessWidget { onTap: () => _selectWakeupTime(context, state), child: AbsorbPointer( child: CustomTextFormField( - hintText: - state.wakeupController.format(context).toString(), + hintText: state.wakeupController.format(context).toString(), prefix: Icon(Icons.sunny), autofocus: false, ), @@ -951,8 +980,7 @@ class DiaryScreen extends StatelessWidget { onTap: () => _selectRetireTime(context, state), child: AbsorbPointer( child: CustomTextFormField( - hintText: - state.retireController.format(context).toString(), + hintText: state.retireController.format(context).toString(), prefix: Icon(Icons.bed), autofocus: false, ), @@ -999,8 +1027,7 @@ class DiaryScreen extends StatelessWidget { }; } - Function() sendFinishDayData( - BuildContext dialogContext, BuildContext context) { + Function() sendFinishDayData(BuildContext dialogContext, BuildContext context) { return () { closeDialog(dialogContext); context.read().add(FinishDay()); @@ -1034,9 +1061,7 @@ class DiaryScreen extends StatelessWidget { "Ваше настроение после приема пищи", style: CustomTextStyles.bodyMediumBlack900, ), - Icon(state.moodExpanded - ? Icons.arrow_drop_up - : Icons.arrow_drop_down), + Icon(state.moodExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down), ], ), ), @@ -1096,8 +1121,7 @@ class DiaryScreen extends StatelessWidget { }; } - Future _selectWakeupTime( - BuildContext context, DiaryStateLoaded state) async { + Future _selectWakeupTime(BuildContext context, DiaryStateLoaded state) async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: state.wakeupController, @@ -1107,8 +1131,7 @@ class DiaryScreen extends StatelessWidget { } } - Future _selectRetireTime( - BuildContext context, DiaryStateLoaded state) async { + Future _selectRetireTime(BuildContext context, DiaryStateLoaded state) async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: state.retireController, @@ -1118,8 +1141,7 @@ class DiaryScreen extends StatelessWidget { } } - Future _selectMealTime( - BuildContext context, DiaryStateLoaded state) async { + Future _selectMealTime(BuildContext context, DiaryStateLoaded state) async { final TimeOfDay? pickedTime = await showTimePicker( context: context, initialTime: state.mealTimeController ?? TimeOfDay.now(), @@ -1130,8 +1152,7 @@ class DiaryScreen extends StatelessWidget { } } -bool checkConsumedValues( - List recommendedValues, List consumedValues) { +bool checkConsumedValues(List recommendedValues, List consumedValues) { for (int i = 0; i < recommendedValues.length; i++) { if (consumedValues[i] > recommendedValues[i]) { // Если хотя бы одно потребленное значение превышает рекомендованное diff --git a/lib/features/diary/services/diary_service.g.dart b/lib/features/diary/services/diary_service.g.dart index aba060cd..8c1039c0 100644 --- a/lib/features/diary/services/diary_service.g.dart +++ b/lib/features/diary/services/diary_service.g.dart @@ -12,36 +12,45 @@ class _DiaryService implements DiaryService { _DiaryService( this._dio, { this.baseUrl, + this.errorLogger, }); final Dio _dio; String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future> getDiaryID() async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType>(Options( + final _options = _setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = _result.data!.cast(); + .compose( + _dio.options, + '/api/diary/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.cast(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -51,25 +60,31 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType>(Options( + final _options = _setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${id}/show/', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - var _value = _result.data!.map((k, dynamic v) => - MapEntry(k, DiaryModel.fromJson(v as Map))); + .compose( + _dio.options, + '/api/diary/${id}/show/', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.map((k, dynamic v) => + MapEntry(k, DiaryModel.fromJson(v as Map))); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -79,7 +94,7 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -94,7 +109,8 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); + ))); + final _result = await _dio.fetch(_options); final _value = _result.data; return _value; } @@ -105,28 +121,34 @@ class _DiaryService implements DiaryService { final queryParameters = {r'name': name}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType>>(Options( + final _options = _setStreamType>>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/filter', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - var _value = _result.data!.map((k, dynamic v) => MapEntry( - k, - (v as List) - .map((i) => Product.fromJson(i as Map)) - .toList())); + .compose( + _dio.options, + '/api/diary/product_nutritional_values/filter', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map> _value; + try { + _value = _result.data!.map((k, dynamic v) => MapEntry( + k, + (v as List) + .map((i) => Product.fromJson(i as Map)) + .toList())); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -140,24 +162,30 @@ class _DiaryService implements DiaryService { final queryParameters = {r'satiety': satiety}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType>(Options( + final _options = _setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/satiety/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = _result.data!.cast(); + .compose( + _dio.options, + '/api/diary/${diary_id}/meal/${meal_id}/satiety/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.cast(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -171,24 +199,30 @@ class _DiaryService implements DiaryService { final queryParameters = {r'mood': mood}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType>(Options( + final _options = _setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/mood/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = _result.data!.cast(); + .compose( + _dio.options, + '/api/diary/${diary_id}/meal/${meal_id}/mood/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.cast(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -201,24 +235,30 @@ class _DiaryService implements DiaryService { final queryParameters = {r'wakeup': wakeup}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/wakeup/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = DiaryModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/diary/${diary_id}/wakeup/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late DiaryModel _value; + try { + _value = DiaryModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -231,24 +271,30 @@ class _DiaryService implements DiaryService { final queryParameters = {r'retire': retire}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/retire/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = DiaryModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/diary/${diary_id}/retire/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late DiaryModel _value; + try { + _value = DiaryModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -268,25 +314,31 @@ class _DiaryService implements DiaryService { }; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType>(Options( + final _options = _setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/portions/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - var _value = _result.data!.map((k, dynamic v) => - MapEntry(k, Portion.fromJson(v as Map))); + .compose( + _dio.options, + '/api/diary/${diary_id}/meal/${meal_id}/portions/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.map((k, dynamic v) => + MapEntry(k, Portion.fromJson(v as Map))); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -307,7 +359,7 @@ class _DiaryService implements DiaryService { filename: photo.path.split(Platform.pathSeparator).last, ), )); - await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -322,7 +374,8 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); + ))); + await _dio.fetch(_options); } @override @@ -343,24 +396,30 @@ class _DiaryService implements DiaryService { }; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType>(Options( + final _options = _setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/sendToModeration', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = _result.data!.cast(); + .compose( + _dio.options, + '/api/diary/product_nutritional_values/sendToModeration', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.cast(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -370,7 +429,7 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -385,7 +444,8 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); + ))); + await _dio.fetch(_options); } @override @@ -398,7 +458,7 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'DELETE', headers: _headers, extra: _extra, @@ -413,7 +473,8 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); + ))); + await _dio.fetch(_options); } @override @@ -430,7 +491,7 @@ class _DiaryService implements DiaryService { }; final _headers = {}; const Map? _data = null; - await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'DELETE', headers: _headers, extra: _extra, @@ -445,7 +506,8 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); + ))); + await _dio.fetch(_options); } RequestOptions _setStreamType(RequestOptions requestOptions) { diff --git a/lib/features/feed/models/diets_pagination_model.freezed.dart b/lib/features/feed/models/diets_pagination_model.freezed.dart index c6965ee7..2c402671 100644 --- a/lib/features/feed/models/diets_pagination_model.freezed.dart +++ b/lib/features/feed/models/diets_pagination_model.freezed.dart @@ -22,38 +22,39 @@ DietsPagination _$DietsPaginationFromJson(Map json) { mixin _$DietsPagination { @JsonKey(name: "data") List get data => throw _privateConstructorUsedError; - @JsonKey(name: "links") Links get links => throw _privateConstructorUsedError; - @JsonKey(name: "meta") Meta get meta => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $DietsPaginationCopyWith get copyWith => throw _privateConstructorUsedError; + $DietsPaginationCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $DietsPaginationCopyWith<$Res> { - factory $DietsPaginationCopyWith(DietsPagination value, $Res Function(DietsPagination) then) = _$DietsPaginationCopyWithImpl<$Res, DietsPagination>; - + factory $DietsPaginationCopyWith( + DietsPagination value, $Res Function(DietsPagination) then) = + _$DietsPaginationCopyWithImpl<$Res, DietsPagination>; @useResult - $Res call({@JsonKey(name: "data") List data, @JsonKey(name: "links") Links links, @JsonKey(name: "meta") Meta meta}); + $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 _$DietsPaginationCopyWithImpl<$Res, $Val extends DietsPagination> implements $DietsPaginationCopyWith<$Res> { +class _$DietsPaginationCopyWithImpl<$Res, $Val extends DietsPagination> + implements $DietsPaginationCopyWith<$Res> { _$DietsPaginationCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -98,24 +99,31 @@ class _$DietsPaginationCopyWithImpl<$Res, $Val extends DietsPagination> implemen } /// @nodoc -abstract class _$$DietsPaginationImplCopyWith<$Res> implements $DietsPaginationCopyWith<$Res> { - factory _$$DietsPaginationImplCopyWith(_$DietsPaginationImpl value, $Res Function(_$DietsPaginationImpl) then) = __$$DietsPaginationImplCopyWithImpl<$Res>; - +abstract class _$$DietsPaginationImplCopyWith<$Res> + implements $DietsPaginationCopyWith<$Res> { + factory _$$DietsPaginationImplCopyWith(_$DietsPaginationImpl value, + $Res Function(_$DietsPaginationImpl) then) = + __$$DietsPaginationImplCopyWithImpl<$Res>; @override @useResult - $Res call({@JsonKey(name: "data") List data, @JsonKey(name: "links") Links links, @JsonKey(name: "meta") Meta meta}); + $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 __$$DietsPaginationImplCopyWithImpl<$Res> extends _$DietsPaginationCopyWithImpl<$Res, _$DietsPaginationImpl> +class __$$DietsPaginationImplCopyWithImpl<$Res> + extends _$DietsPaginationCopyWithImpl<$Res, _$DietsPaginationImpl> implements _$$DietsPaginationImplCopyWith<$Res> { - __$$DietsPaginationImplCopyWithImpl(_$DietsPaginationImpl _value, $Res Function(_$DietsPaginationImpl) _then) : super(_value, _then); + __$$DietsPaginationImplCopyWithImpl( + _$DietsPaginationImpl _value, $Res Function(_$DietsPaginationImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -145,13 +153,15 @@ class __$$DietsPaginationImplCopyWithImpl<$Res> extends _$DietsPaginationCopyWit @JsonSerializable() class _$DietsPaginationImpl implements _DietsPagination { const _$DietsPaginationImpl( - {@JsonKey(name: "data") required final List data, @JsonKey(name: "links") required this.links, @JsonKey(name: "meta") required this.meta}) + {@JsonKey(name: "data") required final List data, + @JsonKey(name: "links") required this.links, + @JsonKey(name: "meta") required this.meta}) : _data = data; - factory _$DietsPaginationImpl.fromJson(Map json) => _$$DietsPaginationImplFromJson(json); + factory _$DietsPaginationImpl.fromJson(Map json) => + _$$DietsPaginationImplFromJson(json); final List _data; - @override @JsonKey(name: "data") List get data { @@ -184,12 +194,15 @@ class _$DietsPaginationImpl implements _DietsPagination { @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_data), links, meta); + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_data), links, meta); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$DietsPaginationImplCopyWith<_$DietsPaginationImpl> get copyWith => __$$DietsPaginationImplCopyWithImpl<_$DietsPaginationImpl>(this, _$identity); + _$$DietsPaginationImplCopyWith<_$DietsPaginationImpl> get copyWith => + __$$DietsPaginationImplCopyWithImpl<_$DietsPaginationImpl>( + this, _$identity); @override Map toJson() { @@ -205,23 +218,22 @@ abstract class _DietsPagination implements DietsPagination { @JsonKey(name: "links") required final Links links, @JsonKey(name: "meta") required final Meta meta}) = _$DietsPaginationImpl; - factory _DietsPagination.fromJson(Map json) = _$DietsPaginationImpl.fromJson; + factory _DietsPagination.fromJson(Map json) = + _$DietsPaginationImpl.fromJson; @override @JsonKey(name: "data") List get data; - @override @JsonKey(name: "links") Links get links; - @override @JsonKey(name: "meta") Meta get meta; - @override @JsonKey(ignore: true) - _$$DietsPaginationImplCopyWith<_$DietsPaginationImpl> get copyWith => throw _privateConstructorUsedError; + _$$DietsPaginationImplCopyWith<_$DietsPaginationImpl> get copyWith => + throw _privateConstructorUsedError; } Datum _$DatumFromJson(Map json) { @@ -232,50 +244,39 @@ Datum _$DatumFromJson(Map json) { mixin _$Datum { @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") Type get type => throw _privateConstructorUsedError; - @JsonKey(name: "details") String get details => throw _privateConstructorUsedError; - @JsonKey(name: "daily_schedule") - List>> get dailySchedule => throw _privateConstructorUsedError; - + List>> get dailySchedule => + 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; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $DatumCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class $DatumCopyWith<$Res> { - factory $DatumCopyWith(Datum value, $Res Function(Datum) then) = _$DatumCopyWithImpl<$Res, Datum>; - + factory $DatumCopyWith(Datum value, $Res Function(Datum) then) = + _$DatumCopyWithImpl<$Res, Datum>; @useResult $Res call( {@JsonKey(name: "id") int id, @@ -285,24 +286,24 @@ abstract class $DatumCopyWith<$Res> { @JsonKey(name: "state") String state, @JsonKey(name: "type") Type type, @JsonKey(name: "details") String details, - @JsonKey(name: "daily_schedule") List>> dailySchedule, + @JsonKey(name: "daily_schedule") + List>> dailySchedule, @JsonKey(name: "author") Author author, @JsonKey(name: "total_likes") int totalLikes, @JsonKey(name: "total_views") int totalViews, @JsonKey(name: "total_comments") int totalComments}); $TypeCopyWith<$Res> get type; - $AuthorCopyWith<$Res> get author; } /// @nodoc -class _$DatumCopyWithImpl<$Res, $Val extends Datum> implements $DatumCopyWith<$Res> { +class _$DatumCopyWithImpl<$Res, $Val extends Datum> + implements $DatumCopyWith<$Res> { _$DatumCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -393,8 +394,9 @@ class _$DatumCopyWithImpl<$Res, $Val extends Datum> implements $DatumCopyWith<$R /// @nodoc abstract class _$$DatumImplCopyWith<$Res> implements $DatumCopyWith<$Res> { - factory _$$DatumImplCopyWith(_$DatumImpl value, $Res Function(_$DatumImpl) then) = __$$DatumImplCopyWithImpl<$Res>; - + factory _$$DatumImplCopyWith( + _$DatumImpl value, $Res Function(_$DatumImpl) then) = + __$$DatumImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -405,7 +407,8 @@ abstract class _$$DatumImplCopyWith<$Res> implements $DatumCopyWith<$Res> { @JsonKey(name: "state") String state, @JsonKey(name: "type") Type type, @JsonKey(name: "details") String details, - @JsonKey(name: "daily_schedule") List>> dailySchedule, + @JsonKey(name: "daily_schedule") + List>> dailySchedule, @JsonKey(name: "author") Author author, @JsonKey(name: "total_likes") int totalLikes, @JsonKey(name: "total_views") int totalViews, @@ -413,14 +416,17 @@ abstract class _$$DatumImplCopyWith<$Res> implements $DatumCopyWith<$Res> { @override $TypeCopyWith<$Res> get type; - @override $AuthorCopyWith<$Res> get author; } /// @nodoc -class __$$DatumImplCopyWithImpl<$Res> extends _$DatumCopyWithImpl<$Res, _$DatumImpl> implements _$$DatumImplCopyWith<$Res> { - __$$DatumImplCopyWithImpl(_$DatumImpl _value, $Res Function(_$DatumImpl) _then) : super(_value, _then); +class __$$DatumImplCopyWithImpl<$Res> + extends _$DatumCopyWithImpl<$Res, _$DatumImpl> + implements _$$DatumImplCopyWith<$Res> { + __$$DatumImplCopyWithImpl( + _$DatumImpl _value, $Res Function(_$DatumImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -502,14 +508,16 @@ class _$DatumImpl implements _Datum { @JsonKey(name: "state") required this.state, @JsonKey(name: "type") required this.type, @JsonKey(name: "details") required this.details, - @JsonKey(name: "daily_schedule") required final List>> dailySchedule, + @JsonKey(name: "daily_schedule") + required final List>> dailySchedule, @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}) : _dailySchedule = dailySchedule; - factory _$DatumImpl.fromJson(Map json) => _$$DatumImplFromJson(json); + factory _$DatumImpl.fromJson(Map json) => + _$$DatumImplFromJson(json); @override @JsonKey(name: "id") @@ -533,7 +541,6 @@ class _$DatumImpl implements _Datum { @JsonKey(name: "details") final String details; final List>> _dailySchedule; - @override @JsonKey(name: "daily_schedule") List>> get dailySchedule { @@ -568,26 +575,44 @@ class _$DatumImpl implements _Datum { (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.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) && - const DeepCollectionEquality().equals(other._dailySchedule, _dailySchedule) && + const DeepCollectionEquality() + .equals(other._dailySchedule, _dailySchedule) && (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)); + (identical(other.totalLikes, totalLikes) || + other.totalLikes == totalLikes) && + (identical(other.totalViews, totalViews) || + other.totalViews == totalViews) && + (identical(other.totalComments, totalComments) || + other.totalComments == totalComments)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, name, image, duration, state, type, details, const DeepCollectionEquality().hash(_dailySchedule), author, - totalLikes, totalViews, totalComments); + int get hashCode => Object.hash( + runtimeType, + id, + name, + image, + duration, + state, + type, + details, + const DeepCollectionEquality().hash(_dailySchedule), + author, + totalLikes, + totalViews, + totalComments); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$DatumImplCopyWith<_$DatumImpl> get copyWith => __$$DatumImplCopyWithImpl<_$DatumImpl>(this, _$identity); + _$$DatumImplCopyWith<_$DatumImpl> get copyWith => + __$$DatumImplCopyWithImpl<_$DatumImpl>(this, _$identity); @override Map toJson() { @@ -599,72 +624,63 @@ class _$DatumImpl implements _Datum { abstract class _Datum implements Datum { const factory _Datum( - {@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 Type type, - @JsonKey(name: "details") required final String details, - @JsonKey(name: "daily_schedule") required final List>> dailySchedule, - @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}) = _$DatumImpl; + {@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 Type type, + @JsonKey(name: "details") required final String details, + @JsonKey(name: "daily_schedule") + required final List>> dailySchedule, + @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}) = + _$DatumImpl; factory _Datum.fromJson(Map json) = _$DatumImpl.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") Type get type; - @override @JsonKey(name: "details") String get details; - @override @JsonKey(name: "daily_schedule") List>> get dailySchedule; - @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; - @override @JsonKey(ignore: true) - _$$DatumImplCopyWith<_$DatumImpl> get copyWith => throw _privateConstructorUsedError; + _$$DatumImplCopyWith<_$DatumImpl> get copyWith => + throw _privateConstructorUsedError; } Author _$AuthorFromJson(Map json) { @@ -675,26 +691,22 @@ Author _$AuthorFromJson(Map json) { mixin _$Author { @JsonKey(name: "author_slug") String get authorSlug => throw _privateConstructorUsedError; - @JsonKey(name: "author_name") String get authorName => throw _privateConstructorUsedError; - @JsonKey(name: "author_profile_icon") String get authorProfileIcon => throw _privateConstructorUsedError; - @JsonKey(name: "author_is_me") bool get authorIsMe => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $AuthorCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class $AuthorCopyWith<$Res> { - factory $AuthorCopyWith(Author value, $Res Function(Author) then) = _$AuthorCopyWithImpl<$Res, Author>; - + factory $AuthorCopyWith(Author value, $Res Function(Author) then) = + _$AuthorCopyWithImpl<$Res, Author>; @useResult $Res call( {@JsonKey(name: "author_slug") String authorSlug, @@ -704,12 +716,12 @@ abstract class $AuthorCopyWith<$Res> { } /// @nodoc -class _$AuthorCopyWithImpl<$Res, $Val extends Author> implements $AuthorCopyWith<$Res> { +class _$AuthorCopyWithImpl<$Res, $Val extends Author> + implements $AuthorCopyWith<$Res> { _$AuthorCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -744,8 +756,9 @@ class _$AuthorCopyWithImpl<$Res, $Val extends Author> implements $AuthorCopyWith /// @nodoc abstract class _$$AuthorImplCopyWith<$Res> implements $AuthorCopyWith<$Res> { - factory _$$AuthorImplCopyWith(_$AuthorImpl value, $Res Function(_$AuthorImpl) then) = __$$AuthorImplCopyWithImpl<$Res>; - + factory _$$AuthorImplCopyWith( + _$AuthorImpl value, $Res Function(_$AuthorImpl) then) = + __$$AuthorImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -756,8 +769,12 @@ abstract class _$$AuthorImplCopyWith<$Res> implements $AuthorCopyWith<$Res> { } /// @nodoc -class __$$AuthorImplCopyWithImpl<$Res> extends _$AuthorCopyWithImpl<$Res, _$AuthorImpl> implements _$$AuthorImplCopyWith<$Res> { - __$$AuthorImplCopyWithImpl(_$AuthorImpl _value, $Res Function(_$AuthorImpl) _then) : super(_value, _then); +class __$$AuthorImplCopyWithImpl<$Res> + extends _$AuthorCopyWithImpl<$Res, _$AuthorImpl> + implements _$$AuthorImplCopyWith<$Res> { + __$$AuthorImplCopyWithImpl( + _$AuthorImpl _value, $Res Function(_$AuthorImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -797,7 +814,8 @@ class _$AuthorImpl implements _Author { @JsonKey(name: "author_profile_icon") required this.authorProfileIcon, @JsonKey(name: "author_is_me") required this.authorIsMe}); - factory _$AuthorImpl.fromJson(Map json) => _$$AuthorImplFromJson(json); + factory _$AuthorImpl.fromJson(Map json) => + _$$AuthorImplFromJson(json); @override @JsonKey(name: "author_slug") @@ -822,20 +840,26 @@ class _$AuthorImpl implements _Author { return identical(this, other) || (other.runtimeType == runtimeType && other is _$AuthorImpl && - (identical(other.authorSlug, authorSlug) || other.authorSlug == authorSlug) && - (identical(other.authorName, authorName) || other.authorName == authorName) && - (identical(other.authorProfileIcon, authorProfileIcon) || other.authorProfileIcon == authorProfileIcon) && - (identical(other.authorIsMe, authorIsMe) || other.authorIsMe == authorIsMe)); + (identical(other.authorSlug, authorSlug) || + other.authorSlug == authorSlug) && + (identical(other.authorName, authorName) || + other.authorName == authorName) && + (identical(other.authorProfileIcon, authorProfileIcon) || + other.authorProfileIcon == authorProfileIcon) && + (identical(other.authorIsMe, authorIsMe) || + other.authorIsMe == authorIsMe)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, authorSlug, authorName, authorProfileIcon, authorIsMe); + int get hashCode => Object.hash( + runtimeType, authorSlug, authorName, authorProfileIcon, authorIsMe); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$AuthorImplCopyWith<_$AuthorImpl> get copyWith => __$$AuthorImplCopyWithImpl<_$AuthorImpl>(this, _$identity); + _$$AuthorImplCopyWith<_$AuthorImpl> get copyWith => + __$$AuthorImplCopyWithImpl<_$AuthorImpl>(this, _$identity); @override Map toJson() { @@ -847,32 +871,31 @@ class _$AuthorImpl implements _Author { abstract class _Author implements Author { const factory _Author( - {@JsonKey(name: "author_slug") required final String authorSlug, - @JsonKey(name: "author_name") required final String authorName, - @JsonKey(name: "author_profile_icon") required final String authorProfileIcon, - @JsonKey(name: "author_is_me") required final bool authorIsMe}) = _$AuthorImpl; + {@JsonKey(name: "author_slug") required final String authorSlug, + @JsonKey(name: "author_name") required final String authorName, + @JsonKey(name: "author_profile_icon") + required final String authorProfileIcon, + @JsonKey(name: "author_is_me") required final bool authorIsMe}) = + _$AuthorImpl; factory _Author.fromJson(Map json) = _$AuthorImpl.fromJson; @override @JsonKey(name: "author_slug") String get authorSlug; - @override @JsonKey(name: "author_name") String get authorName; - @override @JsonKey(name: "author_profile_icon") String get authorProfileIcon; - @override @JsonKey(name: "author_is_me") bool get authorIsMe; - @override @JsonKey(ignore: true) - _$$AuthorImplCopyWith<_$AuthorImpl> get copyWith => throw _privateConstructorUsedError; + _$$AuthorImplCopyWith<_$AuthorImpl> get copyWith => + throw _privateConstructorUsedError; } DailySchedule _$DailyScheduleFromJson(Map json) { @@ -883,26 +906,24 @@ DailySchedule _$DailyScheduleFromJson(Map json) { mixin _$DailySchedule { @JsonKey(name: "name") String get name => throw _privateConstructorUsedError; - @JsonKey(name: "uniq") String get uniq => throw _privateConstructorUsedError; - @JsonKey(name: "portion") Portion get portion => throw _privateConstructorUsedError; - @JsonKey(name: "quantity") int get quantity => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $DailyScheduleCopyWith get copyWith => throw _privateConstructorUsedError; + $DailyScheduleCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $DailyScheduleCopyWith<$Res> { - factory $DailyScheduleCopyWith(DailySchedule value, $Res Function(DailySchedule) then) = _$DailyScheduleCopyWithImpl<$Res, DailySchedule>; - + factory $DailyScheduleCopyWith( + DailySchedule value, $Res Function(DailySchedule) then) = + _$DailyScheduleCopyWithImpl<$Res, DailySchedule>; @useResult $Res call( {@JsonKey(name: "name") String name, @@ -912,12 +933,12 @@ abstract class $DailyScheduleCopyWith<$Res> { } /// @nodoc -class _$DailyScheduleCopyWithImpl<$Res, $Val extends DailySchedule> implements $DailyScheduleCopyWith<$Res> { +class _$DailyScheduleCopyWithImpl<$Res, $Val extends DailySchedule> + implements $DailyScheduleCopyWith<$Res> { _$DailyScheduleCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -951,9 +972,11 @@ class _$DailyScheduleCopyWithImpl<$Res, $Val extends DailySchedule> implements $ } /// @nodoc -abstract class _$$DailyScheduleImplCopyWith<$Res> implements $DailyScheduleCopyWith<$Res> { - factory _$$DailyScheduleImplCopyWith(_$DailyScheduleImpl value, $Res Function(_$DailyScheduleImpl) then) = __$$DailyScheduleImplCopyWithImpl<$Res>; - +abstract class _$$DailyScheduleImplCopyWith<$Res> + implements $DailyScheduleCopyWith<$Res> { + factory _$$DailyScheduleImplCopyWith( + _$DailyScheduleImpl value, $Res Function(_$DailyScheduleImpl) then) = + __$$DailyScheduleImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -964,8 +987,12 @@ abstract class _$$DailyScheduleImplCopyWith<$Res> implements $DailyScheduleCopyW } /// @nodoc -class __$$DailyScheduleImplCopyWithImpl<$Res> extends _$DailyScheduleCopyWithImpl<$Res, _$DailyScheduleImpl> implements _$$DailyScheduleImplCopyWith<$Res> { - __$$DailyScheduleImplCopyWithImpl(_$DailyScheduleImpl _value, $Res Function(_$DailyScheduleImpl) _then) : super(_value, _then); +class __$$DailyScheduleImplCopyWithImpl<$Res> + extends _$DailyScheduleCopyWithImpl<$Res, _$DailyScheduleImpl> + implements _$$DailyScheduleImplCopyWith<$Res> { + __$$DailyScheduleImplCopyWithImpl( + _$DailyScheduleImpl _value, $Res Function(_$DailyScheduleImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -1005,7 +1032,8 @@ class _$DailyScheduleImpl implements _DailySchedule { @JsonKey(name: "portion") required this.portion, @JsonKey(name: "quantity") required this.quantity}); - factory _$DailyScheduleImpl.fromJson(Map json) => _$$DailyScheduleImplFromJson(json); + factory _$DailyScheduleImpl.fromJson(Map json) => + _$$DailyScheduleImplFromJson(json); @override @JsonKey(name: "name") @@ -1033,7 +1061,8 @@ class _$DailyScheduleImpl implements _DailySchedule { (identical(other.name, name) || other.name == name) && (identical(other.uniq, uniq) || other.uniq == uniq) && (identical(other.portion, portion) || other.portion == portion) && - (identical(other.quantity, quantity) || other.quantity == quantity)); + (identical(other.quantity, quantity) || + other.quantity == quantity)); } @JsonKey(ignore: true) @@ -1043,7 +1072,8 @@ class _$DailyScheduleImpl implements _DailySchedule { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$DailyScheduleImplCopyWith<_$DailyScheduleImpl> get copyWith => __$$DailyScheduleImplCopyWithImpl<_$DailyScheduleImpl>(this, _$identity); + _$$DailyScheduleImplCopyWith<_$DailyScheduleImpl> get copyWith => + __$$DailyScheduleImplCopyWithImpl<_$DailyScheduleImpl>(this, _$identity); @override Map toJson() { @@ -1055,32 +1085,31 @@ class _$DailyScheduleImpl implements _DailySchedule { abstract class _DailySchedule implements DailySchedule { const factory _DailySchedule( - {@JsonKey(name: "name") required final String name, - @JsonKey(name: "uniq") required final String uniq, - @JsonKey(name: "portion") required final Portion portion, - @JsonKey(name: "quantity") required final int quantity}) = _$DailyScheduleImpl; + {@JsonKey(name: "name") required final String name, + @JsonKey(name: "uniq") required final String uniq, + @JsonKey(name: "portion") required final Portion portion, + @JsonKey(name: "quantity") required final int quantity}) = + _$DailyScheduleImpl; - factory _DailySchedule.fromJson(Map json) = _$DailyScheduleImpl.fromJson; + factory _DailySchedule.fromJson(Map json) = + _$DailyScheduleImpl.fromJson; @override @JsonKey(name: "name") String get name; - @override @JsonKey(name: "uniq") String get uniq; - @override @JsonKey(name: "portion") Portion get portion; - @override @JsonKey(name: "quantity") int get quantity; - @override @JsonKey(ignore: true) - _$$DailyScheduleImplCopyWith<_$DailyScheduleImpl> get copyWith => throw _privateConstructorUsedError; + _$$DailyScheduleImplCopyWith<_$DailyScheduleImpl> get copyWith => + throw _privateConstructorUsedError; } Type _$TypeFromJson(Map json) { @@ -1091,37 +1120,37 @@ Type _$TypeFromJson(Map json) { mixin _$Type { @JsonKey(name: "alko") bool? get alko => throw _privateConstructorUsedError; - @JsonKey(name: "veg") bool? get veg => throw _privateConstructorUsedError; - @JsonKey(name: "corb") bool? get corb => throw _privateConstructorUsedError; - @JsonKey(name: "meat") bool? get meat => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $TypeCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class $TypeCopyWith<$Res> { - factory $TypeCopyWith(Type value, $Res Function(Type) then) = _$TypeCopyWithImpl<$Res, Type>; - + factory $TypeCopyWith(Type value, $Res Function(Type) then) = + _$TypeCopyWithImpl<$Res, Type>; @useResult - $Res call({@JsonKey(name: "alko") bool? alko, @JsonKey(name: "veg") bool? veg, @JsonKey(name: "corb") bool? corb, @JsonKey(name: "meat") bool? meat}); + $Res call( + {@JsonKey(name: "alko") bool? alko, + @JsonKey(name: "veg") bool? veg, + @JsonKey(name: "corb") bool? corb, + @JsonKey(name: "meat") bool? meat}); } /// @nodoc -class _$TypeCopyWithImpl<$Res, $Val extends Type> implements $TypeCopyWith<$Res> { +class _$TypeCopyWithImpl<$Res, $Val extends Type> + implements $TypeCopyWith<$Res> { _$TypeCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -1156,16 +1185,24 @@ class _$TypeCopyWithImpl<$Res, $Val extends Type> implements $TypeCopyWith<$Res> /// @nodoc abstract class _$$TypeImplCopyWith<$Res> implements $TypeCopyWith<$Res> { - factory _$$TypeImplCopyWith(_$TypeImpl value, $Res Function(_$TypeImpl) then) = __$$TypeImplCopyWithImpl<$Res>; - + factory _$$TypeImplCopyWith( + _$TypeImpl value, $Res Function(_$TypeImpl) then) = + __$$TypeImplCopyWithImpl<$Res>; @override @useResult - $Res call({@JsonKey(name: "alko") bool? alko, @JsonKey(name: "veg") bool? veg, @JsonKey(name: "corb") bool? corb, @JsonKey(name: "meat") bool? meat}); + $Res call( + {@JsonKey(name: "alko") bool? alko, + @JsonKey(name: "veg") bool? veg, + @JsonKey(name: "corb") bool? corb, + @JsonKey(name: "meat") bool? meat}); } /// @nodoc -class __$$TypeImplCopyWithImpl<$Res> extends _$TypeCopyWithImpl<$Res, _$TypeImpl> implements _$$TypeImplCopyWith<$Res> { - __$$TypeImplCopyWithImpl(_$TypeImpl _value, $Res Function(_$TypeImpl) _then) : super(_value, _then); +class __$$TypeImplCopyWithImpl<$Res> + extends _$TypeCopyWithImpl<$Res, _$TypeImpl> + implements _$$TypeImplCopyWith<$Res> { + __$$TypeImplCopyWithImpl(_$TypeImpl _value, $Res Function(_$TypeImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -1199,9 +1236,14 @@ class __$$TypeImplCopyWithImpl<$Res> extends _$TypeCopyWithImpl<$Res, _$TypeImpl /// @nodoc @JsonSerializable() class _$TypeImpl implements _Type { - const _$TypeImpl({@JsonKey(name: "alko") this.alko, @JsonKey(name: "veg") this.veg, @JsonKey(name: "corb") this.corb, @JsonKey(name: "meat") this.meat}); + const _$TypeImpl( + {@JsonKey(name: "alko") this.alko, + @JsonKey(name: "veg") this.veg, + @JsonKey(name: "corb") this.corb, + @JsonKey(name: "meat") this.meat}); - factory _$TypeImpl.fromJson(Map json) => _$$TypeImplFromJson(json); + factory _$TypeImpl.fromJson(Map json) => + _$$TypeImplFromJson(json); @override @JsonKey(name: "alko") @@ -1239,7 +1281,8 @@ class _$TypeImpl implements _Type { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$TypeImplCopyWith<_$TypeImpl> get copyWith => __$$TypeImplCopyWithImpl<_$TypeImpl>(this, _$identity); + _$$TypeImplCopyWith<_$TypeImpl> get copyWith => + __$$TypeImplCopyWithImpl<_$TypeImpl>(this, _$identity); @override Map toJson() { @@ -1261,22 +1304,19 @@ abstract class _Type implements Type { @override @JsonKey(name: "alko") bool? get alko; - @override @JsonKey(name: "veg") bool? get veg; - @override @JsonKey(name: "corb") bool? get corb; - @override @JsonKey(name: "meat") bool? get meat; - @override @JsonKey(ignore: true) - _$$TypeImplCopyWith<_$TypeImpl> get copyWith => throw _privateConstructorUsedError; + _$$TypeImplCopyWith<_$TypeImpl> get copyWith => + throw _privateConstructorUsedError; } Links _$LinksFromJson(Map json) { @@ -1287,38 +1327,37 @@ Links _$LinksFromJson(Map json) { mixin _$Links { @JsonKey(name: "first") String get first => throw _privateConstructorUsedError; - @JsonKey(name: "last") String get last => throw _privateConstructorUsedError; - @JsonKey(name: "prev") dynamic get prev => throw _privateConstructorUsedError; - @JsonKey(name: "next") dynamic get next => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $LinksCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class $LinksCopyWith<$Res> { - factory $LinksCopyWith(Links value, $Res Function(Links) then) = _$LinksCopyWithImpl<$Res, Links>; - + factory $LinksCopyWith(Links value, $Res Function(Links) then) = + _$LinksCopyWithImpl<$Res, Links>; @useResult $Res call( - {@JsonKey(name: "first") String first, @JsonKey(name: "last") String last, @JsonKey(name: "prev") dynamic prev, @JsonKey(name: "next") dynamic next}); + {@JsonKey(name: "first") String first, + @JsonKey(name: "last") String last, + @JsonKey(name: "prev") dynamic prev, + @JsonKey(name: "next") dynamic next}); } /// @nodoc -class _$LinksCopyWithImpl<$Res, $Val extends Links> implements $LinksCopyWith<$Res> { +class _$LinksCopyWithImpl<$Res, $Val extends Links> + implements $LinksCopyWith<$Res> { _$LinksCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -1353,17 +1392,25 @@ class _$LinksCopyWithImpl<$Res, $Val extends Links> implements $LinksCopyWith<$R /// @nodoc abstract class _$$LinksImplCopyWith<$Res> implements $LinksCopyWith<$Res> { - factory _$$LinksImplCopyWith(_$LinksImpl value, $Res Function(_$LinksImpl) then) = __$$LinksImplCopyWithImpl<$Res>; - + factory _$$LinksImplCopyWith( + _$LinksImpl value, $Res Function(_$LinksImpl) then) = + __$$LinksImplCopyWithImpl<$Res>; @override @useResult $Res call( - {@JsonKey(name: "first") String first, @JsonKey(name: "last") String last, @JsonKey(name: "prev") dynamic prev, @JsonKey(name: "next") dynamic next}); + {@JsonKey(name: "first") String first, + @JsonKey(name: "last") String last, + @JsonKey(name: "prev") dynamic prev, + @JsonKey(name: "next") dynamic next}); } /// @nodoc -class __$$LinksImplCopyWithImpl<$Res> extends _$LinksCopyWithImpl<$Res, _$LinksImpl> implements _$$LinksImplCopyWith<$Res> { - __$$LinksImplCopyWithImpl(_$LinksImpl _value, $Res Function(_$LinksImpl) _then) : super(_value, _then); +class __$$LinksImplCopyWithImpl<$Res> + extends _$LinksCopyWithImpl<$Res, _$LinksImpl> + implements _$$LinksImplCopyWith<$Res> { + __$$LinksImplCopyWithImpl( + _$LinksImpl _value, $Res Function(_$LinksImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -1403,7 +1450,8 @@ class _$LinksImpl implements _Links { @JsonKey(name: "prev") required this.prev, @JsonKey(name: "next") required this.next}); - factory _$LinksImpl.fromJson(Map json) => _$$LinksImplFromJson(json); + factory _$LinksImpl.fromJson(Map json) => + _$$LinksImplFromJson(json); @override @JsonKey(name: "first") @@ -1436,12 +1484,18 @@ class _$LinksImpl implements _Links { @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, first, last, const DeepCollectionEquality().hash(prev), const DeepCollectionEquality().hash(next)); + int get hashCode => Object.hash( + runtimeType, + first, + last, + const DeepCollectionEquality().hash(prev), + const DeepCollectionEquality().hash(next)); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$LinksImplCopyWith<_$LinksImpl> get copyWith => __$$LinksImplCopyWithImpl<_$LinksImpl>(this, _$identity); + _$$LinksImplCopyWith<_$LinksImpl> get copyWith => + __$$LinksImplCopyWithImpl<_$LinksImpl>(this, _$identity); @override Map toJson() { @@ -1463,22 +1517,19 @@ abstract class _Links implements Links { @override @JsonKey(name: "first") String get first; - @override @JsonKey(name: "last") String get last; - @override @JsonKey(name: "prev") dynamic get prev; - @override @JsonKey(name: "next") dynamic get next; - @override @JsonKey(ignore: true) - _$$LinksImplCopyWith<_$LinksImpl> get copyWith => throw _privateConstructorUsedError; + _$$LinksImplCopyWith<_$LinksImpl> get copyWith => + throw _privateConstructorUsedError; } Meta _$MetaFromJson(Map json) { @@ -1489,38 +1540,30 @@ Meta _$MetaFromJson(Map json) { mixin _$Meta { @JsonKey(name: "current_page") int get currentPage => throw _privateConstructorUsedError; - @JsonKey(name: "from") int get from => throw _privateConstructorUsedError; - @JsonKey(name: "last_page") int get lastPage => throw _privateConstructorUsedError; - @JsonKey(name: "links") List get links => throw _privateConstructorUsedError; - @JsonKey(name: "path") String get path => throw _privateConstructorUsedError; - @JsonKey(name: "per_page") int get perPage => throw _privateConstructorUsedError; - @JsonKey(name: "to") int get to => throw _privateConstructorUsedError; - @JsonKey(name: "total") int get total => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $MetaCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class $MetaCopyWith<$Res> { - factory $MetaCopyWith(Meta value, $Res Function(Meta) then) = _$MetaCopyWithImpl<$Res, Meta>; - + factory $MetaCopyWith(Meta value, $Res Function(Meta) then) = + _$MetaCopyWithImpl<$Res, Meta>; @useResult $Res call( {@JsonKey(name: "current_page") int currentPage, @@ -1534,12 +1577,12 @@ abstract class $MetaCopyWith<$Res> { } /// @nodoc -class _$MetaCopyWithImpl<$Res, $Val extends Meta> implements $MetaCopyWith<$Res> { +class _$MetaCopyWithImpl<$Res, $Val extends Meta> + implements $MetaCopyWith<$Res> { _$MetaCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -1594,8 +1637,9 @@ class _$MetaCopyWithImpl<$Res, $Val extends Meta> implements $MetaCopyWith<$Res> /// @nodoc abstract class _$$MetaImplCopyWith<$Res> implements $MetaCopyWith<$Res> { - factory _$$MetaImplCopyWith(_$MetaImpl value, $Res Function(_$MetaImpl) then) = __$$MetaImplCopyWithImpl<$Res>; - + factory _$$MetaImplCopyWith( + _$MetaImpl value, $Res Function(_$MetaImpl) then) = + __$$MetaImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -1610,8 +1654,11 @@ abstract class _$$MetaImplCopyWith<$Res> implements $MetaCopyWith<$Res> { } /// @nodoc -class __$$MetaImplCopyWithImpl<$Res> extends _$MetaCopyWithImpl<$Res, _$MetaImpl> implements _$$MetaImplCopyWith<$Res> { - __$$MetaImplCopyWithImpl(_$MetaImpl _value, $Res Function(_$MetaImpl) _then) : super(_value, _then); +class __$$MetaImplCopyWithImpl<$Res> + extends _$MetaCopyWithImpl<$Res, _$MetaImpl> + implements _$$MetaImplCopyWith<$Res> { + __$$MetaImplCopyWithImpl(_$MetaImpl _value, $Res Function(_$MetaImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -1676,7 +1723,8 @@ class _$MetaImpl implements _Meta { @JsonKey(name: "total") required this.total}) : _links = links; - factory _$MetaImpl.fromJson(Map json) => _$$MetaImplFromJson(json); + factory _$MetaImpl.fromJson(Map json) => + _$$MetaImplFromJson(json); @override @JsonKey(name: "current_page") @@ -1688,7 +1736,6 @@ class _$MetaImpl implements _Meta { @JsonKey(name: "last_page") final int lastPage; final List _links; - @override @JsonKey(name: "links") List get links { @@ -1720,9 +1767,11 @@ class _$MetaImpl implements _Meta { return identical(this, other) || (other.runtimeType == runtimeType && other is _$MetaImpl && - (identical(other.currentPage, currentPage) || other.currentPage == currentPage) && + (identical(other.currentPage, currentPage) || + other.currentPage == currentPage) && (identical(other.from, from) || other.from == from) && - (identical(other.lastPage, lastPage) || other.lastPage == lastPage) && + (identical(other.lastPage, lastPage) || + other.lastPage == lastPage) && const DeepCollectionEquality().equals(other._links, _links) && (identical(other.path, path) || other.path == path) && (identical(other.perPage, perPage) || other.perPage == perPage) && @@ -1732,12 +1781,14 @@ class _$MetaImpl implements _Meta { @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, currentPage, from, lastPage, const DeepCollectionEquality().hash(_links), path, perPage, to, total); + int get hashCode => Object.hash(runtimeType, currentPage, from, lastPage, + const DeepCollectionEquality().hash(_links), path, perPage, to, total); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$MetaImplCopyWith<_$MetaImpl> get copyWith => __$$MetaImplCopyWithImpl<_$MetaImpl>(this, _$identity); + _$$MetaImplCopyWith<_$MetaImpl> get copyWith => + __$$MetaImplCopyWithImpl<_$MetaImpl>(this, _$identity); @override Map toJson() { @@ -1763,38 +1814,31 @@ abstract class _Meta implements Meta { @override @JsonKey(name: "current_page") int get currentPage; - @override @JsonKey(name: "from") int get from; - @override @JsonKey(name: "last_page") int get lastPage; - @override @JsonKey(name: "links") List get links; - @override @JsonKey(name: "path") String get path; - @override @JsonKey(name: "per_page") int get perPage; - @override @JsonKey(name: "to") int get to; - @override @JsonKey(name: "total") int get total; - @override @JsonKey(ignore: true) - _$$MetaImplCopyWith<_$MetaImpl> get copyWith => throw _privateConstructorUsedError; + _$$MetaImplCopyWith<_$MetaImpl> get copyWith => + throw _privateConstructorUsedError; } Link _$LinkFromJson(Map json) { @@ -1805,34 +1849,34 @@ Link _$LinkFromJson(Map json) { mixin _$Link { @JsonKey(name: "url") String? get url => throw _privateConstructorUsedError; - @JsonKey(name: "label") String get label => throw _privateConstructorUsedError; - @JsonKey(name: "active") bool get active => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) $LinkCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc abstract class $LinkCopyWith<$Res> { - factory $LinkCopyWith(Link value, $Res Function(Link) then) = _$LinkCopyWithImpl<$Res, Link>; - + factory $LinkCopyWith(Link value, $Res Function(Link) then) = + _$LinkCopyWithImpl<$Res, Link>; @useResult - $Res call({@JsonKey(name: "url") String? url, @JsonKey(name: "label") String label, @JsonKey(name: "active") bool active}); + $Res call( + {@JsonKey(name: "url") String? url, + @JsonKey(name: "label") String label, + @JsonKey(name: "active") bool active}); } /// @nodoc -class _$LinkCopyWithImpl<$Res, $Val extends Link> implements $LinkCopyWith<$Res> { +class _$LinkCopyWithImpl<$Res, $Val extends Link> + implements $LinkCopyWith<$Res> { _$LinkCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; @@ -1862,16 +1906,23 @@ class _$LinkCopyWithImpl<$Res, $Val extends Link> implements $LinkCopyWith<$Res> /// @nodoc abstract class _$$LinkImplCopyWith<$Res> implements $LinkCopyWith<$Res> { - factory _$$LinkImplCopyWith(_$LinkImpl value, $Res Function(_$LinkImpl) then) = __$$LinkImplCopyWithImpl<$Res>; - + factory _$$LinkImplCopyWith( + _$LinkImpl value, $Res Function(_$LinkImpl) then) = + __$$LinkImplCopyWithImpl<$Res>; @override @useResult - $Res call({@JsonKey(name: "url") String? url, @JsonKey(name: "label") String label, @JsonKey(name: "active") bool active}); + $Res call( + {@JsonKey(name: "url") String? url, + @JsonKey(name: "label") String label, + @JsonKey(name: "active") bool active}); } /// @nodoc -class __$$LinkImplCopyWithImpl<$Res> extends _$LinkCopyWithImpl<$Res, _$LinkImpl> implements _$$LinkImplCopyWith<$Res> { - __$$LinkImplCopyWithImpl(_$LinkImpl _value, $Res Function(_$LinkImpl) _then) : super(_value, _then); +class __$$LinkImplCopyWithImpl<$Res> + extends _$LinkCopyWithImpl<$Res, _$LinkImpl> + implements _$$LinkImplCopyWith<$Res> { + __$$LinkImplCopyWithImpl(_$LinkImpl _value, $Res Function(_$LinkImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -1900,9 +1951,13 @@ class __$$LinkImplCopyWithImpl<$Res> extends _$LinkCopyWithImpl<$Res, _$LinkImpl /// @nodoc @JsonSerializable() class _$LinkImpl implements _Link { - const _$LinkImpl({@JsonKey(name: "url") required this.url, @JsonKey(name: "label") required this.label, @JsonKey(name: "active") required this.active}); + const _$LinkImpl( + {@JsonKey(name: "url") required this.url, + @JsonKey(name: "label") required this.label, + @JsonKey(name: "active") required this.active}); - factory _$LinkImpl.fromJson(Map json) => _$$LinkImplFromJson(json); + factory _$LinkImpl.fromJson(Map json) => + _$$LinkImplFromJson(json); @override @JsonKey(name: "url") @@ -1936,7 +1991,8 @@ class _$LinkImpl implements _Link { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$LinkImplCopyWith<_$LinkImpl> get copyWith => __$$LinkImplCopyWithImpl<_$LinkImpl>(this, _$identity); + _$$LinkImplCopyWith<_$LinkImpl> get copyWith => + __$$LinkImplCopyWithImpl<_$LinkImpl>(this, _$identity); @override Map toJson() { @@ -1957,16 +2013,14 @@ abstract class _Link implements Link { @override @JsonKey(name: "url") String? get url; - @override @JsonKey(name: "label") String get label; - @override @JsonKey(name: "active") bool get active; - @override @JsonKey(ignore: true) - _$$LinkImplCopyWith<_$LinkImpl> get copyWith => throw _privateConstructorUsedError; + _$$LinkImplCopyWith<_$LinkImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/feed/models/diets_pagination_model.g.dart b/lib/features/feed/models/diets_pagination_model.g.dart index ac11372f..0a745095 100644 --- a/lib/features/feed/models/diets_pagination_model.g.dart +++ b/lib/features/feed/models/diets_pagination_model.g.dart @@ -6,13 +6,19 @@ part of 'diets_pagination_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$DietsPaginationImpl _$$DietsPaginationImplFromJson(Map json) => _$DietsPaginationImpl( - data: (json['data'] as List).map((e) => Datum.fromJson(e as Map)).toList(), +_$DietsPaginationImpl _$$DietsPaginationImplFromJson( + Map json) => + _$DietsPaginationImpl( + data: (json['data'] as List) + .map((e) => Datum.fromJson(e as Map)) + .toList(), links: Links.fromJson(json['links'] as Map), meta: Meta.fromJson(json['meta'] as Map), ); -Map _$$DietsPaginationImplToJson(_$DietsPaginationImpl instance) => { +Map _$$DietsPaginationImplToJson( + _$DietsPaginationImpl instance) => + { 'data': instance.data, 'links': instance.links, 'meta': instance.meta, @@ -27,7 +33,11 @@ _$DatumImpl _$$DatumImplFromJson(Map json) => _$DatumImpl( type: Type.fromJson(json['type'] as Map), details: json['details'] as String, dailySchedule: (json['daily_schedule'] as List) - .map((e) => (e as List).map((e) => (e as List).map((e) => DailySchedule.fromJson(e as Map)).toList()).toList()) + .map((e) => (e as List) + .map((e) => (e as List) + .map((e) => DailySchedule.fromJson(e as Map)) + .toList()) + .toList()) .toList(), author: Author.fromJson(json['author'] as Map), totalLikes: (json['total_likes'] as num).toInt(), @@ -35,7 +45,8 @@ _$DatumImpl _$$DatumImplFromJson(Map json) => _$DatumImpl( totalComments: (json['total_comments'] as num).toInt(), ); -Map _$$DatumImplToJson(_$DatumImpl instance) => { +Map _$$DatumImplToJson(_$DatumImpl instance) => + { 'id': instance.id, 'name': instance.name, 'image': instance.image, @@ -57,21 +68,24 @@ _$AuthorImpl _$$AuthorImplFromJson(Map json) => _$AuthorImpl( authorIsMe: json['author_is_me'] as bool, ); -Map _$$AuthorImplToJson(_$AuthorImpl instance) => { +Map _$$AuthorImplToJson(_$AuthorImpl instance) => + { 'author_slug': instance.authorSlug, 'author_name': instance.authorName, 'author_profile_icon': instance.authorProfileIcon, 'author_is_me': instance.authorIsMe, }; -_$DailyScheduleImpl _$$DailyScheduleImplFromJson(Map json) => _$DailyScheduleImpl( +_$DailyScheduleImpl _$$DailyScheduleImplFromJson(Map json) => + _$DailyScheduleImpl( name: json['name'] as String, uniq: json['uniq'] as String, portion: $enumDecode(_$PortionEnumMap, json['portion']), quantity: (json['quantity'] as num).toInt(), ); -Map _$$DailyScheduleImplToJson(_$DailyScheduleImpl instance) => { +Map _$$DailyScheduleImplToJson(_$DailyScheduleImpl instance) => + { 'name': instance.name, 'uniq': instance.uniq, 'portion': _$PortionEnumMap[instance.portion]!, @@ -91,7 +105,8 @@ _$TypeImpl _$$TypeImplFromJson(Map json) => _$TypeImpl( meat: json['meat'] as bool?, ); -Map _$$TypeImplToJson(_$TypeImpl instance) => { +Map _$$TypeImplToJson(_$TypeImpl instance) => + { 'alko': instance.alko, 'veg': instance.veg, 'corb': instance.corb, @@ -105,7 +120,8 @@ _$LinksImpl _$$LinksImplFromJson(Map json) => _$LinksImpl( next: json['next'], ); -Map _$$LinksImplToJson(_$LinksImpl instance) => { +Map _$$LinksImplToJson(_$LinksImpl instance) => + { 'first': instance.first, 'last': instance.last, 'prev': instance.prev, @@ -116,14 +132,17 @@ _$MetaImpl _$$MetaImplFromJson(Map json) => _$MetaImpl( currentPage: (json['current_page'] as num).toInt(), from: (json['from'] as num).toInt(), lastPage: (json['last_page'] as num).toInt(), - links: (json['links'] as List).map((e) => Link.fromJson(e as Map)).toList(), + links: (json['links'] as List) + .map((e) => Link.fromJson(e as Map)) + .toList(), path: json['path'] as String, perPage: (json['per_page'] as num).toInt(), to: (json['to'] as num).toInt(), total: (json['total'] as num).toInt(), ); -Map _$$MetaImplToJson(_$MetaImpl instance) => { +Map _$$MetaImplToJson(_$MetaImpl instance) => + { 'current_page': instance.currentPage, 'from': instance.from, 'last_page': instance.lastPage, @@ -140,7 +159,8 @@ _$LinkImpl _$$LinkImplFromJson(Map json) => _$LinkImpl( active: json['active'] as bool, ); -Map _$$LinkImplToJson(_$LinkImpl instance) => { +Map _$$LinkImplToJson(_$LinkImpl instance) => + { 'url': instance.url, 'label': instance.label, 'active': instance.active, diff --git a/lib/features/feed/models/feed_blog_post_settings_model.dart b/lib/features/feed/models/feed_blog_post_settings_model.dart index 8296a8be..66e0ecf3 100644 --- a/lib/features/feed/models/feed_blog_post_settings_model.dart +++ b/lib/features/feed/models/feed_blog_post_settings_model.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; @@ -8,6 +9,7 @@ part 'feed_blog_post_settings_model.g.dart'; class FeedBlogPostSettingsModel with _$FeedBlogPostSettingsModel { const factory FeedBlogPostSettingsModel({ @JsonKey(name: 'data') required List feedBlogPostList, + required Meta meta, }) = _FeedBlogPostSettingsModel; factory FeedBlogPostSettingsModel.fromJson(Map json) => _$FeedBlogPostSettingsModelFromJson(json); diff --git a/lib/features/feed/models/feed_blog_post_settings_model.freezed.dart b/lib/features/feed/models/feed_blog_post_settings_model.freezed.dart index 7fd8a12e..c680d82e 100644 --- a/lib/features/feed/models/feed_blog_post_settings_model.freezed.dart +++ b/lib/features/feed/models/feed_blog_post_settings_model.freezed.dart @@ -24,6 +24,7 @@ mixin _$FeedBlogPostSettingsModel { @JsonKey(name: 'data') List get feedBlogPostList => throw _privateConstructorUsedError; + Meta get meta => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -37,7 +38,11 @@ abstract class $FeedBlogPostSettingsModelCopyWith<$Res> { $Res Function(FeedBlogPostSettingsModel) then) = _$FeedBlogPostSettingsModelCopyWithImpl<$Res, FeedBlogPostSettingsModel>; @useResult - $Res call({@JsonKey(name: 'data') List feedBlogPostList}); + $Res call( + {@JsonKey(name: 'data') List feedBlogPostList, + Meta meta}); + + $MetaCopyWith<$Res> get meta; } /// @nodoc @@ -55,14 +60,27 @@ class _$FeedBlogPostSettingsModelCopyWithImpl<$Res, @override $Res call({ Object? feedBlogPostList = null, + Object? meta = null, }) { return _then(_value.copyWith( feedBlogPostList: null == feedBlogPostList ? _value.feedBlogPostList : feedBlogPostList // ignore: cast_nullable_to_non_nullable as List, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, ) as $Val); } + + @override + @pragma('vm:prefer-inline') + $MetaCopyWith<$Res> get meta { + return $MetaCopyWith<$Res>(_value.meta, (value) { + return _then(_value.copyWith(meta: value) as $Val); + }); + } } /// @nodoc @@ -74,7 +92,12 @@ abstract class _$$FeedBlogPostSettingsModelImplCopyWith<$Res> __$$FeedBlogPostSettingsModelImplCopyWithImpl<$Res>; @override @useResult - $Res call({@JsonKey(name: 'data') List feedBlogPostList}); + $Res call( + {@JsonKey(name: 'data') List feedBlogPostList, + Meta meta}); + + @override + $MetaCopyWith<$Res> get meta; } /// @nodoc @@ -91,12 +114,17 @@ class __$$FeedBlogPostSettingsModelImplCopyWithImpl<$Res> @override $Res call({ Object? feedBlogPostList = null, + Object? meta = null, }) { return _then(_$FeedBlogPostSettingsModelImpl( feedBlogPostList: null == feedBlogPostList ? _value._feedBlogPostList : feedBlogPostList // ignore: cast_nullable_to_non_nullable as List, + meta: null == meta + ? _value.meta + : meta // ignore: cast_nullable_to_non_nullable + as Meta, )); } } @@ -106,7 +134,8 @@ class __$$FeedBlogPostSettingsModelImplCopyWithImpl<$Res> class _$FeedBlogPostSettingsModelImpl implements _FeedBlogPostSettingsModel { const _$FeedBlogPostSettingsModelImpl( {@JsonKey(name: 'data') - required final List feedBlogPostList}) + required final List feedBlogPostList, + required this.meta}) : _feedBlogPostList = feedBlogPostList; factory _$FeedBlogPostSettingsModelImpl.fromJson(Map json) => @@ -122,9 +151,12 @@ class _$FeedBlogPostSettingsModelImpl implements _FeedBlogPostSettingsModel { return EqualUnmodifiableListView(_feedBlogPostList); } + @override + final Meta meta; + @override String toString() { - return 'FeedBlogPostSettingsModel(feedBlogPostList: $feedBlogPostList)'; + return 'FeedBlogPostSettingsModel(feedBlogPostList: $feedBlogPostList, meta: $meta)'; } @override @@ -133,13 +165,14 @@ class _$FeedBlogPostSettingsModelImpl implements _FeedBlogPostSettingsModel { (other.runtimeType == runtimeType && other is _$FeedBlogPostSettingsModelImpl && const DeepCollectionEquality() - .equals(other._feedBlogPostList, _feedBlogPostList)); + .equals(other._feedBlogPostList, _feedBlogPostList) && + (identical(other.meta, meta) || other.meta == meta)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, const DeepCollectionEquality().hash(_feedBlogPostList)); + int get hashCode => Object.hash(runtimeType, + const DeepCollectionEquality().hash(_feedBlogPostList), meta); @JsonKey(ignore: true) @override @@ -158,9 +191,9 @@ class _$FeedBlogPostSettingsModelImpl implements _FeedBlogPostSettingsModel { abstract class _FeedBlogPostSettingsModel implements FeedBlogPostSettingsModel { const factory _FeedBlogPostSettingsModel( - {@JsonKey(name: 'data') - required final List feedBlogPostList}) = - _$FeedBlogPostSettingsModelImpl; + {@JsonKey(name: 'data') + required final List feedBlogPostList, + required final Meta meta}) = _$FeedBlogPostSettingsModelImpl; factory _FeedBlogPostSettingsModel.fromJson(Map json) = _$FeedBlogPostSettingsModelImpl.fromJson; @@ -169,6 +202,8 @@ abstract class _FeedBlogPostSettingsModel implements FeedBlogPostSettingsModel { @JsonKey(name: 'data') List get feedBlogPostList; @override + Meta get meta; + @override @JsonKey(ignore: true) _$$FeedBlogPostSettingsModelImplCopyWith<_$FeedBlogPostSettingsModelImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/features/feed/models/feed_blog_post_settings_model.g.dart b/lib/features/feed/models/feed_blog_post_settings_model.g.dart index 3f48be1b..e300b594 100644 --- a/lib/features/feed/models/feed_blog_post_settings_model.g.dart +++ b/lib/features/feed/models/feed_blog_post_settings_model.g.dart @@ -12,10 +12,12 @@ _$FeedBlogPostSettingsModelImpl _$$FeedBlogPostSettingsModelImplFromJson( feedBlogPostList: (json['data'] as List) .map((e) => FeedBlogPostModel.fromJson(e as Map)) .toList(), + meta: Meta.fromJson(json['meta'] as Map), ); Map _$$FeedBlogPostSettingsModelImplToJson( _$FeedBlogPostSettingsModelImpl instance) => { 'data': instance.feedBlogPostList, + 'meta': instance.meta, }; diff --git a/lib/features/feed/presentation/bloc/diets_cubit/diets_state.freezed.dart b/lib/features/feed/presentation/bloc/diets_cubit/diets_state.freezed.dart index 84dc0117..adff30f5 100644 --- a/lib/features/feed/presentation/bloc/diets_cubit/diets_state.freezed.dart +++ b/lib/features/feed/presentation/bloc/diets_cubit/diets_state.freezed.dart @@ -24,7 +24,6 @@ mixin _$DietsState { required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; - @optionalTypeArgs TResult? whenOrNull( TResult? Function()? $default, { @@ -71,28 +70,36 @@ mixin _$DietsState { /// @nodoc abstract class $DietsStateCopyWith<$Res> { - factory $DietsStateCopyWith(DietsState value, $Res Function(DietsState) then) = _$DietsStateCopyWithImpl<$Res, DietsState>; + factory $DietsStateCopyWith( + DietsState value, $Res Function(DietsState) then) = + _$DietsStateCopyWithImpl<$Res, DietsState>; } /// @nodoc -class _$DietsStateCopyWithImpl<$Res, $Val extends DietsState> implements $DietsStateCopyWith<$Res> { +class _$DietsStateCopyWithImpl<$Res, $Val extends DietsState> + implements $DietsStateCopyWith<$Res> { _$DietsStateCopyWithImpl(this._value, this._then); // ignore: unused_field final $Val _value; - // ignore: unused_field final $Res Function($Val) _then; } /// @nodoc abstract class _$$DietsStateImplCopyWith<$Res> { - factory _$$DietsStateImplCopyWith(_$DietsStateImpl value, $Res Function(_$DietsStateImpl) then) = __$$DietsStateImplCopyWithImpl<$Res>; + factory _$$DietsStateImplCopyWith( + _$DietsStateImpl value, $Res Function(_$DietsStateImpl) then) = + __$$DietsStateImplCopyWithImpl<$Res>; } /// @nodoc -class __$$DietsStateImplCopyWithImpl<$Res> extends _$DietsStateCopyWithImpl<$Res, _$DietsStateImpl> implements _$$DietsStateImplCopyWith<$Res> { - __$$DietsStateImplCopyWithImpl(_$DietsStateImpl _value, $Res Function(_$DietsStateImpl) _then) : super(_value, _then); +class __$$DietsStateImplCopyWithImpl<$Res> + extends _$DietsStateCopyWithImpl<$Res, _$DietsStateImpl> + implements _$$DietsStateImplCopyWith<$Res> { + __$$DietsStateImplCopyWithImpl( + _$DietsStateImpl _value, $Res Function(_$DietsStateImpl) _then) + : super(_value, _then); } /// @nodoc @@ -107,7 +114,8 @@ class _$DietsStateImpl implements _DietsState { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$DietsStateImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$DietsStateImpl); } @override @@ -194,14 +202,18 @@ abstract class _DietsState implements DietsState { /// @nodoc abstract class _$$DietsStateLoadingImplCopyWith<$Res> { - factory _$$DietsStateLoadingImplCopyWith(_$DietsStateLoadingImpl value, $Res Function(_$DietsStateLoadingImpl) then) = + factory _$$DietsStateLoadingImplCopyWith(_$DietsStateLoadingImpl value, + $Res Function(_$DietsStateLoadingImpl) then) = __$$DietsStateLoadingImplCopyWithImpl<$Res>; } /// @nodoc -class __$$DietsStateLoadingImplCopyWithImpl<$Res> extends _$DietsStateCopyWithImpl<$Res, _$DietsStateLoadingImpl> +class __$$DietsStateLoadingImplCopyWithImpl<$Res> + extends _$DietsStateCopyWithImpl<$Res, _$DietsStateLoadingImpl> implements _$$DietsStateLoadingImplCopyWith<$Res> { - __$$DietsStateLoadingImplCopyWithImpl(_$DietsStateLoadingImpl _value, $Res Function(_$DietsStateLoadingImpl) _then) : super(_value, _then); + __$$DietsStateLoadingImplCopyWithImpl(_$DietsStateLoadingImpl _value, + $Res Function(_$DietsStateLoadingImpl) _then) + : super(_value, _then); } /// @nodoc @@ -216,7 +228,8 @@ class _$DietsStateLoadingImpl implements DietsStateLoading { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType && other is _$DietsStateLoadingImpl); + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$DietsStateLoadingImpl); } @override @@ -303,9 +316,9 @@ abstract class DietsStateLoading implements DietsState { /// @nodoc abstract class _$$DietsStateLoadedImplCopyWith<$Res> { - factory _$$DietsStateLoadedImplCopyWith(_$DietsStateLoadedImpl value, $Res Function(_$DietsStateLoadedImpl) then) = + factory _$$DietsStateLoadedImplCopyWith(_$DietsStateLoadedImpl value, + $Res Function(_$DietsStateLoadedImpl) then) = __$$DietsStateLoadedImplCopyWithImpl<$Res>; - @useResult $Res call({DietsPagination diets}); @@ -313,9 +326,12 @@ abstract class _$$DietsStateLoadedImplCopyWith<$Res> { } /// @nodoc -class __$$DietsStateLoadedImplCopyWithImpl<$Res> extends _$DietsStateCopyWithImpl<$Res, _$DietsStateLoadedImpl> +class __$$DietsStateLoadedImplCopyWithImpl<$Res> + extends _$DietsStateCopyWithImpl<$Res, _$DietsStateLoadedImpl> implements _$$DietsStateLoadedImplCopyWith<$Res> { - __$$DietsStateLoadedImplCopyWithImpl(_$DietsStateLoadedImpl _value, $Res Function(_$DietsStateLoadedImpl) _then) : super(_value, _then); + __$$DietsStateLoadedImplCopyWithImpl(_$DietsStateLoadedImpl _value, + $Res Function(_$DietsStateLoadedImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -355,7 +371,9 @@ class _$DietsStateLoadedImpl implements DietsStateLoaded { @override bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$DietsStateLoadedImpl && (identical(other.diets, diets) || other.diets == diets)); + (other.runtimeType == runtimeType && + other is _$DietsStateLoadedImpl && + (identical(other.diets, diets) || other.diets == diets)); } @override @@ -364,7 +382,9 @@ class _$DietsStateLoadedImpl implements DietsStateLoaded { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith => __$$DietsStateLoadedImplCopyWithImpl<_$DietsStateLoadedImpl>(this, _$identity); + _$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith => + __$$DietsStateLoadedImplCopyWithImpl<_$DietsStateLoadedImpl>( + this, _$identity); @override @optionalTypeArgs @@ -442,25 +462,31 @@ class _$DietsStateLoadedImpl implements DietsStateLoaded { } abstract class DietsStateLoaded implements DietsState { - const factory DietsStateLoaded({required final DietsPagination diets}) = _$DietsStateLoadedImpl; + const factory DietsStateLoaded({required final DietsPagination diets}) = + _$DietsStateLoadedImpl; DietsPagination get diets; - @JsonKey(ignore: true) - _$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; + _$$DietsStateLoadedImplCopyWith<_$DietsStateLoadedImpl> get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class _$$DietsStateErrorImplCopyWith<$Res> { - factory _$$DietsStateErrorImplCopyWith(_$DietsStateErrorImpl value, $Res Function(_$DietsStateErrorImpl) then) = __$$DietsStateErrorImplCopyWithImpl<$Res>; - + factory _$$DietsStateErrorImplCopyWith(_$DietsStateErrorImpl value, + $Res Function(_$DietsStateErrorImpl) then) = + __$$DietsStateErrorImplCopyWithImpl<$Res>; @useResult $Res call({String errorMessage}); } /// @nodoc -class __$$DietsStateErrorImplCopyWithImpl<$Res> extends _$DietsStateCopyWithImpl<$Res, _$DietsStateErrorImpl> implements _$$DietsStateErrorImplCopyWith<$Res> { - __$$DietsStateErrorImplCopyWithImpl(_$DietsStateErrorImpl _value, $Res Function(_$DietsStateErrorImpl) _then) : super(_value, _then); +class __$$DietsStateErrorImplCopyWithImpl<$Res> + extends _$DietsStateCopyWithImpl<$Res, _$DietsStateErrorImpl> + implements _$$DietsStateErrorImplCopyWith<$Res> { + __$$DietsStateErrorImplCopyWithImpl( + _$DietsStateErrorImpl _value, $Res Function(_$DietsStateErrorImpl) _then) + : super(_value, _then); @pragma('vm:prefer-inline') @override @@ -494,7 +520,8 @@ class _$DietsStateErrorImpl implements DietsStateError { return identical(this, other) || (other.runtimeType == runtimeType && other is _$DietsStateErrorImpl && - (identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); } @override @@ -503,7 +530,9 @@ class _$DietsStateErrorImpl implements DietsStateError { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith => __$$DietsStateErrorImplCopyWithImpl<_$DietsStateErrorImpl>(this, _$identity); + _$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith => + __$$DietsStateErrorImplCopyWithImpl<_$DietsStateErrorImpl>( + this, _$identity); @override @optionalTypeArgs @@ -581,10 +610,11 @@ class _$DietsStateErrorImpl implements DietsStateError { } abstract class DietsStateError implements DietsState { - const factory DietsStateError({required final String errorMessage}) = _$DietsStateErrorImpl; + const factory DietsStateError({required final String errorMessage}) = + _$DietsStateErrorImpl; String get errorMessage; - @JsonKey(ignore: true) - _$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith => throw _privateConstructorUsedError; + _$$DietsStateErrorImplCopyWith<_$DietsStateErrorImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart index c052c26b..904282c5 100644 --- a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart +++ b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart @@ -4,15 +4,47 @@ import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; class FeedCubit extends Cubit { final FeedRepository feedRepository; + int currentPage = 1; + final int lastPage = 7; + bool isLoading = false; FeedCubit({required this.feedRepository}) : super(const FeedState.loading()); loadFeedBlogPostList() async { try { - final feedBlogPostList = await feedRepository.getFeedBlogPostList(); - emit(FeedState.loaded(feedBlogPostList: feedBlogPostList)); + final feedBlogPosts = await feedRepository.getFeedBlogPosts(); + emit( + FeedState.loaded( + feedBlogPostList: feedBlogPosts.feedBlogPostList, + isLoading: false, + ), + ); } catch (e) { emit(FeedState.error(errorMessage: e.toString())); } } + + loadNextPage() async { + print('start'); + try { + if (lastPage < currentPage) { + currentPage++; + final feedBlogPosts = await feedRepository.getFeedBlogPosts(page: currentPage); + emit( + FeedState.loaded( + feedBlogPostList: [ + ...(state as FeedStateLoaded).feedBlogPostList, + ...feedBlogPosts.feedBlogPostList, + ], + isLoading: false, + ), + ); + } + } catch (e) { + print('error bro'); + print(e.toString()); + } finally { + print('end'); + } + } } diff --git a/lib/features/feed/presentation/bloc/feed_cubit/feed_state.dart b/lib/features/feed/presentation/bloc/feed_cubit/feed_state.dart index 70e8c3b7..09837dfb 100644 --- a/lib/features/feed/presentation/bloc/feed_cubit/feed_state.dart +++ b/lib/features/feed/presentation/bloc/feed_cubit/feed_state.dart @@ -11,6 +11,7 @@ abstract class FeedState with _$FeedState { const factory FeedState.loaded({ required List feedBlogPostList, + required bool isLoading, }) = FeedStateLoaded; const factory FeedState.error({ diff --git a/lib/features/feed/presentation/bloc/feed_cubit/feed_state.freezed.dart b/lib/features/feed/presentation/bloc/feed_cubit/feed_state.freezed.dart index ab3385f3..779dcdb5 100644 --- a/lib/features/feed/presentation/bloc/feed_cubit/feed_state.freezed.dart +++ b/lib/features/feed/presentation/bloc/feed_cubit/feed_state.freezed.dart @@ -20,7 +20,9 @@ mixin _$FeedState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List feedBlogPostList) loaded, + required TResult Function( + List feedBlogPostList, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) => throw _privateConstructorUsedError; @@ -28,7 +30,8 @@ mixin _$FeedState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List feedBlogPostList)? loaded, + TResult? Function(List feedBlogPostList, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) => throw _privateConstructorUsedError; @@ -36,7 +39,8 @@ mixin _$FeedState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List feedBlogPostList)? loaded, + TResult Function(List feedBlogPostList, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) => @@ -125,7 +129,9 @@ class _$FeedStateImpl implements _FeedState { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List feedBlogPostList) loaded, + required TResult Function( + List feedBlogPostList, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return $default(); @@ -136,7 +142,8 @@ class _$FeedStateImpl implements _FeedState { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List feedBlogPostList)? loaded, + TResult? Function(List feedBlogPostList, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return $default?.call(); @@ -147,7 +154,8 @@ class _$FeedStateImpl implements _FeedState { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List feedBlogPostList)? loaded, + TResult Function(List feedBlogPostList, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -239,7 +247,9 @@ class _$FeedStateLoadingImpl implements FeedStateLoading { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List feedBlogPostList) loaded, + required TResult Function( + List feedBlogPostList, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return loading(); @@ -250,7 +260,8 @@ class _$FeedStateLoadingImpl implements FeedStateLoading { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List feedBlogPostList)? loaded, + TResult? Function(List feedBlogPostList, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return loading?.call(); @@ -261,7 +272,8 @@ class _$FeedStateLoadingImpl implements FeedStateLoading { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List feedBlogPostList)? loaded, + TResult Function(List feedBlogPostList, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { @@ -319,7 +331,7 @@ abstract class _$$FeedStateLoadedImplCopyWith<$Res> { $Res Function(_$FeedStateLoadedImpl) then) = __$$FeedStateLoadedImplCopyWithImpl<$Res>; @useResult - $Res call({List feedBlogPostList}); + $Res call({List feedBlogPostList, bool isLoading}); } /// @nodoc @@ -334,12 +346,17 @@ class __$$FeedStateLoadedImplCopyWithImpl<$Res> @override $Res call({ Object? feedBlogPostList = null, + Object? isLoading = null, }) { return _then(_$FeedStateLoadedImpl( feedBlogPostList: null == feedBlogPostList ? _value._feedBlogPostList : feedBlogPostList // ignore: cast_nullable_to_non_nullable as List, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, )); } } @@ -348,7 +365,8 @@ class __$$FeedStateLoadedImplCopyWithImpl<$Res> class _$FeedStateLoadedImpl implements FeedStateLoaded { const _$FeedStateLoadedImpl( - {required final List feedBlogPostList}) + {required final List feedBlogPostList, + required this.isLoading}) : _feedBlogPostList = feedBlogPostList; final List _feedBlogPostList; @@ -360,9 +378,12 @@ class _$FeedStateLoadedImpl implements FeedStateLoaded { return EqualUnmodifiableListView(_feedBlogPostList); } + @override + final bool isLoading; + @override String toString() { - return 'FeedState.loaded(feedBlogPostList: $feedBlogPostList)'; + return 'FeedState.loaded(feedBlogPostList: $feedBlogPostList, isLoading: $isLoading)'; } @override @@ -371,12 +392,14 @@ class _$FeedStateLoadedImpl implements FeedStateLoaded { (other.runtimeType == runtimeType && other is _$FeedStateLoadedImpl && const DeepCollectionEquality() - .equals(other._feedBlogPostList, _feedBlogPostList)); + .equals(other._feedBlogPostList, _feedBlogPostList) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading)); } @override - int get hashCode => Object.hash( - runtimeType, const DeepCollectionEquality().hash(_feedBlogPostList)); + int get hashCode => Object.hash(runtimeType, + const DeepCollectionEquality().hash(_feedBlogPostList), isLoading); @JsonKey(ignore: true) @override @@ -390,10 +413,12 @@ class _$FeedStateLoadedImpl implements FeedStateLoaded { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List feedBlogPostList) loaded, + required TResult Function( + List feedBlogPostList, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { - return loaded(feedBlogPostList); + return loaded(feedBlogPostList, isLoading); } @override @@ -401,10 +426,11 @@ class _$FeedStateLoadedImpl implements FeedStateLoaded { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List feedBlogPostList)? loaded, + TResult? Function(List feedBlogPostList, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { - return loaded?.call(feedBlogPostList); + return loaded?.call(feedBlogPostList, isLoading); } @override @@ -412,12 +438,13 @@ class _$FeedStateLoadedImpl implements FeedStateLoaded { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List feedBlogPostList)? loaded, + TResult Function(List feedBlogPostList, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { if (loaded != null) { - return loaded(feedBlogPostList); + return loaded(feedBlogPostList, isLoading); } return orElse(); } @@ -462,10 +489,11 @@ class _$FeedStateLoadedImpl implements FeedStateLoaded { abstract class FeedStateLoaded implements FeedState { const factory FeedStateLoaded( - {required final List feedBlogPostList}) = - _$FeedStateLoadedImpl; + {required final List feedBlogPostList, + required final bool isLoading}) = _$FeedStateLoadedImpl; List get feedBlogPostList; + bool get isLoading; @JsonKey(ignore: true) _$$FeedStateLoadedImplCopyWith<_$FeedStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; @@ -539,7 +567,9 @@ class _$FeedStateErrorImpl implements FeedStateError { TResult when( TResult Function() $default, { required TResult Function() loading, - required TResult Function(List feedBlogPostList) loaded, + required TResult Function( + List feedBlogPostList, bool isLoading) + loaded, required TResult Function(String errorMessage) error, }) { return error(errorMessage); @@ -550,7 +580,8 @@ class _$FeedStateErrorImpl implements FeedStateError { TResult? whenOrNull( TResult? Function()? $default, { TResult? Function()? loading, - TResult? Function(List feedBlogPostList)? loaded, + TResult? Function(List feedBlogPostList, bool isLoading)? + loaded, TResult? Function(String errorMessage)? error, }) { return error?.call(errorMessage); @@ -561,7 +592,8 @@ class _$FeedStateErrorImpl implements FeedStateError { TResult maybeWhen( TResult Function()? $default, { TResult Function()? loading, - TResult Function(List feedBlogPostList)? loaded, + TResult Function(List feedBlogPostList, bool isLoading)? + loaded, TResult Function(String errorMessage)? error, required TResult orElse(), }) { diff --git a/lib/features/feed/presentation/pages/feed_screen.dart b/lib/features/feed/presentation/pages/feed_screen.dart index ec949667..662c06ec 100644 --- a/lib/features/feed/presentation/pages/feed_screen.dart +++ b/lib/features/feed/presentation/pages/feed_screen.dart @@ -94,6 +94,7 @@ class _FeedScreenState extends State { ); } else if (state is DietsStateError) { return Scaffold( + backgroundColor: Colors.grey.shade200, body: Padding( padding: const EdgeInsets.all(16), child: Center( @@ -103,6 +104,7 @@ class _FeedScreenState extends State { ); } else { return Scaffold( + backgroundColor: Colors.grey.shade200, body: Center( child: CupertinoActivityIndicator(), ), @@ -133,6 +135,7 @@ class _FeedScreenState extends State { ); } else if (state is FeedStateError) { return Scaffold( + backgroundColor: Colors.grey.shade200, body: Padding( padding: const EdgeInsets.all(16), child: Center( @@ -142,6 +145,7 @@ class _FeedScreenState extends State { ); } else { return Scaffold( + backgroundColor: Colors.grey.shade200, body: Center( child: CupertinoActivityIndicator(), ), @@ -172,6 +176,7 @@ class _FeedScreenState extends State { ); } else if (state is RecipesStateError) { return Scaffold( + backgroundColor: Colors.grey.shade200, body: Padding( padding: const EdgeInsets.all(16), child: Center( @@ -181,6 +186,7 @@ class _FeedScreenState extends State { ); } else { return Scaffold( + backgroundColor: Colors.grey.shade200, body: Center( child: CupertinoActivityIndicator(), ), diff --git a/lib/features/feed/presentation/widgets/blog_post_widget.dart b/lib/features/feed/presentation/widgets/blog_post_widget.dart index 7e8e4e8f..c75e6056 100644 --- a/lib/features/feed/presentation/widgets/blog_post_widget.dart +++ b/lib/features/feed/presentation/widgets/blog_post_widget.dart @@ -4,7 +4,9 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart'; import 'package:eatvio_app/features/feed/models/feed_blog_post_model.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'; class BlogPostWidget extends StatefulWidget { final FeedBlogPostModel feedBlogPostModel; @@ -70,12 +72,15 @@ class _BlogPostWidgetState extends State { if (widget.feedBlogPostModel.title.isNotEmpty && widget.feedBlogPostModel.description.isNotEmpty) SizedBox(height: 8), Padding( padding: const EdgeInsets.symmetric(horizontal: 12), - child: Text( - widget.feedBlogPostModel.description, - style: TextStyle( - color: Colors.black87, - ), + child: Html( + data: widget.feedBlogPostModel.description, ), + // child: Text( + // widget.feedBlogPostModel.description, + // style: TextStyle( + // color: Colors.black87, + // ), + // ), ), if (widget.feedBlogPostModel.title.isNotEmpty || widget.feedBlogPostModel.description.isNotEmpty) SizedBox(height: 8), GestureDetector( @@ -92,6 +97,7 @@ class _BlogPostWidgetState extends State { tag: baseUrl + '/storage/' + widget.feedBlogPostModel.image, child: CachedNetworkImage( imageUrl: baseUrl + '/storage/' + widget.feedBlogPostModel.image, + errorWidget: (context, str, object) => SizedBox.shrink(), ), ), ), @@ -100,18 +106,25 @@ class _BlogPostWidgetState extends State { padding: const EdgeInsets.symmetric(horizontal: 12), child: Row( children: [ - _iconButton(Icons.favorite_border_rounded, widget.feedBlogPostModel.totalLikes.toString()), + _iconButton(icon: Icons.favorite_border_rounded, text: widget.feedBlogPostModel.totalLikes.toString()), SizedBox(width: 8), _iconButton( - Icons.mode_comment_outlined, - widget.feedBlogPostModel.totalComments.toString(), - () => GoRouter.of(context).pushNamed( + icon: Icons.mode_comment_outlined, + text: widget.feedBlogPostModel.totalComments.toString(), + onTap: () => GoRouter.of(context).pushNamed( 'blogPostScreen', extra: widget.feedBlogPostModel, ), ), SizedBox(width: 8), - _iconButton(Icons.reply_rounded), + _iconButton( + icon: Icons.reply_rounded, + onTap: () => Share.shareUri( + Uri.parse( + baseUrl + '/ru/blog_post/' + widget.feedBlogPostModel.id.toString(), + ), + ), + ), Spacer(), Icon( Icons.visibility_rounded, @@ -137,7 +150,7 @@ class _BlogPostWidgetState extends State { ); } - _iconButton(IconData icon, [String? text, Function()? onTap]) { + _iconButton({required IconData icon, String? text, Function()? onTap}) { return InkWell( onTap: onTap ?? () {}, borderRadius: BorderRadius.circular(16), diff --git a/lib/features/feed/repositories/feed_repository.dart b/lib/features/feed/repositories/feed_repository.dart index 0d2476ff..b217759d 100644 --- a/lib/features/feed/repositories/feed_repository.dart +++ b/lib/features/feed/repositories/feed_repository.dart @@ -1,5 +1,5 @@ import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; -import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; +import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart'; import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:eatvio_app/features/feed/services/feed_service.dart'; @@ -8,9 +8,9 @@ class FeedRepository { FeedRepository({required this.feedService}); - Future> getFeedBlogPostList() async { + Future getFeedBlogPosts({int page = 1}) async { try { - return (await feedService.getBlocPostList()).feedBlogPostList; + return (await feedService.getBlocPostList(page: page)); } catch (e) { rethrow; } diff --git a/lib/features/feed/services/feed_service.dart b/lib/features/feed/services/feed_service.dart index 0d848a56..3fbb2dce 100644 --- a/lib/features/feed/services/feed_service.dart +++ b/lib/features/feed/services/feed_service.dart @@ -10,8 +10,10 @@ part 'feed_service.g.dart'; abstract class FeedService { factory FeedService(Dio dio, {String baseUrl}) = _FeedService; - @GET('/api/blogPosts/index') - Future getBlocPostList(); + @GET('/api/blogPosts/index?page={page}') + Future getBlocPostList({ + @Path() required int page, + }); @GET('/api/recipes/index') Future getRecipes(); diff --git a/lib/features/feed/services/feed_service.g.dart b/lib/features/feed/services/feed_service.g.dart index 77b65773..36b29923 100644 --- a/lib/features/feed/services/feed_service.g.dart +++ b/lib/features/feed/services/feed_service.g.dart @@ -12,36 +12,45 @@ class _FeedService implements FeedService { _FeedService( this._dio, { this.baseUrl, + this.errorLogger, }); final Dio _dio; String? baseUrl; + final ParseErrorLogger? errorLogger; + @override - Future getBlocPostList() async { + Future getBlocPostList({required int page}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/blogPosts/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = FeedBlogPostSettingsModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/blogPosts/index?page=${page}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late FeedBlogPostSettingsModel _value; + try { + _value = FeedBlogPostSettingsModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -51,24 +60,30 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/recipes/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = RecipesPagination.fromJson(_result.data!); + .compose( + _dio.options, + '/api/recipes/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late RecipesPagination _value; + try { + _value = RecipesPagination.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -78,24 +93,30 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diets/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = DietsPagination.fromJson(_result.data!); + .compose( + _dio.options, + '/api/diets/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late DietsPagination _value; + try { + _value = DietsPagination.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/features/profile/services/profile_service.g.dart b/lib/features/profile/services/profile_service.g.dart index 83b66e99..79ebdb24 100644 --- a/lib/features/profile/services/profile_service.g.dart +++ b/lib/features/profile/services/profile_service.g.dart @@ -12,36 +12,45 @@ class _ProfileService implements ProfileService { _ProfileService( this._dio, { this.baseUrl, + this.errorLogger, }); final Dio _dio; String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future getProfileBySlug({required String slug}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = - await _dio.fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/profile/show/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = Profile.fromJson(_result.data!); + .compose( + _dio.options, + '/api/profile/show/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Profile _value; + try { + _value = Profile.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/features/recipes/models/image.dart b/lib/features/recipes/models/image.dart deleted file mode 100644 index f10e8db7..00000000 --- a/lib/features/recipes/models/image.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'image.freezed.dart'; - -part 'image.g.dart'; - -@freezed -class Image with _$Image { - const factory Image({ - required String path, - }) = _Image; - - factory Image.fromJson(Map json) => _$ImageFromJson(json); -} diff --git a/lib/features/recipes/models/image.freezed.dart b/lib/features/recipes/models/image.freezed.dart deleted file mode 100644 index 3d4cc2ed..00000000 --- a/lib/features/recipes/models/image.freezed.dart +++ /dev/null @@ -1,147 +0,0 @@ -// 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 'image.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'); - -Image _$ImageFromJson(Map json) { - return _Image.fromJson(json); -} - -/// @nodoc -mixin _$Image { - String get path => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $ImageCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $ImageCopyWith<$Res> { - factory $ImageCopyWith(Image value, $Res Function(Image) then) = - _$ImageCopyWithImpl<$Res, Image>; - @useResult - $Res call({String path}); -} - -/// @nodoc -class _$ImageCopyWithImpl<$Res, $Val extends Image> - implements $ImageCopyWith<$Res> { - _$ImageCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? path = null, - }) { - return _then(_value.copyWith( - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$ImageImplCopyWith<$Res> implements $ImageCopyWith<$Res> { - factory _$$ImageImplCopyWith( - _$ImageImpl value, $Res Function(_$ImageImpl) then) = - __$$ImageImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String path}); -} - -/// @nodoc -class __$$ImageImplCopyWithImpl<$Res> - extends _$ImageCopyWithImpl<$Res, _$ImageImpl> - implements _$$ImageImplCopyWith<$Res> { - __$$ImageImplCopyWithImpl( - _$ImageImpl _value, $Res Function(_$ImageImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? path = null, - }) { - return _then(_$ImageImpl( - path: null == path - ? _value.path - : path // ignore: cast_nullable_to_non_nullable - as String, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$ImageImpl implements _Image { - const _$ImageImpl({required this.path}); - - factory _$ImageImpl.fromJson(Map json) => - _$$ImageImplFromJson(json); - - @override - final String path; - - @override - String toString() { - return 'Image(path: $path)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ImageImpl && - (identical(other.path, path) || other.path == path)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash(runtimeType, path); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$ImageImplCopyWith<_$ImageImpl> get copyWith => - __$$ImageImplCopyWithImpl<_$ImageImpl>(this, _$identity); - - @override - Map toJson() { - return _$$ImageImplToJson( - this, - ); - } -} - -abstract class _Image implements Image { - const factory _Image({required final String path}) = _$ImageImpl; - - factory _Image.fromJson(Map json) = _$ImageImpl.fromJson; - - @override - String get path; - @override - @JsonKey(ignore: true) - _$$ImageImplCopyWith<_$ImageImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/features/recipes/models/image.g.dart b/lib/features/recipes/models/image.g.dart deleted file mode 100644 index 3e44a28c..00000000 --- a/lib/features/recipes/models/image.g.dart +++ /dev/null @@ -1,15 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'image.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$ImageImpl _$$ImageImplFromJson(Map json) => _$ImageImpl( - path: json['path'] as String, - ); - -Map _$$ImageImplToJson(_$ImageImpl instance) => { - 'path': instance.path, - }; diff --git a/lib/features/recipes/models/ingredient.dart b/lib/features/recipes/models/ingredient.dart index bf00fe1b..d7a130e4 100644 --- a/lib/features/recipes/models/ingredient.dart +++ b/lib/features/recipes/models/ingredient.dart @@ -7,12 +7,10 @@ part 'ingredient.g.dart'; @freezed class Ingredient with _$Ingredient { const factory Ingredient({ - int? id, - required String product_name, + required String name, required String unit, - required num portion, + required String portion, }) = _Ingredient; - factory Ingredient.fromJson(Map json) => - _$IngredientFromJson(json); + factory Ingredient.fromJson(Map json) => _$IngredientFromJson(json); } diff --git a/lib/features/recipes/models/ingredient.freezed.dart b/lib/features/recipes/models/ingredient.freezed.dart index 2555a744..63f3facb 100644 --- a/lib/features/recipes/models/ingredient.freezed.dart +++ b/lib/features/recipes/models/ingredient.freezed.dart @@ -20,10 +20,9 @@ Ingredient _$IngredientFromJson(Map json) { /// @nodoc mixin _$Ingredient { - int? get id => throw _privateConstructorUsedError; - String get product_name => throw _privateConstructorUsedError; + String get name => throw _privateConstructorUsedError; String get unit => throw _privateConstructorUsedError; - num get portion => throw _privateConstructorUsedError; + String get portion => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -37,7 +36,7 @@ abstract class $IngredientCopyWith<$Res> { Ingredient value, $Res Function(Ingredient) then) = _$IngredientCopyWithImpl<$Res, Ingredient>; @useResult - $Res call({int? id, String product_name, String unit, num portion}); + $Res call({String name, String unit, String portion}); } /// @nodoc @@ -53,19 +52,14 @@ class _$IngredientCopyWithImpl<$Res, $Val extends Ingredient> @pragma('vm:prefer-inline') @override $Res call({ - Object? id = freezed, - Object? product_name = null, + Object? name = null, Object? unit = null, Object? portion = null, }) { return _then(_value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int?, - product_name: null == product_name - ? _value.product_name - : product_name // ignore: cast_nullable_to_non_nullable + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable as String, unit: null == unit ? _value.unit @@ -74,7 +68,7 @@ class _$IngredientCopyWithImpl<$Res, $Val extends Ingredient> portion: null == portion ? _value.portion : portion // ignore: cast_nullable_to_non_nullable - as num, + as String, ) as $Val); } } @@ -87,7 +81,7 @@ abstract class _$$IngredientImplCopyWith<$Res> __$$IngredientImplCopyWithImpl<$Res>; @override @useResult - $Res call({int? id, String product_name, String unit, num portion}); + $Res call({String name, String unit, String portion}); } /// @nodoc @@ -101,19 +95,14 @@ class __$$IngredientImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? id = freezed, - Object? product_name = null, + Object? name = null, Object? unit = null, Object? portion = null, }) { return _then(_$IngredientImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int?, - product_name: null == product_name - ? _value.product_name - : product_name // ignore: cast_nullable_to_non_nullable + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable as String, unit: null == unit ? _value.unit @@ -122,7 +111,7 @@ class __$$IngredientImplCopyWithImpl<$Res> portion: null == portion ? _value.portion : portion // ignore: cast_nullable_to_non_nullable - as num, + as String, )); } } @@ -131,26 +120,21 @@ class __$$IngredientImplCopyWithImpl<$Res> @JsonSerializable() class _$IngredientImpl implements _Ingredient { const _$IngredientImpl( - {this.id, - required this.product_name, - required this.unit, - required this.portion}); + {required this.name, required this.unit, required this.portion}); factory _$IngredientImpl.fromJson(Map json) => _$$IngredientImplFromJson(json); @override - final int? id; - @override - final String product_name; + final String name; @override final String unit; @override - final num portion; + final String portion; @override String toString() { - return 'Ingredient(id: $id, product_name: $product_name, unit: $unit, portion: $portion)'; + return 'Ingredient(name: $name, unit: $unit, portion: $portion)'; } @override @@ -158,16 +142,14 @@ class _$IngredientImpl implements _Ingredient { return identical(this, other) || (other.runtimeType == runtimeType && other is _$IngredientImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.product_name, product_name) || - other.product_name == product_name) && + (identical(other.name, name) || other.name == name) && (identical(other.unit, unit) || other.unit == unit) && (identical(other.portion, portion) || other.portion == portion)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, product_name, unit, portion); + int get hashCode => Object.hash(runtimeType, name, unit, portion); @JsonKey(ignore: true) @override @@ -185,22 +167,19 @@ class _$IngredientImpl implements _Ingredient { abstract class _Ingredient implements Ingredient { const factory _Ingredient( - {final int? id, - required final String product_name, + {required final String name, required final String unit, - required final num portion}) = _$IngredientImpl; + required final String portion}) = _$IngredientImpl; factory _Ingredient.fromJson(Map json) = _$IngredientImpl.fromJson; @override - int? get id; - @override - String get product_name; + String get name; @override String get unit; @override - num get portion; + String get portion; @override @JsonKey(ignore: true) _$$IngredientImplCopyWith<_$IngredientImpl> get copyWith => diff --git a/lib/features/recipes/models/ingredient.g.dart b/lib/features/recipes/models/ingredient.g.dart index 7e3c9d91..b3f1844d 100644 --- a/lib/features/recipes/models/ingredient.g.dart +++ b/lib/features/recipes/models/ingredient.g.dart @@ -8,16 +8,14 @@ part of 'ingredient.dart'; _$IngredientImpl _$$IngredientImplFromJson(Map json) => _$IngredientImpl( - id: (json['id'] as num?)?.toInt(), - product_name: json['product_name'] as String, + name: json['name'] as String, unit: json['unit'] as String, - portion: json['portion'] as num, + portion: json['portion'] as String, ); Map _$$IngredientImplToJson(_$IngredientImpl instance) => { - 'id': instance.id, - 'product_name': instance.product_name, + 'name': instance.name, 'unit': instance.unit, 'portion': instance.portion, }; diff --git a/lib/features/recipes/models/recipe_model.dart b/lib/features/recipes/models/recipe_model.dart index 2ab3ea81..8b5b8c56 100644 --- a/lib/features/recipes/models/recipe_model.dart +++ b/lib/features/recipes/models/recipe_model.dart @@ -1,4 +1,3 @@ -import 'package:eatvio_app/features/recipes/models/image.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/step.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; @@ -9,17 +8,16 @@ part 'recipe_model.g.dart'; @freezed class RecipeModel with _$RecipeModel { const factory RecipeModel({ - int? id, - required List ingredients, - required List steps, - required String state, - required String description, - required String type, - required Image image, + List? ingredients, + List? steps, + String? type, + String? state, + String? title, + String? description, String? video_url, - num? cooking_time, + String? image, + int? cooking_time, }) = _RecipeModel; - factory RecipeModel.fromJson(Map json) => - _$RecipeModelFromJson(json); + factory RecipeModel.fromJson(Map json) => _$RecipeModelFromJson(json); } diff --git a/lib/features/recipes/models/recipe_model.freezed.dart b/lib/features/recipes/models/recipe_model.freezed.dart index 984d3bd7..fb93e70a 100644 --- a/lib/features/recipes/models/recipe_model.freezed.dart +++ b/lib/features/recipes/models/recipe_model.freezed.dart @@ -20,15 +20,15 @@ RecipeModel _$RecipeModelFromJson(Map json) { /// @nodoc mixin _$RecipeModel { - int? get id => throw _privateConstructorUsedError; - List get ingredients => throw _privateConstructorUsedError; - List get steps => throw _privateConstructorUsedError; - String get state => throw _privateConstructorUsedError; - String get description => throw _privateConstructorUsedError; - String get type => throw _privateConstructorUsedError; - Image get image => throw _privateConstructorUsedError; + List? get ingredients => throw _privateConstructorUsedError; + List? get steps => throw _privateConstructorUsedError; + String? get type => throw _privateConstructorUsedError; + String? get state => throw _privateConstructorUsedError; + String? get title => throw _privateConstructorUsedError; + String? get description => throw _privateConstructorUsedError; String? get video_url => throw _privateConstructorUsedError; - num? get cooking_time => throw _privateConstructorUsedError; + String? get image => throw _privateConstructorUsedError; + int? get cooking_time => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -43,17 +43,15 @@ abstract class $RecipeModelCopyWith<$Res> { _$RecipeModelCopyWithImpl<$Res, RecipeModel>; @useResult $Res call( - {int? id, - List ingredients, - List steps, - String state, - String description, - String type, - Image image, + {List? ingredients, + List? steps, + String? type, + String? state, + String? title, + String? description, String? video_url, - num? cooking_time}); - - $ImageCopyWith<$Res> get image; + String? image, + int? cooking_time}); } /// @nodoc @@ -69,63 +67,55 @@ class _$RecipeModelCopyWithImpl<$Res, $Val extends RecipeModel> @pragma('vm:prefer-inline') @override $Res call({ - Object? id = freezed, - Object? ingredients = null, - Object? steps = null, - Object? state = null, - Object? description = null, - Object? type = null, - Object? image = null, + Object? ingredients = freezed, + Object? steps = freezed, + Object? type = freezed, + Object? state = freezed, + Object? title = freezed, + Object? description = freezed, Object? video_url = freezed, + Object? image = freezed, Object? cooking_time = freezed, }) { return _then(_value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int?, - ingredients: null == ingredients + ingredients: freezed == ingredients ? _value.ingredients : ingredients // ignore: cast_nullable_to_non_nullable - as List, - steps: null == steps + as List?, + steps: freezed == steps ? _value.steps : steps // ignore: cast_nullable_to_non_nullable - as List, - state: null == state - ? _value.state - : state // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - type: null == type + as List?, + type: freezed == type ? _value.type : type // ignore: cast_nullable_to_non_nullable - as String, - image: null == image - ? _value.image - : image // ignore: cast_nullable_to_non_nullable - as Image, + as String?, + state: freezed == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as String?, + title: freezed == title + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as String?, + description: freezed == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String?, video_url: freezed == video_url ? _value.video_url : video_url // ignore: cast_nullable_to_non_nullable as String?, + image: freezed == image + ? _value.image + : image // ignore: cast_nullable_to_non_nullable + as String?, cooking_time: freezed == cooking_time ? _value.cooking_time : cooking_time // ignore: cast_nullable_to_non_nullable - as num?, + as int?, ) as $Val); } - - @override - @pragma('vm:prefer-inline') - $ImageCopyWith<$Res> get image { - return $ImageCopyWith<$Res>(_value.image, (value) { - return _then(_value.copyWith(image: value) as $Val); - }); - } } /// @nodoc @@ -137,18 +127,15 @@ abstract class _$$RecipeModelImplCopyWith<$Res> @override @useResult $Res call( - {int? id, - List ingredients, - List steps, - String state, - String description, - String type, - Image image, + {List? ingredients, + List? steps, + String? type, + String? state, + String? title, + String? description, String? video_url, - num? cooking_time}); - - @override - $ImageCopyWith<$Res> get image; + String? image, + int? cooking_time}); } /// @nodoc @@ -162,53 +149,53 @@ class __$$RecipeModelImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? id = freezed, - Object? ingredients = null, - Object? steps = null, - Object? state = null, - Object? description = null, - Object? type = null, - Object? image = null, + Object? ingredients = freezed, + Object? steps = freezed, + Object? type = freezed, + Object? state = freezed, + Object? title = freezed, + Object? description = freezed, Object? video_url = freezed, + Object? image = freezed, Object? cooking_time = freezed, }) { return _then(_$RecipeModelImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int?, - ingredients: null == ingredients + ingredients: freezed == ingredients ? _value._ingredients : ingredients // ignore: cast_nullable_to_non_nullable - as List, - steps: null == steps + as List?, + steps: freezed == steps ? _value._steps : steps // ignore: cast_nullable_to_non_nullable - as List, - state: null == state - ? _value.state - : state // ignore: cast_nullable_to_non_nullable - as String, - description: null == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, - type: null == type + as List?, + type: freezed == type ? _value.type : type // ignore: cast_nullable_to_non_nullable - as String, - image: null == image - ? _value.image - : image // ignore: cast_nullable_to_non_nullable - as Image, + as String?, + state: freezed == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as String?, + title: freezed == title + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as String?, + description: freezed == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String?, video_url: freezed == video_url ? _value.video_url : video_url // ignore: cast_nullable_to_non_nullable as String?, + image: freezed == image + ? _value.image + : image // ignore: cast_nullable_to_non_nullable + as String?, cooking_time: freezed == cooking_time ? _value.cooking_time : cooking_time // ignore: cast_nullable_to_non_nullable - as num?, + as int?, )); } } @@ -217,14 +204,14 @@ class __$$RecipeModelImplCopyWithImpl<$Res> @JsonSerializable() class _$RecipeModelImpl implements _RecipeModel { const _$RecipeModelImpl( - {this.id, - required final List ingredients, - required final List steps, - required this.state, - required this.description, - required this.type, - required this.image, + {final List? ingredients, + final List? steps, + this.type, + this.state, + this.title, + this.description, this.video_url, + this.image, this.cooking_time}) : _ingredients = ingredients, _steps = steps; @@ -232,40 +219,44 @@ class _$RecipeModelImpl implements _RecipeModel { factory _$RecipeModelImpl.fromJson(Map json) => _$$RecipeModelImplFromJson(json); + final List? _ingredients; @override - final int? id; - final List _ingredients; - @override - List get ingredients { + List? get ingredients { + final value = _ingredients; + if (value == null) return null; if (_ingredients is EqualUnmodifiableListView) return _ingredients; // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_ingredients); + return EqualUnmodifiableListView(value); } - final List _steps; + final List? _steps; @override - List get steps { + List? get steps { + final value = _steps; + if (value == null) return null; if (_steps is EqualUnmodifiableListView) return _steps; // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_steps); + return EqualUnmodifiableListView(value); } @override - final String state; + final String? type; @override - final String description; + final String? state; @override - final String type; + final String? title; @override - final Image image; + final String? description; @override final String? video_url; @override - final num? cooking_time; + final String? image; + @override + final int? cooking_time; @override String toString() { - return 'RecipeModel(id: $id, ingredients: $ingredients, steps: $steps, state: $state, description: $description, type: $type, image: $image, video_url: $video_url, cooking_time: $cooking_time)'; + return 'RecipeModel(ingredients: $ingredients, steps: $steps, type: $type, state: $state, title: $title, description: $description, video_url: $video_url, image: $image, cooking_time: $cooking_time)'; } @override @@ -273,17 +264,17 @@ class _$RecipeModelImpl implements _RecipeModel { return identical(this, other) || (other.runtimeType == runtimeType && other is _$RecipeModelImpl && - (identical(other.id, id) || other.id == id) && const DeepCollectionEquality() .equals(other._ingredients, _ingredients) && const DeepCollectionEquality().equals(other._steps, _steps) && + (identical(other.type, type) || other.type == type) && (identical(other.state, state) || other.state == state) && + (identical(other.title, title) || other.title == title) && (identical(other.description, description) || other.description == description) && - (identical(other.type, type) || other.type == type) && - (identical(other.image, image) || other.image == image) && (identical(other.video_url, video_url) || other.video_url == video_url) && + (identical(other.image, image) || other.image == image) && (identical(other.cooking_time, cooking_time) || other.cooking_time == cooking_time)); } @@ -292,14 +283,14 @@ class _$RecipeModelImpl implements _RecipeModel { @override int get hashCode => Object.hash( runtimeType, - id, const DeepCollectionEquality().hash(_ingredients), const DeepCollectionEquality().hash(_steps), - state, - description, type, - image, + state, + title, + description, video_url, + image, cooking_time); @JsonKey(ignore: true) @@ -318,37 +309,37 @@ class _$RecipeModelImpl implements _RecipeModel { abstract class _RecipeModel implements RecipeModel { const factory _RecipeModel( - {final int? id, - required final List ingredients, - required final List steps, - required final String state, - required final String description, - required final String type, - required final Image image, + {final List? ingredients, + final List? steps, + final String? type, + final String? state, + final String? title, + final String? description, final String? video_url, - final num? cooking_time}) = _$RecipeModelImpl; + final String? image, + final int? cooking_time}) = _$RecipeModelImpl; factory _RecipeModel.fromJson(Map json) = _$RecipeModelImpl.fromJson; @override - int? get id; + List? get ingredients; @override - List get ingredients; + List? get steps; @override - List get steps; + String? get type; @override - String get state; + String? get state; @override - String get description; + String? get title; @override - String get type; - @override - Image get image; + String? get description; @override String? get video_url; @override - num? get cooking_time; + String? get image; + @override + int? get cooking_time; @override @JsonKey(ignore: true) _$$RecipeModelImplCopyWith<_$RecipeModelImpl> get copyWith => diff --git a/lib/features/recipes/models/recipe_model.g.dart b/lib/features/recipes/models/recipe_model.g.dart index 35cd7d47..d5ab9c96 100644 --- a/lib/features/recipes/models/recipe_model.g.dart +++ b/lib/features/recipes/models/recipe_model.g.dart @@ -8,30 +8,32 @@ part of 'recipe_model.dart'; _$RecipeModelImpl _$$RecipeModelImplFromJson(Map json) => _$RecipeModelImpl( - id: (json['id'] as num?)?.toInt(), - ingredients: (json['ingredients'] as List) - .map((e) => Ingredient.fromJson(e as Map)) + ingredients: (json['ingredients'] as List?) + ?.map((e) => + e == null ? null : Ingredient.fromJson(e as Map)) .toList(), - steps: (json['steps'] as List) - .map((e) => Step.fromJson(e as Map)) + steps: (json['steps'] as List?) + ?.map((e) => + e == null ? null : Step.fromJson(e as Map)) .toList(), - state: json['state'] as String, - description: json['description'] as String, - type: json['type'] as String, - image: Image.fromJson(json['image'] as Map), + type: json['type'] as String?, + state: json['state'] as String?, + title: json['title'] as String?, + description: json['description'] as String?, video_url: json['video_url'] as String?, - cooking_time: json['cooking_time'] as num?, + image: json['image'] as String?, + cooking_time: (json['cooking_time'] as num?)?.toInt(), ); Map _$$RecipeModelImplToJson(_$RecipeModelImpl instance) => { - 'id': instance.id, 'ingredients': instance.ingredients, 'steps': instance.steps, - 'state': instance.state, - 'description': instance.description, 'type': instance.type, - 'image': instance.image, + 'state': instance.state, + 'title': instance.title, + 'description': instance.description, 'video_url': instance.video_url, + 'image': instance.image, 'cooking_time': instance.cooking_time, }; diff --git a/lib/features/recipes/models/step.dart b/lib/features/recipes/models/step.dart index 735f72c2..9c22eb76 100644 --- a/lib/features/recipes/models/step.dart +++ b/lib/features/recipes/models/step.dart @@ -1,4 +1,3 @@ -import 'package:eatvio_app/features/recipes/models/image.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'step.freezed.dart'; @@ -8,8 +7,7 @@ part 'step.g.dart'; @freezed class Step with _$Step { const factory Step({ - int? id, - Image? image, + String? image, String? description, }) = _Step; diff --git a/lib/features/recipes/models/step.freezed.dart b/lib/features/recipes/models/step.freezed.dart index 1ff4d0c1..c2014f4f 100644 --- a/lib/features/recipes/models/step.freezed.dart +++ b/lib/features/recipes/models/step.freezed.dart @@ -20,8 +20,7 @@ Step _$StepFromJson(Map json) { /// @nodoc mixin _$Step { - int? get id => throw _privateConstructorUsedError; - Image? get image => throw _privateConstructorUsedError; + String? get image => throw _privateConstructorUsedError; String? get description => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -34,9 +33,7 @@ abstract class $StepCopyWith<$Res> { factory $StepCopyWith(Step value, $Res Function(Step) then) = _$StepCopyWithImpl<$Res, Step>; @useResult - $Res call({int? id, Image? image, String? description}); - - $ImageCopyWith<$Res>? get image; + $Res call({String? image, String? description}); } /// @nodoc @@ -52,37 +49,20 @@ class _$StepCopyWithImpl<$Res, $Val extends Step> @pragma('vm:prefer-inline') @override $Res call({ - Object? id = freezed, Object? image = freezed, Object? description = freezed, }) { return _then(_value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int?, image: freezed == image ? _value.image : image // ignore: cast_nullable_to_non_nullable - as Image?, + as String?, description: freezed == description ? _value.description : description // ignore: cast_nullable_to_non_nullable as String?, ) as $Val); } - - @override - @pragma('vm:prefer-inline') - $ImageCopyWith<$Res>? get image { - if (_value.image == null) { - return null; - } - - return $ImageCopyWith<$Res>(_value.image!, (value) { - return _then(_value.copyWith(image: value) as $Val); - }); - } } /// @nodoc @@ -92,10 +72,7 @@ abstract class _$$StepImplCopyWith<$Res> implements $StepCopyWith<$Res> { __$$StepImplCopyWithImpl<$Res>; @override @useResult - $Res call({int? id, Image? image, String? description}); - - @override - $ImageCopyWith<$Res>? get image; + $Res call({String? image, String? description}); } /// @nodoc @@ -108,19 +85,14 @@ class __$$StepImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? id = freezed, Object? image = freezed, Object? description = freezed, }) { return _then(_$StepImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int?, image: freezed == image ? _value.image : image // ignore: cast_nullable_to_non_nullable - as Image?, + as String?, description: freezed == description ? _value.description : description // ignore: cast_nullable_to_non_nullable @@ -132,21 +104,19 @@ class __$$StepImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$StepImpl implements _Step { - const _$StepImpl({this.id, this.image, this.description}); + const _$StepImpl({this.image, this.description}); factory _$StepImpl.fromJson(Map json) => _$$StepImplFromJson(json); @override - final int? id; - @override - final Image? image; + final String? image; @override final String? description; @override String toString() { - return 'Step(id: $id, image: $image, description: $description)'; + return 'Step(image: $image, description: $description)'; } @override @@ -154,7 +124,6 @@ class _$StepImpl implements _Step { return identical(this, other) || (other.runtimeType == runtimeType && other is _$StepImpl && - (identical(other.id, id) || other.id == id) && (identical(other.image, image) || other.image == image) && (identical(other.description, description) || other.description == description)); @@ -162,7 +131,7 @@ class _$StepImpl implements _Step { @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, image, description); + int get hashCode => Object.hash(runtimeType, image, description); @JsonKey(ignore: true) @override @@ -179,17 +148,13 @@ class _$StepImpl implements _Step { } abstract class _Step implements Step { - const factory _Step( - {final int? id, - final Image? image, - final String? description}) = _$StepImpl; + const factory _Step({final String? image, final String? description}) = + _$StepImpl; factory _Step.fromJson(Map json) = _$StepImpl.fromJson; @override - int? get id; - @override - Image? get image; + String? get image; @override String? get description; @override diff --git a/lib/features/recipes/models/step.g.dart b/lib/features/recipes/models/step.g.dart index 688769ce..31d97f9f 100644 --- a/lib/features/recipes/models/step.g.dart +++ b/lib/features/recipes/models/step.g.dart @@ -7,16 +7,12 @@ part of 'step.dart'; // ************************************************************************** _$StepImpl _$$StepImplFromJson(Map json) => _$StepImpl( - id: (json['id'] as num?)?.toInt(), - image: json['image'] == null - ? null - : Image.fromJson(json['image'] as Map), + image: json['image'] as String?, description: json['description'] as String?, ); Map _$$StepImplToJson(_$StepImpl instance) => { - 'id': instance.id, 'image': instance.image, 'description': instance.description, }; diff --git a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart index 0790f2a4..5507c0ea 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_cubit.dart @@ -1,58 +1,154 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; +import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; import 'package:eatvio_app/features/recipes/reporitories/recipe_repository.dart'; +import 'package:eatvio_app/features/diary/models/product.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; class RecipeCreateCubit extends Cubit { final RecipeRepository recipeRepository; - RecipeCreateCubit({required this.recipeRepository}) - : super(const RecipeCreateState.loading()); + RecipeCreateCubit({required this.recipeRepository}) : super(const RecipeCreateState.loading()); + + loadRecipeById(String recipeID) async { + emit(const RecipeCreateStateLoading()); + try { + final RecipeModel recipe = await recipeRepository.getRecipe(recipeID); + final List types = [ + SelectionPopupModel(title: 'Первые блюда', value: 'first_meals'), + SelectionPopupModel(title: 'Вторые блюда', value: 'second_meals'), + SelectionPopupModel(title: 'Cалаты', value: 'salads'), + SelectionPopupModel(title: 'Перекусы/закуски', value: 'snacks'), + SelectionPopupModel(title: 'Сладости', value: 'sweets'), + SelectionPopupModel(title: 'Напитки', value: 'drinks'), + SelectionPopupModel(title: 'Прочее', value: 'other'), + ]; + final List cookingTimes = [ + SelectionPopupModel(title: '10 минут', value: 10), + SelectionPopupModel(title: '20 минут', value: 20), + SelectionPopupModel(title: '30 минут', value: 30), + SelectionPopupModel(title: '1 час', value: 60), + SelectionPopupModel(title: '2 часа', value: 120), + SelectionPopupModel(title: '10 дней', value: 14400), + ]; + final List statuses = [ + SelectionPopupModel(title: 'Активна', value: 'active'), + SelectionPopupModel(title: 'Неактивна', value: 'inactive'), + ]; + final selectedType = types.firstWhere( + (type) => type.value == recipe.type, + orElse: () => types[0], + ); + + final selectedCookingTime = cookingTimes.firstWhere( + (time) => time.value == recipe.cooking_time, + orElse: () => cookingTimes[0], + ); + + final selectedStatus = statuses.firstWhere( + (status) => status.value == recipe.state, + orElse: () => statuses[0], + ); + + final stepControllers = recipe.steps?.map((step) { + return TextEditingController(text: step?.description); + }).toList(); + + final stepImages = recipe.steps?.map((step) { + return step?.image != null ? XFile(step!.image!) : null; + }).toList(); + + final ingredients = recipe.ingredients?.map((ingredient) { + return Ingredient( + name: ingredient!.name, + portion: ingredient.portion, + unit: ingredient.unit, + ); + }).toList(); + + emit(RecipeCreateState.loaded( + picker: ImagePicker(), + recipeImage: XFile(recipe.image!), + titleController: TextEditingController(text: recipe.title), + productNameController: TextEditingController(), + ingredientController: TextEditingController(), + stepDescriptionController: TextEditingController(text: recipe.description), + youtubeLinkController: TextEditingController(text: recipe.video_url), + stepControllers: stepControllers ?? [], + stepImages: stepImages ?? [], + autocompleteList: [], + ingredients: ingredients ?? [], + numberOfSteps: 1, + ingredientAsItems: false, + types: types, + cookingTimes: cookingTimes, + statuses: statuses, + selectedType: selectedType, + selectedCookingTime: selectedCookingTime, + selectedStatus: selectedStatus)); + } catch (e) { + emit(RecipeCreateState.error(errorMessage: e.toString())); + } + } loadRecipeCreate() { emit(const RecipeCreateStateLoading()); try { + final List types = [ + SelectionPopupModel(title: 'Первые блюда', value: 'first_meals'), + SelectionPopupModel(title: 'Вторые блюда', value: 'second_meals'), + SelectionPopupModel(title: 'Cалаты', value: 'salads'), + SelectionPopupModel(title: 'Перекусы/закуски', value: 'snacks'), + SelectionPopupModel(title: 'Сладости', value: 'sweets'), + SelectionPopupModel(title: 'Напитки', value: 'drinks'), + SelectionPopupModel(title: 'Прочее', value: 'other'), + ]; + final List cookingTimes = [ + SelectionPopupModel(title: '10 минут', value: 10), + SelectionPopupModel(title: '20 минут', value: 20), + SelectionPopupModel(title: '30 минут', value: 30), + SelectionPopupModel(title: '1 час', value: 60), + SelectionPopupModel(title: '2 часа', value: 120), + SelectionPopupModel(title: '10 дней', value: 14400), + ]; + final List statuses = [ + SelectionPopupModel(title: 'Активна', value: 'active'), + SelectionPopupModel(title: 'Неактивна', value: 'inactive'), + ]; emit(RecipeCreateState.loaded( - picker: ImagePicker(), - titleController: TextEditingController(), - productNameController: TextEditingController(), - ingredientController: TextEditingController(), - stepDescriptionController: TextEditingController(), - youtubeLinkController: TextEditingController(), - stepControllers: [TextEditingController()], - stepImages: [null], - ingredients: [], - numberOfSteps: 1, - ingredientAsItems: false, - types: [ - SelectionPopupModel(title: 'Первые блюда'), - SelectionPopupModel(title: 'Вторые блюда'), - SelectionPopupModel(title: 'Cалаты'), - SelectionPopupModel(title: 'Перекусы/закуски'), - SelectionPopupModel(title: 'Сладости'), - SelectionPopupModel(title: 'Напитки'), - SelectionPopupModel(title: 'Прочее'), - ], - cookingTimes: [ - SelectionPopupModel(title: '10 минут'), - SelectionPopupModel(title: '20 минут'), - SelectionPopupModel(title: '30 минут'), - SelectionPopupModel(title: '1 час'), - SelectionPopupModel(title: '2 часа'), - SelectionPopupModel(title: '10 дней'), - ], - statuses: [ - SelectionPopupModel(title: 'Активна'), - SelectionPopupModel(title: 'Неактивна'), - ], - )); + picker: ImagePicker(), + titleController: TextEditingController(), + productNameController: TextEditingController(), + ingredientController: TextEditingController(), + stepDescriptionController: TextEditingController(), + youtubeLinkController: TextEditingController(), + stepControllers: [TextEditingController()], + stepImages: [null], + autocompleteList: [], + ingredients: [], + numberOfSteps: 1, + ingredientAsItems: false, + types: types, + cookingTimes: cookingTimes, + statuses: statuses, + selectedType: types[0], + selectedCookingTime: cookingTimes[0], + selectedStatus: statuses[0])); } catch (e) { emit(RecipeCreateState.error(errorMessage: e.toString())); } } + publishRecipe(RecipeModel recipe) async { + await recipeRepository.publishRecipe(recipe); + } + + editRecipe(RecipeModel recipe, String id) async { + await recipeRepository.editRecipe(recipe, id); + } + uploadRecipeImage(XFile? pickedFile) { try { if (state is RecipeCreateStateLoaded) { @@ -106,18 +202,14 @@ class RecipeCreateCubit extends Cubit { if (state is RecipeCreateStateLoaded) { var currentState = state as RecipeCreateStateLoaded; - bool ingredientExists = currentState.ingredients.any( - (existingIngredient) => - existingIngredient.product_name == ingredient.product_name); + bool ingredientExists = currentState.ingredients.any((existingIngredient) => existingIngredient.name == ingredient.name); if (ingredientExists) { - emit(RecipeCreateState.error( - errorMessage: 'Ингредиент уже существует.')); + emit(RecipeCreateState.error(errorMessage: 'Ингредиент уже существует.')); return; } - List newIngredients = - List.from(currentState.ingredients); + List newIngredients = List.from(currentState.ingredients); newIngredients.add(ingredient); var updatedState = currentState.copyWith(ingredients: newIngredients); @@ -134,13 +226,9 @@ class RecipeCreateCubit extends Cubit { var currentState = state as RecipeCreateStateLoaded; List newStepImages = List.from(currentState.stepImages); newStepImages.add(null); - List newStepControllers = - List.from(currentState.stepControllers); + List newStepControllers = List.from(currentState.stepControllers); newStepControllers.add(TextEditingController()); - var updatedState = currentState.copyWith( - stepImages: newStepImages, - stepControllers: newStepControllers, - numberOfSteps: currentState.numberOfSteps + 1); + var updatedState = currentState.copyWith(stepImages: newStepImages, stepControllers: newStepControllers, numberOfSteps: currentState.numberOfSteps + 1); emit(updatedState); } } catch (e) { @@ -154,17 +242,58 @@ class RecipeCreateCubit extends Cubit { var currentState = state as RecipeCreateStateLoaded; List newStepImages = List.from(currentState.stepImages); newStepImages.removeLast(); - List newStepControllers = - List.from(currentState.stepControllers); + List newStepControllers = List.from(currentState.stepControllers); newStepControllers.removeLast(); - var updatedState = currentState.copyWith( - stepImages: newStepImages, - stepControllers: newStepControllers, - numberOfSteps: currentState.numberOfSteps - 1); + var updatedState = currentState.copyWith(stepImages: newStepImages, stepControllers: newStepControllers, numberOfSteps: currentState.numberOfSteps - 1); emit(updatedState); } } catch (e) { emit(RecipeCreateState.error(errorMessage: e.toString())); } } + + inputProduct(String input) async { + if (state is RecipeCreateStateLoaded) { + var currentState = state as RecipeCreateStateLoaded; + + final Map> productNutritionalValues = await recipeRepository.inputProduct(input); + print(productNutritionalValues); + var updatedState = currentState.copyWith( + productNameController: TextEditingController(text: input), + autocompleteList: productNutritionalValues['product_nutritional_value'] ?? [], + ); + + emit(updatedState); + } + } + + changeType(SelectionPopupModel type) { + if (state is RecipeCreateStateLoaded) { + var currentState = state as RecipeCreateStateLoaded; + RecipeCreateStateLoaded updatedState = currentState.copyWith( + selectedType: type, + ); + emit(updatedState); + } + } + + changeStatus(SelectionPopupModel status) { + if (state is RecipeCreateStateLoaded) { + var currentState = state as RecipeCreateStateLoaded; + RecipeCreateStateLoaded updatedState = currentState.copyWith( + selectedStatus: status, + ); + emit(updatedState); + } + } + + changeCookingTime(SelectionPopupModel cookingTime) { + if (state is RecipeCreateStateLoaded) { + var currentState = state as RecipeCreateStateLoaded; + RecipeCreateStateLoaded updatedState = currentState.copyWith( + selectedCookingTime: cookingTime, + ); + emit(updatedState); + } + } } diff --git a/lib/features/recipes/presentation/bloc/recipe_create_state.dart b/lib/features/recipes/presentation/bloc/recipe_create_state.dart index 796e27e7..8bb6051a 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_state.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_state.dart @@ -1,5 +1,6 @@ import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; +import 'package:eatvio_app/features/diary/models/product.dart'; import 'package:flutter/material.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:image_picker/image_picker.dart'; @@ -26,11 +27,15 @@ abstract class RecipeCreateState with _$RecipeCreateState { XFile? recipeImage, required List stepImages, required List ingredients, + required List autocompleteList, required int numberOfSteps, required bool ingredientAsItems, required List types, required List cookingTimes, required List statuses, + required SelectionPopupModel selectedType, + required SelectionPopupModel selectedCookingTime, + required SelectionPopupModel selectedStatus, }) = RecipeCreateStateLoaded; const factory RecipeCreateState.error({ diff --git a/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart b/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart index 783252e9..9acea107 100644 --- a/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart +++ b/lib/features/recipes/presentation/bloc/recipe_create_state.freezed.dart @@ -32,11 +32,15 @@ mixin _$RecipeCreateState { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses) + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus) loaded, required TResult Function(String errorMessage) error, }) => @@ -57,11 +61,15 @@ mixin _$RecipeCreateState { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult? Function(String errorMessage)? error, }) => @@ -82,11 +90,15 @@ mixin _$RecipeCreateState { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), @@ -189,11 +201,15 @@ class _$RecipeCreateStateImpl implements _RecipeCreateState { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses) + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus) loaded, required TResult Function(String errorMessage) error, }) { @@ -217,11 +233,15 @@ class _$RecipeCreateStateImpl implements _RecipeCreateState { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult? Function(String errorMessage)? error, }) { @@ -245,11 +265,15 @@ class _$RecipeCreateStateImpl implements _RecipeCreateState { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), @@ -358,11 +382,15 @@ class _$RecipeCreateStateLoadingImpl implements RecipeCreateStateLoading { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses) + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus) loaded, required TResult Function(String errorMessage) error, }) { @@ -386,11 +414,15 @@ class _$RecipeCreateStateLoadingImpl implements RecipeCreateStateLoading { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult? Function(String errorMessage)? error, }) { @@ -414,11 +446,15 @@ class _$RecipeCreateStateLoadingImpl implements RecipeCreateStateLoading { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), @@ -490,13 +526,20 @@ abstract class _$$RecipeCreateStateLoadedImplCopyWith<$Res> { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses}); + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus}); $RecipeModelCopyWith<$Res>? get recipe; + $SelectionPopupModelCopyWith<$Res> get selectedType; + $SelectionPopupModelCopyWith<$Res> get selectedCookingTime; + $SelectionPopupModelCopyWith<$Res> get selectedStatus; } /// @nodoc @@ -522,11 +565,15 @@ class __$$RecipeCreateStateLoadedImplCopyWithImpl<$Res> Object? recipeImage = freezed, Object? stepImages = null, Object? ingredients = null, + Object? autocompleteList = null, Object? numberOfSteps = null, Object? ingredientAsItems = null, Object? types = null, Object? cookingTimes = null, Object? statuses = null, + Object? selectedType = null, + Object? selectedCookingTime = null, + Object? selectedStatus = null, }) { return _then(_$RecipeCreateStateLoadedImpl( recipe: freezed == recipe @@ -573,6 +620,10 @@ class __$$RecipeCreateStateLoadedImplCopyWithImpl<$Res> ? _value._ingredients : ingredients // ignore: cast_nullable_to_non_nullable as List, + autocompleteList: null == autocompleteList + ? _value._autocompleteList + : autocompleteList // ignore: cast_nullable_to_non_nullable + as List, numberOfSteps: null == numberOfSteps ? _value.numberOfSteps : numberOfSteps // ignore: cast_nullable_to_non_nullable @@ -593,6 +644,18 @@ class __$$RecipeCreateStateLoadedImplCopyWithImpl<$Res> ? _value._statuses : statuses // ignore: cast_nullable_to_non_nullable as List, + selectedType: null == selectedType + ? _value.selectedType + : selectedType // ignore: cast_nullable_to_non_nullable + as SelectionPopupModel, + selectedCookingTime: null == selectedCookingTime + ? _value.selectedCookingTime + : selectedCookingTime // ignore: cast_nullable_to_non_nullable + as SelectionPopupModel, + selectedStatus: null == selectedStatus + ? _value.selectedStatus + : selectedStatus // ignore: cast_nullable_to_non_nullable + as SelectionPopupModel, )); } @@ -607,6 +670,31 @@ class __$$RecipeCreateStateLoadedImplCopyWithImpl<$Res> return _then(_value.copyWith(recipe: value)); }); } + + @override + @pragma('vm:prefer-inline') + $SelectionPopupModelCopyWith<$Res> get selectedType { + return $SelectionPopupModelCopyWith<$Res>(_value.selectedType, (value) { + return _then(_value.copyWith(selectedType: value)); + }); + } + + @override + @pragma('vm:prefer-inline') + $SelectionPopupModelCopyWith<$Res> get selectedCookingTime { + return $SelectionPopupModelCopyWith<$Res>(_value.selectedCookingTime, + (value) { + return _then(_value.copyWith(selectedCookingTime: value)); + }); + } + + @override + @pragma('vm:prefer-inline') + $SelectionPopupModelCopyWith<$Res> get selectedStatus { + return $SelectionPopupModelCopyWith<$Res>(_value.selectedStatus, (value) { + return _then(_value.copyWith(selectedStatus: value)); + }); + } } /// @nodoc @@ -624,14 +712,19 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { this.recipeImage, required final List stepImages, required final List ingredients, + required final List autocompleteList, required this.numberOfSteps, required this.ingredientAsItems, required final List types, required final List cookingTimes, - required final List statuses}) + required final List statuses, + required this.selectedType, + required this.selectedCookingTime, + required this.selectedStatus}) : _stepControllers = stepControllers, _stepImages = stepImages, _ingredients = ingredients, + _autocompleteList = autocompleteList, _types = types, _cookingTimes = cookingTimes, _statuses = statuses; @@ -676,6 +769,15 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { return EqualUnmodifiableListView(_ingredients); } + final List _autocompleteList; + @override + List get autocompleteList { + if (_autocompleteList is EqualUnmodifiableListView) + return _autocompleteList; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_autocompleteList); + } + @override final int numberOfSteps; @override @@ -704,9 +806,16 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { return EqualUnmodifiableListView(_statuses); } + @override + final SelectionPopupModel selectedType; + @override + final SelectionPopupModel selectedCookingTime; + @override + final SelectionPopupModel selectedStatus; + @override String toString() { - return 'RecipeCreateState.loaded(recipe: $recipe, picker: $picker, titleController: $titleController, productNameController: $productNameController, ingredientController: $ingredientController, stepDescriptionController: $stepDescriptionController, youtubeLinkController: $youtubeLinkController, stepControllers: $stepControllers, recipeImage: $recipeImage, stepImages: $stepImages, ingredients: $ingredients, numberOfSteps: $numberOfSteps, ingredientAsItems: $ingredientAsItems, types: $types, cookingTimes: $cookingTimes, statuses: $statuses)'; + return 'RecipeCreateState.loaded(recipe: $recipe, picker: $picker, titleController: $titleController, productNameController: $productNameController, ingredientController: $ingredientController, stepDescriptionController: $stepDescriptionController, youtubeLinkController: $youtubeLinkController, stepControllers: $stepControllers, recipeImage: $recipeImage, stepImages: $stepImages, ingredients: $ingredients, autocompleteList: $autocompleteList, numberOfSteps: $numberOfSteps, ingredientAsItems: $ingredientAsItems, types: $types, cookingTimes: $cookingTimes, statuses: $statuses, selectedType: $selectedType, selectedCookingTime: $selectedCookingTime, selectedStatus: $selectedStatus)'; } @override @@ -735,6 +844,8 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { .equals(other._stepImages, _stepImages) && const DeepCollectionEquality() .equals(other._ingredients, _ingredients) && + const DeepCollectionEquality() + .equals(other._autocompleteList, _autocompleteList) && (identical(other.numberOfSteps, numberOfSteps) || other.numberOfSteps == numberOfSteps) && (identical(other.ingredientAsItems, ingredientAsItems) || @@ -742,28 +853,39 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { const DeepCollectionEquality().equals(other._types, _types) && const DeepCollectionEquality() .equals(other._cookingTimes, _cookingTimes) && - const DeepCollectionEquality().equals(other._statuses, _statuses)); + const DeepCollectionEquality().equals(other._statuses, _statuses) && + (identical(other.selectedType, selectedType) || + other.selectedType == selectedType) && + (identical(other.selectedCookingTime, selectedCookingTime) || + other.selectedCookingTime == selectedCookingTime) && + (identical(other.selectedStatus, selectedStatus) || + other.selectedStatus == selectedStatus)); } @override - int get hashCode => Object.hash( - runtimeType, - recipe, - picker, - titleController, - productNameController, - ingredientController, - stepDescriptionController, - youtubeLinkController, - const DeepCollectionEquality().hash(_stepControllers), - recipeImage, - const DeepCollectionEquality().hash(_stepImages), - const DeepCollectionEquality().hash(_ingredients), - numberOfSteps, - ingredientAsItems, - const DeepCollectionEquality().hash(_types), - const DeepCollectionEquality().hash(_cookingTimes), - const DeepCollectionEquality().hash(_statuses)); + int get hashCode => Object.hashAll([ + runtimeType, + recipe, + picker, + titleController, + productNameController, + ingredientController, + stepDescriptionController, + youtubeLinkController, + const DeepCollectionEquality().hash(_stepControllers), + recipeImage, + const DeepCollectionEquality().hash(_stepImages), + const DeepCollectionEquality().hash(_ingredients), + const DeepCollectionEquality().hash(_autocompleteList), + numberOfSteps, + ingredientAsItems, + const DeepCollectionEquality().hash(_types), + const DeepCollectionEquality().hash(_cookingTimes), + const DeepCollectionEquality().hash(_statuses), + selectedType, + selectedCookingTime, + selectedStatus + ]); @JsonKey(ignore: true) @override @@ -789,11 +911,15 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses) + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus) loaded, required TResult Function(String errorMessage) error, }) { @@ -809,11 +935,15 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { recipeImage, stepImages, ingredients, + autocompleteList, numberOfSteps, ingredientAsItems, types, cookingTimes, - statuses); + statuses, + selectedType, + selectedCookingTime, + selectedStatus); } @override @@ -833,11 +963,15 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult? Function(String errorMessage)? error, }) { @@ -853,11 +987,15 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { recipeImage, stepImages, ingredients, + autocompleteList, numberOfSteps, ingredientAsItems, types, cookingTimes, - statuses); + statuses, + selectedType, + selectedCookingTime, + selectedStatus); } @override @@ -877,11 +1015,15 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), @@ -899,11 +1041,15 @@ class _$RecipeCreateStateLoadedImpl implements RecipeCreateStateLoaded { recipeImage, stepImages, ingredients, + autocompleteList, numberOfSteps, ingredientAsItems, types, cookingTimes, - statuses); + statuses, + selectedType, + selectedCookingTime, + selectedStatus); } return orElse(); } @@ -959,11 +1105,15 @@ abstract class RecipeCreateStateLoaded implements RecipeCreateState { final XFile? recipeImage, required final List stepImages, required final List ingredients, + required final List autocompleteList, required final int numberOfSteps, required final bool ingredientAsItems, required final List types, required final List cookingTimes, - required final List statuses}) = + required final List statuses, + required final SelectionPopupModel selectedType, + required final SelectionPopupModel selectedCookingTime, + required final SelectionPopupModel selectedStatus}) = _$RecipeCreateStateLoadedImpl; RecipeModel? get recipe; @@ -977,11 +1127,15 @@ abstract class RecipeCreateStateLoaded implements RecipeCreateState { XFile? get recipeImage; List get stepImages; List get ingredients; + List get autocompleteList; int get numberOfSteps; bool get ingredientAsItems; List get types; List get cookingTimes; List get statuses; + SelectionPopupModel get selectedType; + SelectionPopupModel get selectedCookingTime; + SelectionPopupModel get selectedStatus; @JsonKey(ignore: true) _$$RecipeCreateStateLoadedImplCopyWith<_$RecipeCreateStateLoadedImpl> get copyWith => throw _privateConstructorUsedError; @@ -1069,11 +1223,15 @@ class _$RecipeCreateStateErrorImpl implements RecipeCreateStateError { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses) + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus) loaded, required TResult Function(String errorMessage) error, }) { @@ -1097,11 +1255,15 @@ class _$RecipeCreateStateErrorImpl implements RecipeCreateStateError { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult? Function(String errorMessage)? error, }) { @@ -1125,11 +1287,15 @@ class _$RecipeCreateStateErrorImpl implements RecipeCreateStateError { XFile? recipeImage, List stepImages, List ingredients, + List autocompleteList, int numberOfSteps, bool ingredientAsItems, List types, List cookingTimes, - List statuses)? + List statuses, + SelectionPopupModel selectedType, + SelectionPopupModel selectedCookingTime, + SelectionPopupModel selectedStatus)? loaded, TResult Function(String errorMessage)? error, required TResult orElse(), diff --git a/lib/features/recipes/presentation/pages/recipe_create_screen.dart b/lib/features/recipes/presentation/pages/recipe_create_screen.dart index 0f5973cb..79b159b7 100644 --- a/lib/features/recipes/presentation/pages/recipe_create_screen.dart +++ b/lib/features/recipes/presentation/pages/recipe_create_screen.dart @@ -1,8 +1,9 @@ +import 'dart:convert'; import 'dart:io'; import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/features/diary/models/product.dart'; import 'package:eatvio_app/features/recipes/models/ingredient.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; -import 'package:eatvio_app/features/recipes/models/image.dart' as image; import 'package:eatvio_app/features/recipes/models/step.dart' as step; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_cubit.dart'; import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; @@ -17,6 +18,7 @@ import 'package:image_picker/image_picker.dart'; class RecipeCreateScreen extends StatelessWidget { RecipeCreateScreen({Key? key}) : super(key: key); Widget build(BuildContext context) { + context.read().loadRecipeCreate(); return BlocBuilder( builder: (context, state) { if (state is RecipeCreateStateLoaded) { @@ -49,12 +51,33 @@ class RecipeCreateScreen extends StatelessWidget { ); } - Widget _buildRecipeCreate( - BuildContext context, RecipeCreateStateLoaded state) { + Widget _buildRecipeCreate(BuildContext context, RecipeCreateStateLoaded state) { + List _options = state.autocompleteList.map((Product item) => item.name).toList(); return Scaffold( appBar: AppBar( - toolbarHeight: 0, - automaticallyImplyLeading: false, + actions: [ + InkWell( + borderRadius: BorderRadius.circular(16), + child: Ink( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(height: 4), + Text( + 'Новый рецепт', + style: TextStyle( + color: Colors.black, + fontSize: 14, + fontWeight: FontWeight.w400, + height: 1, + ), + ), + ], + ), + ), + ), + ], ), backgroundColor: Color.fromARGB(255, 240, 242, 245), resizeToAvoidBottomInset: true, @@ -86,18 +109,16 @@ class RecipeCreateScreen extends StatelessWidget { Text('Тип блюда'), SizedBox(height: 8), CustomDropDown( - value: state.types[0], + value: state.selectedType, items: state.types, + onChanged: changeType(context), ), SizedBox(height: 16), Text('Изображение'), GestureDetector( onTap: () async { - final pickedFile = await state.picker - .pickImage(source: ImageSource.gallery); - context - .read() - .uploadRecipeImage(pickedFile); + final pickedFile = await state.picker.pickImage(source: ImageSource.gallery); + context.read().uploadRecipeImage(pickedFile); }, child: state.recipeImage == null ? Container( @@ -121,31 +142,71 @@ class RecipeCreateScreen extends StatelessWidget { ], ), ) - : Image.file(File(state.recipeImage!.path), - height: 200, fit: BoxFit.cover), + : Image.file(File(state.recipeImage!.path), height: 200, fit: BoxFit.cover), ), SizedBox(height: 16), Text('Время приготовления'), SizedBox(height: 8), CustomDropDown( items: state.cookingTimes, - value: state.cookingTimes[0], + value: state.selectedCookingTime, + onChanged: changeCookingTime(context), ), SizedBox(height: 16), Text('Статус'), SizedBox(height: 8), CustomDropDown( items: state.statuses, - value: state.statuses[0], + value: state.selectedStatus, + onChanged: changeStatus(context), ), SizedBox(height: 24), if (!state.ingredients.isEmpty) - for (int j = 0; j < state.ingredients.length; j++) - _buildIngredient(state.ingredients[j]), + for (int j = 0; j < state.ingredients.length; j++) _buildIngredient(state.ingredients[j]), SizedBox(height: 24), - CustomTextFormField( - hintText: 'Введите название продукта', - controller: state.productNameController, + RawAutocomplete( + optionsBuilder: _buildOptions(_options), + fieldViewBuilder: ( + BuildContext context, + TextEditingController productEditingController, + FocusNode focusNodeName, + VoidCallback onFieldSubmitted, + ) { + return CustomTextFormField( + hintText: 'Введите название продукта', + controller: TextEditingController(text: state.productNameController.text), + focusNode: focusNodeName, + onChanged: getAutocomplete(context, focusNodeName), + ); + }, + optionsViewBuilder: ( + BuildContext context, + AutocompleteOnSelected onSelected, + Iterable options, + ) { + return Align( + alignment: Alignment.topLeft, + child: Material( + elevation: 4.0, + child: SizedBox( + height: 200.0, + child: ListView.builder( + padding: const EdgeInsets.all(8.0), + itemCount: options.length, + itemBuilder: (BuildContext context, int index) { + final String option = options.elementAt(index); + return GestureDetector( + onTap: selectProduct(onSelected, option, state), + child: ListTile( + title: Text(option), + ), + ); + }, + ), + ), + ), + ); + }, ), SizedBox(height: 24), CustomTextFormField( @@ -153,18 +214,14 @@ class RecipeCreateScreen extends StatelessWidget { fillColor: appTheme.gray50, controller: state.ingredientController, keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly - ], + inputFormatters: [FilteringTextInputFormatter.digitsOnly], ), SizedBox(height: 8), Row(children: [ Text('гр'), Switch( value: state.ingredientAsItems, - onChanged: (bool value) => context - .read() - .switchUnits(value), + onChanged: (bool value) => context.read().switchUnits(value), activeColor: appTheme.blueA400, inactiveThumbColor: Colors.grey, inactiveTrackColor: Colors.grey.shade300, @@ -187,16 +244,10 @@ class RecipeCreateScreen extends StatelessWidget { '+', style: theme.textTheme.titleSmall, ), - onPressed: () => context - .read() - .addIngredient(new Ingredient( - product_name: - state.productNameController.text, - portion: int.parse( - state.ingredientController.text), - unit: state.ingredientAsItems - ? 'pcs' - : 'gr'))), + onPressed: () => context.read().addIngredient(new Ingredient( + name: state.productNameController.text, + portion: state.ingredientController.text, + unit: state.ingredientAsItems ? 'pcs' : 'gr'))), ), SizedBox(height: 24), Text('Описание рецепта'), @@ -207,8 +258,7 @@ class RecipeCreateScreen extends StatelessWidget { controller: state.stepDescriptionController, ), SizedBox(height: 24), - for (int i = 0; i < state.numberOfSteps; i++) - _buildStep(context, i, state), + for (int i = 0; i < state.numberOfSteps; i++) _buildStep(context, i, state), SizedBox(height: 24), Container( height: 48, @@ -221,8 +271,7 @@ class RecipeCreateScreen extends StatelessWidget { borderRadius: BorderRadius.circular(8), ), backgroundColor: appTheme.blueA400, - onPressed: () => - context.read().addStep(), + onPressed: () => context.read().addStep(), label: Text( '+', style: theme.textTheme.titleSmall, @@ -241,8 +290,7 @@ class RecipeCreateScreen extends StatelessWidget { borderRadius: BorderRadius.circular(8), ), backgroundColor: Colors.grey, - onPressed: () => - context.read().removeStep(), + onPressed: () => context.read().removeStep(), label: Text( '-', style: theme.textTheme.titleSmall, @@ -269,7 +317,7 @@ class RecipeCreateScreen extends StatelessWidget { borderRadius: BorderRadius.circular(8), ), backgroundColor: appTheme.blueA400, - onPressed: () {}, + onPressed: () => context.read().publishRecipe(createRecipeFromState(state)), label: Text( 'Опубликовать', style: theme.textTheme.titleSmall, @@ -285,23 +333,15 @@ class RecipeCreateScreen extends StatelessWidget { ); } - _buildStep( - BuildContext context, int stepNumber, RecipeCreateStateLoaded state) { + _buildStep(BuildContext context, int stepNumber, RecipeCreateStateLoaded state) { return Column( children: [ - Row(children: [ - Text('Шаг ${stepNumber + 1}'), - Spacer(), - Text('Всего шагов: ${state.numberOfSteps}') - ]), + Row(children: [Text('Шаг ${stepNumber + 1}'), Spacer(), Text('Всего шагов: ${state.numberOfSteps}')]), SizedBox(height: 8), GestureDetector( onTap: () async { - final pickedFile = - await state.picker.pickImage(source: ImageSource.gallery); - context - .read() - .uploadStepImage(pickedFile, stepNumber); + final pickedFile = await state.picker.pickImage(source: ImageSource.gallery); + context.read().uploadStepImage(pickedFile, stepNumber); }, child: state.stepImages[stepNumber] == null ? Container( @@ -326,8 +366,7 @@ class RecipeCreateScreen extends StatelessWidget { ], ), ) - : Image.file(File(state.stepImages[stepNumber]!.path), - height: 150, fit: BoxFit.cover)), + : Image.file(File(state.stepImages[stepNumber]!.path), height: 150, fit: BoxFit.cover)), SizedBox(height: 16), CustomTextFormField( hintText: 'Введите описание шага', @@ -361,9 +400,7 @@ class RecipeCreateScreen extends StatelessWidget { top: 5.v, ), child: Text( - ingredient.product_name.length > 8 - ? ingredient.product_name.substring(0, 8) - : ingredient.product_name, + ingredient.name.length > 8 ? ingredient.name.substring(0, 8) : ingredient.name, style: CustomTextStyles.titleMedium16, ), ), @@ -374,9 +411,7 @@ class RecipeCreateScreen extends StatelessWidget { bottom: 3.v, ), child: Text( - ingredient.portion.toString() + - ' ' + - ingredient.unit.toString().tr, + ingredient.portion.toString() + ' ' + ingredient.unit.toString().tr, ), ), Spacer(), @@ -395,35 +430,72 @@ class RecipeCreateScreen extends StatelessWidget { ); } + _buildOptions(List _options) { + return (TextEditingValue textEditingValue) { + return _options.where((String option) { + return true; + }); + }; + } + + selectProduct(AutocompleteOnSelected onSelected, String option, RecipeCreateStateLoaded state) { + state.productNameController.text = option; + return () { + onSelected(option); + }; + } + + getAutocomplete(BuildContext context, FocusNode focusNode) { + return (value) { + if (value.length > 2) { + context.read().inputProduct(value); + } + }; + } + + changeType(BuildContext context) { + return (value) { + context.read().changeType(value); + }; + } + + changeStatus(BuildContext context) { + return (value) { + context.read().changeStatus(value); + }; + } + + changeCookingTime(BuildContext context) { + return (value) { + context.read().changeCookingTime(value); + }; + } + RecipeModel createRecipeFromState(RecipeCreateStateLoaded state) { - // Подготовка ингредиентов List ingredients = state.ingredients; - // Подготовка шагов (например, можно создать шаги из stepControllers) List steps = []; for (int i = 0; i < state.stepControllers.length; i++) { if (state.stepControllers[i].text.isNotEmpty) { - steps.add(step.Step(description: state.stepControllers[i].text)); + steps.add(step.Step( + description: state.stepControllers[i].text, + image: state.stepImages[i]?.path, + )); } } - // Подготовка изображения - image.Image pic = image.Image(path: state.recipeImage?.path ?? ''); - - // Создание экземпляра RecipeModel - return RecipeModel( - id: null, + final RecipeModel recipe = RecipeModel( ingredients: ingredients, steps: steps, - state: 'draft', - description: state.titleController.text, - type: state.types.first.value, - image: pic, - video_url: state.youtubeLinkController.text.isNotEmpty - ? state.youtubeLinkController.text - : null, - cooking_time: - state.cookingTimes.isNotEmpty ? state.cookingTimes.first.value : null, + state: state.selectedStatus.value, + type: state.selectedType.value, + cooking_time: state.selectedCookingTime.value, + description: state.stepDescriptionController.text, + title: state.titleController.text, + image: state.recipeImage?.path, + video_url: state.youtubeLinkController.text.isNotEmpty ? state.youtubeLinkController.text : null, ); + print(jsonDecode(jsonEncode(recipe))); + return recipe; } } diff --git a/lib/features/recipes/presentation/pages/recipe_edit_screen.dart b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart new file mode 100644 index 00000000..584a8e79 --- /dev/null +++ b/lib/features/recipes/presentation/pages/recipe_edit_screen.dart @@ -0,0 +1,513 @@ +import 'package:eatvio_app/core/app_export.dart'; +import 'package:eatvio_app/features/diary/models/product.dart'; +import 'package:eatvio_app/features/recipes/models/ingredient.dart'; +import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; +import 'package:eatvio_app/features/recipes/models/step.dart' as step; +import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_cubit.dart'; +import 'package:eatvio_app/features/recipes/presentation/bloc/recipe_create_state.dart'; +import 'package:eatvio_app/widgets/custom_drop_down.dart'; +import 'package:eatvio_app/widgets/custom_text_form_field.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/services.dart'; +import 'package:image_picker/image_picker.dart'; + +// ignore: must_be_immutable +class RecipeEditScreen extends StatelessWidget { + final String recipeID; + const RecipeEditScreen({ + required this.recipeID, + super.key, + }); + Widget build(BuildContext context) { + if (recipeID != "0") { + context.read().loadRecipeById(recipeID); + } + return BlocBuilder( + builder: (context, state) { + if (state is RecipeCreateStateLoaded) { + return _buildRecipeCreate(context, state); + } else if (state is RecipeCreateStateLoading) { + return Scaffold( + body: Center( + child: CupertinoActivityIndicator(), + ), + ); + } else if (state is RecipeCreateStateError) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text(state.errorMessage), + ), + ), + ); + } else + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Text("Неопределенная ошибка"), + ), + ), + ); + }, + ); + } + + Widget _buildRecipeCreate(BuildContext context, RecipeCreateStateLoaded state) { + List _options = state.autocompleteList.map((Product item) => item.name).toList(); + return Scaffold( + appBar: AppBar( + actions: [ + InkWell( + borderRadius: BorderRadius.circular(16), + child: Ink( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(height: 4), + Text( + state.titleController.text, + style: TextStyle( + color: Colors.black, + fontSize: 14, + fontWeight: FontWeight.w400, + height: 1, + ), + ), + ], + ), + ), + ), + ], + ), + backgroundColor: Color.fromARGB(255, 240, 242, 245), + resizeToAvoidBottomInset: true, + body: SizedBox( + width: double.maxFinite, + child: SingleChildScrollView( + child: Column( + children: [ + Container( + padding: EdgeInsets.symmetric( + horizontal: 24, + vertical: 12, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(8)), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Заголовок'), + SizedBox(height: 8), + CustomTextFormField( + fillColor: appTheme.gray50, + controller: state.titleController, + hintText: 'Заголовок', + ), + SizedBox(height: 16), + Text('Тип блюда'), + SizedBox(height: 8), + CustomDropDown( + value: state.selectedType, + items: state.types, + onChanged: changeType(context), + ), + SizedBox(height: 16), + Text('Изображение'), + GestureDetector( + onTap: () async { + final pickedFile = await state.picker.pickImage(source: ImageSource.gallery); + context.read().uploadRecipeImage(pickedFile); + }, + child: state.recipeImage == null + ? Container( + height: 128, + decoration: AppDecoration.fillGray.copyWith( + borderRadius: BorderRadius.circular(16), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.photo_library, + color: appTheme.blueGray300, + ), + SizedBox(width: 8), + Text( + "Добавить фото", + selectionColor: appTheme.blueA400, + ), + ], + ), + ) + : Image.network( + baseUrl + '/storage/' + state.recipeImage!.path, + height: 150, + fit: BoxFit.cover, + ), + ), + SizedBox(height: 16), + Text('Время приготовления'), + SizedBox(height: 8), + CustomDropDown( + items: state.cookingTimes, + value: state.selectedCookingTime, + onChanged: changeCookingTime(context), + ), + SizedBox(height: 16), + Text('Статус'), + SizedBox(height: 8), + CustomDropDown( + items: state.statuses, + value: state.selectedStatus, + onChanged: changeStatus(context), + ), + SizedBox(height: 24), + if (!state.ingredients.isEmpty) + for (int j = 0; j < state.ingredients.length; j++) _buildIngredient(state.ingredients[j]), + SizedBox(height: 24), + RawAutocomplete( + optionsBuilder: _buildOptions(_options), + fieldViewBuilder: ( + BuildContext context, + TextEditingController productEditingController, + FocusNode focusNodeName, + VoidCallback onFieldSubmitted, + ) { + return CustomTextFormField( + hintText: 'Введите название продукта', + controller: TextEditingController(text: state.productNameController.text), + focusNode: focusNodeName, + onChanged: getAutocomplete(context, focusNodeName), + ); + }, + optionsViewBuilder: ( + BuildContext context, + AutocompleteOnSelected onSelected, + Iterable options, + ) { + return Align( + alignment: Alignment.topLeft, + child: Material( + elevation: 4.0, + child: SizedBox( + height: 200.0, + child: ListView.builder( + padding: const EdgeInsets.all(8.0), + itemCount: options.length, + itemBuilder: (BuildContext context, int index) { + final String option = options.elementAt(index); + return GestureDetector( + onTap: selectProduct(onSelected, option, state), + child: ListTile( + title: Text(option), + ), + ); + }, + ), + ), + ), + ); + }, + ), + SizedBox(height: 24), + CustomTextFormField( + hintText: 'Порция', + fillColor: appTheme.gray50, + controller: state.ingredientController, + keyboardType: TextInputType.number, + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + ), + SizedBox(height: 8), + Row(children: [ + Text('гр'), + Switch( + value: state.ingredientAsItems, + onChanged: (bool value) => context.read().switchUnits(value), + activeColor: appTheme.blueA400, + inactiveThumbColor: Colors.grey, + inactiveTrackColor: Colors.grey.shade300, + ), + Text('шт'), + ]), + SizedBox(height: 8), + Container( + height: 48, + width: MediaQuery.of(context).size.width, + child: FloatingActionButton.extended( + highlightElevation: 0, + elevation: 0, + focusElevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + backgroundColor: appTheme.blueA400, + label: Text( + '+', + style: theme.textTheme.titleSmall, + ), + onPressed: () => context.read().addIngredient(new Ingredient( + name: state.productNameController.text, + portion: state.ingredientController.text, + unit: state.ingredientAsItems ? 'pcs' : 'gr'))), + ), + SizedBox(height: 24), + Text('Описание рецепта'), + SizedBox(height: 8), + CustomTextFormField( + maxLines: 8, + minLines: 8, + controller: state.stepDescriptionController, + ), + SizedBox(height: 24), + for (int i = 0; i < state.numberOfSteps; i++) _buildStep(context, i, state), + SizedBox(height: 24), + Container( + height: 48, + width: MediaQuery.of(context).size.width, + child: FloatingActionButton.extended( + highlightElevation: 0, + elevation: 0, + focusElevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + backgroundColor: appTheme.blueA400, + onPressed: () => context.read().addStep(), + label: Text( + '+', + style: theme.textTheme.titleSmall, + ), + ), + ), + SizedBox(height: 8), + Container( + height: 48, + width: MediaQuery.of(context).size.width, + child: FloatingActionButton.extended( + highlightElevation: 0, + elevation: 0, + focusElevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + backgroundColor: Colors.grey, + onPressed: () => context.read().removeStep(), + label: Text( + '-', + style: theme.textTheme.titleSmall, + ), + ), + ), + SizedBox(height: 24), + Text('Ссылка на видео (YouTube)'), + SizedBox(height: 8), + CustomTextFormField( + hintText: 'Введите описание шага', + fillColor: appTheme.gray50, + controller: state.youtubeLinkController, + ), + SizedBox(height: 24), + Container( + height: 48, + width: MediaQuery.of(context).size.width, + child: FloatingActionButton.extended( + highlightElevation: 0, + elevation: 0, + focusElevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + backgroundColor: appTheme.blueA400, + onPressed: () => context.read().editRecipe(createRecipeFromState(state), recipeID), + label: Text( + 'Опубликовать', + style: theme.textTheme.titleSmall, + ), + ), + ), + ], + )), + ], + ), + ), + ), + ); + } + + _buildStep(BuildContext context, int stepNumber, RecipeCreateStateLoaded state) { + print(baseUrl + '/storage/' + state.stepImages[stepNumber]!.path); + return Column( + children: [ + Row(children: [Text('Шаг ${stepNumber + 1}'), Spacer(), Text('Всего шагов: ${state.numberOfSteps}')]), + SizedBox(height: 8), + GestureDetector( + onTap: () async { + final pickedFile = await state.picker.pickImage(source: ImageSource.gallery); + context.read().uploadStepImage(pickedFile, stepNumber); + }, + child: state.stepImages[stepNumber] == null + ? Container( + height: 128, + decoration: AppDecoration.fillGray.copyWith( + borderRadius: BorderRadius.circular(16), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.photo_library, + color: appTheme.blueGray300, + ), + SizedBox(width: 8), + Text( + "Добавить фото", + selectionColor: appTheme.blueA400, + ), + SizedBox(height: 8), + ], + ), + ) + : Image.network( + baseUrl + '/storage/' + state.stepImages[stepNumber]!.path, + height: 150, + fit: BoxFit.cover, + )), + SizedBox(height: 16), + CustomTextFormField( + hintText: 'Введите описание шага', + maxLines: 8, + minLines: 8, + fillColor: appTheme.gray50, + controller: state.stepControllers[stepNumber], + ), + SizedBox(height: 24), + ], + ); + } + + _buildIngredient(Ingredient ingredient) { + return Container( + margin: EdgeInsets.symmetric(horizontal: 10.h), + padding: EdgeInsets.symmetric( + horizontal: 8.h, + vertical: 6.v, + ), + decoration: AppDecoration.fillGray.copyWith( + borderRadius: BorderRadiusStyle.roundedBorder5, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: EdgeInsets.only( + left: 7.h, + top: 5.v, + ), + child: Text( + ingredient.name.length > 8 ? ingredient.name.substring(0, 8) : ingredient.name, + style: CustomTextStyles.titleMedium16, + ), + ), + Padding( + padding: EdgeInsets.only( + left: 20.h, + top: 3.v, + bottom: 3.v, + ), + child: Text( + ingredient.portion.toString() + ' ' + ingredient.unit.toString().tr, + ), + ), + Spacer(), + GestureDetector( + // onTap: removeIngredient(context, ingredient), + child: Padding( + padding: const EdgeInsets.only(right: 10), + child: Icon( + Icons.close, + color: appTheme.blueGray300, + ), + ), + ), + ], + ), + ); + } + + _buildOptions(List _options) { + return (TextEditingValue textEditingValue) { + return _options.where((String option) { + return true; + }); + }; + } + + selectProduct(AutocompleteOnSelected onSelected, String option, RecipeCreateStateLoaded state) { + state.productNameController.text = option; + return () { + onSelected(option); + }; + } + + getAutocomplete(BuildContext context, FocusNode focusNode) { + return (value) { + if (value.length > 2) { + context.read().inputProduct(value); + } + }; + } + + changeType(BuildContext context) { + return (value) { + context.read().changeType(value); + }; + } + + changeStatus(BuildContext context) { + return (value) { + context.read().changeStatus(value); + }; + } + + changeCookingTime(BuildContext context) { + return (value) { + context.read().changeCookingTime(value); + }; + } + + RecipeModel createRecipeFromState(RecipeCreateStateLoaded state) { + List ingredients = state.ingredients; + + List steps = []; + for (int i = 0; i < state.stepControllers.length; i++) { + if (state.stepControllers[i].text.isNotEmpty) { + steps.add(step.Step( + description: state.stepControllers[i].text, + image: state.stepImages[i]?.path, + )); + } + } + + final RecipeModel recipe = RecipeModel( + ingredients: ingredients, + steps: steps, + state: state.selectedStatus.value, + type: state.selectedType.value, + cooking_time: state.selectedCookingTime.value, + description: state.stepDescriptionController.text, + title: state.titleController.text, + image: state.recipeImage?.path, + video_url: state.youtubeLinkController.text.isNotEmpty ? state.youtubeLinkController.text : null, + ); + return recipe; + } +} diff --git a/lib/features/recipes/reporitories/recipe_repository.dart b/lib/features/recipes/reporitories/recipe_repository.dart index 621da2fb..8d2bc57b 100644 --- a/lib/features/recipes/reporitories/recipe_repository.dart +++ b/lib/features/recipes/reporitories/recipe_repository.dart @@ -1,14 +1,43 @@ +import 'dart:convert'; + +import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/services/recipe_service.dart'; +import 'package:eatvio_app/features/diary/models/product.dart'; class RecipeRepository { final RecipeService recipeService; RecipeRepository({required this.recipeService}); - /*Future getRecipe(int recipeID) async { + + Future>> inputProduct(String name) async { try { - return (await recipeService.getRecipe(recipeID)); + return await recipeService.getInputProduct(name); } catch (e) { rethrow; } - }*/ + } + + Future publishRecipe(RecipeModel recipe) async { + try { + return await recipeService.publishRecipe(jsonDecode(jsonEncode(recipe))); + } catch (e) { + rethrow; + } + } + + Future editRecipe(RecipeModel recipe, String id) async { + try { + return await recipeService.editRecipe(jsonDecode(jsonEncode(recipe)), id); + } catch (e) { + rethrow; + } + } + + Future getRecipe(String recipeID) async { + try { + return await recipeService.getRecipe(recipeID); + } catch (e) { + rethrow; + } + } } diff --git a/lib/features/recipes/services/recipe_service.dart b/lib/features/recipes/services/recipe_service.dart index 16b3b890..d68a4e33 100644 --- a/lib/features/recipes/services/recipe_service.dart +++ b/lib/features/recipes/services/recipe_service.dart @@ -1,6 +1,7 @@ import 'package:dio/dio.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:retrofit/retrofit.dart'; +import 'package:eatvio_app/features/diary/models/product.dart'; part 'recipe_service.g.dart'; @@ -8,6 +9,15 @@ part 'recipe_service.g.dart'; abstract class RecipeService { factory RecipeService(Dio dio, {String baseUrl}) = _RecipeService; - @GET('/api/recipe/{id}/show/') - Future> getRecipe(@Path() int id); + @GET('/api/recipes/show/{id}') + Future getRecipe(@Path() String id); + + @GET('/api/diary/product_nutritional_values/filter') + Future>> getInputProduct(@Query('name') String name); + + @POST('/api/recipes/create') + Future publishRecipe(@Part() Map recipe); + + @POST('/api/recipes/update/{id}') + Future editRecipe(@Part() Map recipe, String id); } diff --git a/lib/features/recipes/services/recipe_service.g.dart b/lib/features/recipes/services/recipe_service.g.dart index 04b47319..c28edc26 100644 --- a/lib/features/recipes/services/recipe_service.g.dart +++ b/lib/features/recipes/services/recipe_service.g.dart @@ -12,37 +12,151 @@ class _RecipeService implements RecipeService { _RecipeService( this._dio, { this.baseUrl, + this.errorLogger, }); final Dio _dio; String? baseUrl; + final ParseErrorLogger? errorLogger; + @override - Future> getRecipe(int id) async { + Future getRecipe(String id) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType>(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/recipe/${id}/show/', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - var _value = _result.data!.map((k, dynamic v) => - MapEntry(k, RecipeModel.fromJson(v as Map))); + .compose( + _dio.options, + '/api/recipes/show/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late RecipeModel _value; + try { + _value = RecipeModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future>> getInputProduct(String name) async { + final _extra = {}; + final queryParameters = {r'name': name}; + final _headers = {}; + const Map? _data = null; + final _options = _setStreamType>>(Options( + method: 'GET', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/diary/product_nutritional_values/filter', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map> _value; + try { + _value = _result.data!.map((k, dynamic v) => MapEntry( + k, + (v as List) + .map((i) => Product.fromJson(i as Map)) + .toList())); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future publishRecipe(Map recipe) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = FormData.fromMap(recipe); + final _options = _setStreamType(Options( + method: 'POST', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/recipes/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late RecipeModel _value; + try { + _value = RecipeModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + @override + Future editRecipe( + Map recipe, + String id, + ) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = FormData.fromMap(recipe); + final _options = _setStreamType(Options( + method: 'POST', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/recipes/update/{id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late RecipeModel _value; + try { + _value = RecipeModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/features/registration/services/registration_service.g.dart b/lib/features/registration/services/registration_service.g.dart index 9820fd33..4aaccede 100644 --- a/lib/features/registration/services/registration_service.g.dart +++ b/lib/features/registration/services/registration_service.g.dart @@ -12,12 +12,15 @@ class _RegistrationService implements RegistrationService { _RegistrationService( this._dio, { this.baseUrl, + this.errorLogger, }); final Dio _dio; String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future> register( {required Map sheet}) async { @@ -26,24 +29,30 @@ class _RegistrationService implements RegistrationService { final _headers = {}; final _data = {}; _data.addAll(sheet); - final _result = await _dio.fetch>( - _setStreamType>(Options( + final _options = _setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/register', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = _result.data!.cast(); + .compose( + _dio.options, + '/api/register', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map _value; + try { + _value = _result.data!.cast(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -53,24 +62,30 @@ class _RegistrationService implements RegistrationService { final queryParameters = {r'user_address': query}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/location_by_address', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = LocationModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/location_by_address', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late LocationModel _value; + try { + _value = LocationModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -86,24 +101,30 @@ class _RegistrationService implements RegistrationService { }; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/location_by_coordinate', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = LocationModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/location_by_coordinate', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late LocationModel _value; + try { + _value = LocationModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/main.dart b/lib/main.dart index e1f41274..8a9f334c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -73,7 +73,6 @@ class MyApp extends StatelessWidget { ], child: MaterialApp.router( theme: theme, - title: 'Eatvio', routerConfig: AppRouter.appRouter, debugShowCheckedModeBanner: false, localizationsDelegates: [ @@ -85,7 +84,6 @@ class MyApp extends StatelessWidget { supportedLocales: [ Locale( 'ru', - '', ), ], ), diff --git a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart index 29e47b36..2f7d2cc1 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart @@ -91,7 +91,7 @@ class RecipeSelectScreen extends StatelessWidget { Padding( padding: const EdgeInsets.only(right: 20.0), child: GestureDetector( - onTap: () => GoRouter.of(context).goNamed('recipeCreateScreen'), + onTap: () => GoRouter.of(context).pushNamed('recipeCreateScreen'), child: Icon(Icons.create_outlined), ), ), @@ -155,9 +155,9 @@ class RecipeSelectScreen extends StatelessWidget { extra: post?['id'].toString(), ), trailing: GestureDetector( - onTap: () => GoRouter.of(context).goNamed( + onTap: () => GoRouter.of(context).pushNamed( 'recipeEditScreen', - extra: post?['id'].toString(), + extra: post?['slug'].toString(), ), child: Icon(Icons.edit), ), diff --git a/pubspec.yaml b/pubspec.yaml index 612c9396..02db5422 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,10 +44,13 @@ dependencies: lazy_load_scrollview: ^1.3.0 badges: ^3.1.2 google_fonts: ^6.2.1 - location: ^7.0.0 + location: 6.0.2 syncfusion_flutter_charts: ^26.2.8 table_calendar: ^3.1.2 flutter_keyboard_visibility: ^6.0.0 + share_plus: ^10.0.0 + flutter_html: 3.0.0-beta.2 + file_picker: ^8.1.1 dev_dependencies: build_runner: ^2.4.11