From 88228e5f287be85b1b7de707d158ba6d5851dd23 Mon Sep 17 00:00:00 2001 From: Benimautner Date: Thu, 6 Jun 2024 23:11:20 +0200 Subject: [PATCH] feat(task): add page to edit html of task --- lib/pages/project/task_edit.dart | 51 ++++++---- lib/pages/task/edit_description.dart | 43 ++++++++ pubspec.lock | 140 ++++++++++++++++++++++++++- pubspec.yaml | 1 + 4 files changed, 215 insertions(+), 20 deletions(-) create mode 100644 lib/pages/task/edit_description.dart diff --git a/lib/pages/project/task_edit.dart b/lib/pages/project/task_edit.dart index eef5158..2923461 100644 --- a/lib/pages/project/task_edit.dart +++ b/lib/pages/project/task_edit.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart'; +import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:vikunja_app/components/datetimePicker.dart'; import 'package:vikunja_app/components/label.dart'; import 'package:vikunja_app/global.dart'; @@ -11,6 +12,7 @@ import 'package:vikunja_app/utils/repeat_after_parse.dart'; import 'package:vikunja_app/utils/priority.dart'; import '../../stores/project_store.dart'; +import '../task/edit_description.dart'; class TaskEditPage extends StatefulWidget { final Task task; @@ -68,6 +70,7 @@ class _TaskEditPageState extends State { _labels = widget.task.labels; _priority = widget.task.priority; + _description = widget.task.description; super.initState(); } @@ -147,24 +150,36 @@ class _TaskEditPageState extends State { ), Padding( padding: EdgeInsets.symmetric(vertical: 10.0), - child: TextFormField( - maxLines: null, - keyboardType: TextInputType.multiline, - initialValue: widget.task.description, - onSaved: (description) => _description = description, - onChanged: (_) => _changed = true, - validator: (description) { - if (description == null) return null; - if (description.length > 1000) { - return 'The description can have a maximum of 1000 characters.'; - } - return null; - }, - decoration: new InputDecoration( - labelText: 'Description', - border: OutlineInputBorder(), - ), - ), + child: Row( + children: [ + Padding( + padding: + EdgeInsets.only(right: 15, left: 2), + child: Icon( + Icons.description, + color: Colors.grey, + )), + Flexible( + child: GestureDetector( + onTap: () { + // open editdescription + Navigator.push( + context, + MaterialPageRoute( + builder: (buildContext) => EditDescription(initialText: _description,) + ), + ).then((description) => setState(() { + if (description != null) _description = description; + _changed = true; + })); + }, + child: HtmlWidget(_description != null + ? _description! + : "No description"), + ), + ), + ], + ) ), Padding( padding: EdgeInsets.symmetric(vertical: 10.0), diff --git a/lib/pages/task/edit_description.dart b/lib/pages/task/edit_description.dart new file mode 100644 index 0000000..0847d03 --- /dev/null +++ b/lib/pages/task/edit_description.dart @@ -0,0 +1,43 @@ +import 'package:html_editor_enhanced/html_editor.dart'; + +import 'package:flutter/material.dart'; + + + + +class EditDescription extends StatefulWidget { + final String? initialText; + EditDescription({required this.initialText}); + @override + EditDescriptionState createState() => EditDescriptionState(); +} + +class EditDescriptionState extends State { + HtmlEditorController controller = HtmlEditorController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Edit Description'), + actions: [ + IconButton( + icon: Icon(Icons.save), + onPressed: () { + print(controller.getText()); + Navigator.pop(context, controller.getText()); + }, + ) + ], + ), + body: HtmlEditor( + + controller: controller, + htmlEditorOptions: HtmlEditorOptions( + hint: "Your text here...", + initialText: widget.initialText, + ), + ), + ); + } +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index c6a9b9a..3120a35 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -177,6 +177,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32" + url: "https://pub.dev" + source: hosted + version: "0.3.4+1" crypto: dependency: transitive description: @@ -273,6 +281,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + file_picker: + dependency: transitive + description: + name: file_picker + sha256: "29c90806ac5f5fb896547720b73b17ee9aed9bba540dc5d91fe29f8c5745b10a" + url: "https://pub.dev" + source: hosted + version: "8.0.3" fixnum: dependency: transitive description: @@ -281,6 +297,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + flex_color_picker: + dependency: transitive + description: + name: flex_color_picker + sha256: "31b27677d8d8400e4cff5edb3f189f606dd964d608779b6ae1b7ddad37ea48c6" + url: "https://pub.dev" + source: hosted + version: "3.5.0" + flex_seed_scheme: + dependency: transitive + description: + name: flex_seed_scheme + sha256: fb66cdb8ca89084e79efcad2bc2d9deb144666875116f08cdd8d9f8238c8b3ab + url: "https://pub.dev" + source: hosted + version: "2.0.0" flutter: dependency: "direct main" description: flutter @@ -310,6 +342,62 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.7" + flutter_inappwebview: + dependency: transitive + description: + name: flutter_inappwebview + sha256: "3e9a443a18ecef966fb930c3a76ca5ab6a7aafc0c7b5e14a4a850cf107b09959" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + flutter_inappwebview_android: + dependency: transitive + description: + name: flutter_inappwebview_android + sha256: d247f6ed417f1f8c364612fa05a2ecba7f775c8d0c044c1d3b9ee33a6515c421 + url: "https://pub.dev" + source: hosted + version: "1.0.13" + flutter_inappwebview_internal_annotations: + dependency: transitive + description: + name: flutter_inappwebview_internal_annotations + sha256: "5f80fd30e208ddded7dbbcd0d569e7995f9f63d45ea3f548d8dd4c0b473fb4c8" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter_inappwebview_ios: + dependency: transitive + description: + name: flutter_inappwebview_ios + sha256: f363577208b97b10b319cd0c428555cd8493e88b468019a8c5635a0e4312bd0f + url: "https://pub.dev" + source: hosted + version: "1.0.13" + flutter_inappwebview_macos: + dependency: transitive + description: + name: flutter_inappwebview_macos + sha256: b55b9e506c549ce88e26580351d2c71d54f4825901666bd6cfa4be9415bb2636 + url: "https://pub.dev" + source: hosted + version: "1.0.11" + flutter_inappwebview_platform_interface: + dependency: transitive + description: + name: flutter_inappwebview_platform_interface + sha256: "545fd4c25a07d2775f7d5af05a979b2cac4fbf79393b0a7f5d33ba39ba4f6187" + url: "https://pub.dev" + source: hosted + version: "1.0.10" + flutter_inappwebview_web: + dependency: transitive + description: + name: flutter_inappwebview_web + sha256: d8c680abfb6fec71609a700199635d38a744df0febd5544c5a020bd73de8ee07 + url: "https://pub.dev" + source: hosted + version: "1.0.8" flutter_keyboard_visibility: dependency: "direct main" description: @@ -390,6 +478,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.1.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: c6b0b4c05c458e1c01ad9bcc14041dd7b1f6783d487be4386f793f47a8a4d03e + url: "https://pub.dev" + source: hosted + version: "2.0.20" flutter_secure_storage: dependency: "direct main" description: @@ -560,6 +656,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.15.4" + html_editor_enhanced: + dependency: "direct main" + description: + name: html_editor_enhanced + sha256: "5ae6cd965cca77f7186efccc47ca353799e831b31bd71438687a56131bbcd3a5" + url: "https://pub.dev" + source: hosted + version: "2.6.0" http: dependency: "direct main" description: @@ -592,6 +696,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.2.0" + infinite_listview: + dependency: transitive + description: + name: infinite_listview + sha256: f6062c1720eb59be553dfa6b89813d3e8dd2f054538445aaa5edaddfa5195ce6 + url: "https://pub.dev" + source: hosted + version: "1.1.0" intl: dependency: "direct main" description: @@ -688,6 +800,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235" + url: "https://pub.dev" + source: hosted + version: "4.0.0" logging: dependency: transitive description: @@ -744,6 +864,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + numberpicker: + dependency: transitive + description: + name: numberpicker + sha256: "4c129154944b0f6b133e693f8749c3f8bfb67c4d07ef9dcab48b595c22d1f156" + url: "https://pub.dev" + source: hosted + version: "2.1.2" octo_image: dependency: transitive description: @@ -1317,6 +1445,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.0" + visibility_detector: + dependency: transitive + description: + name: visibility_detector + sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420 + url: "https://pub.dev" + source: hosted + version: "0.4.0+2" vm_service: dependency: transitive description: @@ -1454,5 +1590,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.3.0 <4.0.0" - flutter: ">=3.19.0" + dart: ">=3.4.0 <4.0.0" + flutter: ">=3.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1bb13ad..520e0d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,6 +40,7 @@ dependencies: cupertino_http: ^1.4.0 cronet_http: ^1.2.0 package_info_plus: any + html_editor_enhanced: ^2.6.0 dev_dependencies: flutter_test: sdk: flutter