-
Notifications
You must be signed in to change notification settings - Fork 0
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
Top-59 feature falling Like UI #82
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.
๊ณ ์ํ์ จ์ต๋๋ค!!
displayMetrics.heightPixels to displayMetrics.widthPixels | ||
} | ||
|
||
fun setBottomSheetDialogSize(activity: Activity, bottomSheetDialog: BottomSheetDialog) { |
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.
setBottomSheetDialogSize
์ธ๋ฐ set๋๋ ๊ฐ์ด ๋งค๊ฐ๋ณ์๋ก ์ ๋ฌ๋๊ฑฐ๋, ํจ์ ์ด๋ฆ์ ํฌํจ๋๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค
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.
๋งค๊ฐ๋ณ์์ bottomSheetDialog
๋ฅผ ๋๊ฒจ์ฃผ๊ณ ์๋๋ฐ ๋ค๋ฅธ ๊ฑธ ์๋ฏธํ๋ ๊ฑธ๊น์?
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.
์ด๋ค Size๋ก Set๋๋์ง ๋ค์ด๋ฐ์ ํฌํจ๋๊ฑฐ๋, ์ฌ์ด์ฆ๋ฅผ ๋งค๊ฐ๋ณ์๋ก ์ ๋ฌํด์ฃผ๋๊ฑด ์ด๋จ๊น ์๊ฐ์ด ๋ค์์์ต๋๋ค!!
@@ -0,0 +1,5 @@ | |||
package tht.feature.like.constant | |||
|
|||
object LikeConstant { |
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.
LikeFragment์์ LikeDetailFragment๋ก ๋์ด๊ฐ๋ argument์ key๊ฐ์ผ๋ก ์ฌ์ฉ๋๋ ๊ฒ ๊ฐ์ต๋๋ค
๋ค์ด๋ฐ์ ํด๋น ์๋ฏธ๋ฅผ ๋ด์ ์ ์๊ฒ ํ๊ฑฐ๋, Key๊ฐ์ ์์น๋ฅผ LikeDetailFragment์ชฝ์ผ๋ก ์ด๋ํ๋๊ฒ๋ ์ข์ ๊ฒ ๊ฐ๋ค๋ ์๊ฐ์ด ๋ค์์ต๋๋ค!!
๊ทธ๋ฆฌ๊ณ LikeDetailFragment์์ ์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋ ํจํด์ ์ฌ์ฉํ๋ฉด Key๊ฐ์ ์บก์ํ ํ ์ ์์ด์ ๋ ์ข์ ๋ฐฉ๋ฒ์ด๋ผ๊ณ ์๊ฐ๋ฉ๋๋ค
class LikeDetailFragment : Fragment() {
companion object {
private const val ARGUMENT_KEY = "key"
fun getInstance(likeModel: LikeModel): LikeDetailFragment {
return LikeDetailFragment().apply {
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, likeModel) }
}
}
}
}
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.
์ข์ ์๊ฒฌ ๊ฐ์ฌํฉ๋๋ค!
์๋๋ ์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋ ํจํด์ ์ฌ์ฉํ๊ณ ์์์ผ๋ ๋ ์ข์ ๋ฐฉ๋ฒ ๊ฐ๋ค์!!
likeUser = arguments?.let { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) | ||
it.getSerializable(LikeConstant.KEY, LikeModel::class.java) | ||
else | ||
it.getSerializable(LikeConstant.KEY) as LikeModel | ||
} ?: LikeModel.getDefaultLikeModel() | ||
if (likeUser.nickname.isEmpty()) dismiss() | ||
else { | ||
binding.apply { | ||
svDetail.clipToOutline = true | ||
tvCategory.text = likeUser.category | ||
tvNickname.text = getString(R.string.nickname, likeUser.nickname, likeUser.age) | ||
tvAddress.text = likeUser.address | ||
tvIntroduction.text = likeUser.introduce | ||
likeUser.idealTypes.forEachIndexed { index, idealType -> | ||
addChip(binding.cgIdealType, idealType.emojiCode, idealType.title, index) | ||
} | ||
likeUser.interests.forEachIndexed { index, interest -> | ||
addChip(binding.cgInterests, interest.emojiCode, interest.title, index) | ||
} | ||
val images = listOf(binding.ivOne, binding.ivTwo, binding.ivThree) | ||
likeUser.profileImgUrl.forEachIndexed { index, url -> | ||
loadImage(images[index], url) | ||
} | ||
} | ||
} |
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.
์ ์๊ฐ์๋ if (likeUser.nickname.isEmpty()) dismiss()
๊ฐ์ ํ๋จ์ ViewModel์์ ์ํํด์ฃผ๋๊ฒ ์ ํฉํ๋ค๊ณ ์๊ฐ๋ฉ๋๋ค
SavedInstanceHandle๋ก ViewModel์์ argument๋ฅผ ์ ๋ฌ๋ฐ๊ณ , ViewModel์์ ๋ฐ์ดํฐ๋ SideEffect๋ฅผ ๋ฐฉ์ถํด์ฃผ๋ ์์ผ๋ก ์ํํ๋ ๋ฐฉ๋ฒ์ ์ด๋ ์ ๊ฐ์??
if (likeUser.nickname.isEmpty()) dismiss() | ||
else { |
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.
์ปจ๋ฒค์
์ if else ๊ตฌ๋ฌธ์ ๋ชจ๋ ์ค๊ดํธ๋ฅผ ๋ถ์ด๊ฑฐ๋, ๋๋ค ๋ถ์ด์ง ์์์ผ ํ๋๊ฒ์ผ๋ก ์๊ณ ์์ต๋๋ค!!
else๋ฌธ์ ๊ธธ์ด๊ฐ ๊ธฐ๋, if๋ฌธ์ ์ค๊ดํธ๋ฅผ ์ถ๊ฐํด์ฃผ๋ ๋ฐฉ์์ผ๋ก ๋ณ๊ฒฝ๋๋ฉด ์ปจ๋ฒค์
์ ์ ํฉํ ๊ฒ ๊ฐ์ต๋๋ค
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 setOnClickListener() { | ||
binding.ivClose.setOnClickListener { | ||
dismiss() |
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.
๊ฐ๋จํ ๊ธฐ๋ฅ์ด๋ผ Activity์์ ์ง์ dismiss๋ฅผ ํธ์ถํด์ฃผ๋๊ฒ๋ ์ข์ง๋ง, ์ผ๊ด์ฑ ์๊ฒ dismiss() ๋ํ ViewModel๋ก Event๋ฅผ ์ ๋ฌํ๊ณ ViewModel์์ State๋ SideEffect๋ฅผ ๋ฐฉ์ถํด์ฃผ๋ ๋ฐฉ์์ ๋์๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค
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.
๋ต dismiss()
์ ๊ฐ์ ํ์? ๋ค์ SideEffect๋ฅผ ๋ฐฉ์ถํด์ฃผ๋ ๋ฐฉ์์ผ๋ก ๋ชจ๋ ์์ ํ๊ฒ ์ต๋๋ค!
override val _uiStateFlow: MutableStateFlow<LikeUiState> = | ||
MutableStateFlow(LikeUiState.Empty) | ||
|
||
private val likeItems = MutableStateFlow<LinkedHashMap<String, List<LikeModel>>>(MockData.data) |
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.
<LinkedHashMap<String, List<LikeModel>>>
๋ ์ ๊ฑฐ๋์ด๋ ๋ ๊ฒ ๊ฐ์ต๋๋ค!
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.
Notification๊ฐ์ด Toolbar์ ๊ณตํต์ ์ผ๋ก ์ฌ์ฉ๋๋ ์์ด์ฝ์ core-ui์ ๋ฐฐ์นํ๋ฉด ์ฌ์ฌ์ฉ์ด ๊ฐ๋ฅํ ๊ฒ ๊ฐ์๋ฐ... ๊ณ ๋ฏผ์ด ๋๋ค์..
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.
๊ทธ๋ ์ฃ ์๋ฌด๋๋ ์ฌ๊ธฐ์ ๊ธฐ ์ฐ์ด๋๊น ํ์ดํ๋ง ๋ฐ๊ฟ ์ ์๋๋ก core-ui์ ๋ฐฐ์นํ๋ฉด ์ข์ ๊ฒ ๊ฐ๊ธด ํฉ๋๋ค..
import tht.feature.like.like.LikeModel | ||
|
||
object MockData { | ||
val data = LinkedHashMap<String, List<LikeModel>>().apply { |
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.
์ 3๋ช ๋ฟ์ธ๊ฐ์?????
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.
ใ ใ .. ๊ท์ฐฎ์ ์ด์..
) | ||
) | ||
|
||
else -> LikeContentViewHolder( |
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.
ViewHolder์ ์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋๋ฅผ ์ถ๊ฐํด์ค๋ค๋ฉด, ๋ฉํฐ ๋ทฐ ํ์ ๋ฆฌ์ฌ์ดํด๋ฌ ๋ทฐ์ Adapter์ onCreateViewHolder์ ๊ฐ๋ ์ฑ์ด ์ข์ ์ง ๊ฒ ๊ฐ์ต๋๋ค!!
companion object {
fun getInstance(
parent: ViewGroup
) : LikeContentViewHolder {
return LikeContentViewHolder(
ItemContentBinding.inflate(
LayoutInflater.from(
parent.context
), parent, false
)
)
}
}
์์ ๊ฐ์ด ํฉํ ๋ฆฌ ๋ฉ์๋๋ฅผ ์ ์ธํด ๋๋ค๋ฉด
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return when (viewType) {
HEADER -> LikeHeaderViewHolder.getInstance(parent)
else -> LikeContentViewHolder.getInstance(parent)
}
}
onCreateViewHolder๊ฐ ์์ ๊ฐ์ด ๊ฐ๋ ์ฑ์ด ์ข์์ง๋ ํจ๊ณผ๊ฐ ์์ด์ ์ฌ์ฉ์ ์ถ์ฒ๋๋ฆฝ๋๋ค!
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.
์ญ์ ํฉํ ๋ ๋ฉ์๋ ํจํด์ ์ฅ์ ์ ๊ฐ๋ ์ฑ์ด ์ต๊ณ ์ธ ๊ฒ ๊ฐ๋ค์..! ๊ฐ์ฌํฉ๋๋ค ใ ใ
override fun getChangePayload(oldItem: LikeItem, newItem: LikeItem): Any? { | ||
if (oldItem is LikeItem.Content && newItem is LikeItem.Content) { | ||
if (oldItem.item.isNew != newItem.item.isNew) | ||
return newItem.item.isNew | ||
} | ||
|
||
return super.getChangePayload(oldItem, newItem) |
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.
๐
KakaoTalk_Video_2023-06-19-11-52-36.mp4์กฐ๊ธ ๊น๋ฐ์ด๋ ์ฆ์์ด์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค |
Explain this Pull Request ๐
What has changed? ๐ค
Screenshot ๐ธ
Test Checklist ๐ฉ