Skip to content

Commit

Permalink
[MP-5177] tabBar center animation internal 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-deali committed Nov 6, 2024
1 parent 6c83e9b commit 7605f71
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import kotlinx.coroutines.launch
import net.deali.designsystem.internal.tabbar.CoreFixedTabBar
import net.deali.designsystem.internal.tabbar.CoreScrollableTabBar
import net.deali.designsystem.internal.tabbar.CoreTabBarLayout
import net.deali.designsystem.internal.tabbar.animateScrollAndCentralizeItem
import net.deali.designsystem.theme.DealiColor
import net.deali.designsystem.theme.DealiFont
import net.deali.designsystem.util.animation.animateScrollAndCentralizeItem

/**
* 화면의 1/n 크기 고정된 탭바
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ package net.deali.designsystem.internal.tabbar
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.animateScrollBy
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerScope
import androidx.compose.foundation.pager.PagerState
Expand Down Expand Up @@ -239,17 +237,6 @@ internal fun CoreScrollableTabBar(
}
}

internal suspend fun LazyListState.animateScrollAndCentralizeItem(index: Int) {
val itemInfo = this.layoutInfo.visibleItemsInfo.firstOrNull { it.index == index }
if (itemInfo != null) {
val center = layoutInfo.viewportEndOffset / 2
val childCenter = itemInfo.offset + itemInfo.size / 2
animateScrollBy((childCenter - center).toFloat())
} else {
animateScrollToItem(index)
}
}

@Composable
private fun FixedTabItem(
title: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.deali.designsystem.util.animation

import androidx.compose.foundation.gestures.animateScrollBy
import androidx.compose.foundation.lazy.LazyListState

suspend fun LazyListState.animateScrollAndCentralizeItem(index: Int) {
val itemInfo = this.layoutInfo.visibleItemsInfo.firstOrNull { it.index == index }
if (itemInfo != null) {
val center = layoutInfo.viewportEndOffset / 2
val childCenter = itemInfo.offset + itemInfo.size / 2
animateScrollBy((childCenter - center).toFloat())
} else {
animateScrollToItem(index)
}
}

0 comments on commit 7605f71

Please sign in to comment.