Merge pull request #11 from ProjectInfinity/double-click-checkout

Add double click to checkout branch
This commit is contained in:
Abdelilah El Aissaoui 2022-06-11 12:13:24 +02:00 committed by GitHub
commit f3ec209e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -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(

View File

@ -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
}