mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
fix add time when log meal and nutrition
This commit is contained in:
@@ -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>(
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user