From 62aeeedca64f35a84a30ef2aa302c0563ef6305d Mon Sep 17 00:00:00 2001 From: Benimautner Date: Fri, 5 Jan 2024 22:29:34 +0100 Subject: [PATCH] added html renderer to task description in overview. --- lib/components/TaskTile.dart | 5 +- lib/pages/user/login_webview.dart | 30 ++- pubspec.lock | 408 ++++++++++++++++++++++++++++-- pubspec.yaml | 7 +- 4 files changed, 415 insertions(+), 35 deletions(-) diff --git a/lib/components/TaskTile.dart b/lib/components/TaskTile.dart index 7441721..4be707e 100644 --- a/lib/components/TaskTile.dart +++ b/lib/components/TaskTile.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:provider/provider.dart'; import 'package:vikunja_app/models/task.dart'; import 'package:vikunja_app/utils/misc.dart'; @@ -51,7 +52,7 @@ Widget? _buildTaskSubtitle(Task? task, bool showInfo) { } if(texts.isEmpty && task.description.isNotEmpty) { - return Text(task.description); + return HtmlWidget(task.description); } if(texts.isNotEmpty) { @@ -84,7 +85,7 @@ class TaskTileState extends State with AutomaticKeepAliveClientMixin { subtitle: _currentTask.description.isEmpty ? null - : Text(_currentTask.description), + : HtmlWidget(_currentTask.description), trailing: IconButton( icon: Icon(Icons.settings), onPressed: () { }, ), diff --git a/lib/pages/user/login_webview.dart b/lib/pages/user/login_webview.dart index ff75ca8..2b72c2a 100644 --- a/lib/pages/user/login_webview.dart +++ b/lib/pages/user/login_webview.dart @@ -17,22 +17,38 @@ class LoginWithWebView extends StatefulWidget { class LoginWithWebViewState extends State { - WebView? webView; + WebViewWidget? webView; WebViewController? webViewController; + + @override void initState() { super.initState(); - webView = WebView( + webViewController = WebViewController() + ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..setUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Mobile Safari/537.36") + ..setNavigationDelegate(NavigationDelegate( + onPageFinished: (value) => _handlePageFinished(value), + )) + + ..loadRequest(Uri.parse(widget.frontEndUrl)).then((value) => { + webViewController!.runJavaScript("localStorage.clear(); location.href=location.href;") + }); + + /* + webView = WebViewWidget( initialUrl: widget.frontEndUrl, javascriptMode: JavascriptMode.unrestricted, onPageFinished: (value) => _handlePageFinished(value), userAgent: "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Mobile Safari/537.36", onWebViewCreated: (controller) { webViewController = controller; - webViewController!.runJavascript("localStorage.clear(); location.href=location.href;"); + webViewController!.runJavaScript("localStorage.clear(); location.href=location.href;"); }, ); + */ + } @override @@ -54,11 +70,11 @@ class LoginWithWebViewState extends State { Future _handlePageFinished(String pageLocation) async { log("handlePageFinished"); if(webViewController != null) { - String localStorage = await webViewController! - .runJavascriptReturningResult("JSON.stringify(localStorage);"); + String localStorage = (await webViewController! + .runJavaScriptReturningResult("JSON.stringify(localStorage);")).toString(); - String apiUrl = await webViewController!.runJavascriptReturningResult("API_URL"); - if (localStorage != "{}") { + String apiUrl = (await webViewController!.runJavaScriptReturningResult("API_URL")).toString(); + if (localStorage.toString() != "{}") { apiUrl = apiUrl.replaceAll("\"", ""); if(!apiUrl.startsWith("http")) { if(pageLocation.endsWith("/")) diff --git a/pubspec.lock b/pubspec.lock index a5ea771..468d34b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -29,10 +29,10 @@ packages: dependency: transitive description: name: archive - sha256: "7b875fd4a20b165a3084bd2d210439b22ebc653f21cea4842729c0c30c82596b" + sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d" url: "https://pub.dev" source: hosted - version: "3.4.9" + version: "3.4.10" args: dependency: transitive description: @@ -49,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + audio_session: + dependency: transitive + description: + name: audio_session + sha256: "6fdf255ed3af86535c96452c33ecff1245990bb25a605bfb1958661ccc3d467f" + url: "https://pub.dev" + source: hosted + version: "0.1.18" boolean_selector: dependency: transitive description: @@ -73,6 +81,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + cached_network_image: + dependency: transitive + description: + name: cached_network_image + sha256: "28ea9690a8207179c319965c13cd8df184d5ee721ae2ce60f398ced1219cea1f" + url: "https://pub.dev" + source: hosted + version: "3.3.1" + cached_network_image_platform_interface: + dependency: transitive + description: + name: cached_network_image_platform_interface + sha256: "9e90e78ae72caa874a323d78fa6301b3fb8fa7ea76a8f96dc5b5bf79f283bf2f" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + cached_network_image_web: + dependency: transitive + description: + name: cached_network_image_web + sha256: "42a835caa27c220d1294311ac409a43361088625a4f23c820b006dd9bffb3316" + url: "https://pub.dev" + source: hosted + version: "1.1.1" characters: dependency: transitive description: @@ -89,6 +121,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" + chewie: + dependency: "direct main" + description: + name: chewie + sha256: "745e81e84c6d7f3835f89f85bb49771c0a66099e4caf8f8e9e9a372bc66fb2c1" + url: "https://pub.dev" + source: hosted + version: "1.5.0" cli_util: dependency: transitive description: @@ -137,6 +177,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + csslib: + dependency: transitive + description: + name: csslib + sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" + url: "https://pub.dev" + source: hosted + version: "1.0.0" cupertino_icons: dependency: "direct main" description: @@ -214,6 +262,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_cache_manager: + dependency: transitive + description: + name: flutter_cache_manager + sha256: "8207f27539deb83732fdda03e259349046a39a4c767269285f449ade355d54ba" + url: "https://pub.dev" + source: hosted + version: "3.3.1" flutter_colorpicker: dependency: "direct main" description: @@ -350,6 +406,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c + url: "https://pub.dev" + source: hosted + version: "2.0.9" flutter_test: dependency: "direct dev" description: flutter @@ -376,6 +440,22 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_widget_from_html: + dependency: "direct main" + description: + name: flutter_widget_from_html + sha256: d2ad036fb34a4f6ab84c21196788a5b1620f34d7930d16b32daadb511be24bb2 + url: "https://pub.dev" + source: hosted + version: "0.14.10+1" + flutter_widget_from_html_core: + dependency: transitive + description: + name: flutter_widget_from_html_core + sha256: "0e281196f962fd951da5b9d3fa50e0674fabf8fda92eafd8745d050d70877c68" + url: "https://pub.dev" + source: hosted + version: "0.14.10+1" frontend_server_client: dependency: transitive description: @@ -384,6 +464,54 @@ packages: url: "https://pub.dev" source: hosted version: "3.2.0" + fwfh_cached_network_image: + dependency: transitive + description: + name: fwfh_cached_network_image + sha256: "952aea958a5fda7d616cc297ba4bc08427e381459e75526fa375d6d8345630d3" + url: "https://pub.dev" + source: hosted + version: "0.14.2" + fwfh_chewie: + dependency: transitive + description: + name: fwfh_chewie + sha256: bbb036cd322ab77dc0edd34cbbf76181681f5e414987ece38745dc4f3d7408ed + url: "https://pub.dev" + source: hosted + version: "0.14.7" + fwfh_just_audio: + dependency: transitive + description: + name: fwfh_just_audio + sha256: "4962bc59cf8bbb0a77a55ff56a7b925612b0d8263bc2ede3636b9c86113cb493" + url: "https://pub.dev" + source: hosted + version: "0.14.2" + fwfh_svg: + dependency: transitive + description: + name: fwfh_svg + sha256: "3fd83926b7245d287f133a437ef430befd99d3b00ba8c600f26cc324af281f72" + url: "https://pub.dev" + source: hosted + version: "0.8.1" + fwfh_url_launcher: + dependency: transitive + description: + name: fwfh_url_launcher + sha256: "2a526c9819f74b4106ba2fba4dac79f0082deecd8d2c7011cd0471cb710e3eff" + url: "https://pub.dev" + source: hosted + version: "0.9.0+4" + fwfh_webview: + dependency: transitive + description: + name: fwfh_webview + sha256: b828bb5ddd4361a866cdb8f1b0de4f3348f332915ecf2f4215ba17e46c656adc + url: "https://pub.dev" + source: hosted + version: "0.14.8" glob: dependency: transitive description: @@ -392,6 +520,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + html: + dependency: transitive + description: + name: html + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" + url: "https://pub.dev" + source: hosted + version: "0.15.4" http: dependency: "direct main" description: @@ -464,6 +600,30 @@ packages: url: "https://pub.dev" source: hosted version: "6.7.1" + just_audio: + dependency: transitive + description: + name: just_audio + sha256: b607cd1a43bac03d85c3aaee00448ff4a589ef2a77104e3d409889ff079bf823 + url: "https://pub.dev" + source: hosted + version: "0.9.36" + just_audio_platform_interface: + dependency: transitive + description: + name: just_audio_platform_interface + sha256: c3dee0014248c97c91fe6299edb73dc4d6c6930a2f4f713579cd692d9e47f4a1 + url: "https://pub.dev" + source: hosted + version: "4.2.2" + just_audio_web: + dependency: transitive + description: + name: just_audio_web + sha256: "134356b0fe3d898293102b33b5fd618831ffdc72bb7a1b726140abdf22772b70" + url: "https://pub.dev" + source: hosted + version: "0.4.9" logging: dependency: transitive description: @@ -520,6 +680,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + octo_image: + dependency: transitive + description: + name: octo_image + sha256: "45b40f99622f11901238e18d48f5f12ea36426d8eced9f4cbf58479c7aa2430d" + url: "https://pub.dev" + source: hosted + version: "2.0.0" package_config: dependency: transitive description: @@ -568,6 +736,54 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa + url: "https://pub.dev" + source: hosted + version: "2.1.1" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668" + url: "https://pub.dev" + source: hosted + version: "2.2.2" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + url: "https://pub.dev" + source: hosted + version: "2.2.1" permission_handler: dependency: "direct main" description: @@ -620,18 +836,18 @@ packages: dependency: transitive description: name: platform - sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59" + sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" url: "https://pub.dev" source: hosted - version: "3.1.3" + version: "3.1.4" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" url: "https://pub.dev" source: hosted - version: "2.1.7" + version: "2.1.8" pointer_interceptor: dependency: transitive description: @@ -773,6 +989,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + sqflite: + dependency: transitive + description: + name: sqflite + sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + sha256: bb4738f15b23352822f4c42a531677e5c6f522e079461fd240ead29d8d8a54a6 + url: "https://pub.dev" + source: hosted + version: "2.5.0+2" stack_trace: dependency: transitive description: @@ -797,6 +1037,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558" + url: "https://pub.dev" + source: hosted + version: "3.1.0+1" term_glyph: dependency: transitive description: @@ -857,18 +1105,18 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def" + sha256: c0766a55ab42cefaa728cabc951e82919ab41a3a4fee0aaa96176ca82da8cc51 url: "https://pub.dev" source: hosted - version: "6.2.0" + version: "6.2.1" url_launcher_ios: dependency: transitive description: name: url_launcher_ios - sha256: bba3373219b7abb6b5e0d071b0fe66dfbe005d07517a68e38d4fc3638f35c6d3 + sha256: "46b81e3109cbb2d6b81702ad3077540789a3e74e22795eb9f0b7d494dbaa72ea" url: "https://pub.dev" source: hosted - version: "6.2.1" + version: "6.2.2" url_launcher_linux: dependency: transitive description: @@ -889,18 +1137,18 @@ packages: dependency: transitive description: name: url_launcher_platform_interface - sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50" + sha256: "4aca1e060978e19b2998ee28503f40b5ba6226819c2b5e3e4d1821e8ccd92198" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.0" url_launcher_web: dependency: transitive description: name: url_launcher_web - sha256: "7286aec002c8feecc338cc33269e96b73955ab227456e9fb2a91f7fab8a358e9" + sha256: fff0932192afeedf63cdd50ecbb1bc825d31aed259f02bb8dba0f3b729a5e88b url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.2.3" url_launcher_windows: dependency: transitive description: @@ -909,6 +1157,38 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" + uuid: + dependency: transitive + description: + name: uuid + sha256: "22c94e5ad1e75f9934b766b53c742572ee2677c56bc871d850a57dad0f82127f" + url: "https://pub.dev" + source: hosted + version: "4.2.2" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" vector_math: dependency: transitive description: @@ -917,6 +1197,46 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + video_player: + dependency: transitive + description: + name: video_player + sha256: fbf28ce8bcfe709ad91b5789166c832cb7a684d14f571a81891858fefb5bb1c2 + url: "https://pub.dev" + source: hosted + version: "2.8.2" + video_player_android: + dependency: transitive + description: + name: video_player_android + sha256: "7f8f25d7ad56819a82b2948357f3c3af071f6a678db33833b26ec36bbc221316" + url: "https://pub.dev" + source: hosted + version: "2.4.11" + video_player_avfoundation: + dependency: transitive + description: + name: video_player_avfoundation + sha256: "752b783a00748684312dd6a68e22f795281d295921e69ae5ad36f90b7fb39cdb" + url: "https://pub.dev" + source: hosted + version: "2.5.5" + video_player_platform_interface: + dependency: transitive + description: + name: video_player_platform_interface + sha256: be72301bf2c0150ab35a8c34d66e5a99de525f6de1e8d27c0672b836fe48f73a + url: "https://pub.dev" + source: hosted + version: "6.2.1" + video_player_web: + dependency: transitive + description: + name: video_player_web + sha256: "34beb3a07d4331a24f7e7b2f75b8e2b103289038e07e65529699a671b6a6e2cb" + url: "https://pub.dev" + source: hosted + version: "2.1.3" vm_service: dependency: transitive description: @@ -925,6 +1245,46 @@ packages: url: "https://pub.dev" source: hosted version: "13.0.0" + wakelock: + dependency: transitive + description: + name: wakelock + sha256: "769ecf42eb2d07128407b50cb93d7c10bd2ee48f0276ef0119db1d25cc2f87db" + url: "https://pub.dev" + source: hosted + version: "0.6.2" + wakelock_macos: + dependency: transitive + description: + name: wakelock_macos + sha256: "047c6be2f88cb6b76d02553bca5a3a3b95323b15d30867eca53a19a0a319d4cd" + url: "https://pub.dev" + source: hosted + version: "0.4.0" + wakelock_platform_interface: + dependency: transitive + description: + name: wakelock_platform_interface + sha256: "1f4aeb81fb592b863da83d2d0f7b8196067451e4df91046c26b54a403f9de621" + url: "https://pub.dev" + source: hosted + version: "0.3.0" + wakelock_web: + dependency: transitive + description: + name: wakelock_web + sha256: "1b256b811ee3f0834888efddfe03da8d18d0819317f20f6193e2922b41a501b5" + url: "https://pub.dev" + source: hosted + version: "0.4.0" + wakelock_windows: + dependency: transitive + description: + name: wakelock_windows + sha256: "857f77b3fe6ae82dd045455baa626bc4b93cb9bb6c86bf3f27c182167c3a5567" + url: "https://pub.dev" + source: hosted + version: "0.2.1" watcher: dependency: transitive description: @@ -961,42 +1321,42 @@ packages: dependency: "direct main" description: name: webview_flutter - sha256: "392c1d83b70fe2495de3ea2c84531268d5b8de2de3f01086a53334d8b6030a88" + sha256: "60e23976834e995c404c0b21d3b9db37ecd77d3303ef74f8b8d7a7b19947fc04" url: "https://pub.dev" source: hosted - version: "3.0.4" + version: "4.4.3" webview_flutter_android: dependency: transitive description: name: webview_flutter_android - sha256: "8b3b2450e98876c70bfcead876d9390573b34b9418c19e28168b74f6cb252dbd" + sha256: "161af93c2abaf94ef2192bffb53a3658b2d721a3bf99b69aa1e47814ee18cc96" url: "https://pub.dev" source: hosted - version: "2.10.4" + version: "3.13.2" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface - sha256: "812165e4e34ca677bdfbfa58c01e33b27fd03ab5fa75b70832d4b7d4ca1fa8cf" + sha256: dbe745ee459a16b6fec296f7565a8ef430d0d681001d8ae521898b9361854943 url: "https://pub.dev" source: hosted - version: "1.9.5" + version: "2.9.0" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview - sha256: a5364369c758892aa487cbf59ea41d9edd10f9d9baf06a94e80f1bd1b4c7bbc0 + sha256: "02d8f3ebbc842704b2b662377b3ee11c0f8f1bbaa8eab6398262f40049819160" url: "https://pub.dev" source: hosted - version: "2.9.5" + version: "3.10.1" win32: dependency: transitive description: name: win32 - sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" + sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4 url: "https://pub.dev" source: hosted - version: "4.1.4" + version: "3.1.4" workmanager: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index b93d1a8..d6e8abc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,15 +23,18 @@ dependencies: json_serializable: ^6.3.1 petitparser: ^5.0.0 provider: ^6.0.3 - webview_flutter: ^3.0.4 + webview_flutter: ^4.4.3 flutter_colorpicker: ^1.0.3 - flutter_keyboard_visibility: ^5.3.0 + flutter_keyboard_visibility: ^5.4.2 dotted_border: ^2.0.0+2 package_info_plus: ^3.0.2 url_launcher: ^6.1.7 workmanager: ^0.5.1 permission_handler: ^10.2.0 dynamic_color: ^1.6.6 + chewie: ^1.5.0 + flutter_widget_from_html: ^0.14.10 + dev_dependencies: flutter_test: