Skip to content

Commit

Permalink
Reduce alpha of read items in home screen and search screen
Browse files Browse the repository at this point in the history
  • Loading branch information
msasikanth committed Jan 27, 2024
1 parent a33ba48 commit afbf2e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
Expand Down Expand Up @@ -71,7 +72,12 @@ internal fun FeaturedPostItem(
) {
val isLargeScreenLayout =
LocalWindowSizeClass.current.widthSizeClass == WindowWidthSizeClass.Expanded
Box(modifier = Modifier.clip(MaterialTheme.shapes.extraLarge).clickable(onClick = onClick)) {
Box(
modifier =
Modifier.clip(MaterialTheme.shapes.extraLarge)
.clickable(onClick = onClick)
.alpha(if (item.read) 0.65f else 1f)
) {
if (isLargeScreenLayout) {
LargeScreenFeaturedPostItem(
item = item,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
Expand Down Expand Up @@ -106,6 +107,7 @@ internal fun PostsList(
PostListItem(
item = post,
enablePostSource = true,
reduceReadItemAlpha = true,
onClick = { onPostClicked(post) },
onPostBookmarkClick = { onPostBookmarkClick(post) },
onPostCommentsClick = { onPostCommentsClick(post.commentsLink!!) },
Expand All @@ -130,13 +132,15 @@ fun PostListItem(
onClick: () -> Unit,
onPostBookmarkClick: () -> Unit,
onPostCommentsClick: () -> Unit,
onPostSourceClick: () -> Unit
onPostSourceClick: () -> Unit,
reduceReadItemAlpha: Boolean = false
) {
Column(
modifier =
Modifier.clickable(onClick = onClick)
.windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Horizontal))
.padding(postListPadding)
.alpha(if (item.read && reduceReadItemAlpha) 0.65f else 1f)
) {
Row(
modifier = Modifier.padding(start = 24.dp, top = 20.dp, end = 24.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ internal fun SearchScreen(searchPresenter: SearchPresenter, modifier: Modifier =
PostListItem(
item = post,
enablePostSource = false,
reduceReadItemAlpha = true,
onClick = { searchPresenter.dispatch(SearchEvent.OnPostClicked(post)) },
onPostBookmarkClick = {
searchPresenter.dispatch(SearchEvent.OnPostBookmarkClick(post))
Expand Down

0 comments on commit afbf2e2

Please sign in to comment.