From 67de6b4eaea6542abbbaffedee9be15de840b7d8 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Mon, 9 Sep 2024 00:20:07 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT/#226]=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=ED=99=9C=EC=84=B1=ED=99=94=20=EB=A1=9C?= =?UTF-8?q?=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 --- .../feature/mypage/profileedit/ProfileEditState.kt | 1 + .../feature/mypage/profileedit/ProfileEditViewModel.kt | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditState.kt b/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditState.kt index 7048e20a7..41d811f37 100644 --- a/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditState.kt +++ b/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditState.kt @@ -6,6 +6,7 @@ data class ProfileEditState( val profile: String = "", val initialProfile: String = "", val initialView: Boolean = true, + val isModified: Boolean = false, val isButtonValid: Boolean = false, val authType: String = "", val showBottomSheet: Boolean = false diff --git a/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditViewModel.kt b/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditViewModel.kt index 2ed62c6ce..a12f19733 100644 --- a/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditViewModel.kt +++ b/feature/src/main/java/com/terning/feature/mypage/profileedit/ProfileEditViewModel.kt @@ -44,14 +44,19 @@ class ProfileEditViewModel @Inject constructor( fun updateName(name: String) { _state.value = _state.value.copy( name = name, - initialView = false + initialView = false, + isModified = true ) } fun updateProfile(profile: String) { + val isSameAsInitial = profile == _state.value.initialProfile + val isSameAsPrevious = profile == _state.value.profile + _state.value = _state.value.copy( profile = profile, - initialView = profile == _state.value.initialProfile + initialView = !_state.value.isModified && isSameAsInitial, + isModified = if (isSameAsPrevious) _state.value.isModified else !isSameAsInitial ) }