Skip to content

Commit

Permalink
only swipe to remove artile with unread filter
Browse files Browse the repository at this point in the history
(cherry picked from commit c35fe96)
  • Loading branch information
aeghn authored and mbestavros committed Jan 17, 2024
1 parent 169a7b1 commit 2b43ce2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,17 @@ fun ArticleItem(
@Composable
fun SwipeableArticleItem(
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) {
SwipeableArticleItem(
articleWithFeed = item.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 2b43ce2

Please sign in to comment.