feat(calendar): Calendar to diary transition
This commit is contained in:
@@ -96,106 +96,199 @@ class CalendarScreen extends StatelessWidget {
|
||||
Map<String, dynamic> diary = {};
|
||||
if (state.calendarList[index].diary is List<dynamic>) {
|
||||
diary['status'] = 'Скоро';
|
||||
} else if (state.calendarList[index].diary is Map<String, dynamic>) {
|
||||
diary = state.calendarList[index].diary as Map<String, dynamic>;
|
||||
}
|
||||
return InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
onTap: () => GoRouter.of(context).go(
|
||||
'/diary-screen',
|
||||
extra: diary['id'].toString(),
|
||||
),
|
||||
child: Ink(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
color: getBackgroundColor(diary['state']),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
formatDate(state.calendarList[index].date),
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
SizedBox(height: 2.v),
|
||||
if (diary['state'] != null)
|
||||
Row(children: [
|
||||
return InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
child: Ink(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
color: getBackgroundColor(diary['state']),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
formatDate(state.calendarList[index].date),
|
||||
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>)
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: diary['state'] == 'finished'
|
||||
? Color.fromRGBO(1, 154, 62, 1)
|
||||
: Color.fromRGBO(154, 74, 1, 1),
|
||||
color: Color.fromRGBO(108, 117, 125, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
_getStateText(diary['state'] ?? ''),
|
||||
'Cкоро',
|
||||
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>)
|
||||
Container(
|
||||
padding:
|
||||
EdgeInsets.all(4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(108, 117, 125, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Cкоро',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
} else {
|
||||
diary = state.calendarList[index].diary as Map<String, dynamic>;
|
||||
return InkWell(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
onTap: () => GoRouter.of(context).go(
|
||||
'/diary-screen',
|
||||
extra: diary['id'].toString(),
|
||||
),
|
||||
child: Ink(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
color: getBackgroundColor(diary['state']),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
formatDate(state.calendarList[index].date),
|
||||
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>)
|
||||
Container(
|
||||
padding: EdgeInsets.all(
|
||||
4.0), // Отступы внутри контейнера
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(108, 117, 125, 1),
|
||||
borderRadius: BorderRadius.circular(
|
||||
24.0), // Закругленные углы
|
||||
),
|
||||
child: Text(
|
||||
'Cкоро',
|
||||
style: CustomTextStyles
|
||||
.titleSmallBold, // Предполагается, что текст белый
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
DiaryBloc({required this.diaryRepository})
|
||||
: super(const DiaryState.loading()) {
|
||||
on<LoadDiary>(loadDiary);
|
||||
on<LoadDiaryById>(loadDiaryById);
|
||||
on<ChangeSatiety>(_changeSatiety); // пользователь нажимает на шкалу сытости
|
||||
on<ChangeMood>(_changeMood); // пользователь нажимает на шкалу настроения
|
||||
on<ChangeMealTime>(_changeMealTime); // пользовательяет времяа пиши
|
||||
@@ -61,26 +62,25 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
|
||||
final Map<String, dynamic> chartData =
|
||||
await diaryRepository.getChartData(diaryID ?? 45);
|
||||
print(chartData);
|
||||
final Map<String, dynamic> dailyNutritionIntake =
|
||||
chartData['dailyNutritionIntake']!;
|
||||
final Map<String, dynamic> dailyNutritionRecommendations =
|
||||
chartData['dailyNutritionRecommendation']!;
|
||||
final double ccal = dailyNutritionIntake['energy']! /
|
||||
dailyNutritionRecommendations['energy']! *
|
||||
100;
|
||||
50;
|
||||
final double proteins = dailyNutritionIntake['proteins']! /
|
||||
dailyNutritionRecommendations['proteins']! *
|
||||
100;
|
||||
50;
|
||||
final double fats = dailyNutritionIntake['fats']! /
|
||||
dailyNutritionRecommendations['fats']! *
|
||||
100;
|
||||
50;
|
||||
final double carbs = dailyNutritionIntake['carbohydrates']! /
|
||||
dailyNutritionRecommendations['carbohydrates']! *
|
||||
100;
|
||||
50;
|
||||
|
||||
Color getColor(double value) {
|
||||
if (value >= 49.1) {
|
||||
if (value >= 99.1) {
|
||||
return Colors.red;
|
||||
} else {
|
||||
return Colors.blue;
|
||||
@@ -102,6 +102,97 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
|
||||
SelectionPopupModel(title: "Прием пищи 5", id: 5),
|
||||
SelectionPopupModel(title: "Прием пищи 6", id: 6),
|
||||
];
|
||||
|
||||
emit(DiaryState.loaded(
|
||||
diary: diary,
|
||||
currentMeal: currentMeal,
|
||||
portions: currentMeal.portions,
|
||||
portionList: portionList,
|
||||
portionController: portionList[0],
|
||||
mealList: mealList,
|
||||
chartData: chartDataCounted,
|
||||
selectedMood: currentMeal.mood,
|
||||
selectedSatiety: currentMeal.satiety,
|
||||
wakeupController: TimeOfDay.now(),
|
||||
retireController: TimeOfDay.now(),
|
||||
commentController: TextEditingController(),
|
||||
product_nameController: TextEditingController(),
|
||||
productQuantityController: TextEditingController(),
|
||||
caloriesController: TextEditingController(),
|
||||
fatsController: TextEditingController(),
|
||||
proteinsController: TextEditingController(),
|
||||
carbsController: TextEditingController(),
|
||||
wakeupExpanded: false,
|
||||
moderationExpanded: false,
|
||||
moodExpanded: false,
|
||||
isLoading: false,
|
||||
isAdded: false,
|
||||
autocompleteList: [],
|
||||
recommendedChartValues: [1, 1, 1, 1],
|
||||
consumedChartValues: [1, 1, 1, 1]));
|
||||
} catch (e) {
|
||||
emit(DiaryState.error(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
loadDiaryById(
|
||||
LoadDiaryById event,
|
||||
Emitter<DiaryState> emit,
|
||||
) async {
|
||||
emit(const DiaryState.loading());
|
||||
try {
|
||||
final int diaryID = int.parse(event.id ?? "0");
|
||||
final DiaryModel diary = await diaryRepository.getDiary(diaryID);
|
||||
final Meal currentMeal = diary.meals[0];
|
||||
|
||||
List<SelectionPopupModel> portionList = [
|
||||
SelectionPopupModel(title: "gr"),
|
||||
SelectionPopupModel(title: "pcs")
|
||||
];
|
||||
|
||||
final Map<String, dynamic> chartData =
|
||||
await diaryRepository.getChartData(diaryID);
|
||||
final Map<String, dynamic> dailyNutritionIntake =
|
||||
chartData['dailyNutritionIntake']!;
|
||||
final Map<String, dynamic> dailyNutritionRecommendations =
|
||||
chartData['dailyNutritionRecommendation']!;
|
||||
final double ccal = dailyNutritionIntake['energy']! /
|
||||
dailyNutritionRecommendations['energy']! *
|
||||
50;
|
||||
final double proteins = dailyNutritionIntake['proteins']! /
|
||||
dailyNutritionRecommendations['proteins']! *
|
||||
50;
|
||||
final double fats = dailyNutritionIntake['fats']! /
|
||||
dailyNutritionRecommendations['fats']! *
|
||||
50;
|
||||
final double carbs = dailyNutritionIntake['carbohydrates']! /
|
||||
dailyNutritionRecommendations['carbohydrates']! *
|
||||
50;
|
||||
|
||||
Color getColor(double value) {
|
||||
if (value >= 99.1) {
|
||||
return Colors.red;
|
||||
} else {
|
||||
return Colors.blue;
|
||||
}
|
||||
}
|
||||
|
||||
final List<NutritionData> chartDataCounted = [
|
||||
NutritionData('Калории', ccal, getColor(ccal)),
|
||||
NutritionData('Белки', proteins, getColor(proteins)),
|
||||
NutritionData('Жиры', fats, getColor(fats)),
|
||||
NutritionData('Углеводы', carbs, getColor(carbs)),
|
||||
];
|
||||
|
||||
List<SelectionPopupModel> mealList = [
|
||||
SelectionPopupModel(title: "Прием пищи 1", id: 1),
|
||||
SelectionPopupModel(title: "Прием пищи 2", id: 2),
|
||||
SelectionPopupModel(title: "Прием пищи 3", id: 3),
|
||||
SelectionPopupModel(title: "Прием пищи 4", id: 4),
|
||||
SelectionPopupModel(title: "Прием пищи 5", id: 5),
|
||||
SelectionPopupModel(title: "Прием пищи 6", id: 6),
|
||||
];
|
||||
|
||||
emit(DiaryState.loaded(
|
||||
diary: diary,
|
||||
currentMeal: currentMeal,
|
||||
|
||||
@@ -15,6 +15,15 @@ class LoadDiary extends DiaryEvent {
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class LoadDiaryById extends DiaryEvent {
|
||||
LoadDiaryById(
|
||||
this.id,
|
||||
);
|
||||
final String? id;
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class ChangeSatiety extends DiaryEvent {
|
||||
ChangeSatiety(
|
||||
this.selectedElement,
|
||||
|
||||
@@ -13,7 +13,9 @@ part 'diary_state.freezed.dart';
|
||||
abstract class DiaryState with _$DiaryState {
|
||||
const factory DiaryState() = _DiaryState;
|
||||
|
||||
const factory DiaryState.loading() = DiaryStateLoading;
|
||||
const factory DiaryState.loading({
|
||||
int? id,
|
||||
}) = DiaryStateLoading;
|
||||
|
||||
const factory DiaryState.loaded({
|
||||
required DiaryModel diary,
|
||||
|
||||
@@ -19,7 +19,7 @@ mixin _$DiaryState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(int? id) loading,
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -56,7 +56,7 @@ mixin _$DiaryState {
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(int? id)? loading,
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -93,7 +93,7 @@ mixin _$DiaryState {
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(int? id)? loading,
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -212,7 +212,7 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(int? id) loading,
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -252,7 +252,7 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(int? id)? loading,
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -292,7 +292,7 @@ class _$DiaryStateImpl implements _DiaryState {
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(int? id)? loading,
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -379,6 +379,8 @@ abstract class _$$DiaryStateLoadingImplCopyWith<$Res> {
|
||||
factory _$$DiaryStateLoadingImplCopyWith(_$DiaryStateLoadingImpl value,
|
||||
$Res Function(_$DiaryStateLoadingImpl) then) =
|
||||
__$$DiaryStateLoadingImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({int? id});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -388,32 +390,57 @@ class __$$DiaryStateLoadingImplCopyWithImpl<$Res>
|
||||
__$$DiaryStateLoadingImplCopyWithImpl(_$DiaryStateLoadingImpl _value,
|
||||
$Res Function(_$DiaryStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
}) {
|
||||
return _then(_$DiaryStateLoadingImpl(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
const _$DiaryStateLoadingImpl();
|
||||
const _$DiaryStateLoadingImpl({this.id});
|
||||
|
||||
@override
|
||||
final int? id;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DiaryState.loading()';
|
||||
return 'DiaryState.loading(id: $id)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$DiaryStateLoadingImpl);
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$DiaryStateLoadingImpl &&
|
||||
(identical(other.id, id) || other.id == id));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
int get hashCode => Object.hash(runtimeType, id);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith =>
|
||||
__$$DiaryStateLoadingImplCopyWithImpl<_$DiaryStateLoadingImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(int? id) loading,
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -446,14 +473,14 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
loaded,
|
||||
required TResult Function(String errorMessage) error,
|
||||
}) {
|
||||
return loading();
|
||||
return loading(id);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(int? id)? loading,
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -486,14 +513,14 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
loaded,
|
||||
TResult? Function(String errorMessage)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
return loading?.call(id);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(int? id)? loading,
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -528,7 +555,7 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
return loading(id);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
@@ -572,7 +599,12 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading {
|
||||
}
|
||||
|
||||
abstract class DiaryStateLoading implements DiaryState {
|
||||
const factory DiaryStateLoading() = _$DiaryStateLoadingImpl;
|
||||
const factory DiaryStateLoading({final int? id}) = _$DiaryStateLoadingImpl;
|
||||
|
||||
int? get id;
|
||||
@JsonKey(ignore: true)
|
||||
_$$DiaryStateLoadingImplCopyWith<_$DiaryStateLoadingImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -1050,7 +1082,7 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(int? id) loading,
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -1118,7 +1150,7 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(int? id)? loading,
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -1186,7 +1218,7 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded {
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(int? id)? loading,
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -1423,7 +1455,7 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>(
|
||||
TResult Function() $default, {
|
||||
required TResult Function() loading,
|
||||
required TResult Function(int? id) loading,
|
||||
required TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -1463,7 +1495,7 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>(
|
||||
TResult? Function()? $default, {
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(int? id)? loading,
|
||||
TResult? Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
@@ -1503,7 +1535,7 @@ class _$DiaryStateErrorImpl implements DiaryStateError {
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>(
|
||||
TResult Function()? $default, {
|
||||
TResult Function()? loading,
|
||||
TResult Function(int? id)? loading,
|
||||
TResult Function(
|
||||
DiaryModel diary,
|
||||
String? diaryDate,
|
||||
|
||||
@@ -31,6 +31,9 @@ class DiaryScreen extends StatelessWidget {
|
||||
});
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
if (diaryID != "0") {
|
||||
context.read<DiaryBloc>().add(LoadDiaryById(diaryID));
|
||||
}
|
||||
return BlocBuilder<DiaryBloc, DiaryState>(
|
||||
builder: (context, state) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
|
||||
Reference in New Issue
Block a user