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

[feature/#725] poke ananymous #732

Merged
merged 23 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
52117e4
feat #725: PokeUser class 변경
chattymin Jun 3, 2024
1609210
feat #725: PokeFriend를 isAnonymous에 따른 분기처리추가
chattymin Jun 3, 2024
d9d401a
feat #725: Small User View를 isAnonymous에 따른 분기처리추가
chattymin Jun 3, 2024
3212487
feat #725: poke home 서버 의존적 recycleview 적용
chattymin Jun 4, 2024
6674c3c
feat #725: someone poke anonymous
chattymin Jun 4, 2024
401898d
feat #725: someone poke anonymous item
chattymin Jun 4, 2024
c5fae64
add #725: mate lottie
chattymin Jun 5, 2024
3ea8480
feat #725: pokeNum에 따른 lottie 구현
chattymin Jun 5, 2024
3a2c1ab
feat #725: string res 적용
chattymin Jun 5, 2024
3a5acce
feat #725: 1차 qa 일부 적용
chattymin Jun 7, 2024
7a1564a
feat #725: onboarding 타이틀 오류 수정
chattymin Jun 7, 2024
6010b94
feat #725: 변수 수정
chattymin Jun 8, 2024
b8bea26
feat #725: Add FriendListSummary AnonymousFriend Lottie
chattymin Jun 8, 2024
f47ddea
feat #725: Add FriendListDetail
chattymin Jun 8, 2024
d8a7f2e
feat #725: code clear
chattymin Jun 8, 2024
b2f908e
feat #725: spotlessApply
chattymin Jun 8, 2024
2536869
fix #725: View.AddAnimatorEndListener 추가 및 적용
chattymin Jun 9, 2024
885f815
fix #725: AddOnAnimatorEndListener 수정 및 적용
chattymin Jun 9, 2024
dcf93fb
fix #725: "Loading" 제거
chattymin Jun 9, 2024
d2a0421
fix #725: lifecycleScope 수정
chattymin Jun 9, 2024
1d43000
fix #725: dummyData 제거
chattymin Jun 9, 2024
4b0d31d
fix #725: 매직넘버 제거 및 함수화
chattymin Jun 9, 2024
b30a930
fix #725: spotlessApply
chattymin Jun 9, 2024
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 @@ -54,6 +54,12 @@ data class PokeUserResult(
val isFirstMeet: Boolean,
@SerialName("isAlreadyPoke")
val isAlreadyPoke: Boolean,
@SerialName("isAnonymous")
val isAnonymous: Boolean,
@SerialName("anonymousName")
val anonymousName: String,
@SerialName("anonymousImage")
val anonymousImage: String,
) {
fun toEntity(): PokeUser = PokeUser(
userId = userId,
Expand All @@ -68,5 +74,8 @@ data class PokeUserResult(
mutualRelationMessage = mutualRelationMessage,
isFirstMeet = isFirstMeet,
isAlreadyPoke = isAlreadyPoke,
isAnonymous = isAnonymous,
anonymousName = anonymousName,
anonymousImage = anonymousImage
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ data class PokeUser(
val mutualRelationMessage: String,
val isFirstMeet: Boolean,
var isAlreadyPoke: Boolean,
val isAnonymous: Boolean,
val anonymousName: String,
val anonymousImage: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@
*/
package org.sopt.official.feature.poke.friend.detail

import android.animation.Animator
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import coil.load
import coil.transform.CircleCropTransformation
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
Expand All @@ -58,6 +63,7 @@ import org.sopt.official.feature.poke.user.ItemDecorationDivider
import org.sopt.official.feature.poke.user.PokeUserListAdapter
import org.sopt.official.feature.poke.user.PokeUserListClickListener
import org.sopt.official.feature.poke.user.PokeUserListItemViewType
import org.sopt.official.feature.poke.util.setRelationStrokeColor
import org.sopt.official.feature.poke.util.showPokeToast

@AndroidEntryPoint
Expand Down Expand Up @@ -111,11 +117,52 @@ class FriendListDetailBottomSheetFragment : BottomSheetDialogFragment() {
)
}

initLottieListener()
initRecyclerView()
launchPokeMessageListUiStateFlow()
launchPokeUserUiStateFlow()
}

private fun initLottieListener() {
with(binding) {
animationFriendViewLottie.addAnimatorListener(
object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator) {}

override fun onAnimationEnd(animation: Animator) {
Copy link
Member

Choose a reason for hiding this comment

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

이거 확장함수 만들어서 View.doOnAnimationEnd { } 같은걸로 사용하면 좋을듯

Copy link
Member Author

Choose a reason for hiding this comment

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

오 이건 생각 못해봤는데 좋을 것 같네요!! 반영하겠습니다 :)

if (viewModel.anonymousFriend.value != null) { // 천생연분 -> 정체 공개
// 로티
layoutAnonymousFriendLottie.visibility = View.GONE
layoutAnonymousFriendOpen.visibility = View.VISIBLE

val anonymousFriend = viewModel.anonymousFriend.value
anonymousFriend?.let {
tvAnonymousFreindName.text = getString(R.string.anonymous_user_identity, it.anonymousName)
tvAnonymousFreindInfo.text = getString(R.string.anonymous_user_info, it.generation, it.part, it.name)
imgAnonymousFriendOpen.load(it.profileImage.ifEmpty { R.drawable.ic_empty_profile }) {
transformations(CircleCropTransformation())
}

imgAnonymousFriendOpenOutline.setRelationStrokeColor(it.mutualRelationMessage)
}

Handler(Looper.getMainLooper()).postDelayed({
layoutAnonymousFriendOpen.visibility = View.GONE
viewModel.setAnonymousFriend(null)
}, 2000)
Copy link
Member

Choose a reason for hiding this comment

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

lifecycleScope.launch...?

Copy link
Member

Choose a reason for hiding this comment

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

아 또 막 중복해서 하면 취소하고 해야돼서 그래가지고 안한건가...근데 그렇게 해도 중복해서 실행된다면(따닥) 취소해야하는건 매한가지일텐데

Copy link
Member Author

Choose a reason for hiding this comment

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

음... 둘의 차이점을 찾아보니 lifecycleScope를 쓰는게 더 좋을 것 같습니다! 수정하도록 하겠습니다 :)

} else {
layoutAnonymousFriendLottie.visibility = View.GONE
}
}

override fun onAnimationCancel(animation: Animator) {}

override fun onAnimationRepeat(animation: Animator) {}
},
)
}
}

private fun initRecyclerView() {
binding.includeFriendListBlock.apply {
pokeFriendType?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class FriendListDetailViewModel @Inject constructor(
private val _pokeUserUiState = MutableStateFlow<UiState<PokeUser>>(UiState.Loading)
val pokeUserUiState: StateFlow<UiState<PokeUser>> get() = _pokeUserUiState

private val _anonymousFriend = MutableStateFlow<PokeUser?>(null)
val anonymousFriend: StateFlow<PokeUser?>
get() = _anonymousFriend

private var totalPageSize = -1
private var currentPaginationIndex = 0
private var friendListJob: Job? = null
Expand Down Expand Up @@ -132,4 +136,8 @@ class FriendListDetailViewModel @Inject constructor(
}
}
}

fun setAnonymousFriend(pokeUser: PokeUser?) {
_anonymousFriend.value = pokeUser
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@
*/
package org.sopt.official.feature.poke.friend.summary

import android.animation.Animator
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import coil.load
import coil.transform.CircleCropTransformation
import dagger.hilt.android.AndroidEntryPoint
import java.io.Serializable
import javax.inject.Inject
Expand All @@ -57,6 +63,7 @@ import org.sopt.official.feature.poke.user.ItemDecorationDivider
import org.sopt.official.feature.poke.user.PokeUserListAdapter
import org.sopt.official.feature.poke.user.PokeUserListClickListener
import org.sopt.official.feature.poke.user.PokeUserListItemViewType
import org.sopt.official.feature.poke.util.setRelationStrokeColor
import org.sopt.official.feature.poke.util.showPokeToast

@AndroidEntryPoint
Expand Down Expand Up @@ -89,6 +96,7 @@ class FriendListSummaryActivity : AppCompatActivity() {
setContentView(binding.root)

initAppBar()
initLottieListener()
initFriendListBlock()
launchFriendListSummaryUiStateFlow()
launchPokeUserUiStateFlow()
Expand All @@ -106,6 +114,46 @@ class FriendListSummaryActivity : AppCompatActivity() {
}
}

private fun initLottieListener() {
with(binding) {
animationFriendViewLottie.addAnimatorListener(
object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator) {}

override fun onAnimationEnd(animation: Animator) {
if (viewModel.anonymousFriend.value != null) { // 천생연분 -> 정체 공개
// 로티
layoutAnonymousFriendLottie.visibility = View.GONE
layoutAnonymousFriendOpen.visibility = View.VISIBLE

val anonymousFriend = viewModel.anonymousFriend.value
anonymousFriend?.let {
tvAnonymousFreindName.text = getString(R.string.anonymous_user_identity, it.anonymousName)
tvAnonymousFreindInfo.text = getString(R.string.anonymous_user_info, it.generation, it.part, it.name)
imgAnonymousFriendOpen.load(it.profileImage.ifEmpty { R.drawable.ic_empty_profile }) {
transformations(CircleCropTransformation())
}

imgAnonymousFriendOpenOutline.setRelationStrokeColor(it.mutualRelationMessage)
}

Handler(Looper.getMainLooper()).postDelayed({
layoutAnonymousFriendOpen.visibility = View.GONE
viewModel.setAnonymousFriend(null)
}, 2000)
} else {
layoutAnonymousFriendLottie.visibility = View.GONE
}
}

override fun onAnimationCancel(animation: Animator) {}

override fun onAnimationRepeat(animation: Animator) {}
},
)
}
}

private fun initFriendListBlock() {
binding.swipeRefreshLayout.setOnRefreshListener {
viewModel.getFriendListSummary()
Expand Down Expand Up @@ -283,7 +331,29 @@ class FriendListSummaryActivity : AppCompatActivity() {
is UiState.Success<PokeUser> -> {
messageListBottomSheet?.dismiss()
viewModel.getFriendListSummary()
showPokeToast(getString(R.string.toast_poke_user_success))

if ((it.data.pokeNum == 5 || it.data.pokeNum == 6) && it.data.isAnonymous) { // 익명 베스트 프랜드 + 힌트
Copy link
Member

Choose a reason for hiding this comment

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

Magic Number 지양해주세요, 그리고 이 조건이 무슨 조건인지는 주석만으로는 파악하기 힘들 수 있으니 조건 자체를 property나 함수로 빼는걸 권장합니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

넵 알겠습니다. 함수로 빼서 진행하도록 하겠습니다!

with(binding) {
layoutAnonymousFriendLottie.visibility = View.VISIBLE
tvFreindLottie.text = getString(R.string.anonymous_to_friend, it.data.anonymousName, "단짝친구가")
tvFreindLottieHint.text =
getString(R.string.anonymous_user_info_part, it.data.generation, it.data.part)
animationFriendViewLottie.apply {
setAnimation(R.raw.friendtobestfriend)
}.playAnimation()
}
} else if ((it.data.pokeNum == 11 || it.data.pokeNum == 12) && it.data.isAnonymous) { // 익명 소울메이트 + 정체 공개
Copy link
Member

Choose a reason for hiding this comment

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

이것도 마찬가지

viewModel.setAnonymousFriend(it.data)
with(binding) {
layoutAnonymousFriendLottie.visibility = View.VISIBLE
tvFreindLottie.text = getString(R.string.anonymous_to_friend, it.data.anonymousName, "천생연분이")
animationFriendViewLottie.apply {
setAnimation(R.raw.bestfriendtosoulmate)
}.playAnimation()
}
} else {
showPokeToast(getString(R.string.toast_poke_user_success))
}
}

is UiState.ApiError -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class FriendListSummaryViewModel @Inject constructor(
private val _pokeUserUiState = MutableStateFlow<UiState<PokeUser>>(UiState.Loading)
val pokeUserUiState: StateFlow<UiState<PokeUser>> get() = _pokeUserUiState

private val _anonymousFriend = MutableStateFlow<PokeUser?>(null)
val anonymousFriend: StateFlow<PokeUser?>
get() = _anonymousFriend

init {
getFriendListSummary()
}
Expand Down Expand Up @@ -90,4 +94,8 @@ class FriendListSummaryViewModel @Inject constructor(
}
}
}

fun setAnonymousFriend(pokeUser: PokeUser?) {
_anonymousFriend.value = pokeUser
}
}
Loading