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

[mod] 비회원이 내 필터를 클릭하면 로그인 유도 바텀 시트를 띄우도록 구현 #234

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
applicationId "com.sopt.geonppang"
minSdk 28
targetSdk 34
versionCode 5
versionCode 6
versionName "1.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.sopt.geonppang.presentation.type.BakerySortType

data class BakeryListFilterType(
val sortType: BakerySortType = BakerySortType.DEFAULT,
val isPersonalFilterApplied: Boolean? = null,
val isPersonalFilterApplied: Boolean,
val isHard: Boolean = false,
val isDessert: Boolean = false,
val isBrunch: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ class BakeryListFragment :
addItemDecoration(CustomItemDecoration(requireContext()))
}

val isFilterSelectedMember =
bakeryListViewModel.userRoleType.value == UserRoleType.FILTER_SELECTED_MEMBER.name
val isFilterUnSelectedMember =
bakeryListViewModel.userRoleType.value == UserRoleType.FILTER_UNSELECTED_MEMBER.name

with(binding) {
includeHomeSpeechBubble.root.setVisibility(bakeryListViewModel.userRoleType.value == UserRoleType.FILTER_UNSELECTED_MEMBER.name)
checkBakeryListMyFilter.isEnabled = isFilterSelectedMember
checkBakeryListMyFilter.isChecked = isFilterSelectedMember
layoutBakeryListMyFiltaerApply.isEnabled = isFilterSelectedMember
includeHomeSpeechBubble.root.setVisibility(isFilterUnSelectedMember)
layoutBakeryListMyFilterApply.isEnabled = !isFilterUnSelectedMember
Copy link
Member Author

Choose a reason for hiding this comment

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

오 똑똑하다

}
}

Expand All @@ -91,15 +89,20 @@ class BakeryListFragment :

// 비회원, 회원 분기처리
binding.ivBakeryListFilter.setOnClickListener {
val isMember = bakeryListViewModel.userRoleType.value == UserRoleType.NONE_MEMBER.name
val isNoneMember =
bakeryListViewModel.userRoleType.value == UserRoleType.NONE_MEMBER.name

if (isMember) {
if (isNoneMember) {
showLoginNeedDialog()
} else {
moveToFilter()
AmplitudeUtils.trackEvent(START_FILTER_LIST)
}
}

binding.layoutBakeryListMyFilterApply.setOnClickListener {
onApplyPersonalFilterClicked()
}
}

private fun collectData() {
Expand All @@ -116,7 +119,7 @@ class BakeryListFragment :
.map { it.isPersonalFilterApplied }
.distinctUntilChanged()
.flowWithLifecycle(viewLifecycleOwner.lifecycle).onEach { isPersonalFilterApplied ->
if (isPersonalFilterApplied == false) {
if (!isPersonalFilterApplied) {
AmplitudeUtils.trackEvent(CLICK_PERSONAL_FILTER_APPLY_OFF)
}
}.launchIn(viewLifecycleOwner.lifecycleScope)
Expand Down Expand Up @@ -200,6 +203,17 @@ class BakeryListFragment :
bakeryListViewModel.setBakerySortType(bakerySortType)
}

private fun onApplyPersonalFilterClicked() {
val isNoneMember =
bakeryListViewModel.userRoleType.value == UserRoleType.NONE_MEMBER.name

if (isNoneMember) {
showLoginNeedDialog()
} else {
bakeryListViewModel.setIsPersonalFilterAppliedState()
Copy link
Member Author

Choose a reason for hiding this comment

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

아 이렇게 할 수 도 있었네요

}
}

companion object {
const val BAKERY_ID = "bakeryId"
const val FILTER_INFO = "filterInfo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.sopt.geonppang.domain.model.BakeryInformation
import com.sopt.geonppang.domain.model.BakeryListFilterType
import com.sopt.geonppang.presentation.type.BakeryCategoryType
import com.sopt.geonppang.presentation.type.BakerySortType
import com.sopt.geonppang.presentation.type.UserRoleType
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -22,7 +23,11 @@ class BakeryListViewModel @Inject constructor(
private val bakeryListPagingRepository: BakeryListPagingRepository,
private val gpDataSource: GPDataSource
) : ViewModel() {
private var _bakeryListFilterState = MutableStateFlow(BakeryListFilterType())
private var _bakeryListFilterState = MutableStateFlow(
Copy link
Member Author

Choose a reason for hiding this comment

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

wow 짱이에요

BakeryListFilterType(
isPersonalFilterApplied = gpDataSource.userRoleType == UserRoleType.FILTER_SELECTED_MEMBER.name
)
)
val bakeryListFilterType get() = _bakeryListFilterState.asStateFlow()

private val _userRoleType = MutableStateFlow(gpDataSource.userRoleType)
Expand All @@ -37,7 +42,7 @@ class BakeryListViewModel @Inject constructor(
// TODO: dana update 로직 수정 필요
fun setIsPersonalFilterAppliedState() {
_bakeryListFilterState.update {
it.copy(isPersonalFilterApplied = it.isPersonalFilterApplied == false)
it.copy(isPersonalFilterApplied = !it.isPersonalFilterApplied)
}
}

Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/fragment_bakery_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,10 @@
app:layout_constraintTop_toBottomOf="@id/view_line_bottom">

<LinearLayout
android:id="@+id/layout_bakery_list_my_filtaer_apply"
android:id="@+id/layout_bakery_list_my_filter_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing24"
android:onClick="@{() -> viewModel.setIsPersonalFilterAppliedState()}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
Expand All @@ -163,7 +162,9 @@
style="@style/Style.CheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{() -> viewModel.setIsPersonalFilterAppliedState()}" />
android:checked="@{viewModel.bakeryListFilterType.personalFilterApplied}"
Copy link
Member Author

Choose a reason for hiding this comment

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

진짜 여기서 머리 터지는 줄 ㅋㅋㅋㅋ ㅜ

Copy link
Member

Choose a reason for hiding this comment

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

이걸 왜 생각 못했을까,,

android:clickable="false"
android:focusable="false" />

<TextView
android:layout_width="wrap_content"
Expand Down
Loading