Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the item swipe design more universal #463

Merged
merged 1 commit into from
Sep 15, 2023
Merged
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
30 changes: 20 additions & 10 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 @@ -26,7 +26,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
Expand All @@ -39,6 +38,8 @@ import me.ash.reader.ui.component.FeedIcon
import me.ash.reader.ui.component.base.RYAsyncImage
import me.ash.reader.ui.component.base.SIZE_1000
import me.ash.reader.ui.theme.Shape20
import me.ash.reader.data.model.preference.LocalDarkTheme
import me.ash.reader.data.model.preference.LocalAmoledDarkTheme

@Composable
fun ArticleItem(
Expand Down Expand Up @@ -183,28 +184,25 @@ fun swipeToDismiss(
if (isArticleVisible) {
SwipeToDismiss(
state = dismissState,
/*** create dismiss alert Background */
/*** create dismiss alert background box */
background = {
val color = Color.Gray

if (dismissState.dismissDirection == DismissDirection.StartToEnd) {
Box(
modifier = Modifier
.fillMaxSize()
.background(color)
.padding(8.dp)
.padding(12.dp)
) {
Column(modifier = Modifier.align(Alignment.CenterStart)) {
Icon(
imageVector = Icons.Default.Check,
contentDescription = null,
tint = Color.White,
tint = MaterialTheme.colorScheme.inverseSurface,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Text(
text = "Mark Read", fontWeight = FontWeight.Bold,
text = "Mark Read",
textAlign = TextAlign.Center,
color = Color.White
color = MaterialTheme.colorScheme.inverseSurface
)
}

Expand All @@ -213,7 +211,19 @@ fun swipeToDismiss(
},
/**** Dismiss Content */
dismissContent = {
ArticleItem(articleWithFeed, onClick)
val isDarkTheme = LocalDarkTheme.current.isDarkTheme()
val isAmoledDarkTheme = LocalAmoledDarkTheme.current.value

val articleItemBackgroundColor = if (isDarkTheme && isAmoledDarkTheme) {Color.Black}
else {MaterialTheme.colorScheme.background}

Box(
modifier = Modifier
.fillMaxSize()
.background(articleItemBackgroundColor)
) {
ArticleItem(articleWithFeed, onClick)
}
},
/*** Set Direction to dismiss */
directions = setOf(DismissDirection.StartToEnd),
Expand Down