very annoying, probably have to skip seperate stateful widgets and dump everything in the build() of the page widet....
This commit is contained in:
parent
3c28bd01ca
commit
8de0282956
1 changed files with 27 additions and 17 deletions
|
@ -5,7 +5,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/RecipeStep.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaRecipe/RecipeSubStep.dart';
|
import 'package:pizzaplanner/entities/PizzaRecipe/RecipeSubStep.dart';
|
||||||
|
|
||||||
class PizzaEventPage extends StatefulWidget {
|
class PizzaEventPage extends StatefulWidget {
|
||||||
PizzaEvent pizzaEvent;
|
final PizzaEvent pizzaEvent;
|
||||||
|
|
||||||
PizzaEventPage(this.pizzaEvent);
|
PizzaEventPage(this.pizzaEvent);
|
||||||
|
|
||||||
|
@ -63,8 +63,10 @@ class PizzaEventRecipeStepWidgetState extends State<PizzaEventRecipeStepWidget>
|
||||||
),
|
),
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(this.widget.recipeStep.description),
|
Text(this.widget.recipeStep.description),
|
||||||
|
Column(
|
||||||
] + this.widget.recipeStep.subSteps.map((subStep) => PizzaEventSubStepWidget(subStep)).toList() //subStep.buildPizzaEventSubStepWidget(context, pizzaEventPage)).toList()
|
children: this.widget.recipeStep.subSteps.map((subStep) => PizzaEventSubStepWidget(subStep, this)).toList()
|
||||||
|
)
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,12 +92,12 @@ class PizzaEventRecipeStepWidgetState extends State<PizzaEventRecipeStepWidget>
|
||||||
if (newValue == null){
|
if (newValue == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.widget.recipeStep.completedOn = newValue ? DateTime.now() : null;
|
setState(() {this.widget.recipeStep.completedOn = newValue ? DateTime.now() : null;});
|
||||||
setState(() {});
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
|
Divider(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -103,8 +105,9 @@ class PizzaEventRecipeStepWidgetState extends State<PizzaEventRecipeStepWidget>
|
||||||
|
|
||||||
class PizzaEventSubStepWidget extends StatefulWidget {
|
class PizzaEventSubStepWidget extends StatefulWidget {
|
||||||
final RecipeSubStep recipeSubStep;
|
final RecipeSubStep recipeSubStep;
|
||||||
|
final PizzaEventRecipeStepWidgetState parent;
|
||||||
|
|
||||||
PizzaEventSubStepWidget(this.recipeSubStep);
|
PizzaEventSubStepWidget(this.recipeSubStep, this.parent);
|
||||||
|
|
||||||
PizzaEventSubStepWidgetState createState() => PizzaEventSubStepWidgetState();
|
PizzaEventSubStepWidgetState createState() => PizzaEventSubStepWidgetState();
|
||||||
}
|
}
|
||||||
|
@ -119,18 +122,25 @@ class PizzaEventSubStepWidgetState extends State<PizzaEventSubStepWidget> {
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return PizzaEventSubStepDialog(this.widget.recipeSubStep);
|
return PizzaEventSubStepDialog(this.widget.recipeSubStep);
|
||||||
}
|
}
|
||||||
);
|
).then((_) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
this.widget.parent.setState(() {});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(this.widget.recipeSubStep.name),
|
Expanded(
|
||||||
IgnorePointer(
|
flex: 1,
|
||||||
child: Checkbox(
|
child: SizedBox(
|
||||||
value: this.widget.recipeSubStep.completed,
|
height: 50,
|
||||||
onChanged: (b) {},
|
child: Container(
|
||||||
)
|
color: this.widget.recipeSubStep.completed ? Colors.green : Colors.grey,
|
||||||
|
child: Center(
|
||||||
|
child: Text(this.widget.recipeSubStep.name)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -164,7 +174,7 @@ class PizzaEventSubStepDialogState extends State<PizzaEventSubStepDialog> {
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 70,
|
height: 70,
|
||||||
child: Container(
|
child: Container(
|
||||||
color: this.widget.recipeSubStep.completed ? Colors.green : Colors.redAccent,
|
color: this.widget.recipeSubStep.completed ? Colors.green : Colors.grey,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
child: Text(this.widget.recipeSubStep.completed ? "Complete" : "Todo", style: TextStyle(color: Colors.white)),
|
child: Text(this.widget.recipeSubStep.completed ? "Complete" : "Todo", style: TextStyle(color: Colors.white)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue