Skip to content

Commit

Permalink
Merge pull request #2094 from acterglobal/kumar/bug-add-task
Browse files Browse the repository at this point in the history
Fixes : Space Details - Add Task Inline option not working
  • Loading branch information
kumarpalsinh25 authored Aug 23, 2024
2 parents 30d3913 + acd6fc5 commit 9043958
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions app/lib/features/tasks/widgets/task_items_list_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@ import 'package:logging/logging.dart';

final _log = Logger('a3::tasks::widgets::list');

class TaskItemsListWidget extends ConsumerWidget {
class TaskItemsListWidget extends ConsumerStatefulWidget {
final TaskList taskList;
final bool showCompletedTask;

TaskItemsListWidget({
const TaskItemsListWidget({
super.key,
required this.taskList,
this.showCompletedTask = false,
});

@override
ConsumerState<ConsumerStatefulWidget> createState() =>
TaskItemsListWidgetState();
}

class TaskItemsListWidgetState extends ConsumerState<TaskItemsListWidget> {
final ValueNotifier<bool> showInlineAddTask = ValueNotifier(false);

@override
Widget build(BuildContext context, WidgetRef ref) {
final overviewLoader = ref.watch(taskItemsListProvider(taskList));
Widget build(BuildContext context) {
final overviewLoader = ref.watch(taskItemsListProvider(widget.taskList));
return overviewLoader.when(
data: (overview) => taskData(context, overview),
error: (e, s) {
Expand All @@ -41,6 +47,7 @@ class TaskItemsListWidget extends ConsumerWidget {

Widget taskData(BuildContext context, TasksOverview overview) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
openTasksEntries(context, overview),
Expand All @@ -60,21 +67,21 @@ class TaskItemsListWidget extends ConsumerWidget {
for (final taskId in overview.openTasks)
TaskItem(
onTap: () => showInlineAddTask.value = false,
taskListId: taskList.eventIdStr(),
taskListId: widget.taskList.eventIdStr(),
taskId: taskId,
),
],
);
}

Widget inlineAddTask() {
final taskListEventId = taskList.eventIdStr();
final taskListEventId = widget.taskList.eventIdStr();
return ValueListenableBuilder(
valueListenable: showInlineAddTask,
builder: (context, value, child) {
return value
? _InlineTaskAdd(
taskList: taskList,
taskList: widget.taskList,
cancel: () => showInlineAddTask.value = false,
)
: Container(
Expand All @@ -94,7 +101,7 @@ class TaskItemsListWidget extends ConsumerWidget {
}

Widget doneTasksEntries(BuildContext context, TasksOverview overview) {
if (overview.doneTasks.isEmpty || !showCompletedTask) {
if (overview.doneTasks.isEmpty || !widget.showCompletedTask) {
return const SizedBox.shrink();
}

Expand All @@ -112,7 +119,7 @@ class TaskItemsListWidget extends ConsumerWidget {
),
for (final taskId in overview.doneTasks)
TaskItem(
taskListId: taskList.eventIdStr(),
taskListId: widget.taskList.eventIdStr(),
taskId: taskId,
onTap: () => showInlineAddTask.value = false,
),
Expand Down

0 comments on commit 9043958

Please sign in to comment.