The new Preferences API and the old UserSettings #294
-
My app uses UserSettings for configuring navigators, unfortunately the new API requires too many code changes. I didn't understand how I can continue to use 'UserSettings' even if deprecated, but ignoring the new API is not enough because in this way no change is perceived on my EPUB (e.g. increase in font size, change of font...) To avoid major refactorings, I would like to adopt this strategy at the moment: continue to use UserSettings to store the values changed by the user, but invoke the new EPUBPreferences to force the navigator to update. For example to increase the font size:
Can you provide more details on how to convert the old values to the new ones? Thank you. P.S. I saw the EPUBPreferences.fromLegacyPreferences but I didn't understand how to use it and if it would be useful in this case (for each modification of the userSettings transform it completely into an EPUBPreferences? mmh) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Did you do the HTTP server migration? If you want to keep using the old I didn't try it, but if you want to bridge the legacy // Saves to the UserDefaults
userSettings.save()
// Loads from the UserDefaults
let preferences = EPUBPreferences.fromLegacyPreferences()
navigator.submitPreferences(preferences) See |
Beta Was this translation helpful? Give feedback.
Did you do the HTTP server migration? If you want to keep using the old
updateUserSettingsStyle()
API, you need to keep the old HTTP server. After doing the HTTP server migration, the new Preferences API is required.I didn't try it, but if you want to bridge the legacy
UserSettings
with the newEPUBPreferences
, I think you should be able to do:See
swift-toolkit/Sources/Navigator/EPUB/Preferences/EPUBPreferences+Legacy.swift
Line 20 in 9e03397