Changed log's ref chips design

This commit is contained in:
Abdelilah El Aissaoui 2021-12-12 02:02:33 +01:00
parent 05326f3a1d
commit e068ac42de
2 changed files with 36 additions and 19 deletions

View File

@ -41,6 +41,10 @@ fun AppTheme(theme: Themes = Themes.LIGHT, content: @Composable() () -> Unit) {
val Colors.primaryTextColor: Color val Colors.primaryTextColor: Color
get() = if (isLight) mainText else mainTextDark get() = if (isLight) mainText else mainTextDark
@get:Composable
val Colors.inversePrimaryTextColor: Color
get() = if (isLight) mainTextDark else mainText
@get:Composable @get:Composable
val Colors.secondaryTextColor: Color val Colors.secondaryTextColor: Color
get() = if (isLight) secondaryText else secondaryTextDark get() = if (isLight) secondaryText else secondaryTextDark

View File

@ -15,6 +15,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Icon import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.material.contentColorFor
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
@ -37,10 +38,7 @@ import app.git.GitManager
import app.git.LogStatus import app.git.LogStatus
import app.git.graph.GraphNode import app.git.graph.GraphNode
import app.images.rememberNetworkImage import app.images.rememberNetworkImage
import app.theme.headerBackground import app.theme.*
import app.theme.headerText
import app.theme.primaryTextColor
import app.theme.secondaryTextColor
import app.ui.SelectedItem import app.ui.SelectedItem
import app.ui.components.ScrollableLazyColumn import app.ui.components.ScrollableLazyColumn
import app.ui.dialogs.MergeDialog import app.ui.dialogs.MergeDialog
@ -353,11 +351,14 @@ fun CommitLine(
.height(40.dp) .height(40.dp)
.fillMaxWidth(), .fillMaxWidth(),
) { ) {
val nodeColor = colors[graphNode.lane.position % colors.size]
CommitsGraphLine( CommitsGraphLine(
modifier = Modifier modifier = Modifier
.width(graphWidth) .width(graphWidth)
.fillMaxHeight(), .fillMaxHeight(),
plotCommit = graphNode plotCommit = graphNode,
nodeColor = nodeColor,
) )
DividerLog( DividerLog(
@ -375,6 +376,7 @@ fun CommitLine(
commit = graphNode, commit = graphNode,
selected = selected, selected = selected,
refs = commitRefs, refs = commitRefs,
nodeColor = nodeColor,
currentBranch = currentBranch, currentBranch = currentBranch,
onCheckoutRef = { ref -> gitManager.checkoutRef(ref) }, onCheckoutRef = { ref -> gitManager.checkoutRef(ref) },
onMergeBranch = { ref -> onMergeBranch(ref) }, onMergeBranch = { ref -> onMergeBranch(ref) },
@ -393,6 +395,7 @@ fun CommitMessage(
selected: Boolean, selected: Boolean,
refs: List<Ref>, refs: List<Ref>,
currentBranch: Ref?, currentBranch: Ref?,
nodeColor: Color,
onCheckoutRef: (ref: Ref) -> Unit, onCheckoutRef: (ref: Ref) -> Unit,
onMergeBranch: (ref: Ref) -> Unit, onMergeBranch: (ref: Ref) -> Unit,
onDeleteBranch: (ref: Ref) -> Unit, onDeleteBranch: (ref: Ref) -> Unit,
@ -429,12 +432,14 @@ fun CommitMessage(
if (ref.isTag) { if (ref.isTag) {
TagChip( TagChip(
ref = ref, ref = ref,
color = nodeColor,
onCheckoutTag = { onCheckoutRef(ref) }, onCheckoutTag = { onCheckoutRef(ref) },
onDeleteTag = { onDeleteTag(ref) }, onDeleteTag = { onDeleteTag(ref) },
) )
} else if (ref.isBranch) { } else if (ref.isBranch) {
BranchChip( BranchChip(
ref = ref, ref = ref,
color = nodeColor,
isCurrentBranch = ref.isSameBranch(currentBranch), isCurrentBranch = ref.isSameBranch(currentBranch),
onCheckoutBranch = { onCheckoutRef(ref) }, onCheckoutBranch = { onCheckoutRef(ref) },
onMergeBranch = { onMergeBranch(ref) }, onMergeBranch = { onMergeBranch(ref) },
@ -492,6 +497,7 @@ fun DividerLog(modifier: Modifier) {
fun CommitsGraphLine( fun CommitsGraphLine(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
plotCommit: GraphNode, plotCommit: GraphNode,
nodeColor: Color,
) { ) {
val passingLanes = plotCommit.passingLanes val passingLanes = plotCommit.passingLanes
val forkingOffLanes = plotCommit.forkingOffLanes val forkingOffLanes = plotCommit.forkingOffLanes
@ -552,7 +558,7 @@ fun CommitsGraphLine(
.align(Alignment.CenterStart) .align(Alignment.CenterStart)
.padding(start = ((itemPosition + 1) * 30 - 15).dp), .padding(start = ((itemPosition + 1) * 30 - 15).dp),
plotCommit = plotCommit, plotCommit = plotCommit,
color = colors[itemPosition % colors.size], color = nodeColor,
) )
} }
} }
@ -617,6 +623,7 @@ fun BranchChip(
onCheckoutBranch: () -> Unit, onCheckoutBranch: () -> Unit,
onMergeBranch: () -> Unit, onMergeBranch: () -> Unit,
onDeleteBranch: () -> Unit, onDeleteBranch: () -> Unit,
color: Color,
) { ) {
val contextMenuItemsList = { val contextMenuItemsList = {
mutableListOf( mutableListOf(
@ -652,13 +659,14 @@ fun BranchChip(
painter = painterResource("location.svg"), painter = painterResource("location.svg"),
contentDescription = null, contentDescription = null,
modifier = Modifier.padding(end = 6.dp), modifier = Modifier.padding(end = 6.dp),
tint = MaterialTheme.colors.background, tint = MaterialTheme.colors.primary,
) )
} }
} }
RefChip( RefChip(
modifier = modifier, modifier = modifier,
color = color,
ref = ref, ref = ref,
icon = "branch.svg", icon = "branch.svg",
onCheckoutRef = onCheckoutBranch, onCheckoutRef = onCheckoutBranch,
@ -674,6 +682,7 @@ fun TagChip(
ref: Ref, ref: Ref,
onCheckoutTag: () -> Unit, onCheckoutTag: () -> Unit,
onDeleteTag: () -> Unit, onDeleteTag: () -> Unit,
color: Color,
) { ) {
val contextMenuItemsList = { val contextMenuItemsList = {
mutableListOf( mutableListOf(
@ -699,6 +708,7 @@ fun TagChip(
"tag.svg", "tag.svg",
onCheckoutRef = onCheckoutTag, onCheckoutRef = onCheckoutTag,
contextMenuItemsList = contextMenuItemsList, contextMenuItemsList = contextMenuItemsList,
color = color,
) )
} }
@ -708,6 +718,7 @@ fun RefChip(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
ref: Ref, ref: Ref,
icon: String, icon: String,
color: Color,
onCheckoutRef: () -> Unit, onCheckoutRef: () -> Unit,
contextMenuItemsList: () -> List<ContextMenuItem>, contextMenuItemsList: () -> List<ContextMenuItem>,
endingContent: @Composable () -> Unit = {}, endingContent: @Composable () -> Unit = {},
@ -716,7 +727,7 @@ fun RefChip(
modifier = Modifier modifier = Modifier
.padding(horizontal = 4.dp) .padding(horizontal = 4.dp)
.clip(RoundedCornerShape(16.dp)) .clip(RoundedCornerShape(16.dp))
.background(MaterialTheme.colors.primary) .border(width = 2.dp, color = color, shape = RoundedCornerShape(16.dp))
.combinedClickable( .combinedClickable(
onDoubleClick = onCheckoutRef, onDoubleClick = onCheckoutRef,
onClick = {} onClick = {}
@ -729,20 +740,22 @@ fun RefChip(
modifier = modifier, modifier = modifier,
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Box (modifier = Modifier.background(color = color)) {
Icon( Icon(
modifier = Modifier modifier = Modifier
.padding(start = 6.dp, end = 4.dp, top = 6.dp, bottom = 6.dp) .padding(6.dp)
.size(14.dp), .size(14.dp),
painter = painterResource(icon), painter = painterResource(icon),
contentDescription = null, contentDescription = null,
tint = MaterialTheme.colors.onPrimary, tint = MaterialTheme.colors.inversePrimaryTextColor,
) )
}
Text( Text(
text = ref.simpleVisibleName, text = ref.simpleVisibleName,
color = MaterialTheme.colors.onPrimary, color = MaterialTheme.colors.primaryTextColor,
fontSize = 12.sp, fontSize = 13.sp,
modifier = Modifier modifier = Modifier
.padding(end = 6.dp) .padding(horizontal = 6.dp)
) )
endingContent() endingContent()