Changed how the diff list is created to improve scrollbar's behavior (used to change its size depending on the scroll position ???)

This commit is contained in:
Abdelilah El Aissaoui 2022-02-11 20:47:20 +01:00
parent c374ac77d5
commit 587843d246

View File

@ -132,7 +132,8 @@ fun SideDiff(entryContent: EntryContent) {
when (entryContent) {
EntryContent.Binary -> BinaryDiff()
is EntryContent.ImageBinary -> ImageDiff(entryContent.tempFilePath)
else -> {}
else -> {
}
// is EntryContent.Text -> //TODO maybe have a text view if the file was a binary before?
// TODO Show some info about this EntryContent.TooLargeEntry -> TODO()
}
@ -162,32 +163,35 @@ fun TextDiff(diffEntryType: DiffEntryType, diffViewModel: DiffViewModel, diffRes
val hunks = diffResult.hunks
val scrollState by diffViewModel.lazyListState.collectAsState()
SelectionContainer {
ScrollableLazyColumn(
modifier = Modifier
.fillMaxSize(),
state = scrollState
) {
items(hunks) { hunk ->
for (hunk in hunks) {
item {
DisableSelection {
HunkHeader(
hunk = hunk,
diffEntryType = diffEntryType,
diffViewModel = diffViewModel,
)
}
}
SelectionContainer {
Column {
val oldHighestLineNumber = hunk.lines.maxOf { it.displayOldLineNumber }
val newHighestLineNumber = hunk.lines.maxOf { it.displayNewLineNumber }
val highestLineNumber = max(oldHighestLineNumber, newHighestLineNumber)
val highestLineNumberLength = highestLineNumber.toString().count()
hunk.lines.forEach { line ->
items(hunk.lines) { line ->
DiffLine(highestLineNumberLength, line)
}
}
}
}
}
}