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