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 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ class BakeryListFragment :

val isFilterSelectedMember =
bakeryListViewModel.userRoleType.value == UserRoleType.FILTER_SELECTED_MEMBER.name
val isNoneMember = bakeryListViewModel.userRoleType.value == UserRoleType.NONE_MEMBER.name

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

Choose a reason for hiding this comment

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

함냐 이게 isNoneMember일 때 클릭 가능하려면 enable 하게 만들어야 하군욤..? 이거 때문에 꼬이는건강

Copy link
Member Author

Choose a reason for hiding this comment

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

제가 어제오늘 고치려다가 발견한 것입니당(먼가 틀린게 있을 수도..)

  1. 일단 BakeryFragment 의 initLayout 에서
    Timber.e("filter : ${bakeryListViewModel.bakeryListFilterType.value.isPersonalFilterApplied}") 확인해보면

image 이렇게 null 로 떠서.. 왜지? 라는 생각을 했습니당
collectdata 에서 페이징하는 걸 보면 true 로 설정이 되어있는데.. image
image
그래서 결과는 checkbox 혹은 layout 을 누르기 전에는 null
1번째 누르면 또 null 값이 오고
2번째 누르면 false 값이 오지만 또 체크는 되어있는 그런 상태입니다

  1. 'android:checked="@{viewModel}"` 로 요소를 추가해서 하면 레이아웃 클릭할때마다 체크박스도 표시가 되긴하는데 위와 같은 문제 + 초기상태 설정이 같이 고민이되어야하는 부분 때문에 꼬이고 있는 상태입니다

}
}

Expand Down Expand Up @@ -141,6 +142,12 @@ class BakeryListFragment :
}
}
.launchIn(viewLifecycleOwner.lifecycleScope)

bakeryListViewModel.showLoginNeed.flowWithLifecycle(viewLifecycleOwner.lifecycle).onEach {
if (it) {
showLoginNeedDialog()
}
}.launchIn(viewLifecycleOwner.lifecycleScope)
}

private fun initBreadTypeChips(chipGroup: ChipGroup, breadFilterList: List<BreadFilterType>) {
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 @@ -28,6 +29,9 @@ class BakeryListViewModel @Inject constructor(
private val _userRoleType = MutableStateFlow(gpDataSource.userRoleType)
val userRoleType get() = _userRoleType

private val _showLoginNeed = MutableStateFlow(false)
val showLoginNeed get() = _showLoginNeed

fun setBakerySortType(bakerySortType: BakerySortType) {
_bakeryListFilterState.update {
it.copy(sortType = bakerySortType)
Expand All @@ -36,8 +40,12 @@ class BakeryListViewModel @Inject constructor(

// TODO: dana update 로직 수정 필요
fun setIsPersonalFilterAppliedState() {
_bakeryListFilterState.update {
it.copy(isPersonalFilterApplied = it.isPersonalFilterApplied == false)
if (_userRoleType.value == UserRoleType.NONE_MEMBER.name) {
_showLoginNeed.value = true
} else {
_bakeryListFilterState.update {
it.copy(isPersonalFilterApplied = it.isPersonalFilterApplied == false)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_bakery_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
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"
Expand Down
Loading