mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Some renaming
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user