diff --git a/lib/components/html_message.dart b/lib/components/html_message.dart index df508a4..a67377a 100644 --- a/lib/components/html_message.dart +++ b/lib/components/html_message.dart @@ -33,6 +33,8 @@ class HtmlMessage extends StatelessWidget { // there is no need to pre-validate the html, as we validate it while rendering + final matrix = Matrix.of(context); + final themeData = Theme.of(context); return Html( data: renderHtml, @@ -50,12 +52,18 @@ class HtmlMessage extends StatelessWidget { getMxcUrl: (String mxc, double width, double height) { final ratio = MediaQuery.of(context).devicePixelRatio; return Uri.parse(mxc)?.getThumbnail( - Matrix.of(context).client, + matrix.client, width: (width ?? 800) * ratio, height: (height ?? 800) * ratio, method: ThumbnailMethod.scale, ); }, + setCodeLanguage: (String key, String value) async { + await matrix.store.setItem('code_language.$key', value); + }, + getCodeLanguage: (String key) async { + return await matrix.store.getItem('code_language.$key'); + }, getPillInfo: (String identifier) async { if (room == null) { return null; diff --git a/lib/utils/famedlysdk_store.dart b/lib/utils/famedlysdk_store.dart index 6bb3f9c..34232e5 100644 --- a/lib/utils/famedlysdk_store.dart +++ b/lib/utils/famedlysdk_store.dart @@ -62,7 +62,7 @@ class Store { if (!PlatformInfos.isMobile) { await _setupLocalStorage(); try { - return await storage.getItem(key).toString(); + return await storage.getItem(key)?.toString(); } catch (_) { return null; } diff --git a/pubspec.lock b/pubspec.lock index 7a1d482..849b916 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -309,6 +309,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + flutter_highlight: + dependency: transitive + description: + name: flutter_highlight + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.0" flutter_keyboard_visibility: dependency: transitive description: @@ -348,7 +355,7 @@ packages: name: flutter_matrix_html url: "https://pub.dartlang.org" source: hosted - version: "0.1.9" + version: "0.1.10" flutter_olm: dependency: "direct main" description: @@ -408,6 +415,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + highlight: + dependency: transitive + description: + name: highlight + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.0" html: dependency: transitive description: @@ -540,7 +554,7 @@ packages: name: matrix_link_text url: "https://pub.dartlang.org" source: hosted - version: "0.3.1" + version: "0.3.2" meta: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1aa8c19..0aa8704 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: firebase_messaging: ^7.0.2 flutter_local_notifications: ^1.4.3 # desktop_notifications: ^0.0.0-dev.4 // Currently blocked by: https://github.com/canonical/desktop_notifications.dart/issues/5 - matrix_link_text: ^0.3.1 + matrix_link_text: ^0.3.2 path_provider: ^1.5.1 downloads_path_provider_28: ^0.1.0 permission_handler: ^5.0.1+1 @@ -53,7 +53,7 @@ dependencies: open_file: ^3.0.1 mime_type: ^0.3.0 bot_toast: ^3.0.0 - flutter_matrix_html: ^0.1.9 + flutter_matrix_html: ^0.1.10 moor: ^3.3.1 sqlite3_flutter_libs: ^0.2.0 sqlite3: ^0.1.4