Uncommited changes line is now always visible

This commit is contained in:
Abdelilah El Aissaoui 2023-09-10 21:21:32 +02:00
parent 0a8c8ac1ed
commit 64f9953837
No known key found for this signature in database
GPG Key ID: 7587FC860F594869

View File

@ -27,7 +27,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.clipRect import androidx.compose.ui.graphics.drawscope.clipRect
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
@ -58,7 +57,6 @@ import kotlinx.coroutines.launch
import org.eclipse.jgit.lib.Ref import org.eclipse.jgit.lib.Ref
import org.eclipse.jgit.lib.RepositoryState import org.eclipse.jgit.lib.RepositoryState
import org.eclipse.jgit.revwalk.RevCommit import org.eclipse.jgit.revwalk.RevCommit
import java.awt.Cursor
private val colors = listOf( private val colors = listOf(
Color(0xFF42a5f5), Color(0xFF42a5f5),
@ -130,7 +128,6 @@ private fun LogLoaded(
repositoryState: RepositoryState repositoryState: RepositoryState
) { ) {
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
val hasUncommittedChanges = logStatus.hasUncommittedChanges
val commitList = logStatus.plotCommitList val commitList = logStatus.plotCommitList
val verticalScrollState by logViewModel.verticalListState.collectAsState() val verticalScrollState by logViewModel.verticalListState.collectAsState()
val horizontalScrollState by logViewModel.horizontalListState.collectAsState() val horizontalScrollState by logViewModel.horizontalListState.collectAsState()
@ -219,8 +216,6 @@ private fun LogLoaded(
// a padding, so it doesn't cover the graph // a padding, so it doesn't cover the graph
MessagesList( MessagesList(
scrollState = verticalScrollState, scrollState = verticalScrollState,
horizontalScrollState = horizontalScrollState,
hasUncommittedChanges = hasUncommittedChanges,
searchFilter = if (searchFilterValue is LogSearch.SearchResults) searchFilterValue.commits else null, searchFilter = if (searchFilterValue is LogSearch.SearchResults) searchFilterValue.commits else null,
selectedCommit = selectedCommit, selectedCommit = selectedCommit,
logStatus = logStatus, logStatus = logStatus,
@ -228,7 +223,6 @@ private fun LogLoaded(
selectedItem = selectedItem, selectedItem = selectedItem,
commitList = commitList, commitList = commitList,
logViewModel = logViewModel, logViewModel = logViewModel,
graphWidth = graphWidth,
commitsLimit = logStatus.commitsLimit, commitsLimit = logStatus.commitsLimit,
onMerge = { ref -> onMerge = { ref ->
logViewModel.mergeBranch(ref) logViewModel.mergeBranch(ref)
@ -238,7 +232,9 @@ private fun LogLoaded(
}, },
onShowLogDialog = { dialog -> onShowLogDialog = { dialog ->
logViewModel.showDialog(dialog) logViewModel.showDialog(dialog)
} },
graphWidth = graphWidth,
horizontalScrollState = horizontalScrollState
) )
val density = LocalDensity.current.density val density = LocalDensity.current.density
@ -428,7 +424,6 @@ fun SearchFilter(
@Composable @Composable
fun MessagesList( fun MessagesList(
scrollState: LazyListState, scrollState: LazyListState,
hasUncommittedChanges: Boolean,
searchFilter: List<GraphNode>?, searchFilter: List<GraphNode>?,
selectedCommit: RevCommit?, selectedCommit: RevCommit?,
logStatus: LogStatus.Loaded, logStatus: LogStatus.Loaded,
@ -447,32 +442,25 @@ fun MessagesList(
state = scrollState, state = scrollState,
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
) { ) {
if ( item {
hasUncommittedChanges || Box(
repositoryState.isMerging || modifier = Modifier.height(LINE_HEIGHT.dp)
repositoryState.isRebasing || .clipToBounds()
repositoryState.isCherryPicking .fillMaxWidth()
) { .clickable { logViewModel.selectUncommitedChanges() }
item { ) {
Box( UncommitedChangesGraphNode(
modifier = Modifier.height(LINE_HEIGHT.dp) hasPreviousCommits = commitList.isNotEmpty(),
.clipToBounds() isSelected = selectedItem is SelectedItem.UncommitedChanges,
.fillMaxWidth() modifier = Modifier.offset(-horizontalScrollState.value.dp)
.clickable { logViewModel.selectUncommitedChanges() } )
) {
UncommitedChangesGraphNode(
hasPreviousCommits = commitList.isNotEmpty(),
isSelected = selectedItem is SelectedItem.UncommitedChanges,
modifier = Modifier.offset(-horizontalScrollState.value.dp)
)
UncommitedChangesLine( UncommitedChangesLine(
graphWidth = graphWidth, graphWidth = graphWidth,
isSelected = selectedItem == SelectedItem.UncommitedChanges, isSelected = selectedItem == SelectedItem.UncommitedChanges,
statusSummary = logStatus.statusSummary, statusSummary = logStatus.statusSummary,
repositoryState = repositoryState, repositoryState = repositoryState,
) )
}
} }
} }