Moved opening dialog to a function
This commit is contained in:
parent
0a107ee558
commit
7af1756a8e
17
src/main/kotlin/SystemDialogs.kt
Normal file
17
src/main/kotlin/SystemDialogs.kt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import git.GitManager
|
||||||
|
import javax.swing.JFileChooser
|
||||||
|
|
||||||
|
fun openRepositoryDialog(gitManager: GitManager) {
|
||||||
|
val latestDirectoryOpened = gitManager.latestDirectoryOpened
|
||||||
|
|
||||||
|
val f = if (latestDirectoryOpened == null)
|
||||||
|
JFileChooser()
|
||||||
|
else
|
||||||
|
JFileChooser(latestDirectoryOpened)
|
||||||
|
|
||||||
|
f.fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
|
||||||
|
f.showSaveDialog(null)
|
||||||
|
|
||||||
|
if (f.selectedFile != null)
|
||||||
|
gitManager.openRepository(f.selectedFile)
|
||||||
|
}
|
@ -79,8 +79,7 @@ fun main() = application {
|
|||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize(),
|
||||||
.background(Color.Cyan)
|
|
||||||
) {
|
) {
|
||||||
items(items = tabs.value, key = { it.key }) {
|
items(items = tabs.value, key = { it.key }) {
|
||||||
val isItemSelected = it.key == selectedTabKey
|
val isItemSelected = it.key == selectedTabKey
|
||||||
@ -130,18 +129,7 @@ fun Gitnuro(isNewTab: Boolean, tabName: MutableState<String>) {
|
|||||||
) {
|
) {
|
||||||
GMenu(
|
GMenu(
|
||||||
onRepositoryOpen = {
|
onRepositoryOpen = {
|
||||||
val latestDirectoryOpened = gitManager.latestDirectoryOpened
|
openRepositoryDialog(gitManager = gitManager)
|
||||||
|
|
||||||
val f = if (latestDirectoryOpened == null)
|
|
||||||
JFileChooser()
|
|
||||||
else
|
|
||||||
JFileChooser(latestDirectoryOpened)
|
|
||||||
|
|
||||||
f.fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
|
|
||||||
f.showSaveDialog(null)
|
|
||||||
|
|
||||||
if (f.selectedFile != null)
|
|
||||||
gitManager.openRepository(f.selectedFile)
|
|
||||||
},
|
},
|
||||||
onPull = { gitManager.pull() },
|
onPull = { gitManager.pull() },
|
||||||
onPush = { gitManager.push() },
|
onPush = { gitManager.push() },
|
||||||
|
Loading…
Reference in New Issue
Block a user