-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UI/#9] 취향 태그 뷰 / UI 구현 #24
Changes from 16 commits
f55ffc8
eed05db
3ced80c
ba55740
e16d065
910e515
57d3877
6658c4a
6e604ae
40ab234
6a9883c
da52f03
4948b47
295d451
664de4f
dffb7a1
0bf16fa
7f30678
8b8c792
8604eae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.going.domain.entity | ||
|
||
data class PreferenceData( | ||
val number: Int, | ||
val leftPrefer: String, | ||
val rightPrefer: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.going.presentation.preferencetag | ||
|
||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import com.going.domain.entity.PreferenceData | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ActivityPreferenceTagBinding | ||
import com.going.ui.base.BaseActivity | ||
import com.going.ui.extension.toast | ||
|
||
class PreferenceTagActivity : | ||
BaseActivity<ActivityPreferenceTagBinding>(R.layout.activity_preference_tag), | ||
PreferenceTagAdapter.OnPreferenceSelectedListener { | ||
|
||
private var _adapter: PreferenceTagAdapter? = null | ||
private val adapter get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) } | ||
|
||
private val viewModel by viewModels<PreferenceTagViewModel>() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
initAdapter() | ||
} | ||
|
||
private fun initAdapter() { | ||
_adapter = PreferenceTagAdapter(this, this) | ||
binding.rvPreferenceTag.adapter = adapter | ||
adapter.submitList(viewModel.preferenceTagList) | ||
} | ||
|
||
override fun onPreferenceSelected(preference: PreferenceData) { | ||
// 선택된 취향 태그 처리 | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
_adapter = null | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.going.presentation.preferencetag | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import com.going.domain.entity.PreferenceData | ||
import androidx.recyclerview.widget.ListAdapter | ||
import com.going.presentation.databinding.ItemPreferenceTagBinding | ||
import com.going.ui.extension.ItemDiffCallback | ||
|
||
class PreferenceTagAdapter( | ||
context: Context, | ||
private val listener: OnPreferenceSelectedListener | ||
) : | ||
ListAdapter<PreferenceData, PreferenceTagViewHolder>(diffUtil) { | ||
|
||
private val inflater by lazy { LayoutInflater.from(context) } | ||
|
||
interface OnPreferenceSelectedListener { | ||
fun onPreferenceSelected(preference: PreferenceData) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PreferenceTagViewHolder { | ||
val binding: ItemPreferenceTagBinding = | ||
ItemPreferenceTagBinding.inflate(inflater, parent, false) | ||
return PreferenceTagViewHolder(binding, listener) | ||
} | ||
|
||
override fun onBindViewHolder(holder: PreferenceTagViewHolder, position: Int) { | ||
holder.onBind(getItem(position)) | ||
} | ||
|
||
override fun getItemCount() = currentList.size | ||
|
||
companion object { | ||
private val diffUtil = ItemDiffCallback<PreferenceData>( | ||
onItemsTheSame = { old, new -> old.number == new.number }, | ||
onContentsTheSame = { old, new -> old == new }, | ||
) | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.going.presentation.preferencetag | ||
|
||
import androidx.appcompat.widget.AppCompatButton | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.going.domain.entity.PreferenceData | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ItemPreferenceTagBinding | ||
|
||
class PreferenceTagViewHolder( | ||
val binding: ItemPreferenceTagBinding, | ||
private val listener: PreferenceTagAdapter.OnPreferenceSelectedListener | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun onBind(item: PreferenceData) { | ||
binding.run { | ||
tvPreferenceNumber.text = item.number.toString() | ||
tvPreferenceLeft.text = item.leftPrefer | ||
tvPreferenceRight.text = item.rightPrefer | ||
|
||
rgPreferenceTag.setOnCheckedChangeListener { group, 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 | ||
) | ||
|
||
if (checkedId in selectedButtonIdList) { | ||
listener.onPreferenceSelected(item) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. group의 경우 사용하지 않는 변수기때문에 _ 로 바꾸면 좋을 것 같습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호 좋은 정보 감사합니당 |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.going.presentation.preferencetag | ||
|
||
import androidx.lifecycle.ViewModel | ||
import com.going.domain.entity.PreferenceData | ||
|
||
class PreferenceTagViewModel : ViewModel() { | ||
|
||
val preferenceTagList = listOf<PreferenceData>( | ||
PreferenceData( | ||
number = 1, | ||
leftPrefer = "휴식", | ||
rightPrefer = "관광" | ||
), | ||
PreferenceData( | ||
number = 2, | ||
leftPrefer = "관광지", | ||
rightPrefer = "로컬 플레이스" | ||
), | ||
PreferenceData( | ||
number = 3, | ||
leftPrefer = "철처한 계획", | ||
rightPrefer = "무계획" | ||
), | ||
PreferenceData( | ||
number = 4, | ||
leftPrefer = "찾아온 맛집", | ||
rightPrefer = "끌리는 곳" | ||
), | ||
PreferenceData( | ||
number = 5, | ||
leftPrefer = "느긋하게", | ||
rightPrefer = "효율적으로" | ||
), | ||
) | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="177dp" | ||
android:height="2dp" | ||
android:viewportWidth="177" | ||
android:viewportHeight="2"> | ||
<path | ||
android:pathData="M0,1L177,1" | ||
android:strokeWidth="0.5" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#000000"/> | ||
</vector> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 선을 이미지로 활용하기 보다는, View의 색상을 검정색으로 두고 고정 height를 줘서 선처럼 보이도록 하는 방법, Material Divider를 활용하는 방법 중에 선택해서 활용하는게 더 바람직해보입니당 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="48dp" | ||
android:height="48dp" | ||
android:viewportWidth="48" | ||
android:viewportHeight="48"> | ||
<path | ||
android:pathData="M24,24m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0" | ||
android:fillColor="#D9D9D9"/> | ||
</vector> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:color="@color/white_000" android:state_checked="true" /> | ||
<item android:color="@color/black_000" /> | ||
</selector> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 개인적인 생각이긴 하지만 저는 checked="false" 도 써두는게 명확하게 표시할 수 있어서 좋다고 생각해요! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:state_checked="true"> | ||
<shape> | ||
<solid android:color="@color/black_000" /> | ||
<corners android:radius="24dp" /> | ||
</shape> | ||
</item> | ||
|
||
<item android:state_checked="false"> | ||
<shape> | ||
<solid android:color="@color/gray_300" /> | ||
<corners android:radius="24dp" /> | ||
</shape> | ||
</item> | ||
</selector> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<data> | ||
|
||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/white_000" | ||
tools:context=".preferencetag.PreferenceTagActivity"> | ||
|
||
<TextView | ||
android:id="@+id/tv_preference_title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="12dp" | ||
android:fontFamily="@font/pretendard_bold" | ||
android:text="@string/preference_tv_title" | ||
android:textColor="@color/black_000" | ||
android:textSize="18sp" | ||
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 디자인 나오면 폰트패밀리, 크기 각각 적용하지 말고 style로 사전 설정해둔거 활용해주세용 ~ |
||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/rv_preference_tag" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:background="@color/gray_200" | ||
android:paddingTop="17dp" | ||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
app:layout_constraintBottom_toTopOf="@id/btn_preference_start" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_preference_title" | ||
tools:listitem="@layout/item_preference_tag" /> | ||
|
||
<androidx.appcompat.widget.AppCompatButton | ||
android:id="@+id/btn_preference_start" | ||
style="@style/button_style" | ||
android:layout_width="0dp" | ||
android:layout_height="50dp" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 wrap_content와 padding 값으로 구현해봅시다 ~ |
||
android:layout_marginHorizontal="18dp" | ||
android:layout_marginBottom="50dp" | ||
android:background="@drawable/sel_rounded_corner_button" | ||
android:backgroundTint="@color/black_000" | ||
android:text="@string/preference_btn_start" | ||
android:textColor="@color/white_000" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</layout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
히야 굿굿 !