fix add time when log meal and nutrition

This commit is contained in:
cryptbrn
2026-01-31 12:28:11 +07:00
parent ad0f343c72
commit 6317cc7fe9
2 changed files with 6 additions and 4 deletions

View File

@@ -63,7 +63,8 @@ class _LogMealScreenState extends State<LogMealScreen> {
@override
Widget build(BuildContext context) {
final dateFormat = DateFormat.yMd(Localizations.localeOf(context).languageCode).add_Hm();
final dateFormat = DateFormat.yMd(Localizations.localeOf(context).languageCode);
final dateTimeFormat = DateFormat.yMd(Localizations.localeOf(context).languageCode).add_Hm();
final i18n = AppLocalizations.of(context);
final args = ModalRoute.of(context)!.settings.arguments as LogMealArguments;
@@ -174,7 +175,7 @@ class _LogMealScreenState extends State<LogMealScreen> {
TextButton(
child: Text(i18n.save),
onPressed: () async {
final loggedDate = dateFormat.parse(
final loggedDate = dateTimeFormat.parse(
'${_dateController.text} ${_timeController.text}',
);
await Provider.of<NutritionPlansProvider>(

View File

@@ -228,8 +228,9 @@ class IngredientFormState extends State<IngredientForm> {
@override
Widget build(BuildContext context) {
final languageCode = Localizations.localeOf(context).languageCode;
final dateFormat = DateFormat.yMd(languageCode).add_Hm();
final dateFormat = DateFormat.yMd(languageCode);
final timeFormat = DateFormat.Hm(languageCode);
final dateTimeFormat = DateFormat.yMd(languageCode).add_Hm();
if (_dateController.text.isEmpty) {
_dateController.text = dateFormat.format(DateTime.now());
@@ -405,7 +406,7 @@ class IngredientFormState extends State<IngredientForm> {
_form.currentState!.save();
_mealItem.ingredientId = int.parse(_ingredientIdController.text);
final loggedDate = dateFormat.parse(
final loggedDate = dateTimeFormat.parse(
'${_dateController.text} ${_timeController.text}',
);
widget.onSave(context, _mealItem, loggedDate);