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 ) }