Added file path to the diff view

This commit is contained in:
Abdelilah El Aissaoui 2022-01-04 22:04:10 +01:00
parent 3cfbcd058e
commit 9271dcdd60

View File

@ -32,6 +32,7 @@ fun Diff(
val diffResult = diffResultState.value ?: return val diffResult = diffResultState.value ?: return
val diffEntryType = diffResult.diffEntryType val diffEntryType = diffResult.diffEntryType
val diffEntry = diffEntryType.diffEntry
val hunks = diffResult.hunks val hunks = diffResult.hunks
Column( Column(
@ -40,10 +41,27 @@ fun Diff(
.background(MaterialTheme.colors.background) .background(MaterialTheme.colors.background)
.fillMaxSize() .fillMaxSize()
) { ) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
val filePath = if(diffEntry.newPath != "/dev/null")
diffEntry.newPath
else
diffEntry.oldPath
Text(
text = filePath,
color = MaterialTheme.colors.primaryTextColor,
fontSize = 16.sp,
modifier = Modifier.padding(horizontal = 16.dp),
)
Spacer(modifier = Modifier.weight(1f))
OutlinedButton( OutlinedButton(
modifier = Modifier modifier = Modifier
.padding(vertical = 16.dp, horizontal = 16.dp) .padding(vertical = 8.dp, horizontal = 16.dp),
.align(Alignment.End),
onClick = onCloseDiffView, onClick = onCloseDiffView,
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
backgroundColor = MaterialTheme.colors.background, backgroundColor = MaterialTheme.colors.background,
@ -52,6 +70,7 @@ fun Diff(
) { ) {
Text("Close diff") Text("Close diff")
} }
}
val scrollState by diffViewModel.lazyListState.collectAsState() val scrollState by diffViewModel.lazyListState.collectAsState()
ScrollableLazyColumn( ScrollableLazyColumn(