forked from eatvio/eatvio_app
feat(diary): New way of portion send
This commit is contained in:
@@ -527,10 +527,15 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
TimeOfDay? retire,
|
||||
String? comment,
|
||||
) async {
|
||||
final formatter = DateFormat('HH:mm');
|
||||
final wakeupString =
|
||||
formatter.format(DateTime(2022, 1, 1, wakeup!.hour, wakeup.minute));
|
||||
final retireString =
|
||||
formatter.format(DateTime(2022, 1, 1, retire!.hour, retire.minute));
|
||||
final Map<String, dynamic> credentials = {
|
||||
'wakeup': wakeup,
|
||||
'retire': retire,
|
||||
'comment': comment,
|
||||
'wakeup': wakeupString,
|
||||
'retire': retireString,
|
||||
'comment': comment ?? " ",
|
||||
};
|
||||
String url = dotenv.env['SERVER_ROOT']! + '/diary/$diaryID/finishDay';
|
||||
var response = await http.post(Uri.parse(url),
|
||||
|
||||
@@ -482,15 +482,15 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 7.h,
|
||||
top: 5.v,
|
||||
),
|
||||
child: Text(
|
||||
portion['product_name'],
|
||||
style: CustomTextStyles.titleMedium16,
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.only(
|
||||
left: 7.h,
|
||||
top: 5.v,
|
||||
),
|
||||
child: Text(
|
||||
portion['product_name']
|
||||
.substring(0, 8), // Обрезаем название до 8 символов
|
||||
style: CustomTextStyles.titleMedium16,
|
||||
)),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 20.h,
|
||||
@@ -901,13 +901,14 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
),
|
||||
onPressed: () => onFinishDayPressed(context),
|
||||
onPressed: onFinishDayPressed(context),
|
||||
// Установите прозрачный фон
|
||||
);
|
||||
}
|
||||
|
||||
Function onFinishDayPressed(BuildContext context) {
|
||||
Function() onFinishDayPressed(BuildContext context) {
|
||||
return () {
|
||||
print("sad");
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
@@ -917,11 +918,11 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text("Отмена"),
|
||||
onPressed: () => closeDialog(dialogContext),
|
||||
onPressed: closeDialog(dialogContext),
|
||||
),
|
||||
TextButton(
|
||||
child: Text("Подтвердить"),
|
||||
onPressed: () => sendFinishDayData(dialogContext, context),
|
||||
onPressed: sendFinishDayData(dialogContext, context),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -930,14 +931,15 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
Function sendFinishDayData(BuildContext dialogContext, BuildContext context) {
|
||||
Function() sendFinishDayData(
|
||||
BuildContext dialogContext, BuildContext context) {
|
||||
return () {
|
||||
closeDialog(dialogContext);
|
||||
context.read<DiaryEditBloc>().add(FinishDay());
|
||||
};
|
||||
}
|
||||
|
||||
Function closeDialog(BuildContext dialogContext) {
|
||||
Function() closeDialog(BuildContext dialogContext) {
|
||||
return () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user