in between commit before layout changes
This commit is contained in:
parent
1bb5d8f6a8
commit
7f3d7202b9
1 changed files with 47 additions and 59 deletions
|
@ -6,6 +6,7 @@ import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaRecipe/RecipeStep.dart';
|
import 'package:pizzaplanner/entities/PizzaRecipe/RecipeStep.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaRecipe/RecipeSubStep.dart';
|
import 'package:pizzaplanner/entities/PizzaRecipe/RecipeSubStep.dart';
|
||||||
import 'package:pizzaplanner/main.dart';
|
import 'package:pizzaplanner/main.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class PizzaEventPage extends StatefulWidget {
|
class PizzaEventPage extends StatefulWidget {
|
||||||
final PizzaEvent pizzaEvent;
|
final PizzaEvent pizzaEvent;
|
||||||
|
@ -46,34 +47,18 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildRecipeStep(RecipeStep recipeStep) {
|
Widget buildRecipeStep(RecipeStep recipeStep) {
|
||||||
var r = Row(
|
var subSteps = recipeStep.subSteps.length == 0 ? 1 : recipeStep.subSteps.length;
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
var currentSubStep = recipeStep.subSteps.indexWhere((subStep) => subStep.completed);
|
||||||
flex: 10,
|
if (currentSubStep == -1){
|
||||||
child: Container(
|
currentSubStep = 0;
|
||||||
color: Colors.blue,
|
}
|
||||||
child: TextButton(
|
|
||||||
child: Text("Undo", style: TextStyle(color: Colors.white)),
|
var completedSubSteps = recipeStep.completed ? 1 : 0;
|
||||||
onPressed: () {
|
if (recipeStep.subSteps.length > 0){
|
||||||
controller.nextPage(duration: Duration(milliseconds: 100), curve: Curves.bounceIn);
|
completedSubSteps = currentSubStep + 1;
|
||||||
},
|
}
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 10,
|
|
||||||
child: Container(
|
|
||||||
color: Colors.blue,
|
|
||||||
child: TextButton(
|
|
||||||
child: Text("Complete ->", style: TextStyle(color: Colors.white)),
|
|
||||||
onPressed: () {
|
|
||||||
controller.nextPage(duration: Duration(milliseconds: 100), curve: Curves.bounceIn);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -82,13 +67,18 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(recipeStep.name),
|
Text(recipeStep.name),
|
||||||
Text("${recipeStep.completedOn == null ? 0 : 1}/1")
|
Text("$completedSubSteps/$subSteps")
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 80,
|
flex: 80,
|
||||||
child: MarkdownBody(data: recipeStep.description)
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
MarkdownBody(data: recipeStep.description),
|
||||||
|
Divider(),
|
||||||
|
] + recipeStep.subSteps.asMap().map<int, Widget>((index, subStep) => MapEntry(index, getSubStepWidget(subStep, index, currentSubStep))).values.toList()
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 10,
|
flex: 10,
|
||||||
|
@ -104,11 +94,16 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
child: Text("Undo", style: TextStyle(color: Colors.white)),
|
child: Text("Undo", style: TextStyle(color: Colors.white)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
controller.nextPage(duration: Duration(milliseconds: 100), curve: Curves.bounceIn);
|
recipeStep.subSteps.map((subStep) => subStep.completedOn = null);
|
||||||
|
//controller.nextPage(duration: Duration(milliseconds: 100), curve: Curves.bounceIn);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Container(),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 10,
|
flex: 10,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -117,7 +112,10 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
child: Text("Complete ->", style: TextStyle(color: Colors.white)),
|
child: Text("Complete ->", style: TextStyle(color: Colors.white)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
controller.nextPage(duration: Duration(milliseconds: 100), curve: Curves.bounceIn);
|
recipeStep.subSteps.where((recipeSubStep) => !(recipeSubStep.completed)).completeNow();
|
||||||
|
//recipeStep.completeStepNow();
|
||||||
|
//this.widget.pizzaEvent.save();
|
||||||
|
//controller.nextPage(duration: Duration(milliseconds: 100), curve: Curves.bounceIn);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -144,38 +142,28 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
),
|
),
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(recipeStep.description),
|
Text(recipeStep.description),
|
||||||
Column(
|
|
||||||
children: recipeStep.subSteps.map(
|
|
||||||
(subStep) => getSubStepWidget(subStep)
|
|
||||||
).expand((subStep) => [Divider(), subStep]).toList()
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getSubStepWidget(RecipeSubStep recipeSubStep){
|
Widget getSubStepWidget(RecipeSubStep recipeSubStep, int index, int current){
|
||||||
return InkWell(
|
return ExpansionTile(
|
||||||
onLongPress: () async {},
|
initiallyExpanded: index == current,
|
||||||
onTap: () async {
|
title: Row(
|
||||||
await showDialog(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
context: context,
|
children: <Widget>[
|
||||||
builder: (context) {
|
Text(recipeSubStep.name),
|
||||||
return SubStepDialog(recipeSubStep);
|
Icon(FontAwesome5.check, color: recipeSubStep.completed ? Colors.green : Colors.grey),
|
||||||
}
|
]
|
||||||
);
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
color: recipeSubStep.completed ? Colors.green : Colors.grey,
|
|
||||||
child: Column(
|
|
||||||
children: <Widget>[
|
|
||||||
Center(
|
|
||||||
child: Text(recipeSubStep.name),
|
|
||||||
),
|
|
||||||
Text(recipeSubStep.description)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
children: <Widget>[
|
||||||
|
MarkdownBody(
|
||||||
|
data: recipeSubStep.description,
|
||||||
|
onTapLink: (text, url, title) {
|
||||||
|
launch(url!);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue