diff --git a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt index c5d490fd..6d5ecac4 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/main/feed/WineyFeedFragment.kt @@ -167,7 +167,7 @@ class WineyFeedFragment : } private fun WineyPopupMenu.showCustomPosition(anchorView: View) { - showAsDropDown(anchorView, -POPUP_MENU_OFFSET, -POPUP_MENU_OFFSET, Gravity.END) + showAsDropDown(anchorView, -POPUP_MENU_POS_OFFSET, -POPUP_MENU_POS_OFFSET, Gravity.END) } private fun showFeedDeleteDialog(feed: WineyFeed) { @@ -437,9 +437,7 @@ class WineyFeedFragment : private const val TAG_GOAL_DIALOG = "NO_GOAL_DIALOG" private const val TAG_FEED_DELETE_DIALOG = "FEED_DELETE_DIALOG" private const val TAG_FEED_REPORT_DIALOG = "FEED_REPORT_DIALOG" - - private const val POPUP_MENU_OFFSET = 65 - + private const val POPUP_MENU_POS_OFFSET = 65 private const val KEY_FEED_ID = "feedId" private const val KEY_FEED_WRITER_ID = "feedWriterId" } diff --git a/app/src/main/java/org/go/sopt/winey/presentation/nickname/NicknameActivity.kt b/app/src/main/java/org/go/sopt/winey/presentation/nickname/NicknameActivity.kt index 5ae59af9..112a0707 100644 --- a/app/src/main/java/org/go/sopt/winey/presentation/nickname/NicknameActivity.kt +++ b/app/src/main/java/org/go/sopt/winey/presentation/nickname/NicknameActivity.kt @@ -135,10 +135,14 @@ class NicknameActivity : BindingActivity(R.layout.activ private fun switchEditTextHint() { lifecycleScope.launch { when (prevScreenName) { - STORY_SCREEN -> binding.etNickname.hint = stringOf(R.string.nickname_default_hint) + STORY_SCREEN -> { + binding.etNickname.hint = stringOf(R.string.nickname_default_hint) + } + MY_PAGE_SCREEN -> { val user = dataStoreRepository.getUserInfo().first() ?: return@launch binding.etNickname.hint = user.nickname + binding.originalNicknameLength = user.nickname.length } } } diff --git a/app/src/main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt b/app/src/main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt index 82d887d4..ab9b8856 100644 --- a/app/src/main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt +++ b/app/src/main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt @@ -132,6 +132,33 @@ fun TextView.setNicknameHelperTextColor(inputUiState: InputUiState) { } } +@BindingAdapter( + "app:prevScreenName", + "app:inputNicknameLength", + "app:originalNicknameLength", + requireAll = false +) +fun TextView.setNicknameCounter( + prevScreenName: String, + inputNicknameLength: Int, + originalNicknameLength: Int +) { + when (prevScreenName) { + STORY_SCREEN -> { + text = context.getString(R.string.nickname_counter, inputNicknameLength) + } + + MY_PAGE_SCREEN -> { + text = if (inputNicknameLength == 0) { + // 입력 값이 비어있을 때는 원래 닉네임의 글자 수 표시 + context.getString(R.string.nickname_counter, originalNicknameLength) + } else { + context.getString(R.string.nickname_counter, inputNicknameLength) + } + } + } +} + @BindingAdapter("switchCloseButtonVisibility") fun ImageView.switchCloseButtonVisibility(prevScreenName: String) { when (prevScreenName) { diff --git a/app/src/main/res/layout/activity_nickname.xml b/app/src/main/res/layout/activity_nickname.xml index 3cce72b4..0ffc2fab 100644 --- a/app/src/main/res/layout/activity_nickname.xml +++ b/app/src/main/res/layout/activity_nickname.xml @@ -9,6 +9,10 @@ name="vm" type="org.go.sopt.winey.presentation.nickname.NicknameViewModel" /> + + @@ -98,9 +102,12 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical|end" android:layout_marginEnd="8dp" - android:text="@{@string/nickname_counter(vm._nickname.length)}" android:textAppearance="@style/TextAppearance.WINEY.body_m_14" - android:textColor="@color/gray_300" /> + android:textColor="@color/gray_300" + app:inputNicknameLength="@{vm._nickname.length}" + app:originalNicknameLength="@{originalNicknameLength}" + app:prevScreenName="@{vm.prevScreenName}" + tools:text="(0/8)" />