feat: toggle tâche → statut terminé sur API + bouton déconnexion dans le menu
This commit is contained in:
@@ -16,7 +16,7 @@ android {
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
versionCode = 1
|
||||
versionName = "0.0.16"
|
||||
versionName = "0.0.17"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.compose.material.icons.outlined.FilterList
|
||||
import androidx.compose.material.icons.outlined.Inbox
|
||||
import androidx.compose.material.icons.outlined.Menu
|
||||
import androidx.compose.material.icons.outlined.Search
|
||||
import androidx.compose.material.icons.outlined.Logout
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material.icons.outlined.Today
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
@@ -174,6 +175,15 @@ fun MainScreen(
|
||||
scope.launch { drawerState.close() }
|
||||
},
|
||||
)
|
||||
NavigationDrawerItem(
|
||||
icon = { Icon(Icons.Outlined.Logout, null) },
|
||||
label = { Text("Déconnexion") },
|
||||
selected = false,
|
||||
onClick = {
|
||||
authViewModel.logout()
|
||||
scope.launch { drawerState.close() }
|
||||
},
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "v${com.planify.mobile.BuildConfig.VERSION_NAME}",
|
||||
|
||||
@@ -7,6 +7,10 @@ import com.planify.mobile.domain.model.Project
|
||||
import com.planify.mobile.domain.model.Section
|
||||
import com.planify.mobile.domain.model.Task
|
||||
import com.planify.mobile.domain.model.ViewStyle
|
||||
import com.planify.mobile.data.bonsai.BonsaiApiClient
|
||||
import com.planify.mobile.data.bonsai.BonsaiAuthManager
|
||||
import com.planify.mobile.data.bonsai.BonsaiSyncManager
|
||||
import com.planify.mobile.data.bonsai.dto.BonsaIssueRequest
|
||||
import com.planify.mobile.domain.repository.ProjectRepository
|
||||
import com.planify.mobile.domain.repository.SectionRepository
|
||||
import com.planify.mobile.domain.repository.TaskRepository
|
||||
@@ -32,6 +36,8 @@ class ProjectViewModel @Inject constructor(
|
||||
private val taskRepository: TaskRepository,
|
||||
private val projectRepository: ProjectRepository,
|
||||
private val sectionRepository: SectionRepository,
|
||||
private val apiClient: BonsaiApiClient,
|
||||
private val authManager: BonsaiAuthManager,
|
||||
) : ViewModel() {
|
||||
|
||||
private val projectId: String = checkNotNull(savedStateHandle["projectId"])
|
||||
@@ -66,7 +72,24 @@ class ProjectViewModel @Inject constructor(
|
||||
)
|
||||
|
||||
fun toggleTask(task: Task) {
|
||||
viewModelScope.launch { taskRepository.checkTask(task.id, !task.checked) }
|
||||
val newChecked = !task.checked
|
||||
viewModelScope.launch {
|
||||
taskRepository.checkTask(task.id, newChecked)
|
||||
|
||||
val projectIdLong = task.projectId.toLongOrNull() ?: return@launch
|
||||
val taskIdLong = task.id.toLongOrNull() ?: return@launch
|
||||
if (!authManager.isLoggedIn) return@launch
|
||||
authManager.refreshIfNeeded()
|
||||
|
||||
val request = BonsaIssueRequest(
|
||||
name = task.content,
|
||||
priority = BonsaiSyncManager.toBonsaiPriority(task.priority),
|
||||
status = BonsaiSyncManager.toBonsaiStatus(newChecked),
|
||||
dueDate = task.dueDate?.date,
|
||||
description = task.description.ifBlank { null },
|
||||
)
|
||||
apiClient.updateIssue(projectIdLong, taskIdLong, request)
|
||||
}
|
||||
}
|
||||
|
||||
fun reorderTasks(reordered: List<Task>) {
|
||||
|
||||
Reference in New Issue
Block a user