Added progress title and subtitle for push

Also added option to cancel a push
This commit is contained in:
Abdelilah El Aissaoui 2023-04-08 21:07:20 +02:00
parent 03b84ff9c3
commit 5359f58a67
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
4 changed files with 30 additions and 14 deletions

View File

@ -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 =

View File

@ -101,18 +101,24 @@ fun AppTab(
Column(
horizontalAlignment = Alignment.CenterHorizontally,
) {
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),

View File

@ -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)
}

View File

@ -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)
}