Skip to content

Commit

Permalink
feat: 로그인 바텀시트 보여주는 로직 변경
Browse files Browse the repository at this point in the history
이제부터는 모든 바텀 버튼을 누르면 로그인 화면이 뜹니다.
  • Loading branch information
RightHennessy committed Oct 31, 2023
1 parent 6ac28dc commit 585a18b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class GuestViewModel @Inject constructor(
private val _refreshState: MutableLiveData<Boolean> = MutableLiveData<Boolean>()
val refreshState: LiveData<Boolean> get() = _refreshState

fun refresh() {
_refreshState.value = true
fun refresh(isRefreshed: Boolean) {
_refreshState.value = isRefreshed
}

fun signUp(token: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ class LoginBottomSheetFragment :
setClickEventOnLoginButton()
}

override fun onDestroyView() {
super.onDestroyView()

if (guestViewModel.signUpState.value != SUCCESS) {
guestViewModel.refresh(false)
}
}

private fun initBinding() {
binding.lifecycleOwner = viewLifecycleOwner
}
Expand All @@ -72,7 +80,7 @@ class LoginBottomSheetFragment :
when (onBoardingDoneState) {
is OnBoardingDoneState.Success -> {
if (onBoardingDoneState.isDone) {
guestViewModel.refresh()
guestViewModel.refresh(true)
this.dismiss()
if (parentFragment is BottomSheetListener) {
(parentFragment as BottomSheetListener).onBottomSheetClosed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,40 +66,34 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
val itemId = binding.bnvMain.selectedItemId
val fragmentType = FragmentType.valueOf(itemId)
showFragment(fragmentType)
} else {
binding.bnvMain.selectedItemId = R.id.menu_study_list
}
}
}

private fun setBottomNavigationView() {
binding.bnvMain.setOnItemSelectedListener(::displayFragment)
binding.bnvMain.selectedItemId = R.id.menu_home
binding.bnvMain.selectedItemId = when (mainViewModel.isGuest) {
true -> R.id.menu_study_list
false -> R.id.menu_home
}
}

private fun displayFragment(item: MenuItem): Boolean {
when (FragmentType.valueOf(item.itemId)) {
HOME -> showOriginOrGuest(HOME)
HOME -> showOriginOrLogin(HOME)
STUDY_LIST -> showFragment(STUDY_LIST)
CHAT -> showOriginOrGuest(CHAT)
CHAT -> showOriginOrLogin(CHAT)
MY_PAGE -> showOriginOrLogin(MY_PAGE)
else -> throw IllegalStateException()
}
return true
}

private fun showOriginOrGuest(type: FragmentType) {
when (mainViewModel.isGuest) {
true -> showFragment(GUEST)
false -> showFragment(type)
}
}

private fun showOriginOrLogin(type: FragmentType) {
when (mainViewModel.isGuest) {
true -> {
showFragment(GUEST)
showLoginBottomSheetDialog()
}

true -> showLoginBottomSheetDialog()
false -> showFragment(type)
}
}
Expand Down

0 comments on commit 585a18b

Please sign in to comment.