Skip to content
Open
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
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ dependencies {
implementation "com.google.accompanist:accompanist-navigation-animation:$accompanist"
implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist"

implementation platform("androidx.compose:compose-bom:$composeBom")
androidTestImplementation(platform("androidx.compose:compose-bom:$composeBom"))
implementation platform("dev.chrisbanes.compose:compose-bom:$composeBom")
androidTestImplementation(platform("dev.chrisbanes.compose:compose-bom:$composeBom"))

// https://developer.android.com/jetpack/androidx/releases/compose-animation
implementation "androidx.compose.animation:animation-graphics"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ fun RYOutlineTextField(

OutlinedTextField(
modifier = Modifier.focusRequester(focusRequester),
colors = TextFieldDefaults.textFieldColors(
containerColor = Color.Transparent,
colors = TextFieldDefaults.colors(
focusedContainerColor = Color.Transparent,
unfocusedContainerColor = Color.Transparent,
),
maxLines = if (singleLine) 1 else Int.MAX_VALUE,
enabled = !readOnly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fun RYScaffold(
title = {},
navigationIcon = { navigationIcon?.invoke() },
actions = { actions?.invoke(this) },
colors = TopAppBarDefaults.smallTopAppBarColors(
colors = TopAppBarDefaults.mediumTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
topBarTonalElevation
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ fun RYTextField(

TextField(
modifier = Modifier.focusRequester(focusRequester),
colors = TextFieldDefaults.textFieldColors(
containerColor = Color.Transparent,
colors = TextFieldDefaults.colors(
focusedContainerColor = Color.Transparent,
unfocusedTextColor = Color.Transparent,
),
maxLines = if (singleLine) 1 else Int.MAX_VALUE,
enabled = !readOnly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package me.ash.reader.ui.page.home.feeds.drawer.feed
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetState
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.ui.unit.Density
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -232,7 +233,10 @@ class FeedOptionViewModel @Inject constructor(

@OptIn(ExperimentalMaterialApi::class)
data class FeedOptionUiState(
var drawerState: ModalBottomSheetState = ModalBottomSheetState(ModalBottomSheetValue.Hidden),
var drawerState: ModalBottomSheetState = ModalBottomSheetState(
ModalBottomSheetValue.Hidden,
Density(0f, 1f)
),
val feed: Feed? = null,
val selectedGroupId: String = "",
val newGroupContent: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package me.ash.reader.ui.page.home.feeds.drawer.group
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetState
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.ui.unit.Density
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -196,7 +197,10 @@ class GroupOptionViewModel @Inject constructor(

@OptIn(ExperimentalMaterialApi::class)
data class GroupOptionUiState(
var drawerState: ModalBottomSheetState = ModalBottomSheetState(ModalBottomSheetValue.Hidden),
var drawerState: ModalBottomSheetState = ModalBottomSheetState(
ModalBottomSheetValue.Hidden,
Density(0f, 1f)
),
val group: Group? = null,
val targetGroup: Group? = null,
val groups: List<Group> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package me.ash.reader.ui.page.home.flow
import android.view.HapticFeedbackConstants
import androidx.compose.animation.Animatable
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.DecayAnimationSpec
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.exponentialDecay
import androidx.compose.animation.core.spring
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
Expand Down Expand Up @@ -240,6 +242,7 @@ private const val SwipeActionDelay = 300L
@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@Composable
fun SwipeableArticleItem(
modifier: Modifier = Modifier,
articleWithFeed: ArticleWithFeed,
isFilterUnread: Boolean = false,
articleListTonalElevation: Int = 0,
Expand Down Expand Up @@ -289,11 +292,13 @@ fun SwipeableArticleItem(
}
val velocityThreshold: () -> Float = { Float.POSITIVE_INFINITY }
val animationSpec: AnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow)
val decayAnimationSpec: DecayAnimationSpec<Float> = exponentialDecay()
val swipeState = rememberSaveable(
articleWithFeed.article, saver = SwipeToDismissBoxState.Saver(
confirmValueChange = confirmValueChange,
density = density,
animationSpec = animationSpec,
decayAnimationSpec = decayAnimationSpec,
velocityThreshold = velocityThreshold,
positionalThreshold = positionalThreshold
)
Expand Down Expand Up @@ -333,6 +338,7 @@ fun SwipeableArticleItem(
var menuOffset by remember { mutableStateOf(Offset(0f, 0f)) }

SwipeToDismissBox(
modifier = modifier,
state = swipeState,
enabled = !isSwipeEnabled(),
/*** create dismiss alert background box */
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fun LazyListScope.ArticleList(
is ArticleFlowItem.Article -> {
item(key = item.articleWithFeed.article.id) {
SwipeableArticleItem(
modifier = Modifier.animateItem(),
articleWithFeed = item.articleWithFeed,
isFilterUnread = isFilterUnread,
articleListTonalElevation = articleListTonalElevation,
Expand All @@ -51,11 +52,20 @@ fun LazyListScope.ArticleList(
if (item.showSpacer) item { Spacer(modifier = Modifier.height(40.dp)) }
if (isShowStickyHeader) {
stickyHeader(key = item.date) {
StickyHeader(item.date, isShowFeedIcon, articleListTonalElevation)
StickyHeader(
dateString = item.date,
isShowFeedIcon = isShowFeedIcon,
articleListTonalElevation = articleListTonalElevation
)
}
} else {
item(key = item.date) {
StickyHeader(item.date, isShowFeedIcon, articleListTonalElevation)
StickyHeader(
modifier = Modifier.animateItem(),
dateString = item.date,
isShowFeedIcon = isShowFeedIcon,
articleListTonalElevation = articleListTonalElevation
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import me.ash.reader.ui.theme.palette.onDark

@Composable
fun StickyHeader(
modifier: Modifier = Modifier,
dateString: String,
isShowFeedIcon: Boolean,
articleListTonalElevation: Int,
) {
Row(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.background(
MaterialTheme.colorScheme.surfaceColorAtElevation(articleListTonalElevation.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package me.ash.reader.ui.page.home.flow

import androidx.annotation.FloatRange
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.DecayAnimationSpec
import androidx.compose.animation.core.exponentialDecay
import androidx.compose.animation.core.spring
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.AnchoredDraggableState
Expand Down Expand Up @@ -88,13 +90,15 @@ class SwipeToDismissBoxState(
initialValue: SwipeToDismissBoxValue,
internal val density: Density,
animationSpec: AnimationSpec<Float> = spring(),
decayAnimationSpec: DecayAnimationSpec<Float> = exponentialDecay(),
confirmValueChange: (SwipeToDismissBoxValue) -> Boolean = { true },
velocityThreshold: () -> Float = { with(density) { DismissThreshold.toPx() } },
positionalThreshold: (totalDistance: Float) -> Float
) {
internal val anchoredDraggableState = AnchoredDraggableState(
initialValue = initialValue,
animationSpec = animationSpec,
snapAnimationSpec = animationSpec,
decayAnimationSpec = decayAnimationSpec,
confirmValueChange = confirmValueChange,
positionalThreshold = positionalThreshold,
velocityThreshold = velocityThreshold
Expand Down Expand Up @@ -200,6 +204,7 @@ class SwipeToDismissBoxState(
positionalThreshold: (totalDistance: Float) -> Float,
velocityThreshold: () -> Float,
animationSpec: AnimationSpec<Float>,
decayAnimationSpec: DecayAnimationSpec<Float>,
density: Density
) = Saver<SwipeToDismissBoxState, SwipeToDismissBoxValue>(
save = { it.currentValue },
Expand All @@ -208,6 +213,7 @@ class SwipeToDismissBoxState(
it,
density,
animationSpec,
decayAnimationSpec,
confirmValueChange,
velocityThreshold,
positionalThreshold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fun TopBar(
) {
sharedContent.share(context, title, link)
}
}, colors = TopAppBarDefaults.smallTopAppBarColors(
}, colors = TopAppBarDefaults.mediumTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(tonalElevation.value.dp),
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fun FeedsPagePreview(
contentDescription = stringResource(R.string.subscribe),
tint = MaterialTheme.colorScheme.onSurface,
)
}, colors = TopAppBarDefaults.smallTopAppBarColors(
}, colors = TopAppBarDefaults.mediumTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
topBarTonalElevation.value.dp
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fun FlowPagePreview(
contentDescription = stringResource(R.string.search),
tint = MaterialTheme.colorScheme.onSurface,
) {}
}, colors = TopAppBarDefaults.smallTopAppBarColors(
}, colors = TopAppBarDefaults.mediumTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(topBarTonalElevation.value.dp),
)
)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
// https://developer.android.com/jetpack/androidx/releases/compose-ui
// compose = '1.2.0-beta02'
// https://developer.android.com/jetpack/compose/bom
composeBom = '2024.01.00'
composeBom = '2024.05.00-alpha01'
// https://github.com/google/accompanist/releases
accompanist = '0.34.0'
// https://developer.android.com/jetpack/androidx/releases/compose-material3
Expand Down