Removed delay when clicking on a branch in the side panel

This commit is contained in:
Abdelilah El Aissaoui 2023-11-11 16:58:20 +01:00
parent d7f69f69ff
commit 7ce7285d70
No known key found for this signature in database
GPG key ID: 7587FC860F594869

View file

@ -2,9 +2,7 @@
package com.jetpackduba.gitnuro.ui.components package com.jetpackduba.gitnuro.ui.components
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.*
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.material.Icon import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
@ -17,6 +15,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.jetpackduba.gitnuro.extensions.backgroundIf import com.jetpackduba.gitnuro.extensions.backgroundIf
import com.jetpackduba.gitnuro.extensions.onDoubleClick
import com.jetpackduba.gitnuro.theme.backgroundSelected import com.jetpackduba.gitnuro.theme.backgroundSelected
@ -29,7 +28,7 @@ fun SideMenuSubentry(
iconResourcePath: String, iconResourcePath: String,
isSelected: Boolean, isSelected: Boolean,
extraPadding: Dp = 0.dp, extraPadding: Dp = 0.dp,
onClick: (() -> Unit)? = null, onClick: () -> Unit,
onDoubleClick: (() -> Unit)? = null, onDoubleClick: (() -> Unit)? = null,
additionalInfo: @Composable () -> Unit = {} additionalInfo: @Composable () -> Unit = {}
) { ) {
@ -37,9 +36,10 @@ fun SideMenuSubentry(
modifier = Modifier modifier = Modifier
.height(ENTRY_HEIGHT.dp) .height(ENTRY_HEIGHT.dp)
.fillMaxWidth() .fillMaxWidth()
.clickable { onClick() }
.run { .run {
if (onClick != null) if (onDoubleClick != null)
combinedClickable(onClick = onClick, onDoubleClick = onDoubleClick) this.onDoubleClick(onDoubleClick)
else else
this this
} }