Disabled commit with ctrl+enter if commtis conditions are not met

This commit is contained in:
Abdelilah El Aissaoui 2021-12-04 06:53:13 +01:00
parent 7b1a79e2cf
commit 2a8794d62d

View file

@ -66,6 +66,7 @@ fun UncommitedChanges(
onStagedDiffEntrySelected(null)
commitMessage = ""
}
val canCommit = commitMessage.isNotEmpty() && staged.isNotEmpty()
Column {
AnimatedVisibility(
@ -136,7 +137,7 @@ fun UncommitedChanges(
.fillMaxWidth()
.weight(weight = 1f, fill = true)
.onPreviewKeyEvent {
if (it.isCtrlPressed && it.key == Key.Enter) {
if (it.isCtrlPressed && it.key == Key.Enter && canCommit) {
doCommit()
true
}
@ -157,7 +158,7 @@ fun UncommitedChanges(
onClick = {
doCommit()
},
enabled = commitMessage.isNotEmpty() && staged.isNotEmpty(),
enabled = canCommit,
shape = RectangleShape,
) {
Text(