Skip to content

Commit 1b3ab73

Browse files
committed
Merge branch 'master' of https://github.com/Sub6Resources/flutter_html into feature/details-tag
� Conflicts: � lib/html_parser.dart � lib/src/layout_element.dart
2 parents f25a9c0 + f24f461 commit 1b3ab73

File tree

6 files changed

+462
-99
lines changed

6 files changed

+462
-99
lines changed

lib/html_parser.dart

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -336,38 +336,47 @@ class HtmlParser extends StatelessWidget {
336336
);
337337
}
338338
} else if (tree is InteractableElement) {
339+
InlineSpan addTaps(InlineSpan childSpan, TextStyle childStyle) {
340+
if (childSpan is TextSpan) {
341+
return TextSpan(
342+
text: childSpan.text,
343+
children: childSpan.children
344+
?.map((e) => addTaps(e, childStyle.merge(childSpan.style)))
345+
?.toList(),
346+
style: newContext.style.generateTextStyle().merge(
347+
childSpan.style == null
348+
? childStyle
349+
: childStyle.merge(childSpan.style)),
350+
semanticsLabel: childSpan.semanticsLabel,
351+
recognizer: TapGestureRecognizer()
352+
..onTap = () => onLinkTap?.call(tree.href),
353+
);
354+
} else {
355+
return WidgetSpan(
356+
child: RawGestureDetector(
357+
gestures: {
358+
MultipleTapGestureRecognizer:
359+
GestureRecognizerFactoryWithHandlers<
360+
MultipleTapGestureRecognizer>(
361+
() => MultipleTapGestureRecognizer(),
362+
(instance) {
363+
instance..onTap = () => onLinkTap?.call(tree.href);
364+
},
365+
),
366+
},
367+
child: (childSpan as WidgetSpan).child,
368+
),
369+
);
370+
}
371+
}
372+
339373
return TextSpan(
340374
children: tree.children
341-
.map((tree) => parseTree(newContext, tree))
342-
.map((childSpan) {
343-
if (childSpan is TextSpan) {
344-
return TextSpan(
345-
text: childSpan.text,
346-
children: childSpan.children,
347-
style: (childSpan.style ?? TextStyle())
348-
.merge(newContext.style.generateTextStyle()),
349-
semanticsLabel: childSpan.semanticsLabel,
350-
recognizer: TapGestureRecognizer()
351-
..onTap = () => onLinkTap?.call(tree.href),
352-
);
353-
} else {
354-
return WidgetSpan(
355-
child: RawGestureDetector(
356-
gestures: {
357-
MultipleTapGestureRecognizer:
358-
GestureRecognizerFactoryWithHandlers<
359-
MultipleTapGestureRecognizer>(
360-
() => MultipleTapGestureRecognizer(),
361-
(instance) {
362-
instance..onTap = () => onLinkTap?.call(tree.href);
363-
},
364-
),
365-
},
366-
child: (childSpan as WidgetSpan).child,
367-
),
368-
);
369-
}
370-
}).toList() ??
375+
.map((tree) => parseTree(newContext, tree))
376+
.map((childSpan) {
377+
return addTaps(childSpan,
378+
newContext.style.generateTextStyle().merge(childSpan.style));
379+
}).toList() ??
371380
[],
372381
);
373382
} else if (tree is LayoutElement) {
@@ -661,6 +670,8 @@ class HtmlParser extends StatelessWidget {
661670
child.text.trim().isEmpty &&
662671
lastChildBlock) {
663672
toRemove.add(child);
673+
} else if (child.style.display == Display.NONE) {
674+
toRemove.add(child);
664675
} else {
665676
_removeEmptyElements(child);
666677
}

0 commit comments

Comments
 (0)