Reformated project's code
This commit is contained in:
parent
df48b40ce5
commit
e473d29167
@ -45,9 +45,9 @@ class TabState @Inject constructor(
|
|||||||
*/
|
*/
|
||||||
@set:Synchronized
|
@set:Synchronized
|
||||||
var operationRunning = false
|
var operationRunning = false
|
||||||
get() {
|
get() {
|
||||||
return field || mutex.isLocked
|
return field || mutex.isLocked
|
||||||
}
|
}
|
||||||
|
|
||||||
private val _processing = MutableStateFlow(false)
|
private val _processing = MutableStateFlow(false)
|
||||||
val processing: StateFlow<Boolean> = _processing
|
val processing: StateFlow<Boolean> = _processing
|
||||||
|
@ -1,20 +1,8 @@
|
|||||||
package app.ui
|
package app.ui
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.heightIn
|
|
||||||
import androidx.compose.foundation.lazy.items
|
|
||||||
import androidx.compose.material.MaterialTheme
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import app.maxSidePanelHeight
|
|
||||||
import app.ui.components.ScrollableLazyColumn
|
|
||||||
import app.ui.components.SideMenuEntry
|
|
||||||
import app.ui.components.SideMenuPanel
|
import app.ui.components.SideMenuPanel
|
||||||
import app.ui.components.SideMenuSubentry
|
import app.ui.components.SideMenuSubentry
|
||||||
import app.viewmodels.StashStatus
|
import app.viewmodels.StashStatus
|
||||||
|
@ -2,22 +2,10 @@ package app.ui
|
|||||||
|
|
||||||
import androidx.compose.foundation.ContextMenuArea
|
import androidx.compose.foundation.ContextMenuArea
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.heightIn
|
|
||||||
import androidx.compose.foundation.lazy.items
|
|
||||||
import androidx.compose.material.MaterialTheme
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import app.extensions.simpleName
|
import app.extensions.simpleName
|
||||||
import app.maxSidePanelHeight
|
|
||||||
import app.ui.components.ScrollableLazyColumn
|
|
||||||
import app.ui.components.SideMenuEntry
|
|
||||||
import app.ui.components.SideMenuPanel
|
import app.ui.components.SideMenuPanel
|
||||||
import app.ui.components.SideMenuSubentry
|
import app.ui.components.SideMenuSubentry
|
||||||
import app.ui.context_menu.tagContextMenuItems
|
import app.ui.context_menu.tagContextMenuItems
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package app.ui.components
|
package app.ui.components
|
||||||
|
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
|
||||||
import androidx.compose.animation.ExperimentalAnimationApi
|
import androidx.compose.animation.ExperimentalAnimationApi
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.MutableState
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|
||||||
@OptIn(ExperimentalAnimationApi::class)
|
@OptIn(ExperimentalAnimationApi::class)
|
||||||
@ -40,7 +42,7 @@ fun VerticalExpandable(
|
|||||||
header()
|
header()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isExpanded) {
|
if (isExpanded) {
|
||||||
child()
|
child()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.painter.Painter
|
import androidx.compose.ui.graphics.painter.Painter
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
@ -30,7 +29,7 @@ fun SideMenuEntry(
|
|||||||
.background(color = MaterialTheme.colors.headerBackground),
|
.background(color = MaterialTheme.colors.headerBackground),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
if(icon != null) {
|
if (icon != null) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = icon,
|
painter = icon,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
|
@ -2,7 +2,6 @@ package app.ui.components
|
|||||||
|
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.heightIn
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
@ -33,7 +33,7 @@ fun SideMenuSubentry(
|
|||||||
.height(ENTRY_HEIGHT.dp)
|
.height(ENTRY_HEIGHT.dp)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.run {
|
.run {
|
||||||
if(onClick != null)
|
if (onClick != null)
|
||||||
clickable(onClick = onClick)
|
clickable(onClick = onClick)
|
||||||
else
|
else
|
||||||
this
|
this
|
||||||
|
@ -25,7 +25,7 @@ class DiffViewModel @Inject constructor(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun updateDiff(diffEntryType: DiffEntryType) = tabState.runOperation (
|
fun updateDiff(diffEntryType: DiffEntryType) = tabState.runOperation(
|
||||||
refreshType = RefreshType.NONE,
|
refreshType = RefreshType.NONE,
|
||||||
) { git ->
|
) { git ->
|
||||||
val oldDiffEntryType = _diffResult.value?.diffEntryType
|
val oldDiffEntryType = _diffResult.value?.diffEntryType
|
||||||
@ -54,13 +54,13 @@ class DiffViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stageHunk(diffEntry: DiffEntry, hunk: Hunk) = tabState.runOperation (
|
fun stageHunk(diffEntry: DiffEntry, hunk: Hunk) = tabState.runOperation(
|
||||||
refreshType = RefreshType.UNCOMMITED_CHANGES,
|
refreshType = RefreshType.UNCOMMITED_CHANGES,
|
||||||
) { git ->
|
) { git ->
|
||||||
statusManager.stageHunk(git, diffEntry, hunk)
|
statusManager.stageHunk(git, diffEntry, hunk)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unstageHunk(diffEntry: DiffEntry, hunk: Hunk) = tabState.runOperation (
|
fun unstageHunk(diffEntry: DiffEntry, hunk: Hunk) = tabState.runOperation(
|
||||||
refreshType = RefreshType.UNCOMMITED_CHANGES,
|
refreshType = RefreshType.UNCOMMITED_CHANGES,
|
||||||
) { git ->
|
) { git ->
|
||||||
statusManager.unstageHunk(git, diffEntry, hunk)
|
statusManager.unstageHunk(git, diffEntry, hunk)
|
||||||
|
@ -38,13 +38,13 @@ class LogViewModel @Inject constructor(
|
|||||||
logManager.checkoutCommit(git, revCommit)
|
logManager.checkoutCommit(git, revCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun revertCommit(revCommit: RevCommit) = tabState.safeProcessing (
|
fun revertCommit(revCommit: RevCommit) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
logManager.revertCommit(git, revCommit)
|
logManager.revertCommit(git, revCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetToCommit(revCommit: RevCommit, resetType: ResetType) = tabState.safeProcessing (
|
fun resetToCommit(revCommit: RevCommit, resetType: ResetType) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
logManager.resetToCommit(git, revCommit, resetType = resetType)
|
logManager.resetToCommit(git, revCommit, resetType = resetType)
|
||||||
@ -52,36 +52,36 @@ class LogViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun checkoutRef(ref: Ref) = tabState.safeProcessing(
|
fun checkoutRef(ref: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
branchesManager.checkoutRef(git, ref)
|
branchesManager.checkoutRef(git, ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun createBranchOnCommit(branch: String, revCommit: RevCommit) = tabState.safeProcessing (
|
fun createBranchOnCommit(branch: String, revCommit: RevCommit) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
branchesManager.createBranchOnCommit(git, branch, revCommit)
|
branchesManager.createBranchOnCommit(git, branch, revCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createTagOnCommit(tag: String, revCommit: RevCommit) = tabState.safeProcessing (
|
fun createTagOnCommit(tag: String, revCommit: RevCommit) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
tagsManager.createTagOnCommit(git, tag, revCommit)
|
tagsManager.createTagOnCommit(git, tag, revCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mergeBranch(ref: Ref, fastForward: Boolean) = tabState.safeProcessing (
|
fun mergeBranch(ref: Ref, fastForward: Boolean) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
mergeManager.mergeBranch(git, ref, fastForward)
|
mergeManager.mergeBranch(git, ref, fastForward)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteBranch(branch: Ref) = tabState.safeProcessing (
|
fun deleteBranch(branch: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
branchesManager.deleteBranch(git, branch)
|
branchesManager.deleteBranch(git, branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteTag(tag: Ref) = tabState.safeProcessing (
|
fun deleteTag(tag: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
tagsManager.deleteTag(git, tag)
|
tagsManager.deleteTag(git, tag)
|
||||||
@ -91,7 +91,7 @@ class LogViewModel @Inject constructor(
|
|||||||
loadLog(git)
|
loadLog(git)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun rebaseBranch(ref: Ref) = tabState.safeProcessing (
|
fun rebaseBranch(ref: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
rebaseManager.rebaseBranch(git, ref)
|
rebaseManager.rebaseBranch(git, ref)
|
||||||
|
@ -12,34 +12,34 @@ class MenuViewModel @Inject constructor(
|
|||||||
private val remoteOperationsManager: RemoteOperationsManager,
|
private val remoteOperationsManager: RemoteOperationsManager,
|
||||||
private val stashManager: StashManager,
|
private val stashManager: StashManager,
|
||||||
) {
|
) {
|
||||||
fun pull(rebase: Boolean = false) = tabState.safeProcessing (
|
fun pull(rebase: Boolean = false) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
refreshEvenIfCrashes = true,
|
refreshEvenIfCrashes = true,
|
||||||
) { git ->
|
) { git ->
|
||||||
remoteOperationsManager.pull(git, rebase)
|
remoteOperationsManager.pull(git, rebase)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fetchAll() = tabState.safeProcessing (
|
fun fetchAll() = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
refreshEvenIfCrashes = true,
|
refreshEvenIfCrashes = true,
|
||||||
) { git ->
|
) { git ->
|
||||||
remoteOperationsManager.fetchAll(git)
|
remoteOperationsManager.fetchAll(git)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun push(force: Boolean = false) = tabState.safeProcessing (
|
fun push(force: Boolean = false) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
refreshEvenIfCrashes = true,
|
refreshEvenIfCrashes = true,
|
||||||
) { git ->
|
) { git ->
|
||||||
remoteOperationsManager.push(git, force)
|
remoteOperationsManager.push(git, force)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stash() = tabState.safeProcessing (
|
fun stash() = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.UNCOMMITED_CHANGES,
|
refreshType = RefreshType.UNCOMMITED_CHANGES,
|
||||||
) { git ->
|
) { git ->
|
||||||
stashManager.stash(git)
|
stashManager.stash(git)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun popStash() = tabState.safeProcessing (
|
fun popStash() = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.UNCOMMITED_CHANGES,
|
refreshType = RefreshType.UNCOMMITED_CHANGES,
|
||||||
) { git ->
|
) { git ->
|
||||||
stashManager.popStash(git)
|
stashManager.popStash(git)
|
||||||
@ -48,7 +48,7 @@ class MenuViewModel @Inject constructor(
|
|||||||
fun openFolderInFileExplorer() = tabState.runOperation(
|
fun openFolderInFileExplorer() = tabState.runOperation(
|
||||||
showError = true,
|
showError = true,
|
||||||
refreshType = RefreshType.NONE,
|
refreshType = RefreshType.NONE,
|
||||||
) { git ->
|
) { git ->
|
||||||
Desktop.getDesktop().open(git.repository.directory.parentFile)
|
Desktop.getDesktop().open(git.repository.directory.parentFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,7 +39,7 @@ class RemotesViewModel @Inject constructor(
|
|||||||
_remotes.value = remoteViewList
|
_remotes.value = remoteViewList
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteRemoteBranch(ref: Ref) = tabState.safeProcessing (
|
fun deleteRemoteBranch(ref: Ref) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
) { git ->
|
) { git ->
|
||||||
remoteOperationsManager.deleteBranch(git, ref)
|
remoteOperationsManager.deleteBranch(git, ref)
|
||||||
|
@ -163,9 +163,9 @@ class TabViewModel @Inject constructor(
|
|||||||
stashesViewModel.refresh(git)
|
stashesViewModel.refresh(git)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun refreshRepositoryInfo() = tabState.safeProcessing (
|
private suspend fun refreshRepositoryInfo() = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.NONE,
|
refreshType = RefreshType.NONE,
|
||||||
){ git ->
|
) { git ->
|
||||||
logViewModel.refresh(git)
|
logViewModel.refresh(git)
|
||||||
branchesViewModel.refresh(git)
|
branchesViewModel.refresh(git)
|
||||||
remotesViewModel.refresh(git)
|
remotesViewModel.refresh(git)
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
<svg width="325" height="325" viewBox="0 0 325 325" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="325" height="325" viewBox="0 0 325 325" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<g clip-path="url(#clip0_407_2)">
|
<g clip-path="url(#clip0_407_2)">
|
||||||
<rect width="325" height="325" rx="73" fill="#D3EFFF"/>
|
<rect width="325" height="325" rx="73" fill="#D3EFFF"/>
|
||||||
<rect x="150" width="26" height="325" fill="#4898F7"/>
|
<rect x="150" width="26" height="325" fill="#4898F7"/>
|
||||||
<path d="M300 0L300.086 72.671C300.151 126.998 256.009 171.011 201.682 170.786L158.86 170.61" stroke="#FF8888" stroke-width="24"/>
|
<path d="M300 0L300.086 72.671C300.151 126.998 256.009 171.011 201.682 170.786L158.86 170.61" stroke="#FF8888"
|
||||||
<path d="M25 0L24.9137 72.671C24.8492 126.998 68.9913 171.011 123.318 170.786L166.14 170.61" stroke="#FF8888" stroke-width="24"/>
|
stroke-width="24"/>
|
||||||
<circle cx="163" cy="163" r="68.5" fill="white" stroke="#2775D1" stroke-width="13"/>
|
<path d="M25 0L24.9137 72.671C24.8492 126.998 68.9913 171.011 123.318 170.786L166.14 170.61" stroke="#FF8888"
|
||||||
</g>
|
stroke-width="24"/>
|
||||||
<defs>
|
<circle cx="163" cy="163" r="68.5" fill="white" stroke="#2775D1" stroke-width="13"/>
|
||||||
<clipPath id="clip0_407_2">
|
</g>
|
||||||
<rect width="325" height="325" rx="73" fill="white"/>
|
<defs>
|
||||||
</clipPath>
|
<clipPath id="clip0_407_2">
|
||||||
</defs>
|
<rect width="325" height="325" rx="73" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 824 B |
Loading…
Reference in New Issue
Block a user