Skip to content
Open
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
167 changes: 111 additions & 56 deletions lib/app/modules/detailRoute/views/description_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,64 +86,12 @@ class DescriptionWidget extends StatelessWidget {
),
),
onTap: () {
var controller = TextEditingController(
text: value,
);
showDialog(
context: context,
builder: (context) => Utils.showAlertDialog(
scrollable: true,
title: Text(
SentenceManager(currentLanguage: AppSettings.selectedLanguage)
.sentences
.editDescription,
style: TextStyle(
color: tColors.primaryTextColor,
),
),
content: TextField(
style: TextStyle(
color: tColors.primaryTextColor,
),
autofocus: true,
maxLines: null,
controller: controller,
),
actions: [
TextButton(
onPressed: () {
Get.back();
},
child: Text(
SentenceManager(
currentLanguage: AppSettings.selectedLanguage)
.sentences
.cancel,
style: TextStyle(
color: tColors.primaryTextColor,
),
),
),
TextButton(
onPressed: () {
try {
callback(controller.text);
Get.back();
} on FormatException catch (e, trace) {
logError(e, trace);
}
},
child: Text(
SentenceManager(
currentLanguage: AppSettings.selectedLanguage)
.sentences
.submit,
style: TextStyle(
color: tColors.primaryTextColor,
),
),
),
],
builder: (context) => _DescriptionEditDialog(
value: value,
callback: callback,
tColors: tColors,
),
);
},
Expand Down Expand Up @@ -295,3 +243,110 @@ class ProjectWidget extends StatelessWidget {
);
}
}

class _DescriptionEditDialog extends StatefulWidget {
const _DescriptionEditDialog({
required this.value,
required this.callback,
required this.tColors,
});

final dynamic value;
final void Function(dynamic) callback;
final TaskwarriorColorTheme tColors;

@override
State<_DescriptionEditDialog> createState() => _DescriptionEditDialogState();
}

class _DescriptionEditDialogState extends State<_DescriptionEditDialog> {
late TextEditingController controller;
final _formKey = GlobalKey<FormState>();
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _formKey is declared but never used. Consider either:

  1. Using it with _formKey.currentState?.validate() to validate the form, or
  2. Removing it if manual validation via errorText is preferred.

Currently, the code manually validates by checking controller.text.trim().isEmpty and setting errorText, which makes the Form wrapper unnecessary.

Copilot uses AI. Check for mistakes.
String? errorText;

@override
void initState() {
super.initState();
controller = TextEditingController(text: widget.value);
}

@override
void dispose() {
controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Utils.showAlertDialog(
scrollable: true,
title: Text(
SentenceManager(currentLanguage: AppSettings.selectedLanguage)
.sentences
.editDescription,
style: TextStyle(
color: widget.tColors.primaryTextColor,
),
),
content: Form(
key: _formKey,
child: TextFormField(
style: TextStyle(
color: widget.tColors.primaryTextColor,
),
decoration: InputDecoration(
errorText: errorText,
errorStyle: TextStyle(
color: Colors.red,
),
),
autofocus: true,
maxLines: null,
controller: controller,
),
),
actions: [
TextButton(
onPressed: () {
Get.back();
},
child: Text(
SentenceManager(currentLanguage: AppSettings.selectedLanguage)
.sentences
.cancel,
style: TextStyle(
color: widget.tColors.primaryTextColor,
),
),
),
TextButton(
onPressed: () {
try {
if (controller.text.trim().isEmpty) {
setState(() {
errorText = SentenceManager(
currentLanguage: AppSettings.selectedLanguage)
.sentences
.descriprtionCannotBeEmpty;
});
return;
}
widget.callback(controller.text);
Get.back();
} on FormatException catch (e, trace) {
logError(e, trace);
}
},
child: Text(
SentenceManager(currentLanguage: AppSettings.selectedLanguage)
.sentences
.submit,
style: TextStyle(
color: widget.tColors.primaryTextColor,
),
),
),
],
);
}
}