diff --git a/src/main/kotlin/SystemDialogs.kt b/src/main/kotlin/SystemDialogs.kt new file mode 100644 index 0000000..fcd2b11 --- /dev/null +++ b/src/main/kotlin/SystemDialogs.kt @@ -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) +} \ No newline at end of file diff --git a/src/main/kotlin/main.kt b/src/main/kotlin/main.kt index fa7c84f..7144765 100644 --- a/src/main/kotlin/main.kt +++ b/src/main/kotlin/main.kt @@ -79,8 +79,7 @@ fun main() = application { LazyColumn( modifier = Modifier - .fillMaxSize() - .background(Color.Cyan) + .fillMaxSize(), ) { items(items = tabs.value, key = { it.key }) { val isItemSelected = it.key == selectedTabKey @@ -130,18 +129,7 @@ fun Gitnuro(isNewTab: Boolean, tabName: MutableState) { ) { GMenu( onRepositoryOpen = { - 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) + openRepositoryDialog(gitManager = gitManager) }, onPull = { gitManager.pull() }, onPush = { gitManager.push() },