Added icon instead of used image on stash

This commit is contained in:
Abdelilah El Aissaoui 2023-11-26 15:58:32 +01:00
parent e98dd4b63a
commit 21ce125931
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
3 changed files with 63 additions and 39 deletions

View File

@ -16,6 +16,7 @@ open class GraphNode(id: AnyObjectId?) : RevCommit(id), IGraphNode {
var lane: GraphLane = NO_LANE
var children: Array<GraphNode> = NO_CHILDREN
var refs: List<Ref> = NO_REFS
var isStash: Boolean = false
fun addForkingOffLane(graphLane: GraphLane) {
forkingOffLanes = addLane(graphLane, forkingOffLanes)

View File

@ -48,8 +48,12 @@ class GraphWalk(private var repository: Repository?) : RevWalk(repository) {
override fun next(): RevCommit? {
val graphNode = super.next() as GraphNode?
if (graphNode != null)
graphNode.refs = getRefs(graphNode)
if (graphNode != null) {
val refs = getRefs(graphNode)
graphNode.isStash = refs.count() == 1 && refs.firstOrNull()?.name == "refs/stash"
graphNode.refs = refs
}
return graphNode
}

View File

@ -24,6 +24,7 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.drawscope.clipRect
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.key.onPreviewKeyEvent
@ -808,7 +809,6 @@ fun CommitLine(
) {
CommitMessage(
commit = graphNode,
refs = graphNode.refs,
nodeColor = nodeColor,
matchesSearchFilter = matchesSearchFilter,
currentBranch = currentBranch,
@ -830,8 +830,7 @@ fun CommitLine(
@Composable
fun CommitMessage(
commit: RevCommit,
refs: List<Ref>,
commit: GraphNode,
currentBranch: Ref?,
nodeColor: Color,
matchesSearchFilter: Boolean?,
@ -852,7 +851,8 @@ fun CommitMessage(
Row(
modifier = Modifier.padding(start = 16.dp)
) {
refs.sortedWith { ref1, ref2 ->
if (!commit.isStash) {
commit.refs.sortedWith { ref1, ref2 ->
if (ref1.isSameBranch(currentBranch)) {
-1
} else {
@ -884,6 +884,7 @@ fun CommitMessage(
}
}
}
}
val message = remember(commit.id.name) {
commit.getShortMessageTrimmed()
@ -1028,6 +1029,23 @@ fun CommitNode(
color: Color,
) {
val author = plotCommit.authorIdent
if (plotCommit.isStash) {
Box(
modifier = modifier
.size(30.dp)
.border(2.dp, color, shape = CircleShape)
.clip(CircleShape)
.background(MaterialTheme.colors.background),
contentAlignment = Alignment.Center,
) {
Image(
painterResource(AppIcons.STASH),
modifier = Modifier.size(20.dp),
contentDescription = null,
colorFilter = ColorFilter.tint(color),
)
}
} else {
Tooltip("${author.name} <${author.emailAddress}>") {
Box(
modifier = modifier
@ -1043,6 +1061,7 @@ fun CommitNode(
}
}
}
}
@Composable
fun UncommitedChangesGraphNode(