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

[FIX] 홈,시야아카이빙, 스크랩 2차 MVP 2차 QA #166

Merged
merged 15 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file modified buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin
Binary file not shown.
Binary file modified buildSrc/build/kotlin/compileKotlin/local-state/build-history.bin
Binary file not shown.
Binary file modified buildSrc/build/libs/buildSrc.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,7 @@ data class ResponseMySeatRecord(
}

fun kakaoShareSeatFeedTitle() : String {
val base = when(stadiumName.base(blockCode)) {
BASE.Base1 -> "1루 "
BASE.Base3 -> "3루 "
else -> ""
}
val section = sectionName
val block = "${rowNumber} 열 "
val seat = if(seatNumber == null) "" else "${seatNumber}번 "

return "$stadiumName $base $section $block $seat".trim()
return "$stadiumName ${formattedBaseName()}${formattedSectionName()}${formattedBlockName()}${formattedRowNumber()}${formattedSeatNumber()}".trim()
}

private fun formattedBaseName(): String {
Expand Down Expand Up @@ -77,7 +68,8 @@ data class ResponseMySeatRecord(
private fun formattedBlockName() = when(stadiumId) {
1 -> {
when(blockCode) {
in listOf("101w", "102w", "122w", "121w", "109w", "114w") -> "휠체어석 ${blockCode.replace("w", "")}블록 "
in listOf("101w", "102w", "122w", "121w") -> "휠체어석-레드 ${blockCode.replace("w", "")}블록"
in listOf("109w", "114w") -> "휠체어석-블루 ${blockCode.replace("w", "")}블록"
in listOf("exciting1") -> "1루 익사이팅석 "
in listOf("exciting3") -> "3루 익사이팅석 "
in listOf("premium") -> "프리미엄석 "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data class ResponseScrap(
val nextCursor: String? = null,
val hasNext: Boolean = false,
val totalScrapCount: Int = 0,
val filter: ResponseFilter,
val filter: ResponseFilter = ResponseFilter(),
) {
data class ResponseReviewWrapper(
val baseReview: ResponseBaseReview,
Expand All @@ -35,8 +35,13 @@ data class ResponseScrap(
val isLiked: Boolean = false,
val isScrapped: Boolean = false,
) {
/**
* @param
* formatted는 띄워쓰기 x parameter들은 띄워쓰기 o 일괄 적용
* 띄워쓰기가 모두 적용되어있기 때문에 마지막에 trim 일괄 적용
*/
fun formattedStadiumToSection() : String =
"${stadium.name} ${formattedBaseName()} ${formattedSectionName()}".trim()
"${stadium.name} ${formattedBaseName()}${formattedSectionName()}".trim()

fun formattedBlockToSeat(): String =
if (seat != null) {
Expand All @@ -51,11 +56,9 @@ data class ResponseScrap(
BASE.Base3 -> "3루 "
else -> ""
}
val section = section.name
val block = "${row.number}열 "
val seat = if(seat == null) "" else "${seat.seatNumber}번 "

return "${stadium.name}$base$section$block$seat".trim()
return "${stadium.name} ${formattedBaseName()}${formattedSectionName()}${formattedBlockToSeat()}".trim()
}

fun formattedBaseToBlock() : String =
Expand All @@ -79,18 +82,20 @@ data class ResponseScrap(
section.name.trim()
}
return when(block.code){
in listOf("101w", "102w", "122w", "121w", "109w", "114w","exciting1","exciting3","premium") -> ""
in listOf("101w", "102w", "122w", "121w") -> "휠체어석-레드"
in listOf("109w", "114w") -> "휠체어석-블루"
in listOf("exciting1") -> "1루 익사이팅석 "
in listOf("exciting3") -> "3루 익사이팅석 "
in listOf("premium") -> "프리미엄석 "
else -> "$section "
}
}

private fun formattedBlockName() = when(stadium.id) {
1 -> {
when(block.code) {
in listOf("101w", "102w", "122w", "121w", "109w", "114w") -> "휠체어석 ${block.code.replace("w", "")}블록 "
in listOf("exciting1") -> "1루 익사이팅석 "
in listOf("exciting3") -> "3루 익사이팅석 "
in listOf("premium") -> "프리미엄석 "
in listOf("101w", "102w", "122w", "121w", "109w", "114w") -> "${block.code.replace("w", "")}블록 "
in listOf("exciting1","exciting3","premium") -> ""
else -> "${block.code}블록 "
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
}

private fun initView() {
setLayoutBorder()
initReviewDialog()
initViewStatusBar()
homeViewModel.getStadiums()
Expand Down Expand Up @@ -117,6 +118,10 @@ class HomeActivity : BaseActivity<ActivityHomeBinding>(
}
}

private fun setLayoutBorder(){
binding.clHomeArchiving.clipToOutline = true
binding.clHomeScrap.clipToOutline = true
}

private fun initEvent() = with(binding) {
clHomeArchiving.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.dpm.core.base.BaseActivity
import com.dpm.core.state.UiState
import com.dpm.designsystem.extension.dpToPx
import com.dpm.presentation.extension.setOnSingleClickListener
import com.dpm.presentation.global.GlobalVariable
import com.dpm.presentation.scrap.adapter.ScrapFilterAdapter
import com.dpm.presentation.scrap.adapter.ScrapGridSpacingItemDecoration
import com.dpm.presentation.scrap.adapter.ScrapRecordAdapter
Expand Down Expand Up @@ -77,7 +76,7 @@ class ScrapActivity : BaseActivity<ActivityScrapBinding>(
viewModel.scrap.asLiveData().observe(this) { state ->
when (state) {
is UiState.Success -> {
binding.tvScrapCount.text = state.data.totalScrapCount .toString()
binding.tvScrapCount.text = state.data.totalScrapCount.toString()
scrapAdapter.submitList(state.data.reviews)
isLoading = false
setScrapScreenVisibility(ScrapScreenState.SUCCESS)
Expand Down Expand Up @@ -120,7 +119,8 @@ class ScrapActivity : BaseActivity<ActivityScrapBinding>(
binding.rvScrapRecord.itemAnimator = null
binding.rvScrapRecord.addItemDecoration(
ScrapGridSpacingItemDecoration(
spanCount = 2, spacing = 12.dpToPx(this), bottomSpacing = 40.dpToPx(this)
spanCount = 2, spacing = 12.dpToPx(this), bottomSpacing = 40.dpToPx(this),
borderMargin = 16.dpToPx(this)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ package com.dpm.presentation.scrap

import android.os.Bundle
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.ScaleAnimation
import androidx.activity.OnBackPressedCallback
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
Expand All @@ -13,14 +17,18 @@ import androidx.fragment.app.DialogFragment
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.commit
import androidx.lifecycle.asLiveData
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SimpleItemAnimator
import androidx.viewpager2.widget.ViewPager2
import com.depromeet.presentation.R
import com.depromeet.presentation.databinding.FragmentScrapDetailPictureBinding
import com.dpm.core.base.BindingFragment
import com.dpm.core.state.UiState
import com.dpm.designsystem.SpotSnackBar
import com.dpm.domain.entity.response.home.ResponseScrap
import com.dpm.presentation.scheme.SchemeKey
import com.dpm.presentation.scrap.adapter.ScrapDetailAdapter
import com.dpm.presentation.scrap.adapter.ScrapDetailViewHolder
import com.dpm.presentation.scrap.viewmodel.ScrapViewModel
import com.dpm.presentation.util.KakaoUtils
import com.dpm.presentation.util.Utils
Expand All @@ -40,6 +48,8 @@ class ScrapDetailPictureFragment : BindingFragment<FragmentScrapDetailPictureBin
private val viewModel: ScrapViewModel by activityViewModels()
private lateinit var adapter: ScrapDetailAdapter
private var isLoading: Boolean = false
private var snackbar: SpotSnackBar? = null


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand All @@ -51,6 +61,7 @@ class ScrapDetailPictureFragment : BindingFragment<FragmentScrapDetailPictureBin
private fun initView() {
initViewPager()
initWindowInsets()
viewModel.getDetailScrap()
}

private fun initEvent() = with(binding) {
Expand All @@ -67,25 +78,43 @@ class ScrapDetailPictureFragment : BindingFragment<FragmentScrapDetailPictureBin
}

private fun initObserve() {
viewModel.scrap.asLiveData().observe(viewLifecycleOwner) { state ->
when (state) {
is UiState.Success -> {
adapter.submitList(state.data.reviews.map { it.baseReview }.toList())
binding.vpScrap.post {
binding.vpScrap.setCurrentItem(viewModel.currentPage.value, false)
}
isLoading = false
}
viewModel.detailScrap.asLiveData().observe(viewLifecycleOwner) { data ->
adapter.submitList(data.map { it.baseReview }.toList())
binding.vpScrap.setCurrentItem(viewModel.currentPage.value, false)
isLoading = false
}

else -> {}
viewModel.isFirstLike.asLiveData().observe(viewLifecycleOwner) { isFirstLike ->
if (!isFirstLike) {
hideLikeDescriptionView()
}
}
}

private fun initViewPager() {
adapter = ScrapDetailAdapter(
scrapClick = {
viewModel.updateScrap(it)
scrapClick = { id, isScrap ->
viewModel.updateScrap(id)
if (isScrap) {
snackbar = SpotSnackBar.make(
view = binding.root,
message = "스크랩이 해제되었어요!",
background = R.drawable.rect_gray800_fill_60,
marginBottom = 20,
onClick = {},
)
} else {
snackbar = SpotSnackBar.make(
view = binding.root,
message = "스크랩이 완료되었어요!",
background = R.drawable.rect_gray800_fill_60,
endMessage = "스크랩으로 이동",
marginBottom = 20,
) {
removeFragment()
}
}
snackbar?.show()
},
likeClick = {
viewModel.updateLike(it)
Expand All @@ -95,26 +124,42 @@ class ScrapDetailPictureFragment : BindingFragment<FragmentScrapDetailPictureBin
}
)
binding.vpScrap.adapter = adapter
val recyclerView = binding.vpScrap.getChildAt(0) as RecyclerView
(recyclerView.itemAnimator as? SimpleItemAnimator)?.supportsChangeAnimations = false
recyclerView.itemAnimator = null
setupPageChangeListener()
}

override fun onDestroyView() {
super.onDestroyView()
resetWindowInsets()
snackbar?.dismiss()
snackbar = null
}

private fun setupPageChangeListener() {

binding.vpScrap.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageScrollStateChanged(state: Int) {
super.onPageScrollStateChanged(state)
if (state == ViewPager2.SCROLL_STATE_IDLE) {
viewModel.setCurrentPage(binding.vpScrap.currentItem)
if (viewModel.isFirstLike.value)
updateRecyclerViewVisibility(true)
else
hideLikeDescriptionView()
} else {
if (viewModel.isFirstLike.value) {
updateRecyclerViewVisibility(false)
}
else
hideLikeDescriptionView()
}
}

override fun onPageSelected(position: Int) {
super.onPageSelected(position)
binding.spotAppbar.setText((viewModel.scrap.value as UiState.Success).data.reviews[position].baseReview.formattedStadiumToSection())
binding.spotAppbar.setText(viewModel.detailScrap.value[position].baseReview.formattedStadiumToSection())
if (!isLoading && position >= adapter.itemCount - 2 && (viewModel.scrap.value as UiState.Success).data.hasNext) {
isLoading = true
viewModel.getNextScrapRecord()
Expand All @@ -123,12 +168,55 @@ class ScrapDetailPictureFragment : BindingFragment<FragmentScrapDetailPictureBin
})
}

private fun hideLikeDescriptionView() {
val recyclerView = binding.vpScrap.getChildAt(0) as RecyclerView
for (i in 0 until recyclerView.childCount) {
val child = recyclerView.getChildAt(i)
val viewHolder = recyclerView.getChildViewHolder(child) as? ScrapDetailViewHolder
viewHolder?.binding?.csbvLikeDescription?.visibility = GONE
}
}

private fun updateRecyclerViewVisibility(isVisible: Boolean) {
if (!viewModel.isFirstLike.value) return

val recyclerView = binding.vpScrap.getChildAt(0) as RecyclerView
for (i in 0 until recyclerView.childCount) {
val child = recyclerView.getChildAt(i)
val viewHolder = recyclerView.getChildViewHolder(child) as? ScrapDetailViewHolder
viewHolder?.let {
val scaleAnimation = if (isVisible) {
ScaleAnimation(
0.2f, 1f,
0.2f, 1f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f
).apply {
duration = 300
}
} else {
ScaleAnimation(
1f, 0.2f,
1f, 0.2f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f
).apply {
duration = 300
}
}
it.binding.csbvLikeDescription.startAnimation(scaleAnimation)
it.binding.csbvLikeDescription.visibility = if (isVisible) VISIBLE else GONE
}
}
}


private fun startToBottomSheetReportDialog(dialogInstance: DialogFragment) {
dialogInstance.show(parentFragmentManager, ReportDialog.TAG)
}

private fun removeFragment() {
viewModel.updateScrapRecord()
val fragment = parentFragmentManager.findFragmentByTag(TAG)
if (fragment != null) {
parentFragmentManager.commit {
Expand All @@ -141,12 +229,7 @@ class ScrapDetailPictureFragment : BindingFragment<FragmentScrapDetailPictureBin
requireActivity().onBackPressedDispatcher
.addCallback(viewLifecycleOwner, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
val fragment = parentFragmentManager.findFragmentByTag(TAG)
if (fragment != null) {
parentFragmentManager.beginTransaction()
.remove(fragment)
.commit()
}
removeFragment()
}
})
}
Expand All @@ -165,6 +248,7 @@ class ScrapDetailPictureFragment : BindingFragment<FragmentScrapDetailPictureBin
),
onSuccess = { sharingIntent ->
requireContext().startActivity(sharingIntent)
viewModel.updateIsFirstShare(true)
},
onFailure = {
Timber.d("링크 공유 실패 : ${it.message}")
Expand Down Expand Up @@ -210,4 +294,5 @@ class ScrapDetailPictureFragment : BindingFragment<FragmentScrapDetailPictureBin
}
}
}

}
Loading
Loading