Skip to content

Commit

Permalink
only swipe to remove artile with unread filter
Browse files Browse the repository at this point in the history
  • Loading branch information
aeghn committed Oct 18, 2023
1 parent a3c8ec2 commit c35fe96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,18 @@ fun ArticleItem(
@ExperimentalMaterialApi
@Composable
fun swipeToDismiss(
articleWithFeed: ArticleWithFeed,
onClick: (ArticleWithFeed) -> Unit = {},
onSwipeOut: (ArticleWithFeed) -> Unit = {},
articleWithFeed: ArticleWithFeed,
isFilterUnread: Boolean,
onClick: (ArticleWithFeed) -> Unit = {},
onSwipeOut: (ArticleWithFeed) -> Unit = {},
) {
var isArticleVisible by remember { mutableStateOf(true) }
val dismissState = rememberDismissState(initialValue = DismissValue.Default, confirmStateChange = {
if (it == DismissValue.DismissedToEnd) {
isArticleVisible = false
isArticleVisible = !isFilterUnread
onSwipeOut(articleWithFeed)
}
true
isFilterUnread
})
if (isArticleVisible) {
SwipeToDismiss(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import me.ash.reader.domain.model.article.ArticleWithFeed
@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterialApi::class)
fun LazyListScope.ArticleList(
pagingItems: LazyPagingItems<ArticleFlowItem>,
isFilterUnread: Boolean,
isShowFeedIcon: Boolean,
isShowStickyHeader: Boolean,
articleListTonalElevation: Int,
Expand All @@ -27,6 +28,7 @@ fun LazyListScope.ArticleList(
item(key = item.articleWithFeed.article.id) {
swipeToDismiss(
articleWithFeed = (pagingItems[index] as ArticleFlowItem.Article).articleWithFeed,
isFilterUnread = isFilterUnread,
onClick = { onClick(it) },
onSwipeOut = { onSwipeOut(it) }
)
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/me/ash/reader/ui/page/home/flow/FlowPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import androidx.work.WorkInfo
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import me.ash.reader.R
import me.ash.reader.domain.model.article.ArticleFlowItem
import me.ash.reader.domain.model.general.Filter
import me.ash.reader.domain.model.general.MarkAsReadConditions
import me.ash.reader.infrastructure.preference.*
import me.ash.reader.ui.component.FilterBar
Expand Down Expand Up @@ -232,6 +234,7 @@ fun FlowPage(
}
ArticleList(
pagingItems = pagingItems,
isFilterUnread = filterUiState.filter == Filter.Unread,
isShowFeedIcon = articleListFeedIcon.value,
isShowStickyHeader = articleListDateStickyHeader.value,
articleListTonalElevation = articleListTonalElevation.value,
Expand Down

0 comments on commit c35fe96

Please sign in to comment.