Implement displaying ingredient sections
This commit is contained in:
@@ -18,6 +18,7 @@ data class RecipeIngredientInfo(
|
||||
val quantity: Double?,
|
||||
val unit: String?,
|
||||
val food: String?,
|
||||
val title: String?,
|
||||
)
|
||||
|
||||
data class RecipeInstructionInfo(
|
||||
|
||||
@@ -52,6 +52,7 @@ fun RecipeIngredientInfo.toRecipeIngredientEntity(remoteId: String) = RecipeIngr
|
||||
unit = unit,
|
||||
food = food,
|
||||
quantity = quantity,
|
||||
title = title,
|
||||
)
|
||||
|
||||
fun RecipeInstructionInfo.toRecipeInstructionEntity(remoteId: String) = RecipeInstructionEntity(
|
||||
@@ -129,6 +130,7 @@ fun GetRecipeIngredientResponseV0.toRecipeIngredientInfo() = RecipeIngredientInf
|
||||
unit = null,
|
||||
food = null,
|
||||
quantity = 1.0,
|
||||
title = null,
|
||||
)
|
||||
|
||||
fun GetRecipeInstructionResponseV0.toRecipeInstructionInfo() = RecipeInstructionInfo(
|
||||
@@ -153,6 +155,7 @@ fun GetRecipeIngredientResponseV1.toRecipeIngredientInfo() = RecipeIngredientInf
|
||||
unit = unit?.name,
|
||||
food = food?.name,
|
||||
quantity = quantity,
|
||||
title = title,
|
||||
)
|
||||
|
||||
fun GetRecipeInstructionResponseV1.toRecipeInstructionInfo() = RecipeInstructionInfo(
|
||||
|
||||
@@ -3,6 +3,7 @@ package gq.kirmanak.mealient.ui.recipes.info
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.core.view.isGone
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@@ -54,6 +55,8 @@ class RecipeIngredientsAdapter private constructor(
|
||||
|
||||
fun bind(item: RecipeIngredientEntity) {
|
||||
logger.v { "bind() called with: item = $item" }
|
||||
binding.sectionGroup.isGone = item.title.isNullOrBlank()
|
||||
binding.title.text = item.title.orEmpty()
|
||||
binding.checkBox.text = if (disableAmounts) {
|
||||
item.note
|
||||
} else {
|
||||
|
||||
@@ -5,12 +5,41 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/section_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="title, title_divider"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/margin_small"
|
||||
android:textAppearance="?textAppearanceHeadline6"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Meat a very long and weird title that someone might have for some reason" />
|
||||
|
||||
<View
|
||||
android:id="@+id/title_divider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:alpha="0.3"
|
||||
android:background="?colorOnSurface"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title_divider"
|
||||
tools:text="900 g braising steak/stew meat, cubed into 2.5cm pieces" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user