-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from Sinnaj94/feat/make-entries-editable
Feature: Make Entries Editable (#36)
- Loading branch information
Showing
15 changed files
with
208 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:opennutritracker/core/data/repository/intake_repository.dart'; | ||
import 'package:opennutritracker/core/domain/entity/intake_entity.dart'; | ||
|
||
class UpdateIntakeUsecase { | ||
final IntakeRepository _intakeRepository; | ||
|
||
UpdateIntakeUsecase(this._intakeRepository); | ||
|
||
Future<IntakeEntity?> updateIntake( | ||
String intakeId, Map<String, dynamic> intakeFields) async { | ||
return await _intakeRepository.updateIntake(intakeId, intakeFields); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:opennutritracker/core/domain/entity/intake_entity.dart'; | ||
import 'package:opennutritracker/generated/l10n.dart'; | ||
|
||
class EditDialog extends StatefulWidget { | ||
final IntakeEntity intakeEntity; | ||
|
||
const EditDialog({super.key, required this.intakeEntity}); | ||
|
||
@override | ||
State<StatefulWidget> createState() => _EditDialogState(); | ||
} | ||
|
||
class _EditDialogState extends State<EditDialog> { | ||
|
||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var amountEditingController = TextEditingController(text: widget.intakeEntity.amount.toInt().toString()); | ||
return AlertDialog( | ||
title: Text(S.of(context).editItemDialogTitle), | ||
content: Column(mainAxisSize: MainAxisSize.min, children: [ | ||
TextFormField( | ||
controller: amountEditingController, | ||
keyboardType: TextInputType.number, | ||
decoration: InputDecoration( | ||
labelText: S.of(context).quantityLabel, | ||
suffixText: widget.intakeEntity.meal.mealUnit ?? S.of(context).gramMilliliterUnit | ||
), | ||
) | ||
]), | ||
actions: [ | ||
TextButton( | ||
onPressed: () { | ||
double newAmount = double.parse(amountEditingController.text); | ||
Navigator.of(context).pop(newAmount); | ||
}, | ||
child: Text(S.of(context).dialogOKLabel)), | ||
TextButton( | ||
onPressed: () { | ||
Navigator.of(context).pop(); | ||
}, | ||
child: Text(S.of(context).dialogCancelLabel)) | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.