shows room but not really
This commit is contained in:
parent
85d96b80bc
commit
a28bced44d
23 changed files with 885 additions and 805 deletions
|
|
@ -2,21 +2,16 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart";
|
||||
import "package:matrix/matrix.dart";
|
||||
import "package:nexus/controllers/thumbnail_controller.dart";
|
||||
import "package:nexus/helpers/extensions/get_headers.dart";
|
||||
import "package:nexus/helpers/extensions/link_to_mention.dart";
|
||||
import "package:nexus/helpers/launch_helper.dart";
|
||||
import "package:nexus/models/image_data.dart";
|
||||
import "package:nexus/widgets/chat_page/html/mention_chip.dart";
|
||||
import "package:nexus/widgets/chat_page/html/spoiler_text.dart";
|
||||
import "package:nexus/widgets/chat_page/html/code_block.dart";
|
||||
import "package:nexus/widgets/chat_page/html/quoted.dart";
|
||||
import "package:nexus/widgets/error_dialog.dart";
|
||||
|
||||
class Html extends ConsumerWidget {
|
||||
final String html;
|
||||
final Client client;
|
||||
const Html(this.html, {required this.client, super.key});
|
||||
const Html(this.html, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) => HtmlWidget(
|
||||
|
|
@ -38,61 +33,60 @@ class Html extends ConsumerWidget {
|
|||
)
|
||||
: null,
|
||||
|
||||
"blockquote" => Quoted(Html(element.innerHtml, client: client)),
|
||||
"blockquote" => Quoted(Html(element.innerHtml)),
|
||||
|
||||
"a" =>
|
||||
element.attributes["href"]?.parseIdentifierIntoParts() == null
|
||||
element.attributes["href"]?.mention == null
|
||||
? null
|
||||
: InlineCustomWidget(child: MentionChip(element.text)),
|
||||
|
||||
"img" =>
|
||||
element.attributes["src"] == null
|
||||
? null
|
||||
: Consumer(
|
||||
builder: (_, ref, _) => ref
|
||||
.watch(
|
||||
ThumbnailController.provider(
|
||||
ImageData(
|
||||
uri: element.attributes["src"]!,
|
||||
height: height,
|
||||
width: width,
|
||||
),
|
||||
),
|
||||
)
|
||||
.when(
|
||||
data: (uri) {
|
||||
if (uri == null) return SizedBox.shrink();
|
||||
|
||||
return InlineCustomWidget(
|
||||
child: Image.network(
|
||||
uri,
|
||||
headers: client.headers,
|
||||
errorBuilder: (_, error, _) => Text(
|
||||
"Image Failed to Load",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
height: height.toDouble(),
|
||||
width: width?.toDouble(),
|
||||
loadingBuilder: (_, child, loadingProgress) =>
|
||||
loadingProgress == null
|
||||
? child
|
||||
: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
},
|
||||
error: ErrorDialog.new,
|
||||
loading: () => InlineCustomWidget(
|
||||
child: SizedBox(
|
||||
width: width?.toDouble(),
|
||||
height: height.toDouble(),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// "img" => TODO: Img support
|
||||
// element.attributes["src"] == null
|
||||
// ? null
|
||||
// : Consumer(
|
||||
// builder: (_, ref, _) => ref
|
||||
// .watch(
|
||||
// ThumbnailController.provider(
|
||||
// ImageData(
|
||||
// uri: element.attributes["src"]!,
|
||||
// height: height,
|
||||
// width: width,
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// .when(
|
||||
// data: (uri) {
|
||||
// if (uri == null) return SizedBox.shrink();
|
||||
|
||||
// return InlineCustomWidget(
|
||||
// child: Image.network(
|
||||
// uri,
|
||||
// headers: client.headers,
|
||||
// errorBuilder: (_, error, _) => Text(
|
||||
// "Image Failed to Load",
|
||||
// style: TextStyle(
|
||||
// color: Theme.of(context).colorScheme.error,
|
||||
// ),
|
||||
// ),
|
||||
// height: height.toDouble(),
|
||||
// width: width?.toDouble(),
|
||||
// loadingBuilder: (_, child, loadingProgress) =>
|
||||
// loadingProgress == null
|
||||
// ? child
|
||||
// : CircularProgressIndicator(),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// error: ErrorDialog.new,
|
||||
// loading: () => InlineCustomWidget(
|
||||
// child: SizedBox(
|
||||
// width: width?.toDouble(),
|
||||
// height: height.toDouble(),
|
||||
// child: CircularProgressIndicator(),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
("del" ||
|
||||
"h1" ||
|
||||
"h2" ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue