|
|
|
@ -3,14 +3,24 @@ package org.tasks.compose.edit
|
|
|
|
|
import android.content.res.Configuration
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
|
import androidx.compose.foundation.focusable
|
|
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
|
|
import androidx.compose.foundation.layout.Spacer
|
|
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
|
|
import androidx.compose.foundation.text.BasicTextField
|
|
|
|
|
import androidx.compose.foundation.text.KeyboardActions
|
|
|
|
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
|
|
|
import androidx.compose.material.ContentAlpha
|
|
|
|
|
import androidx.compose.material.MaterialTheme
|
|
|
|
|
import androidx.compose.material.Text
|
|
|
|
|
import androidx.compose.runtime.*
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
|
|
import androidx.compose.runtime.remember
|
|
|
|
|
import androidx.compose.runtime.setValue
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.draw.alpha
|
|
|
|
@ -27,8 +37,14 @@ import com.google.android.material.composethemeadapter.MdcTheme
|
|
|
|
|
import com.todoroo.astrid.api.Filter
|
|
|
|
|
import com.todoroo.astrid.api.GtasksFilter
|
|
|
|
|
import com.todoroo.astrid.data.Task
|
|
|
|
|
import org.tasks.compose.*
|
|
|
|
|
import org.tasks.compose.CheckBox
|
|
|
|
|
import org.tasks.compose.ClearButton
|
|
|
|
|
import org.tasks.compose.DisabledText
|
|
|
|
|
import org.tasks.compose.SubtaskChip
|
|
|
|
|
import org.tasks.compose.TaskEditIcon
|
|
|
|
|
import org.tasks.compose.TaskEditRow
|
|
|
|
|
import org.tasks.data.TaskContainer
|
|
|
|
|
import org.tasks.ui.TaskListViewModel
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun SubtaskRow(
|
|
|
|
@ -36,7 +52,7 @@ fun SubtaskRow(
|
|
|
|
|
filter: Filter?,
|
|
|
|
|
hasParent: Boolean,
|
|
|
|
|
desaturate: Boolean,
|
|
|
|
|
existingSubtasks: List<TaskContainer>,
|
|
|
|
|
existingSubtasks: TaskListViewModel.TasksResults,
|
|
|
|
|
newSubtasks: List<Task>,
|
|
|
|
|
openSubtask: (Task) -> Unit,
|
|
|
|
|
completeExistingSubtask: (Task, Boolean) -> Unit,
|
|
|
|
@ -73,16 +89,23 @@ fun SubtaskRow(
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
Spacer(modifier = Modifier.height(height = 8.dp))
|
|
|
|
|
existingSubtasks.forEach { task ->
|
|
|
|
|
if (existingSubtasks is TaskListViewModel.TasksResults.Results) {
|
|
|
|
|
existingSubtasks.tasks.forEach { task ->
|
|
|
|
|
ExistingSubtaskRow(
|
|
|
|
|
task = task,
|
|
|
|
|
desaturate = desaturate,
|
|
|
|
|
indent = if (filter !is GtasksFilter) task.indent else 0,
|
|
|
|
|
onRowClick = { openSubtask(task.task) },
|
|
|
|
|
onCompleteClick = { completeExistingSubtask(task.task, !task.isCompleted) },
|
|
|
|
|
onCompleteClick = {
|
|
|
|
|
completeExistingSubtask(
|
|
|
|
|
task.task,
|
|
|
|
|
!task.isCompleted
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
onToggleSubtaskClick = { toggleSubtask(task.id, !task.isCollapsed) }
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
newSubtasks.forEach { subtask ->
|
|
|
|
|
NewSubtaskRow(
|
|
|
|
|
subtask = subtask,
|
|
|
|
@ -214,7 +237,7 @@ fun NoSubtasks() {
|
|
|
|
|
filter = null,
|
|
|
|
|
hasParent = false,
|
|
|
|
|
desaturate = true,
|
|
|
|
|
existingSubtasks = emptyList(),
|
|
|
|
|
existingSubtasks = TaskListViewModel.TasksResults.Results(emptyList()),
|
|
|
|
|
newSubtasks = emptyList(),
|
|
|
|
|
openSubtask = {},
|
|
|
|
|
completeExistingSubtask = { _, _ -> },
|
|
|
|
@ -236,21 +259,23 @@ fun SubtasksPreview() {
|
|
|
|
|
filter = null,
|
|
|
|
|
hasParent = false,
|
|
|
|
|
desaturate = true,
|
|
|
|
|
existingSubtasks = listOf(
|
|
|
|
|
existingSubtasks = TaskListViewModel.TasksResults.Results(
|
|
|
|
|
listOf(
|
|
|
|
|
TaskContainer(
|
|
|
|
|
task = Task().apply {
|
|
|
|
|
title = "Existing subtask 1"
|
|
|
|
|
priority = Task.Priority.HIGH
|
|
|
|
|
},
|
|
|
|
|
task = Task(
|
|
|
|
|
title = "Existing subtask 1",
|
|
|
|
|
priority = Task.Priority.HIGH,
|
|
|
|
|
),
|
|
|
|
|
indent = 0
|
|
|
|
|
),
|
|
|
|
|
TaskContainer(
|
|
|
|
|
task = Task().apply {
|
|
|
|
|
title = "Existing subtask 2 with a really long title"
|
|
|
|
|
priority = Task.Priority.LOW
|
|
|
|
|
},
|
|
|
|
|
task = Task(
|
|
|
|
|
title = "Existing subtask 2 with a really long title",
|
|
|
|
|
priority = Task.Priority.LOW,
|
|
|
|
|
),
|
|
|
|
|
indent = 1
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
newSubtasks = listOf(
|
|
|
|
|
Task().apply {
|
|
|
|
|