Skip to content

Commit

Permalink
[FIX/#152] 취향 태그 버튼 터치 영역 넓히기
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jan 17, 2024
1 parent e46da03 commit 7557fc2
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.going.presentation.entertrip.preferencetag

import androidx.recyclerview.widget.RecyclerView
import com.going.domain.entity.PreferenceData
import com.going.presentation.R
import com.going.presentation.databinding.ItemPreferenceTagBinding

class PreferenceTagViewHolder(
Expand All @@ -17,20 +16,36 @@ class PreferenceTagViewHolder(
tvPreferenceTag1.text = item.leftPrefer
tvPreferenceTag3.text = item.rightPrefer

rgPreferenceTag.setOnCheckedChangeListener { _, checkedId ->
val selectedButtonIdList = listOf(
R.id.rb_preference_1,
R.id.rb_preference_2,
R.id.rb_preference_3,
R.id.rb_preference_4,
R.id.rb_preference_5
)
val selectedButtonList = listOf(
rbPreference1,
rbPreference2,
rbPreference3,
rbPreference4,
rbPreference5
)

val checkedIndex = selectedButtonIdList.indexOf(checkedId)
if (checkedIndex != -1) {
listener.onPreferenceSelected(item, checkedIndex)
val selectedViewList = listOf(
viewRadio1,
viewRadio2,
viewRadio3,
viewRadio4,
viewRadio5
)

selectedButtonList.forEachIndexed { index, radioButton ->
radioButton.setOnClickListener {
if (radioButton.isChecked) {
listener.onPreferenceSelected(item, index)
}
}
}

selectedViewList.forEachIndexed { index, view ->
view.setOnClickListener {
selectedButtonList[index].isChecked = true
listener.onPreferenceSelected(item, index)
}
}
}
}
}
}
66 changes: 62 additions & 4 deletions presentation/src/main/res/layout/item_preference_tag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
<ImageView
android:id="@+id/iv_preference_number"
android:layout_width="wrap_content"
android:adjustViewBounds="true"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:paddingVertical="2dp"
android:src="@drawable/ic_preference_union"
app:layout_constraintTop_toTopOf="@id/tv_preference_number"
app:layout_constraintBottom_toBottomOf="@id/tv_preference_number"
app:layout_constraintEnd_toEndOf="@id/tv_preference_number"
app:layout_constraintStart_toStartOf="@id/tv_preference_number"
app:layout_constraintEnd_toEndOf="@id/tv_preference_number"/>
app:layout_constraintTop_toTopOf="@id/tv_preference_number" />

<TextView
android:id="@+id/tv_preference_number"
Expand Down Expand Up @@ -66,6 +66,64 @@
app:layout_constraintTop_toBottomOf="@id/layout_preference_number"
tools:text="계획은 얼만큼 짤까요?" />

<LinearLayout
android:id="@+id/layout_radio"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginHorizontal="16dp"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@id/rg_preference_tag"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_preference_question">

<View
android:id="@+id/view_radio_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:background="@color/white_000"
app:layout_constraintBottom_toTopOf="@id/rg_preference_tag" />

<View
android:id="@+id/view_radio_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:background="@color/white_000"
app:layout_constraintBottom_toTopOf="@id/rg_preference_tag" />

<View
android:id="@+id/view_radio_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:background="@color/white_000"
app:layout_constraintBottom_toTopOf="@id/rg_preference_tag" />

<View
android:id="@+id/view_radio_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:background="@color/white_000"
app:layout_constraintBottom_toTopOf="@id/rg_preference_tag" />

<View
android:id="@+id/view_radio_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:background="@color/white_000"
app:layout_constraintBottom_toTopOf="@id/rg_preference_tag" />

</LinearLayout>

<RadioGroup
android:id="@+id/rg_preference_tag"
android:layout_width="0dp"
Expand Down Expand Up @@ -171,4 +229,4 @@

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 7557fc2

Please sign in to comment.