Skip to content

Commit

Permalink
#210 내 이미지 제거 바텀시트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Aug 21, 2023
1 parent b99b108 commit fcbf47f
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class MyPageFragment :
setFragmentResultListner()
}

private fun setBinding() =
binding.apply {
private fun setBinding() = binding.apply {
viewModel = fragmentViewModel.apply {
viewLifecycleOwner.apply {
repeatOnStarted { token.collect { handleToken(it) } }
Expand Down Expand Up @@ -203,7 +202,9 @@ class MyPageFragment :
MyPageMoreBottomSheetFragment.BottomSheetFlag.CHANGE_PASSWORD.value -> showMyPageMoreDialog(MyPageMoreDialogFragment.DialogType.CHANGE_PASSWORD)
MyPageMoreBottomSheetFragment.BottomSheetFlag.WITHDRAWAL.value -> showMyPageMoreDialog(MyPageMoreDialogFragment.DialogType.WITHDRAWAL)
MyPageMoreBottomSheetFragment.BottomSheetFlag.LOGOUT.value -> showMyPageMoreDialog(MyPageMoreDialogFragment.DialogType.LOGOUT)
MyPageMoreBottomSheetFragment.BottomSheetFlag.CHANGE_USER_IMAGE.value -> {}

MyPageMoreBottomSheetFragment.BottomSheetFlag.CHANGE_IMAGE.value -> {}
MyPageMoreBottomSheetFragment.BottomSheetFlag.REMOVE_IMAGE.value -> {}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class MyPageMoreBottomSheetFragment(private val bottomSheetType: BottomSheetType
CHANGE_PASSWORD(302),
WITHDRAWAL(303),
LOGOUT(304),
CHANGE_USER_IMAGE(305)
CHANGE_IMAGE(305),
REMOVE_IMAGE(306)
}

enum class BottomSheetType {
Expand Down Expand Up @@ -82,20 +83,18 @@ class MyPageMoreBottomSheetFragment(private val bottomSheetType: BottomSheetType
private fun setBottomSheetType() {
when (bottomSheetType) {
BottomSheetType.DEFAULT -> defaultBottomSheetVisible()
BottomSheetType.IMAGE ->imageBottomSheetVisible()
BottomSheetType.IMAGE -> imageBottomSheetVisible()
}
}

private fun defaultBottomSheetVisible() {
binding.changeUserImageTV.visibility = View.GONE
private fun defaultBottomSheetVisible() = binding.apply {
defaultBottomSheetLL.visibility = View.VISIBLE
imageBottomSheetLL.visibility = View.GONE
}

private fun imageBottomSheetVisible() = binding.apply {
changeNickNameTV.visibility = View.GONE
changePasswordTV.visibility = View.GONE
withdrawalTV.visibility = View.GONE
logoutTV.visibility = View.GONE
changeUserImageTV.visibility = View.VISIBLE
defaultBottomSheetLL.visibility = View.GONE
imageBottomSheetLL.visibility = View.VISIBLE
}

private fun setBinding() {
Expand All @@ -117,7 +116,9 @@ class MyPageMoreBottomSheetFragment(private val bottomSheetType: BottomSheetType
BottomSheetFlag.CHANGE_PASSWORD -> completeBottomSheetChangePassword()
BottomSheetFlag.WITHDRAWAL -> completeBottomSheetWithdrawal()
BottomSheetFlag.LOGOUT -> completeBottomSheetLogout()
BottomSheetFlag.CHANGE_USER_IMAGE -> completeBottomSheetChangeUserImage()

BottomSheetFlag.CHANGE_IMAGE -> completeBottomSheetChangeImage()
BottomSheetFlag.REMOVE_IMAGE -> completeBottomSheetRemoveImage()
}
}
}
Expand All @@ -139,8 +140,12 @@ class MyPageMoreBottomSheetFragment(private val bottomSheetType: BottomSheetType
setFragmentResult(TAG, bundleOf(TAG to BottomSheetFlag.LOGOUT.value))
}

private fun completeBottomSheetChangeUserImage() {
setFragmentResult(TAG, bundleOf(TAG to BottomSheetFlag.CHANGE_USER_IMAGE.value))
private fun completeBottomSheetChangeImage() {
setFragmentResult(TAG, bundleOf(TAG to BottomSheetFlag.CHANGE_IMAGE.value))
}

private fun completeBottomSheetRemoveImage() {
setFragmentResult(TAG, bundleOf(TAG to BottomSheetFlag.REMOVE_IMAGE.value))
}

private fun handleFlag(flag: BottomSheetFlag) {
Expand All @@ -149,13 +154,22 @@ class MyPageMoreBottomSheetFragment(private val bottomSheetType: BottomSheetType
BottomSheetFlag.CHANGE_PASSWORD -> highlight(binding.changePasswordTV)
BottomSheetFlag.WITHDRAWAL -> highlight(binding.withdrawalTV)
BottomSheetFlag.LOGOUT -> highlight(binding.logoutTV)
BottomSheetFlag.CHANGE_USER_IMAGE -> highlight(binding.changeUserImageTV)

BottomSheetFlag.CHANGE_IMAGE -> highlight(binding.changeImageTV)
BottomSheetFlag.REMOVE_IMAGE -> highlight(binding.removeImageTV)
}
}

private fun highlight(view: TextView) {
val flagTextViewList =
listOf(binding.changePasswordTV, binding.withdrawalTV, binding.changeNickNameTV, binding.logoutTV, binding.changeUserImageTV)
listOf(
binding.changePasswordTV,
binding.withdrawalTV,
binding.changeNickNameTV,
binding.logoutTV,
binding.changeImageTV,
binding.removeImageTV,
)

flagTextViewList.forEach { flagTextView ->
if (view == flagTextView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ class MyPageMoreBottomSheetViewModel @Inject constructor() : BaseViewModel() {
_bottomsheetFlag.value = MyPageMoreBottomSheetFragment.BottomSheetFlag.LOGOUT
}

fun changeUserImage(){
_bottomsheetFlag.value = MyPageMoreBottomSheetFragment.BottomSheetFlag.CHANGE_USER_IMAGE
fun changeImage(){
_bottomsheetFlag.value = MyPageMoreBottomSheetFragment.BottomSheetFlag.CHANGE_IMAGE
}

fun removeImage(){
_bottomsheetFlag.value = MyPageMoreBottomSheetFragment.BottomSheetFlag.REMOVE_IMAGE
}

sealed class MyPageMoreBottomSheetEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,94 @@
android:orientation="vertical"
tools:context=".mypagemore.MyPageMoreBottomSheetFragment">

<TextView
android:id="@+id/changeNickNameTV"
<LinearLayout
android:id="@+id/defaultBottomSheetLL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:gravity="center"
android:onClick="@{()->viewModel.changeNickName()}"
android:padding="10dp"
android:text="@string/changeNickName"
android:textColor="@color/gray3"
android:textSize="18sp" />
android:orientation="vertical">

<TextView
android:id="@+id/changePasswordTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:onClick="@{()->viewModel.changePassword()}"
android:padding="10dp"
android:text="@string/changePassword"
android:textColor="@color/gray3"
android:textSize="18sp" />
<TextView
android:id="@+id/changeNickNameTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:gravity="center"
android:onClick="@{()->viewModel.changeNickName()}"
android:padding="10dp"
android:text="@string/changeNickName"
android:textColor="@color/gray3"
android:textSize="18sp" />

<TextView
android:id="@+id/withdrawalTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:onClick="@{()->viewModel.withdrawal()}"
android:padding="10dp"
android:text="@string/withdrawal"
android:textColor="@color/gray3"
android:textSize="18sp" />
<TextView
android:id="@+id/changePasswordTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:onClick="@{()->viewModel.changePassword()}"
android:padding="10dp"
android:text="@string/changePassword"
android:textColor="@color/gray3"
android:textSize="18sp" />

<TextView
android:id="@+id/logoutTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:onClick="@{()->viewModel.logout()}"
android:padding="10dp"
android:text="@string/logout"
android:textColor="@color/gray3"
android:textSize="18sp" />
<TextView
android:id="@+id/withdrawalTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:onClick="@{()->viewModel.withdrawal()}"
android:padding="10dp"
android:text="@string/withdrawal"
android:textColor="@color/gray3"
android:textSize="18sp" />

<TextView
android:id="@+id/changeUserImageTV"
<TextView
android:id="@+id/logoutTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:onClick="@{()->viewModel.logout()}"
android:padding="10dp"
android:text="@string/logout"
android:textColor="@color/gray3"
android:textSize="18sp" />
</LinearLayout>

<LinearLayout
android:id="@+id/imageBottomSheetLL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:onClick="@{()->viewModel.changeUserImage()}"
android:padding="10dp"
android:text="@string/changeUserImage"
android:visibility="gone"
android:textColor="@color/gray3"
android:textSize="18sp" />
android:orientation="vertical"
android:visibility="gone">

<TextView
android:id="@+id/changeImageTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:onClick="@{()->viewModel.changeImage()}"
android:padding="10dp"
android:text="@string/changeImage"
android:textColor="@color/gray3"
android:textSize="18sp" />

<TextView
android:id="@+id/removeImageTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:onClick="@{()->viewModel.removeImage()}"
android:padding="10dp"
android:text="@string/removeImage"
android:textColor="@color/gray3"
android:textSize="18sp" />
</LinearLayout>

<TextView
android:layout_width="match_parent"
Expand Down
3 changes: 2 additions & 1 deletion feature/mypage/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<string name="changePassword">비밀번호 변경</string>
<string name="withdrawal">회원 탈퇴</string>
<string name="logout">로그아웃</string>
<string name="changeUserImage">내 이미지 변경</string>
<string name="changeImage">이미지 변경</string>
<string name="removeImage">이미지 제거</string>
<string name="confirm">확인</string>
<string name="cancel">취소</string>

Expand Down

0 comments on commit fcbf47f

Please sign in to comment.