diet creation page

This commit is contained in:
Username1548
2024-11-20 15:28:48 +07:00
parent 92c1bb1a91
commit c292f3a767
19 changed files with 1036 additions and 38 deletions

View File

@@ -0,0 +1,12 @@
import 'package:flutter/widgets.dart';
class CreateDietScreen extends StatelessWidget {
static const name = 'createDietScreen';
static const path = '/create-diet-screen';
const CreateDietScreen({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}

View File

@@ -0,0 +1,37 @@
import 'dart:io';
import 'package:eatvio_app/features/create_diet/presentation/cubit/create_diet_state.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class CreateDietCubit extends Cubit<CreateDietState> {
CreateDietCubit() : super(CreateDietState.initial());
void setDetails(String text) {
emit(state.copyWith(dietData: state.dietData.copyWith(details: text)));
}
void setName(String name) {
emit(state.copyWith(dietData: state.dietData.copyWith(name: name)));
}
void setDuration(int duration) {
emit(state.copyWith(dietData: state.dietData.copyWith(duration: duration)));
}
void setImage(File image) {
emit(state.copyWith(dietData: state.dietData.copyWith(image: image)));
}
void setDailySchedule(List<List<List<DailySchedule>>> dailySchedule) {
emit(state.copyWith(dietData: state.dietData.copyWith(dailySchedule: dailySchedule)));
}
void setDietState(String dietState) {
emit(state.copyWith(dietData: state.dietData.copyWith(state: dietState)));
}
void setDietType(List<String> type) {
emit(state.copyWith(dietData: state.dietData.copyWith(type: type)));
}
}

View File

@@ -0,0 +1,15 @@
import 'package:eatvio_app/features/create_diet/models/create_diet_model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'create_diet_state.freezed.dart';
@freezed
class CreateDietState with _$CreateDietState {
const factory CreateDietState({
required bool isLoading,
required String? errorMessage,
required CreateDietModel dietData,
}) = _CreateDietState;
factory CreateDietState.initial() => CreateDietState(isLoading: false, errorMessage: null, dietData: CreateDietModel());
}

View File

@@ -0,0 +1,201 @@
// 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 'create_diet_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');
/// @nodoc
mixin _$CreateDietState {
bool get isLoading => throw _privateConstructorUsedError;
String? get errorMessage => throw _privateConstructorUsedError;
CreateDietModel get dietData => throw _privateConstructorUsedError;
/// Create a copy of CreateDietState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$CreateDietStateCopyWith<CreateDietState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CreateDietStateCopyWith<$Res> {
factory $CreateDietStateCopyWith(
CreateDietState value, $Res Function(CreateDietState) then) =
_$CreateDietStateCopyWithImpl<$Res, CreateDietState>;
@useResult
$Res call({bool isLoading, String? errorMessage, CreateDietModel dietData});
$CreateDietModelCopyWith<$Res> get dietData;
}
/// @nodoc
class _$CreateDietStateCopyWithImpl<$Res, $Val extends CreateDietState>
implements $CreateDietStateCopyWith<$Res> {
_$CreateDietStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CreateDietState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? isLoading = null,
Object? errorMessage = freezed,
Object? dietData = null,
}) {
return _then(_value.copyWith(
isLoading: null == isLoading
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
errorMessage: freezed == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
dietData: null == dietData
? _value.dietData
: dietData // ignore: cast_nullable_to_non_nullable
as CreateDietModel,
) as $Val);
}
/// Create a copy of CreateDietState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$CreateDietModelCopyWith<$Res> get dietData {
return $CreateDietModelCopyWith<$Res>(_value.dietData, (value) {
return _then(_value.copyWith(dietData: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$CreateDietStateImplCopyWith<$Res>
implements $CreateDietStateCopyWith<$Res> {
factory _$$CreateDietStateImplCopyWith(_$CreateDietStateImpl value,
$Res Function(_$CreateDietStateImpl) then) =
__$$CreateDietStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({bool isLoading, String? errorMessage, CreateDietModel dietData});
@override
$CreateDietModelCopyWith<$Res> get dietData;
}
/// @nodoc
class __$$CreateDietStateImplCopyWithImpl<$Res>
extends _$CreateDietStateCopyWithImpl<$Res, _$CreateDietStateImpl>
implements _$$CreateDietStateImplCopyWith<$Res> {
__$$CreateDietStateImplCopyWithImpl(
_$CreateDietStateImpl _value, $Res Function(_$CreateDietStateImpl) _then)
: super(_value, _then);
/// Create a copy of CreateDietState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? isLoading = null,
Object? errorMessage = freezed,
Object? dietData = null,
}) {
return _then(_$CreateDietStateImpl(
isLoading: null == isLoading
? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable
as bool,
errorMessage: freezed == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String?,
dietData: null == dietData
? _value.dietData
: dietData // ignore: cast_nullable_to_non_nullable
as CreateDietModel,
));
}
}
/// @nodoc
class _$CreateDietStateImpl implements _CreateDietState {
const _$CreateDietStateImpl(
{required this.isLoading,
required this.errorMessage,
required this.dietData});
@override
final bool isLoading;
@override
final String? errorMessage;
@override
final CreateDietModel dietData;
@override
String toString() {
return 'CreateDietState(isLoading: $isLoading, errorMessage: $errorMessage, dietData: $dietData)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CreateDietStateImpl &&
(identical(other.isLoading, isLoading) ||
other.isLoading == isLoading) &&
(identical(other.errorMessage, errorMessage) ||
other.errorMessage == errorMessage) &&
(identical(other.dietData, dietData) ||
other.dietData == dietData));
}
@override
int get hashCode =>
Object.hash(runtimeType, isLoading, errorMessage, dietData);
/// Create a copy of CreateDietState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CreateDietStateImplCopyWith<_$CreateDietStateImpl> get copyWith =>
__$$CreateDietStateImplCopyWithImpl<_$CreateDietStateImpl>(
this, _$identity);
}
abstract class _CreateDietState implements CreateDietState {
const factory _CreateDietState(
{required final bool isLoading,
required final String? errorMessage,
required final CreateDietModel dietData}) = _$CreateDietStateImpl;
@override
bool get isLoading;
@override
String? get errorMessage;
@override
CreateDietModel get dietData;
/// Create a copy of CreateDietState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CreateDietStateImplCopyWith<_$CreateDietStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}