From 9d3bf28477ef21c2d58b3935e06d8fb7c48dbcba Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 13 Mar 2024 23:09:08 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[FIX/#257]=20header=20underline=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/res/layout/activity_change_tag.xml | 1 - presentation/src/main/res/layout/activity_enter_preference.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/presentation/src/main/res/layout/activity_change_tag.xml b/presentation/src/main/res/layout/activity_change_tag.xml index eba0d1d2..ec146d3c 100644 --- a/presentation/src/main/res/layout/activity_change_tag.xml +++ b/presentation/src/main/res/layout/activity_change_tag.xml @@ -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"> diff --git a/presentation/src/main/res/layout/activity_enter_preference.xml b/presentation/src/main/res/layout/activity_enter_preference.xml index 5b02ad06..341a7cac 100644 --- a/presentation/src/main/res/layout/activity_enter_preference.xml +++ b/presentation/src/main/res/layout/activity_enter_preference.xml @@ -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"> From bfa5ca1abedd25ebcbb0f8463b3c3af3ed0b1f09 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 13 Mar 2024 23:16:02 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[FIX/#257]=20=EB=B2=84=ED=8A=BC=20=EC=83=89?= =?UTF-8?q?=EC=83=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/res/layout/activity_finish_preference.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presentation/src/main/res/layout/activity_finish_preference.xml b/presentation/src/main/res/layout/activity_finish_preference.xml index 9db8388d..9abb9d59 100644 --- a/presentation/src/main/res/layout/activity_finish_preference.xml +++ b/presentation/src/main/res/layout/activity_finish_preference.xml @@ -10,7 +10,7 @@ Date: Wed, 13 Mar 2024 23:29:18 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[FIX/#257]=20=EC=97=A0=ED=8B=B0=EB=B7=B0=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=8B=9C=EC=A0=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkfriends/CheckFriendsActivity.kt | 23 +++++++------------ .../res/layout/activity_check_friends.xml | 1 + 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/presentation/src/main/java/com/going/presentation/todo/ourtodo/checkfriends/CheckFriendsActivity.kt b/presentation/src/main/java/com/going/presentation/todo/ourtodo/checkfriends/CheckFriendsActivity.kt index eede90a6..9cdad3a8 100644 --- a/presentation/src/main/java/com/going/presentation/todo/ourtodo/checkfriends/CheckFriendsActivity.kt +++ b/presentation/src/main/java/com/going/presentation/todo/ourtodo/checkfriends/CheckFriendsActivity.kt @@ -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 @@ -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) { - 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) } } diff --git a/presentation/src/main/res/layout/activity_check_friends.xml b/presentation/src/main/res/layout/activity_check_friends.xml index 01a66bd3..c7e87594 100644 --- a/presentation/src/main/res/layout/activity_check_friends.xml +++ b/presentation/src/main/res/layout/activity_check_friends.xml @@ -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" From ab763c738ee297c0245368737369a8aad7cee70c Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Thu, 14 Mar 2024 00:50:45 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[FIX/#257]=20=EC=B7=A8=ED=96=A5=20=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=20=EB=B2=84=ED=8A=BC=20=ED=99=9C=EC=84=B1=ED=99=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profiletag/changetag/ChangeTagActivity.kt | 46 ++++++----- .../changetag/ChangeTagViewModel.kt | 79 +++++++++++++++++-- .../main/res/layout/activity_change_tag.xml | 1 - 3 files changed, 96 insertions(+), 30 deletions(-) diff --git a/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagActivity.kt b/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagActivity.kt index e2589c74..a1e31ede 100644 --- a/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagActivity.kt +++ b/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagActivity.kt @@ -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() @@ -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) @@ -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() { diff --git a/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagViewModel.kt b/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagViewModel.kt index c3ba95c6..5eb45e66 100644 --- a/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagViewModel.kt @@ -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 @@ -20,13 +22,80 @@ class ChangeTagViewModel @Inject constructor( private val _preferencePatchState = MutableSharedFlow() val preferencePatchState: SharedFlow = _preferencePatchState + private val _isButtonValid = MutableStateFlow(false) + val isButtonValid: StateFlow = _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) + + 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 + } + + 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 { diff --git a/presentation/src/main/res/layout/activity_change_tag.xml b/presentation/src/main/res/layout/activity_change_tag.xml index ec146d3c..e193b149 100644 --- a/presentation/src/main/res/layout/activity_change_tag.xml +++ b/presentation/src/main/res/layout/activity_change_tag.xml @@ -76,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" From 5a2a836f69688ced7b5e643275036cad80fc99bd Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Thu, 14 Mar 2024 00:57:28 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[FIX/#257]=20=EB=8C=80=EC=8B=9C=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=20=EB=B7=B0=20=EB=8B=89=EB=84=A4=EC=9E=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/going/presentation/dashboard/DashBoardActivity.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt b/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt index 9395441b..a6ca2e91 100644 --- a/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt +++ b/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt @@ -31,12 +31,17 @@ class DashBoardActivity : checkIsFirstEntered() setTabLayout() setViewPager() - setTravelerName() initSettingBtnClickListener() initCreateTripBtnClickListener() initOnBackPressedListener(binding.root) } + override fun onResume() { + super.onResume() + + setTravelerName() + } + private fun checkIsFirstEntered() { if (intent.getBooleanExtra(IS_FIRST_ENTERED, false)) { val tripId = intent.getLongExtra(TRIP_ID, 0) From 13917ca7933d13d08f52b4b05ec48bf2a56b4b38 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Thu, 14 Mar 2024 01:22:43 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[FIX/#257]=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../changetag/ChangeTagViewModel.kt | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagViewModel.kt b/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagViewModel.kt index 5eb45e66..053bcd43 100644 --- a/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/changetag/ChangeTagViewModel.kt @@ -1,6 +1,5 @@ package com.going.presentation.profile.participant.profiletag.changetag -import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.going.domain.entity.ProfilePreferenceData @@ -27,17 +26,17 @@ class ChangeTagViewModel @Inject constructor( var tripId: Long = 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 var defaultStyleA: Int? = 0 + private var defaultStyleB: Int? = 0 + private var defaultStyleC: Int? = 0 + private var defaultStyleD: Int? = 0 + private var defaultStyleE: Int? = 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) + private var styleA: Int? = 0 + private var styleB: Int? = 0 + private var styleC: Int? = 0 + private var styleD: Int? = 0 + private var styleE: Int? = 0 private var isStyleAChanged: Boolean = false private var isStyleBChanged: Boolean = false @@ -46,47 +45,47 @@ class ChangeTagViewModel @Inject constructor( private var isStyleEChanged: Boolean = false fun setDefaultPreference(styleA: Int, styleB: Int, styleC: Int, styleD: Int, styleE: Int) { - defaultStyleA.value = styleA - this.styleA.value = styleA + defaultStyleA = styleA + this.styleA = styleA - defaultStyleB.value = styleB - this.styleB.value = styleB + defaultStyleB = styleB + this.styleB = styleB - defaultStyleC.value = styleC - this.styleC.value = styleC + defaultStyleC = styleC + this.styleC = styleC - defaultStyleD.value = styleD - this.styleD.value = styleD + defaultStyleD = styleD + this.styleD = styleD - defaultStyleE.value = styleE - this.styleE.value = styleE + defaultStyleE = styleE + this.styleE = styleE } fun checkIsPreferenceChange(number: Int, index: Int) { when (number) { 1 -> { - styleA.value = index - isStyleAChanged = index != defaultStyleA.value + styleA = index + isStyleAChanged = index != defaultStyleA } 2 -> { - styleB.value = index - isStyleBChanged = index != defaultStyleB.value + styleB = index + isStyleBChanged = index != defaultStyleB } 3 -> { - styleC.value = index - isStyleCChanged = index != defaultStyleC.value + styleC = index + isStyleCChanged = index != defaultStyleC } 4 -> { - styleD.value = index - isStyleDChanged = index != defaultStyleD.value + styleD = index + isStyleDChanged = index != defaultStyleD } 5 -> { - styleE.value = index - isStyleEChanged = index != defaultStyleE.value + styleE = index + isStyleEChanged = index != defaultStyleE } } checkIsButtonValid() @@ -102,11 +101,11 @@ class ChangeTagViewModel @Inject constructor( profileRepository.patchPreferenceTag( tripId, PreferenceChangeRequestModel( - styleA.value ?: 0, - styleB.value ?: 0, - styleC.value ?: 0, - styleD.value ?: 0, - styleE.value ?: 0 + styleA ?: 0, + styleB ?: 0, + styleC ?: 0, + styleD ?: 0, + styleE ?: 0 ) ) .onSuccess {