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,21 +49,21 @@ 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, child: Container(
onChanged: (bool? newValue) async { width: double.infinity,
if (newValue == null){ color: recipeStep.completed ? Colors.green : Colors.grey,
return; child: Column(
} children: <Widget>[
setState(() {recipeStep.completedOn = newValue ? DateTime.now() : null;}); 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,22 +105,16 @@ class PizzaEventPageState extends State<PizzaEventPage> {
); );
setState(() {}); setState(() {});
}, },
child: Row( child: Container(
mainAxisAlignment: MainAxisAlignment.center, color: recipeSubStep.completed ? Colors.green : Colors.grey,
children: [ child: Column(
Expanded( children: <Widget>[
flex: 1, Center(
child: SizedBox( child: Text(recipeSubStep.name),
height: 50,
child: Container(
color: recipeSubStep.completed ? Colors.green : Colors.grey,
child: Center(
child: Text(recipeSubStep.name)
),
),
), ),
) Text(recipeSubStep.description)
], ],
),
), ),
); );
} }