Skip to content

fix: Disabled editing for completed and pending task fields #485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class DetailRouteController extends GetxController {
late String uuid;
late Modify modify;
var onEdit = false.obs;
var isReadOnly = false.obs;

@override
void onInit() {
Expand All @@ -29,12 +30,26 @@ class DetailRouteController extends GetxController {
uuid: uuid,
);
initValues();

// Check if task is completed or deleted and set read-only state
isReadOnly.value = (modify.draft.status == 'completed' ||
modify.draft.status == 'deleted');
}

void setAttribute(String name, dynamic newValue) {
if (isReadOnly.value && name != 'status') {
return;
}

modify.set(name, newValue);
onEdit.value = true;
if(name == 'start'){

// If status is being changed, update read-only state
if (name == 'status') {
isReadOnly.value = (newValue == 'completed' || newValue == 'deleted');
}

if (name == 'start') {
debugPrint('Start Value Changed to $newValue');
startValue.value = newValue;
}
Expand Down
39 changes: 26 additions & 13 deletions lib/app/modules/detailRoute/views/dateTimePicker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,33 @@ class DateTimeWidget extends StatelessWidget {
required this.value,
required this.callback,
required this.globalKey,
this.isEditable = true,
});

final String name;

final dynamic value;
final void Function(dynamic) callback;
final GlobalKey globalKey;
final bool isEditable;

@override
Widget build(BuildContext context) {
final Color textColor = isEditable
? (AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black)
: (AppSettings.isDarkMode
? TaskWarriorColors.grey
: TaskWarriorColors.grey);

return Card(
key: globalKey,
color: AppSettings.isDarkMode
? const Color.fromARGB(255, 57, 57, 57)
: Colors.white,
child: ListTile(
enabled: isEditable,
textColor: AppSettings.isDarkMode
? Colors.white
: const Color.fromARGB(255, 48, 46, 46),
Expand All @@ -54,9 +65,7 @@ class DateTimeWidget extends StatelessWidget {
fontFamily: FontFamily.poppins,
fontWeight: TaskWarriorFonts.bold,
fontSize: TaskWarriorFonts.fontSizeMedium,
color: AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black,
color: textColor,
),
),
TextSpan(
Expand All @@ -70,9 +79,7 @@ class DateTimeWidget extends StatelessWidget {
style: TextStyle(
fontFamily: FontFamily.poppins,
fontSize: TaskWarriorFonts.fontSizeMedium,
color: AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black,
color: textColor,
),
),
],
Expand Down Expand Up @@ -187,7 +194,6 @@ class DateTimeWidget extends StatelessWidget {
}
}
},

onLongPress: () => callback(null),
),
);
Expand All @@ -199,20 +205,31 @@ class StartWidget extends StatelessWidget {
required this.name,
required this.value,
required this.callback,
this.isEditable = true,
super.key,
});

final String name;
final dynamic value;
final bool isEditable;
final void Function(dynamic) callback;

@override
Widget build(BuildContext context) {
final Color textColor = isEditable
? (AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black)
: (AppSettings.isDarkMode
? TaskWarriorColors.grey
: TaskWarriorColors.grey);

return Card(
color: AppSettings.isDarkMode
? const Color.fromARGB(255, 57, 57, 57)
: Colors.white,
child: ListTile(
enabled: isEditable,
textColor: AppSettings.isDarkMode
? Colors.white
: const Color.fromARGB(255, 48, 46, 46),
Expand All @@ -236,9 +253,7 @@ class StartWidget extends StatelessWidget {
fontFamily: FontFamily.poppins,
fontWeight: TaskWarriorFonts.bold,
fontSize: TaskWarriorFonts.fontSizeMedium,
color: AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black,
color: textColor,
),
),
TextSpan(
Expand All @@ -252,9 +267,7 @@ class StartWidget extends StatelessWidget {
style: TextStyle(
fontFamily: FontFamily.poppins,
fontSize: TaskWarriorFonts.fontSizeMedium,
color: AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black,
color: textColor,
),
),
],
Expand Down
64 changes: 38 additions & 26 deletions lib/app/modules/detailRoute/views/description_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,35 @@ import 'package:taskwarrior/app/utils/gen/fonts.gen.dart';
import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';

class DescriptionWidget extends StatelessWidget {
const DescriptionWidget(
{required this.name,
required this.value,
required this.callback,
super.key});
const DescriptionWidget({
required this.name,
required this.value,
required this.callback,
this.isEditable = true,
super.key,
});

final String name;
final dynamic value;
final void Function(dynamic) callback;
final bool isEditable;

@override
Widget build(BuildContext context) {
final Color textColor = isEditable
? (AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black)
: (AppSettings.isDarkMode
? TaskWarriorColors.grey
: TaskWarriorColors.grey);

return Card(
color: AppSettings.isDarkMode
? const Color.fromARGB(255, 57, 57, 57)
: Colors.white,
child: ListTile(
enabled: isEditable,
textColor: AppSettings.isDarkMode
? Colors.white
: const Color.fromARGB(255, 48, 46, 46),
Expand All @@ -48,9 +60,7 @@ class DescriptionWidget extends StatelessWidget {
fontFamily: FontFamily.poppins,
fontWeight: TaskWarriorFonts.bold,
fontSize: TaskWarriorFonts.fontSizeMedium,
color: AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black,
color: textColor,
),
),
TextSpan(
Expand All @@ -64,9 +74,7 @@ class DescriptionWidget extends StatelessWidget {
style: TextStyle(
fontFamily: FontFamily.poppins,
fontSize: TaskWarriorFonts.fontSizeMedium,
color: AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black,
color: textColor,
),
),
],
Expand Down Expand Up @@ -104,7 +112,6 @@ class DescriptionWidget extends StatelessWidget {
actions: [
TextButton(
onPressed: () {
// Navigator.of(context).pop();
Get.back();
},
child: Text(
Expand All @@ -120,7 +127,6 @@ class DescriptionWidget extends StatelessWidget {
onPressed: () {
try {
callback(controller.text);
// Navigator.of(context).pop();
Get.back();
} on FormatException catch (e, trace) {
logError(e, trace);
Expand All @@ -145,23 +151,35 @@ class DescriptionWidget extends StatelessWidget {
}

class ProjectWidget extends StatelessWidget {
const ProjectWidget(
{required this.name,
required this.value,
required this.callback,
super.key});
const ProjectWidget({
required this.name,
required this.value,
required this.callback,
this.isEditable = true,
super.key,
});

final String name;
final dynamic value;
final void Function(dynamic) callback;
final bool isEditable;

@override
Widget build(BuildContext context) {
final Color textColor = isEditable
? (AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black)
: (AppSettings.isDarkMode
? TaskWarriorColors.grey
: TaskWarriorColors.grey);

return Card(
color: AppSettings.isDarkMode
? const Color.fromARGB(255, 57, 57, 57)
: Colors.white,
child: ListTile(
enabled: isEditable,
textColor: AppSettings.isDarkMode
? Colors.white
: const Color.fromARGB(255, 48, 46, 46),
Expand All @@ -185,9 +203,7 @@ class ProjectWidget extends StatelessWidget {
fontFamily: FontFamily.poppins,
fontWeight: TaskWarriorFonts.bold,
fontSize: TaskWarriorFonts.fontSizeMedium,
color: AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black,
color: textColor,
),
),
TextSpan(
Expand All @@ -201,9 +217,7 @@ class ProjectWidget extends StatelessWidget {
style: TextStyle(
fontFamily: FontFamily.poppins,
fontSize: TaskWarriorFonts.fontSizeMedium,
color: AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black,
color: textColor,
),
),
],
Expand Down Expand Up @@ -241,7 +255,6 @@ class ProjectWidget extends StatelessWidget {
actions: [
TextButton(
onPressed: () {
// Navigator.of(context).pop();
Get.back();
},
child: Text(
Expand All @@ -258,7 +271,6 @@ class ProjectWidget extends StatelessWidget {
try {
callback(
(controller.text == '') ? null : controller.text);
// Navigator.of(context).pop();
Get.back();
} on FormatException catch (e, trace) {
logError(e, trace);
Expand Down
Loading
Loading