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

Top-59 feature falling Like UI #82

Merged
merged 36 commits into from
Jan 12, 2024
Merged

Top-59 feature falling Like UI #82

merged 36 commits into from
Jan 12, 2024

Conversation

kwangddang
Copy link
Collaborator

Explain this Pull Request ๐Ÿ™

  • Like UI ๊ตฌํ˜„

What has changed? ๐Ÿค”

  • ๋ณ€๊ฒฝ ์‚ฌํ•ญ
    • AlertDialog๊ฐ€ ๋‹ค์–‘ํ•œ ํ˜•ํƒœ๋กœ ์—ฌ๋Ÿฌ ๊ณณ์—์„œ ์žฌํ™œ์šฉ ๋˜์–ด์„œ core-ui์— ๋”ฐ๋กœ ์ •์˜ ํ›„ ๊ธฐ์กด์— ๊ตฌํ˜„๋˜์–ด ์žˆ๋˜ ๊ฒƒ๋“ค ๋ณ€๊ฒฝ
    • ํˆฌ๋ช…ํ•œ BottomSheet์„ ์ด์šฉํ•˜์—ฌ LikeDetail ํ™”๋ฉด ๊ตฌํ˜„
    • RecyclerView payload ์ ์šฉ
    • RecyclerView๋Š” ์ฃผ์ œ์™€, ์ฃผ์ œ๋ฅผ ์„ ํƒํ•œ ์‚ฌ๋žŒ๋“ค ๋ชฉ๋ก์„ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•˜๋ฏ€๋กœ HashMap ํ˜•ํƒœ๋กœ ๊ด€๋ฆฌ
    • ์ข‹์•„์š”๊ฐ€ ํ•˜๋‚˜๋„ ์—†์„ ์‹œ ๋ณด์—ฌ์ค„ Empty ํ™”๋ฉด ๊ตฌํ˜„

Screenshot ๐Ÿ“ธ

Test Checklist ๐Ÿšฉ

@kwangddang kwangddang self-assigned this Jun 18, 2023
Copy link
Member

@cwj-c cwj-c left a 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) {
Copy link
Member

Choose a reason for hiding this comment

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

setBottomSheetDialogSize ์ธ๋ฐ set๋˜๋Š” ๊ฐ’์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ „๋‹ฌ๋˜๊ฑฐ๋‚˜, ํ•จ์ˆ˜ ์ด๋ฆ„์— ํฌํ•จ๋˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

๋งค๊ฐœ๋ณ€์ˆ˜์— bottomSheetDialog๋ฅผ ๋„˜๊ฒจ์ฃผ๊ณ  ์žˆ๋Š”๋ฐ ๋‹ค๋ฅธ ๊ฑธ ์˜๋ฏธํ•˜๋Š” ๊ฑธ๊นŒ์š”?

Copy link
Member

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 {
Copy link
Member

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) }
            }
        }
    }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

์ข‹์€ ์˜๊ฒฌ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!
์›๋ž˜๋„ ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ํŒจํ„ด์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์—ˆ์œผ๋‹ˆ ๋” ์ข‹์€ ๋ฐฉ๋ฒ• ๊ฐ™๋„ค์š”!!

Comment on lines 68 to 93
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)
}
}
}
Copy link
Member

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๋ฅผ ๋ฐฉ์ถœํ•ด์ฃผ๋Š” ์‹์œผ๋กœ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์–ด๋– ์‹ ๊ฐ€์š”??

Comment on lines 74 to 75
if (likeUser.nickname.isEmpty()) dismiss()
else {
Copy link
Member

Choose a reason for hiding this comment

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

์ปจ๋ฒค์…˜์ƒ if else ๊ตฌ๋ฌธ์— ๋ชจ๋‘ ์ค‘๊ด„ํ˜ธ๋ฅผ ๋ถ™์ด๊ฑฐ๋‚˜, ๋‘˜๋‹ค ๋ถ™์ด์ง€ ์•Š์•„์•ผ ํ•˜๋Š”๊ฒƒ์œผ๋กœ ์•Œ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค!!
else๋ฌธ์˜ ๊ธธ์ด๊ฐ€ ๊ธฐ๋‹ˆ, if๋ฌธ์— ์ค‘๊ด„ํ˜ธ๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ณ€๊ฒฝ๋˜๋ฉด ์ปจ๋ฒค์…˜์— ์ ํ•ฉํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค

Copy link
Collaborator Author

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()
Copy link
Member

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๋ฅผ ๋ฐฉ์ถœํ•ด์ฃผ๋Š” ๋ฐฉ์‹์˜ ๋™์ž‘๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค

Copy link
Collaborator Author

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)
Copy link
Member

Choose a reason for hiding this comment

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

<LinkedHashMap<String, List<LikeModel>>> ๋Š” ์ œ๊ฑฐ๋˜์–ด๋„ ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

Copy link
Member

Choose a reason for hiding this comment

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

Notification๊ฐ™์ด Toolbar์— ๊ณตํ†ต์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ์•„์ด์ฝ˜์€ core-ui์— ๋ฐฐ์น˜ํ•˜๋ฉด ์žฌ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ• ๊ฒƒ ๊ฐ™์€๋ฐ... ๊ณ ๋ฏผ์ด ๋“œ๋„ค์š”..

Copy link
Collaborator Author

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 {
Copy link
Member

Choose a reason for hiding this comment

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

์™œ 3๋ช…๋ฟ์ธ๊ฐ€์š”?????

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ใ…‹ใ…‹.. ๊ท€์ฐฎ์Œ ์ด์Šˆ..

)
)

else -> LikeContentViewHolder(
Copy link
Member

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๊ฐ€ ์œ„์™€ ๊ฐ™์ด ๊ฐ€๋…์„ฑ์ด ์ข‹์•„์ง€๋Š” ํšจ๊ณผ๊ฐ€ ์žˆ์–ด์„œ ์‚ฌ์šฉ์„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

์—ญ์‹œ ํŒฉํ† ๋ ˆ ๋ฉ”์†Œ๋“œ ํŒจํ„ด์˜ ์žฅ์ ์€ ๊ฐ€๋…์„ฑ์ด ์ตœ๊ณ ์ธ ๊ฒƒ ๊ฐ™๋„ค์š”..! ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค ใ…Žใ…Ž

Comment on lines 73 to 79
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)
Copy link
Member

Choose a reason for hiding this comment

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

๐Ÿ‘

@cwj-c
Copy link
Member

cwj-c commented Jun 19, 2023

KakaoTalk_Video_2023-06-19-11-52-36.mp4

์กฐ๊ธˆ ๊นœ๋ฐ•์ด๋Š” ์ฆ์ƒ์ด์ด ์žˆ๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค
ํ˜น์‹œ ์ฒ˜์Œ์— ํฌ๊ธฐ๊ฐ€ ํฌ๊ฒŒ ๋‚˜์™”๋‹ค๊ฐ€, ์ž‘๊ฒŒ ์กฐ์ ˆ๋˜๋Š” ํ˜„์ƒ์ธ๊ฐ€ ์‹ถ์–ด์„œ ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊ฒผ์Šต๋‹ˆ๋‹ค!
ํ™˜๊ฒฝ์€ Android Studio Emulator Pixel 5 API 33 ์ž…๋‹ˆ๋‹ค

@cwj-c cwj-c merged commit 4a03da9 into develop Jan 12, 2024
3 checks passed
@cwj-c cwj-c deleted the feature/TOP-59_like_ui branch April 21, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants