Skip to content

Commit

Permalink
#6 mypage_fragment/설정 화면 : 6 로그아웃 다이얼로그
Browse files Browse the repository at this point in the history
 - 로그아웃 다이얼로그 연결
  • Loading branch information
likppi10 committed Aug 27, 2022
1 parent 628db20 commit b3dcba9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.ftw.hometerview.R
import com.ftw.hometerview.databinding.FragmentMyPageBinding
import com.ftw.hometerview.ui.dialog.LogoutDialog
import com.ftw.hometerview.ui.login.LoginActivity
import com.ftw.hometerview.ui.manageaccount.ManageAccountActivity
import com.ftw.hometerview.ui.updatenickname.UpdateNicknameActivity
import com.ftw.hometerview.ui.myreviews.MyReviewsActivity
Expand Down Expand Up @@ -77,6 +79,7 @@ class MyPageFragment : Fragment() {
is MyPageViewModel.Event.onClickUpdateNickname -> updateNicknameActivity(event.nickname)
MyPageViewModel.Event.onClickWrittenReview -> writtenReviewActivity()
MyPageViewModel.Event.onClickManageAccount -> manageAccountActivity()
MyPageViewModel.Event.onClickLogout -> onClickLogoutDialog()
}
}
}
Expand Down Expand Up @@ -140,6 +143,18 @@ class MyPageFragment : Fragment() {
startActivity(ManageAccountActivity.newIntent(requireContext()))
}

private fun onClickLogoutDialog(){
val customDialog = LogoutDialog(logout = {onClickLogout()})
customDialog.show(parentFragmentManager, "CustomDialog")
}

private fun onClickLogout(){
requireActivity().apply {
finish()
startActivity(LoginActivity.newIntent(requireContext()))
}
}

private fun setLauncher() {
updateNicknameLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MyPageViewModel (
class onClickUpdateNickname(val nickname: String) : Event()
object onClickWrittenReview : Event()
object onClickManageAccount : Event()
object onClickLogout : Event()
}

private val _user: MutableStateFlow<User> = MutableStateFlow(User.NONE)
Expand Down Expand Up @@ -54,4 +55,9 @@ class MyPageViewModel (
_event.value = Event.onClickManageAccount
_event.value = Event.None
}

fun onClickLogout() {
_event.value = Event.onClickLogout
_event.value = Event.None
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_my_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
android:id="@+id/logout_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{() -> viewModel.onClickLogout()}"
android:paddingVertical="@dimen/dp_size_16"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down

0 comments on commit b3dcba9

Please sign in to comment.