Skip to content

Commit

Permalink
Merge pull request #44 from opatry/disable-unplugged-feature
Browse files Browse the repository at this point in the history
Disable unplugged feature
  • Loading branch information
opatry authored Oct 4, 2024
2 parents e245d11 + fdeb534 commit d142fe5
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fun EditTextDialog(
OutlinedTextField(
newTitle,
onValueChange = { newTitle = it },
label = { Text("Title") },
maxLines = 1,
supportingText = if (allowBlank) null else {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ fun TaskListMenu(taskList: TaskListUIModel, expanded: Boolean, onAction: (TaskLi
text = {
Text(text = "Sort by", style = MaterialTheme.typography.titleSmall)
},
enabled = false, onClick = {})
enabled = false,
onClick = {}
)

DropdownMenuItem(
text = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ fun TaskMenu(taskLists: List<TaskListUIModel>, task: TaskUIModel, expanded: Bool
text = {
RowWithIcon("Move to top")
},
onClick = { onAction(TaskMenuAction.MoveToTop) }
onClick = { onAction(TaskMenuAction.MoveToTop) },
enabled = false
)
}

Expand All @@ -79,7 +80,8 @@ fun TaskMenu(taskLists: List<TaskListUIModel>, task: TaskUIModel, expanded: Bool
text = {
RowWithIcon("Add subtask", LucideIcons.SquareStack)
},
onClick = { onAction(TaskMenuAction.AddSubTask) }
onClick = { onAction(TaskMenuAction.AddSubTask) },
enabled = false
)
}

Expand All @@ -88,7 +90,8 @@ fun TaskMenu(taskLists: List<TaskListUIModel>, task: TaskUIModel, expanded: Bool
text = {
RowWithIcon("Indent")
},
onClick = { onAction(TaskMenuAction.Indent) }
onClick = { onAction(TaskMenuAction.Indent) },
enabled = false
)
}

Expand All @@ -97,7 +100,8 @@ fun TaskMenu(taskLists: List<TaskListUIModel>, task: TaskUIModel, expanded: Bool
text = {
RowWithIcon("Unindent")
},
onClick = { onAction(TaskMenuAction.Unindent) }
onClick = { onAction(TaskMenuAction.Unindent) },
enabled = false
)
}

Expand All @@ -107,30 +111,36 @@ fun TaskMenu(taskLists: List<TaskListUIModel>, task: TaskUIModel, expanded: Bool
text = {
Text(text = "Move to…", style = MaterialTheme.typography.titleSmall)
},
enabled = false, onClick = {})
enabled = false,
onClick = {}
)

DropdownMenuItem(
text = {
RowWithIcon("New list", LucideIcons.ListPlus)
},
onClick = { onAction(TaskMenuAction.MoveToNewList) }
onClick = { onAction(TaskMenuAction.MoveToNewList) },
enabled = false,
)

// FIXME not ideal when a lot of list, maybe ask for a dialog or bottom sheet in which to choose?
// or using a submenu?
taskLists.forEach { taskList ->
DropdownMenuItem(
text = {
RowWithIcon(icon = if (taskList.id == currentTaskList?.id) {
{ Icon(LucideIcons.Check, null) }
} else null
) {
Text(taskList.title, overflow = TextOverflow.Ellipsis, maxLines = 1)
}
},
enabled = taskList.id != currentTaskList?.id,
onClick = { onAction(TaskMenuAction.MoveToList(taskList)) }
)
val enableMoveTaskList = false
if (enableMoveTaskList) {
taskLists.forEach { taskList ->
DropdownMenuItem(
text = {
RowWithIcon(icon = if (taskList.id == currentTaskList?.id) {
{ Icon(LucideIcons.Check, null) }
} else null
) {
Text(taskList.title, overflow = TextOverflow.Ellipsis, maxLines = 1)
}
},
enabled = taskList.id != currentTaskList?.id,
onClick = { onAction(TaskMenuAction.MoveToList(taskList)) }
)
}
}

HorizontalDivider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ fun TaskListDetail(
var showUndoTaskDeletionSnackbar by remember { mutableStateOf(false) }
val snackbarHostState = remember { SnackbarHostState() }

if (showUndoTaskDeletionSnackbar) {
val enableUndoTaskDeletion = false
if (enableUndoTaskDeletion && showUndoTaskDeletionSnackbar) {
LaunchedEffect(Unit) {
taskOfInterest?.let { task ->
val result = snackbarHostState.showSnackbar(
Expand Down Expand Up @@ -333,7 +334,8 @@ fun TaskListDetail(
OutlinedTextField(
newTitle,
onValueChange = { newTitle = it },
Modifier.fillMaxWidth(),
modifier = Modifier.fillMaxWidth(),
label = { Text("Title") },
maxLines = 1,
supportingText = {
AnimatedVisibility(visible = titleHasError) {
Expand All @@ -346,7 +348,8 @@ fun TaskListDetail(
OutlinedTextField(
newNotes,
onValueChange = { newNotes = it },
Modifier.fillMaxWidth(),
modifier = Modifier.fillMaxWidth(),
label = { Text("Notes") },
leadingIcon = { Icon(LucideIcons.NotepadText, null) },
singleLine = false,
minLines = 2,
Expand All @@ -360,45 +363,50 @@ fun TaskListDetail(
val dueDateLabel = task?.dateRange?.toLabel()?.takeUnless(String::isBlank) ?: "No due date"
AssistChip(
onClick = { showDatePickerDialog = true },
enabled = false, // TODO not supported for now, super imposed dialogs breaks the flow
shape = MaterialTheme.shapes.large,
leadingIcon = { Icon(LucideIcons.CalendarDays, null) },
label = { Text(dueDateLabel, color = task?.dateRange.toColor()) },
)

ExposedDropdownMenuBox(
expanded = expandTaskListsDropDown,
onExpandedChange = { expandTaskListsDropDown = it }
) {
OutlinedTextField(
targetList.title,
onValueChange = {},
modifier = Modifier.menuAnchor(MenuAnchorType.PrimaryNotEditable, true),
readOnly = true,
trailingIcon = {
ExposedDropdownMenuDefaults.TrailingIcon(expanded = expandTaskListsDropDown)
},
)

ExposedDropdownMenu(
val enableAdvancedTaskEdit = false
if (enableAdvancedTaskEdit) {
ExposedDropdownMenuBox(
expanded = expandTaskListsDropDown,
onDismissRequest = { expandTaskListsDropDown = false }
onExpandedChange = { expandTaskListsDropDown = it }
) {
taskLists.forEach { taskList ->
DropdownMenuItem(
text = { Text(taskList.title) },
onClick = {
targetList = taskList
expandTaskListsDropDown = false
}
)
OutlinedTextField(
targetList.title,
onValueChange = {},
modifier = Modifier.menuAnchor(MenuAnchorType.PrimaryNotEditable, true),
label = { Text("List title") },
readOnly = true,
trailingIcon = {
ExposedDropdownMenuDefaults.TrailingIcon(expanded = expandTaskListsDropDown)
},
)

ExposedDropdownMenu(
expanded = expandTaskListsDropDown,
onDismissRequest = { expandTaskListsDropDown = false }
) {
taskLists.forEach { taskList ->
DropdownMenuItem(
text = { Text(taskList.title) },
onClick = {
targetList = taskList
expandTaskListsDropDown = false
}
)
}
}
}
}

// TODO instead of a button opening a dialog, TextField could be editable to let user
// enter the new list name, if targetList isn't part of taskLists, then, it's a new one
IconButton(onClick = {}) {
Icon(LucideIcons.ListPlus, null)
// TODO instead of a button opening a dialog, TextField could be editable to let user
// enter the new list name, if targetList isn't part of taskLists, then, it's a new one
IconButton(onClick = {}) {
Icon(LucideIcons.ListPlus, null)
}
}
}

Expand Down

0 comments on commit d142fe5

Please sign in to comment.