🛠️ Add .noRippleClickable()
* Added new ".noRippleClickable()" Modifier extension
This commit is contained in:
parent
e70848a9cf
commit
1d713b6ab4
13 changed files with 47 additions and 64 deletions
|
|
@ -2,6 +2,9 @@ package ua.acclorite.book_story.presentation.core.util
|
|||
|
||||
import android.content.Intent
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
fun String.removeTrailingZero(): String {
|
||||
if (!this.contains('.'))
|
||||
|
|
@ -41,4 +44,21 @@ fun Float.calculateProgress(digits: Int): String {
|
|||
.removeDigits(digits)
|
||||
.removeTrailingZero()
|
||||
.dropWhile { it == '-' }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
fun Modifier.noRippleClickable(
|
||||
enabled: Boolean = true,
|
||||
onLongClick: (() -> Unit)? = null,
|
||||
onDoubleClick: (() -> Unit)? = null,
|
||||
onClick: () -> Unit
|
||||
): Modifier {
|
||||
return this.combinedClickable(
|
||||
indication = null,
|
||||
interactionSource = null,
|
||||
enabled = enabled,
|
||||
onLongClick = onLongClick,
|
||||
onDoubleClick = onDoubleClick,
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.book_info.components
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
|
@ -26,12 +23,12 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.core.components.LocalBookInfoViewModel
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoEvent
|
||||
|
||||
/**
|
||||
* Description section.
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun BookInfoDescriptionSection() {
|
||||
val state = LocalBookInfoViewModel.current.state
|
||||
|
|
@ -48,9 +45,7 @@ fun BookInfoDescriptionSection() {
|
|||
textAlign = TextAlign.Start,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 24.dp)
|
||||
.combinedClickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null,
|
||||
.noRippleClickable(
|
||||
onClick = {},
|
||||
onLongClick = {
|
||||
onEvent(BookInfoEvent.OnShowHideEditDescription)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
package ua.acclorite.book_story.presentation.screens.book_info.components
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
|
|
@ -40,12 +37,12 @@ import androidx.compose.ui.unit.dp
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.core.components.CustomCoverImage
|
||||
import ua.acclorite.book_story.presentation.core.components.LocalBookInfoViewModel
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoEvent
|
||||
|
||||
/**
|
||||
* BookInfo's Info section.
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun BookInfoInfoSection() {
|
||||
val state = LocalBookInfoViewModel.current.state
|
||||
|
|
@ -68,9 +65,7 @@ fun BookInfoInfoSection() {
|
|||
MaterialTheme.colorScheme.surfaceContainerLow,
|
||||
MaterialTheme.shapes.medium
|
||||
)
|
||||
.combinedClickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null,
|
||||
.noRippleClickable(
|
||||
onClick = {},
|
||||
onLongClick = {
|
||||
onEvent(BookInfoEvent.OnShowHideChangeCoverBottomSheet)
|
||||
|
|
@ -107,9 +102,7 @@ fun BookInfoInfoSection() {
|
|||
style = MaterialTheme.typography.headlineSmall,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.combinedClickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null,
|
||||
.noRippleClickable(
|
||||
onClick = {},
|
||||
onLongClick = {
|
||||
onEvent(BookInfoEvent.OnShowHideEditTitle)
|
||||
|
|
@ -164,9 +157,7 @@ fun BookInfoInfoSection() {
|
|||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.combinedClickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null,
|
||||
.noRippleClickable(
|
||||
onClick = {},
|
||||
onLongClick = {
|
||||
onEvent(BookInfoEvent.OnShowHideEditAuthor)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package ua.acclorite.book_story.presentation.screens.browse.components.layout.grid
|
||||
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
|
|
@ -29,6 +28,7 @@ import androidx.compose.ui.unit.sp
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.domain.model.SelectableFile
|
||||
import ua.acclorite.book_story.presentation.core.components.CustomCheckbox
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.ui.DefaultTransition
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
|
@ -93,11 +93,7 @@ fun BrowseGridDirectoryItem(
|
|||
),
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.clickable(
|
||||
enabled = !hasSelectedFiles,
|
||||
interactionSource = null,
|
||||
indication = null
|
||||
) {
|
||||
.noRippleClickable(enabled = !hasSelectedFiles) {
|
||||
onFavoriteClick()
|
||||
},
|
||||
tint = if (file.isFavorite) MaterialTheme.colorScheme.primary
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package ua.acclorite.book_story.presentation.screens.browse.components.layout.li
|
|||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
|
|
@ -28,6 +27,7 @@ import androidx.compose.ui.unit.dp
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.domain.model.SelectableFile
|
||||
import ua.acclorite.book_story.presentation.core.components.CustomCheckbox
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.ui.FadeTransitionPreservingSpace
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
|
|
@ -112,11 +112,7 @@ fun BrowseListItem(
|
|||
),
|
||||
modifier = Modifier
|
||||
.size(24.dp)
|
||||
.clickable(
|
||||
enabled = !hasSelectedFiles,
|
||||
interactionSource = null,
|
||||
indication = null
|
||||
) {
|
||||
.noRippleClickable(enabled = !hasSelectedFiles) {
|
||||
onFavoriteClick()
|
||||
},
|
||||
tint = if (file.isFavorite) MaterialTheme.colorScheme.primary
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import android.os.Environment
|
|||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.expandVertically
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
|
|
@ -30,6 +29,7 @@ import ua.acclorite.book_story.presentation.core.components.CustomAnimatedVisibi
|
|||
import ua.acclorite.book_story.presentation.core.components.LocalBrowseViewModel
|
||||
import ua.acclorite.book_story.presentation.core.components.LocalMainViewModel
|
||||
import ua.acclorite.book_story.presentation.core.components.customItemsIndexed
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.screens.browse.data.BrowseEvent
|
||||
import ua.acclorite.book_story.presentation.screens.settings.nested.browse.data.BrowseFilesStructure
|
||||
import java.io.File
|
||||
|
|
@ -112,10 +112,8 @@ fun BrowseTopBarDirectoryPath() {
|
|||
label = ""
|
||||
).value,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.clickable(
|
||||
enabled = state.value.selectedDirectory != directory.second,
|
||||
indication = null,
|
||||
interactionSource = null
|
||||
modifier = Modifier.noRippleClickable(
|
||||
enabled = state.value.selectedDirectory != directory.second
|
||||
) {
|
||||
onEvent(
|
||||
BrowseEvent.OnChangeDirectory(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.help.components
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
|
|
@ -20,6 +19,7 @@ import androidx.compose.ui.text.AnnotatedString
|
|||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.core.components.CustomTooltip
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.ui.ExpandingTransition
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +38,7 @@ fun HelpClickableNote(text: AnnotatedString) {
|
|||
imageVector = Icons.Outlined.Info,
|
||||
modifier = Modifier
|
||||
.size(20.dp)
|
||||
.clickable(interactionSource = null, indication = null) {
|
||||
.noRippleClickable {
|
||||
showNote.value = !showNote.value
|
||||
},
|
||||
contentDescription = stringResource(R.string.note_content_desc),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import androidx.compose.animation.animateColorAsState
|
|||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
|
|
@ -32,6 +31,7 @@ import androidx.compose.ui.unit.dp
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.domain.model.HelpTip
|
||||
import ua.acclorite.book_story.presentation.core.navigation.LocalOnNavigate
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.ui.ExpandingTransition
|
||||
|
||||
/**
|
||||
|
|
@ -83,7 +83,7 @@ fun HelpItem(
|
|||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(interactionSource = null, indication = null) {
|
||||
.noRippleClickable {
|
||||
showDescription.value = !showDescription.value
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import ua.acclorite.book_story.R
|
|||
import ua.acclorite.book_story.domain.model.History
|
||||
import ua.acclorite.book_story.presentation.core.components.CustomCoverImage
|
||||
import ua.acclorite.book_story.presentation.core.components.CustomIconButton
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
|
@ -121,9 +122,7 @@ fun HistoryItem(
|
|||
lineHeight = 21.sp,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(
|
||||
interactionSource = null,
|
||||
indication = null,
|
||||
.noRippleClickable(
|
||||
enabled = isOnClickEnabled,
|
||||
onClick = onTitleClick
|
||||
),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import androidx.compose.animation.animateColorAsState
|
|||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.animation.slideOutVertically
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
|
|
@ -73,6 +72,7 @@ import ua.acclorite.book_story.presentation.core.components.is_messages.IsError
|
|||
import ua.acclorite.book_story.presentation.core.constants.Constants
|
||||
import ua.acclorite.book_story.presentation.core.navigation.LocalOnNavigate
|
||||
import ua.acclorite.book_story.presentation.core.navigation.Screen
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.core.util.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
|
|
@ -416,9 +416,7 @@ private fun ReaderScreen(lazyListState: LazyListState) {
|
|||
.then(
|
||||
if (!state.value.loading && toolbarHidden) {
|
||||
Modifier
|
||||
.clickable(
|
||||
interactionSource = null,
|
||||
indication = null,
|
||||
.noRippleClickable(
|
||||
onClick = {
|
||||
onEvent(
|
||||
ReaderEvent.OnShowHideMenu(
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package ua.acclorite.book_story.presentation.screens.reader.components
|
|||
|
||||
import android.content.Context
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
|
@ -24,6 +22,7 @@ import androidx.compose.ui.unit.TextUnit
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.domain.model.FontWithName
|
||||
import ua.acclorite.book_story.presentation.core.components.LocalReaderViewModel
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.core.util.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||
import ua.acclorite.book_story.presentation.screens.settings.nested.reader.data.ReaderTextAlignment
|
||||
|
|
@ -46,7 +45,6 @@ import ua.acclorite.book_story.presentation.screens.settings.nested.reader.data.
|
|||
* @param doubleClickTranslationEnabled Whether Double Click Translation is enabled.
|
||||
* @param toolbarHidden Whether selection toolBar is hidden.
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun LazyItemScope.ReaderTextParagraph(
|
||||
line: String,
|
||||
|
|
@ -87,9 +85,7 @@ fun LazyItemScope.ReaderTextParagraph(
|
|||
doubleClickTranslationEnabled &&
|
||||
toolbarHidden
|
||||
) {
|
||||
Modifier.combinedClickable(
|
||||
interactionSource = null,
|
||||
indication = null,
|
||||
Modifier.noRippleClickable(
|
||||
onDoubleClick = {
|
||||
onEvent(
|
||||
ReaderEvent.OnOpenTranslator(
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import androidx.compose.animation.shrinkHorizontally
|
|||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
|
|
@ -43,6 +42,7 @@ import ua.acclorite.book_story.presentation.core.components.LocalHistoryViewMode
|
|||
import ua.acclorite.book_story.presentation.core.components.LocalLibraryViewModel
|
||||
import ua.acclorite.book_story.presentation.core.components.LocalReaderViewModel
|
||||
import ua.acclorite.book_story.presentation.core.util.calculateProgress
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||
|
|
@ -86,11 +86,7 @@ fun ReaderBottomBar() {
|
|||
Modifier
|
||||
.fillMaxWidth()
|
||||
.background(Colors.readerSystemBarsColor)
|
||||
.clickable(
|
||||
interactionSource = null,
|
||||
indication = null,
|
||||
onClick = {}
|
||||
)
|
||||
.noRippleClickable(onClick = {})
|
||||
.navigationBarsPadding()
|
||||
.padding(horizontal = 18.dp)
|
||||
.padding(top = 16.dp),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package ua.acclorite.book_story.presentation.screens.reader.components.app_bar
|
|||
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.foundation.basicMarquee
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material.icons.Icons
|
||||
|
|
@ -27,6 +26,7 @@ import ua.acclorite.book_story.presentation.core.components.LocalLibraryViewMode
|
|||
import ua.acclorite.book_story.presentation.core.components.LocalReaderViewModel
|
||||
import ua.acclorite.book_story.presentation.core.navigation.LocalOnNavigate
|
||||
import ua.acclorite.book_story.presentation.core.navigation.Screen
|
||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||
|
|
@ -79,10 +79,8 @@ fun ReaderTopBar() {
|
|||
color = MaterialTheme.colorScheme.onSurface,
|
||||
maxLines = 1,
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
.noRippleClickable(
|
||||
enabled = !state.value.lockMenu,
|
||||
interactionSource = null,
|
||||
indication = null,
|
||||
onClick = {
|
||||
onEvent(
|
||||
ReaderEvent.OnGoBack(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue