forked from eatvio/eatvio_app
feat(diary) Finished static layouts
This commit is contained in:
@@ -2,10 +2,9 @@ import 'bloc/diary_edit_bloc.dart';
|
|||||||
import 'models/diary_edit_model.dart';
|
import 'models/diary_edit_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:eatvio_app/core/app_export.dart';
|
import 'package:eatvio_app/core/app_export.dart';
|
||||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||||
import 'package:eatvio_app/widgets/custom_edit_drop_down.dart';
|
import 'package:eatvio_app/widgets/custom_edit_drop_down.dart';
|
||||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||||
import 'package:eatvio_app/widgets/custom_icon_button.dart';
|
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class DiaryEditScreen extends StatelessWidget {
|
class DiaryEditScreen extends StatelessWidget {
|
||||||
@@ -14,12 +13,6 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
key: key,
|
key: key,
|
||||||
);
|
);
|
||||||
|
|
||||||
List<String> dropdownItemList = [
|
|
||||||
"Item One",
|
|
||||||
"Item Two",
|
|
||||||
"Item Three",
|
|
||||||
];
|
|
||||||
|
|
||||||
List<String> mealList = [
|
List<String> mealList = [
|
||||||
"Прием пищи 1",
|
"Прием пищи 1",
|
||||||
"Прием пищи 2",
|
"Прием пищи 2",
|
||||||
@@ -29,10 +22,13 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
"Прием пищи 6",
|
"Прием пищи 6",
|
||||||
];
|
];
|
||||||
|
|
||||||
List<String> dropdownItemList2 = [
|
List<String> satietyList = [
|
||||||
"Item One",
|
"Ужасное",
|
||||||
"Item Two",
|
"Плохое",
|
||||||
"Item Three",
|
"Удовлетворительное",
|
||||||
|
"Нормальное",
|
||||||
|
"Хорошее",
|
||||||
|
"Прекрасное",
|
||||||
];
|
];
|
||||||
|
|
||||||
List<String> moodList = [
|
List<String> moodList = [
|
||||||
@@ -169,16 +165,6 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Section Widget
|
|
||||||
Widget _buildEnterProductName(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8.h),
|
|
||||||
child: CustomTextFormField(
|
|
||||||
hintText: "Введите названия продукта",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Section Widget
|
/// Section Widget
|
||||||
Widget _buildAddProduct(BuildContext context) {
|
Widget _buildAddProduct(BuildContext context) {
|
||||||
return CustomOutlinedButton(
|
return CustomOutlinedButton(
|
||||||
@@ -242,7 +228,7 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: MediaQuery.of(context).size.width - 210,
|
maxWidth: MediaQuery.of(context).size.width - 247,
|
||||||
),
|
),
|
||||||
child: CustomTextFormField(
|
child: CustomTextFormField(
|
||||||
hintText: "14:52",
|
hintText: "14:52",
|
||||||
@@ -259,19 +245,24 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
hintText: "Прием пищи",
|
hintText: "Прием пищи",
|
||||||
items: mealList,
|
items: mealList,
|
||||||
contentPadding: EdgeInsets.symmetric(
|
contentPadding: EdgeInsets.symmetric(
|
||||||
horizontal: 15.h,
|
horizontal: 10.h,
|
||||||
vertical: 9.v,
|
vertical: 9.v,
|
||||||
),
|
),
|
||||||
onChanged: (value) {},
|
onChanged: (value) {},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 20.v),
|
SizedBox(height: 20.v),
|
||||||
_buildEnterProductName(context),
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||||
|
child: CustomTextFormField(
|
||||||
|
hintText: "Введите названия продукта",
|
||||||
|
),
|
||||||
|
),
|
||||||
SizedBox(height: 20.v),
|
SizedBox(height: 20.v),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
padding: EdgeInsets.symmetric(horizontal: 10.h),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
CustomTextFormField(
|
CustomTextFormField(
|
||||||
width: 146.h,
|
width: 146.h,
|
||||||
@@ -279,7 +270,7 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(left: 10.h),
|
padding: EdgeInsets.only(right: 30.h),
|
||||||
child: Text(
|
child: Text(
|
||||||
"порций",
|
"порций",
|
||||||
style: CustomTextStyles.bodyMediumBlack900,
|
style: CustomTextStyles.bodyMediumBlack900,
|
||||||
@@ -288,16 +279,28 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 30.v),
|
SizedBox(height: 30.v),
|
||||||
|
|
||||||
_buildAddProduct(context),
|
_buildAddProduct(context),
|
||||||
SizedBox(height: 30.v),
|
SizedBox(height: 30.v),
|
||||||
//_buildAddPhoto(context),
|
//_buildAddPhoto(context),
|
||||||
SizedBox(height: 29.v),
|
|
||||||
Text(
|
Text(
|
||||||
"Ваша сытость после приёма пищи",
|
"Ваша сытость после приёма пищи",
|
||||||
style: CustomTextStyles.bodyMediumBlack900,
|
style: CustomTextStyles.bodyMediumBlack900,
|
||||||
),
|
),
|
||||||
SizedBox(height: 15.v),
|
SizedBox(height: 15.v),
|
||||||
|
CustomDropDown(
|
||||||
|
icon: Container(
|
||||||
|
margin: EdgeInsets.fromLTRB(30.h, 30.v, 20.h, 30.v),
|
||||||
|
child: CustomImageView(
|
||||||
|
imagePath: ImageConstant.imgArrowLeft,
|
||||||
|
height: 10.v,
|
||||||
|
width: 18.h,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
hintText: "Сытость",
|
||||||
|
items: satietyList,
|
||||||
|
borderDecoration: InputBorder.none,
|
||||||
|
onChanged: (value) {},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
@@ -736,77 +739,80 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
bottom: 41.v,
|
bottom: 41.v,
|
||||||
),
|
),
|
||||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.transparent,
|
||||||
|
), // Установите прозрачный фон
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildMood(
|
Widget _buildMood(
|
||||||
List<String> moodList, BuildContext context, DiaryEditLoadedState state) {
|
List<String> moodList, BuildContext context, DiaryEditLoadedState state) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16.h),
|
padding: EdgeInsets.symmetric(horizontal: 16.h),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: 24.h,
|
horizontal: 24.h,
|
||||||
vertical: 12.v,
|
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(children: [
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
/*BlocProvider.of<DiaryEditBloc>(context)
|
|
||||||
.add(ToggleWakeupExpandedEvent());*/
|
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Ваше настроение после приема пищи",
|
|
||||||
style: CustomTextStyles.bodyMediumBlack900,
|
|
||||||
),
|
|
||||||
Icon(state.wakeupExpanded
|
|
||||||
? Icons.arrow_drop_up
|
|
||||||
: Icons.arrow_drop_down),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (state.moodExpanded)
|
decoration: BoxDecoration(
|
||||||
CustomDropDown(
|
color: Colors.white,
|
||||||
icon: Container(
|
borderRadius: BorderRadius.circular(12),
|
||||||
margin: EdgeInsets.fromLTRB(30.h, 30.v, 20.h, 30.v),
|
boxShadow: [
|
||||||
child: CustomImageView(
|
BoxShadow(
|
||||||
imagePath: ImageConstant.imgArrowLeft,
|
color: Colors.grey.withOpacity(0.5),
|
||||||
height: 10.v,
|
spreadRadius: 2,
|
||||||
width: 18.h,
|
blurRadius: 5,
|
||||||
),
|
offset: Offset(0, 3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
/*BlocProvider.of<DiaryEditBloc>(context)
|
||||||
|
.add(ToggleWakeupExpandedEvent());*/
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Ваше настроение после приема пищи",
|
||||||
|
style: CustomTextStyles.bodyMediumBlack900,
|
||||||
|
),
|
||||||
|
Icon(state.wakeupExpanded
|
||||||
|
? Icons.arrow_drop_up
|
||||||
|
: Icons.arrow_drop_down),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
hintText: "Ваше настроение после приема пищи",
|
|
||||||
items: moodList,
|
|
||||||
onChanged: (value) {},
|
|
||||||
),
|
),
|
||||||
])));
|
if (state.moodExpanded)
|
||||||
}
|
CustomDropDown(
|
||||||
|
icon: Container(
|
||||||
Future<void> _selectTime(
|
margin: EdgeInsets.fromLTRB(30.h, 30.v, 20.h, 30.v),
|
||||||
BuildContext context, DiaryEditLoadedState state) async {
|
child: CustomImageView(
|
||||||
final TimeOfDay? pickedTime = await showTimePicker(
|
imagePath: ImageConstant.imgArrowLeft,
|
||||||
context: context,
|
height: 10.v,
|
||||||
initialTime: state.wakeupController ?? TimeOfDay.now(),
|
width: 18.h,
|
||||||
);
|
),
|
||||||
if (pickedTime != null && pickedTime != state.wakeupController) {
|
),
|
||||||
state.wakeupController = pickedTime;
|
hintText: "Ваше настроение после приема пищи",
|
||||||
|
items: moodList,
|
||||||
|
borderDecoration: InputBorder.none,
|
||||||
|
onChanged: (value) {},
|
||||||
|
),
|
||||||
|
])));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _selectTime(
|
||||||
|
BuildContext context, DiaryEditLoadedState state) async {
|
||||||
|
final TimeOfDay? pickedTime = await showTimePicker(
|
||||||
|
context: context,
|
||||||
|
initialTime: state.wakeupController ?? TimeOfDay.now(),
|
||||||
|
);
|
||||||
|
if (pickedTime != null && pickedTime != state.wakeupController) {
|
||||||
|
state.wakeupController = pickedTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*Widget _buildImageStack(BuildContext context) {
|
/*Widget _buildImageStack(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@@ -1032,4 +1038,5 @@ Future<void> _selectTime(
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}*/
|
}*/
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:eatvio_app/core/app_export.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CustomDropDown extends StatelessWidget {
|
class CustomDropDown extends StatelessWidget {
|
||||||
@@ -114,20 +115,17 @@ class CustomDropDown extends StatelessWidget {
|
|||||||
filled: filled,
|
filled: filled,
|
||||||
border: borderDecoration ??
|
border: borderDecoration ??
|
||||||
OutlineInputBorder(
|
OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8.h),
|
||||||
borderSide: BorderSide.none,
|
borderSide: BorderSide.none,
|
||||||
),
|
),
|
||||||
enabledBorder: borderDecoration ??
|
enabledBorder: borderDecoration ??
|
||||||
OutlineInputBorder(
|
OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8.h),
|
||||||
borderSide: BorderSide(color: Colors.grey, width: 1)),
|
borderSide: BorderSide(color: Colors.grey, width: 1)),
|
||||||
focusedBorder: borderDecoration ??
|
focusedBorder: borderDecoration ??
|
||||||
OutlineInputBorder(
|
OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5.h),
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||||
color: Colors.blue,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
144
lib/widgets/custom_edit_text_form_field.dart
Normal file
144
lib/widgets/custom_edit_text_form_field.dart
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
import 'package:eatvio_app/core/app_export.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
class CustomTextFormField extends StatelessWidget {
|
||||||
|
CustomTextFormField({
|
||||||
|
Key? key,
|
||||||
|
this.alignment,
|
||||||
|
this.width,
|
||||||
|
this.controller,
|
||||||
|
this.focusNode,
|
||||||
|
this.autofocus = true,
|
||||||
|
this.textStyle,
|
||||||
|
this.obscureText = false,
|
||||||
|
this.textInputAction = TextInputAction.next,
|
||||||
|
this.textInputType = TextInputType.text,
|
||||||
|
this.maxLines,
|
||||||
|
this.hintText,
|
||||||
|
this.hintStyle,
|
||||||
|
this.prefix,
|
||||||
|
this.prefixConstraints,
|
||||||
|
this.suffix,
|
||||||
|
this.suffixConstraints,
|
||||||
|
this.contentPadding,
|
||||||
|
this.inputFormatters,
|
||||||
|
this.borderDecoration,
|
||||||
|
this.fillColor,
|
||||||
|
this.filled = true,
|
||||||
|
this.validator,
|
||||||
|
this.keyboardType,
|
||||||
|
this.onSaved,
|
||||||
|
}) : super(
|
||||||
|
key: key,
|
||||||
|
);
|
||||||
|
|
||||||
|
final Alignment? alignment;
|
||||||
|
|
||||||
|
final double? width;
|
||||||
|
|
||||||
|
final TextEditingController? controller;
|
||||||
|
|
||||||
|
final FocusNode? focusNode;
|
||||||
|
|
||||||
|
final bool? autofocus;
|
||||||
|
|
||||||
|
final TextStyle? textStyle;
|
||||||
|
|
||||||
|
final bool? obscureText;
|
||||||
|
|
||||||
|
final List<TextInputFormatter>? inputFormatters;
|
||||||
|
|
||||||
|
final TextInputAction? textInputAction;
|
||||||
|
|
||||||
|
final TextInputType? textInputType;
|
||||||
|
|
||||||
|
final int? maxLines;
|
||||||
|
|
||||||
|
final String? hintText;
|
||||||
|
|
||||||
|
final TextStyle? hintStyle;
|
||||||
|
|
||||||
|
final Widget? prefix;
|
||||||
|
|
||||||
|
final BoxConstraints? prefixConstraints;
|
||||||
|
|
||||||
|
final Widget? suffix;
|
||||||
|
|
||||||
|
final BoxConstraints? suffixConstraints;
|
||||||
|
|
||||||
|
final EdgeInsets? contentPadding;
|
||||||
|
|
||||||
|
final InputBorder? borderDecoration;
|
||||||
|
|
||||||
|
final Color? fillColor;
|
||||||
|
|
||||||
|
final bool? filled;
|
||||||
|
|
||||||
|
final TextInputType? keyboardType;
|
||||||
|
|
||||||
|
final FormFieldValidator<String>? validator;
|
||||||
|
|
||||||
|
final void Function(String?)? onSaved;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return alignment != null
|
||||||
|
? Align(
|
||||||
|
alignment: alignment ?? Alignment.center,
|
||||||
|
child: textFormFieldWidget,
|
||||||
|
)
|
||||||
|
: textFormFieldWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget get textFormFieldWidget => SizedBox(
|
||||||
|
width: width ?? double.maxFinite,
|
||||||
|
child: TextFormField(
|
||||||
|
controller: controller,
|
||||||
|
focusNode: focusNode ?? FocusNode(),
|
||||||
|
autofocus: autofocus!,
|
||||||
|
style: textStyle ?? theme.textTheme.titleMedium,
|
||||||
|
obscureText: obscureText!,
|
||||||
|
textInputAction: textInputAction,
|
||||||
|
maxLines: maxLines ?? 1,
|
||||||
|
decoration: decoration,
|
||||||
|
validator: validator,
|
||||||
|
keyboardType: keyboardType,
|
||||||
|
onSaved: onSaved,
|
||||||
|
inputFormatters: inputFormatters,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
InputDecoration get decoration => InputDecoration(
|
||||||
|
hintText: hintText ?? "",
|
||||||
|
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,
|
||||||
|
prefixIcon: prefix,
|
||||||
|
prefixIconConstraints: prefixConstraints,
|
||||||
|
suffixIcon: suffix,
|
||||||
|
suffixIconConstraints: suffixConstraints,
|
||||||
|
isDense: true,
|
||||||
|
contentPadding: contentPadding ?? EdgeInsets.all(6.h),
|
||||||
|
fillColor: fillColor ?? theme.colorScheme.onPrimary,
|
||||||
|
filled: filled,
|
||||||
|
border: borderDecoration ??
|
||||||
|
OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8.h),
|
||||||
|
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||||
|
),
|
||||||
|
enabledBorder: borderDecoration ??
|
||||||
|
OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8.h),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.grey,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
focusedBorder: borderDecoration ??
|
||||||
|
OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8.h),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.grey,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user