Skip to content

Commit

Permalink
Merge pull request #187 from team-winey/feature/mod-nickname-hint-cou…
Browse files Browse the repository at this point in the history
…nter

[mod] λ§ˆμ΄νŽ˜μ΄μ§€ / λ‹‰λ„€μž„ μˆ˜μ • λ·°μ—μ„œ μ›λž˜ λ‹‰λ„€μž„μ˜ κΈ€μžμˆ˜ ν‘œμ‹œ
  • Loading branch information
leeeha authored Sep 5, 2023
2 parents 80965eb + 076487c commit 5df067b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
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
)
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

0 comments on commit 5df067b

Please sign in to comment.