Added progress title and subtitle for push
Also added option to cancel a push
This commit is contained in:
parent
03b84ff9c3
commit
5359f58a67
@ -3,8 +3,10 @@ package com.jetpackduba.gitnuro.git.remote_operations
|
|||||||
import com.jetpackduba.gitnuro.git.isRejected
|
import com.jetpackduba.gitnuro.git.isRejected
|
||||||
import com.jetpackduba.gitnuro.git.statusMessage
|
import com.jetpackduba.gitnuro.git.statusMessage
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
|
import org.eclipse.jgit.lib.ProgressMonitor
|
||||||
import org.eclipse.jgit.transport.RefSpec
|
import org.eclipse.jgit.transport.RefSpec
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -23,6 +25,13 @@ class PushBranchUseCase @Inject constructor(
|
|||||||
setPushTags()
|
setPushTags()
|
||||||
}
|
}
|
||||||
.setTransportConfigCallback { handleTransportUseCase(it, git) }
|
.setTransportConfigCallback { handleTransportUseCase(it, git) }
|
||||||
|
.setProgressMonitor(object: ProgressMonitor {
|
||||||
|
override fun start(totalTasks: Int) {}
|
||||||
|
override fun beginTask(title: String?, totalWork: Int) {}
|
||||||
|
override fun update(completed: Int) {}
|
||||||
|
override fun endTask() {}
|
||||||
|
override fun isCancelled() = !isActive
|
||||||
|
})
|
||||||
.call()
|
.call()
|
||||||
|
|
||||||
val results =
|
val results =
|
||||||
|
@ -101,18 +101,24 @@ fun AppTab(
|
|||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
|
if (processingState.title.isNotEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
processingState.title,
|
processingState.title,
|
||||||
style = MaterialTheme.typography.h3,
|
style = MaterialTheme.typography.h3,
|
||||||
color = MaterialTheme.colors.onBackground,
|
color = MaterialTheme.colors.onBackground,
|
||||||
modifier = Modifier.padding(bottom = 8.dp),
|
modifier = Modifier.padding(bottom = 8.dp),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (processingState.subtitle.isNotEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
processingState.subtitle,
|
processingState.subtitle,
|
||||||
style = MaterialTheme.typography.body1,
|
style = MaterialTheme.typography.body1,
|
||||||
color = MaterialTheme.colors.onBackground,
|
color = MaterialTheme.colors.onBackground,
|
||||||
modifier = Modifier.padding(bottom = 32.dp),
|
modifier = Modifier.padding(bottom = 32.dp),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
LinearProgressIndicator(
|
LinearProgressIndicator(
|
||||||
modifier = Modifier.width(280.dp)
|
modifier = Modifier.width(280.dp)
|
||||||
.padding(bottom = 32.dp),
|
.padding(bottom = 32.dp),
|
||||||
|
@ -92,8 +92,6 @@ private fun Modifier.dropdownMenu(items: () -> List<ContextMenuElement>): Modifi
|
|||||||
val mod = this
|
val mod = this
|
||||||
.onGloballyPositioned { layoutCoordinates ->
|
.onGloballyPositioned { layoutCoordinates ->
|
||||||
val offsetToRoot = layoutCoordinates.localToRoot(Offset.Zero)
|
val offsetToRoot = layoutCoordinates.localToRoot(Offset.Zero)
|
||||||
println(offsetToRoot)
|
|
||||||
|
|
||||||
val offsetToBottomOfComponent = offsetToRoot.copy(y = offsetToRoot.y + layoutCoordinates.size.height)
|
val offsetToBottomOfComponent = offsetToRoot.copy(y = offsetToRoot.y + layoutCoordinates.size.height)
|
||||||
setOffset(offsetToBottomOfComponent)
|
setOffset(offsetToBottomOfComponent)
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,9 @@ class MenuViewModel @Inject constructor(
|
|||||||
fun push(force: Boolean = false, pushTags: Boolean = false) = tabState.safeProcessing(
|
fun push(force: Boolean = false, pushTags: Boolean = false) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
refreshEvenIfCrashes = true,
|
refreshEvenIfCrashes = true,
|
||||||
|
title = "Push",
|
||||||
|
subtitle = "Pushing current branch to the remote repository",
|
||||||
|
isCancellable = true,
|
||||||
) { git ->
|
) { git ->
|
||||||
pushBranchUseCase(git, force, pushTags)
|
pushBranchUseCase(git, force, pushTags)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user