Skip to content

Commit

Permalink
feat: ForegroundPopularFestival 아이템 설명을 뷰페이저 밖으로 이동하고 사이즈 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongHoonC committed Feb 5, 2024
1 parent 7fdd352 commit 16565df
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -32,15 +33,24 @@ class PopularFestivalViewPagerAdapter(
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
target.setCurrentItem(position, false)
onPopularFestivalSelected(popularFestivals[position])
}
}
viewpager.registerOnPageChangeCallback(onPageChangeCallback)
}

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

Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

<import type="java.time.format.DateTimeFormatter" />

<variable
name="item"
type="com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalItemUiState" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
Expand All @@ -25,23 +35,72 @@
android:textColor="@color/background_gray_01"
app:layout_constraintTop_toTopOf="@id/vpPopularFestivalBackground" />

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vpPopularFestivalForeground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
app:layout_constraintTop_toBottomOf="@id/tvPopularFestivalTitle" />

<TextView
android:id="@+id/tvPopularFestivalName"
style="@style/H3Bold18Lh20"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ellipsize="end"
android:gravity="center"
android:lineSpacingExtra="0dp"
android:maxLines="2"
android:text="@{item.schoolUiState.name+'\n'+ item.name }"
android:textColor="@color/background_gray_01"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vpPopularFestivalForeground"
tools:text="대학교 \n 축제 이름" />

<TextView
android:id="@+id/tvFestivalSchedule"
style="@style/B2Medium14Lh20"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="@{@string/festival_list_tv_date_range_format(item.startDate.format(DateTimeFormatter.ofPattern(@string/festival_list_tv_date_format)),item.endDate.format(DateTimeFormatter.ofPattern(@string/festival_list_tv_date_format)))}"
android:textColor="@color/background_gray_01"
app:layout_constraintEnd_toEndOf="@+id/tvPopularFestivalName"
app:layout_constraintStart_toStartOf="@+id/tvPopularFestivalName"
app:layout_constraintTop_toBottomOf="@id/tvPopularFestivalName"
tools:text="2023.07.03 - 2023.07.09" />

<TextView
android:id="@+id/tvPopularFestivalArtistsName"
style="@style/B2Medium14Lh20"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:lineSpacingExtra="0dp"
android:lines="2"
android:textColor="@color/background_gray_01"
app:layout_constraintEnd_toEndOf="@+id/tvFestivalSchedule"
app:layout_constraintStart_toStartOf="@+id/tvFestivalSchedule"
app:layout_constraintTop_toBottomOf="@id/tvFestivalSchedule"
tools:text="르세라핌, 아이브, 뉴진스, \n다이나믹 듀오" />

<com.google.android.material.tabs.TabLayout
android:id="@+id/tlDotIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:layout_constraintTop_toBottomOf="@id/vpPopularFestivalForeground"
app:layout_constraintTop_toBottomOf="@id/tvPopularFestivalArtistsName"
app:tabBackground="@drawable/selector_tab_page"
app:tabGravity="center"
app:tabIndicatorHeight="0dp"
app:tabPaddingEnd="8dp"
app:tabPaddingStart="8dp" />

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vpPopularFestivalForeground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tvPopularFestivalTitle" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -20,70 +20,19 @@
<ImageView
android:id="@+id/ivPopularFestivalImage"
imageUrl="@{item.imageUrl}"
android:layout_width="200dp"
android:layout_height="200dp"
android:outlineProvider="bounds"
android:layout_marginTop="24dp"
android:layout_width="220dp"
android:layout_height="220dp"
android:elevation="10dp"
android:importantForAccessibility="no"
android:outlineProvider="bounds"
android:scaleType="centerCrop"
android:elevation="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintDimensionRatio="1:1"
tools:src="@drawable/ic_launcher_background" />


<TextView
android:id="@+id/tvPopularFestivalName"
style="@style/H3Bold18Lh20"
android:textColor="@color/background_gray_01"
android:layout_width="0dp"
android:layout_marginTop="16dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:lineSpacingExtra="0dp"
android:text="@{item.schoolUiState.name+'\n'+ item.name }"
app:layout_constraintTop_toBottomOf="@id/ivPopularFestivalImage"
app:layout_constraintEnd_toEndOf="@+id/ivPopularFestivalImage"
app:layout_constraintStart_toStartOf="@+id/ivPopularFestivalImage"
tools:text="대학교 \n 축제 이름" />


<TextView
android:id="@+id/tvFestivalSchedule"
style="@style/B2Medium14Lh20"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/background_gray_01"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:layout_marginTop="8dp"
android:text="@{@string/festival_list_tv_date_range_format(item.startDate.format(DateTimeFormatter.ofPattern(@string/festival_list_tv_date_format)),item.endDate.format(DateTimeFormatter.ofPattern(@string/festival_list_tv_date_format)))}"
app:layout_constraintTop_toBottomOf="@id/tvPopularFestivalName"
app:layout_constraintEnd_toEndOf="@+id/ivPopularFestivalImage"
tools:text="2023.07.03 - 2023.07.09"
app:layout_constraintStart_toStartOf="@+id/ivPopularFestivalImage" />

<TextView
android:id="@+id/tvPopularFestivalArtistsName"
style="@style/B2Medium14Lh20"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/background_gray_01"
android:ellipsize="end"
android:gravity="center"
android:lineSpacingExtra="0dp"
android:lines="2"
app:layout_constraintTop_toBottomOf="@id/tvFestivalSchedule"
app:layout_constraintEnd_toEndOf="@+id/ivPopularFestivalImage"
app:layout_constraintStart_toStartOf="@+id/ivPopularFestivalImage"
tools:text="르세라핌, 아이브, 뉴진스, \n다이나믹 듀오" />


</androidx.constraintlayout.widget.ConstraintLayout>

</layout>

0 comments on commit 16565df

Please sign in to comment.