forked from eatvio/eatvio_app
Refactoring diary started
This commit is contained in:
@@ -92,7 +92,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
Widget _buildHeaderRow(BuildContext context, DiaryEditLoadedState state) {
|
||||
_buildHeaderRow(BuildContext context, DiaryEditLoadedState state) {
|
||||
final day = state.diaryId;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h, vertical: 16.h),
|
||||
@@ -102,7 +102,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
@@ -116,10 +116,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
CustomImageView(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
onTap: () {
|
||||
NavigatorService.goBack();
|
||||
}),
|
||||
imagePath: ImageConstant.imgArrowLeft, onTap: onTapBack()),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 1.v),
|
||||
child: Column(
|
||||
@@ -144,30 +141,32 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
onTapBack() {
|
||||
return () {
|
||||
NavigatorService.goBack();
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
Widget _buildAddProduct(BuildContext context, DiaryEditLoadedState state) {
|
||||
_buildAddProduct(BuildContext context, DiaryEditLoadedState state) {
|
||||
return CustomOutlinedButton(
|
||||
text: "Добавить продукт",
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
onPressed: () {
|
||||
context.read<DiaryEditBloc>().add(AddPortionEvent());
|
||||
},
|
||||
onPressed: addProduct(context),
|
||||
);
|
||||
}
|
||||
|
||||
addProduct(BuildContext context) {
|
||||
return () {
|
||||
context.read<DiaryEditBloc>().add(AddPortionEvent());
|
||||
};
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
Widget _buildAddPhoto(BuildContext context) {
|
||||
_buildAddPhoto(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
final picker = ImagePicker();
|
||||
List<XFile>? images = await picker.pickMultiImage();
|
||||
if (images.isNotEmpty) {
|
||||
for (var image in images) {
|
||||
context.read<DiaryEditBloc>().add(UploadImages(image));
|
||||
}
|
||||
}
|
||||
},
|
||||
onTap: addImage(context),
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
@@ -202,243 +201,249 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Padding _buildMeal(BuildContext context, DiaryEditLoadedState state) {
|
||||
addImage(BuildContext context) {
|
||||
return () async {
|
||||
final picker = ImagePicker();
|
||||
List<XFile>? images = await picker.pickMultiImage();
|
||||
if (images.isNotEmpty) {
|
||||
for (var image in images) {
|
||||
context.read<DiaryEditBloc>().add(UploadImages(image));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_buildMeal(BuildContext context, DiaryEditLoadedState state) {
|
||||
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
|
||||
List<String> _options =
|
||||
state.autocompleteList!.map((dynamic item) => item as String).toList();
|
||||
print(_options);
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Время приема пищи",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width - 260,
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () => _selectMealTime(context, state),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText: state.mealTimeController
|
||||
?.format(context)
|
||||
.toString(),
|
||||
autofocus: false,
|
||||
),
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Время приема пищи",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width - 260,
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () => _selectMealTime(context, state),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText: state.mealTimeController
|
||||
?.format(context)
|
||||
.toString(),
|
||||
autofocus: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: BlocSelector<DiaryEditBloc, DiaryEditState,
|
||||
DiaryEditModel?>(
|
||||
selector: (state) => state.diaryEditModelObj,
|
||||
builder: (context, diaryEditModelObj) {
|
||||
return CustomDropDown(
|
||||
hintText: "Прием пищи",
|
||||
items: diaryEditModelObj?.mealList,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: 10.h,
|
||||
vertical: 9.v,
|
||||
),
|
||||
defaultValue: diaryEditModelObj?.mealList[0],
|
||||
onChanged: (value) {
|
||||
context.read<DiaryEditBloc>().add(
|
||||
ChangeMeal(meals: state.meals, value: value));
|
||||
},
|
||||
);
|
||||
})),
|
||||
SizedBox(height: 20.v),
|
||||
Padding(
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: RawAutocomplete<String>(
|
||||
optionsBuilder: (TextEditingValue textEditingValue) {
|
||||
return _options.where((String option) {
|
||||
return true;
|
||||
});
|
||||
}, fieldViewBuilder: (
|
||||
BuildContext context,
|
||||
TextEditingController textEditingController,
|
||||
FocusNode focusNode,
|
||||
VoidCallback onFieldSubmitted,
|
||||
) {
|
||||
return CustomTextFormField(
|
||||
hintText: "Введите название продукта",
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
onChanged: (value) {
|
||||
/*print(state.autocompleteList
|
||||
child: BlocSelector<DiaryEditBloc, DiaryEditState,
|
||||
DiaryEditModel?>(
|
||||
selector: (state) => state.diaryEditModelObj,
|
||||
builder: (context, diaryEditModelObj) {
|
||||
return CustomDropDown(
|
||||
hintText: "Прием пищи",
|
||||
items: diaryEditModelObj?.mealList,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: 10.h,
|
||||
vertical: 9.v,
|
||||
),
|
||||
defaultValue: diaryEditModelObj?.mealList[0],
|
||||
onChanged: (value) {
|
||||
context.read<DiaryEditBloc>().add(
|
||||
ChangeMeal(meals: state.meals, value: value));
|
||||
},
|
||||
);
|
||||
})),
|
||||
SizedBox(height: 20.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: RawAutocomplete<String>(
|
||||
optionsBuilder: (TextEditingValue textEditingValue) {
|
||||
return _options.where((String option) {
|
||||
return true;
|
||||
});
|
||||
}, fieldViewBuilder: (
|
||||
BuildContext context,
|
||||
TextEditingController textEditingController,
|
||||
FocusNode focusNode,
|
||||
VoidCallback onFieldSubmitted,
|
||||
) {
|
||||
return CustomTextFormField(
|
||||
hintText: "Введите название продукта",
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
onChanged: (value) {
|
||||
/*print(state.autocompleteList
|
||||
?.map((dynamic item) => item as String)
|
||||
.toList());*/
|
||||
if (value.length > 2) {
|
||||
context.read<DiaryEditBloc>().add(ProductInput(value));
|
||||
}
|
||||
},
|
||||
/*onFieldSubmitted: (String value) {
|
||||
if (value.length > 2) {
|
||||
context.read<DiaryEditBloc>().add(ProductInput(value));
|
||||
}
|
||||
},
|
||||
/*onFieldSubmitted: (String value) {
|
||||
onFieldSubmitted();
|
||||
},*/
|
||||
);
|
||||
}, 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: () {
|
||||
onSelected(option);
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text(option),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}, 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: () {
|
||||
onSelected(option);
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text(option),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
CustomTextFormField(
|
||||
width: 146.h,
|
||||
hintText: "Кол-во",
|
||||
textInputAction: TextInputAction.done,
|
||||
controller: state.productQuantityController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[digitsOnly],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 30.h),
|
||||
child: Text(
|
||||
"порций",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 30.v),
|
||||
_buildAddProduct(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
...state.portions!
|
||||
.map((portion) => _buildProduct(context, portion))
|
||||
.toList(),
|
||||
SizedBox(height: 30.v),
|
||||
_buildAddPhoto(context),
|
||||
SizedBox(height: 30.v),
|
||||
Text(
|
||||
"Ваша сытость после приёма пищи",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
SizedBox(height: 15.v),
|
||||
BlocBuilder<DiaryEditBloc, DiaryEditState>(
|
||||
builder: (context, state) {
|
||||
if (state is DiaryEditLoadedState) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("😭"),
|
||||
ScaleElement(
|
||||
color: Colors.red,
|
||||
isSelected: state.selectedSatiety == 0,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(0));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.orange,
|
||||
isSelected: state.selectedSatiety == 1,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(1));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.yellow,
|
||||
isSelected: state.selectedSatiety == 2,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(2));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.lime,
|
||||
isSelected: state.selectedSatiety == 3,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(3));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.lightGreen,
|
||||
isSelected: state.selectedSatiety == 4,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(4));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.green,
|
||||
isSelected: state.selectedSatiety == 5,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(5));
|
||||
},
|
||||
),
|
||||
Text("😊"),
|
||||
// Остальные элементы шкалы
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
CustomTextFormField(
|
||||
width: 146.h,
|
||||
hintText: "Кол-во",
|
||||
textInputAction: TextInputAction.done,
|
||||
controller: state.productQuantityController,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: <TextInputFormatter>[digitsOnly],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 30.h),
|
||||
child: Text(
|
||||
"порций",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 30.v),
|
||||
_buildAddProduct(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
...state.portions!
|
||||
.map((portion) => _buildProduct(context, portion))
|
||||
.toList(),
|
||||
SizedBox(height: 30.v),
|
||||
_buildAddPhoto(context),
|
||||
SizedBox(height: 30.v),
|
||||
Text(
|
||||
"Ваша сытость после приёма пищи",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
SizedBox(height: 15.v),
|
||||
BlocBuilder<DiaryEditBloc, DiaryEditState>(
|
||||
builder: (context, state) {
|
||||
if (state is DiaryEditLoadedState) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("😭"),
|
||||
ScaleElement(
|
||||
color: Colors.red,
|
||||
isSelected: state.selectedSatiety == 0,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(0));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.orange,
|
||||
isSelected: state.selectedSatiety == 1,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(1));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.yellow,
|
||||
isSelected: state.selectedSatiety == 2,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(2));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.lime,
|
||||
isSelected: state.selectedSatiety == 3,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(3));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.lightGreen,
|
||||
isSelected: state.selectedSatiety == 4,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(4));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.green,
|
||||
isSelected: state.selectedSatiety == 5,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeSatiety(5));
|
||||
},
|
||||
),
|
||||
Text("😊"),
|
||||
// Остальные элементы шкалы
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Container(); // Возвращаем пустой контейнер, если состояние не является DiaryEditLoadedState
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
} else {
|
||||
return Container(); // Возвращаем пустой контейнер, если состояние не является DiaryEditLoadedState
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
@@ -497,7 +502,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNutritionChart(BuildContext context) {
|
||||
_buildNutritionChart(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
@@ -506,7 +511,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
@@ -737,148 +742,129 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
Widget _buildComment(BuildContext context, DiaryEditLoadedState state) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
_buildComment(BuildContext context, DiaryEditLoadedState state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Дополнительная информация для консультанта",
|
||||
style: theme.textTheme.titleMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Дополнительная информация для консультанта",
|
||||
style: theme.textTheme.titleMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 20.v),
|
||||
Container(
|
||||
width: 320.h,
|
||||
child: CustomTextFormField(
|
||||
autofocus: false,
|
||||
hintText: "Введите информацию для консультанта",
|
||||
maxLines: 7,
|
||||
borderDecoration: InputBorder.none,
|
||||
controller: state.commentController,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(height: 20.v),
|
||||
Container(
|
||||
width: 320.h,
|
||||
child: CustomTextFormField(
|
||||
autofocus: false,
|
||||
hintText: "Введите информацию для консультанта",
|
||||
maxLines: 7,
|
||||
borderDecoration: InputBorder.none,
|
||||
controller: state.commentController,
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Padding _buildWakupRetire(BuildContext context, DiaryEditLoadedState state) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
_buildWakupRetire(BuildContext context, DiaryEditLoadedState state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
BlocProvider.of<DiaryEditBloc>(context)
|
||||
.add(ToggleWakeupExpandedEvent());
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
r"Подъем \ отход ко сну",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
Icon(state.wakeupExpanded
|
||||
? Icons.arrow_drop_up
|
||||
: Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
BlocProvider.of<DiaryEditBloc>(context)
|
||||
.add(ToggleWakeupExpandedEvent());
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
r"Подъем \ отход ко сну",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
if (state.wakeupExpanded)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 20.v),
|
||||
GestureDetector(
|
||||
onTap: () => _selectWakeupTime(context, state),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText:
|
||||
state.wakeupController?.format(context).toString(),
|
||||
prefix: Icon(Icons.sunny),
|
||||
autofocus: false,
|
||||
),
|
||||
),
|
||||
Icon(state.wakeupExpanded
|
||||
? Icons.arrow_drop_up
|
||||
: Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (state.wakeupExpanded)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 20.v),
|
||||
GestureDetector(
|
||||
onTap: () => _selectWakeupTime(context, state),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText: state.wakeupController
|
||||
?.format(context)
|
||||
.toString(),
|
||||
prefix: Icon(Icons.sunny),
|
||||
autofocus: false,
|
||||
/*initialValue: state.wakeupController
|
||||
?.format(context)
|
||||
.toString()*/
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
GestureDetector(
|
||||
onTap: () => _selectRetireTime(context, state),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText: state.retireController
|
||||
?.format(context)
|
||||
.toString(),
|
||||
prefix: Icon(Icons.bed),
|
||||
autofocus: false,
|
||||
/*initialValue: state.retireController
|
||||
?.format(context)
|
||||
.toString(),*/
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
SizedBox(height: 20.v),
|
||||
GestureDetector(
|
||||
onTap: () => _selectRetireTime(context, state),
|
||||
child: AbsorbPointer(
|
||||
child: CustomTextFormField(
|
||||
hintText:
|
||||
state.retireController?.format(context).toString(),
|
||||
prefix: Icon(Icons.bed),
|
||||
autofocus: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
Widget _buildEndDay(BuildContext context) {
|
||||
_buildEndDay(BuildContext context) {
|
||||
return CustomOutlinedButton(
|
||||
text: "Закончить день",
|
||||
margin: EdgeInsets.only(
|
||||
@@ -893,97 +879,96 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMood(BuildContext context, DiaryEditLoadedState state) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
_buildMood(BuildContext context, DiaryEditLoadedState state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
],
|
||||
),
|
||||
child: Column(children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
BlocProvider.of<DiaryEditBloc>(context)
|
||||
.add(ToggleMoodExpandedEvent());
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Ваше настроение после приема пищи",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
Icon(state.moodExpanded
|
||||
? Icons.arrow_drop_up
|
||||
: Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
child: Column(children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
BlocProvider.of<DiaryEditBloc>(context)
|
||||
.add(ToggleMoodExpandedEvent());
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Ваше настроение после приема пищи",
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
Icon(state.moodExpanded
|
||||
? Icons.arrow_drop_up
|
||||
: Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
if (state.moodExpanded)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("😭"),
|
||||
ScaleElement(
|
||||
color: Colors.red,
|
||||
isSelected: state.selectedMood == 0,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(0));
|
||||
},
|
||||
),
|
||||
),
|
||||
if (state.moodExpanded)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("😭"),
|
||||
ScaleElement(
|
||||
color: Colors.red,
|
||||
isSelected: state.selectedMood == 0,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(0));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.orange,
|
||||
isSelected: state.selectedMood == 1,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(1));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.yellow,
|
||||
isSelected: state.selectedMood == 2,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(2));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.lime,
|
||||
isSelected: state.selectedMood == 3,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(3));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.lightGreen,
|
||||
isSelected: state.selectedMood == 4,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(4));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.green,
|
||||
isSelected: state.selectedMood == 5,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(5));
|
||||
},
|
||||
),
|
||||
Text("😊"),
|
||||
// Остальные элементы шкалы
|
||||
],
|
||||
ScaleElement(
|
||||
color: Colors.orange,
|
||||
isSelected: state.selectedMood == 1,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(1));
|
||||
},
|
||||
),
|
||||
])));
|
||||
ScaleElement(
|
||||
color: Colors.yellow,
|
||||
isSelected: state.selectedMood == 2,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(2));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.lime,
|
||||
isSelected: state.selectedMood == 3,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(3));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.lightGreen,
|
||||
isSelected: state.selectedMood == 4,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(4));
|
||||
},
|
||||
),
|
||||
ScaleElement(
|
||||
color: Colors.green,
|
||||
isSelected: state.selectedMood == 5,
|
||||
onTap: () {
|
||||
context.read<DiaryEditBloc>().add(ChangeMood(5));
|
||||
},
|
||||
),
|
||||
Text("😊"),
|
||||
// Остальные элементы шкалы
|
||||
],
|
||||
),
|
||||
]));
|
||||
}
|
||||
|
||||
Future<void> _selectWakeupTime(
|
||||
|
||||
Reference in New Issue
Block a user