diff --git a/lib/widgets/html/html.dart b/lib/widgets/html/html.dart index 9236e9a..06e3ebb 100644 --- a/lib/widgets/html/html.dart +++ b/lib/widgets/html/html.dart @@ -8,7 +8,7 @@ import "package:nexus/helpers/launch_helper.dart"; import "package:nexus/helpers/mxc_image.dart"; import "package:nexus/widgets/common/expandable_image.dart"; import "package:nexus/widgets/html/mention_chip.dart"; -import "package:nexus/widgets/html/spoiler_text.dart"; +import "package:nexus/widgets/html/spoiler.dart"; import "package:nexus/widgets/html/code_block.dart"; import "package:nexus/widgets/html/quoted.dart"; @@ -29,7 +29,11 @@ class const Html( } if (element.attributes.keys.contains("data-mx-spoiler")) { - return InlineCustomWidget(child: SpoilerText(element.text)); + return InlineCustomWidget( + child: Spoiler( + Html(element.innerHtml, textStyle: textStyle, roomId: roomId), + ), + ); } final height = diff --git a/lib/widgets/html/spoiler_text.dart b/lib/widgets/html/spoiler.dart similarity index 55% rename from lib/widgets/html/spoiler_text.dart rename to lib/widgets/html/spoiler.dart index 8094f9d..7970bf3 100644 --- a/lib/widgets/html/spoiler_text.dart +++ b/lib/widgets/html/spoiler.dart @@ -1,7 +1,7 @@ import "package:material_ui/material_ui.dart"; import "package:flutter_hooks/flutter_hooks.dart"; -class const SpoilerText(final String text, {super.key}) extends HookWidget { +class const Spoiler(final Widget child, {super.key}) extends HookWidget { @override Widget build(BuildContext context) { final revealed = useState(false); @@ -11,15 +11,14 @@ class const SpoilerText(final String text, {super.key}) extends HookWidget { child: AnimatedContainer( duration: Durations.short2, decoration: BoxDecoration( - color: revealed.value - ? Colors.blueGrey.withValues(alpha: 0.3) - : Colors.blueGrey, + color: Colors.blueGrey.withValues(alpha: 0.3), borderRadius: .circular(4), ), - child: Text( - text, - style: .new(color: revealed.value ? null : Colors.transparent), + foregroundDecoration: BoxDecoration( + color: revealed.value ? Colors.transparent : Colors.blueGrey, + borderRadius: .circular(4), ), + child: IgnorePointer(ignoring: !revealed.value, child: child), ), ); }