fix: FAB rond (CircleShape) + crash ajout tâche (projet Inbox absent + projectId vide)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import androidx.compose.material.icons.outlined.Menu
|
||||
import androidx.compose.material.icons.outlined.Search
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material.icons.outlined.Today
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material3.DrawerValue
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
@@ -183,6 +184,7 @@ fun MainScreen(viewModel: DrawerViewModel = hiltViewModel()) {
|
||||
FloatingActionButton(
|
||||
onClick = { showCreateTask = true },
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
shape = CircleShape,
|
||||
) {
|
||||
Icon(Icons.Outlined.Add, contentDescription = "Nouvelle tâche", tint = MaterialTheme.colorScheme.onPrimary)
|
||||
}
|
||||
|
||||
@@ -2,16 +2,19 @@ package com.planify.mobile.ui.navigation
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.planify.mobile.domain.model.BackendType
|
||||
import com.planify.mobile.domain.model.Project
|
||||
import com.planify.mobile.domain.repository.ProjectRepository
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.UUID
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class DrawerViewModel @Inject constructor(
|
||||
projectRepository: ProjectRepository,
|
||||
private val projectRepository: ProjectRepository,
|
||||
) : ViewModel() {
|
||||
|
||||
val projects = projectRepository.getAllProjects()
|
||||
@@ -19,4 +22,20 @@ class DrawerViewModel @Inject constructor(
|
||||
|
||||
val favorites = projectRepository.getFavoriteProjects()
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList<Project>())
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
if (projectRepository.getInboxProject() == null) {
|
||||
projectRepository.insertProject(
|
||||
Project(
|
||||
id = UUID.randomUUID().toString(),
|
||||
name = "Boîte de réception",
|
||||
isInbox = true,
|
||||
backendType = BackendType.LOCAL,
|
||||
childOrder = -1,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class TaskEditViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_state.update { it.copy(projectId = projectId, sectionId = sectionId, parentId = parentId) }
|
||||
_state.value = TaskEditState(projectId = projectId, sectionId = sectionId, parentId = parentId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class TaskEditViewModel @Inject constructor(
|
||||
|
||||
fun save(onDone: () -> Unit) {
|
||||
val st = _state.value
|
||||
if (st.content.isBlank()) return
|
||||
if (st.content.isBlank() || st.projectId.isBlank()) return
|
||||
_state.update { it.copy(isSaving = true) }
|
||||
viewModelScope.launch {
|
||||
val now = LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
|
||||
|
||||
Reference in New Issue
Block a user