Skip to content

Commit 4aeb41e

Browse files
disabled editing for completed and pending task fields (#485)
1 parent 4327d71 commit 4aeb41e

File tree

7 files changed

+141
-115
lines changed

7 files changed

+141
-115
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: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,28 @@ 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) {
28-
TaskwarriorColorTheme tColors = Theme.of(context).extension<TaskwarriorColorTheme>()!;
30+
TaskwarriorColorTheme tColors =
31+
Theme.of(context).extension<TaskwarriorColorTheme>()!;
2932
return Card(
3033
key: globalKey,
3134
color: tColors.secondaryBackgroundColor,
3235
child: ListTile(
33-
textColor: tColors.primaryTextColor,
36+
enabled: isEditable,
37+
textColor: isEditable
38+
? tColors.primaryTextColor
39+
: tColors.primaryDisabledTextColor,
3440
title: SingleChildScrollView(
3541
scrollDirection: Axis.horizontal,
3642
child: Row(
@@ -51,7 +57,9 @@ class DateTimeWidget extends StatelessWidget {
5157
fontFamily: FontFamily.poppins,
5258
fontWeight: TaskWarriorFonts.bold,
5359
fontSize: TaskWarriorFonts.fontSizeMedium,
54-
color: tColors.primaryTextColor,
60+
color: isEditable
61+
? tColors.primaryTextColor
62+
: tColors.primaryDisabledTextColor,
5563
),
5664
),
5765
TextSpan(
@@ -65,7 +73,9 @@ class DateTimeWidget extends StatelessWidget {
6573
style: TextStyle(
6674
fontFamily: FontFamily.poppins,
6775
fontSize: TaskWarriorFonts.fontSizeMedium,
68-
color: tColors.primaryTextColor,
76+
color: isEditable
77+
? tColors.primaryTextColor
78+
: tColors.primaryDisabledTextColor,
6979
),
7080
),
7181
],
@@ -176,7 +186,6 @@ class DateTimeWidget extends StatelessWidget {
176186
}
177187
}
178188
},
179-
180189
onLongPress: () => callback(null),
181190
),
182191
);
@@ -188,20 +197,26 @@ class StartWidget extends StatelessWidget {
188197
required this.name,
189198
required this.value,
190199
required this.callback,
200+
this.isEditable = true,
191201
super.key,
192202
});
193203

194204
final String name;
195205
final dynamic value;
206+
final bool isEditable;
196207
final void Function(dynamic) callback;
197208

198209
@override
199210
Widget build(BuildContext context) {
200-
TaskwarriorColorTheme tColors = Theme.of(context).extension<TaskwarriorColorTheme>()!;
211+
TaskwarriorColorTheme tColors =
212+
Theme.of(context).extension<TaskwarriorColorTheme>()!;
201213
return Card(
202214
color: tColors.secondaryBackgroundColor,
203215
child: ListTile(
204-
textColor: tColors.secondaryBackgroundColor,
216+
enabled: isEditable,
217+
textColor: isEditable
218+
? tColors.primaryTextColor
219+
: tColors.primaryDisabledTextColor,
205220
title: SingleChildScrollView(
206221
scrollDirection: Axis.horizontal,
207222
child: Row(
@@ -222,7 +237,9 @@ class StartWidget extends StatelessWidget {
222237
fontFamily: FontFamily.poppins,
223238
fontWeight: TaskWarriorFonts.bold,
224239
fontSize: TaskWarriorFonts.fontSizeMedium,
225-
color: tColors.primaryTextColor,
240+
color: isEditable
241+
? tColors.primaryTextColor
242+
: tColors.primaryDisabledTextColor,
226243
),
227244
),
228245
TextSpan(
@@ -236,7 +253,9 @@ class StartWidget extends StatelessWidget {
236253
style: TextStyle(
237254
fontFamily: FontFamily.poppins,
238255
fontSize: TaskWarriorFonts.fontSizeMedium,
239-
color: tColors.primaryTextColor,
256+
color: isEditable
257+
? tColors.primaryTextColor
258+
: tColors.primaryDisabledTextColor,
240259
),
241260
),
242261
],

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

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ import 'package:taskwarrior/app/utils/gen/fonts.gen.dart';
88
import 'package:taskwarrior/app/utils/themes/theme_extension.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) {
@@ -25,7 +28,10 @@ class DescriptionWidget extends StatelessWidget {
2528
return Card(
2629
color: tColors.secondaryBackgroundColor,
2730
child: ListTile(
28-
textColor: tColors.primaryTextColor,
31+
enabled: isEditable,
32+
textColor: isEditable
33+
? tColors.primaryTextColor
34+
: tColors.primaryDisabledTextColor,
2935
title: SingleChildScrollView(
3036
scrollDirection: Axis.horizontal,
3137
child: Row(
@@ -46,7 +52,9 @@ class DescriptionWidget extends StatelessWidget {
4652
fontFamily: FontFamily.poppins,
4753
fontWeight: TaskWarriorFonts.bold,
4854
fontSize: TaskWarriorFonts.fontSizeMedium,
49-
color: tColors.primaryTextColor,
55+
color: isEditable
56+
? tColors.primaryTextColor
57+
: tColors.primaryDisabledTextColor,
5058
),
5159
),
5260
TextSpan(
@@ -60,7 +68,9 @@ class DescriptionWidget extends StatelessWidget {
6068
style: TextStyle(
6169
fontFamily: FontFamily.poppins,
6270
fontSize: TaskWarriorFonts.fontSizeMedium,
63-
color: tColors.primaryTextColor,
71+
color: isEditable
72+
? tColors.primaryTextColor
73+
: tColors.primaryDisabledTextColor,
6474
),
6575
),
6676
],
@@ -94,7 +104,6 @@ class DescriptionWidget extends StatelessWidget {
94104
actions: [
95105
TextButton(
96106
onPressed: () {
97-
// Navigator.of(context).pop();
98107
Get.back();
99108
},
100109
child: Text(
@@ -108,7 +117,6 @@ class DescriptionWidget extends StatelessWidget {
108117
onPressed: () {
109118
try {
110119
callback(controller.text);
111-
// Navigator.of(context).pop();
112120
Get.back();
113121
} on FormatException catch (e, trace) {
114122
logError(e, trace);
@@ -131,15 +139,18 @@ class DescriptionWidget extends StatelessWidget {
131139
}
132140

133141
class ProjectWidget extends StatelessWidget {
134-
const ProjectWidget(
135-
{required this.name,
136-
required this.value,
137-
required this.callback,
138-
super.key});
142+
const ProjectWidget({
143+
required this.name,
144+
required this.value,
145+
required this.callback,
146+
this.isEditable = true,
147+
super.key,
148+
});
139149

140150
final String name;
141151
final dynamic value;
142152
final void Function(dynamic) callback;
153+
final bool isEditable;
143154

144155
@override
145156
Widget build(BuildContext context) {
@@ -148,7 +159,10 @@ class ProjectWidget extends StatelessWidget {
148159
return Card(
149160
color: tColors.secondaryBackgroundColor,
150161
child: ListTile(
151-
textColor: tColors.primaryTextColor,
162+
enabled: isEditable,
163+
textColor: isEditable
164+
? tColors.primaryTextColor
165+
: tColors.primaryDisabledTextColor,
152166
title: SingleChildScrollView(
153167
scrollDirection: Axis.horizontal,
154168
child: Row(
@@ -169,7 +183,9 @@ class ProjectWidget extends StatelessWidget {
169183
fontFamily: FontFamily.poppins,
170184
fontWeight: TaskWarriorFonts.bold,
171185
fontSize: TaskWarriorFonts.fontSizeMedium,
172-
color: tColors.primaryTextColor,
186+
color: isEditable
187+
? tColors.primaryTextColor
188+
: tColors.primaryDisabledTextColor,
173189
),
174190
),
175191
TextSpan(
@@ -183,7 +199,9 @@ class ProjectWidget extends StatelessWidget {
183199
style: TextStyle(
184200
fontFamily: FontFamily.poppins,
185201
fontSize: TaskWarriorFonts.fontSizeMedium,
186-
color: tColors.primaryTextColor,
202+
color: isEditable
203+
? tColors.primaryTextColor
204+
: tColors.primaryDisabledTextColor,
187205
),
188206
),
189207
],
@@ -217,7 +235,6 @@ class ProjectWidget extends StatelessWidget {
217235
actions: [
218236
TextButton(
219237
onPressed: () {
220-
// Navigator.of(context).pop();
221238
Get.back();
222239
},
223240
child: Text(
@@ -232,7 +249,6 @@ class ProjectWidget extends StatelessWidget {
232249
try {
233250
callback(
234251
(controller.text == '') ? null : controller.text);
235-
// Navigator.of(context).pop();
236252
Get.back();
237253
} on FormatException catch (e, trace) {
238254
logError(e, trace);

0 commit comments

Comments
 (0)