Skip to content

Commit e789701

Browse files
committed
bottom sheet changes
allow due and wait dates for tcv3 fetch projects for tcv3
1 parent a868601 commit e789701

2 files changed

Lines changed: 35 additions & 33 deletions

File tree

lib/app/modules/home/views/add_task_bottom_sheet_new.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class AddTaskBottomSheet extends StatelessWidget {
3131

3232
@override
3333
Widget build(BuildContext context) {
34+
debugPrint(
35+
"Building Add Task Bottom Sheet for ${forTaskC ? "TaskC" : forReplica ? "Replica" : "Normal Task"}");
3436
const padding = 12.0;
3537
return Padding(
3638
padding: EdgeInsets.only(
@@ -223,7 +225,8 @@ class AddTaskBottomSheet extends StatelessWidget {
223225
onDateChanges: (List<DateTime?> p0) {
224226
homeController.selectedDates.value = p0;
225227
},
226-
onlyDueDate: forTaskC || forReplica,
228+
allowedIndexes: forReplica ? [0, 1] : [0, 1, 2, 3],
229+
onlyDueDate: forTaskC,
227230
);
228231

229232
Widget buildPriority(BuildContext context) => Column(
@@ -306,6 +309,11 @@ class AddTaskBottomSheet extends StatelessWidget {
306309
);
307310

308311
Set<String> getProjects() {
312+
if (homeController.taskReplica.value) {
313+
return homeController.tasksFromReplica
314+
.map((task) => task.project ?? '')
315+
.toSet();
316+
}
309317
Iterable<Task> tasks = homeController.storage.data.allData();
310318
return tasks
311319
.where((task) => task.project != null)

lib/app/utils/add_task_dialogue/date_picker_input.dart

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import 'package:flutter/material.dart';
22
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
33
import 'package:taskwarrior/app/utils/language/sentence_manager.dart';
44
import 'package:taskwarrior/app/utils/taskfunctions/add_task_dialog_utils.dart';
5-
import 'package:taskwarrior/app/utils/themes/theme_extension.dart';
65

76
class AddTaskDatePickerInput extends StatefulWidget {
87
final Function(List<DateTime?>)? onDateChanges;
98
final bool onlyDueDate;
9+
final List<int> allowedIndexes;
1010
const AddTaskDatePickerInput(
11-
{super.key, this.onDateChanges, this.onlyDueDate = false});
11+
{super.key,
12+
this.onDateChanges,
13+
this.onlyDueDate = false,
14+
this.allowedIndexes = const [0, 1, 2, 3]});
1215

1316
@override
1417
_AddTaskDatePickerInputState createState() => _AddTaskDatePickerInputState();
@@ -42,32 +45,23 @@ class _AddTaskDatePickerInputState extends State<AddTaskDatePickerInput> {
4245
child: DropdownButtonHideUnderline(
4346
child: DropdownButton<int>(
4447
value: currentIndex,
45-
itemHeight: null,
46-
items: List.generate(length, (index) {
47-
bool hasDate = _selectedDates[index] != null;
48-
return DropdownMenuItem<int>(
49-
value: index,
50-
child: Row(
51-
mainAxisSize: MainAxisSize.max,
52-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
53-
children: [
54-
Text(dateLabels[index]),
55-
if (hasDate)
56-
const Padding(
57-
padding: EdgeInsets.only(left: 12),
58-
child: Icon(Icons.check_circle,
59-
size: 14, color: Colors.white),
60-
),
61-
],
62-
),
63-
);
64-
}),
48+
items: [
49+
for (int index = 0; index < length; index++)
50+
if (widget.allowedIndexes
51+
.contains(index)) // Only add if allowed
52+
DropdownMenuItem<int>(
53+
value: index,
54+
child: Row(
55+
children: [
56+
Text(dateLabels[index]),
57+
if (_selectedDates[index] != null)
58+
const Icon(Icons.check_circle, size: 14),
59+
],
60+
),
61+
),
62+
],
6563
onChanged: (value) {
66-
if (value != null) {
67-
setState(() {
68-
currentIndex = value;
69-
});
70-
}
64+
if (value != null) setState(() => currentIndex = value);
7165
},
7266
),
7367
),
@@ -106,18 +100,18 @@ class _AddTaskDatePickerInputState extends State<AddTaskDatePickerInput> {
106100
firstDate: DateTime.now(),
107101
lastDate: DateTime(2101),
108102
);
109-
103+
110104
// FIX: Check if date was selected before showing time picker
111105
if (picked == null) {
112106
return; // User canceled date picker, exit early
113107
}
114-
108+
115109
// Only show time picker if date was selected
116110
final TimeOfDay? time = await showTimePicker(
117111
context: context,
118112
initialTime: TimeOfDay.now(),
119113
);
120-
114+
121115
// If user cancels time picker, still set the date with default time
122116
if (time == null) {
123117
setState(() {
@@ -134,7 +128,7 @@ class _AddTaskDatePickerInputState extends State<AddTaskDatePickerInput> {
134128
}
135129
return;
136130
}
137-
131+
138132
// Both date and time selected
139133
setState(() {
140134
_selectedDates[forIndex] =
@@ -160,4 +154,4 @@ class _AddTaskDatePickerInputState extends State<AddTaskDatePickerInput> {
160154
}
161155
return null;
162156
}
163-
}
157+
}

0 commit comments

Comments
 (0)