Skip to content

Commit

Permalink
feat(task): add page to edit html of task
Browse files Browse the repository at this point in the history
  • Loading branch information
Benimautner committed Jun 6, 2024
1 parent dbf7549 commit 88228e5
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 20 deletions.
51 changes: 33 additions & 18 deletions lib/pages/project/task_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -68,6 +70,7 @@ class _TaskEditPageState extends State<TaskEditPage> {

_labels = widget.task.labels;
_priority = widget.task.priority;
_description = widget.task.description;

super.initState();
}
Expand Down Expand Up @@ -147,24 +150,36 @@ class _TaskEditPageState extends State<TaskEditPage> {
),
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),
Expand Down
43 changes: 43 additions & 0 deletions lib/pages/task/edit_description.dart
Original file line number Diff line number Diff line change
@@ -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<EditDescription> {
HtmlEditorController controller = HtmlEditorController();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Edit Description'),
actions: <Widget>[
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,
),
),
);
}
}
140 changes: 138 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 88228e5

Please sign in to comment.