diff --git a/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/DishDetailsActivity.kt b/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/DishDetailsActivity.kt index f89f414..518d6ab 100644 --- a/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/DishDetailsActivity.kt +++ b/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/DishDetailsActivity.kt @@ -3,8 +3,10 @@ package tech.mercantec.easyeat.ui.dishes import android.app.Activity import android.app.ProgressDialog import android.os.Bundle +import android.text.Html import android.util.Log import android.view.View +import android.view.ViewGroup import android.widget.Button import android.widget.LinearLayout import android.widget.Toast @@ -25,7 +27,7 @@ class DishDetailsActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_dish_details) - val ingredientsContainer = findViewById(R.id.dishDetailIngredients) + val ingredientsContainer = findViewById(R.id.ingredients) val multiplierEditText = findViewById(R.id.ingredientMultiplier) val dishId = intent.getIntExtra("dish_id", -1) @@ -48,30 +50,20 @@ class DishDetailsActivity : AppCompatActivity() { return@thread } Log.i("DISH", recipe.ingredients.toString()) - val ingredientsLayout = findViewById(R.id.dishDetailIngredients) - val instructionsLayout = findViewById(R.id.dishDetailInstructions) + val instructionsLayout = findViewById(R.id.instructions) // Example data: recipe.ingredients and recipe.directions runOnUiThread { findViewById(R.id.dishDetailName).text = recipe.name findViewById(R.id.dishDetailDescription).text = recipe.description - // Populate Ingredients - recipe.ingredients.forEach { ingredient -> - val textView = TextView(this).apply { - text = "${ingredient.name} ${ingredient.amount ?: ""} ${ingredient.unit ?: ""}" - textSize = 18f - } - textView.textAlignment = View.TEXT_ALIGNMENT_CENTER - ingredientsLayout.addView(textView) - } // Populate Instructions (if directions are strings) recipe.directions.forEachIndexed { index, direction -> val textView = TextView(this).apply { text = "${index + 1}. $direction" textSize = 18f + setPadding(0, 8, 0, 8) } - textView.textAlignment = View.TEXT_ALIGNMENT_CENTER instructionsLayout.addView(textView) } } @@ -82,10 +74,9 @@ class DishDetailsActivity : AppCompatActivity() { for (ingredient in ingredients) { val row = TextView(this) val amount = (ingredient.amount ?: 0.0) * multiplier - row.text = "${ingredient.name}: ${"%.2f".format(amount)} ${ingredient.unit ?: ""}" + row.text = Html.fromHtml("• ${ingredient.name}: ${"%.2f".format(amount)} ${ingredient.unit ?: ""}", Html.FROM_HTML_MODE_LEGACY) row.textSize = 18f row.setPadding(0, 8, 0, 8) - row.textAlignment = View.TEXT_ALIGNMENT_CENTER container.addView(row) } } diff --git a/app/app/src/main/res/layout/activity_dish_details.xml b/app/app/src/main/res/layout/activity_dish_details.xml index 088988f..e50eb50 100644 --- a/app/app/src/main/res/layout/activity_dish_details.xml +++ b/app/app/src/main/res/layout/activity_dish_details.xml @@ -1,89 +1,89 @@ + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:padding="30sp" + android:orientation="vertical"> + + style="@style/HighContrastText" /> + - + /> + + + android:textSize="16sp" + android:paddingTop="8dp" + android:text="@string/portions_label" + /> + - - - - + /> - + android:textSize="18sp" + android:text="@string/ingredients_label" + style="@style/HighContrastText" + /> + + + + + />