Skip to content

Commit

Permalink
Open relative links
Browse files Browse the repository at this point in the history
See #5
  • Loading branch information
amake committed Apr 26, 2021
1 parent 0e8b415 commit ff641fd
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/src/pages/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,7 @@ class _DocumentPageState extends State<DocumentPage> with ViewSettingsState {
constraints: const BoxConstraints(maxWidth: 800),
child: OrgRootWidget(
style: textStyle,
onLinkTap: (url) {
debugPrint('Launching URL: $url');
return launch(url, forceSafariVC: false);
},
onLinkTap: _openLink,
onSectionLongPress: (section) =>
narrow(context, widget.dataSource, section),
onLocalSectionLinkTap: (section) =>
Expand Down Expand Up @@ -292,6 +289,16 @@ class _DocumentPageState extends State<DocumentPage> with ViewSettingsState {
);
}

Future<bool> _openLink(String url) {
if (looksLikeRelativePath(url) && url.endsWith('.org')) {
final resolved = widget.dataSource.resolveRelative(url);
return loadDocument(context, resolved);
} else {
debugPrint('Launching URL: $url');
return launch(url, forceSafariVC: false);
}
}

bool? _hasRelativeLinks;

bool get _askForDirectoryPermissions =>
Expand Down

0 comments on commit ff641fd

Please sign in to comment.