Compare commits

...

3 commits

Author SHA1 Message Date
Abdelilah El Aissaoui
55730886d2
Fixed horizontal scroll in the commits graph
Fixes #177
2024-02-12 01:44:00 +01:00
Abdelilah El Aissaoui
3e7dc4ddc6
Fixed file picker not working on MacOS
Fixes #198
2024-02-11 18:45:51 +01:00
Abdelilah El Aissaoui
c91106a1bb
Updated rust dependencies 2024-02-10 01:31:22 +01:00
3 changed files with 39 additions and 12 deletions

View file

@ -8,13 +8,13 @@ crate-type = ["cdylib"]
name = "gitnuro_rs"
[dependencies]
uniffi = { version = "0.25.0" }
notify = "6.0.1"
thiserror = "1.0.43"
uniffi = { version = "0.26.0" }
notify = "6.1.1"
thiserror = "1.0.56"
libssh-rs = { version = "0.2.2", features = ["vendored", "vendored-openssl"] }
[build-dependencies]
uniffi = { version = "0.25.0", features = ["build"] }
uniffi = { version = "0.26.0", features = ["build"] }
[[bin]]
name = "uniffi-bindgen"

View file

@ -40,7 +40,7 @@ class OpenFilePickerUseCase @Inject constructor(
if (isZenityInstalled) {
val command = when (pickerType) {
PickerType.FILES, PickerType.FILES_AND_DIRECTORIES -> listOf(
PickerType.FILES -> listOf(
"zenity",
"--file-selection",
"--title=Open"
@ -70,15 +70,21 @@ class OpenFilePickerUseCase @Inject constructor(
}
if (isMac) {
System.setProperty("apple.awt.fileDialogForDirectories", "true")
val fileChooser = if (basePath.isNullOrEmpty())
if (pickerType == PickerType.DIRECTORIES) {
System.setProperty("apple.awt.fileDialogForDirectories", "true")
}
val fileChooser = if (basePath.isNullOrEmpty()) {
FileDialog(null as java.awt.Frame?, "Open", FileDialog.LOAD)
else
} else {
FileDialog(null as java.awt.Frame?, "Open", FileDialog.LOAD).apply {
directory = basePath
}
}
fileChooser.isMultipleMode = false
fileChooser.isVisible = true
System.setProperty("apple.awt.fileDialogForDirectories", "false")
if (fileChooser.file != null && fileChooser.directory != null) {
@ -103,6 +109,5 @@ class OpenFilePickerUseCase @Inject constructor(
enum class PickerType(val value: Int) {
FILES(JFileChooser.FILES_ONLY),
DIRECTORIES(JFileChooser.DIRECTORIES_ONLY),
FILES_AND_DIRECTORIES(JFileChooser.FILES_AND_DIRECTORIES);
DIRECTORIES(JFileChooser.DIRECTORIES_ONLY);
}

View file

@ -6,6 +6,7 @@ import androidx.compose.foundation.*
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.draggable
import androidx.compose.foundation.gestures.rememberDraggableState
import androidx.compose.foundation.gestures.scrollBy
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyListState
@ -29,6 +30,8 @@ import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.drawscope.clipRect
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.pointer.PointerEventType
import androidx.compose.ui.input.pointer.onPointerEvent
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
@ -45,7 +48,10 @@ import com.jetpackduba.gitnuro.keybindings.KeybindingOption
import com.jetpackduba.gitnuro.keybindings.matchesBinding
import com.jetpackduba.gitnuro.theme.*
import com.jetpackduba.gitnuro.ui.SelectedItem
import com.jetpackduba.gitnuro.ui.components.*
import com.jetpackduba.gitnuro.ui.components.AvatarImage
import com.jetpackduba.gitnuro.ui.components.ScrollableLazyColumn
import com.jetpackduba.gitnuro.ui.components.gitnuroDynamicViewModel
import com.jetpackduba.gitnuro.ui.components.gitnuroViewModel
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltip
import com.jetpackduba.gitnuro.ui.components.tooltip.InstantTooltipPosition
import com.jetpackduba.gitnuro.ui.context_menu.*
@ -75,6 +81,8 @@ private const val CANVAS_MIN_WIDTH = 100
private const val CANVAS_DEFAULT_WIDTH = 120
private const val MIN_GRAPH_LANES = 2
private const val HORIZONTAL_SCROLL_PIXELS_MULTIPLIER = 10
/**
* Additional number of lanes to simulate to create a margin at the end of the graph.
*/
@ -425,6 +433,7 @@ fun SearchFilter(
}
}
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun CommitsList(
scrollState: LazyListState,
@ -443,9 +452,22 @@ fun CommitsList(
graphWidth: Dp,
horizontalScrollState: ScrollState,
) {
val scope = rememberCoroutineScope()
ScrollableLazyColumn(
state = scrollState,
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.fillMaxSize()
// The underlying composable assigned to the horizontal scroll bar won't be receiving the scroll events
// because the commits list will consume the events, so this code tries to scroll manually when it detects
// horizontal scrolling
.onPointerEvent(PointerEventType.Scroll) { pointerEvent ->
scope.launch {
val xScroll = pointerEvent.changes.map { it.scrollDelta.x }.sum()
horizontalScrollState.scrollBy(xScroll * HORIZONTAL_SCROLL_PIXELS_MULTIPLIER)
}
println(pointerEvent)
},
) {
if (
hasUncommittedChanges ||