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

Conversation

jooyyoo
Copy link
Member

@jooyyoo jooyyoo commented Feb 26, 2024

Related issue 🛠

Work Description ✏️

  • 로그인 바텀 시트 띄우기

Screenshot 📸

default.mp4

Uncompleted Tasks 😅

  • [ ]

To Reviewers 📢

바인딩으로 setIsPersonalFilterAppliedState()를 호출하고 있어서 프래그먼트를 init 했을 때마다 적용이 되고

발견한 문제도 마찬가지로 바인딩으로 호출하고 내 필터 타입 첫 상태가 null 이어서 그런지 원하는 형태로 바꾸기가 쉽지 않군요! ㅜ
이걸 고민하다가 조금 오래걸렸는데.. 해결을 못하고 pr 올립니다

data class BakeryListFilterType(
    val sortType: BakerySortType = BakerySortType.DEFAULT,
    val isPersonalFilterApplied: Boolean? = null,
    val isHard: Boolean = false,
    val isDessert: Boolean = false,
    val isBrunch: Boolean = false
)

다은 수정사항!
문제 상황 1. 필터 적용 회원일 때, 건빵집 리스트를 최초에 진입했을 시 필터 적용이 안되어 있음
원인: fragment 생성 시, 내 필터 적용 초기값이 null
해결: userRoleType에 따라 true, false로 초기값을 지정(필터 적용 회원일 때 초기값이 true가 되도록)

문제 상황, 원인 2. 비회원 일 시, 체크박스가 enable하지 않아 클릭 리스너가 먹히지 않아 로그인 유도 바텀 시트가 눌리지 않는 상황
헤결: 체크 박스 자체에 클릭, 포커스 속성을 없앰. 체크박스와 내 필터 적용 텍스트를 감싸는 레이아웃만 포커스를 주기 위해!
따라서 레이아웃을 눌렀을 때 UserRoleType에 따른 분기처리를 진행했고 체크 박스에 체크 표시는 isPersonalFilterApplied 속성에 따라 조절되게 함! 누르는 행위로 인해 체크 상태가 바뀌는게 아닌!


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}"` 로 요소를 추가해서 하면 레이아웃 클릭할때마다 체크박스도 표시가 되긴하는데 위와 같은 문제 + 초기상태 설정이 같이 고민이되어야하는 부분 때문에 꼬이고 있는 상태입니다

Copy link
Member Author

@jooyyoo jooyyoo left a comment

Choose a reason for hiding this comment

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

감사함니다🤍🤍
어케 해결하는지 너무 궁금했음 ㅎ.ㅎ
checkbox 자체는 아예 누르는 행위를 주지 않는 방법이 있군여

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.

오 똑똑하다

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.

아 이렇게 할 수 도 있었네요

@@ -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 짱이에요

@@ -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.

이걸 왜 생각 못했을까,,

@jihyunniiii
Copy link
Collaborator

주영 공주 수고했어 사랑해 보규 싶당

@jooyyoo jooyyoo merged commit 54deefe into develop Feb 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[mod] QA 반영
3 participants