added search to recipes page
This commit is contained in:
parent
9bf85e3fe7
commit
3c3dfe706a
2 changed files with 40 additions and 17 deletions
|
@ -5,26 +5,34 @@ import 'package:pizzaplanner/pages/nav_drawer.dart';
|
||||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||||
import 'package:pizzaplanner/widgets/pizza_recipe_widget.dart';
|
import 'package:pizzaplanner/widgets/pizza_recipe_widget.dart';
|
||||||
|
|
||||||
class RecipesPage extends StatelessWidget {
|
|
||||||
|
class RecipesPage extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
RecipesPageState createState() => RecipesPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class RecipesPageState extends State<RecipesPage> {
|
||||||
|
String searchText = "";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context){
|
Widget build(BuildContext context){
|
||||||
return PizzaPlannerScaffold(
|
return PizzaPlannerScaffold(
|
||||||
title: const Text("Pizza Recipes"),
|
title: const Text("Pizza Recipes"),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const Expanded(
|
Expanded(
|
||||||
flex: 5,
|
flex: 5,
|
||||||
child: Text("Search here maybe")
|
child: TextFormField(
|
||||||
),
|
decoration: const InputDecoration(
|
||||||
Container(
|
hintText: "Search Recipes",
|
||||||
color: Colors.blue,
|
),
|
||||||
width: double.infinity,
|
initialValue: searchText,
|
||||||
child: TextButton(
|
onChanged: (String newSearch) {
|
||||||
onPressed: () async {
|
setState(() {
|
||||||
Navigator.pushNamed(context, "/recipes/edit");
|
searchText = newSearch;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
child: const Text("New Recipe", style: TextStyle(color: Colors.white)),
|
),
|
||||||
)
|
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
const Center(child: Text("Long press to edit")),
|
const Center(child: Text("Long press to edit")),
|
||||||
|
@ -38,7 +46,10 @@ class RecipesPage extends StatelessWidget {
|
||||||
itemCount: pizzaRecipesBox.length,
|
itemCount: pizzaRecipesBox.length,
|
||||||
itemBuilder: (context, i) {
|
itemBuilder: (context, i) {
|
||||||
final pizzaRecipe = pizzaRecipesBox.get(i);
|
final pizzaRecipe = pizzaRecipesBox.get(i);
|
||||||
if (pizzaRecipe == null || pizzaRecipe.deleted){
|
if (
|
||||||
|
pizzaRecipe == null ||
|
||||||
|
pizzaRecipe.deleted ||
|
||||||
|
(searchText.isNotEmpty && !pizzaRecipe.name.toLowerCase().contains(searchText))){
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
return InkWell(
|
return InkWell(
|
||||||
|
@ -104,7 +115,10 @@ class RecipesPage extends StatelessWidget {
|
||||||
},
|
},
|
||||||
separatorBuilder: (BuildContext context, int i) {
|
separatorBuilder: (BuildContext context, int i) {
|
||||||
final pizzaRecipe = pizzaRecipesBox.get(i);
|
final pizzaRecipe = pizzaRecipesBox.get(i);
|
||||||
if (pizzaRecipe == null || pizzaRecipe.deleted){
|
if (
|
||||||
|
pizzaRecipe == null ||
|
||||||
|
pizzaRecipe.deleted ||
|
||||||
|
(searchText.isNotEmpty && !pizzaRecipe.name.toLowerCase().contains(searchText))){
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
return const Divider();
|
return const Divider();
|
||||||
|
@ -112,7 +126,18 @@ class RecipesPage extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
const Divider(),
|
||||||
|
Container(
|
||||||
|
color: Colors.blue,
|
||||||
|
width: double.infinity,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.pushNamed(context, "/recipes/edit");
|
||||||
|
},
|
||||||
|
child: const Text("New Recipe", style: TextStyle(color: Colors.white)),
|
||||||
|
)
|
||||||
|
),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
2
todo.md
2
todo.md
|
@ -1,8 +1,6 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
## Feature
|
## Feature
|
||||||
- add search to recipes page
|
|
||||||
- add directory structure to recipes?
|
|
||||||
- share to/export of yaml of recipes
|
- share to/export of yaml of recipes
|
||||||
- add an import of recipes from raw url
|
- add an import of recipes from raw url
|
||||||
- maybe allow a 'dir' yaml, that just points to other raw pizza yaml urls
|
- maybe allow a 'dir' yaml, that just points to other raw pizza yaml urls
|
||||||
|
|
Loading…
Add table
Reference in a new issue