added page to view the archived pizza events

This commit is contained in:
broodjeaap89 2021-09-24 20:50:00 +02:00
parent 3f2278aa7e
commit 57ce64fc2b
4 changed files with 86 additions and 1 deletions

View file

@ -8,6 +8,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_substep.dart';
import 'package:pizzaplanner/pages/add_pizza_event_page.dart';
import 'package:pizzaplanner/pages/add_recipe_url.dart';
import 'package:pizzaplanner/pages/archived_pizza_event_page.dart';
import 'package:pizzaplanner/pages/edit_recipe_page.dart';
import 'package:pizzaplanner/pages/edit_recipe_step_page.dart';
import 'package:pizzaplanner/pages/edit_recipe_sub_step_page.dart';
@ -126,6 +127,9 @@ class RouteGenerator {
case PizzaEventsPage.route: {
return MaterialPageRoute(builder: (context) => PizzaEventsPage());
}
case ArchivedPizzaEventsPage.route: {
return MaterialPageRoute(builder: (context) => ArchivedPizzaEventsPage());
}
case PickPizzaRecipePage.route: {
return MaterialPageRoute(builder: (context) => PickPizzaRecipePage());
}

View file

@ -0,0 +1,74 @@
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:pizzaplanner/entities/pizza_event.dart';
import 'package:pizzaplanner/pages/pizza_event_page.dart';
import 'package:pizzaplanner/pages/scaffold.dart';
import 'package:pizzaplanner/widgets/pizza_event_widget.dart';
class ArchivedPizzaEventsPage extends StatefulWidget {
static const String route = "/events/archived";
@override
ArchivedPizzaEventsPageState createState() => ArchivedPizzaEventsPageState();
}
class ArchivedPizzaEventsPageState extends State<ArchivedPizzaEventsPage> {
@override
Widget build(BuildContext context){
return PizzaPlannerScaffold(
title: const Text("Archived Pizza Events"),
body: ValueListenableBuilder(
valueListenable: Hive.box<PizzaEvent>(PizzaEvent.hiveName).listenable(),
builder: (context, Box<PizzaEvent> pizzaEventBox, widget) {
if (pizzaEventBox.isEmpty){
return Container();
}
return ListView.separated(
padding: const EdgeInsets.all(8),
itemCount: pizzaEventBox.length,
itemBuilder: (BuildContext context, int i) {
final pizzaEvent = pizzaEventBox.get(i);
if (pizzaEvent == null || !pizzaEvent.archived || pizzaEvent.deleted){
return const SizedBox();
}
return InkWell(
onTap: () {
showDialog(context: context, builder: (BuildContext context) {
return AlertDialog(
title: Text(pizzaEvent.name),
content: const Text("Remove from archive?"),
actions: <Widget>[
TextButton(
onPressed: () async {
Navigator.pop(context);
pizzaEvent.archived = false;
await pizzaEvent.save();
},
child: const Text("Yes"),
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("No"),
)
]
);
});
},
child: PizzaEventWidget(pizzaEvent),
);
},
separatorBuilder: (BuildContext context, int i) {
final pizzaEvent = pizzaEventBox.get(i);
if (pizzaEvent == null || !pizzaEvent.archived || pizzaEvent.deleted){
return const SizedBox();
}
return const Divider();
},
);
}
),
);
}
}

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:pizzaplanner/entities/pizza_event.dart';
import 'package:pizzaplanner/pages/archived_pizza_event_page.dart';
import 'package:pizzaplanner/pages/pizza_events_page.dart';
import 'package:pizzaplanner/pages/recipes_page.dart';
@ -38,6 +39,13 @@ class NavDrawer extends StatelessWidget {
Navigator.pushNamed(context, RecipesPage.route)
},
),
ListTile(
leading: const Icon(FontAwesome5.archive),
title: const Text("Archive"),
onTap: () => {
Navigator.pushNamed(context, ArchivedPizzaEventsPage.route)
},
),
]
)
);

View file

@ -1,7 +1,6 @@
# TODO
## Feature
- add page for archived pizza events?
- add 'capturing' sharing intent
- add settings page
- option for type of notification, full screen or just in the appbar