another in between commit, getting messy :o
This commit is contained in:
parent
e7cca581c5
commit
1382a4a843
16 changed files with 181 additions and 89 deletions
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -3,7 +3,7 @@
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<type id="android" />
|
<type id="android" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" default="false" project-jdk-name="Android API 30 Platform" project-jdk-type="Android SDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
3
android/.idea/.gitignore
generated
vendored
Normal file
3
android/.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
6
android/.idea/compiler.xml
generated
Normal file
6
android/.idea/compiler.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="11" />
|
||||||
|
</component>
|
||||||
|
</project>
|
22
android/.idea/gradle.xml
generated
Normal file
22
android/.idea/gradle.xml
generated
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="PLATFORM" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleHome" value="C:/ProgramData/chocolatey/lib/gradle/tools/gradle-7.1" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$/../../../lib/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/android" />
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
9
android/.idea/misc.xml
generated
Normal file
9
android/.idea/misc.xml
generated
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
android/.idea/modules.xml
generated
Normal file
8
android/.idea/modules.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/android.iml" filepath="$PROJECT_DIR$/.idea/modules/android.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
10
android/.idea/runConfigurations.xml
generated
Normal file
10
android/.idea/runConfigurations.xml
generated
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -6,6 +6,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/Ingredient.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:tuple/tuple.dart';
|
||||||
import 'package:yaml/yaml.dart';
|
import 'package:yaml/yaml.dart';
|
||||||
|
|
||||||
@entity
|
@entity
|
||||||
|
@ -61,7 +62,7 @@ class PizzaRecipe {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<PizzaRecipe> fromYaml(yamlPath) async{
|
static Future<Tuple4<PizzaRecipe, List<Ingredient>, List<RecipeStep>, List<RecipeSubStep>>> fromYaml(yamlPath) async{
|
||||||
String yamlString = await loadAsset(yamlPath);
|
String yamlString = await loadAsset(yamlPath);
|
||||||
var yaml = loadYaml(yamlString);
|
var yaml = loadYaml(yamlString);
|
||||||
var recipe = yaml["recipe"];
|
var recipe = yaml["recipe"];
|
||||||
|
@ -72,14 +73,13 @@ class PizzaRecipe {
|
||||||
PizzaRecipe pizzaRecipe = PizzaRecipe(name, description);
|
PizzaRecipe pizzaRecipe = PizzaRecipe(name, description);
|
||||||
pizzaRecipe.insert();
|
pizzaRecipe.insert();
|
||||||
|
|
||||||
YamlList ingredients = recipe["ingredients"];
|
YamlList ingredientsYamlList = recipe["ingredients"];
|
||||||
|
List<Ingredient> ingredients = ingredientsYamlList.map((ingredientYaml) => Ingredient(pizzaRecipe.id!, ingredientYaml["name"], ingredientYaml["unit"], ingredientYaml["value"])).toList();
|
||||||
|
|
||||||
for (var ingredientYaml in ingredients){
|
|
||||||
Ingredient ingredient = Ingredient(pizzaRecipe.id!, ingredientYaml["name"], ingredientYaml["unit"], ingredientYaml["value"]);
|
|
||||||
ingredient.insert();
|
|
||||||
}
|
|
||||||
|
|
||||||
YamlList steps = recipe["steps"];
|
YamlList steps = recipe["steps"];
|
||||||
|
List<RecipeStep> recipeSteps = [];
|
||||||
|
List<RecipeSubStep> recipeSubSteps = [];
|
||||||
for (var step in steps){
|
for (var step in steps){
|
||||||
String stepName = step["name"];
|
String stepName = step["name"];
|
||||||
String stepDescription = step["description"];
|
String stepDescription = step["description"];
|
||||||
|
@ -97,25 +97,31 @@ class PizzaRecipe {
|
||||||
waitMin = waitMap["min"];
|
waitMin = waitMap["min"];
|
||||||
waitMax = waitMap["max"];
|
waitMax = waitMap["max"];
|
||||||
}
|
}
|
||||||
|
var recipeStep = RecipeStep(
|
||||||
RecipeStep recipeStep = RecipeStep(
|
pizzaRecipe.id!,
|
||||||
pizzaRecipe.id!,
|
stepName,
|
||||||
stepName,
|
stepDescription,
|
||||||
stepDescription,
|
waitDescription,
|
||||||
waitDescription,
|
waitUnit,
|
||||||
waitUnit,
|
waitMin,
|
||||||
waitMin,
|
waitMax
|
||||||
waitMax
|
);
|
||||||
|
recipeSteps.add(
|
||||||
|
recipeStep
|
||||||
);
|
);
|
||||||
recipeStep.insert();
|
|
||||||
|
|
||||||
YamlList subSteps = step.containsKey("substeps") ? step["substeps"] : YamlList();
|
YamlList subSteps = step.containsKey("substeps") ? step["substeps"] : YamlList();
|
||||||
for (var subStep in subSteps ) {
|
for (var subStep in subSteps ) {
|
||||||
RecipeSubStep recipeSubStep = RecipeSubStep(recipeStep.id!, subStep["name"], subStep["description"]);
|
recipeSubSteps.add(
|
||||||
recipeSubStep.insert();
|
RecipeSubStep(
|
||||||
|
recipeStep.id!,
|
||||||
|
subStep["name"],
|
||||||
|
subStep["description"]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pizzaRecipe;
|
return Tuple4(pizzaRecipe, ingredients, recipeSteps, recipeSubSteps);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Duration> getMinDuration() async {
|
Future<Duration> getMinDuration() async {
|
||||||
|
|
|
@ -61,4 +61,10 @@ class RecipeStep {
|
||||||
int getCurrentWaitInSeconds() {
|
int getCurrentWaitInSeconds() {
|
||||||
return convertToSeconds(this.waitValue);
|
return convertToSeconds(this.waitValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<List<RecipeStep>> getRecipeStepForRecipe(PizzaRecipe pizzaRecipe) async {
|
||||||
|
final database = await getDatabase();
|
||||||
|
final recipeStepDao = database.recipeStepDao;
|
||||||
|
return recipeStepDao.getPizzaRecipeSteps(pizzaRecipe.id!);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:pizzaplanner/pages/AddPizzaEventPage.dart';
|
import 'package:pizzaplanner/pages/AddPizzaEvent/AddPizzaEventPage.dart';
|
||||||
import 'package:pizzaplanner/pages/PizzaEventsPage.dart';
|
import 'package:pizzaplanner/pages/PizzaEventsPage.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||||
import 'package:fluttericon/font_awesome5_icons.dart';
|
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaRecipe/PizzaRecipe.dart';
|
import 'package:pizzaplanner/entities/PizzaRecipe/PizzaRecipe.dart';
|
||||||
|
import 'package:pizzaplanner/entities/PizzaRecipe/RecipeStep.dart';
|
||||||
import 'package:pizzaplanner/util.dart';
|
import 'package:pizzaplanner/util.dart';
|
||||||
|
|
||||||
class AddPizzaEventPage extends StatefulWidget {
|
class AddPizzaEventPage extends StatefulWidget {
|
||||||
|
@ -13,29 +14,14 @@ class AddPizzaEventPage extends StatefulWidget {
|
||||||
|
|
||||||
class AddPizzaEventPageState extends State<AddPizzaEventPage> {
|
class AddPizzaEventPageState extends State<AddPizzaEventPage> {
|
||||||
String name = "";
|
String name = "";
|
||||||
bool initialized = false;
|
late Future<PizzaRecipe> pizzaRecipe;
|
||||||
late PizzaRecipe pizzaRecipe;
|
final Future<List<PizzaRecipe>> pizzaRecipes = getRecipes();
|
||||||
late List<PizzaRecipe> pizzaTypes;
|
|
||||||
int pizzaCount = 1;
|
int pizzaCount = 1;
|
||||||
int doughBallSize = 250;
|
int doughBallSize = 250;
|
||||||
DateTime eventTime = DateTime.now();
|
DateTime eventTime = DateTime.now();
|
||||||
|
|
||||||
bool nameValidation = false;
|
bool nameValidation = false;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
getRecipes().then((pTypes) {
|
|
||||||
this.pizzaTypes = pTypes;
|
|
||||||
this.pizzaRecipe = this.pizzaTypes.first;
|
|
||||||
setState(() {this.initialized = true;});
|
|
||||||
}, onError: (e, stacktrace) {
|
|
||||||
print(e);
|
|
||||||
print(stacktrace);
|
|
||||||
Navigator.pop(context);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -70,24 +56,34 @@ class AddPizzaEventPageState extends State<AddPizzaEventPage> {
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Icon(FontAwesome5.pizza_slice),
|
Icon(FontAwesome5.pizza_slice),
|
||||||
Container(width: 25),
|
Container(width: 25),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: this.initialized ? // Only render the dropdown if the recipes have been loaded from storage
|
child: FutureBuilder<List<PizzaRecipe>>(
|
||||||
DropdownButton<String>(
|
future: pizzaRecipes,
|
||||||
value: this.pizzaRecipe.name,
|
builder: (BuildContext context, AsyncSnapshot<List<PizzaRecipe>> snapshot){
|
||||||
onChanged: (String? newType) {
|
if(snapshot.hasData && !snapshot.hasError){
|
||||||
setState(() => this.pizzaRecipe = this.pizzaTypes.firstWhere((pizzaRecipe) => pizzaRecipe.name == newType));
|
//this.pizzaRecipe = snapshot.data!.first;
|
||||||
},
|
return DropdownButton<String>(
|
||||||
items: this.pizzaTypes.map((pizzaRecipe) {
|
value: "this.pizzaRecipe.name",
|
||||||
return DropdownMenuItem(
|
onChanged: (String? newType) {
|
||||||
value: pizzaRecipe.name,
|
//setState(() => this.pizzaRecipe = snapshot.data!.firstWhere((pizzaRecipe) => pizzaRecipe.name == newType));
|
||||||
child: Text(pizzaRecipe.name)
|
},
|
||||||
);
|
items: snapshot.data!.map((pizzaRecipe) {
|
||||||
}).toList()
|
return DropdownMenuItem(
|
||||||
) : CircularProgressIndicator()
|
value: pizzaRecipe.name,
|
||||||
|
child: Text(pizzaRecipe.name)
|
||||||
|
);
|
||||||
|
}).toList()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
@ -141,31 +137,40 @@ class AddPizzaEventPageState extends State<AddPizzaEventPage> {
|
||||||
flex: 45,
|
flex: 45,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
this.initialized ? Column(
|
/*FutureBuilder(
|
||||||
children: this.pizzaRecipe.recipeSteps.where((recipeStep) => recipeStep.waitDescription.length > 0).map((recipeStep) {
|
future: RecipeStep.getRecipeStepForRecipe(this.pizzaRecipe),
|
||||||
return <Widget>[
|
builder: (BuildContext context, AsyncSnapshot<List<RecipeStep>> snapshot){
|
||||||
Text(recipeStep.waitDescription),
|
if (snapshot.hasData && !snapshot.hasError) {
|
||||||
Row(
|
return Column(
|
||||||
children: <Widget>[
|
children: snapshot.data!.where((recipeStep) => recipeStep.waitDescription.length > 0).map((recipeStep) {
|
||||||
Expanded(
|
return <Widget>[
|
||||||
child: Slider(
|
Text(recipeStep.waitDescription),
|
||||||
value: recipeStep.waitValue.toDouble(),
|
Row(
|
||||||
min: recipeStep.waitMin.toDouble(),
|
children: <Widget>[
|
||||||
max: recipeStep.waitMax.toDouble(),
|
Expanded(
|
||||||
divisions: recipeStep.waitMax - recipeStep.waitMin,
|
child: Slider(
|
||||||
label: recipeStep.waitValue.toString(),
|
value: recipeStep.waitValue.toDouble(),
|
||||||
onChanged: (newValue) => this.setState(() => recipeStep.waitValue = newValue.toInt()),
|
min: recipeStep.waitMin.toDouble(),
|
||||||
)
|
max: recipeStep.waitMax.toDouble(),
|
||||||
),
|
divisions: recipeStep.waitMax - recipeStep.waitMin,
|
||||||
Container(
|
label: recipeStep.waitValue.toString(),
|
||||||
width: 25,
|
onChanged: (newValue) => this.setState(() => recipeStep.waitValue = newValue.toInt()),
|
||||||
child: Text(recipeStep.waitValue.toString())
|
)
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 25,
|
||||||
|
child: Text(recipeStep.waitValue.toString())
|
||||||
|
)
|
||||||
|
]
|
||||||
)
|
)
|
||||||
]
|
];
|
||||||
)
|
}).expand((option) => option).toList()
|
||||||
];
|
);
|
||||||
}).expand((option) => option).toList()
|
} else {
|
||||||
) : Container(),
|
return CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)*/
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -188,15 +193,15 @@ class AddPizzaEventPageState extends State<AddPizzaEventPage> {
|
||||||
DateTime? eventTime = await showDialog(
|
DateTime? eventTime = await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return ConfirmPizzaEventDialog(name: name, pizzaRecipe: pizzaRecipe, pizzaCount: pizzaCount, doughBallSize: doughBallSize);
|
return Text("tmp") //ConfirmPizzaEventDialog(name: name, pizzaRecipe: pizzaRecipe, pizzaCount: pizzaCount, doughBallSize: doughBallSize);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (eventTime == null){
|
if (eventTime == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Navigator.pop(context, PizzaEvent(
|
Navigator.pop(context, PizzaEvent(
|
||||||
|
1, // this.pizzaRecipe.id!,
|
||||||
this.name,
|
this.name,
|
||||||
this.pizzaRecipe,
|
|
||||||
this.pizzaCount,
|
this.pizzaCount,
|
||||||
this.doughBallSize,
|
this.doughBallSize,
|
||||||
eventTime
|
eventTime
|
||||||
|
@ -234,10 +239,11 @@ class ConfirmPizzaEventState extends State<ConfirmPizzaEventDialog> {
|
||||||
late final DateTime minTime;
|
late final DateTime minTime;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() async {
|
||||||
super.initState();
|
super.initState();
|
||||||
eventTime = DateTime.now().add(widget.pizzaRecipe.getCurrentDuration()).add(Duration(minutes: 1));
|
var currentDuration = await widget.pizzaRecipe.getCurrentDuration();
|
||||||
minTime = DateTime.now().add(widget.pizzaRecipe.getCurrentDuration());
|
eventTime = DateTime.now().add(currentDuration).add(Duration(minutes: 1));
|
||||||
|
minTime = DateTime.now().add(currentDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -255,7 +261,7 @@ class ConfirmPizzaEventState extends State<ConfirmPizzaEventDialog> {
|
||||||
Text(widget.name),
|
Text(widget.name),
|
||||||
Divider(),
|
Divider(),
|
||||||
Text("Ingredients"),
|
Text("Ingredients"),
|
||||||
widget.pizzaRecipe.getIngredientsTable(widget.pizzaCount, widget.doughBallSize),
|
//widget.pizzaRecipe.getIngredientsTable(widget.pizzaCount, widget.doughBallSize),
|
||||||
Divider(),
|
Divider(),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
|
@ -293,7 +299,7 @@ class ConfirmPizzaEventState extends State<ConfirmPizzaEventDialog> {
|
||||||
flex: 60,
|
flex: 60,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
widget.pizzaRecipe.getStepTimeTable(eventTime)
|
//widget.pizzaRecipe.getStepTimeTable(eventTime)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
),
|
),
|
0
lib/pages/AddPizzaEvent/PickPizzaRecipePage.dart
Normal file
0
lib/pages/AddPizzaEvent/PickPizzaRecipePage.dart
Normal file
|
@ -21,7 +21,7 @@ class PizzaEventsState extends State<PizzaEventsPage> {
|
||||||
body: ListView.separated(
|
body: ListView.separated(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
itemCount: pizzaEvents.length,
|
itemCount: pizzaEvents.length,
|
||||||
itemBuilder: (BuildContext context, int i) => PizzaEventWidget(pizzaEvents[i]),
|
itemBuilder: (BuildContext context, int i) => const Divider(),// PizzaEventWidget(pizzaEvents[i]),
|
||||||
separatorBuilder: (BuildContext context, int i) => const Divider(),
|
separatorBuilder: (BuildContext context, int i) => const Divider(),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
|
|
|
@ -6,17 +6,30 @@ import 'package:pizzaplanner/entities/PizzaDatabase.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaRecipe/PizzaRecipe.dart';
|
import 'package:pizzaplanner/entities/PizzaRecipe/PizzaRecipe.dart';
|
||||||
|
|
||||||
Future<List<PizzaRecipe>> getRecipes() async {
|
Future<List<PizzaRecipe>> getRecipes() async {
|
||||||
|
final database = await getDatabase();
|
||||||
|
final pizzaRecipeDao = database.pizzaRecipeDao;
|
||||||
|
final pizzaRecipes = await pizzaRecipeDao.getAllPizzaRecipes();
|
||||||
|
if (pizzaRecipes.isNotEmpty) {
|
||||||
|
return pizzaRecipes;
|
||||||
|
}
|
||||||
|
|
||||||
|
// load recipes from yaml files in the asset directory
|
||||||
final manifestContent = await rootBundle.loadString('AssetManifest.json');
|
final manifestContent = await rootBundle.loadString('AssetManifest.json');
|
||||||
final Map<String, dynamic> manifestMap = json.decode(manifestContent);
|
final Map<String, dynamic> manifestMap = json.decode(manifestContent);
|
||||||
final List<String> fileList = manifestMap.keys.toList();
|
final List<String> fileList = manifestMap.keys.toList();
|
||||||
final List<PizzaRecipe> pizzaRecipes = [];
|
final List<PizzaRecipe> newPizzaRecipes = [];
|
||||||
for (var filePath in fileList) {
|
for (var filePath in fileList) {
|
||||||
if (filePath.startsWith("assets/recipes") && filePath.endsWith(".yaml")) {
|
if (filePath.startsWith("assets/recipes") && filePath.endsWith(".yaml")) {
|
||||||
PizzaRecipe pizzaRecipe = await PizzaRecipe.fromYaml(filePath);
|
var parsedPizzaRecipe = await PizzaRecipe.fromYaml(filePath);
|
||||||
pizzaRecipes.add(pizzaRecipe);
|
await parsedPizzaRecipe.item1.insert();
|
||||||
|
newPizzaRecipes.add(parsedPizzaRecipe.item1);
|
||||||
|
|
||||||
|
parsedPizzaRecipe.item2.forEach((ingredient) async { await ingredient.insert(); });
|
||||||
|
parsedPizzaRecipe.item3.forEach((recipeStep) async { await recipeStep.insert(); });
|
||||||
|
parsedPizzaRecipe.item4.forEach((recipeSubStep) async { await recipeSubStep.insert(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pizzaRecipes;
|
return newPizzaRecipes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> loadAsset(String path) async {
|
Future<String> loadAsset(String path) async {
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
||||||
|
import 'package:pizzaplanner/entities/PizzaRecipe/PizzaRecipe.dart';
|
||||||
import 'package:pizzaplanner/util.dart';
|
import 'package:pizzaplanner/util.dart';
|
||||||
|
|
||||||
class PizzaEventWidget extends StatelessWidget {
|
class PizzaEventWidget extends StatelessWidget {
|
||||||
final PizzaEvent pizzaEvent;
|
final PizzaEvent pizzaEvent;
|
||||||
|
final PizzaRecipe pizzaRecipe;
|
||||||
|
|
||||||
PizzaEventWidget(this.pizzaEvent);
|
PizzaEventWidget(this.pizzaEvent, this.pizzaRecipe);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context){
|
Widget build(BuildContext context){
|
||||||
|
@ -69,7 +71,7 @@ class PizzaEventWidget extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(getDateFormat().format(pizzaEvent.dateTime)),
|
Text(getDateFormat().format(pizzaEvent.dateTime)),
|
||||||
Text(pizzaEvent.recipe.name)
|
Text(pizzaRecipe.name)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ dependencies:
|
||||||
yaml: ^3.1.0
|
yaml: ^3.1.0
|
||||||
|
|
||||||
floor: ^1.1.0
|
floor: ^1.1.0
|
||||||
|
tuple: ^2.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Add table
Reference in a new issue