updated layout of pizza event page
This commit is contained in:
parent
3620ea383a
commit
cca65a5718
2 changed files with 37 additions and 6 deletions
|
@ -5,7 +5,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/PizzaRecipe.dart';
|
||||||
part 'PizzaEvent.g.dart';
|
part 'PizzaEvent.g.dart';
|
||||||
|
|
||||||
@HiveType(typeId: 4)
|
@HiveType(typeId: 4)
|
||||||
class PizzaEvent {
|
class PizzaEvent extends HiveObject{
|
||||||
@HiveField(0)
|
@HiveField(0)
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
||||||
|
|
||||||
class PizzaEventPage extends StatefulWidget {
|
class PizzaEventPage extends StatefulWidget {
|
||||||
|
@ -22,14 +23,44 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(10),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: this.widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) {
|
children: this.widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) {
|
||||||
|
int recipeSubStepsCompleted = recipeStep.subSteps.where((subStep) => subStep.completed).length;
|
||||||
|
int recipeSubSteps = recipeStep.subSteps.length != 0 ? recipeStep.subSteps.length : 1;
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [],
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(FontAwesome5.sitemap),
|
||||||
|
Text(recipeStep.name),
|
||||||
|
Text("$recipeSubStepsCompleted/$recipeSubSteps")
|
||||||
|
],
|
||||||
),
|
),
|
||||||
children: recipeStep.subSteps.map((recipeSubStep) {
|
children: <Widget>[
|
||||||
return Text(recipeSubStep.name);
|
Text(recipeStep.description),
|
||||||
|
|
||||||
|
] + recipeStep.subSteps.map((subStep) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(subStep.name),
|
||||||
|
Checkbox(
|
||||||
|
value: subStep.completed,
|
||||||
|
onChanged: (bool? newValue) async {
|
||||||
|
if (newValue == null){
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
).toList(),
|
if (newValue){
|
||||||
|
subStep.completedOn = DateTime.now();
|
||||||
|
} else {
|
||||||
|
subStep.completedOn = null;
|
||||||
|
}
|
||||||
|
await this.widget.pizzaEvent.delete();
|
||||||
|
await this.widget.pizzaEvent.save();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue