Skip to content

Commit

Permalink
Implemented treeview in files list
Browse files Browse the repository at this point in the history
Fixes #22
  • Loading branch information
JetpackDuba committed Jan 23, 2024
1 parent 8cde01b commit e5ff773
Show file tree
Hide file tree
Showing 15 changed files with 1,459 additions and 524 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/com/jetpackduba/gitnuro/Icons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ object AppIcons {
const val ERROR = "error.svg"
const val EXPAND_MORE = "expand_more.svg"
const val FETCH = "fetch.svg"
const val FOLDER = "folder.svg"
const val FOLDER_OPEN = "folder_open.svg"
const val GRADE = "grade.svg"
const val HORIZONTAL_SPLIT = "horizontal_split.svg"
const val HISTORY = "history.svg"
Expand Down Expand Up @@ -59,6 +61,7 @@ object AppIcons {
const val TAG = "tag.svg"
const val TERMINAL = "terminal.svg"
const val TOPIC = "topic.svg"
const val TREE = "tree.svg"
const val UNDO = "undo.svg"
const val UNIFIED = "unified.svg"
const val UPDATE = "update.svg"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.jetpackduba.gitnuro.git.workspace

import com.jetpackduba.gitnuro.system.systemSeparator
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.eclipse.jgit.api.Git
import javax.inject.Inject

class StageByDirectoryUseCase @Inject constructor() {
suspend operator fun invoke(git: Git, dir: String) = withContext(Dispatchers.IO) {
git.add()
.addFilepattern(dir)
.call()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.jetpackduba.gitnuro.git.workspace

import com.jetpackduba.gitnuro.system.systemSeparator
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.eclipse.jgit.api.Git
import javax.inject.Inject

class UnstageByDirectoryUseCase @Inject constructor() {
suspend operator fun invoke(git: Git, dir: String) = withContext(Dispatchers.IO) {
git.reset()
.addPath(dir)
.call()
}
}
26 changes: 14 additions & 12 deletions src/main/kotlin/com/jetpackduba/gitnuro/preferences/AppSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private const val PREF_DIFF_TYPE = "diffType"
private const val PREF_DIFF_FULL_FILE = "diffFullFile"
private const val PREF_SWAP_UNCOMMITTED_CHANGES = "inverseUncommittedChanges"
private const val PREF_TERMINAL_PATH = "terminalPath"
private const val PREF_SHOW_CHANGES_AS_TREE = "showChangesAsTree"
private const val PREF_USE_PROXY = "useProxy"
private const val PREF_PROXY_TYPE = "proxyType"
private const val PREF_PROXY_HOST_NAME = "proxyHostName"
Expand All @@ -50,6 +51,7 @@ private const val PREF_VERIFY_SSL = "verifySsl"
private const val DEFAULT_COMMITS_LIMIT = 1000
private const val DEFAULT_COMMITS_LIMIT_ENABLED = true
private const val DEFAULT_SWAP_UNCOMMITTED_CHANGES = false
private const val DEFAULT_SHOW_CHANGES_AS_TREE = false
private const val DEFAULT_CACHE_CREDENTIALS_IN_MEMORY = true
private const val DEFAULT_VERIFY_SSL = true
const val DEFAULT_UI_SCALE = -1f
Expand All @@ -67,6 +69,9 @@ class AppSettings @Inject constructor() {
private val _swapUncommittedChangesFlow = MutableStateFlow(swapUncommittedChanges)
val swapUncommittedChangesFlow = _swapUncommittedChangesFlow.asStateFlow()

private val _showChangesAsTreeFlow = MutableStateFlow(showChangesAsTree)
val showChangesAsTreeFlow = _showChangesAsTreeFlow.asStateFlow()

private val _cacheCredentialsInMemoryFlow = MutableStateFlow(cacheCredentialsInMemory)
val cacheCredentialsInMemoryFlow = _cacheCredentialsInMemoryFlow.asStateFlow()

Expand Down Expand Up @@ -165,6 +170,15 @@ class AppSettings @Inject constructor() {
_swapUncommittedChangesFlow.value = value
}

var showChangesAsTree: Boolean
get() {
return preferences.getBoolean(PREF_SHOW_CHANGES_AS_TREE, DEFAULT_SHOW_CHANGES_AS_TREE)
}
set(value) {
preferences.putBoolean(PREF_SHOW_CHANGES_AS_TREE, value)
_showChangesAsTreeFlow.value = value
}

var cacheCredentialsInMemory: Boolean
get() {
return preferences.getBoolean(PREF_CACHE_CREDENTIALS_IN_MEMORY, DEFAULT_CACHE_CREDENTIALS_IN_MEMORY)
Expand Down Expand Up @@ -347,18 +361,6 @@ class AppSettings @Inject constructor() {
_customThemeFlow.value = Json.decodeFromString<ColorsScheme>(themeJson)
}
}

private fun loadProxySettings() {
_proxyFlow.value = ProxySettings(
useProxy,
proxyType,
proxyHostName,
proxyPortNumber,
proxyUseAuth,
proxyHostUser,
proxyHostPassword,
)
}
}

data class ProxySettings(
Expand Down
Loading

0 comments on commit e5ff773

Please sign in to comment.