Skip to content

Commit 1063d91

Browse files
disabled editing for completed and pending task fields
1 parent 7eaf8fd commit 1063d91

File tree

6 files changed

+142
-140
lines changed

6 files changed

+142
-140
lines changed

lib/app/modules/detailRoute/controllers/detail_route_controller.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class DetailRouteController extends GetxController {
1515
late String uuid;
1616
late Modify modify;
1717
var onEdit = false.obs;
18+
var isReadOnly = false.obs;
1819

1920
@override
2021
void onInit() {
@@ -29,12 +30,26 @@ class DetailRouteController extends GetxController {
2930
uuid: uuid,
3031
);
3132
initValues();
33+
34+
// Check if task is completed or deleted and set read-only state
35+
isReadOnly.value = (modify.draft.status == 'completed' ||
36+
modify.draft.status == 'deleted');
3237
}
3338

3439
void setAttribute(String name, dynamic newValue) {
40+
if (isReadOnly.value && name != 'status') {
41+
return;
42+
}
43+
3544
modify.set(name, newValue);
3645
onEdit.value = true;
37-
if(name == 'start'){
46+
47+
// If status is being changed, update read-only state
48+
if (name == 'status') {
49+
isReadOnly.value = (newValue == 'completed' || newValue == 'deleted');
50+
}
51+
52+
if (name == 'start') {
3853
debugPrint('Start Value Changed to $newValue');
3954
startValue.value = newValue;
4055
}

lib/app/modules/detailRoute/views/dateTimePicker.dart

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,33 @@ class DateTimeWidget extends StatelessWidget {
1515
required this.value,
1616
required this.callback,
1717
required this.globalKey,
18+
this.isEditable = true,
1819
});
1920

2021
final String name;
2122

2223
final dynamic value;
2324
final void Function(dynamic) callback;
2425
final GlobalKey globalKey;
26+
final bool isEditable;
2527

2628
@override
2729
Widget build(BuildContext context) {
30+
final Color textColor = isEditable
31+
? (AppSettings.isDarkMode
32+
? TaskWarriorColors.white
33+
: TaskWarriorColors.black)
34+
: (AppSettings.isDarkMode
35+
? TaskWarriorColors.grey
36+
: TaskWarriorColors.grey);
37+
2838
return Card(
2939
key: globalKey,
3040
color: AppSettings.isDarkMode
3141
? const Color.fromARGB(255, 57, 57, 57)
3242
: Colors.white,
3343
child: ListTile(
44+
enabled: isEditable,
3445
textColor: AppSettings.isDarkMode
3546
? Colors.white
3647
: const Color.fromARGB(255, 48, 46, 46),
@@ -54,9 +65,7 @@ class DateTimeWidget extends StatelessWidget {
5465
fontFamily: FontFamily.poppins,
5566
fontWeight: TaskWarriorFonts.bold,
5667
fontSize: TaskWarriorFonts.fontSizeMedium,
57-
color: AppSettings.isDarkMode
58-
? TaskWarriorColors.white
59-
: TaskWarriorColors.black,
68+
color: textColor,
6069
),
6170
),
6271
TextSpan(
@@ -70,9 +79,7 @@ class DateTimeWidget extends StatelessWidget {
7079
style: TextStyle(
7180
fontFamily: FontFamily.poppins,
7281
fontSize: TaskWarriorFonts.fontSizeMedium,
73-
color: AppSettings.isDarkMode
74-
? TaskWarriorColors.white
75-
: TaskWarriorColors.black,
82+
color: textColor,
7683
),
7784
),
7885
],
@@ -187,7 +194,6 @@ class DateTimeWidget extends StatelessWidget {
187194
}
188195
}
189196
},
190-
191197
onLongPress: () => callback(null),
192198
),
193199
);
@@ -199,20 +205,31 @@ class StartWidget extends StatelessWidget {
199205
required this.name,
200206
required this.value,
201207
required this.callback,
208+
this.isEditable = true,
202209
super.key,
203210
});
204211

205212
final String name;
206213
final dynamic value;
214+
final bool isEditable;
207215
final void Function(dynamic) callback;
208216

209217
@override
210218
Widget build(BuildContext context) {
219+
final Color textColor = isEditable
220+
? (AppSettings.isDarkMode
221+
? TaskWarriorColors.white
222+
: TaskWarriorColors.black)
223+
: (AppSettings.isDarkMode
224+
? TaskWarriorColors.grey
225+
: TaskWarriorColors.grey);
226+
211227
return Card(
212228
color: AppSettings.isDarkMode
213229
? const Color.fromARGB(255, 57, 57, 57)
214230
: Colors.white,
215231
child: ListTile(
232+
enabled: isEditable,
216233
textColor: AppSettings.isDarkMode
217234
? Colors.white
218235
: const Color.fromARGB(255, 48, 46, 46),
@@ -236,9 +253,7 @@ class StartWidget extends StatelessWidget {
236253
fontFamily: FontFamily.poppins,
237254
fontWeight: TaskWarriorFonts.bold,
238255
fontSize: TaskWarriorFonts.fontSizeMedium,
239-
color: AppSettings.isDarkMode
240-
? TaskWarriorColors.white
241-
: TaskWarriorColors.black,
256+
color: textColor,
242257
),
243258
),
244259
TextSpan(
@@ -252,9 +267,7 @@ class StartWidget extends StatelessWidget {
252267
style: TextStyle(
253268
fontFamily: FontFamily.poppins,
254269
fontSize: TaskWarriorFonts.fontSizeMedium,
255-
color: AppSettings.isDarkMode
256-
? TaskWarriorColors.white
257-
: TaskWarriorColors.black,
270+
color: textColor,
258271
),
259272
),
260273
],

lib/app/modules/detailRoute/views/description_widget.dart

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,35 @@ import 'package:taskwarrior/app/utils/gen/fonts.gen.dart';
88
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
99

1010
class DescriptionWidget extends StatelessWidget {
11-
const DescriptionWidget(
12-
{required this.name,
13-
required this.value,
14-
required this.callback,
15-
super.key});
11+
const DescriptionWidget({
12+
required this.name,
13+
required this.value,
14+
required this.callback,
15+
this.isEditable = true,
16+
super.key,
17+
});
1618

1719
final String name;
1820
final dynamic value;
1921
final void Function(dynamic) callback;
22+
final bool isEditable;
2023

2124
@override
2225
Widget build(BuildContext context) {
26+
final Color textColor = isEditable
27+
? (AppSettings.isDarkMode
28+
? TaskWarriorColors.white
29+
: TaskWarriorColors.black)
30+
: (AppSettings.isDarkMode
31+
? TaskWarriorColors.grey
32+
: TaskWarriorColors.grey);
33+
2334
return Card(
2435
color: AppSettings.isDarkMode
2536
? const Color.fromARGB(255, 57, 57, 57)
2637
: Colors.white,
2738
child: ListTile(
39+
enabled: isEditable,
2840
textColor: AppSettings.isDarkMode
2941
? Colors.white
3042
: const Color.fromARGB(255, 48, 46, 46),
@@ -48,9 +60,7 @@ class DescriptionWidget extends StatelessWidget {
4860
fontFamily: FontFamily.poppins,
4961
fontWeight: TaskWarriorFonts.bold,
5062
fontSize: TaskWarriorFonts.fontSizeMedium,
51-
color: AppSettings.isDarkMode
52-
? TaskWarriorColors.white
53-
: TaskWarriorColors.black,
63+
color: textColor,
5464
),
5565
),
5666
TextSpan(
@@ -64,9 +74,7 @@ class DescriptionWidget extends StatelessWidget {
6474
style: TextStyle(
6575
fontFamily: FontFamily.poppins,
6676
fontSize: TaskWarriorFonts.fontSizeMedium,
67-
color: AppSettings.isDarkMode
68-
? TaskWarriorColors.white
69-
: TaskWarriorColors.black,
77+
color: textColor,
7078
),
7179
),
7280
],
@@ -104,7 +112,6 @@ class DescriptionWidget extends StatelessWidget {
104112
actions: [
105113
TextButton(
106114
onPressed: () {
107-
// Navigator.of(context).pop();
108115
Get.back();
109116
},
110117
child: Text(
@@ -120,7 +127,6 @@ class DescriptionWidget extends StatelessWidget {
120127
onPressed: () {
121128
try {
122129
callback(controller.text);
123-
// Navigator.of(context).pop();
124130
Get.back();
125131
} on FormatException catch (e, trace) {
126132
logError(e, trace);
@@ -145,23 +151,35 @@ class DescriptionWidget extends StatelessWidget {
145151
}
146152

147153
class ProjectWidget extends StatelessWidget {
148-
const ProjectWidget(
149-
{required this.name,
150-
required this.value,
151-
required this.callback,
152-
super.key});
154+
const ProjectWidget({
155+
required this.name,
156+
required this.value,
157+
required this.callback,
158+
this.isEditable = true,
159+
super.key,
160+
});
153161

154162
final String name;
155163
final dynamic value;
156164
final void Function(dynamic) callback;
165+
final bool isEditable;
157166

158167
@override
159168
Widget build(BuildContext context) {
169+
final Color textColor = isEditable
170+
? (AppSettings.isDarkMode
171+
? TaskWarriorColors.white
172+
: TaskWarriorColors.black)
173+
: (AppSettings.isDarkMode
174+
? TaskWarriorColors.grey
175+
: TaskWarriorColors.grey);
176+
160177
return Card(
161178
color: AppSettings.isDarkMode
162179
? const Color.fromARGB(255, 57, 57, 57)
163180
: Colors.white,
164181
child: ListTile(
182+
enabled: isEditable,
165183
textColor: AppSettings.isDarkMode
166184
? Colors.white
167185
: const Color.fromARGB(255, 48, 46, 46),
@@ -185,9 +203,7 @@ class ProjectWidget extends StatelessWidget {
185203
fontFamily: FontFamily.poppins,
186204
fontWeight: TaskWarriorFonts.bold,
187205
fontSize: TaskWarriorFonts.fontSizeMedium,
188-
color: AppSettings.isDarkMode
189-
? TaskWarriorColors.white
190-
: TaskWarriorColors.black,
206+
color: textColor,
191207
),
192208
),
193209
TextSpan(
@@ -201,9 +217,7 @@ class ProjectWidget extends StatelessWidget {
201217
style: TextStyle(
202218
fontFamily: FontFamily.poppins,
203219
fontSize: TaskWarriorFonts.fontSizeMedium,
204-
color: AppSettings.isDarkMode
205-
? TaskWarriorColors.white
206-
: TaskWarriorColors.black,
220+
color: textColor,
207221
),
208222
),
209223
],
@@ -241,7 +255,6 @@ class ProjectWidget extends StatelessWidget {
241255
actions: [
242256
TextButton(
243257
onPressed: () {
244-
// Navigator.of(context).pop();
245258
Get.back();
246259
},
247260
child: Text(
@@ -258,7 +271,6 @@ class ProjectWidget extends StatelessWidget {
258271
try {
259272
callback(
260273
(controller.text == '') ? null : controller.text);
261-
// Navigator.of(context).pop();
262274
Get.back();
263275
} on FormatException catch (e, trace) {
264276
logError(e, trace);

0 commit comments

Comments
 (0)