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

[Feat] 마이페이지 탭 스크롤 했을 때 앵커 기능 추가 #261

Merged
merged 2 commits into from
Oct 1, 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
37 changes: 37 additions & 0 deletions feature/mypage/src/main/java/team/ppac/mypage/MyPageScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan
import androidx.compose.foundation.lazy.staggeredgrid.rememberLazyStaggeredGridState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Text
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand All @@ -38,6 +42,7 @@ import kotlinx.coroutines.flow.flowOf
import team.ppac.common.android.component.FarmemeMemeItem
import team.ppac.common.android.component.error.FarmemeErrorScreen
import team.ppac.common.android.util.showSkeleton
import team.ppac.common.android.util.systemBarHeight
import team.ppac.common.android.util.visibility
import team.ppac.designsystem.FarmemeTheme
import team.ppac.designsystem.R
Expand Down Expand Up @@ -134,8 +139,16 @@ private fun MyPageContent(
savedMemes: LazyPagingItems<Meme>,
registeredMemes: LazyPagingItems<Meme>,
) {
val staggeredGridState = rememberLazyStaggeredGridState()
val showStickyHeader by remember {
derivedStateOf {
staggeredGridState.firstVisibleItemIndex > 3
}
}

LazyVerticalStaggeredGrid(
modifier = modifier.wrapContentHeight(),
state = staggeredGridState,
columns = StaggeredGridCells.Fixed(2),
horizontalArrangement = Arrangement.spacedBy(space = (-28).dp),
) {
Expand Down Expand Up @@ -165,8 +178,12 @@ private fun MyPageContent(
isLoading = uiState.isLoading,
)
}
item(span = StaggeredGridItemSpan.FullLine) {
Spacer(modifier = Modifier.height(40.dp - systemBarHeight))
}
item(span = StaggeredGridItemSpan.FullLine) {
MyPageMemesTabBar(
modifier = Modifier.padding(top = systemBarHeight),
currentTabType = uiState.currentTabType,
onClick = { tab ->
onIntent(MyPageIntent.ClickMemesTab(currentTabType = tab))
Expand Down Expand Up @@ -236,6 +253,26 @@ private fun MyPageContent(
Spacer(modifier = Modifier.height(30.dp))
}
}
if (showStickyHeader) {
Column(
modifier = Modifier
.background(color = FarmemeTheme.backgroundColor.white)
.padding(top = systemBarHeight),
) {
MyPageMemesTabBar(
currentTabType = uiState.currentTabType,
onClick = { tab ->
onIntent(MyPageIntent.ClickMemesTab(currentTabType = tab))
},
)
Spacer(
modifier = Modifier
.fillMaxWidth()
.height(1.dp)
.background(FarmemeTheme.borderColor.tertiary),
)
}
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ internal fun RecentMemeContent(
} else {
RecentMemeEmpty()
}
Spacer(modifier = Modifier.height(46.dp))
}
}
}
Expand Down