@@ -8,6 +8,7 @@ import 'package:taskwarrior/app/utils/constants/utilites.dart';
88import 'package:taskwarrior/app/utils/gen/fonts.gen.dart' ;
99import 'package:taskwarrior/app/utils/themes/theme_extension.dart' ;
1010import 'package:taskwarrior/app/utils/language/sentence_manager.dart' ;
11+ import 'package:taskwarrior/app/modules/detailRoute/controllers/detail_route_controller.dart' ;
1112
1213class DescriptionWidget extends StatelessWidget {
1314 const DescriptionWidget ({
@@ -25,6 +26,7 @@ class DescriptionWidget extends StatelessWidget {
2526
2627 @override
2728 Widget build (BuildContext context) {
29+ final controller = Get .find <DetailRouteController >();
2830 TaskwarriorColorTheme tColors =
2931 Theme .of (context).extension < TaskwarriorColorTheme > ()! ;
3032 return Card (
@@ -86,64 +88,66 @@ class DescriptionWidget extends StatelessWidget {
8688 ),
8789 ),
8890 onTap: () {
89- var controller = TextEditingController (
90- text: value,
91- );
91+ controller.prepareDescriptionEdit (value ?? '' );
9292 showDialog (
9393 context: context,
94- builder: (context) => Utils .showAlertDialog (
95- scrollable: true ,
96- title: Text (
97- SentenceManager (currentLanguage: AppSettings .selectedLanguage)
98- .sentences
99- .editDescription,
100- style: TextStyle (
101- color: tColors.primaryTextColor,
102- ),
103- ),
104- content: TextField (
105- style: TextStyle (
106- color: tColors.primaryTextColor,
94+ builder: (context) => Obx (
95+ () => Utils .showAlertDialog (
96+ scrollable: true ,
97+ title: Text (
98+ SentenceManager (currentLanguage: AppSettings .selectedLanguage)
99+ .sentences
100+ .editDescription,
101+ style: TextStyle (
102+ color: tColors.primaryTextColor,
103+ ),
107104 ),
108- autofocus: true ,
109- maxLines: null ,
110- controller: controller,
111- ),
112- actions: [
113- TextButton (
114- onPressed: () {
115- Get .back ();
116- },
117- child: Text (
118- SentenceManager (
119- currentLanguage: AppSettings .selectedLanguage)
120- .sentences
121- .cancel,
122- style: TextStyle (
123- color: tColors.primaryTextColor,
105+ content: TextField (
106+ style: TextStyle (
107+ color: tColors.primaryTextColor,
108+ ),
109+ decoration: InputDecoration (
110+ errorText: controller.descriptionErrorText.value,
111+ errorStyle: const TextStyle (
112+ color: Colors .red,
124113 ),
125114 ),
115+ autofocus: true ,
116+ maxLines: null ,
117+ controller: controller.descriptionController,
126118 ),
127- TextButton (
128- onPressed: () {
129- try {
130- callback (controller.text);
131- Get .back ();
132- } on FormatException catch (e, trace) {
133- logError (e, trace);
134- }
135- },
136- child: Text (
137- SentenceManager (
138- currentLanguage: AppSettings .selectedLanguage)
139- .sentences
140- .submit,
141- style: TextStyle (
142- color: tColors.primaryTextColor,
119+ actions: [
120+ TextButton (
121+ onPressed: () => Get .back (),
122+ child: Text (
123+ SentenceManager (
124+ currentLanguage: AppSettings .selectedLanguage)
125+ .sentences
126+ .cancel,
127+ style: TextStyle (
128+ color: tColors.primaryTextColor,
129+ ),
143130 ),
144131 ),
145- ),
146- ],
132+ TextButton (
133+ onPressed: () {
134+ if (controller.validateDescription ()) {
135+ callback (controller.descriptionController.text);
136+ Get .back ();
137+ }
138+ },
139+ child: Text (
140+ SentenceManager (
141+ currentLanguage: AppSettings .selectedLanguage)
142+ .sentences
143+ .submit,
144+ style: TextStyle (
145+ color: tColors.primaryTextColor,
146+ ),
147+ ),
148+ ),
149+ ],
150+ ),
147151 ),
148152 );
149153 },
0 commit comments