forked from eatvio/eatvio_app
feat(calendar): Diet days marked in calendar, diet preview page added
This commit is contained in:
@@ -5,14 +5,18 @@ class CalendarEntryModel {
|
||||
String? date;
|
||||
String? status;
|
||||
String id;
|
||||
bool is_current_day_included_in_the_chosen_diet_progression;
|
||||
|
||||
CalendarEntryModel({
|
||||
this.date,
|
||||
this.status,
|
||||
required this.id,
|
||||
required this.is_current_day_included_in_the_chosen_diet_progression,
|
||||
}) {
|
||||
date = date;
|
||||
status = status;
|
||||
id = id;
|
||||
is_current_day_included_in_the_chosen_diet_progression =
|
||||
is_current_day_included_in_the_chosen_diet_progression;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ part 'calendar_model.g.dart';
|
||||
class CalendarModel with _$CalendarModel {
|
||||
const factory CalendarModel({
|
||||
required String date,
|
||||
required bool is_current_day_included_in_the_chosen_diet_progression,
|
||||
Object? diary,
|
||||
}) = _CalendarModel;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ CalendarModel _$CalendarModelFromJson(Map<String, dynamic> json) {
|
||||
/// @nodoc
|
||||
mixin _$CalendarModel {
|
||||
String get date => throw _privateConstructorUsedError;
|
||||
bool get is_current_day_included_in_the_chosen_diet_progression =>
|
||||
throw _privateConstructorUsedError;
|
||||
Object? get diary => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@@ -35,7 +37,10 @@ abstract class $CalendarModelCopyWith<$Res> {
|
||||
CalendarModel value, $Res Function(CalendarModel) then) =
|
||||
_$CalendarModelCopyWithImpl<$Res, CalendarModel>;
|
||||
@useResult
|
||||
$Res call({String date, Object? diary});
|
||||
$Res call(
|
||||
{String date,
|
||||
bool is_current_day_included_in_the_chosen_diet_progression,
|
||||
Object? diary});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -52,6 +57,7 @@ class _$CalendarModelCopyWithImpl<$Res, $Val extends CalendarModel>
|
||||
@override
|
||||
$Res call({
|
||||
Object? date = null,
|
||||
Object? is_current_day_included_in_the_chosen_diet_progression = null,
|
||||
Object? diary = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
@@ -59,6 +65,11 @@ class _$CalendarModelCopyWithImpl<$Res, $Val extends CalendarModel>
|
||||
? _value.date
|
||||
: date // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
is_current_day_included_in_the_chosen_diet_progression: null ==
|
||||
is_current_day_included_in_the_chosen_diet_progression
|
||||
? _value.is_current_day_included_in_the_chosen_diet_progression
|
||||
: is_current_day_included_in_the_chosen_diet_progression // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
diary: freezed == diary ? _value.diary : diary,
|
||||
) as $Val);
|
||||
}
|
||||
@@ -72,7 +83,10 @@ abstract class _$$CalendarModelImplCopyWith<$Res>
|
||||
__$$CalendarModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String date, Object? diary});
|
||||
$Res call(
|
||||
{String date,
|
||||
bool is_current_day_included_in_the_chosen_diet_progression,
|
||||
Object? diary});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -87,6 +101,7 @@ class __$$CalendarModelImplCopyWithImpl<$Res>
|
||||
@override
|
||||
$Res call({
|
||||
Object? date = null,
|
||||
Object? is_current_day_included_in_the_chosen_diet_progression = null,
|
||||
Object? diary = freezed,
|
||||
}) {
|
||||
return _then(_$CalendarModelImpl(
|
||||
@@ -94,6 +109,11 @@ class __$$CalendarModelImplCopyWithImpl<$Res>
|
||||
? _value.date
|
||||
: date // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
is_current_day_included_in_the_chosen_diet_progression: null ==
|
||||
is_current_day_included_in_the_chosen_diet_progression
|
||||
? _value.is_current_day_included_in_the_chosen_diet_progression
|
||||
: is_current_day_included_in_the_chosen_diet_progression // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
diary: freezed == diary ? _value.diary : diary,
|
||||
));
|
||||
}
|
||||
@@ -102,7 +122,10 @@ class __$$CalendarModelImplCopyWithImpl<$Res>
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$CalendarModelImpl implements _CalendarModel {
|
||||
const _$CalendarModelImpl({required this.date, this.diary});
|
||||
const _$CalendarModelImpl(
|
||||
{required this.date,
|
||||
required this.is_current_day_included_in_the_chosen_diet_progression,
|
||||
this.diary});
|
||||
|
||||
factory _$CalendarModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$CalendarModelImplFromJson(json);
|
||||
@@ -110,11 +133,13 @@ class _$CalendarModelImpl implements _CalendarModel {
|
||||
@override
|
||||
final String date;
|
||||
@override
|
||||
final bool is_current_day_included_in_the_chosen_diet_progression;
|
||||
@override
|
||||
final Object? diary;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CalendarModel(date: $date, diary: $diary)';
|
||||
return 'CalendarModel(date: $date, is_current_day_included_in_the_chosen_diet_progression: $is_current_day_included_in_the_chosen_diet_progression, diary: $diary)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -123,13 +148,22 @@ class _$CalendarModelImpl implements _CalendarModel {
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CalendarModelImpl &&
|
||||
(identical(other.date, date) || other.date == date) &&
|
||||
(identical(
|
||||
other
|
||||
.is_current_day_included_in_the_chosen_diet_progression,
|
||||
is_current_day_included_in_the_chosen_diet_progression) ||
|
||||
other.is_current_day_included_in_the_chosen_diet_progression ==
|
||||
is_current_day_included_in_the_chosen_diet_progression) &&
|
||||
const DeepCollectionEquality().equals(other.diary, diary));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, date, const DeepCollectionEquality().hash(diary));
|
||||
runtimeType,
|
||||
date,
|
||||
is_current_day_included_in_the_chosen_diet_progression,
|
||||
const DeepCollectionEquality().hash(diary));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@@ -147,7 +181,10 @@ class _$CalendarModelImpl implements _CalendarModel {
|
||||
|
||||
abstract class _CalendarModel implements CalendarModel {
|
||||
const factory _CalendarModel(
|
||||
{required final String date, final Object? diary}) = _$CalendarModelImpl;
|
||||
{required final String date,
|
||||
required final bool
|
||||
is_current_day_included_in_the_chosen_diet_progression,
|
||||
final Object? diary}) = _$CalendarModelImpl;
|
||||
|
||||
factory _CalendarModel.fromJson(Map<String, dynamic> json) =
|
||||
_$CalendarModelImpl.fromJson;
|
||||
@@ -155,6 +192,8 @@ abstract class _CalendarModel implements CalendarModel {
|
||||
@override
|
||||
String get date;
|
||||
@override
|
||||
bool get is_current_day_included_in_the_chosen_diet_progression;
|
||||
@override
|
||||
Object? get diary;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
|
||||
@@ -9,11 +9,16 @@ part of 'calendar_model.dart';
|
||||
_$CalendarModelImpl _$$CalendarModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CalendarModelImpl(
|
||||
date: json['date'] as String,
|
||||
is_current_day_included_in_the_chosen_diet_progression:
|
||||
json['is_current_day_included_in_the_chosen_diet_progression']
|
||||
as bool,
|
||||
diary: json['diary'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CalendarModelImplToJson(_$CalendarModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'date': instance.date,
|
||||
'is_current_day_included_in_the_chosen_diet_progression':
|
||||
instance.is_current_day_included_in_the_chosen_diet_progression,
|
||||
'diary': instance.diary,
|
||||
};
|
||||
|
||||
@@ -102,7 +102,10 @@ class CalendarScreen extends StatelessWidget {
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
color: getBackgroundColor(diary['state']),
|
||||
color: state.calendarList[index]
|
||||
.is_current_day_included_in_the_chosen_diet_progression
|
||||
? Color.fromRGBO(59, 130, 246, .2)
|
||||
: Color.fromRGBO(126, 136, 151, .1),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -117,57 +120,24 @@ class CalendarScreen extends StatelessWidget {
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
SizedBox(height: 2.v),
|
||||
if (diary['state'] != null)
|
||||
Row(children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: diary['state'] == 'finished'
|
||||
? Color.fromRGBO(1, 154, 62, 1)
|
||||
: Color.fromRGBO(154, 74, 1, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
_getStateText(diary['state'] ?? ''),
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
if (state.calendarList[index]
|
||||
.is_current_day_included_in_the_chosen_diet_progression)
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
if (diary['state'] == 'started')
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Заполнить отчет',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
if (diary['state'] == 'finished')
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Изменить отчет',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
]),
|
||||
if (state.calendarList[index].diary is List<dynamic>)
|
||||
child: Text(
|
||||
'Посмотреть диету на день',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
if (!state.calendarList[index]
|
||||
.is_current_day_included_in_the_chosen_diet_progression)
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
@@ -191,6 +161,7 @@ class CalendarScreen extends StatelessWidget {
|
||||
);
|
||||
} else {
|
||||
diary = state.calendarList[index].diary as Map<String, dynamic>;
|
||||
print(state.calendarList[index]);
|
||||
return InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
onTap: () => GoRouter.of(context).go(
|
||||
@@ -216,71 +187,55 @@ class CalendarScreen extends StatelessWidget {
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
SizedBox(height: 2.v),
|
||||
if (diary['state'] != null)
|
||||
Row(children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: diary['state'] == 'finished'
|
||||
? Color.fromRGBO(1, 154, 62, 1)
|
||||
: Color.fromRGBO(154, 74, 1, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
_getStateText(diary['state'] ?? ''),
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
if (diary['state'] == 'started')
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Заполнить отчет',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
if (diary['state'] == 'finished')
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Изменить отчет',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
]),
|
||||
if (state.calendarList[index].diary is List<dynamic>)
|
||||
Row(children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(108, 117, 125, 1),
|
||||
color: diary['state'] == 'finished'
|
||||
? Color.fromRGBO(1, 154, 62, 1)
|
||||
: Color.fromRGBO(154, 74, 1, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Cкоро',
|
||||
_getStateText(diary['state'] ?? ''),
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
if (diary['state'] == 'started')
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Заполнить отчет',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
if (diary['state'] == 'finished')
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(13, 110, 253, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Изменить отчет',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
// ignore_for_file: unused_local_variable
|
||||
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class DiaryRecommendationsScreen extends StatelessWidget {
|
||||
final String? diary_recommendationsID;
|
||||
|
||||
const DiaryRecommendationsScreen({
|
||||
this.diary_recommendationsID,
|
||||
super.key,
|
||||
});
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
if (diary_recommendationsID != "0") {
|
||||
context.read<DiaryBloc>().add(LoadDiaryById(diary_recommendationsID));
|
||||
}
|
||||
return BlocBuilder<DiaryBloc, DiaryState>(
|
||||
builder: (context, state) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
return _buildDiaryRecommendations(context, state);
|
||||
} else if (state is DiaryStateLoading) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CupertinoActivityIndicator(),
|
||||
),
|
||||
);
|
||||
} else if (state is DiaryStateError) {
|
||||
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 _buildDiaryRecommendations(
|
||||
BuildContext context, DiaryStateLoaded state) {
|
||||
return Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
FormBuilder(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
backgroundColor: Color.fromARGB(255, 240, 242, 245),
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 5.v),
|
||||
child: Column(
|
||||
children: [],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -250,11 +250,6 @@ class DiaryScreen extends StatelessWidget {
|
||||
style: CustomTextStyles.titleMediumBlack,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 2.v),
|
||||
Text(
|
||||
state.diary.date.toString(),
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user