diff --git a/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/RecipeFragment.kt b/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/RecipeFragment.kt new file mode 100644 index 0000000..2639315 --- /dev/null +++ b/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/RecipeFragment.kt @@ -0,0 +1,54 @@ +package tech.mercantec.easyeat.ui.dishes + +import android.os.Bundle +import android.text.Html +import android.text.Html.FROM_HTML_MODE_LEGACY +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import kotlinx.serialization.json.Json +import tech.mercantec.easyeat.R +import tech.mercantec.easyeat.models.Recipe + +class RecipeFragment : Fragment() { + private var recipe: Recipe? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + arguments?.let { args -> + recipe = args.getString("RECIPE")?.let { Json.decodeFromString(it) } + } + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle?, + ): View? { + val binding = inflater.inflate(R.layout.fragment_recipe, container, false) + + recipe?.let { recipe -> + binding.findViewById(R.id.title).text = recipe.name + + binding.findViewById(R.id.ingredients).text = + Html.fromHtml( + "
    " + + recipe.ingredients.map { "
  • ${it.amount} ${it.unit} ${it.name}
  • " } + + "
", + FROM_HTML_MODE_LEGACY + ) + + binding.findViewById(R.id.directions).text = + Html.fromHtml( + "
    " + + recipe.directions.map { "
  • ${it}
  • " } + + "
", + FROM_HTML_MODE_LEGACY + ) + } + + return binding + } +} \ No newline at end of file diff --git a/app/app/src/main/res/layout/fragment_recipe.xml b/app/app/src/main/res/layout/fragment_recipe.xml new file mode 100644 index 0000000..8b66e2d --- /dev/null +++ b/app/app/src/main/res/layout/fragment_recipe.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + diff --git a/app/app/src/main/res/values-night/styles.xml b/app/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..4aa21da --- /dev/null +++ b/app/app/src/main/res/values-night/styles.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/app/src/main/res/values/strings.xml b/app/app/src/main/res/values/strings.xml index e7d5584..367630e 100644 --- a/app/app/src/main/res/values/strings.xml +++ b/app/app/src/main/res/values/strings.xml @@ -47,6 +47,8 @@ Generate recipe with AI Name of dish Generate + Ingredients + Directions g diff --git a/app/app/src/main/res/values/styles.xml b/app/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..560b559 --- /dev/null +++ b/app/app/src/main/res/values/styles.xml @@ -0,0 +1,6 @@ + + + +