Skip to content
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

[feat] 핑글 개최 프로세스 - 카테고리 선택 뷰 구현 #56

Merged
merged 19 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f56a93d
[feat] #22 카테고리 재사용 뷰 구현
HAJIEUN02 Jan 5, 2024
3d03f1f
[add] #22 string 리소스 추가
HAJIEUN02 Jan 5, 2024
a64ecaa
Merge branch 'develop' into feat-plan-category
HAJIEUN02 Jan 5, 2024
16fe306
[chore] #22 PlanActivity fragmentList에 카테고리 선택 프래그먼트 추가
HAJIEUN02 Jan 5, 2024
85672f3
[feat] #22 BindingAdapter : textColor 커스터마이징 함수 추가
HAJIEUN02 Jan 5, 2024
f75dfa1
[feat] #22 카테고리 선택 뷰 구현
HAJIEUN02 Jan 5, 2024
62e8e40
Merge branch 'develop' into feat-plan-category
HAJIEUN02 Jan 5, 2024
407c940
Merge branch 'develop' into feat-plan-category
HAJIEUN02 Jan 6, 2024
f04a635
Merge branch 'develop' into feat-plan-category
HAJIEUN02 Jan 7, 2024
4b7a997
[add] #22 카테고리 클릭/해제 시 stroke background 추가
HAJIEUN02 Jan 7, 2024
dbf6805
[add] #22 카테고리 클릭/해제 시 stroke background selector 추가 및 stroke backgro…
HAJIEUN02 Jan 7, 2024
104cc4d
Merge branch 'develop' into feat-plan-category
HAJIEUN02 Jan 7, 2024
0a576d0
[chore] #22 머지 후 리소스 color 오류 수정
HAJIEUN02 Jan 7, 2024
abba367
[feat] #22 BindingAdapter Select여부 저장 메소드 구현
HAJIEUN02 Jan 7, 2024
7bdc447
[feat] #22 카테고리 타입 단일선택 로직 구현
HAJIEUN02 Jan 7, 2024
5b1856b
[add] #22 카테고리 타입 UX라이팅 리소스 추가
HAJIEUN02 Jan 7, 2024
831a935
[chore] #22 카테고리 타입 설명 데이터바인딩 적용
HAJIEUN02 Jan 7, 2024
c6fcaf4
Merge branch 'develop' into feat-plan-category
HAJIEUN02 Jan 7, 2024
498d3ac
[chore] #22 ktlint 적용
HAJIEUN02 Jan 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,42 @@ enum class CategoryType(
@ColorRes val activatedOutLinedColor: Int,
@ColorRes val backgroundChipColor: Int,
@ColorRes val backgroundBadgeColor: Int,
@StringRes val categoryNameRes: Int
@StringRes val categoryNameRes: Int,
@StringRes val categoryDescriptionRes: Int
// TODO 해당 부분은 UX, icon 정해지면 추가하기
// @StringRes val categoryDescriptionRes: Int,
// @DrawableRes val categoryIconRes: Int,
) {
PLAY(
textColor = R.color.pingle_green,
activatedOutLinedColor = R.color.pingle_green,
backgroundChipColor = R.color.chip_green,
backgroundBadgeColor = R.color.badge_green,
categoryNameRes = R.string.category_play
categoryNameRes = R.string.category_play,
categoryDescriptionRes = R.string.category_play_detail
),
STUDY(
textColor = R.color.pingle_orange,
activatedOutLinedColor = R.color.pingle_orange,
backgroundChipColor = R.color.chip_orange,
backgroundBadgeColor = R.color.badge_orange,
categoryNameRes = R.string.category_study
categoryNameRes = R.string.category_study,
categoryDescriptionRes = R.string.category_study_detail
),
MULTI(
textColor = R.color.pingle_yellow,
activatedOutLinedColor = R.color.pingle_yellow,
backgroundChipColor = R.color.chip_yellow,
backgroundBadgeColor = R.color.badge_yellow,
categoryNameRes = R.string.category_multi
categoryNameRes = R.string.category_multi,
categoryDescriptionRes = R.string.category_multi_detail
),
OTHERS(
textColor = R.color.g_01,
activatedOutLinedColor = R.color.g_01,
backgroundChipColor = R.color.g_10,
backgroundBadgeColor = R.color.g_07,
categoryNameRes = R.string.category_others
categoryNameRes = R.string.category_others,
categoryDescriptionRes = R.string.category_others_detail
);

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class PlanActivity : BindingActivity<ActivityPlanBinding>(R.layout.activity_plan
// TODO 차후에 나머지 개최 프로세스 fragment 추가
fragmentList = ArrayList()
fragmentList.apply {
add(PlanCategoryFragment())
add(PlanTitleFragment())
add(PlanDateTimeFragment())
add(PlanLocationFragment())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.sopt.pingle.presentation.ui.main.plan

import android.os.Bundle
import android.view.View
import androidx.fragment.app.viewModels
import org.sopt.pingle.R
import org.sopt.pingle.databinding.FragmentPlanCategoryBinding
import org.sopt.pingle.util.base.BindingFragment

class PlanCategoryFragment :
BindingFragment<FragmentPlanCategoryBinding>(R.layout.fragment_plan_category) {
private val planViewModel by viewModels<PlanViewModel>()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.planViewModel = planViewModel
binding.lifecycleOwner = this
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 이미 BindingFragmen에 있어서 적용해주지 않아도 됩니다.
또한, Fragment에서 lifecycleOwner를 잘 설정해주는 것이 중요한데요. 여기서 this를 사용하는 것이 적절할까요?
어떤 걸 쓰면 좋을지 고민해보구 그 이유를 알려주세용


initLayout()
addListeners()
}

private fun initLayout() {
}

Comment on lines +23 to +25
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용하지 않는 함수 지워주세요.

private fun addListeners() {
with(binding) {
includePlanCategoryTypePlay.root.setOnClickListener {
}
includePlanCategoryTypeStudy.root.setOnClickListener {
}
includePlanCategoryTypeMulti.root.setOnClickListener {
}
includePlanCategoryTypeOthers.root.setOnClickListener {
}
}
}
Comment on lines +26 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 지워주세요

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.stateIn
import org.sopt.pingle.presentation.type.CategoryType
import org.sopt.pingle.presentation.type.PlanType

class PlanViewModel : ViewModel() {
Expand Down Expand Up @@ -44,6 +45,14 @@ class PlanViewModel : ViewModel() {
private val _address = MutableStateFlow<String?>(null)
val address get() = _address.asStateFlow()

// TODO 뷰 연결 시 버튼 활성/비활성화 로직 isPlanBtnEnabled에 추가
private val _selectedCategory = MutableStateFlow<CategoryType?>(null)
val selectedCategory get() = _selectedCategory.asStateFlow()

fun setSelectedCategory(categoryType: CategoryType) {
_selectedCategory.value = categoryType
}

fun setCurrentPage(position: Int) {
_currentPage.value = position
}
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/org/sopt/pingle/util/base/BindingAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.sopt.pingle.util.base

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.databinding.BindingAdapter

Expand All @@ -11,6 +12,17 @@ fun setImageResource(imageView: ImageView, resId: Int) {
imageView.setImageDrawable(drawable)
}

@BindingAdapter("color")
fun setTextColor(textView: TextView, resId: Int) {
val colorRes = ContextCompat.getColor(textView.context, resId)
textView.setTextColor(colorRes)
}

@BindingAdapter("selection")
fun setSelected(view: View, isSelected: Boolean) {
view.isSelected = isSelected
}

@BindingAdapter("visibility")
fun View.setVisibility(isVisible: Boolean?) {
if (isVisible == null) {
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shape_line_g_10_radius_10
네이밍 컨벤션 지켜주세요

그리고 이 파일 없어져도 될 것 같습니다!
backgroundTint로 배경 색상 지정해주면 되기 때문에 shape_border_radius_10 파일 사용하면 됩니다

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/g_10"/>
<corners android:radius="10dp"/>
</shape>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shape_line_white_radius_10

네이밍 컨벤션 지켜주세요

그리고 다음과 같은 형식으로 작성해주세요
(shape 따로 지정 필요 X, Solid 값은 색상 따로 지정해두지 말고 backgroundTint 사용해주세요)

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke
        android:width="1dp"
        android:color="@color/white"/>
    <corners android:radius="10dp"/>
</shape>

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/g_10"/>
<stroke
android:width="1dp"
android:color="@color/white"/>
<corners android:radius="10dp"/>
</shape>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요기서도 아까 말했던 drawable 파일 사용해주면 되겠죠??

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/background_disabled_plan_location_category" android:state_selected="false"/>
<item android:drawable="@drawable/background_enabled_plan_location_category" android:state_selected="true"/>
</selector>
100 changes: 100 additions & 0 deletions app/src/main/res/layout/fragment_plan_category.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?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>
<variable
name="planViewModel"
type="org.sopt.pingle.presentation.ui.main.plan.PlanViewModel" />

<import type="org.sopt.pingle.presentation.type.CategoryType"></import>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어제 말했던 방식으로 해보고 얘 지워도되나 테스트 부탁해요 ~

<variable
name="planCategory"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

categoryType으로 작성하는 게 더 가독성 좋을 듯 요

type="org.sopt.pingle.presentation.type.CategoryType" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.ui.plan.PlanLocationFragment">

<TextView
android:id="@+id/tv_plan_location_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing8"
android:text="@string/plan_category_title"
android:textAppearance="@style/TextAppearance.Pingle.Title.Semi.24"
android:textColor="@color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_plan_category_topCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing28"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_plan_location_title">

<include
android:id="@+id/include_plan_category_type_play"
layout="@layout/view_plan_category_type"
android:layout_width="wrap_content"
android:layout_height="0dp"
selection="@{planViewModel.selectedCategory == planCategory.PLAY}"
android:onClick="@{()->planViewModel.setSelectedCategory(planCategory.PLAY)}"
app:categoryType="@{planCategory.PLAY}"
app:layout_constraintStart_toStartOf="parent" />

<include
android:id="@+id/include_plan_category_type_study"
layout="@layout/view_plan_category_type"
android:layout_width="wrap_content"
android:layout_height="0dp"
selection="@{planViewModel.selectedCategory == planCategory.STUDY}"
android:onClick="@{()->planViewModel.setSelectedCategory(planCategory.STUDY)}"
android:layout_marginStart="@dimen/spacing9"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

간격 10 아닌가요?

app:categoryType="@{planCategory.STUDY}"
app:layout_constraintEnd_toEndOf="parent"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지워주세요

app:layout_constraintStart_toEndOf="@id/include_plan_category_type_play" />
</androidx.constraintlayout.widget.ConstraintLayout>
Comment on lines +33 to +64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

두 개 씩 constraintLayout으로 묶어준 이유는 가운데 정렬을 하기 위함인가요?
어제 말했던 대로 기기대응을 적절히 생각해보는 게 좋을 것 같네요 ㅜ
잘 조절하면 constraintLayout으로 묶어줄 필요는 없을 것 같아요 (불필요한 depth를 가져가는 것은 좋지 않습니다)

잘 이해가 안 간다면 건빵 필터 선택 뷰의 빵 유형 선택 뷰가 이와 비슷한 형태이니 그걸 참고해주시면 좋을 것 같습니다 ! (체인을 적절하게 사용해주세요 ~)


<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_plan_category_bottomCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing11"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_plan_category_topCategory">

<include
android:id="@+id/include_plan_category_type_multi"
layout="@layout/view_plan_category_type"
android:layout_width="wrap_content"
android:layout_height="0dp"
Comment on lines +78 to +79
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

width -> 0dp
height -> wrap_content

이유는 왤까요?

selection="@{planViewModel.selectedCategory == planCategory.MULTI}"
android:onClick="@{()->planViewModel.setSelectedCategory(planCategory.MULTI)}"
app:categoryType="@{planCategory.MULTI}"
app:layout_constraintStart_toStartOf="parent" />

<include
android:id="@+id/include_plan_category_type_others"
layout="@layout/view_plan_category_type"
android:layout_width="wrap_content"
android:layout_height="0dp"
selection="@{planViewModel.selectedCategory == planCategory.OTHERS}"
android:onClick="@{()->planViewModel.setSelectedCategory(planCategory.OTHERS)}"
android:layout_marginStart="@dimen/spacing9"
app:categoryType="@{planCategory.OTHERS}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/include_plan_category_type_multi" />
</androidx.constraintlayout.widget.ConstraintLayout>

Comment on lines +66 to +97
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 위와 동일합니다. 불필요한 depth를 줄여주세요


</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
66 changes: 66 additions & 0 deletions app/src/main/res/layout/view_plan_category_type.xml
Copy link
Collaborator

Choose a reason for hiding this comment

The 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,66 @@
<?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>

<variable
name="planViewModel"
type="org.sopt.pingle.presentation.ui.main.plan.PlanViewModel" />

Comment on lines +8 to +11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기에 뷰모델을 추가할 필요는 없어 보입니다 제거해주세요

<variable
name="categoryType"
type="org.sopt.pingle.presentation.type.CategoryType" />

<import type="org.sopt.pingle.presentation.type.CategoryType" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 부탁ㅎㅐ용

</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_item_plan_location_category">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 배경 바꾸면서 background tint 조절 고고


<!--TODO image="@{categoryType.categoryIconRes}" -->
<ImageView
android:id="@+id/iv_plan_category_type"
android:layout_width="84dp"
android:layout_height="84dp"
Comment on lines +27 to +28
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

에셋 나오면 wrap_content나 0dp 로 설정해주는 거 알죵?

android:layout_marginHorizontal="38dp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좌우 정렬을 모두 했으므로 이 마진값 제거해주세요

android:layout_marginTop="@dimen/spacing13"
android:src="@drawable/ic_all_warning_notice_24"
app:layout_constraintDimensionRatio="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tv_plan_category_name"
color="@{categoryType.textColor}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing3"
android:background="@color/g_10"
android:text="@{categoryType.categoryNameRes}"
android:textAppearance="@style/TextAppearance.Pingle.Title.Semi.20"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bold 18

app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_plan_category_type"
tools:text="PLAY" />

<TextView
android:id="@+id/tv_plan_category_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing3"
android:layout_marginBottom="20dp"
android:text="@{categoryType.categoryDescriptionRes}"
android:textAppearance="@style/TextAppearance.Pingle.Cap.Med.12"
android:textColor="@color/g_04"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_plan_category_name"
tools:text="설명 텍스트 미정" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<string name="category_study">STUDY</string>
<string name="category_multi">MULTI</string>
<string name="category_others">OTHERS</string>
<string name="category_play_detail">노는게 제일 좋아!</string>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

타입에서 선언한 이름대로
category_타입이름_description 으로 해주는 게 좋을 것 같네요

<string name="category_study_detail">열공, 열작업 할 사람 모여라!</string>
<string name="category_multi_detail">놀 땐 놀고, 일할 땐 일하자!</string>
<string name="category_others_detail">다른 활동이 하고 싶다면?</string>

<!-- all navi title -->
<string name="all_navi_home">홈</string>
Expand Down Expand Up @@ -87,4 +91,7 @@
<string name="plan_location_quit"><u>나가기</u></string>
<string name="plan_location_empty">검색 결과가 없어요</string>
<string name="plan_location_empty_info">다른 장소로 검색해보세요</string>

<!-- plan Category -->
<string name="plan_category_title">개최할 핑글을\n선택해주세요</string>
</resources>
Loading