Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
judemont committed Apr 8, 2024
1 parent 2e66c98 commit 8ce78f5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 48 deletions.
17 changes: 8 additions & 9 deletions lib/widgets/homePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class _HomePageState extends State<HomePage> {
backup: backup,
restore: restore,
)),
body: Column(
body: SingleChildScrollView(
child: Column(
children: [
Visibility(
visible: displaySearchField,
Expand All @@ -71,16 +72,14 @@ class _HomePageState extends State<HomePage> {
loadRecipes(searchQuery: value);
},
)),
SingleChildScrollView(
child: RecipeListView(
reloadRecipes: loadRecipes,
recipes: recipes,
onRecipesSelectionUpdate: onRecipesSelectionUpdate,
selectedRecipesID: selectedRecipes,
),
RecipeListView(
reloadRecipes: loadRecipes,
recipes: recipes,
onRecipesSelectionUpdate: onRecipesSelectionUpdate,
selectedRecipesID: selectedRecipes,
),
],
));
)));
}

Future<void> loadRecipes({searchQuery = ""}) async {
Expand Down
74 changes: 36 additions & 38 deletions lib/widgets/recipesListView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,43 @@ class _RecipeListViewState extends State<RecipeListView> {
@override
Widget build(BuildContext context) {
List<int> selectedRecipesID = widget.selectedRecipesID;
return Wrap(children: [
ListView.builder(
shrinkWrap: true,
itemCount: widget.recipes.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(widget.recipes[index].title ?? ""),
selected: selectedRecipesID.contains(widget.recipes[index].id),
selectedColor: Colors.white,
selectedTileColor: const Color.fromARGB(255, 63, 63, 63),
onLongPress: () {
if (selectedRecipesID.contains(widget.recipes[index].id)) {
selectedRecipesID.remove(widget.recipes[index].id);
} else {
selectedRecipesID.add(widget.recipes[index].id!);
}
widget.onRecipesSelectionUpdate(selectedRecipesID);
},
onTap: () {
if (selectedRecipesID.contains(widget.recipes[index].id!)) {
selectedRecipesID.remove(widget.recipes[index].id!);
} else if (selectedRecipesID.isNotEmpty) {
selectedRecipesID.add(widget.recipes[index].id!);
} else {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => RecipeViewPage(
recipe: widget.recipes[index],
reloadRecipes: widget.reloadRecipes,
),
return ListView.builder(
shrinkWrap: true,
itemCount: widget.recipes.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(widget.recipes[index].title ?? ""),
selected: selectedRecipesID.contains(widget.recipes[index].id),
selectedColor: Colors.white,
selectedTileColor: const Color.fromARGB(255, 63, 63, 63),
onLongPress: () {
if (selectedRecipesID.contains(widget.recipes[index].id)) {
selectedRecipesID.remove(widget.recipes[index].id);
} else {
selectedRecipesID.add(widget.recipes[index].id!);
}
widget.onRecipesSelectionUpdate(selectedRecipesID);
},
onTap: () {
if (selectedRecipesID.contains(widget.recipes[index].id!)) {
selectedRecipesID.remove(widget.recipes[index].id!);
} else if (selectedRecipesID.isNotEmpty) {
selectedRecipesID.add(widget.recipes[index].id!);
} else {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => RecipeViewPage(
recipe: widget.recipes[index],
reloadRecipes: widget.reloadRecipes,
),
);
}
),
);
}

widget.onRecipesSelectionUpdate(selectedRecipesID);
},
);
},
)
]);
widget.onRecipesSelectionUpdate(selectedRecipesID);
},
);
},
);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.1
version: 1.0.2

environment:
sdk: '>=3.3.1 <4.0.0'
Expand Down

0 comments on commit 8ce78f5

Please sign in to comment.