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

[FIX/#257] 유빈 담당 뷰 / QA 이슈 대응 #258

Merged
merged 6 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ class DashBoardActivity :
checkIsFirstEntered()
setTabLayout()
setViewPager()
setTravelerName()
initSettingBtnClickListener()
initCreateTripBtnClickListener()
initOnBackPressedListener(binding.root)
}

override fun onResume() {
super.onResume()

setTravelerName()
}

Comment on lines +39 to +44
Copy link
Contributor

Choose a reason for hiding this comment

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

굿뜨~~

private fun checkIsFirstEntered() {
if (intent.getBooleanExtra(IS_FIRST_ENTERED, false)) {
val tripId = intent.getLongExtra(TRIP_ID, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class ChangeTagActivity :
private var _adapter: ChangeTagAdapter? = null
private val adapter get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) }

private val preferenceAnswers = MutableList(5) { 0 }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initAdapter()
setTripId()
initPreferenceList()
observeIsButtonValid()
initItemDecoration()
initChangeClickListener()
initBackClickListener()
Expand All @@ -46,6 +46,10 @@ class ChangeTagActivity :
binding.rvChangeTag.adapter = adapter
}

private fun setTripId() {
tagViewModel.tripId = intent.getLongExtra(TRIP_ID, 0)
}

private fun initPreferenceList() {
if (intent != null) {
val styleA = intent.getIntExtra(STYLE_A, 0)
Expand All @@ -64,34 +68,28 @@ class ChangeTagActivity :
)
)

preferenceAnswers[0] = styleA
preferenceAnswers[1] = styleB
preferenceAnswers[2] = styleC
preferenceAnswers[3] = styleD
preferenceAnswers[4] = styleE
tagViewModel.setDefaultPreference(styleA, styleB, styleC, styleD, styleE)
}
}

private fun preferenceTagClickListener(item: ProfilePreferenceData, checkedIndex: Int) {
preferenceAnswers[item.number.toInt() - 1] = checkedIndex
setButtonValid()
sendPreferenceInfo()
}

private fun setButtonValid() {
binding.btnChangeStart.isEnabled = true
binding.btnChangeStart.setTextColor(
colorOf(R.color.white_000)
)
tagViewModel.checkIsPreferenceChange(item.number.toInt(), checkedIndex)
}

private fun sendPreferenceInfo() {
tagViewModel.tripId = intent.getLongExtra(TRIP_ID, 0)
tagViewModel.styleA.value = preferenceAnswers[0]
tagViewModel.styleB.value = preferenceAnswers[1]
tagViewModel.styleC.value = preferenceAnswers[2]
tagViewModel.styleD.value = preferenceAnswers[3]
tagViewModel.styleE.value = preferenceAnswers[4]
private fun observeIsButtonValid() {
tagViewModel.isButtonValid.flowWithLifecycle(lifecycle).onEach { state ->
if (state) {
binding.btnChangeStart.isEnabled = true
binding.btnChangeStart.setTextColor(
colorOf(R.color.white_000)
)
} else {
binding.btnChangeStart.isEnabled = false
binding.btnChangeStart.setTextColor(
colorOf(R.color.gray_200)
)
}
}.launchIn(lifecycleScope)
}

private fun initItemDecoration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import com.going.domain.entity.request.PreferenceChangeRequestModel
import com.going.domain.repository.ProfileRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand All @@ -20,13 +22,80 @@ class ChangeTagViewModel @Inject constructor(
private val _preferencePatchState = MutableSharedFlow<Boolean>()
val preferencePatchState: SharedFlow<Boolean> = _preferencePatchState

private val _isButtonValid = MutableStateFlow(false)
val isButtonValid: StateFlow<Boolean> = _isButtonValid

var tripId: Long = 0

val styleA = MutableLiveData(0)
val styleB = MutableLiveData(0)
val styleC = MutableLiveData(0)
val styleD = MutableLiveData(0)
val styleE = MutableLiveData(0)
private val defaultStyleA = MutableLiveData(0)
private val defaultStyleB = MutableLiveData(0)
private val defaultStyleC = MutableLiveData(0)
private val defaultStyleD = MutableLiveData(0)
private val defaultStyleE = MutableLiveData(0)

private val styleA = MutableLiveData(0)
private val styleB = MutableLiveData(0)
private val styleC = MutableLiveData(0)
private val styleD = MutableLiveData(0)
private val styleE = MutableLiveData(0)
Copy link
Member

Choose a reason for hiding this comment

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

혹시 이걸 전부 다 observe 혹은 데바에 쓰고있나요?
그게 아니라면 mutableLiveData일 필요는 없을 것 같습니다!!
단순히 값을 저장하기 위함이라면 val 혹은 var로도 충분합니당 :)

Copy link
Member Author

Choose a reason for hiding this comment

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

아하! 그렇네요!! 수정했습니다~!!


private var isStyleAChanged: Boolean = false
private var isStyleBChanged: Boolean = false
private var isStyleCChanged: Boolean = false
private var isStyleDChanged: Boolean = false
private var isStyleEChanged: Boolean = false

fun setDefaultPreference(styleA: Int, styleB: Int, styleC: Int, styleD: Int, styleE: Int) {
defaultStyleA.value = styleA
this.styleA.value = styleA

defaultStyleB.value = styleB
this.styleB.value = styleB

defaultStyleC.value = styleC
this.styleC.value = styleC

defaultStyleD.value = styleD
this.styleD.value = styleD

defaultStyleE.value = styleE
this.styleE.value = styleE
}

fun checkIsPreferenceChange(number: Int, index: Int) {
when (number) {
1 -> {
styleA.value = index
isStyleAChanged = index != defaultStyleA.value
Copy link
Contributor

Choose a reason for hiding this comment

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

굿굿!

}

2 -> {
styleB.value = index
isStyleBChanged = index != defaultStyleB.value
}

3 -> {
styleC.value = index
isStyleCChanged = index != defaultStyleC.value
}

4 -> {
styleD.value = index
isStyleDChanged = index != defaultStyleD.value
}

5 -> {
styleE.value = index
isStyleEChanged = index != defaultStyleE.value
}
}
checkIsButtonValid()
}

private fun checkIsButtonValid() {
_isButtonValid.value =
isStyleAChanged || isStyleBChanged || isStyleCChanged || isStyleDChanged || isStyleEChanged
}

fun patchPreferenceTagToServer() {
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.core.view.isVisible
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.going.domain.entity.response.CheckFriendsModel
import com.going.domain.entity.response.TripParticipantModel
import com.going.presentation.R
import com.going.presentation.databinding.ActivityCheckFriendsBinding
import com.going.presentation.profile.participant.ParticipantProfileActivity
Expand Down Expand Up @@ -89,22 +88,16 @@ class CheckFriendsActivity :
}

private fun setFriendsData(data: CheckFriendsModel) {
adapter.submitList(data.participants)

setEmptyView(data.participants)
setProgressBarStatus(data.styles.map { it.rates })
setCountStatus(data.styles.map { it.counts })
setResultTextColor(data.bestPrefer)
}

private fun setEmptyView(participants: List<TripParticipantModel>) {
if (participants.size == 1) {
with(binding) {
svCheckFriends.isVisible = false
layoutCheckFriendsEmpty.isVisible = true
}
if (data.participants.size == 1) {
binding.layoutCheckFriendsEmpty.isVisible = true
setInviteCode()
initInviteBtnListener()
} else {
binding.svCheckFriends.isVisible = true
adapter.submitList(data.participants)
setProgressBarStatus(data.styles.map { it.rates })
setCountStatus(data.styles.map { it.counts })
setResultTextColor(data.bestPrefer)
}
}

Expand Down
2 changes: 0 additions & 2 deletions presentation/src/main/res/layout/activity_change_tag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/layer_list_preference_tag_gray100_line"
android:backgroundTint="@color/white_000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
Expand Down Expand Up @@ -77,7 +76,6 @@
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="22dp"
android:background="@drawable/sel_rounded_corner_button"
android:enabled="false"
android:outlineProvider="none"
android:text="@string/change_tag_btn_change"
android:textColor="@color/gray_200"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
android:id="@+id/sv_check_friends"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/layer_list_preference_tag_gray100_line"
android:backgroundTint="@color/white_000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white_000"
android:background="@color/gray_50"
Copy link
Contributor

Choose a reason for hiding this comment

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

역시 매의 눈 ....들이시군요

tools:context=".entertrip.invitetrip.preference.FinishPreferenceActivity">

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down
Loading