-
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
Merged
+420
−0
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f55ffc8
[ADD/#9] 취향 태그 뷰 파일 추가
leeeyubin eed05db
[ADD/#9] 아이템 파일 및 리소스 추가
leeeyubin 3ced80c
[UI/#9] 아이템 UI 구현
leeeyubin ba55740
[UI/#9] 리사이클러뷰 구현
leeeyubin e16d065
[ADD/#9] 리스트 어댑터 파일 추가
leeeyubin 910e515
[FEAT/#9] 리스트 어댑터 구현
leeeyubin 57d3877
[MOD/#9] 파일 이름 변경
leeeyubin 6658c4a
[MOD/#9] 파일 이름 변경
leeeyubin 6e604ae
[FEAT/#9] 리스트 어댑터 연결
leeeyubin 40ab234
[FEAT/#9] 버튼 클릭 리스너 구현
leeeyubin 6a9883c
[UI/#9] RadioButton UI 변경
leeeyubin da52f03
[FEAT/#9] 중복 클릭 방지 구현
leeeyubin 4948b47
[UI/#9] 버튼 마진값 수정
leeeyubin 295d451
[UI/#9] 버튼 클릭 시 색상 수정
leeeyubin 664de4f
[MOD/#9] Manifest 수정
leeeyubin dffb7a1
[MOD/#9] 코드리뷰 반영 (그래들, 매니페스트, 리스너)
leeeyubin 0bf16fa
[MOD/#9] 코드리뷰 반영 (리스트 어댑터 아이템 UI)
leeeyubin 7f30678
[FIX/#9] 고정 값 고치기
leeeyubin 8b8c792
[FIX/#9] 고정 값 고치기
leeeyubin 8604eae
[FIX/#9] View로 고치기
leeeyubin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
domain/src/main/kotlin/com/going/domain/entity/PreferenceData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
40 changes: 40 additions & 0 deletions
40
presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }, | ||
) | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { _, 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) | ||
} | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "효율적으로" | ||
), | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
4 changes: 4 additions & 0 deletions
4
presentation/src/main/res/drawable/sel_radiobutton_text_color.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" android:state_checked="false" /> | ||
</selector> |
16 changes: 16 additions & 0 deletions
16
presentation/src/main/res/drawable/sel_rounded_corner_preference_tag_button.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
6 changes: 6 additions & 0 deletions
6
presentation/src/main/res/drawable/shape_rect_5_white000_fill.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="@color/white_000" /> | ||
<corners android:radius="5dp" /> | ||
</shape> |
10 changes: 10 additions & 0 deletions
10
presentation/src/main/res/drawable/shape_rect_topleft5_gray300_fill.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<solid android:color="@color/gray_300" /> | ||
<corners | ||
android:bottomRightRadius="0dp" | ||
android:bottomLeftRadius="0dp" | ||
android:topRightRadius="0dp" | ||
android:topLeftRadius="5dp" /> | ||
</shape> |
59 changes: 59 additions & 0 deletions
59
presentation/src/main/res/layout/activity_preference_tag.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="wrap_content" | ||
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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
히야 굿굿 !