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.statusMessage
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.lib.ProgressMonitor
|
||||
import org.eclipse.jgit.transport.RefSpec
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -23,6 +25,13 @@ class PushBranchUseCase @Inject constructor(
|
||||
setPushTags()
|
||||
}
|
||||
.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()
|
||||
|
||||
val results =
|
||||
|
@ -101,18 +101,24 @@ fun AppTab(
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Text(
|
||||
processingState.title,
|
||||
style = MaterialTheme.typography.h3,
|
||||
color = MaterialTheme.colors.onBackground,
|
||||
modifier = Modifier.padding(bottom = 8.dp),
|
||||
)
|
||||
Text(
|
||||
processingState.subtitle,
|
||||
style = MaterialTheme.typography.body1,
|
||||
color = MaterialTheme.colors.onBackground,
|
||||
modifier = Modifier.padding(bottom = 32.dp),
|
||||
)
|
||||
if (processingState.title.isNotEmpty()) {
|
||||
Text(
|
||||
processingState.title,
|
||||
style = MaterialTheme.typography.h3,
|
||||
color = MaterialTheme.colors.onBackground,
|
||||
modifier = Modifier.padding(bottom = 8.dp),
|
||||
)
|
||||
}
|
||||
|
||||
if (processingState.subtitle.isNotEmpty()) {
|
||||
Text(
|
||||
processingState.subtitle,
|
||||
style = MaterialTheme.typography.body1,
|
||||
color = MaterialTheme.colors.onBackground,
|
||||
modifier = Modifier.padding(bottom = 32.dp),
|
||||
)
|
||||
}
|
||||
|
||||
LinearProgressIndicator(
|
||||
modifier = Modifier.width(280.dp)
|
||||
.padding(bottom = 32.dp),
|
||||
|
@ -92,8 +92,6 @@ private fun Modifier.dropdownMenu(items: () -> List<ContextMenuElement>): Modifi
|
||||
val mod = this
|
||||
.onGloballyPositioned { layoutCoordinates ->
|
||||
val offsetToRoot = layoutCoordinates.localToRoot(Offset.Zero)
|
||||
println(offsetToRoot)
|
||||
|
||||
val offsetToBottomOfComponent = offsetToRoot.copy(y = offsetToRoot.y + layoutCoordinates.size.height)
|
||||
setOffset(offsetToBottomOfComponent)
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ class MenuViewModel @Inject constructor(
|
||||
fun push(force: Boolean = false, pushTags: Boolean = false) = tabState.safeProcessing(
|
||||
refreshType = RefreshType.ALL_DATA,
|
||||
refreshEvenIfCrashes = true,
|
||||
title = "Push",
|
||||
subtitle = "Pushing current branch to the remote repository",
|
||||
isCancellable = true,
|
||||
) { git ->
|
||||
pushBranchUseCase(git, force, pushTags)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user