5-stones / react-native-readium

📚 📖 React Native ebook reader for iOS, Android, & Web via Readium
MIT License
83 stars 25 forks source link

Example app: Unable to navigate using table of contents #36

Closed adesege closed 1 year ago

adesege commented 1 year ago

Using the example app, I'm unable to navigate to the selected page. The modal closes but it doesn't perform the navigation.

Upon further investigation, I found out that onPress parameter on TableOfContents component returns a Link and not a Locator.

I also attempted to use the returned Link object as the initialLocation but it didn't work too.

Swipe navigation works as expected.

jspizziri commented 1 year ago

@adesege ahh yes. Links and Locators are not identical. The link needs to be converted into a locator before navigation is called. A primitive way of doing this is:

setLocation({
  href: link.href,
  type: 'application/xhtml+xml',
})

You can see more detail on this here

adesege commented 1 year ago

Ok, noted. Do you think this should be handled automatically from the native side, in the library's javascript side or the example app?

I can put up a PR to fix it

jspizziri commented 1 year ago

@adesege , not currently, I think this should be handled by the user. I think we just need to update the example app to do something like what I chatted above.

Appreciate you catching and being willing to fix!

adesege commented 1 year ago

Happy to help, @jspizziri. Here's the PR https://github.com/5-stones/react-native-readium/pull/37.

I'll resume working on the PDF #8 support and let you know if I have questions.

Cheers!