-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from all commits
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 |
---|---|---|
|
@@ -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 | ||
} | ||
} | ||
|
||
|
@@ -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() { | ||
|
@@ -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) | ||
|
@@ -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() | ||
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. 아 이렇게 할 수 도 있었네요 |
||
} | ||
} | ||
|
||
companion object { | ||
const val BAKERY_ID = "bakeryId" | ||
const val FILTER_INFO = "filterInfo" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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( | ||
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. wow 짱이에요 |
||
BakeryListFilterType( | ||
isPersonalFilterApplied = gpDataSource.userRoleType == UserRoleType.FILTER_SELECTED_MEMBER.name | ||
) | ||
) | ||
val bakeryListFilterType get() = _bakeryListFilterState.asStateFlow() | ||
|
||
private val _userRoleType = MutableStateFlow(gpDataSource.userRoleType) | ||
|
@@ -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) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"> | ||
|
@@ -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}" | ||
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. 진짜 여기서 머리 터지는 줄 ㅋㅋㅋㅋ ㅜ 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. 이걸 왜 생각 못했을까,, |
||
android:clickable="false" | ||
android:focusable="false" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
|
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.
오 똑똑하다