Fixed context menu not showing up in branches/tags

This commit is contained in:
Abdelilah El Aissaoui 2021-10-27 03:52:21 +02:00
parent d4d057c291
commit a7d89aabaf

View File

@ -466,6 +466,48 @@ fun UncommitedChangesGraphLine(
} }
} }
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun BranchChip(modifier: Modifier = Modifier, ref: Ref, onCheckoutBranch: () -> Unit) {
val contextMenuItemsList = {
listOf(
ContextMenuItem(
label = "Checkout branch",
onClick = onCheckoutBranch
)
)
}
RefChip(
modifier,
ref,
"branch.svg",
onCheckoutRef = onCheckoutBranch,
contextMenuItemsList = contextMenuItemsList
)
}
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun TagChip(modifier: Modifier = Modifier, ref: Ref, onCheckoutTag: () -> Unit) {
val contextMenuItemsList = {
listOf(
ContextMenuItem(
label = "Checkout tag",
onClick = onCheckoutTag
)
)
}
RefChip(
modifier,
ref,
"tag.svg",
onCheckoutRef = onCheckoutTag,
contextMenuItemsList = contextMenuItemsList,
)
}
@OptIn(ExperimentalFoundationApi::class) @OptIn(ExperimentalFoundationApi::class)
@Composable @Composable
fun RefChip( fun RefChip(
@ -473,16 +515,23 @@ fun RefChip(
ref: Ref, ref: Ref,
icon: String, icon: String,
onCheckoutRef: () -> Unit, onCheckoutRef: () -> Unit,
contextMenuItemsList: () -> List<ContextMenuItem>,
) { ) {
Box(
modifier = Modifier
.combinedClickable(
onDoubleClick = onCheckoutRef,
onClick = {}
)
) {
ContextMenuArea(
items = contextMenuItemsList
) {
Row( Row(
modifier = modifier modifier = modifier
.padding(horizontal = 4.dp) .padding(horizontal = 4.dp)
.clip(RoundedCornerShape(16.dp)) .clip(RoundedCornerShape(16.dp))
.background(MaterialTheme.colors.primary) .background(MaterialTheme.colors.primary),
.combinedClickable(
onDoubleClick = onCheckoutRef,
onClick = {}
),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Icon( Icon(
@ -501,48 +550,7 @@ fun RefChip(
.padding(end = 6.dp) .padding(end = 6.dp)
) )
} }
} }
}
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun BranchChip(modifier: Modifier = Modifier, ref: Ref, onCheckoutBranch: () -> Unit) {
ContextMenuArea(
items = {
listOf(
ContextMenuItem(
label = "Checkout branch",
onClick = onCheckoutBranch
)
)
}
) {
RefChip(
modifier,
ref,
"branch.svg",
onCheckoutRef = onCheckoutBranch
)
}
}
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun TagChip(modifier: Modifier = Modifier, ref: Ref, onCheckoutTag: () -> Unit) {
ContextMenuArea(
items = {
listOf(
ContextMenuItem(
label = "Checkout tag",
onClick = onCheckoutTag
)
)
}
) {
RefChip(
modifier,
ref,
"tag.svg",
onCheckoutRef = onCheckoutTag
)
}
} }