Skip to content
Closed
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 @@ -20,6 +20,7 @@ data class FeedModel(
) {
val formattedCreatedDate: String = " · $createdDate"
val isEmptyOfRelevantCategories: Boolean = relevantCategories.isEmpty()
val isVisible: Boolean get() = !isSpoiler && imageUrls.isNotEmpty()

data class UserModel(
val id: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class LibraryFragment : Fragment() {
}
}

override fun onResume() {
super.onResume()
libraryViewModel.refreshLibrary()
}

companion object {
const val TAG = "LibraryFragment"
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/item_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
android:layout_marginHorizontal="14dp"
android:layout_marginTop="20dp"
app:cornerRadius="@{8f}"
app:isVisible="@{!feed.imageUrls.empty}"
app:isVisible="@{feed.visible}"
app:layout_constraintBottom_toTopOf="@id/cl_feed_novel_info"
app:layout_constraintDimensionRatio="334:236"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -150,7 +150,7 @@
android:text="@{String.valueOf(feed.imageCount)}"
android:textAppearance="@style/body3"
android:textColor="@color/white"
app:isVisible="@{!feed.imageUrls.empty}"
app:isVisible="@{feed.visible}"
app:layout_constraintBottom_toBottomOf="@id/iv_feed_image"
app:layout_constraintEnd_toEndOf="@id/iv_feed_image"
tools:text="0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.into.websoso.core.common.extensions

import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.Role

@Composable
fun Modifier.clickableWithoutRipple(
enabled: Boolean = true,
onClickLabel: String? = null,
role: Role? = null,
onClick: () -> Unit,
) = clickable(
enabled = enabled,
onClickLabel = onClickLabel,
role = role,
indication = null,
interactionSource = remember { MutableInteractionSource() },
onClick = onClick,
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ internal class DefaultLibraryLocalDataSource
override suspend fun insertNovel(novel: NovelEntity) {
novelDao.apply {
val novelIndex = selectNovelByUserNovelId(novel.userNovelId)?.sortIndex ?: 0

if (novel.readStatus.isEmpty() && novel.isInterest.not()) {
deleteNovel(novelId = novel.novelId)
return
}

insertNovel(novel.toNovelDatabase(novelIndex))
}
}
Expand All @@ -56,7 +62,23 @@ internal class DefaultLibraryLocalDataSource
}

override suspend fun deleteNovel(novelId: Long) {
novelDao.deleteNovel(novelId)
val existedNovel = novelDao.selectNovelByNovelId(novelId) ?: return

novelDao.apply {
if (existedNovel.isInterest) {
val updatedNovel = existedNovel.copy(
readStatus = "",
userNovelRating = 0.0f,
attractivePoints = emptyList(),
startDate = "",
endDate = "",
keywords = emptyList(),
)
insertNovel(updatedNovel)
} else {
deleteNovel(novelId)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import kotlinx.coroutines.flow.Flow
interface LibraryRepository {
val libraryFlow: Flow<PagingData<NovelEntity>>

suspend fun refresh()

companion object {
const val PAGE_SIZE = 20
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class MyLibraryRepository
).flow
}

override suspend fun refresh() {
libraryLocalDataSource.selectAllNovels().invalidate()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:indent reported by reviewdog 🐶
Unexpected indentation (11) (should be 12)

}

suspend fun deleteAllNovels() {
libraryLocalDataSource.deleteAllNovels()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ internal class UserLibraryRepository
).flow
}

override suspend fun refresh() {
}

private suspend fun getUserNovels(
lastUserNovelId: Long,
libraryFilter: LibraryFilter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import javax.inject.Inject
class LibraryViewModel
@Inject
constructor(
libraryRepository: LibraryRepository,
private val libraryRepository: LibraryRepository,
private val filterRepository: FilterRepository,
) : ViewModel() {
private val _uiState = MutableStateFlow(LibraryUiState())
Expand Down Expand Up @@ -74,6 +74,10 @@ class LibraryViewModel
}
}

fun refreshLibrary() {
viewModelScope.launch { libraryRepository.refresh() }
}

fun updateViewType() {
_uiState.update {
it.copy(isGrid = !it.isGrid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.into.websoso.feature.library.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -28,6 +27,7 @@ import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.into.websoso.core.common.extensions.clickableWithoutRipple
import com.into.websoso.core.designsystem.component.NetworkImage
import com.into.websoso.core.designsystem.theme.Black
import com.into.websoso.core.designsystem.theme.Gray200
Expand Down Expand Up @@ -59,7 +59,7 @@ internal fun NovelGridListItem(
modifier = modifier
.width(itemSize.width)
.wrapContentHeight()
.clickable { onItemClick() },
.clickableWithoutRipple { onItemClick() },
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
NovelGridThumbnail(
Expand Down Expand Up @@ -139,7 +139,8 @@ private fun ReadStatusBadge(
.background(
color = readStatusUiModel.backgroundColor,
shape = RoundedCornerShape(4.dp),
).padding(vertical = 4.dp),
)
.padding(vertical = 4.dp),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:chain-method-continuation reported by reviewdog 🐶
Unexpected newline before '.'

contentAlignment = Alignment.Center,
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.into.websoso.feature.library.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -34,6 +33,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.into.websoso.core.common.extensions.clickableWithoutRipple
import com.into.websoso.core.designsystem.theme.Black
import com.into.websoso.core.designsystem.theme.Gray200
import com.into.websoso.core.designsystem.theme.Gray300
Expand Down Expand Up @@ -72,7 +72,7 @@ internal fun LibraryListItem(
Column(
modifier = modifier
.fillMaxWidth()
.clickable { onClick() },
.clickableWithoutRipple { onClick() },
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Row(
Expand Down Expand Up @@ -162,7 +162,8 @@ private fun ReadStatusBadge(
.background(
color = it.backgroundColor,
shape = RoundedCornerShape(8.dp),
).padding(vertical = 4.dp),
)
.padding(vertical = 4.dp),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:chain-method-continuation reported by reviewdog 🐶
Unexpected newline before '.'

contentAlignment = Alignment.Center,
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.into.websoso.feature.library.component
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -29,6 +28,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import com.into.websoso.core.common.extensions.clickableWithoutRipple
import com.into.websoso.core.designsystem.theme.Black
import com.into.websoso.core.designsystem.theme.Gray200
import com.into.websoso.core.designsystem.theme.Gray300
Expand Down Expand Up @@ -137,7 +137,7 @@ private fun NovelFilterChip(
shape = RoundedCornerShape(20.dp),
modifier = Modifier
.defaultMinSize(minHeight = 32.dp)
.clickable(onClick = onClick),
.clickableWithoutRipple(onClick = onClick),
border = if (!isSelected) BorderStroke(1.dp, Gray70) else null,
) {
Row(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.into.websoso.feature.library.filter.component

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.IntrinsicSize
Expand All @@ -20,6 +19,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.into.websoso.core.common.extensions.clickableWithoutRipple
import com.into.websoso.core.designsystem.theme.Gray300
import com.into.websoso.core.designsystem.theme.Gray50
import com.into.websoso.core.designsystem.theme.Primary100
Expand All @@ -44,7 +44,7 @@ internal fun LibraryFilterBottomSheetButtons(
modifier = Modifier
.fillMaxHeight()
.background(color = Gray50)
.clickable { onResetClick() }
.clickableWithoutRipple { onResetClick() }
.padding(
vertical = 20.dp,
horizontal = 34.dp,
Expand All @@ -66,7 +66,7 @@ internal fun LibraryFilterBottomSheetButtons(
modifier = Modifier
.fillMaxHeight()
.background(color = Primary100)
.clickable { onFilterSearchClick() }
.clickableWithoutRipple { onFilterSearchClick() }
.padding(vertical = 20.dp)
.weight(weight = 1f),
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.into.websoso.feature.library.filter.component

import androidx.annotation.DrawableRes
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
Expand All @@ -17,6 +16,7 @@ import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.into.websoso.core.common.extensions.clickableWithoutRipple
import com.into.websoso.core.designsystem.theme.Gray100
import com.into.websoso.core.designsystem.theme.Gray300
import com.into.websoso.core.designsystem.theme.Primary100
Expand All @@ -35,7 +35,7 @@ internal fun LibraryFilterBottomSheetClickableItem(
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.clickable(onClick = onClick)
.clickableWithoutRipple(onClick = onClick)
.padding(horizontal = horizontalPadding),
) {
Icon(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.into.websoso.feature.library.filter.component

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
Expand All @@ -15,6 +14,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.into.websoso.core.common.extensions.clickableWithoutRipple
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_cancel_modal
Expand All @@ -38,7 +38,7 @@ internal fun LibraryFilterBottomSheetHeader(
Box(
modifier = Modifier
.padding(vertical = 20.dp)
.clickable {
.clickableWithoutRipple {
onDismissRequest()
},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.into.websoso.feature.library.filter.component

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -16,6 +15,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.into.websoso.core.common.extensions.clickableWithoutRipple
import com.into.websoso.core.designsystem.theme.Gray300
import com.into.websoso.core.designsystem.theme.Gray50
import com.into.websoso.core.designsystem.theme.Primary100
Expand Down Expand Up @@ -47,7 +47,7 @@ internal fun LibraryFilterBottomSheetNovelRatingGrid(
title = "3.5 이상",
modifier = Modifier
.weight(weight = 1f)
.clickable {
.clickableWithoutRipple {
onRatingClick(THREE_POINT_FIVE)
},
isSelected = selectedRating.isCloseTo(THREE_POINT_FIVE),
Expand All @@ -56,7 +56,7 @@ internal fun LibraryFilterBottomSheetNovelRatingGrid(
title = "4.0 이상",
modifier = Modifier
.weight(weight = 1f)
.clickable {
.clickableWithoutRipple {
onRatingClick(FOUR)
},
isSelected = selectedRating.isCloseTo(FOUR),
Expand All @@ -71,7 +71,7 @@ internal fun LibraryFilterBottomSheetNovelRatingGrid(
title = "4.5 이상",
modifier = Modifier
.weight(weight = 1f)
.clickable {
.clickableWithoutRipple {
onRatingClick(FOUR_POINT_FIVE)
},
isSelected = selectedRating.isCloseTo(FOUR_POINT_FIVE),
Expand All @@ -80,7 +80,7 @@ internal fun LibraryFilterBottomSheetNovelRatingGrid(
title = "4.8 이상",
modifier = Modifier
.weight(weight = 1f)
.clickable {
.clickableWithoutRipple {
onRatingClick(FOUR_POINT_EIGHT)
},
isSelected = selectedRating.isCloseTo(FOUR_POINT_EIGHT),
Expand All @@ -102,7 +102,8 @@ private fun NovelRatingItem(
.background(
color = backgroundColor,
shape = RoundedCornerShape(size = 8.dp),
).then(
)
.then(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:chain-method-continuation reported by reviewdog 🐶
Unexpected newline before '.'

if (isSelected) {
Modifier.border(
width = 1.dp,
Expand All @@ -112,7 +113,8 @@ private fun NovelRatingItem(
} else {
Modifier
},
).padding(vertical = 14.dp, horizontal = 24.dp),
)
.padding(vertical = 14.dp, horizontal = 24.dp),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:chain-method-continuation reported by reviewdog 🐶
Unexpected newline before '.'

contentAlignment = Alignment.Center,
) {
Text(
Expand Down
Loading