-
Notifications
You must be signed in to change notification settings - Fork 43
feat(ios, android, web): Move from deprecated UserSettings API to the new Preferences API #80
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
Conversation
@TechWilk thanks for this PR! I'll be reviewing this week and reaching out with any questions. |
@TechWilk , I pulled your branch and fired up the example project on iOS. At first glance there seem to be a number of issues. I've attached a screen recording demonstrating them below; however they are as follows:
Let me know if I'm missing something. readium-upgrade-issues-demo-compressed.mp4 |
That doesn't look right. I'll take another look through it. Something isn't applying the preferences properly which would explain all three issues you've listed. The scrolling (issue 3) is now a configurable behaviour, as For clarity, I've cherry-picked the branch off a fork which is in production so I know the changes work and I've probably just missed something small in the rebasing. Clearly I didn't check it as well as I should have so apologies. As and when I get time I'll be trying to send more PRs upstream. |
@TechWilk, no worries, the cherry-picking makes sense. Another thing I found is that the Android side has a build failure:
|
I've found & pushed the missing iOS code - the preferences are now applied properly. I'll take another look at the Android build failure next week & see what I missed there. |
Ok I've found the missing Android changes too so things should all be in order for you now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TechWilk , this is all looking great! I left a couple of questions/comments for you.
The biggest blocker at this point is that web doesn't work at all (I'm guessing you don't use web), due to the fact that the underlying reader there still uses the old settings API. I'm looking into alternatives like ts-toolkit
(which is ultimately what I want to migrate to).
It may be the case that I merge this as a major version alpha or something and isolate the web issue off to a future PR.
android/src/main/java/com/reactnativereadium/ReadiumViewManager.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've addressed your comments. Let me know how you'd like to proceed with the memoization one.
You're quite right, I've never used the web portion. I can see the dilemma but without pushing forward with the preferences changes you'll get stuck with the native toolkits as they've both got major version bumps which require the new preferences. The only other option I can think of is writing a mapping function which takes the most important Preferences and maps them to their equivalent UserSettings so that react-native-readium
handles the backwards compatibility for a few key settings.
android/src/main/java/com/reactnativereadium/ReadiumViewManager.kt
Outdated
Show resolved
Hide resolved
Thinking about the web, I wonder if something like this is actually quite achievable for backwards compatibility, where we just convert the main settings that you care about: |
Try that now, the web should now compile. I've exposed the settings used by the example. There are a couple more which aren't as easy to figure out from the TypeScript types (e.g. |
@TechWilk this is awesome! I'm going to go ahead and merge this as is. I did some experimentation with |
BREAKING CHANGE: This update moves the library to the newer Preferences API for managing the reader font size, theme, etc.
Resolves #79