kinda in between commit before refactor to stateful widgets everywhere
This commit is contained in:
parent
3026bc0bfa
commit
3e043eccb4
4 changed files with 64 additions and 10 deletions
|
@ -61,9 +61,9 @@ class PizzaRecipe extends HiveObject {
|
||||||
return stepCount;
|
return stepCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getPizzaEventRecipeWidget(PizzaEventPageState pizzaEventPage) {
|
Widget getPizzaEventRecipeWidget(BuildContext context, PizzaEventPageState pizzaEventPage) {
|
||||||
return ListView(
|
return ListView(
|
||||||
children: this.recipeSteps.map((recipeStep) => recipeStep.buildPizzaEventRecipeStepWidget(pizzaEventPage)).toList()
|
children: this.recipeSteps.map((recipeStep) => recipeStep.buildPizzaEventRecipeStepWidget(context, pizzaEventPage)).toList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,13 +47,13 @@ class RecipeStep extends HiveObject {
|
||||||
completedOn != null;
|
completedOn != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildPizzaEventRecipeStepWidget(PizzaEventPageState pizzaEventPage){
|
Widget buildPizzaEventRecipeStepWidget(BuildContext context, PizzaEventPageState pizzaEventPage){
|
||||||
return this.subSteps.length > 0 ?
|
return this.subSteps.length > 0 ?
|
||||||
buildPizzaEventRecipeStepWidgetWithSubSteps(pizzaEventPage) :
|
buildPizzaEventRecipeStepWidgetWithSubSteps(context, pizzaEventPage) :
|
||||||
buildPizzaEventRecipeStepWidgetWithoutSubSteps(pizzaEventPage);
|
buildPizzaEventRecipeStepWidgetWithoutSubSteps(context, pizzaEventPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildPizzaEventRecipeStepWidgetWithSubSteps(PizzaEventPageState pizzaEventPage) {
|
Widget buildPizzaEventRecipeStepWidgetWithSubSteps(BuildContext context, PizzaEventPageState pizzaEventPage) {
|
||||||
int recipeSubStepsCompleted = this.subSteps.where((subStep) => subStep.completed).length;
|
int recipeSubStepsCompleted = this.subSteps.where((subStep) => subStep.completed).length;
|
||||||
int recipeSubSteps = this.subSteps.length;
|
int recipeSubSteps = this.subSteps.length;
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
|
@ -68,11 +68,11 @@ class RecipeStep extends HiveObject {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(this.description),
|
Text(this.description),
|
||||||
|
|
||||||
] + subSteps.map((subStep) => subStep.buildPizzaEventSubStepWidget(pizzaEventPage)).toList()
|
] + subSteps.map((subStep) => subStep.buildTest(context, pizzaEventPage)).toList() //subStep.buildPizzaEventSubStepWidget(context, pizzaEventPage)).toList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildPizzaEventRecipeStepWidgetWithoutSubSteps(PizzaEventPageState pizzaEventPage) {
|
Widget buildPizzaEventRecipeStepWidgetWithoutSubSteps(BuildContext context, PizzaEventPageState pizzaEventPage) {
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
title: Row(
|
title: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
|
|
@ -20,7 +20,7 @@ class RecipeSubStep extends HiveObject {
|
||||||
|
|
||||||
RecipeSubStep(this.name, this.description);
|
RecipeSubStep(this.name, this.description);
|
||||||
|
|
||||||
Widget buildPizzaEventSubStepWidget(PizzaEventPageState pizzaEventPage) {
|
Widget buildPizzaEventSubStepWidget(BuildContext context, PizzaEventPageState pizzaEventPage) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
@ -43,4 +43,58 @@ class RecipeSubStep extends HiveObject {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget buildTest(BuildContext context, PizzaEventPageState pizzaEventPage){
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return getDialog(context);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(this.name),
|
||||||
|
Checkbox(
|
||||||
|
value: this.completed,
|
||||||
|
onChanged: (b) {},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getDialog(BuildContext context){
|
||||||
|
return Dialog(
|
||||||
|
insetPadding: EdgeInsets.all(10),
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(10),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Text(this.name),
|
||||||
|
Text(this.description),
|
||||||
|
Expanded(
|
||||||
|
child: Container()
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 70,
|
||||||
|
child: Container(
|
||||||
|
color: this.completed ? Colors.green : Colors.redAccent,
|
||||||
|
child: TextButton(
|
||||||
|
child: Text(this.completed ? "Complete" : "Todo", style: TextStyle(color: Colors.white)),
|
||||||
|
onPressed: () {
|
||||||
|
this.completedOn = this.completed ? null : DateTime.now();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
body: Container(
|
body: Container(
|
||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(10),
|
||||||
child: this.widget.pizzaEvent.recipe.getPizzaEventRecipeWidget(this)
|
child: this.widget.pizzaEvent.recipe.getPizzaEventRecipeWidget(context, this)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue