Some renaming

This commit is contained in:
Roland Geider
2025-09-24 12:31:28 +02:00
parent 5f7116ca92
commit 530efd366e
8 changed files with 18 additions and 19 deletions

View File

@@ -392,7 +392,7 @@ class NutritionPlansProvider with ChangeNotifier {
}
/// Searches for an ingredient with bar code
Future<Ingredient?> searchIngredientWithCode(String barcode) async {
Future<Ingredient?> searchIngredientWithBarcode(String barcode) async {
if (barcode.isEmpty) {
return null;
}
@@ -406,7 +406,6 @@ class NutritionPlansProvider with ChangeNotifier {
return null;
}
// TODO we should probably add it to ingredient cache.
// TODO: we could also use the ingredient cache for code searches
return Ingredient.fromJson(data['results'][0]);
}

View File

@@ -252,8 +252,8 @@ class IngredientFormState extends State<IngredientForm> {
barcode: widget.barcode,
test: widget.test,
selectIngredient: selectIngredient,
unSelectIngredient: unSelectIngredient,
updateSearchQuery: updateSearchQuery,
onDeselectIngredient: unSelectIngredient,
onUpdateSearchQuery: updateSearchQuery,
),
Row(
children: [

View File

@@ -64,8 +64,8 @@ class IngredientTypeahead extends StatefulWidget {
final bool showScanner;
final Function(int id, String name, num? amount) selectIngredient;
final Function() unSelectIngredient;
final Function(String query) updateSearchQuery;
final Function() onDeselectIngredient;
final Function(String query) onUpdateSearchQuery;
IngredientTypeahead(
this._ingredientIdController,
@@ -74,8 +74,8 @@ class IngredientTypeahead extends StatefulWidget {
this.test = false,
this.barcode = '',
required this.selectIngredient,
required this.unSelectIngredient,
required this.updateSearchQuery,
required this.onDeselectIngredient,
required this.onUpdateSearchQuery,
});
@override
@@ -142,9 +142,8 @@ class _IngredientTypeaheadState extends State<IngredientTypeahead> {
return null;
}
widget.updateSearchQuery(pattern);
// unselect to start a new search
widget.unSelectIngredient();
widget.onUpdateSearchQuery(pattern);
widget.onDeselectIngredient();
return Provider.of<NutritionPlansProvider>(context, listen: false).searchIngredient(
pattern,
@@ -219,7 +218,7 @@ class _IngredientTypeaheadState extends State<IngredientTypeahead> {
context: context,
builder: (context) => FutureBuilder<Ingredient?>(
future: Provider.of<NutritionPlansProvider>(context, listen: false)
.searchIngredientWithCode(barcode),
.searchIngredientWithBarcode(barcode),
builder: (BuildContext context, AsyncSnapshot<Ingredient?> snapshot) {
return IngredientScanResultDialog(snapshot, barcode, widget.selectIngredient);
},