Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mod] 마이페이지 / 닉네임 수정 뷰에서 원래 닉네임의 글자수 표시 #187

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,14 @@ class NicknameActivity : BindingActivity<ActivityNicknameBinding>(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
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/java/org/go/sopt/winey/util/binding/BindingAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,33 @@ fun TextView.setNicknameHelperTextColor(inputUiState: InputUiState) {
}
}

@BindingAdapter(
"app:prevScreenName",
"app:inputNicknameLength",
"app:originalNicknameLength",
requireAll = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 속성 알아갑니다 👍

)
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) {
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/res/layout/activity_nickname.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
name="vm"
type="org.go.sopt.winey.presentation.nickname.NicknameViewModel" />

<variable
name="originalNicknameLength"
type="Integer" />

<import type="android.view.View" />

<import type="org.go.sopt.winey.util.view.InputUiState" />
Expand Down Expand Up @@ -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)" />

</FrameLayout>

Expand Down