Skip to content

Commit

Permalink
Fix : 비로그인 마이페이지 error fix
Browse files Browse the repository at this point in the history
- #53
  • Loading branch information
inwoo13 committed Nov 28, 2024
1 parent 4c0b141 commit 81bb497
Showing 1 changed file with 39 additions and 43 deletions.
82 changes: 39 additions & 43 deletions feature/my/src/main/java/com/kolown/my/MyScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ internal fun MyRoute(
navigateToSetting: () -> Unit,
padding: PaddingValues = PaddingValues(),
) {
MyScreen(
isLoggedIn = isLoggedIn,
navigateToLogin = navigateToLogin,
navigateToSetting = navigateToSetting,
padding = padding
)
if(isLoggedIn) {
MyScreen(
navigateToSetting = navigateToSetting,
padding = padding
)
} else {
RestrictedLoginContent(navigateToLogin)
}

}

@Composable
fun MyScreen(
isLoggedIn: Boolean = false,
navigateToLogin: () -> Unit = {},
navigateToSetting: () -> Unit = {},
padding: PaddingValues = PaddingValues(),
viewModel: MyViewModel = hiltViewModel(),
Expand All @@ -53,49 +54,44 @@ fun MyScreen(
val pagingItems = viewModel.galleryFlow.collectAsLazyPagingItems()
val listState = rememberLazyStaggeredGridState()

if (isLoggedIn) {
LaunchedEffect(pagingItems) {
listState.scrollToItem(0)
}
Column(
LaunchedEffect(pagingItems) {
listState.scrollToItem(0)
}
Column(
modifier = Modifier
.fillMaxSize()
.padding(padding)
) {
MyAppBar(
onSettingClicked = navigateToSetting
)
LazyVerticalStaggeredGrid(
columns = StaggeredGridCells.Fixed(2),
modifier = Modifier
.fillMaxSize()
.padding(padding)
) {
MyAppBar(
onSettingClicked = navigateToSetting
)
LazyVerticalStaggeredGrid(
columns = StaggeredGridCells.Fixed(2),
modifier = Modifier
.fillMaxSize(),
state = listState,
contentPadding = PaddingValues(8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalItemSpacing = 8.dp,
content = {
items(pagingItems.itemCount) { index ->
pagingItems[index]?.let {
GalleryItem(it, width) {
viewModel.deletePost(it.postId)
}
.fillMaxSize(),
state = listState,
contentPadding = PaddingValues(8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalItemSpacing = 8.dp,
content = {
items(pagingItems.itemCount) { index ->
pagingItems[index]?.let {
GalleryItem(it, width) {
viewModel.deletePost(it.postId)
}
}
}

if (pagingItems.loadState.append !is LoadState.NotLoading) {
item(key = "", span = StaggeredGridItemSpan.FullLine) {
PageItemFooter(loadState = pagingItems.loadState.append) {
pagingItems.retry()
}
if (pagingItems.loadState.append !is LoadState.NotLoading) {
item(key = "", span = StaggeredGridItemSpan.FullLine) {
PageItemFooter(loadState = pagingItems.loadState.append) {
pagingItems.retry()
}
}
}
)
}
} else {
RestrictedLoginContent(navigateToLogin)
}
)
}

}

@Preview(showBackground = true)
Expand Down

0 comments on commit 81bb497

Please sign in to comment.