mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 11:34:18 +08:00
feat: add onLongClick in ItemBox
This commit is contained in:
@@ -45,7 +45,7 @@ import com.highcapable.betterandroid.compose.extension.ui.componentState
|
|||||||
import com.highcapable.flexiui.ColorsDescriptor
|
import com.highcapable.flexiui.ColorsDescriptor
|
||||||
import com.highcapable.flexiui.SizesDescriptor
|
import com.highcapable.flexiui.SizesDescriptor
|
||||||
import com.highcapable.flexiui.TypographyDescriptor
|
import com.highcapable.flexiui.TypographyDescriptor
|
||||||
import com.highcapable.flexiui.component.interaction.rippleClickable
|
import com.highcapable.flexiui.component.interaction.rippleCombinedClickable
|
||||||
import com.highcapable.flexiui.resources.FlexiIcons
|
import com.highcapable.flexiui.resources.FlexiIcons
|
||||||
import com.highcapable.flexiui.resources.icon.ArrowForward
|
import com.highcapable.flexiui.resources.icon.ArrowForward
|
||||||
import com.highcapable.flexiui.toColor
|
import com.highcapable.flexiui.toColor
|
||||||
@@ -84,6 +84,7 @@ data class ItemBoxStyle(
|
|||||||
* Flexi UI horizontal item box.
|
* Flexi UI horizontal item box.
|
||||||
* @see VerticalItemBox
|
* @see VerticalItemBox
|
||||||
* @param onClick the callback when item is clicked.
|
* @param onClick the callback when item is clicked.
|
||||||
|
* @param onLongClick the callback when item is long clicked.
|
||||||
* @param modifier the [Modifier] to be applied to this item box.
|
* @param modifier the [Modifier] to be applied to this item box.
|
||||||
* @param colors the colors of item box, default is [ItemBoxDefaults.colors].
|
* @param colors the colors of item box, default is [ItemBoxDefaults.colors].
|
||||||
* @param style the style of item box, default is [ItemBoxDefaults.style].
|
* @param style the style of item box, default is [ItemBoxDefaults.style].
|
||||||
@@ -96,7 +97,8 @@ data class ItemBoxStyle(
|
|||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun HorizontalItemBox(
|
fun HorizontalItemBox(
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit = {},
|
||||||
|
onLongClick: (() -> Unit)? = null,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
colors: ItemBoxColors = ItemBoxDefaults.colors(),
|
colors: ItemBoxColors = ItemBoxDefaults.colors(),
|
||||||
style: ItemBoxStyle = ItemBoxDefaults.style(),
|
style: ItemBoxStyle = ItemBoxDefaults.style(),
|
||||||
@@ -108,9 +110,10 @@ fun HorizontalItemBox(
|
|||||||
subtitle: @Composable (() -> Unit)? = null
|
subtitle: @Composable (() -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
AreaBox(
|
AreaBox(
|
||||||
modifier = modifier.rippleClickable(
|
modifier = modifier.rippleCombinedClickable(
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
interactionSource = interactionSource,
|
interactionSource = interactionSource,
|
||||||
|
onLongClick = onLongClick,
|
||||||
onClick = onClick
|
onClick = onClick
|
||||||
),
|
),
|
||||||
initializer = { componentState(enabled) },
|
initializer = { componentState(enabled) },
|
||||||
@@ -156,6 +159,7 @@ fun HorizontalItemBox(
|
|||||||
* Flexi UI vertical item box.
|
* Flexi UI vertical item box.
|
||||||
* @see HorizontalItemBox
|
* @see HorizontalItemBox
|
||||||
* @param onClick the callback when item is clicked.
|
* @param onClick the callback when item is clicked.
|
||||||
|
* @param onLongClick the callback when item is long clicked.
|
||||||
* @param modifier the [Modifier] to be applied to this item box.
|
* @param modifier the [Modifier] to be applied to this item box.
|
||||||
* @param colors the colors of item box, default is [ItemBoxDefaults.colors].
|
* @param colors the colors of item box, default is [ItemBoxDefaults.colors].
|
||||||
* @param style the style of item box, default is [ItemBoxDefaults.style].
|
* @param style the style of item box, default is [ItemBoxDefaults.style].
|
||||||
@@ -167,7 +171,8 @@ fun HorizontalItemBox(
|
|||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun VerticalItemBox(
|
fun VerticalItemBox(
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit = {},
|
||||||
|
onLongClick: (() -> Unit)? = null,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
colors: ItemBoxColors = ItemBoxDefaults.colors(),
|
colors: ItemBoxColors = ItemBoxDefaults.colors(),
|
||||||
style: ItemBoxStyle = ItemBoxDefaults.style(),
|
style: ItemBoxStyle = ItemBoxDefaults.style(),
|
||||||
@@ -178,9 +183,10 @@ fun VerticalItemBox(
|
|||||||
subtitle: @Composable (() -> Unit)? = null
|
subtitle: @Composable (() -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
AreaColumn(
|
AreaColumn(
|
||||||
modifier = modifier.rippleClickable(
|
modifier = modifier.rippleCombinedClickable(
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
interactionSource = interactionSource,
|
interactionSource = interactionSource,
|
||||||
|
onLongClick = onLongClick,
|
||||||
onClick = onClick
|
onClick = onClick
|
||||||
),
|
),
|
||||||
initializer = { componentState(enabled) },
|
initializer = { componentState(enabled) },
|
||||||
|
Reference in New Issue
Block a user