Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[url_launcher][web] Better support for semantics in the Link widget #6711

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
more readable
  • Loading branch information
mdebbar committed Jun 4, 2024
commit 80e7158fb3c1219eea97d715355e4d71655cbf37
71 changes: 40 additions & 31 deletions packages/url_launcher/url_launcher_web/lib/src/link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,42 +106,51 @@ class WebLinkDelegateState extends State<WebLinkDelegate> {
return Stack(
fit: StackFit.passthrough,
children: <Widget>[
Semantics(
link: true,
identifier: _semanticsIdentifier,
value: widget.link.uri?.getHref(),
child: widget.link.builder(
context,
widget.link.isDisabled ? null : _followLink,
),
),
_buildChild(context),
Positioned.fill(
child: ExcludeFocus(
child: ExcludeSemantics(
child: PlatformViewLink(
viewType: linkViewType,
onCreatePlatformView: (PlatformViewCreationParams params) {
_controller = LinkViewController.fromParams(params, _semanticsIdentifier);
return _controller
..setUri(widget.link.uri)
..setTarget(widget.link.target);
},
surfaceFactory:
(BuildContext context, PlatformViewController controller) {
return PlatformViewSurface(
controller: controller,
gestureRecognizers: const <Factory<
OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.transparent,
);
},
),
),
),
child: _buildPlatformView(context),
),
],
);
}

Widget _buildChild(BuildContext context) {
return Semantics(
link: true,
identifier: _semanticsIdentifier,
value: widget.link.uri?.getHref(),
child: widget.link.builder(
context,
widget.link.isDisabled ? null : _followLink,
),
);
}

Widget _buildPlatformView(BuildContext context) {
return ExcludeFocus(
child: ExcludeSemantics(
child: PlatformViewLink(
viewType: linkViewType,
onCreatePlatformView: (PlatformViewCreationParams params) {
_controller =
LinkViewController.fromParams(params, _semanticsIdentifier);
return _controller
..setUri(widget.link.uri)
..setTarget(widget.link.target);
},
surfaceFactory:
(BuildContext context, PlatformViewController controller) {
return PlatformViewSurface(
controller: controller,
gestureRecognizers: const <Factory<
OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.transparent,
);
},
),
),
);
}
}

final JSAny _useCapture = <String, Object>{'capture': true}.jsify()!;
Expand Down