diff --git a/lib/main.dart b/lib/main.dart index 223344b..7da9457 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:pizzaplanner/pages/AddPlannedPizzaPage.dart'; import 'package:pizzaplanner/pages/PlannedPizzasPage.dart'; void main() { @@ -23,6 +24,10 @@ class RouteGenerator { case "/": { return MaterialPageRoute(builder: (context) => PlannedPizzasPage()); } + case "/add": { + return MaterialPageRoute(builder: (context) => AddPlannedPizzaPage()); + } + default: { return MaterialPageRoute(builder: (context) => PlannedPizzasPage()); } diff --git a/lib/pages/AddPlannedPizzaPage.dart b/lib/pages/AddPlannedPizzaPage.dart new file mode 100644 index 0000000..f957e48 --- /dev/null +++ b/lib/pages/AddPlannedPizzaPage.dart @@ -0,0 +1,55 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class AddPlannedPizzaPage extends StatefulWidget { + @override + AddPlannedPizzaPageState createState() => AddPlannedPizzaPageState(); +} + +class AddPlannedPizzaPageState extends State { + String name = ""; + String pizzaType = "Neapolitan"; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("Add Planned Pizza"), + ), + body: Container( + padding: EdgeInsets.fromLTRB(40, 10, 40, 10), + child: Column( + children: [ + TextField( + decoration: InputDecoration( + hintText: "Event Name" + ), + onChanged: (String newName) { + setState(() { + name = newName; + }); + }, + ), + DropdownButton( + icon: const Icon(Icons.arrow_downward), + value: pizzaType, + isExpanded: true, + onChanged: (String? newType) { + setState(() { + pizzaType = newType!; + }); + }, + items: ["Neapolitan", "New York", "Chicago"] + .map>((String v) { + return DropdownMenuItem( + value: v, + child: Text(v) + ); + }).toList() + ), + + ] + ) + ) + ); + } +} \ No newline at end of file diff --git a/lib/pages/PlannedPizzasPage.dart b/lib/pages/PlannedPizzasPage.dart index 0fc6574..bab43a2 100644 --- a/lib/pages/PlannedPizzasPage.dart +++ b/lib/pages/PlannedPizzasPage.dart @@ -9,7 +9,7 @@ class PlannedPizzasPage extends StatefulWidget { } class PlannedPizzasState extends State { - final List plannedPizzas = [ + List plannedPizzas = [ PlannedPizza("Movie Night", DateTime(2021, 6, 30, 12, 8)), PlannedPizza("Birthday Pizza", DateTime(2021, 7, 14, 18, 30)), PlannedPizza("Something else", DateTime(2021, 9, 3, 15, 3)), @@ -24,17 +24,16 @@ class PlannedPizzasState extends State { body: ListView.separated( padding: const EdgeInsets.all(8), itemCount: plannedPizzas.length, - itemBuilder: (BuildContext context, int i) { - return Container( - height: 120, - color: Colors.blueAccent, - child: PlannedPizzaWidget(plannedPizzas[i]) - ); - }, + itemBuilder: (BuildContext context, int i) => PlannedPizzaWidget(plannedPizzas[i]), separatorBuilder: (BuildContext context, int i) => const Divider(), ), floatingActionButton: FloatingActionButton( - onPressed: () => Container(), + onPressed: () { + Navigator.pushNamed( + context, + "/add", + ); + }, tooltip: "Add Pizza Plans", child: Center( child: Row( @@ -47,4 +46,12 @@ class PlannedPizzasState extends State { ), ); } + + void addPlannedPizza(){ + this.setState(() { + plannedPizzas.add( + PlannedPizza("Added Pizza Party", DateTime(2022, 3, 23, 17, 45)) + ); + }); + } } \ No newline at end of file diff --git a/lib/widgets/PlannedPizzaWidget.dart b/lib/widgets/PlannedPizzaWidget.dart index 1738160..c713554 100644 --- a/lib/widgets/PlannedPizzaWidget.dart +++ b/lib/widgets/PlannedPizzaWidget.dart @@ -11,7 +11,7 @@ class PlannedPizzaWidget extends StatelessWidget { @override Widget build(BuildContext context){ return Container( - height: 100, + height: 120, color: Colors.blueAccent, child: Container( padding: const EdgeInsets.all(8),