-
Notifications
You must be signed in to change notification settings - Fork 1
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
UI 개선, 바텀 내비게이션 애니메이션 적용 #282
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다~
|
||
private fun raiseBottomNav() { | ||
ObjectAnimator.ofFloat(binding.bottomNav, "translationY", 0f).apply { | ||
duration = 700 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
700이 여러군데에서 쓰이는 것 같은데 상수화 하는 것 어떤가용??
private fun hideBottomNav() { | ||
binding.bottomNav.visibility = View.GONE | ||
val period = 700L | ||
takeDownBottomNav(period) | ||
|
||
lifecycleScope.launch { | ||
delay(period) | ||
binding.bottomNav.visibility = View.GONE | ||
} | ||
} | ||
|
||
private fun showBottomNav() { | ||
raiseBottomNav() | ||
|
||
binding.bottomNav.visibility = View.VISIBLE | ||
} | ||
|
||
private fun takeDownBottomNav(period: Long) { | ||
val height = binding.bottomNav.height.toFloat() | ||
ObjectAnimator.ofFloat(binding.bottomNav, "translationY", height).apply { | ||
duration = period | ||
start() | ||
} | ||
} | ||
|
||
private fun raiseBottomNav() { | ||
ObjectAnimator.ofFloat(binding.bottomNav, "translationY", 0f).apply { | ||
duration = 700 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
showBottomNav() - raiseBottomNav() 가 함수명이 둘다 비슷한 의미 여서 함수가 어떤의미를 뜻하는지 정확하게 알기 어려운 것 같아요! raiseBottomNav 를 애니메이션 관련된 함수명으로 바꾸는 방법도 있을 것 같고, 두 함수를 합치는 것도 좋을 것 같아요. (hideBottomNav() - takeDownBottomNav 도 마찬가지입니다!) 그리고 scope 함수 apply를 적절하게 활용해보는 것도 좋을 것 같습니당
ex)
private fun showBottomNav() {
val slideUpAnimation = ObjectAnimator.ofFloat(binding.bottomNav, "translationY", 0f).apply {
duration = BOTTOM_NAV_ANIMATION_DURATION
}
slideUpAnimation.start()
binding.bottomNav.visibility = View.VISIBLE
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
하나로 합칠게용
lifecycleScope.launch { | ||
delay(period) | ||
binding.bottomNav.visibility = View.GONE | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delay 를 하드 코딩하는 것보다는 animator 에 doOnEnd 함수를 이용해보는 것도 좋을 것 같아용!
ex)
val slideDown = ObjectAnimator.ofFloat(binding.bottomNav, "translationY", binding.bottomNav.height.toFloat()).apply {
duration = BOTTOM_NAV_ANIMATION_DURATION
doOnEnd { binding.bottomNav.visibility = View.GONE }
}
slideDown.start()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호 저런 함수가 있었군요!
fun Context.fromDpToPx(dp: Float): Float { | ||
val density = resources.displayMetrics.density | ||
return dp * density | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 언제 쓰는 함수인지 궁금하네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dp를 px로 변환하려고 만들었는데, view에서 사이즈를 얻을 수 있어서 안 쓰게 됐네요. 없애버리겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨어용~~~덕분에 네비게이션 보는 재미가 생겼군요 🙂
Issue
Overview
Screenshot
KakaoTalk_20231206_004707408.mp4