[preset] GO
This commit is contained in:
parent
c443901714
commit
e9b2c280d4
2 changed files with 11 additions and 5 deletions
|
@ -70,7 +70,14 @@ class _AddMealScreen extends State<AddMealScreen> {
|
||||||
popMeDaddy();
|
popMeDaddy();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _deletePreset(context, Preset preset) async {
|
Future<void> _deletePreset(Preset preset) async {
|
||||||
|
widget.apiClient.deletePreset(preset.id);
|
||||||
|
setState(() {
|
||||||
|
presets.remove(preset);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deletePreset(context, Preset preset) async {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
|
@ -86,7 +93,7 @@ class _AddMealScreen extends State<AddMealScreen> {
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.delete),
|
icon: const Icon(Icons.delete),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
widget.apiClient.deletePreset(preset.id);
|
_deletePreset(preset);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -113,8 +120,6 @@ class _AddMealScreen extends State<AddMealScreen> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
_getPresets();
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
|
@ -151,7 +156,7 @@ class _AddMealScreen extends State<AddMealScreen> {
|
||||||
_addMealFromPreset();
|
_addMealFromPreset();
|
||||||
},
|
},
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
_deletePreset(context, preset);
|
deletePreset(context, preset);
|
||||||
},
|
},
|
||||||
title: PresetWidget(
|
title: PresetWidget(
|
||||||
preset: preset,
|
preset: preset,
|
||||||
|
|
|
@ -19,6 +19,7 @@ class MealWidget extends StatelessWidget {
|
||||||
|
|
||||||
Future<void> saveMeal(context) async {
|
Future<void> saveMeal(context) async {
|
||||||
TextEditingController textFieldController = TextEditingController();
|
TextEditingController textFieldController = TextEditingController();
|
||||||
|
textFieldController.text = meal.name;
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
Loading…
Reference in a new issue