Merge pull request 'recipe_refactor' (#118) from recipe_refactor into main

Reviewed-on: maxxkim/eatvio_app#118
This commit is contained in:
mso7nueh
2024-08-16 14:38:12 +00:00
81 changed files with 3570 additions and 1774 deletions

View File

@@ -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:

View File

@@ -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',

View File

@@ -24,7 +24,6 @@ mixin _$InitializationState {
required TResult Function(String errorMessage) error,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
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;
}

View File

@@ -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<SelectionPopupModel> get copyWith => throw _privateConstructorUsedError;
$SelectionPopupModelCopyWith<SelectionPopupModel> 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;
}

View File

@@ -24,7 +24,6 @@ mixin _$NewMessagesState {
required TResult Function(String errorMessage) error,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
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;
}

View File

@@ -24,7 +24,6 @@ mixin _$NotificationsState {
required TResult Function(String errorMessage) error,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
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;
}

View File

@@ -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<List<CalendarModel>> getCalendar() async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<List<dynamic>>(_setStreamType<List<CalendarModel>>(Options(
final _options = _setStreamType<List<CalendarModel>>(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<String, dynamic>))
.toList();
.compose(
_dio.options,
'/api/calendar/index',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<List<dynamic>>(_options);
late List<CalendarModel> _value;
try {
_value = _result.data!
.map((dynamic i) => CalendarModel.fromJson(i as Map<String, dynamic>))
.toList();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}

View File

@@ -21,28 +21,25 @@ ChatMessageModel _$ChatMessageModelFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$ChatMessageModel {
int get id => throw _privateConstructorUsedError;
String get data => throw _privateConstructorUsedError;
@JsonKey(name: 'media_data')
List<dynamic>? get mediaData => throw _privateConstructorUsedError;
@JsonKey(name: 'author_id')
int get authorId => throw _privateConstructorUsedError;
@JsonKey(name: 'updated_at')
String get updatedAt => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChatMessageModelCopyWith<ChatMessageModel> get copyWith => throw _privateConstructorUsedError;
$ChatMessageModelCopyWith<ChatMessageModel> 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<String, dynamic> json) => _$$ChatMessageModelImplFromJson(json);
factory _$ChatMessageModelImpl.fromJson(Map<String, dynamic> json) =>
_$$ChatMessageModelImplFromJson(json);
@override
final int id;
@override
final String data;
final List<dynamic>? _mediaData;
@override
@JsonKey(name: 'media_data')
List<dynamic>? 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<String, dynamic> 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<dynamic>? 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<dynamic>? mediaData,
@JsonKey(name: 'author_id') required final int authorId,
@JsonKey(name: 'updated_at') required final String updatedAt}) =
_$ChatMessageModelImpl;
factory _ChatMessageModel.fromJson(Map<String, dynamic> json) = _$ChatMessageModelImpl.fromJson;
factory _ChatMessageModel.fromJson(Map<String, dynamic> json) =
_$ChatMessageModelImpl.fromJson;
@override
int get id;
@override
String get data;
@override
@JsonKey(name: 'media_data')
List<dynamic>? 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;
}

View File

@@ -6,7 +6,9 @@ part of 'chat_message_model.dart';
// JsonSerializableGenerator
// **************************************************************************
_$ChatMessageModelImpl _$$ChatMessageModelImplFromJson(Map<String, dynamic> json) => _$ChatMessageModelImpl(
_$ChatMessageModelImpl _$$ChatMessageModelImplFromJson(
Map<String, dynamic> json) =>
_$ChatMessageModelImpl(
id: (json['id'] as num).toInt(),
data: json['data'] as String,
mediaData: json['media_data'] as List<dynamic>?,
@@ -14,7 +16,9 @@ _$ChatMessageModelImpl _$$ChatMessageModelImplFromJson(Map<String, dynamic> json
updatedAt: json['updated_at'] as String,
);
Map<String, dynamic> _$$ChatMessageModelImplToJson(_$ChatMessageModelImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$ChatMessageModelImplToJson(
_$ChatMessageModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'data': instance.data,
'media_data': instance.mediaData,

View File

@@ -24,26 +24,27 @@ mixin _$ChatMetaModel {
int get lastPage => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChatMetaModelCopyWith<ChatMetaModel> get copyWith => throw _privateConstructorUsedError;
$ChatMetaModelCopyWith<ChatMetaModel> 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<String, dynamic> json) => _$$ChatMetaModelImplFromJson(json);
factory _$ChatMetaModelImpl.fromJson(Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> json) = _$ChatMetaModelImpl.fromJson;
factory _ChatMetaModel.fromJson(Map<String, dynamic> 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;
}

View File

@@ -6,10 +6,12 @@ part of 'chat_meta_model.dart';
// JsonSerializableGenerator
// **************************************************************************
_$ChatMetaModelImpl _$$ChatMetaModelImplFromJson(Map<String, dynamic> json) => _$ChatMetaModelImpl(
_$ChatMetaModelImpl _$$ChatMetaModelImplFromJson(Map<String, dynamic> json) =>
_$ChatMetaModelImpl(
lastPage: (json['last_page'] as num).toInt(),
);
Map<String, dynamic> _$$ChatMetaModelImplToJson(_$ChatMetaModelImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$ChatMetaModelImplToJson(_$ChatMetaModelImpl instance) =>
<String, dynamic>{
'last_page': instance.lastPage,
};

View File

@@ -21,35 +21,39 @@ ChatRoomModel _$ChatRoomModelFromJson(Map<String, dynamic> 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<String, ChatUserModel> get users => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChatRoomModelCopyWith<ChatRoomModel> get copyWith => throw _privateConstructorUsedError;
$ChatRoomModelCopyWith<ChatRoomModel> 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<String, ChatUserModel> users});
$Res call(
{String id,
@JsonKey(name: 'chat_room_setting')
ChatRoomSettingsModel chatRoomSettings,
Map<String, ChatUserModel> 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<String, ChatUserModel> users});
$Res call(
{String id,
@JsonKey(name: 'chat_room_setting')
ChatRoomSettingsModel chatRoomSettings,
Map<String, ChatUserModel> 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<String, ChatUserModel> users})
{required this.id,
@JsonKey(name: 'chat_room_setting') required this.chatRoomSettings,
required final Map<String, ChatUserModel> users})
: _users = users;
factory _$ChatRoomModelImpl.fromJson(Map<String, dynamic> json) => _$$ChatRoomModelImplFromJson(json);
factory _$ChatRoomModelImpl.fromJson(Map<String, dynamic> 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<String, ChatUserModel> _users;
@override
Map<String, ChatUserModel> 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<String, dynamic> 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<String, ChatUserModel> users}) = _$ChatRoomModelImpl;
factory _ChatRoomModel.fromJson(Map<String, dynamic> json) = _$ChatRoomModelImpl.fromJson;
factory _ChatRoomModel.fromJson(Map<String, dynamic> json) =
_$ChatRoomModelImpl.fromJson;
@override
String get id;
@override
@JsonKey(name: 'chat_room_setting')
ChatRoomSettingsModel get chatRoomSettings;
@override
Map<String, ChatUserModel> get users;
@override
@JsonKey(ignore: true)
_$$ChatRoomModelImplCopyWith<_$ChatRoomModelImpl> get copyWith => throw _privateConstructorUsedError;
_$$ChatRoomModelImplCopyWith<_$ChatRoomModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -6,15 +6,19 @@ part of 'chat_room_model.dart';
// JsonSerializableGenerator
// **************************************************************************
_$ChatRoomModelImpl _$$ChatRoomModelImplFromJson(Map<String, dynamic> json) => _$ChatRoomModelImpl(
_$ChatRoomModelImpl _$$ChatRoomModelImplFromJson(Map<String, dynamic> json) =>
_$ChatRoomModelImpl(
id: json['id'] as String,
chatRoomSettings: ChatRoomSettingsModel.fromJson(json['chat_room_setting'] as Map<String, dynamic>),
chatRoomSettings: ChatRoomSettingsModel.fromJson(
json['chat_room_setting'] as Map<String, dynamic>),
users: (json['users'] as Map<String, dynamic>).map(
(k, e) => MapEntry(k, ChatUserModel.fromJson(e as Map<String, dynamic>)),
(k, e) =>
MapEntry(k, ChatUserModel.fromJson(e as Map<String, dynamic>)),
),
);
Map<String, dynamic> _$$ChatRoomModelImplToJson(_$ChatRoomModelImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$ChatRoomModelImplToJson(_$ChatRoomModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'chat_room_setting': instance.chatRoomSettings,
'users': instance.users,

View File

@@ -14,36 +14,33 @@ T _$identity<T>(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<String, dynamic> json) {
ChatRoomSettingsModel _$ChatRoomSettingsModelFromJson(
Map<String, dynamic> 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<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChatRoomSettingsModelCopyWith<ChatRoomSettingsModel> get copyWith => throw _privateConstructorUsedError;
$ChatRoomSettingsModelCopyWith<ChatRoomSettingsModel> 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<String, dynamic> json) => _$$ChatRoomSettingsModelImplFromJson(json);
factory _$ChatRoomSettingsModelImpl.fromJson(Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> json) = _$ChatRoomSettingsModelImpl.fromJson;
factory _ChatRoomSettingsModel.fromJson(Map<String, dynamic> 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;
}

View File

@@ -6,7 +6,9 @@ part of 'chat_room_settings_model.dart';
// JsonSerializableGenerator
// **************************************************************************
_$ChatRoomSettingsModelImpl _$$ChatRoomSettingsModelImplFromJson(Map<String, dynamic> json) => _$ChatRoomSettingsModelImpl(
_$ChatRoomSettingsModelImpl _$$ChatRoomSettingsModelImplFromJson(
Map<String, dynamic> 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<String, dyn
updatedAt: json['updated_at'] as String,
);
Map<String, dynamic> _$$ChatRoomSettingsModelImplToJson(_$ChatRoomSettingsModelImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$ChatRoomSettingsModelImplToJson(
_$ChatRoomSettingsModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'room_name': instance.roomName,
'state': instance.state,

View File

@@ -21,36 +21,38 @@ ChatUserModel _$ChatUserModelFromJson(Map<String, dynamic> 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<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ChatUserModelCopyWith<ChatUserModel> get copyWith => throw _privateConstructorUsedError;
$ChatUserModelCopyWith<ChatUserModel> 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<String, dynamic> json) => _$$ChatUserModelImplFromJson(json);
factory _$ChatUserModelImpl.fromJson(Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> json) = _$ChatUserModelImpl.fromJson;
factory _ChatUserModel.fromJson(Map<String, dynamic> 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;
}

View File

@@ -6,14 +6,16 @@ part of 'chat_user_model.dart';
// JsonSerializableGenerator
// **************************************************************************
_$ChatUserModelImpl _$$ChatUserModelImplFromJson(Map<String, dynamic> json) => _$ChatUserModelImpl(
_$ChatUserModelImpl _$$ChatUserModelImplFromJson(Map<String, dynamic> 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<String, dynamic> _$$ChatUserModelImplToJson(_$ChatUserModelImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$ChatUserModelImplToJson(_$ChatUserModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'profile_photo_path': instance.profilePhotoPath,

View File

@@ -21,38 +21,39 @@ WebsocketInfoModel _$WebsocketInfoModelFromJson(Map<String, dynamic> 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<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$WebsocketInfoModelCopyWith<WebsocketInfoModel> get copyWith => throw _privateConstructorUsedError;
$WebsocketInfoModelCopyWith<WebsocketInfoModel> 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<String, dynamic> json) => _$$WebsocketInfoModelImplFromJson(json);
factory _$WebsocketInfoModelImpl.fromJson(Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> json) = _$WebsocketInfoModelImpl.fromJson;
factory _WebsocketInfoModel.fromJson(Map<String, dynamic> 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;
}

View File

@@ -6,7 +6,9 @@ part of 'websocket_info_model.dart';
// JsonSerializableGenerator
// **************************************************************************
_$WebsocketInfoModelImpl _$$WebsocketInfoModelImplFromJson(Map<String, dynamic> json) => _$WebsocketInfoModelImpl(
_$WebsocketInfoModelImpl _$$WebsocketInfoModelImplFromJson(
Map<String, dynamic> json) =>
_$WebsocketInfoModelImpl(
key: json['key'] as String,
host: json['host'] as String,
port: json['port'] as String,
@@ -14,7 +16,9 @@ _$WebsocketInfoModelImpl _$$WebsocketInfoModelImplFromJson(Map<String, dynamic>
userId: (json['user_id'] as num).toInt(),
);
Map<String, dynamic> _$$WebsocketInfoModelImplToJson(_$WebsocketInfoModelImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$WebsocketInfoModelImplToJson(
_$WebsocketInfoModelImpl instance) =>
<String, dynamic>{
'key': instance.key,
'host': instance.host,
'port': instance.port,

View File

@@ -98,6 +98,7 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
privateChatChannel.subscribe();
privateChatChannel.bind('App\\Events\\ChatMessageUpdated').listen((event) {
print(jsonDecode(event.data));
List<ChatMessageModel> messagesList = [
ChatMessageModel.fromJson(jsonDecode(event.data)['message']),
...(state as ChatRoomStateLoaded).chatMessages,
@@ -138,10 +139,14 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
sendMessage({
required String chatId,
required String data,
required List<File> filesList,
String? data,
List<File>? files,
}) async {
await chatRepository.sendMessage(chatId: chatId, data: data);
await chatRepository.sendMessage(
chatId: chatId,
data: data,
files: files,
);
}
@override

View File

@@ -20,16 +20,19 @@ mixin _$ChatRoomState {
TResult when<TResult extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading) loaded,
required TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)
loaded,
required TResult Function(String errorMessage) error,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult? Function(ChatRoomModel chatRoom,
List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)?
loaded,
TResult? Function(String errorMessage)? error,
}) =>
throw _privateConstructorUsedError;
@@ -37,7 +40,9 @@ mixin _$ChatRoomState {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading) loaded,
required TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult? Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading) loaded,
required TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult? Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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<ChatMessageModel> chatMessages, bool isTyping, bool isLoading});
$Res call(
{ChatRoomModel chatRoom,
List<ChatMessageModel> 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<ChatMessageModel> chatMessages, required this.isTyping, required this.isLoading})
const _$ChatRoomStateLoadedImpl(
{required this.chatRoom,
required final List<ChatMessageModel> chatMessages,
required this.isTyping,
required this.isLoading})
: _chatMessages = chatMessages;
@override
final ChatRoomModel chatRoom;
final List<ChatMessageModel> _chatMessages;
@override
List<ChatMessageModel> 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 extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading) loaded,
required TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult? Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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<ChatMessageModel> 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 extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading) loaded,
required TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult? Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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 extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ChatRoomModel chatRoom, List<ChatMessageModel> chatMessages, bool isTyping, bool isLoading)? loaded,
TResult Function(ChatRoomModel chatRoom,
List<ChatMessageModel> 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;
}

View File

@@ -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<ChatScreen> {
(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<ChatScreen> {
),
),
),
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<ChatRoomCubit>().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<ChatScreen> {
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<ChatScreen> {
context.read<ChatRoomCubit>().sendMessage(
chatId: widget.chatId,
data: textEditingController.text.trim(),
filesList: [],
);
setState(() {
textEditingController.clear();

View File

@@ -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<dynamic> mediaData;

View File

@@ -15,13 +15,13 @@ class ChatRepository {
Future<void> sendMessage({
required String chatId,
String? data,
List<File>? filesList,
List<File>? files,
}) async {
try {
await chatService.sendMessage(
id: chatId,
data: data,
filesList: filesList,
media_data: files,
);
} catch (e) {
print(e);

View File

@@ -18,10 +18,11 @@ abstract class ChatService {
});
@POST('/api/chat/{id}/message/send')
@MultiPart()
Future<void> sendMessage({
@Path() required String id,
@Part() String? data,
@Part() List<File>? filesList,
@Part() List<File>? media_data,
});
@GET('/api/chat/show/{id}/messages?page={page}')

View File

@@ -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<Map<String, ChatRoomModel>> getChatRoom({required String id}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<Map<String, ChatRoomModel>>(Options(
final _options = _setStreamType<Map<String, ChatRoomModel>>(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<String, dynamic>)));
.compose(
_dio.options,
'/api/chat/show/${id}',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, ChatRoomModel> _value;
try {
_value = _result.data!.map((k, dynamic v) =>
MapEntry(k, ChatRoomModel.fromJson(v as Map<String, dynamic>)));
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@@ -50,7 +59,7 @@ class _ChatService implements ChatService {
Future<void> sendMessage({
required String id,
String? data,
List<File>? filesList,
List<File>? media_data,
}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
@@ -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<void>(_setStreamType<void>(Options(
final _options = _setStreamType<void>(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<void>(_options);
}
@override
@@ -98,24 +109,30 @@ class _ChatService implements ChatService {
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<ChatMessagesModel>(Options(
final _options = _setStreamType<ChatMessagesModel>(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<Map<String, dynamic>>(_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 = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<WebsocketInfoModel>(Options(
final _options = _setStreamType<WebsocketInfoModel>(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<Map<String, dynamic>>(_options);
late WebsocketInfoModel _value;
try {
_value = WebsocketInfoModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}

View File

@@ -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<Meal> meals,
required State state,
String? comment,
DateTime? wakeup,
DateTime? retire,

View File

@@ -24,6 +24,7 @@ mixin _$DiaryModel {
DateTime get date => throw _privateConstructorUsedError;
int get closed => throw _privateConstructorUsedError;
List<Meal> 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<Meal> 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<Meal>,
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<Meal> 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<Meal>,
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<Meal> 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<Meal> 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<Meal> get meals;
@override
State get state;
@override
String? get comment;
@override
DateTime? get wakeup;

View File

@@ -14,6 +14,7 @@ _$DiaryModelImpl _$$DiaryModelImplFromJson(Map<String, dynamic> json) =>
meals: (json['meals'] as List<dynamic>)
.map((e) => Meal.fromJson(e as Map<String, dynamic>))
.toList(),
state: State.fromJson(json['state'] as Map<String, dynamic>),
comment: json['comment'] as String?,
wakeup: json['wakeup'] == null
? null
@@ -29,6 +30,7 @@ Map<String, dynamic> _$$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(),

View File

@@ -21,33 +21,33 @@ Photo _$PhotoFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$Photo {
int get id => throw _privateConstructorUsedError;
@JsonKey(name: 'original_name')
String get originalName => throw _privateConstructorUsedError;
String get path => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$PhotoCopyWith<Photo> 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<String, dynamic> json) => _$$PhotoImplFromJson(json);
factory _$PhotoImpl.fromJson(Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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;
}

View File

@@ -12,7 +12,8 @@ _$PhotoImpl _$$PhotoImplFromJson(Map<String, dynamic> json) => _$PhotoImpl(
path: json['path'] as String,
);
Map<String, dynamic> _$$PhotoImplToJson(_$PhotoImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$PhotoImplToJson(_$PhotoImpl instance) =>
<String, dynamic>{
'id': instance.id,
'original_name': instance.originalName,
'path': instance.path,

View File

@@ -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<String, Object?> json) => _$PortionFromJson(json);

View File

@@ -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<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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;

View File

@@ -12,6 +12,7 @@ _$PortionImpl _$$PortionImplFromJson(Map<String, dynamic> 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<String, dynamic> _$$PortionImplToJson(_$PortionImpl instance) =>
@@ -20,4 +21,5 @@ Map<String, dynamic> _$$PortionImplToJson(_$PortionImpl instance) =>
'product_name': instance.product_name,
'quantity': instance.quantity,
'portion': instance.portion,
'from_diet': instance.from_diet,
};

View File

@@ -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<String, Object?> json) => _$StateFromJson(json);
}

View File

@@ -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>(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<String, dynamic> json) {
return _State.fromJson(json);
}
/// @nodoc
mixin _$State {
bool get has_chosen_diet => throw _privateConstructorUsedError;
bool get has_chosen_plan => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$StateCopyWith<State> 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<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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;
}

View File

@@ -0,0 +1,18 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'state.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$StateImpl _$$StateImplFromJson(Map<String, dynamic> json) => _$StateImpl(
has_chosen_diet: json['has_chosen_diet'] as bool,
has_chosen_plan: json['has_chosen_plan'] as bool,
);
Map<String, dynamic> _$$StateImplToJson(_$StateImpl instance) =>
<String, dynamic>{
'has_chosen_diet': instance.has_chosen_diet,
'has_chosen_plan': instance.has_chosen_plan,
};

View File

@@ -42,6 +42,7 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
on<FinishDay>(_finishDay);
on<SendModeration>(_sendModeration);
on<ClearInput>(_clearInput);
on<ConfirmPortion>(_confirmPortion);
}
loadDiary(
@@ -329,7 +330,6 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
) 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<DiaryEvent, DiaryState> {
SelectionPopupModel(id: 1, title: "грамм"),
];
}
FutureOr<void> _confirmPortion(ConfirmPortion event, Emitter<DiaryState> 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) {

View File

@@ -180,6 +180,14 @@ class RefreshEvent extends DiaryEvent {
List<Object?> get props => [];
}
class ConfirmPortion extends DiaryEvent {
ConfirmPortion(this.id);
int id;
@override
List<Object?> get props => [id];
}
class SendModeration extends DiaryEvent {
SendModeration({
required this.name,

View File

@@ -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)),
// Добавьте другие детали о продукте по необходимости
],
),

View File

@@ -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<DiaryBloc>().add(AddPortionEvent());
};
context.read<DiaryBloc>().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<String> _options =
state.autocompleteList.map((Product item) => item.name).toList();
List<String> _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<String> onSelected, String option,
DiaryStateLoaded state) {
selectProduct(AutocompleteOnSelected<String> 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<DiaryBloc>().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<DiaryBloc>()
.add(RemoveImageEvent(photo.id.toString(), photo.path));
context.read<DiaryBloc>().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<DiaryBloc>().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<void> _selectWakeupTime(
BuildContext context, DiaryStateLoaded state) async {
Future<void> _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<void> _selectRetireTime(
BuildContext context, DiaryStateLoaded state) async {
Future<void> _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<void> _selectMealTime(
BuildContext context, DiaryStateLoaded state) async {
Future<void> _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<int> recommendedValues, List<int> consumedValues) {
bool checkConsumedValues(List<int> recommendedValues, List<int> consumedValues) {
for (int i = 0; i < recommendedValues.length; i++) {
if (consumedValues[i] > recommendedValues[i]) {
// Если хотя бы одно потребленное значение превышает рекомендованное

View File

@@ -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<Map<String, int>> getDiaryID() async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<Map<String, int>>(Options(
final _options = _setStreamType<Map<String, int>>(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<String, int>();
.compose(
_dio.options,
'/api/diary/index',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, int> _value;
try {
_value = _result.data!.cast<String, int>();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@@ -51,25 +60,31 @@ class _DiaryService implements DiaryService {
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<Map<String, DiaryModel>>(Options(
final _options = _setStreamType<Map<String, DiaryModel>>(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<String, dynamic>)));
.compose(
_dio.options,
'/api/diary/${id}/show/',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, DiaryModel> _value;
try {
_value = _result.data!.map((k, dynamic v) =>
MapEntry(k, DiaryModel.fromJson(v as Map<String, dynamic>)));
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@@ -79,7 +94,7 @@ class _DiaryService implements DiaryService {
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch(_setStreamType<dynamic>(Options(
final _options = _setStreamType<dynamic>(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 = <String, dynamic>{r'name': name};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<Map<String, List<Product>>>(Options(
final _options = _setStreamType<Map<String, List<Product>>>(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<String, dynamic>))
.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<Map<String, dynamic>>(_options);
late Map<String, List<Product>> _value;
try {
_value = _result.data!.map((k, dynamic v) => MapEntry(
k,
(v as List)
.map((i) => Product.fromJson(i as Map<String, dynamic>))
.toList()));
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@@ -140,24 +162,30 @@ class _DiaryService implements DiaryService {
final queryParameters = <String, dynamic>{r'satiety': satiety};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<Map<String, int>>(Options(
final _options = _setStreamType<Map<String, int>>(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<String, int>();
.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<Map<String, dynamic>>(_options);
late Map<String, int> _value;
try {
_value = _result.data!.cast<String, int>();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@@ -171,24 +199,30 @@ class _DiaryService implements DiaryService {
final queryParameters = <String, dynamic>{r'mood': mood};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<Map<String, int>>(Options(
final _options = _setStreamType<Map<String, int>>(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<String, int>();
.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<Map<String, dynamic>>(_options);
late Map<String, int> _value;
try {
_value = _result.data!.cast<String, int>();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@@ -201,24 +235,30 @@ class _DiaryService implements DiaryService {
final queryParameters = <String, dynamic>{r'wakeup': wakeup};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<DiaryModel>(Options(
final _options = _setStreamType<DiaryModel>(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<Map<String, dynamic>>(_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 = <String, dynamic>{r'retire': retire};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<DiaryModel>(Options(
final _options = _setStreamType<DiaryModel>(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<Map<String, dynamic>>(_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 = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<Map<String, Portion>>(Options(
final _options = _setStreamType<Map<String, Portion>>(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<String, dynamic>)));
.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<Map<String, dynamic>>(_options);
late Map<String, Portion> _value;
try {
_value = _result.data!.map((k, dynamic v) =>
MapEntry(k, Portion.fromJson(v as Map<String, dynamic>)));
} 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<void>(_setStreamType<void>(Options(
final _options = _setStreamType<void>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
@@ -322,7 +374,8 @@ class _DiaryService implements DiaryService {
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
))));
)));
await _dio.fetch<void>(_options);
}
@override
@@ -343,24 +396,30 @@ class _DiaryService implements DiaryService {
};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<Map<String, String>>(Options(
final _options = _setStreamType<Map<String, String>>(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<String, String>();
.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<Map<String, dynamic>>(_options);
late Map<String, String> _value;
try {
_value = _result.data!.cast<String, String>();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@@ -370,7 +429,7 @@ class _DiaryService implements DiaryService {
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
await _dio.fetch<void>(_setStreamType<void>(Options(
final _options = _setStreamType<void>(Options(
method: 'POST',
headers: _headers,
extra: _extra,
@@ -385,7 +444,8 @@ class _DiaryService implements DiaryService {
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
))));
)));
await _dio.fetch<void>(_options);
}
@override
@@ -398,7 +458,7 @@ class _DiaryService implements DiaryService {
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
await _dio.fetch<void>(_setStreamType<void>(Options(
final _options = _setStreamType<void>(Options(
method: 'DELETE',
headers: _headers,
extra: _extra,
@@ -413,7 +473,8 @@ class _DiaryService implements DiaryService {
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
))));
)));
await _dio.fetch<void>(_options);
}
@override
@@ -430,7 +491,7 @@ class _DiaryService implements DiaryService {
};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
await _dio.fetch<void>(_setStreamType<void>(Options(
final _options = _setStreamType<void>(Options(
method: 'DELETE',
headers: _headers,
extra: _extra,
@@ -445,7 +506,8 @@ class _DiaryService implements DiaryService {
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
))));
)));
await _dio.fetch<void>(_options);
}
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {

File diff suppressed because it is too large Load Diff

View File

@@ -6,13 +6,19 @@ part of 'diets_pagination_model.dart';
// JsonSerializableGenerator
// **************************************************************************
_$DietsPaginationImpl _$$DietsPaginationImplFromJson(Map<String, dynamic> json) => _$DietsPaginationImpl(
data: (json['data'] as List<dynamic>).map((e) => Datum.fromJson(e as Map<String, dynamic>)).toList(),
_$DietsPaginationImpl _$$DietsPaginationImplFromJson(
Map<String, dynamic> json) =>
_$DietsPaginationImpl(
data: (json['data'] as List<dynamic>)
.map((e) => Datum.fromJson(e as Map<String, dynamic>))
.toList(),
links: Links.fromJson(json['links'] as Map<String, dynamic>),
meta: Meta.fromJson(json['meta'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$DietsPaginationImplToJson(_$DietsPaginationImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$DietsPaginationImplToJson(
_$DietsPaginationImpl instance) =>
<String, dynamic>{
'data': instance.data,
'links': instance.links,
'meta': instance.meta,
@@ -27,7 +33,11 @@ _$DatumImpl _$$DatumImplFromJson(Map<String, dynamic> json) => _$DatumImpl(
type: Type.fromJson(json['type'] as Map<String, dynamic>),
details: json['details'] as String,
dailySchedule: (json['daily_schedule'] as List<dynamic>)
.map((e) => (e as List<dynamic>).map((e) => (e as List<dynamic>).map((e) => DailySchedule.fromJson(e as Map<String, dynamic>)).toList()).toList())
.map((e) => (e as List<dynamic>)
.map((e) => (e as List<dynamic>)
.map((e) => DailySchedule.fromJson(e as Map<String, dynamic>))
.toList())
.toList())
.toList(),
author: Author.fromJson(json['author'] as Map<String, dynamic>),
totalLikes: (json['total_likes'] as num).toInt(),
@@ -35,7 +45,8 @@ _$DatumImpl _$$DatumImplFromJson(Map<String, dynamic> json) => _$DatumImpl(
totalComments: (json['total_comments'] as num).toInt(),
);
Map<String, dynamic> _$$DatumImplToJson(_$DatumImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$DatumImplToJson(_$DatumImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'image': instance.image,
@@ -57,21 +68,24 @@ _$AuthorImpl _$$AuthorImplFromJson(Map<String, dynamic> json) => _$AuthorImpl(
authorIsMe: json['author_is_me'] as bool,
);
Map<String, dynamic> _$$AuthorImplToJson(_$AuthorImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$AuthorImplToJson(_$AuthorImpl instance) =>
<String, dynamic>{
'author_slug': instance.authorSlug,
'author_name': instance.authorName,
'author_profile_icon': instance.authorProfileIcon,
'author_is_me': instance.authorIsMe,
};
_$DailyScheduleImpl _$$DailyScheduleImplFromJson(Map<String, dynamic> json) => _$DailyScheduleImpl(
_$DailyScheduleImpl _$$DailyScheduleImplFromJson(Map<String, dynamic> json) =>
_$DailyScheduleImpl(
name: json['name'] as String,
uniq: json['uniq'] as String,
portion: $enumDecode(_$PortionEnumMap, json['portion']),
quantity: (json['quantity'] as num).toInt(),
);
Map<String, dynamic> _$$DailyScheduleImplToJson(_$DailyScheduleImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$DailyScheduleImplToJson(_$DailyScheduleImpl instance) =>
<String, dynamic>{
'name': instance.name,
'uniq': instance.uniq,
'portion': _$PortionEnumMap[instance.portion]!,
@@ -91,7 +105,8 @@ _$TypeImpl _$$TypeImplFromJson(Map<String, dynamic> json) => _$TypeImpl(
meat: json['meat'] as bool?,
);
Map<String, dynamic> _$$TypeImplToJson(_$TypeImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$TypeImplToJson(_$TypeImpl instance) =>
<String, dynamic>{
'alko': instance.alko,
'veg': instance.veg,
'corb': instance.corb,
@@ -105,7 +120,8 @@ _$LinksImpl _$$LinksImplFromJson(Map<String, dynamic> json) => _$LinksImpl(
next: json['next'],
);
Map<String, dynamic> _$$LinksImplToJson(_$LinksImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$LinksImplToJson(_$LinksImpl instance) =>
<String, dynamic>{
'first': instance.first,
'last': instance.last,
'prev': instance.prev,
@@ -116,14 +132,17 @@ _$MetaImpl _$$MetaImplFromJson(Map<String, dynamic> 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<dynamic>).map((e) => Link.fromJson(e as Map<String, dynamic>)).toList(),
links: (json['links'] as List<dynamic>)
.map((e) => Link.fromJson(e as Map<String, dynamic>))
.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<String, dynamic> _$$MetaImplToJson(_$MetaImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$MetaImplToJson(_$MetaImpl instance) =>
<String, dynamic>{
'current_page': instance.currentPage,
'from': instance.from,
'last_page': instance.lastPage,
@@ -140,7 +159,8 @@ _$LinkImpl _$$LinkImplFromJson(Map<String, dynamic> json) => _$LinkImpl(
active: json['active'] as bool,
);
Map<String, dynamic> _$$LinkImplToJson(_$LinkImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$LinkImplToJson(_$LinkImpl instance) =>
<String, dynamic>{
'url': instance.url,
'label': instance.label,
'active': instance.active,

View File

@@ -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<FeedBlogPostModel> feedBlogPostList,
required Meta meta,
}) = _FeedBlogPostSettingsModel;
factory FeedBlogPostSettingsModel.fromJson(Map<String, Object?> json) => _$FeedBlogPostSettingsModelFromJson(json);

View File

@@ -24,6 +24,7 @@ mixin _$FeedBlogPostSettingsModel {
@JsonKey(name: 'data')
List<FeedBlogPostModel> get feedBlogPostList =>
throw _privateConstructorUsedError;
Meta get meta => throw _privateConstructorUsedError;
Map<String, dynamic> 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<FeedBlogPostModel> feedBlogPostList});
$Res call(
{@JsonKey(name: 'data') List<FeedBlogPostModel> 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<FeedBlogPostModel>,
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<FeedBlogPostModel> feedBlogPostList});
$Res call(
{@JsonKey(name: 'data') List<FeedBlogPostModel> 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<FeedBlogPostModel>,
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<FeedBlogPostModel> feedBlogPostList})
required final List<FeedBlogPostModel> feedBlogPostList,
required this.meta})
: _feedBlogPostList = feedBlogPostList;
factory _$FeedBlogPostSettingsModelImpl.fromJson(Map<String, dynamic> 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<FeedBlogPostModel> feedBlogPostList}) =
_$FeedBlogPostSettingsModelImpl;
{@JsonKey(name: 'data')
required final List<FeedBlogPostModel> feedBlogPostList,
required final Meta meta}) = _$FeedBlogPostSettingsModelImpl;
factory _FeedBlogPostSettingsModel.fromJson(Map<String, dynamic> json) =
_$FeedBlogPostSettingsModelImpl.fromJson;
@@ -169,6 +202,8 @@ abstract class _FeedBlogPostSettingsModel implements FeedBlogPostSettingsModel {
@JsonKey(name: 'data')
List<FeedBlogPostModel> get feedBlogPostList;
@override
Meta get meta;
@override
@JsonKey(ignore: true)
_$$FeedBlogPostSettingsModelImplCopyWith<_$FeedBlogPostSettingsModelImpl>
get copyWith => throw _privateConstructorUsedError;

View File

@@ -12,10 +12,12 @@ _$FeedBlogPostSettingsModelImpl _$$FeedBlogPostSettingsModelImplFromJson(
feedBlogPostList: (json['data'] as List<dynamic>)
.map((e) => FeedBlogPostModel.fromJson(e as Map<String, dynamic>))
.toList(),
meta: Meta.fromJson(json['meta'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$FeedBlogPostSettingsModelImplToJson(
_$FeedBlogPostSettingsModelImpl instance) =>
<String, dynamic>{
'data': instance.feedBlogPostList,
'meta': instance.meta,
};

View File

@@ -24,7 +24,6 @@ mixin _$DietsState {
required TResult Function(String errorMessage) error,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
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;
}

View File

@@ -4,15 +4,47 @@ import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
class FeedCubit extends Cubit<FeedState> {
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');
}
}
}

View File

@@ -11,6 +11,7 @@ abstract class FeedState with _$FeedState {
const factory FeedState.loaded({
required List<FeedBlogPostModel> feedBlogPostList,
required bool isLoading,
}) = FeedStateLoaded;
const factory FeedState.error({

View File

@@ -20,7 +20,9 @@ mixin _$FeedState {
TResult when<TResult extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<FeedBlogPostModel> feedBlogPostList) loaded,
required TResult Function(
List<FeedBlogPostModel> feedBlogPostList, bool isLoading)
loaded,
required TResult Function(String errorMessage) error,
}) =>
throw _privateConstructorUsedError;
@@ -28,7 +30,8 @@ mixin _$FeedState {
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult? Function(List<FeedBlogPostModel> feedBlogPostList, bool isLoading)?
loaded,
TResult? Function(String errorMessage)? error,
}) =>
throw _privateConstructorUsedError;
@@ -36,7 +39,8 @@ mixin _$FeedState {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult Function(List<FeedBlogPostModel> feedBlogPostList, bool isLoading)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) =>
@@ -125,7 +129,9 @@ class _$FeedStateImpl implements _FeedState {
TResult when<TResult extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<FeedBlogPostModel> feedBlogPostList) loaded,
required TResult Function(
List<FeedBlogPostModel> feedBlogPostList, bool isLoading)
loaded,
required TResult Function(String errorMessage) error,
}) {
return $default();
@@ -136,7 +142,8 @@ class _$FeedStateImpl implements _FeedState {
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult? Function(List<FeedBlogPostModel> feedBlogPostList, bool isLoading)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
return $default?.call();
@@ -147,7 +154,8 @@ class _$FeedStateImpl implements _FeedState {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult Function(List<FeedBlogPostModel> feedBlogPostList, bool isLoading)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) {
@@ -239,7 +247,9 @@ class _$FeedStateLoadingImpl implements FeedStateLoading {
TResult when<TResult extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<FeedBlogPostModel> feedBlogPostList) loaded,
required TResult Function(
List<FeedBlogPostModel> feedBlogPostList, bool isLoading)
loaded,
required TResult Function(String errorMessage) error,
}) {
return loading();
@@ -250,7 +260,8 @@ class _$FeedStateLoadingImpl implements FeedStateLoading {
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult? Function(List<FeedBlogPostModel> feedBlogPostList, bool isLoading)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
return loading?.call();
@@ -261,7 +272,8 @@ class _$FeedStateLoadingImpl implements FeedStateLoading {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult Function(List<FeedBlogPostModel> 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<FeedBlogPostModel> feedBlogPostList});
$Res call({List<FeedBlogPostModel> 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<FeedBlogPostModel>,
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<FeedBlogPostModel> feedBlogPostList})
{required final List<FeedBlogPostModel> feedBlogPostList,
required this.isLoading})
: _feedBlogPostList = feedBlogPostList;
final List<FeedBlogPostModel> _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 extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<FeedBlogPostModel> feedBlogPostList) loaded,
required TResult Function(
List<FeedBlogPostModel> 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 extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult? Function(List<FeedBlogPostModel> 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 extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult Function(List<FeedBlogPostModel> 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<FeedBlogPostModel> feedBlogPostList}) =
_$FeedStateLoadedImpl;
{required final List<FeedBlogPostModel> feedBlogPostList,
required final bool isLoading}) = _$FeedStateLoadedImpl;
List<FeedBlogPostModel> 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 extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<FeedBlogPostModel> feedBlogPostList) loaded,
required TResult Function(
List<FeedBlogPostModel> feedBlogPostList, bool isLoading)
loaded,
required TResult Function(String errorMessage) error,
}) {
return error(errorMessage);
@@ -550,7 +580,8 @@ class _$FeedStateErrorImpl implements FeedStateError {
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult? Function(List<FeedBlogPostModel> feedBlogPostList, bool isLoading)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
return error?.call(errorMessage);
@@ -561,7 +592,8 @@ class _$FeedStateErrorImpl implements FeedStateError {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<FeedBlogPostModel> feedBlogPostList)? loaded,
TResult Function(List<FeedBlogPostModel> feedBlogPostList, bool isLoading)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) {

View File

@@ -94,6 +94,7 @@ class _FeedScreenState extends State<FeedScreen> {
);
} 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<FeedScreen> {
);
} else {
return Scaffold(
backgroundColor: Colors.grey.shade200,
body: Center(
child: CupertinoActivityIndicator(),
),
@@ -133,6 +135,7 @@ class _FeedScreenState extends State<FeedScreen> {
);
} 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<FeedScreen> {
);
} else {
return Scaffold(
backgroundColor: Colors.grey.shade200,
body: Center(
child: CupertinoActivityIndicator(),
),
@@ -172,6 +176,7 @@ class _FeedScreenState extends State<FeedScreen> {
);
} 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<FeedScreen> {
);
} else {
return Scaffold(
backgroundColor: Colors.grey.shade200,
body: Center(
child: CupertinoActivityIndicator(),
),

View File

@@ -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<BlogPostWidget> {
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<BlogPostWidget> {
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<BlogPostWidget> {
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<BlogPostWidget> {
);
}
_iconButton(IconData icon, [String? text, Function()? onTap]) {
_iconButton({required IconData icon, String? text, Function()? onTap}) {
return InkWell(
onTap: onTap ?? () {},
borderRadius: BorderRadius.circular(16),

View File

@@ -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<List<FeedBlogPostModel>> getFeedBlogPostList() async {
Future<FeedBlogPostSettingsModel> getFeedBlogPosts({int page = 1}) async {
try {
return (await feedService.getBlocPostList()).feedBlogPostList;
return (await feedService.getBlocPostList(page: page));
} catch (e) {
rethrow;
}

View File

@@ -10,8 +10,10 @@ part 'feed_service.g.dart';
abstract class FeedService {
factory FeedService(Dio dio, {String baseUrl}) = _FeedService;
@GET('/api/blogPosts/index')
Future<FeedBlogPostSettingsModel> getBlocPostList();
@GET('/api/blogPosts/index?page={page}')
Future<FeedBlogPostSettingsModel> getBlocPostList({
@Path() required int page,
});
@GET('/api/recipes/index')
Future<RecipesPagination> getRecipes();

View File

@@ -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<FeedBlogPostSettingsModel> getBlocPostList() async {
Future<FeedBlogPostSettingsModel> getBlocPostList({required int page}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<FeedBlogPostSettingsModel>(Options(
final _options = _setStreamType<FeedBlogPostSettingsModel>(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<Map<String, dynamic>>(_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 = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<RecipesPagination>(Options(
final _options = _setStreamType<RecipesPagination>(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<Map<String, dynamic>>(_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 = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<DietsPagination>(Options(
final _options = _setStreamType<DietsPagination>(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<Map<String, dynamic>>(_options);
late DietsPagination _value;
try {
_value = DietsPagination.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}

View File

@@ -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<Profile> getProfileBySlug({required String slug}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result =
await _dio.fetch<Map<String, dynamic>>(_setStreamType<Profile>(Options(
final _options = _setStreamType<Profile>(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<Map<String, dynamic>>(_options);
late Profile _value;
try {
_value = Profile.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}

View File

@@ -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<String, Object?> json) => _$ImageFromJson(json);
}

View File

@@ -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>(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<String, dynamic> json) {
return _Image.fromJson(json);
}
/// @nodoc
mixin _$Image {
String get path => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ImageCopyWith<Image> 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<String, dynamic> 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<String, dynamic> toJson() {
return _$$ImageImplToJson(
this,
);
}
}
abstract class _Image implements Image {
const factory _Image({required final String path}) = _$ImageImpl;
factory _Image.fromJson(Map<String, dynamic> json) = _$ImageImpl.fromJson;
@override
String get path;
@override
@JsonKey(ignore: true)
_$$ImageImplCopyWith<_$ImageImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,15 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'image.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$ImageImpl _$$ImageImplFromJson(Map<String, dynamic> json) => _$ImageImpl(
path: json['path'] as String,
);
Map<String, dynamic> _$$ImageImplToJson(_$ImageImpl instance) => <String, dynamic>{
'path': instance.path,
};

View File

@@ -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<String, Object?> json) =>
_$IngredientFromJson(json);
factory Ingredient.fromJson(Map<String, Object?> json) => _$IngredientFromJson(json);
}

View File

@@ -20,10 +20,9 @@ Ingredient _$IngredientFromJson(Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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 =>

View File

@@ -8,16 +8,14 @@ part of 'ingredient.dart';
_$IngredientImpl _$$IngredientImplFromJson(Map<String, dynamic> 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<String, dynamic> _$$IngredientImplToJson(_$IngredientImpl instance) =>
<String, dynamic>{
'id': instance.id,
'product_name': instance.product_name,
'name': instance.name,
'unit': instance.unit,
'portion': instance.portion,
};

View File

@@ -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<Ingredient> ingredients,
required List<Step> steps,
required String state,
required String description,
required String type,
required Image image,
List<Ingredient?>? ingredients,
List<Step?>? 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<String, Object?> json) =>
_$RecipeModelFromJson(json);
factory RecipeModel.fromJson(Map<String, Object?> json) => _$RecipeModelFromJson(json);
}

View File

@@ -20,15 +20,15 @@ RecipeModel _$RecipeModelFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$RecipeModel {
int? get id => throw _privateConstructorUsedError;
List<Ingredient> get ingredients => throw _privateConstructorUsedError;
List<Step> 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<Ingredient?>? get ingredients => throw _privateConstructorUsedError;
List<Step?>? 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<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@@ -43,17 +43,15 @@ abstract class $RecipeModelCopyWith<$Res> {
_$RecipeModelCopyWithImpl<$Res, RecipeModel>;
@useResult
$Res call(
{int? id,
List<Ingredient> ingredients,
List<Step> steps,
String state,
String description,
String type,
Image image,
{List<Ingredient?>? ingredients,
List<Step?>? 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<Ingredient>,
steps: null == steps
as List<Ingredient?>?,
steps: freezed == steps
? _value.steps
: steps // ignore: cast_nullable_to_non_nullable
as List<Step>,
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<Step?>?,
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<Ingredient> ingredients,
List<Step> steps,
String state,
String description,
String type,
Image image,
{List<Ingredient?>? ingredients,
List<Step?>? 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<Ingredient>,
steps: null == steps
as List<Ingredient?>?,
steps: freezed == steps
? _value._steps
: steps // ignore: cast_nullable_to_non_nullable
as List<Step>,
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<Step?>?,
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<Ingredient> ingredients,
required final List<Step> steps,
required this.state,
required this.description,
required this.type,
required this.image,
{final List<Ingredient?>? ingredients,
final List<Step?>? 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<String, dynamic> json) =>
_$$RecipeModelImplFromJson(json);
final List<Ingredient?>? _ingredients;
@override
final int? id;
final List<Ingredient> _ingredients;
@override
List<Ingredient> get ingredients {
List<Ingredient?>? 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<Step> _steps;
final List<Step?>? _steps;
@override
List<Step> get steps {
List<Step?>? 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<Ingredient> ingredients,
required final List<Step> steps,
required final String state,
required final String description,
required final String type,
required final Image image,
{final List<Ingredient?>? ingredients,
final List<Step?>? 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<String, dynamic> json) =
_$RecipeModelImpl.fromJson;
@override
int? get id;
List<Ingredient?>? get ingredients;
@override
List<Ingredient> get ingredients;
List<Step?>? get steps;
@override
List<Step> 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 =>

View File

@@ -8,30 +8,32 @@ part of 'recipe_model.dart';
_$RecipeModelImpl _$$RecipeModelImplFromJson(Map<String, dynamic> json) =>
_$RecipeModelImpl(
id: (json['id'] as num?)?.toInt(),
ingredients: (json['ingredients'] as List<dynamic>)
.map((e) => Ingredient.fromJson(e as Map<String, dynamic>))
ingredients: (json['ingredients'] as List<dynamic>?)
?.map((e) =>
e == null ? null : Ingredient.fromJson(e as Map<String, dynamic>))
.toList(),
steps: (json['steps'] as List<dynamic>)
.map((e) => Step.fromJson(e as Map<String, dynamic>))
steps: (json['steps'] as List<dynamic>?)
?.map((e) =>
e == null ? null : Step.fromJson(e as Map<String, dynamic>))
.toList(),
state: json['state'] as String,
description: json['description'] as String,
type: json['type'] as String,
image: Image.fromJson(json['image'] as Map<String, dynamic>),
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<String, dynamic> _$$RecipeModelImplToJson(_$RecipeModelImpl instance) =>
<String, dynamic>{
'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,
};

View File

@@ -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;

View File

@@ -20,8 +20,7 @@ Step _$StepFromJson(Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> 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<String, dynamic> json) = _$StepImpl.fromJson;
@override
int? get id;
@override
Image? get image;
String? get image;
@override
String? get description;
@override

View File

@@ -7,16 +7,12 @@ part of 'step.dart';
// **************************************************************************
_$StepImpl _$$StepImplFromJson(Map<String, dynamic> json) => _$StepImpl(
id: (json['id'] as num?)?.toInt(),
image: json['image'] == null
? null
: Image.fromJson(json['image'] as Map<String, dynamic>),
image: json['image'] as String?,
description: json['description'] as String?,
);
Map<String, dynamic> _$$StepImplToJson(_$StepImpl instance) =>
<String, dynamic>{
'id': instance.id,
'image': instance.image,
'description': instance.description,
};

View File

@@ -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<RecipeCreateState> {
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<SelectionPopupModel> 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<SelectionPopupModel> 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<SelectionPopupModel> 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<SelectionPopupModel> 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<SelectionPopupModel> 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<SelectionPopupModel> 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<RecipeCreateState> {
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<Ingredient> newIngredients =
List<Ingredient>.from(currentState.ingredients);
List<Ingredient> newIngredients = List<Ingredient>.from(currentState.ingredients);
newIngredients.add(ingredient);
var updatedState = currentState.copyWith(ingredients: newIngredients);
@@ -134,13 +226,9 @@ class RecipeCreateCubit extends Cubit<RecipeCreateState> {
var currentState = state as RecipeCreateStateLoaded;
List<XFile?> newStepImages = List<XFile?>.from(currentState.stepImages);
newStepImages.add(null);
List<TextEditingController> newStepControllers =
List<TextEditingController>.from(currentState.stepControllers);
List<TextEditingController> newStepControllers = List<TextEditingController>.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<RecipeCreateState> {
var currentState = state as RecipeCreateStateLoaded;
List<XFile?> newStepImages = List<XFile?>.from(currentState.stepImages);
newStepImages.removeLast();
List<TextEditingController> newStepControllers =
List<TextEditingController>.from(currentState.stepControllers);
List<TextEditingController> newStepControllers = List<TextEditingController>.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<String, List<Product>> 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);
}
}
}

View File

@@ -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<XFile?> stepImages,
required List<Ingredient> ingredients,
required List<Product> autocompleteList,
required int numberOfSteps,
required bool ingredientAsItems,
required List<SelectionPopupModel> types,
required List<SelectionPopupModel> cookingTimes,
required List<SelectionPopupModel> statuses,
required SelectionPopupModel selectedType,
required SelectionPopupModel selectedCookingTime,
required SelectionPopupModel selectedStatus,
}) = RecipeCreateStateLoaded;
const factory RecipeCreateState.error({

View File

@@ -32,11 +32,15 @@ mixin _$RecipeCreateState {
XFile? recipeImage,
List<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)
List<SelectionPopupModel> statuses,
SelectionPopupModel selectedType,
SelectionPopupModel selectedCookingTime,
SelectionPopupModel selectedStatus)
loaded,
required TResult Function(String errorMessage) error,
}) =>
@@ -57,11 +61,15 @@ mixin _$RecipeCreateState {
XFile? recipeImage,
List<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> statuses,
SelectionPopupModel selectedType,
SelectionPopupModel selectedCookingTime,
SelectionPopupModel selectedStatus)?
loaded,
TResult? Function(String errorMessage)? error,
}) =>
@@ -82,11 +90,15 @@ mixin _$RecipeCreateState {
XFile? recipeImage,
List<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)
List<SelectionPopupModel> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> statuses,
SelectionPopupModel selectedType,
SelectionPopupModel selectedCookingTime,
SelectionPopupModel selectedStatus)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -245,11 +265,15 @@ class _$RecipeCreateStateImpl implements _RecipeCreateState {
XFile? recipeImage,
List<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)
List<SelectionPopupModel> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> statuses,
SelectionPopupModel selectedType,
SelectionPopupModel selectedCookingTime,
SelectionPopupModel selectedStatus)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -414,11 +446,15 @@ class _$RecipeCreateStateLoadingImpl implements RecipeCreateStateLoading {
XFile? recipeImage,
List<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses});
List<SelectionPopupModel> 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<Ingredient>,
autocompleteList: null == autocompleteList
? _value._autocompleteList
: autocompleteList // ignore: cast_nullable_to_non_nullable
as List<Product>,
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<SelectionPopupModel>,
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<XFile?> stepImages,
required final List<Ingredient> ingredients,
required final List<Product> autocompleteList,
required this.numberOfSteps,
required this.ingredientAsItems,
required final List<SelectionPopupModel> types,
required final List<SelectionPopupModel> cookingTimes,
required final List<SelectionPopupModel> statuses})
required final List<SelectionPopupModel> 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<Product> _autocompleteList;
@override
List<Product> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)
List<SelectionPopupModel> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> 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<XFile?> stepImages,
required final List<Ingredient> ingredients,
required final List<Product> autocompleteList,
required final int numberOfSteps,
required final bool ingredientAsItems,
required final List<SelectionPopupModel> types,
required final List<SelectionPopupModel> cookingTimes,
required final List<SelectionPopupModel> statuses}) =
required final List<SelectionPopupModel> 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<XFile?> get stepImages;
List<Ingredient> get ingredients;
List<Product> get autocompleteList;
int get numberOfSteps;
bool get ingredientAsItems;
List<SelectionPopupModel> get types;
List<SelectionPopupModel> get cookingTimes;
List<SelectionPopupModel> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)
List<SelectionPopupModel> 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<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> statuses,
SelectionPopupModel selectedType,
SelectionPopupModel selectedCookingTime,
SelectionPopupModel selectedStatus)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -1125,11 +1287,15 @@ class _$RecipeCreateStateErrorImpl implements RecipeCreateStateError {
XFile? recipeImage,
List<XFile?> stepImages,
List<Ingredient> ingredients,
List<Product> autocompleteList,
int numberOfSteps,
bool ingredientAsItems,
List<SelectionPopupModel> types,
List<SelectionPopupModel> cookingTimes,
List<SelectionPopupModel> statuses)?
List<SelectionPopupModel> statuses,
SelectionPopupModel selectedType,
SelectionPopupModel selectedCookingTime,
SelectionPopupModel selectedStatus)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),

View File

@@ -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<RecipeCreateCubit>().loadRecipeCreate();
return BlocBuilder<RecipeCreateCubit, RecipeCreateState>(
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<String> _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<RecipeCreateCubit>()
.uploadRecipeImage(pickedFile);
final pickedFile = await state.picker.pickImage(source: ImageSource.gallery);
context.read<RecipeCreateCubit>().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<String>(
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<String> onSelected,
Iterable<String> 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: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
),
SizedBox(height: 8),
Row(children: [
Text('гр'),
Switch(
value: state.ingredientAsItems,
onChanged: (bool value) => context
.read<RecipeCreateCubit>()
.switchUnits(value),
onChanged: (bool value) => context.read<RecipeCreateCubit>().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<RecipeCreateCubit>()
.addIngredient(new Ingredient(
product_name:
state.productNameController.text,
portion: int.parse(
state.ingredientController.text),
unit: state.ingredientAsItems
? 'pcs'
: 'gr'))),
onPressed: () => context.read<RecipeCreateCubit>().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<RecipeCreateCubit>().addStep(),
onPressed: () => context.read<RecipeCreateCubit>().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<RecipeCreateCubit>().removeStep(),
onPressed: () => context.read<RecipeCreateCubit>().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<RecipeCreateCubit>().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<RecipeCreateCubit>()
.uploadStepImage(pickedFile, stepNumber);
final pickedFile = await state.picker.pickImage(source: ImageSource.gallery);
context.read<RecipeCreateCubit>().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<String> _options) {
return (TextEditingValue textEditingValue) {
return _options.where((String option) {
return true;
});
};
}
selectProduct(AutocompleteOnSelected<String> 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<RecipeCreateCubit>().inputProduct(value);
}
};
}
changeType(BuildContext context) {
return (value) {
context.read<RecipeCreateCubit>().changeType(value);
};
}
changeStatus(BuildContext context) {
return (value) {
context.read<RecipeCreateCubit>().changeStatus(value);
};
}
changeCookingTime(BuildContext context) {
return (value) {
context.read<RecipeCreateCubit>().changeCookingTime(value);
};
}
RecipeModel createRecipeFromState(RecipeCreateStateLoaded state) {
// Подготовка ингредиентов
List<Ingredient> ingredients = state.ingredients;
// Подготовка шагов (например, можно создать шаги из stepControllers)
List<step.Step> 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;
}
}

View File

@@ -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<RecipeCreateCubit>().loadRecipeById(recipeID);
}
return BlocBuilder<RecipeCreateCubit, RecipeCreateState>(
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<String> _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<RecipeCreateCubit>().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<String>(
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<String> onSelected,
Iterable<String> 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: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
),
SizedBox(height: 8),
Row(children: [
Text('гр'),
Switch(
value: state.ingredientAsItems,
onChanged: (bool value) => context.read<RecipeCreateCubit>().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<RecipeCreateCubit>().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<RecipeCreateCubit>().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<RecipeCreateCubit>().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<RecipeCreateCubit>().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<RecipeCreateCubit>().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<String> _options) {
return (TextEditingValue textEditingValue) {
return _options.where((String option) {
return true;
});
};
}
selectProduct(AutocompleteOnSelected<String> 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<RecipeCreateCubit>().inputProduct(value);
}
};
}
changeType(BuildContext context) {
return (value) {
context.read<RecipeCreateCubit>().changeType(value);
};
}
changeStatus(BuildContext context) {
return (value) {
context.read<RecipeCreateCubit>().changeStatus(value);
};
}
changeCookingTime(BuildContext context) {
return (value) {
context.read<RecipeCreateCubit>().changeCookingTime(value);
};
}
RecipeModel createRecipeFromState(RecipeCreateStateLoaded state) {
List<Ingredient> ingredients = state.ingredients;
List<step.Step> 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;
}
}

View File

@@ -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<RecipeModel> getRecipe(int recipeID) async {
Future<Map<String, List<Product>>> inputProduct(String name) async {
try {
return (await recipeService.getRecipe(recipeID));
return await recipeService.getInputProduct(name);
} catch (e) {
rethrow;
}
}*/
}
Future<RecipeModel> publishRecipe(RecipeModel recipe) async {
try {
return await recipeService.publishRecipe(jsonDecode(jsonEncode(recipe)));
} catch (e) {
rethrow;
}
}
Future<RecipeModel> editRecipe(RecipeModel recipe, String id) async {
try {
return await recipeService.editRecipe(jsonDecode(jsonEncode(recipe)), id);
} catch (e) {
rethrow;
}
}
Future<RecipeModel> getRecipe(String recipeID) async {
try {
return await recipeService.getRecipe(recipeID);
} catch (e) {
rethrow;
}
}
}

View File

@@ -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<Map<String, RecipeModel>> getRecipe(@Path() int id);
@GET('/api/recipes/show/{id}')
Future<RecipeModel> getRecipe(@Path() String id);
@GET('/api/diary/product_nutritional_values/filter')
Future<Map<String, List<Product>>> getInputProduct(@Query('name') String name);
@POST('/api/recipes/create')
Future<RecipeModel> publishRecipe(@Part() Map<String, Object?> recipe);
@POST('/api/recipes/update/{id}')
Future<RecipeModel> editRecipe(@Part() Map<String, Object?> recipe, String id);
}

View File

@@ -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<Map<String, RecipeModel>> getRecipe(int id) async {
Future<RecipeModel> getRecipe(String id) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<Map<String, RecipeModel>>(Options(
final _options = _setStreamType<RecipeModel>(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<String, dynamic>)));
.compose(
_dio.options,
'/api/recipes/show/${id}',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_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<Map<String, List<Product>>> getInputProduct(String name) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{r'name': name};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<Map<String, List<Product>>>(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<Map<String, dynamic>>(_options);
late Map<String, List<Product>> _value;
try {
_value = _result.data!.map((k, dynamic v) => MapEntry(
k,
(v as List)
.map((i) => Product.fromJson(i as Map<String, dynamic>))
.toList()));
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@override
Future<RecipeModel> publishRecipe(Map<String, Object?> recipe) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = FormData.fromMap(recipe);
final _options = _setStreamType<RecipeModel>(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<Map<String, dynamic>>(_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<RecipeModel> editRecipe(
Map<String, Object?> recipe,
String id,
) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = FormData.fromMap(recipe);
final _options = _setStreamType<RecipeModel>(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<Map<String, dynamic>>(_options);
late RecipeModel _value;
try {
_value = RecipeModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}

View File

@@ -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<Map<String, String>> register(
{required Map<String, dynamic> sheet}) async {
@@ -26,24 +29,30 @@ class _RegistrationService implements RegistrationService {
final _headers = <String, dynamic>{};
final _data = <String, dynamic>{};
_data.addAll(sheet);
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<Map<String, String>>(Options(
final _options = _setStreamType<Map<String, String>>(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<String, String>();
.compose(
_dio.options,
'/api/register',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late Map<String, String> _value;
try {
_value = _result.data!.cast<String, String>();
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@@ -53,24 +62,30 @@ class _RegistrationService implements RegistrationService {
final queryParameters = <String, dynamic>{r'user_address': query};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<LocationModel>(Options(
final _options = _setStreamType<LocationModel>(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<Map<String, dynamic>>(_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 = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio
.fetch<Map<String, dynamic>>(_setStreamType<LocationModel>(Options(
final _options = _setStreamType<LocationModel>(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<Map<String, dynamic>>(_options);
late LocationModel _value;
try {
_value = LocationModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}

View File

@@ -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',
'',
),
],
),

View File

@@ -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),
),

View File

@@ -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