Add back haptic feedback long tap to fav

- add back haptic when long tap on manga to add to library
This commit is contained in:
Riztard 2022-11-02 16:37:07 +07:00
parent 1e93d785e5
commit 81486e30e9
3 changed files with 24 additions and 3 deletions

View file

@ -8,6 +8,8 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.paging.LoadState
@ -65,6 +67,8 @@ fun BrowseSourceComfortableGridItem(
onClick: () -> Unit = {},
onLongClick: () -> Unit = onClick,
) {
val haptic = LocalHapticFeedback.current
MangaComfortableGridItem(
title = manga.title,
coverData = MangaCover(
@ -80,7 +84,10 @@ fun BrowseSourceComfortableGridItem(
Badge(text = stringResource(R.string.in_library))
}
},
onLongClick = onLongClick,
onLongClick = {
onLongClick()
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
},
onClick = onClick,
)
}

View file

@ -8,6 +8,8 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.paging.LoadState
@ -65,6 +67,8 @@ private fun BrowseSourceCompactGridItem(
onClick: () -> Unit = {},
onLongClick: () -> Unit = onClick,
) {
val haptic = LocalHapticFeedback.current
MangaCompactGridItem(
title = manga.title,
coverData = MangaCover(
@ -80,7 +84,10 @@ private fun BrowseSourceCompactGridItem(
Badge(text = stringResource(R.string.in_library))
}
},
onLongClick = onLongClick,
onLongClick = {
onLongClick()
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
},
onClick = onClick,
)
}

View file

@ -4,6 +4,8 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.paging.LoadState
@ -59,6 +61,8 @@ fun BrowseSourceListItem(
onClick: () -> Unit = {},
onLongClick: () -> Unit = onClick,
) {
val haptic = LocalHapticFeedback.current
MangaListItem(
title = manga.title,
coverData = MangaCover(
@ -74,7 +78,10 @@ fun BrowseSourceListItem(
Badge(text = stringResource(R.string.in_library))
}
},
onLongClick = onLongClick,
onLongClick = {
onLongClick()
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
},
onClick = onClick,
)
}