From 3ff18edaad1eed17775a4c8590d324481a48c941 Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Sat, 22 Oct 2022 01:38:23 +0200 Subject: [PATCH] Diff header now shrinks path to fit other ui elements if needed (like changed files in a commit) --- .../com/jetpackduba/gitnuro/ui/diff/Diff.kt | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/diff/Diff.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/diff/Diff.kt index fcb136b..d0554cf 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/diff/Diff.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/diff/Diff.kt @@ -624,17 +624,28 @@ private fun DiffHeader( .padding(start = 8.dp, end = 8.dp), verticalAlignment = Alignment.CenterVertically, ) { - val filePath = if (diffEntry.newPath != "/dev/null") - diffEntry.newPath - else - diffEntry.oldPath + val fileName = diffEntry.fileName + val dirPath: String = diffEntry.parentDirectoryPath + if(dirPath.isNotEmpty()) { + Text( + text = dirPath, + style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.secondaryTextColor, + maxLines = 1, + softWrap = false, + overflow = TextOverflow.Ellipsis, + modifier = Modifier + .weight(1f, false) + .padding(start = 16.dp), + ) + } Text( - text = filePath, + text = fileName, style = MaterialTheme.typography.body2, color = MaterialTheme.colors.onBackground, maxLines = 1, - modifier = Modifier.padding(horizontal = 16.dp), + modifier = Modifier.padding(end = 16.dp), ) Spacer(modifier = Modifier.weight(1f))