started work on a 'add planned pizza' page
This commit is contained in:
parent
f355d47e34
commit
259a4d5ddf
4 changed files with 77 additions and 10 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pizzaplanner/pages/AddPlannedPizzaPage.dart';
|
||||||
import 'package:pizzaplanner/pages/PlannedPizzasPage.dart';
|
import 'package:pizzaplanner/pages/PlannedPizzasPage.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -23,6 +24,10 @@ class RouteGenerator {
|
||||||
case "/": {
|
case "/": {
|
||||||
return MaterialPageRoute(builder: (context) => PlannedPizzasPage());
|
return MaterialPageRoute(builder: (context) => PlannedPizzasPage());
|
||||||
}
|
}
|
||||||
|
case "/add": {
|
||||||
|
return MaterialPageRoute(builder: (context) => AddPlannedPizzaPage());
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
return MaterialPageRoute(builder: (context) => PlannedPizzasPage());
|
return MaterialPageRoute(builder: (context) => PlannedPizzasPage());
|
||||||
}
|
}
|
||||||
|
|
55
lib/pages/AddPlannedPizzaPage.dart
Normal file
55
lib/pages/AddPlannedPizzaPage.dart
Normal file
|
@ -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<AddPlannedPizzaPage> {
|
||||||
|
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: <Widget>[
|
||||||
|
TextField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Event Name"
|
||||||
|
),
|
||||||
|
onChanged: (String newName) {
|
||||||
|
setState(() {
|
||||||
|
name = newName;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
DropdownButton<String>(
|
||||||
|
icon: const Icon(Icons.arrow_downward),
|
||||||
|
value: pizzaType,
|
||||||
|
isExpanded: true,
|
||||||
|
onChanged: (String? newType) {
|
||||||
|
setState(() {
|
||||||
|
pizzaType = newType!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: <String>["Neapolitan", "New York", "Chicago"]
|
||||||
|
.map<DropdownMenuItem<String>>((String v) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: v,
|
||||||
|
child: Text(v)
|
||||||
|
);
|
||||||
|
}).toList()
|
||||||
|
),
|
||||||
|
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ class PlannedPizzasPage extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class PlannedPizzasState extends State<PlannedPizzasPage> {
|
class PlannedPizzasState extends State<PlannedPizzasPage> {
|
||||||
final List<PlannedPizza> plannedPizzas = <PlannedPizza>[
|
List<PlannedPizza> plannedPizzas = <PlannedPizza>[
|
||||||
PlannedPizza("Movie Night", DateTime(2021, 6, 30, 12, 8)),
|
PlannedPizza("Movie Night", DateTime(2021, 6, 30, 12, 8)),
|
||||||
PlannedPizza("Birthday Pizza", DateTime(2021, 7, 14, 18, 30)),
|
PlannedPizza("Birthday Pizza", DateTime(2021, 7, 14, 18, 30)),
|
||||||
PlannedPizza("Something else", DateTime(2021, 9, 3, 15, 3)),
|
PlannedPizza("Something else", DateTime(2021, 9, 3, 15, 3)),
|
||||||
|
@ -24,17 +24,16 @@ class PlannedPizzasState extends State<PlannedPizzasPage> {
|
||||||
body: ListView.separated(
|
body: ListView.separated(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
itemCount: plannedPizzas.length,
|
itemCount: plannedPizzas.length,
|
||||||
itemBuilder: (BuildContext context, int i) {
|
itemBuilder: (BuildContext context, int i) => PlannedPizzaWidget(plannedPizzas[i]),
|
||||||
return Container(
|
|
||||||
height: 120,
|
|
||||||
color: Colors.blueAccent,
|
|
||||||
child: PlannedPizzaWidget(plannedPizzas[i])
|
|
||||||
);
|
|
||||||
},
|
|
||||||
separatorBuilder: (BuildContext context, int i) => const Divider(),
|
separatorBuilder: (BuildContext context, int i) => const Divider(),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: () => Container(),
|
onPressed: () {
|
||||||
|
Navigator.pushNamed(
|
||||||
|
context,
|
||||||
|
"/add",
|
||||||
|
);
|
||||||
|
},
|
||||||
tooltip: "Add Pizza Plans",
|
tooltip: "Add Pizza Plans",
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Row(
|
child: Row(
|
||||||
|
@ -47,4 +46,12 @@ class PlannedPizzasState extends State<PlannedPizzasPage> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addPlannedPizza(){
|
||||||
|
this.setState(() {
|
||||||
|
plannedPizzas.add(
|
||||||
|
PlannedPizza("Added Pizza Party", DateTime(2022, 3, 23, 17, 45))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@ class PlannedPizzaWidget extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context){
|
Widget build(BuildContext context){
|
||||||
return Container(
|
return Container(
|
||||||
height: 100,
|
height: 120,
|
||||||
color: Colors.blueAccent,
|
color: Colors.blueAccent,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
|
|
Loading…
Add table
Reference in a new issue