From c6163f1ef45ca8d21cf205deaf5cb8f6972a3cfc Mon Sep 17 00:00:00 2001 From: Infinity Date: Sat, 11 Jun 2022 05:19:36 +0200 Subject: [PATCH] Add double click to checkout branch --- src/main/kotlin/app/ui/Branches.kt | 5 ++++- src/main/kotlin/app/ui/components/SideMenuSubentry.kt | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/ui/Branches.kt b/src/main/kotlin/app/ui/Branches.kt index b21c6fd..f261490 100644 --- a/src/main/kotlin/app/ui/Branches.kt +++ b/src/main/kotlin/app/ui/Branches.kt @@ -44,6 +44,7 @@ fun Branches( currentBranch = currentBranch, isCurrentBranch = currentBranch?.name == branch.name, onBranchClicked = { branchesViewModel.selectBranch(branch) }, + onBranchDoubleClicked = { branchesViewModel.checkoutRef(branch) }, onCheckoutBranch = { branchesViewModel.checkoutRef(branch) }, onMergeBranch = { setMergeBranch(branch) }, onDeleteBranch = { branchesViewModel.deleteBranch(branch) }, @@ -80,6 +81,7 @@ private fun BranchLineEntry( currentBranch: Ref?, isCurrentBranch: Boolean, onBranchClicked: () -> Unit, + onBranchDoubleClicked: () -> Unit, onCheckoutBranch: () -> Unit, onMergeBranch: () -> Unit, onRebaseBranch: () -> Unit, @@ -107,7 +109,8 @@ private fun BranchLineEntry( text = branch.simpleName, iconResourcePath = "branch.svg", bold = isCurrentBranch, - onClick = onBranchClicked + onClick = onBranchClicked, + onDoubleClick = onBranchDoubleClicked ) { if (isCurrentBranch) { Icon( diff --git a/src/main/kotlin/app/ui/components/SideMenuSubentry.kt b/src/main/kotlin/app/ui/components/SideMenuSubentry.kt index 2ba2729..e0f459b 100644 --- a/src/main/kotlin/app/ui/components/SideMenuSubentry.kt +++ b/src/main/kotlin/app/ui/components/SideMenuSubentry.kt @@ -2,7 +2,9 @@ package app.ui.components +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.clickable +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.* import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme @@ -19,6 +21,7 @@ import androidx.compose.ui.unit.sp import app.ENTRY_HEIGHT import app.theme.primaryTextColor +@OptIn(ExperimentalFoundationApi::class) @Composable fun SideMenuSubentry( text: String, @@ -26,6 +29,7 @@ fun SideMenuSubentry( bold: Boolean = false, extraPadding: Dp = 0.dp, onClick: (() -> Unit)? = null, + onDoubleClick: (() -> Unit)? = null, additionalInfo: @Composable () -> Unit = {} ) { Row( @@ -33,8 +37,8 @@ fun SideMenuSubentry( .height(ENTRY_HEIGHT.dp) .fillMaxWidth() .run { - if (onClick != null) - clickable(onClick = onClick) + if (onClick != null && onDoubleClick != null) + combinedClickable(onClick = onClick, onDoubleClick = onDoubleClick) else this }