Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class UserStorageActivity : ComponentActivity() {
::startActivity,
)
},
isMyLibrary = false,
onBackClick = ::finish,
)
}
}
Expand Down
3 changes: 3 additions & 0 deletions core/resource/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@
<string name="storage_watched">봤어요</string>
<string name="storage_quitting">하차</string>
<string name="storage_empty_status">서재가 비어있어요</string>
<string name="storage_other_user_empty_status">보관함이 비어있어요</string>
<string name="storage_explore_novel">작품 둘러보기</string>
<string name="storage_oldest">오래된 순</string>
<string name="storage_newest">최신 순</string>
Expand Down Expand Up @@ -481,6 +482,8 @@
<string name="feed_like_restore_failed_message">좋아요를 반영하는 데 문제가 생겼어요.</string>
<string name="feed_like_unrestored_message">좋아요 일부가 반영되지 않았을 수 있어요.</string>
<string name="library_filter_remove_selected_chip">필터 제거</string>
<string name="library_view_type_to_list">리스트로 보기</string>
<string name="library_view_type_to_grid">그리드로 보기</string>

<!-- 컬렉션 뷰 -->
<string name="collection_title">컬렉션</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import com.into.websoso.core.common.extensions.collectAsEventWithLifecycle
import com.into.websoso.core.designsystem.theme.White
import com.into.websoso.core.resource.R.string.storage_other_user_empty_status
import com.into.websoso.domain.library.model.AttractivePoint
import com.into.websoso.domain.library.model.Genre
import com.into.websoso.domain.library.model.ReadStatus
Expand All @@ -46,6 +47,7 @@ import com.into.websoso.feature.library.component.LibraryGridList
import com.into.websoso.feature.library.component.LibraryList
import com.into.websoso.feature.library.component.LibrarySortBottomSheet
import com.into.websoso.feature.library.component.LibraryTopBar
import com.into.websoso.feature.library.component.OtherUserLibraryTopBar
import com.into.websoso.feature.library.filter.LibraryFilterBottomSheetScreen
import com.into.websoso.feature.library.filter.LibraryFilterTab
import com.into.websoso.feature.library.model.LibraryFilterUiModel
Expand All @@ -62,6 +64,8 @@ fun LibraryScreen(
navigateToNovelDetailActivity: (novelId: Long) -> Unit,
libraryViewModel: LibraryViewModel,
navigateToNotificationSettingActivity: (() -> Unit)? = null,
isMyLibrary: Boolean = true,
onBackClick: () -> Unit = {},
) {
val scope = rememberCoroutineScope()
val uiState by libraryViewModel.uiState.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -105,7 +109,9 @@ fun LibraryScreen(
isShowBottomSheet = isShowBottomSheet,
isShowSortBottomSheet = isShowSortBottomSheet,
isNovelsRefreshing = isNovelsRefreshing,
isMyLibrary = isMyLibrary,
initialFilterTab = filterInitialTab,
onBackClick = onBackClick,
onDismissRequest = {
scope.launch {
isShowBottomSheet = false
Expand Down Expand Up @@ -180,7 +186,9 @@ private fun LibraryScreen(
isNovelsRefreshing: Boolean,
isShowBottomSheet: Boolean,
isShowSortBottomSheet: Boolean,
isMyLibrary: Boolean,
initialFilterTab: LibraryFilterTab,
onBackClick: () -> Unit,
onDismissRequest: () -> Unit,
onSortDismiss: () -> Unit,
onSortSelected: (SortCriteria) -> Unit,
Expand Down Expand Up @@ -210,20 +218,31 @@ private fun LibraryScreen(
.fillMaxSize()
.background(White),
) {
Spacer(modifier = Modifier.height(20.dp))
if (isMyLibrary) {
Spacer(modifier = Modifier.height(20.dp))

LibraryTopBar(onSearchClick = onSearchClick)
LibraryTopBar(onSearchClick = onSearchClick)

LibraryFilterTopBar(
libraryFilterUiModel = uiState.libraryFilterUiModel,
totalCount = uiState.novelTotalCount,
isGrid = uiState.isGrid,
onFilterClick = onFilterClick,
onSortClick = onSortClick,
onToggleViewType = onToggleViewType,
onInterestClick = onInterestClick,
onNotificationManageClick = onNotificationManageClick,
)
LibraryFilterTopBar(
libraryFilterUiModel = uiState.libraryFilterUiModel,
totalCount = uiState.novelTotalCount,
isGrid = uiState.isGrid,
onFilterClick = onFilterClick,
onSortClick = onSortClick,
onToggleViewType = onToggleViewType,
onInterestClick = onInterestClick,
onNotificationManageClick = onNotificationManageClick,
)
} else {
OtherUserLibraryTopBar(
totalCount = uiState.novelTotalCount,
sortCriteria = uiState.libraryFilterUiModel.sortCriteria,
isGrid = uiState.isGrid,
onBackClick = onBackClick,
onSortClick = onSortClick,
onToggleViewType = onToggleViewType,
)
}

PullToRefreshBox(
isRefreshing = isNovelsRefreshing,
Expand All @@ -236,10 +255,18 @@ private fun LibraryScreen(
novels.itemCount == 0 &&
novels.loadState.refresh !is Loading -> {
RefreshableContainer {
if (uiState.libraryFilterUiModel.isFilterApplied) {
LibraryFilterEmptyView()
} else {
LibraryEmptyView(onExploreClick = onExploreClick)
when {
!isMyLibrary -> {
LibraryEmptyView(messageRes = storage_other_user_empty_status)
}

uiState.libraryFilterUiModel.isFilterApplied -> {
LibraryFilterEmptyView()
}

else -> {
LibraryEmptyView(onExploreClick = onExploreClick)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.into.websoso.feature.library.component

import androidx.annotation.StringRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -29,7 +30,10 @@ import com.into.websoso.core.resource.R.string.storage_empty_status
import com.into.websoso.core.resource.R.string.storage_explore_novel

@Composable
internal fun LibraryEmptyView(onExploreClick: () -> Unit = {}) {
internal fun LibraryEmptyView(
@StringRes messageRes: Int = storage_empty_status,
onExploreClick: (() -> Unit)? = null,
) {
Box(
modifier = Modifier
.fillMaxSize(),
Expand All @@ -47,12 +51,14 @@ internal fun LibraryEmptyView(onExploreClick: () -> Unit = {}) {
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = stringResource(storage_empty_status),
text = stringResource(messageRes),
style = WebsosoTheme.typography.body1,
color = Gray200,
)
Spacer(modifier = Modifier.height(48.dp))
LibraryExploreButton(onClick = onExploreClick)
onExploreClick?.let { onClick ->
Spacer(modifier = Modifier.height(48.dp))
LibraryExploreButton(onClick = onClick)
}
Spacer(modifier = Modifier.weight(2f))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ private fun NovelFilterStatusBar(
}

@Composable
private fun StatusBarAction(
internal fun StatusBarAction(
@DrawableRes iconRes: Int,
iconSize: Dp,
text: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package com.into.websoso.feature.library.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.unit.dp
import com.into.websoso.core.common.extensions.debouncedClickable
import com.into.websoso.core.designsystem.theme.Black
import com.into.websoso.core.designsystem.theme.Gray100
import com.into.websoso.core.designsystem.theme.Gray200
import com.into.websoso.core.designsystem.theme.WebsosoTheme
import com.into.websoso.core.resource.R.drawable.ic_library_grid
import com.into.websoso.core.resource.R.drawable.ic_library_list
import com.into.websoso.core.resource.R.drawable.ic_library_sort
import com.into.websoso.core.resource.R.drawable.ic_navigate_left
import com.into.websoso.core.resource.R.string.collection_back
import com.into.websoso.core.resource.R.string.library_view_type_to_grid
import com.into.websoso.core.resource.R.string.library_view_type_to_list
import com.into.websoso.domain.library.model.SortCriteria

/**
* 타유저 서재 상단 영역입니다.
*
* 내 서재와 달리 검색, 필터 칩, 알림 관리 없이 뒤로가기와 타이틀, 작품 개수, 정렬, 보기 전환만 보여줍니다.
*/
@Composable
internal fun OtherUserLibraryTopBar(
totalCount: Long,
sortCriteria: SortCriteria,
isGrid: Boolean,
onBackClick: () -> Unit,
onSortClick: () -> Unit,
onToggleViewType: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(modifier = modifier.fillMaxWidth()) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(44.dp),
contentAlignment = Alignment.Center,
) {
Box(
modifier = Modifier
.align(Alignment.CenterStart)
.padding(start = 6.dp)
.size(44.dp)
.debouncedClickable(
onClickLabel = stringResource(id = collection_back),
role = Role.Button,
onClick = onBackClick,
),
contentAlignment = Alignment.Center,
) {
Image(
imageVector = ImageVector.vectorResource(id = ic_navigate_left),
contentDescription = null,
)
}

Text(
text = "서재",
style = WebsosoTheme.typography.title2,
color = Black,
)
}

Row(
modifier = Modifier
.fillMaxWidth()
.height(40.dp)
.padding(horizontal = 20.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Text(
text = "${totalCount}개",
style = WebsosoTheme.typography.body4,
color = Gray200,
)

Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(10.dp),
) {
StatusBarAction(
iconRes = ic_library_sort,
iconSize = 16.dp,
text = sortCriteria.label,
onClick = onSortClick,
)

Box(
modifier = Modifier
.size(33.dp)
.debouncedClickable(
onClickLabel = stringResource(
id = if (isGrid) library_view_type_to_list else library_view_type_to_grid,
),
role = Role.Button,
onClick = onToggleViewType,
),
contentAlignment = Alignment.CenterEnd,
) {
Icon(
imageVector = ImageVector.vectorResource(
id = if (isGrid) ic_library_grid else ic_library_list,
),
contentDescription = null,
tint = Gray100,
)
}
}
}
}
}
Loading