diff --git a/lib/constants/cooking_units.dart b/lib/constants/cooking_units.dart new file mode 100644 index 0000000..38b21d2 --- /dev/null +++ b/lib/constants/cooking_units.dart @@ -0,0 +1,158 @@ +import 'package:flutter/material.dart'; + +import '../models/unit.dart' show Unit; +import '../src/enums.dart'; + +abstract class CookingUnits { + // Fluid volume units + static Unit get teaspoon => Unit( + 'teaspoon', + UnitType.fluid, + system: System.imperial, + ); + + static Unit get tablespoon => Unit( + 'tablespoon', + UnitType.fluid, + system: System.imperial, + ); + + static Unit get fluidOunce => Unit( + 'fluid ounce', + UnitType.fluid, + system: System.imperial, + ); + + static Unit get cup => Unit( + 'cup', + UnitType.fluid, + system: System.imperial, + ); + + static Unit get pint => Unit( + 'pint', + UnitType.fluid, + system: System.imperial, + ); + + static Unit get quart => Unit( + 'quart', + UnitType.fluid, + system: System.imperial, + ); + + static Unit get gallon => Unit( + 'gallon', + UnitType.fluid, + system: System.imperial, + ); + + static Unit get milliliter => Unit( + 'milliliter', + UnitType.fluid, + ); + + static Unit get liter => Unit( + 'liter', + UnitType.fluid, + ); + + // Weight units + static Unit get ounce => Unit( + 'ounce', + UnitType.weight, + system: System.imperial, + ); + + static Unit get pound => Unit( + 'pound', + UnitType.weight, + system: System.imperial, + ); + + static Unit get gram => Unit( + 'gram', + UnitType.weight, + ); + + static Unit get kilogram => Unit( + 'kilogram', + UnitType.weight, + ); + + // Count units + static Unit get piece => Unit( + 'piece', + UnitType.count, + system: System.neutral, + ); + + static Unit get dozen => Unit( + 'dozen', + UnitType.count, + system: System.neutral, + ); + + // Informal units + static Unit get pinch => Unit( + 'pinch', + UnitType.count, + system: System.neutral, + ); + + static Unit get dash => Unit( + 'dash', + UnitType.count, + system: System.neutral, + ); + + static Unit get drop => Unit( + 'drop', + UnitType.fluid, + system: System.neutral, + ); + + static Unit get stick => Unit( + 'stick', + UnitType.count, + system: System.neutral, + ); + + static Unit get can => Unit( + 'can', + UnitType.count, + system: System.neutral, + ); + + static Unit get batch => Unit( + 'batch', + UnitType.count, + system: System.neutral, + ); + + static Unit get handful => Unit( + 'handful', + UnitType.count, + system: System.neutral, + ); + + /// returns english abbreviation if available, else empty String + static String getUnitAbbreviation(BuildContext context, Unit unit) { + final abbreviations = { + 'teaspoon': 'tsp', + 'tablespoon': 'tbsp', + 'fluid ounce': 'fl oz', + 'cup': 'c', + 'pint': 'pt', + 'quart': 'qt', + 'gallon': 'gal', + 'milliliter': 'ml', + 'liter': 'l', + 'ounce': 'oz', + 'pound': 'lb', + 'gram': 'g', + 'kilogram': 'kg', + }; + return abbreviations[unit.name] ?? ''; + } +} diff --git a/lib/models/ingredient.dart b/lib/models/ingredient.dart new file mode 100644 index 0000000..6d60c55 --- /dev/null +++ b/lib/models/ingredient.dart @@ -0,0 +1,16 @@ +import '../src/enums.dart' show IngredientType; +import 'unit.dart'; + +class Ingredient { + final String title; + final List possibleUnits; + final List preferredBrands; + final IngredientType type; + + Ingredient({ + required this.title, + required this.type, + this.possibleUnits = const [], + this.preferredBrands = const [], + }); +} diff --git a/lib/models/ingredient_list_entry.dart b/lib/models/ingredient_list_entry.dart new file mode 100644 index 0000000..e1643b9 --- /dev/null +++ b/lib/models/ingredient_list_entry.dart @@ -0,0 +1,11 @@ +import 'ingredient.dart'; +import 'unit.dart'; + +class IngredientListEntry { + final Ingredient ingredient; + final int amount; + final Unit unit; + final bool optional; + + IngredientListEntry(this.ingredient, this.amount, this.unit, this.optional); +} diff --git a/lib/models/recipe.dart b/lib/models/recipe.dart new file mode 100644 index 0000000..9524624 --- /dev/null +++ b/lib/models/recipe.dart @@ -0,0 +1,31 @@ +import '../src/enums.dart' show Difficulty, Cuisine, MealCategory; +import 'ingredient_list_entry.dart'; + +class Recipe { + final int id; + final String title; + final String description; + final Difficulty difficulty; + final List ingredients = []; + final List steps = []; + final DateTime datePublished; + final Duration prepTime; + final Duration cookTime; + final Duration totalTime; + final List keywords = []; + final MealCategory mealCategory; + final Cuisine cuisine; + + Recipe({ + required this.id, + required this.title, + required this.description, + required this.difficulty, + required this.datePublished, + required this.prepTime, + required this.cookTime, + required this.totalTime, + required this.mealCategory, + required this.cuisine, + }); +} diff --git a/lib/models/unit.dart b/lib/models/unit.dart new file mode 100644 index 0000000..d6ad649 --- /dev/null +++ b/lib/models/unit.dart @@ -0,0 +1,9 @@ +import '../src/enums.dart' show UnitType, System; + +class Unit { + final String name; + final UnitType type; + final System system; + + Unit(this.name, this.type, {this.system = System.metric}); +} diff --git a/lib/src/enums.dart b/lib/src/enums.dart new file mode 100644 index 0000000..922b8ba --- /dev/null +++ b/lib/src/enums.dart @@ -0,0 +1,128 @@ +enum System { metric, imperial, neutral } + +enum UnitType { + fluid, + weight, + count, +} + +enum Difficulty { + notSelected, + veryEasy, + easy, + intermediate, + hard, + veryHard, +} + +enum IngredientType { + vegetable, + meat, + fish, + grain, + fruit, + dairy, + fatsAndOil, + spice, + other, +} + +enum MealCategory { + // Main Meals + breakfast, + brunch, + lunch, + dinner, + supper, + + // Other Categories + dessert, + snack, + appetizer, + sideDish, + beverage +} + +enum Cuisine { + // Asian Cuisines + chinese, + japanese, + korean, + vietnamese, + thai, + indian, + indonesian, + malaysian, + filipino, + singaporean, + + // European Cuisines + french, + italian, + spanish, + greek, + german, + british, + irish, + polish, + hungarian, + swedish, + norwegian, + danish, + portuguese, + belgian, + dutch, + swiss, + + // Middle Eastern Cuisines + turkish, + lebanese, + persian, + israeli, + moroccan, + egyptian, + + // American Cuisines + american, + mexican, + brazilian, + argentinian, + peruvian, + caribbean, + cajun, + creole, + texMex, + canadian, + + // African Cuisines + ethiopian, + nigerian, + southAfrican, + kenyan, + tunisian, + + // Pacific & Oceanian + australian, + newZealand, + hawaiian, + polynesian, + + // Regional American + southernUs, + newEngland, + midwestern, + southwestern, + california, + + // Fusion + asianFusion, + latinFusion, + mediterranean, + panAsian, + + // Other + international, + modern, + fusion, + streetFood +}