From 7fdd3527b1c2c95118ecb65225c7a3f349d1c91f Mon Sep 17 00:00:00 2001 From: vrexpert Date: Mon, 5 Feb 2024 22:23:05 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=EB=B7=B0=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A0=80=20=ED=83=AD=EC=9D=98=20=EC=A0=90=20=ED=81=AC=EA=B8=B0?= =?UTF-8?q?=20=EC=A4=84=EC=9D=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/src/main/res/drawable/ic_dot_default.xml | 2 +- .../presentation/src/main/res/drawable/ic_dot_selected.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/festago/presentation/src/main/res/drawable/ic_dot_default.xml b/android/festago/presentation/src/main/res/drawable/ic_dot_default.xml index 4905cf54c..c980ed1d4 100644 --- a/android/festago/presentation/src/main/res/drawable/ic_dot_default.xml +++ b/android/festago/presentation/src/main/res/drawable/ic_dot_default.xml @@ -4,7 +4,7 @@ diff --git a/android/festago/presentation/src/main/res/drawable/ic_dot_selected.xml b/android/festago/presentation/src/main/res/drawable/ic_dot_selected.xml index 0cda1e925..28c930e22 100644 --- a/android/festago/presentation/src/main/res/drawable/ic_dot_selected.xml +++ b/android/festago/presentation/src/main/res/drawable/ic_dot_selected.xml @@ -4,7 +4,7 @@ From 16565df4cf30182938405512bffb6b3f82167bde Mon Sep 17 00:00:00 2001 From: vrexpert Date: Mon, 5 Feb 2024 22:26:59 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20ForegroundPopularFestival=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=ED=85=9C=20=EC=84=A4=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EB=B7=B0=ED=8E=98=EC=9D=B4=EC=A0=80=20=EB=B0=96=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99=ED=95=98=EA=B3=A0=20=EC=82=AC?= =?UTF-8?q?=EC=9D=B4=EC=A6=88=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PopularFestivalViewPagerAdapter.kt | 19 ++++- .../res/layout/item_festival_list_popular.xml | 75 +++++++++++++++++-- .../item_popular_festival_foreground.xml | 63 ++-------------- 3 files changed, 89 insertions(+), 68 deletions(-) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt index 09e01fb91..ddb1bed4e 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt @@ -5,6 +5,7 @@ import androidx.viewpager2.widget.ViewPager2 import com.festago.festago.presentation.ui.home.festivallist.popularfestival.background.PopularFestivalBackgroundAdapter import com.festago.festago.presentation.ui.home.festivallist.popularfestival.foreground.PopularFestivalForegroundAdapter import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalItemUiState +import kotlin.math.abs class PopularFestivalViewPagerAdapter( foregroundViewPager: ViewPager2, @@ -32,6 +33,7 @@ class PopularFestivalViewPagerAdapter( override fun onPageSelected(position: Int) { super.onPageSelected(position) target.setCurrentItem(position, false) + onPopularFestivalSelected(popularFestivals[position]) } } viewpager.registerOnPageChangeCallback(onPageChangeCallback) @@ -39,8 +41,16 @@ class PopularFestivalViewPagerAdapter( private fun narrowSpaceViewPager(viewPager: ViewPager2) { viewPager.setPageTransformer { page, position -> - val offset = position * -(2 * dpToPx(OFFSET_BETWEEN_PAGES)) + val offsetBetweenPages = + Resources.getSystem().configuration.screenWidthDp - IMAGE_SIZE - INTERVAL_IMAGE + (IMAGE_SIZE - (IMAGE_SIZE * RATE_SELECT_BY_UNSELECT)) * 0.5f + val offset = position * -dpToPx(offsetBetweenPages) page.translationX = offset + + if (position <= ALREADY_LOAD_POSITION_CONDITION) { + val scaleFactor = RATE_SELECT_BY_UNSELECT.coerceAtLeast(1 - abs(position)) + page.scaleY = scaleFactor + page.scaleX = scaleFactor + } } } @@ -59,7 +69,10 @@ class PopularFestivalViewPagerAdapter( } companion object { - private const val PAGE_LIMIT = 3 - private const val OFFSET_BETWEEN_PAGES = 63.0f + private const val ALREADY_LOAD_POSITION_CONDITION = 2 + private const val RATE_SELECT_BY_UNSELECT = 0.81f + private const val PAGE_LIMIT = 4 + private const val IMAGE_SIZE = 220.0f + private const val INTERVAL_IMAGE = 24.0f } } diff --git a/android/festago/presentation/src/main/res/layout/item_festival_list_popular.xml b/android/festago/presentation/src/main/res/layout/item_festival_list_popular.xml index fc9364c08..92281f38b 100644 --- a/android/festago/presentation/src/main/res/layout/item_festival_list_popular.xml +++ b/android/festago/presentation/src/main/res/layout/item_festival_list_popular.xml @@ -1,6 +1,16 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + + + + + + + + + + + + + + + - - diff --git a/android/festago/presentation/src/main/res/layout/item_popular_festival_foreground.xml b/android/festago/presentation/src/main/res/layout/item_popular_festival_foreground.xml index bf7368a11..29e2b7141 100644 --- a/android/festago/presentation/src/main/res/layout/item_popular_festival_foreground.xml +++ b/android/festago/presentation/src/main/res/layout/item_popular_festival_foreground.xml @@ -20,70 +20,19 @@ - - - - - - - - - \ No newline at end of file From 15bfa7623fdab2074a7d1b6bdd3b8db65ec0655b Mon Sep 17 00:00:00 2001 From: vrexpert Date: Mon, 5 Feb 2024 22:31:39 +0900 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=EC=95=84=EC=9D=B4=ED=85=9C=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=20=EC=8B=9C=20=ED=95=B4=EB=8B=B9=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=ED=85=9C=EC=97=90=20=EB=A7=9E=EB=8A=94=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EA=B0=80=20=ED=99=94=EB=A9=B4=EC=97=90=20=EB=B6=88?= =?UTF-8?q?=EB=9F=AC=EC=99=80=EC=A7=84=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../festival/FestivalListPopularViewHolder.kt | 8 +++++++- .../PopularFestivalViewPagerAdapter.kt | 10 +++++++--- .../PopularFestivalForegroundViewHolder.kt | 18 ------------------ 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/festival/FestivalListPopularViewHolder.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/festival/FestivalListPopularViewHolder.kt index 919782c05..5fb89ed90 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/festival/FestivalListPopularViewHolder.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/festival/FestivalListPopularViewHolder.kt @@ -13,7 +13,11 @@ class FestivalListPopularViewHolder(val binding: ItemFestivalListPopularBinding) PopularFestivalViewPagerAdapter( foregroundViewPager = binding.vpPopularFestivalForeground, backgroundViewPager = binding.vpPopularFestivalBackground, - ) + ) { item -> + binding.item = item + binding.tvPopularFestivalArtistsName.text = + item.artists.joinToString(ARTIST_NAME_JOIN_SEPARATOR) { it.name } + } init { TabLayoutMediator( @@ -27,6 +31,8 @@ class FestivalListPopularViewHolder(val binding: ItemFestivalListPopularBinding) } companion object { + private const val ARTIST_NAME_JOIN_SEPARATOR = ", " + fun of(parent: ViewGroup): FestivalListPopularViewHolder { val binding = ItemFestivalListPopularBinding.inflate( LayoutInflater.from(parent.context), diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt index ddb1bed4e..3f711e4a5 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt @@ -10,8 +10,10 @@ import kotlin.math.abs class PopularFestivalViewPagerAdapter( foregroundViewPager: ViewPager2, backgroundViewPager: ViewPager2, + private val onPopularFestivalSelected: (FestivalItemUiState) -> Unit, ) { + private val popularFestivals = mutableListOf() private val foregroundAdapter: PopularFestivalForegroundAdapter = PopularFestivalForegroundAdapter() private val backgroundAdapter: PopularFestivalBackgroundAdapter = @@ -63,9 +65,11 @@ class PopularFestivalViewPagerAdapter( viewPager.offscreenPageLimit = limit } - fun submitList(popularFestivals: List) { - foregroundAdapter.submitList(popularFestivals) - backgroundAdapter.submitList(popularFestivals) + fun submitList(festivals: List) { + popularFestivals.clear() + popularFestivals.addAll(festivals) + foregroundAdapter.submitList(festivals) + backgroundAdapter.submitList(festivals) } companion object { diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/foreground/PopularFestivalForegroundViewHolder.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/foreground/PopularFestivalForegroundViewHolder.kt index a59f2c000..c60b575d1 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/foreground/PopularFestivalForegroundViewHolder.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/foreground/PopularFestivalForegroundViewHolder.kt @@ -1,6 +1,5 @@ package com.festago.festago.presentation.ui.home.festivallist.popularfestival.foreground -import android.content.res.Resources import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView @@ -14,26 +13,9 @@ class PopularFestivalForegroundViewHolder( fun bind(item: FestivalItemUiState) { binding.item = item - binding.ivPopularFestivalImage.outlineProvider - binding.tvPopularFestivalArtistsName.text = - item.artists.joinToString(ARTIST_NAME_JOIN_SEPARATOR) { it.name } - setImageSizeFlexibleToScreenWidth() - } - - private fun setImageSizeFlexibleToScreenWidth() { - val imageSize = Resources.getSystem().configuration.screenWidthDp - MINUS_TO_IMAGE_SIZE - val density = Resources.getSystem().displayMetrics.density - - binding.ivPopularFestivalImage.layoutParams.apply { - this.width = (imageSize * density + ROUNDUP_CONDITION).toInt() - this.height = (imageSize * density + ROUNDUP_CONDITION).toInt() - } } companion object { - private const val MINUS_TO_IMAGE_SIZE = 160 - private const val ROUNDUP_CONDITION = 0.5f - private const val ARTIST_NAME_JOIN_SEPARATOR = ", " fun of(parent: ViewGroup): PopularFestivalForegroundViewHolder { val binding = ItemPopularFestivalForegroundBinding.inflate( From 7ef03e6bbf672f37a0843ec3f52958335e411e33 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Tue, 6 Feb 2024 17:28:08 +0900 Subject: [PATCH 4/7] =?UTF-8?q?feat:=20=EC=9D=B8=EA=B8=B0=20=EC=B6=95?= =?UTF-8?q?=EC=A0=9C=20=EB=AA=A9=EB=A1=9D=20=EB=84=98=EA=B8=B0=EA=B8=B0=20?= =?UTF-8?q?=EB=B2=94=EC=9C=84=20=ED=99=95=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PopularFestivalViewPagerAdapter.kt | 3 +++ .../res/layout/item_festival_list_popular.xml | 19 ++++++++++--------- .../item_popular_festival_foreground.xml | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt index 3f711e4a5..9080494df 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt @@ -47,6 +47,8 @@ class PopularFestivalViewPagerAdapter( Resources.getSystem().configuration.screenWidthDp - IMAGE_SIZE - INTERVAL_IMAGE + (IMAGE_SIZE - (IMAGE_SIZE * RATE_SELECT_BY_UNSELECT)) * 0.5f val offset = position * -dpToPx(offsetBetweenPages) page.translationX = offset + page.pivotX = page.pivotX + page.pivotY = MIDDLE_IMAGE_PIVOT if (position <= ALREADY_LOAD_POSITION_CONDITION) { val scaleFactor = RATE_SELECT_BY_UNSELECT.coerceAtLeast(1 - abs(position)) @@ -78,5 +80,6 @@ class PopularFestivalViewPagerAdapter( private const val PAGE_LIMIT = 4 private const val IMAGE_SIZE = 220.0f private const val INTERVAL_IMAGE = 24.0f + private const val MIDDLE_IMAGE_PIVOT = 360.0f } } diff --git a/android/festago/presentation/src/main/res/layout/item_festival_list_popular.xml b/android/festago/presentation/src/main/res/layout/item_festival_list_popular.xml index 92281f38b..402c70362 100644 --- a/android/festago/presentation/src/main/res/layout/item_festival_list_popular.xml +++ b/android/festago/presentation/src/main/res/layout/item_festival_list_popular.xml @@ -35,19 +35,12 @@ android:textColor="@color/background_gray_01" app:layout_constraintTop_toTopOf="@id/vpPopularFestivalBackground" /> - - + + Date: Wed, 7 Feb 2024 14:58:06 +0900 Subject: [PATCH 5/7] =?UTF-8?q?refactor:=20offset=20=EA=B3=84=EC=82=B0=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=EC=9D=84=20=ED=95=A8=EC=88=98=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=ED=95=98=EC=97=AC=20=EA=B0=80=EB=8F=85=EC=84=B1?= =?UTF-8?q?=EC=9D=84=20=EC=A6=9D=EA=B0=80=EC=8B=9C=ED=82=A8=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PopularFestivalViewPagerAdapter.kt | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt index 9080494df..792643f92 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/popularfestival/PopularFestivalViewPagerAdapter.kt @@ -1,6 +1,7 @@ package com.festago.festago.presentation.ui.home.festivallist.popularfestival import android.content.res.Resources +import android.view.View import androidx.viewpager2.widget.ViewPager2 import com.festago.festago.presentation.ui.home.festivallist.popularfestival.background.PopularFestivalBackgroundAdapter import com.festago.festago.presentation.ui.home.festivallist.popularfestival.foreground.PopularFestivalForegroundAdapter @@ -43,26 +44,42 @@ class PopularFestivalViewPagerAdapter( private fun narrowSpaceViewPager(viewPager: ViewPager2) { viewPager.setPageTransformer { page, position -> - val offsetBetweenPages = - Resources.getSystem().configuration.screenWidthDp - IMAGE_SIZE - INTERVAL_IMAGE + (IMAGE_SIZE - (IMAGE_SIZE * RATE_SELECT_BY_UNSELECT)) * 0.5f - val offset = position * -dpToPx(offsetBetweenPages) - page.translationX = offset - page.pivotX = page.pivotX - page.pivotY = MIDDLE_IMAGE_PIVOT - - if (position <= ALREADY_LOAD_POSITION_CONDITION) { - val scaleFactor = RATE_SELECT_BY_UNSELECT.coerceAtLeast(1 - abs(position)) - page.scaleY = scaleFactor - page.scaleX = scaleFactor - } + translateOffsetBetweenPages(position, page) + reduceUnselectedPagesScale(page, position) } } + private fun translateOffsetBetweenPages(position: Float, page: View) { + val screenWidth = Resources.getSystem().configuration.screenWidthDp + val offsetBetweenPages = screenWidth - IMAGE_SIZE - INTERVAL_IMAGE + val reducedDifference = IMAGE_SIZE - (IMAGE_SIZE * RATE_SELECT_BY_UNSELECT) + val offset = position * -dpToPx(offsetBetweenPages + reducedDifference * 0.5f) + page.translationX = offset + } + private fun dpToPx(dp: Float): Int { val density = Resources.getSystem().displayMetrics.density return (dp * density).toInt() } + private fun reduceUnselectedPagesScale(page: View, position: Float) { + page.movePivotTo(x = page.pivotX, y = MIDDLE_IMAGE_PIVOT) + if (position <= ALREADY_LOAD_POSITION_CONDITION) { + page.reduceScaleBy(position = position, rate = RATE_SELECT_BY_UNSELECT) + } + } + + private fun View.movePivotTo(x: Float, y: Float) { + pivotX = x + pivotY = y + } + + private fun View.reduceScaleBy(position: Float, rate: Float) { + val scaleFactor = rate.coerceAtLeast(1 - abs(position)) + scaleY = scaleFactor + scaleX = scaleFactor + } + private fun setOffscreenPagesLimit(viewPager: ViewPager2, limit: Int) { viewPager.offscreenPageLimit = limit } From 765735e522184bfdf53a7fe55d6e23e46c3d9ebd Mon Sep 17 00:00:00 2001 From: vrexpert Date: Wed, 7 Feb 2024 15:20:56 +0900 Subject: [PATCH 6/7] =?UTF-8?q?feat(FestivalList):=20=EC=A7=84=ED=96=89?= =?UTF-8?q?=EC=A4=91=20=EC=A7=84=ED=96=89=20=EC=98=88=EC=A0=95=20=ED=83=AD?= =?UTF-8?q?=20=EA=B0=80=EB=A1=9C=20=EC=97=AC=EB=B0=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/src/main/res/layout/item_festival_list_tab.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/android/festago/presentation/src/main/res/layout/item_festival_list_tab.xml b/android/festago/presentation/src/main/res/layout/item_festival_list_tab.xml index 19a28b975..a32fee9a4 100644 --- a/android/festago/presentation/src/main/res/layout/item_festival_list_tab.xml +++ b/android/festago/presentation/src/main/res/layout/item_festival_list_tab.xml @@ -12,6 +12,7 @@ android:id="@+id/tlFestivalListTab" android:layout_width="match_parent" android:layout_height="48dp" + android:layout_marginHorizontal="16dp" android:background="@android:color/transparent" app:tabGravity="fill" app:tabIndicatorColor="@color/contents_gray_07" From a84d72666558767d5bbc2126fe7c0a66d4ac2967 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Wed, 7 Feb 2024 17:17:30 +0900 Subject: [PATCH 7/7] chore: lint check --- .../src/main/res/layout/item_popular_festival_foreground.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/festago/presentation/src/main/res/layout/item_popular_festival_foreground.xml b/android/festago/presentation/src/main/res/layout/item_popular_festival_foreground.xml index 944fe2182..7b5bc2475 100644 --- a/android/festago/presentation/src/main/res/layout/item_popular_festival_foreground.xml +++ b/android/festago/presentation/src/main/res/layout/item_popular_festival_foreground.xml @@ -35,4 +35,4 @@ - \ No newline at end of file +