Added split pane support

This commit is contained in:
Abdelilah El Aissaoui 2021-11-22 03:38:16 +01:00
parent c4afb9e457
commit 2ec3815abf
2 changed files with 131 additions and 65 deletions

View File

@ -24,6 +24,8 @@ repositories {
dependencies { dependencies {
implementation(compose.desktop.currentOs) implementation(compose.desktop.currentOs)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.desktop.components.splitPane)
implementation("org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r") implementation("org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r")
implementation("org.apache.sshd:sshd-core:2.7.0") implementation("org.apache.sshd:sshd-core:2.7.0")
implementation("com.google.dagger:dagger:2.39.1") implementation("com.google.dagger:dagger:2.39.1")

View File

@ -1,10 +1,17 @@
package app.ui package app.ui
import androidx.compose.animation.Crossfade import androidx.compose.animation.Crossfade
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.PointerIconDefaults
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import app.DialogManager import app.DialogManager
import app.credentials.CredentialsState import app.credentials.CredentialsState
@ -15,8 +22,13 @@ import app.ui.dialogs.PasswordDialog
import app.ui.dialogs.UserPasswordDialog import app.ui.dialogs.UserPasswordDialog
import openRepositoryDialog import openRepositoryDialog
import org.eclipse.jgit.revwalk.RevCommit import org.eclipse.jgit.revwalk.RevCommit
import org.jetbrains.compose.splitpane.ExperimentalSplitPaneApi
import org.jetbrains.compose.splitpane.HorizontalSplitPane
import org.jetbrains.compose.splitpane.rememberSplitPaneState
import java.awt.Cursor
@OptIn(ExperimentalSplitPaneApi::class, androidx.compose.ui.ExperimentalComposeUiApi::class)
@Composable @Composable
fun RepositoryOpenPage(gitManager: GitManager, dialogManager: DialogManager) { fun RepositoryOpenPage(gitManager: GitManager, dialogManager: DialogManager) {
var selectedRevCommit by remember { var selectedRevCommit by remember {
@ -87,6 +99,8 @@ fun RepositoryOpenPage(gitManager: GitManager, dialogManager: DialogManager) {
) )
Row { Row {
HorizontalSplitPane() {
first(minSize = 200.dp) {
Column( Column(
modifier = Modifier modifier = Modifier
.widthIn(min = 300.dp) .widthIn(min = 300.dp)
@ -97,10 +111,36 @@ fun RepositoryOpenPage(gitManager: GitManager, dialogManager: DialogManager) {
Tags(gitManager = gitManager) Tags(gitManager = gitManager)
Stashes(gitManager = gitManager) Stashes(gitManager = gitManager)
} }
}
splitter {
visiblePart {
Box(
Modifier
.width(1.dp)
.fillMaxHeight()
.background(MaterialTheme.colors.background)
)
}
handle {
Box(
Modifier
.markAsHandle()
.background(SolidColor(Color.Gray), alpha = 0.50f)
.width(2.dp)
.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR)))
.fillMaxHeight()
)
}
}
second {
HorizontalSplitPane(
splitPaneState = rememberSplitPaneState(0.9f)
) {
first() {
Box( Box(
modifier = Modifier modifier = Modifier
.weight(0.60f) .fillMaxSize()
.fillMaxHeight()
) { ) {
Crossfade(targetState = diffSelected) { diffEntry -> Crossfade(targetState = diffSelected) { diffEntry ->
when (diffEntry) { when (diffEntry) {
@ -128,10 +168,30 @@ fun RepositoryOpenPage(gitManager: GitManager, dialogManager: DialogManager) {
} }
} }
} }
}
splitter {
visiblePart {
Box(
Modifier
.width(1.dp)
.fillMaxHeight()
.background(MaterialTheme.colors.background)
)
}
handle {
Box(
Modifier
.markAsHandle()
.background(SolidColor(Color.Gray), alpha = 0.50f)
.width(2.dp)
.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR)))
.fillMaxHeight()
)
}
}
second(minSize = 300.dp) {
Box( Box(
modifier = Modifier modifier = Modifier
.weight(0.25f)
.fillMaxHeight() .fillMaxHeight()
) { ) {
if (uncommitedChangesSelected) { if (uncommitedChangesSelected) {
@ -161,4 +221,8 @@ fun RepositoryOpenPage(gitManager: GitManager, dialogManager: DialogManager) {
} }
} }
} }
}
}
}
}
} }