Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 36 additions & 27 deletions lib/html_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -336,37 +336,46 @@ class HtmlParser extends StatelessWidget {
);
}
} else if (tree is InteractableElement) {
InlineSpan addTaps(InlineSpan childSpan, TextStyle childStyle) {
if (childSpan is TextSpan) {
return TextSpan(
text: childSpan.text,
children: childSpan.children
?.map((e) => addTaps(e, childStyle.merge(childSpan.style)))
?.toList(),
style: newContext.style.generateTextStyle().merge(
childSpan.style == null
? childStyle
: childStyle.merge(childSpan.style)),
semanticsLabel: childSpan.semanticsLabel,
recognizer: TapGestureRecognizer()
..onTap = () => onLinkTap?.call(tree.href),
);
} else {
return WidgetSpan(
child: RawGestureDetector(
gestures: {
MultipleTapGestureRecognizer:
GestureRecognizerFactoryWithHandlers<
MultipleTapGestureRecognizer>(
() => MultipleTapGestureRecognizer(),
(instance) {
instance..onTap = () => onLinkTap?.call(tree.href);
},
),
},
child: (childSpan as WidgetSpan).child,
),
);
}
}

return TextSpan(
children: tree.children
.map((tree) => parseTree(newContext, tree))
.map((childSpan) {
if (childSpan is TextSpan) {
return TextSpan(
text: childSpan.text,
children: childSpan.children,
style: (childSpan.style ?? TextStyle())
.merge(newContext.style.generateTextStyle()),
semanticsLabel: childSpan.semanticsLabel,
recognizer: TapGestureRecognizer()
..onTap = () => onLinkTap?.call(tree.href),
);
} else {
return WidgetSpan(
child: RawGestureDetector(
gestures: {
MultipleTapGestureRecognizer:
GestureRecognizerFactoryWithHandlers<
MultipleTapGestureRecognizer>(
() => MultipleTapGestureRecognizer(),
(instance) {
instance..onTap = () => onLinkTap?.call(tree.href);
},
),
},
child: (childSpan as WidgetSpan).child,
),
);
}
return addTaps(childSpan,
newContext.style.generateTextStyle().merge(childSpan.style));
}).toList() ??
[],
);
Expand Down