From 076487c23424069bf3bea3395d45c87f52cef883 Mon Sep 17 00:00:00 2001 From: leeeha Date: Tue, 5 Sep 2023 13:00:28 +0900 Subject: [PATCH] =?UTF-8?q?[mod]=20#186=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8B=89=EB=84=A4=EC=9E=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B7=B0=EC=97=90=EC=84=9C=20=EC=9B=90=EB=9E=98=20?= =?UTF-8?q?=EB=8B=89=EB=84=A4=EC=9E=84=EC=9D=98=20=EA=B8=80=EC=9E=90?= =?UTF-8?q?=EC=88=98=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/feed/WineyFeedFragment.kt | 6 ++--- .../presentation/nickname/NicknameActivity.kt | 6 ++++- .../sopt/winey/util/binding/BindingAdapter.kt | 27 +++++++++++++++++++ app/src/main/res/layout/activity_nickname.xml | 11 ++++++-- 4 files changed, 43 insertions(+), 7 deletions(-) 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)" />