-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEAT/#350] Profile / 탈퇴 사유 뷰 구현
- Loading branch information
Showing
53 changed files
with
553 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
app/src/main/java/com/el/yello/presentation/main/profile/manage/ProfileQuitReasonActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.el.yello.presentation.main.profile.manage | ||
|
||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.el.yello.R | ||
import com.el.yello.databinding.ActivityProfileQuitReasonBinding | ||
import com.el.yello.presentation.main.profile.ProfileViewModel | ||
import com.example.ui.base.BindingActivity | ||
import com.example.ui.context.colorOf | ||
import com.example.ui.view.setOnSingleClickListener | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class ProfileQuitReasonActivity : | ||
BindingActivity<ActivityProfileQuitReasonBinding>(R.layout.activity_profile_quit_reason) { | ||
private lateinit var quitReasonList: List<String> | ||
private val viewModel by viewModels<ProfileViewModel>() | ||
private var clickedItemPosition: Int = RecyclerView.NO_POSITION | ||
private var isItemClicked: Boolean = false | ||
private var profileQuitDialog: ProfileQuitDialog? = null | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding.vm = viewModel | ||
initQuitReasonAdapter() | ||
initBackBtnListener() | ||
initInviteDialogBtnListener() | ||
} | ||
|
||
private fun initQuitReasonAdapter() { | ||
viewModel.addQuitReasonList(this) | ||
quitReasonList = viewModel.quitReasonData.value ?: emptyList() | ||
val adapter = ProfileQuitReasonAdapter( | ||
storeQuitReason = ::storeQuitReason, | ||
setEtcText = ::setEtcText, | ||
) { position, clicked -> | ||
clickedItemPosition = position | ||
isItemClicked = clicked | ||
if (isItemClicked) { | ||
if (clickedItemPosition == 7) { | ||
nonClickedButtonUI() | ||
} else { | ||
clickedButtonUI() | ||
} | ||
} | ||
} | ||
binding.rvQuitReason.adapter = adapter | ||
adapter.submitList(ArrayList(quitReasonList)) | ||
} | ||
|
||
private fun initInviteDialogBtnListener() { | ||
binding.btnProfileQuitReasonDone.setOnSingleClickListener { | ||
profileQuitDialog = ProfileQuitDialog() | ||
profileQuitDialog?.show(supportFragmentManager, QUIT_DIALOG) | ||
} | ||
} | ||
|
||
private fun initBackBtnListener() { | ||
binding.btnProfileQuitReasonBack.setOnSingleClickListener { finish() } | ||
} | ||
|
||
private fun clickedButtonUI() { | ||
with(binding.btnProfileQuitReasonDone) { | ||
setBackgroundResource(R.drawable.shape_black_fill_grayscales700_line_100_rect) | ||
setTextColor(colorOf(R.color.semantic_red_500)) | ||
isEnabled = true | ||
} | ||
} | ||
|
||
private fun nonClickedButtonUI() { | ||
with(binding.btnProfileQuitReasonDone) { | ||
setBackgroundResource(R.drawable.shape_black_fill_grayscales600_line_100_rect) | ||
setTextColor(colorOf(R.color.grayscales_600)) | ||
isEnabled = false | ||
} | ||
} | ||
|
||
private fun storeQuitReason(reason: String) { | ||
viewModel.setQuitReason(reason) | ||
} | ||
|
||
private fun setEtcText(etc: String) { | ||
viewModel.setEtcText(etc) | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
profileQuitDialog?.dismiss() | ||
} | ||
|
||
private companion object { | ||
const val QUIT_DIALOG = "quitDialog" | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
app/src/main/java/com/el/yello/presentation/main/profile/manage/ProfileQuitReasonAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.el.yello.presentation.main.profile.manage | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.widget.addTextChangedListener | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.el.yello.R | ||
import com.el.yello.databinding.ItemProfileQuitReasonBinding | ||
import com.example.ui.view.ItemDiffCallback | ||
import com.example.ui.view.setOnSingleClickListener | ||
|
||
class ProfileQuitReasonAdapter( | ||
private val storeQuitReason: (String) -> Unit, | ||
private val setEtcText: (String) -> Unit, | ||
private val onItemClickListener: (Int, Boolean) -> Unit, | ||
) : ListAdapter<String, ProfileQuitReasonAdapter.QuitReasonViewHolder>(diffUtil) { | ||
private var selectedItemPosition: Int = RecyclerView.NO_POSITION | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QuitReasonViewHolder { | ||
return QuitReasonViewHolder( | ||
ItemProfileQuitReasonBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false, | ||
), | ||
storeQuitReason, | ||
setEtcText, | ||
this::onItemClicked, | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: QuitReasonViewHolder, position: Int) { | ||
holder.bind(getItem(position), position == selectedItemPosition) | ||
} | ||
|
||
private fun onItemClicked(position: Int) { | ||
if (selectedItemPosition != RecyclerView.NO_POSITION) { | ||
notifyItemChanged(selectedItemPosition) | ||
} | ||
selectedItemPosition = position | ||
notifyItemChanged(position) | ||
storeQuitReason(getItem(position)) | ||
onItemClickListener(position, true) | ||
} | ||
|
||
class QuitReasonViewHolder( | ||
private val binding: ItemProfileQuitReasonBinding, | ||
private val storeQuitReason: (String) -> Unit, | ||
private val setEtcText: (String) -> Unit, | ||
private val onItemClicked: (Int) -> Unit, | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(reason: String, isItemSelected: Boolean) { | ||
binding.reason = reason | ||
binding.root.setOnSingleClickListener { | ||
onItemClicked(absoluteAdapterPosition) | ||
} | ||
binding.etQuitEtc.addTextChangedListener { | ||
setEtcText(binding.etQuitEtc.text.toString()) | ||
} | ||
if (isItemSelected) { | ||
with(binding) { | ||
ivQuitReasonCheckpoint.setBackgroundResource(R.drawable.ic_profile_quit_reason_check) | ||
cvQuitReasonList.setBackgroundResource(R.drawable.shape_black_fill_white_line_8_rect) | ||
etQuitEtc.visibility = if (absoluteAdapterPosition == 7) View.VISIBLE else View.GONE | ||
} | ||
storeQuitReason(reason) | ||
} else { | ||
with(binding) { | ||
ivQuitReasonCheckpoint.setBackgroundResource(R.drawable.ic_profile_quit_reason_uncheck) | ||
cvQuitReasonList.setBackgroundResource(R.drawable.shape_grayscales900_fill_8_rect) | ||
etQuitEtc.visibility = View.GONE | ||
} | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private val diffUtil = ItemDiffCallback<String>( | ||
onItemsTheSame = { old, new -> old == new }, | ||
onContentsTheSame = { old, new -> old == new }, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nboarding/activity/OnBoardingViewModel.kt → ...ntation/onboarding/OnBoardingViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.