updated widget for recipe steps without substeps

This commit is contained in:
broodjeaap89 2021-08-09 21:11:35 +02:00
parent da32131f0d
commit 1ce594c5df

View file

@ -49,22 +49,22 @@ class PizzaEventPageState extends State<PizzaEventPage> {
],
),
children: <Widget>[
Text(recipeStep.description),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(recipeStep.name),
Checkbox(
value: recipeStep.completedOn != null,
onChanged: (bool? newValue) async {
if (newValue == null){
return;
}
setState(() {recipeStep.completedOn = newValue ? DateTime.now() : null;});
InkWell(
onLongPress: () {
setState(() {
recipeStep.completedOn = recipeStep.completed ? null : DateTime.now();
});
},
)
child: Container(
width: double.infinity,
color: recipeStep.completed ? Colors.green : Colors.grey,
child: Column(
children: <Widget>[
Text(recipeStep.description)
],
),
),
),
Divider(),
]
);
@ -85,7 +85,9 @@ class PizzaEventPageState extends State<PizzaEventPage> {
children: <Widget>[
Text(recipeStep.description),
Column(
children: recipeStep.subSteps.map((subStep) => getSubStepWidget(subStep)).toList()
children: recipeStep.subSteps.map(
(subStep) => getSubStepWidget(subStep)
).expand((subStep) => [Divider(), subStep]).toList()
)
]
);
@ -93,6 +95,7 @@ class PizzaEventPageState extends State<PizzaEventPage> {
Widget getSubStepWidget(RecipeSubStep recipeSubStep){
return InkWell(
onLongPress: () async {},
onTap: () async {
await showDialog(
context: context,
@ -102,23 +105,17 @@ class PizzaEventPageState extends State<PizzaEventPage> {
);
setState(() {});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: SizedBox(
height: 50,
child: Container(
color: recipeSubStep.completed ? Colors.green : Colors.grey,
child: Center(
child: Text(recipeSubStep.name)
child: Column(
children: <Widget>[
Center(
child: Text(recipeSubStep.name),
),
),
),
)
Text(recipeSubStep.description)
],
),
),
);
}
}