@dr33m/react-native-readium 5.0.0-rc.21 → 5.0.0-rc.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -274,26 +274,30 @@ abstract class BaseReaderFragment : Fragment() {
274
274
  fun ttsSkipPrevious() { ttsManager?.skipPrevious() }
275
275
 
276
276
  private fun applyTTSDecoration(locator: Locator) {
277
- // Route through the public applyDecorations so the "tts" group is registered
278
- // via addDecorationListener before the first applyDecorations call — Readium
279
- // silently ignores decorations for groups that have no registered listener.
280
- applyDecorations(
281
- mapOf(
282
- "tts" to listOf(
283
- Decoration(
284
- id = "tts-current",
285
- locator = locator,
286
- style = Decoration.Style.Highlight(
287
- tint = android.graphics.Color.argb(89, 0xF2, 0xCA, 0x50) // #f2ca50 @ 35%
288
- )
277
+ if (!isNavigatorReady) return
278
+ val decorableNavigator = navigator as? DecorableNavigator ?: return
279
+ // Call applyDecorations directly it is a regular (non-suspend) function in
280
+ // Readium 3.x. The test app (VisualReaderFragment) does the same: no launch {},
281
+ // no channel routing. Wrapping in viewScope.launch defers the call to the next
282
+ // dispatch cycle and was preventing the highlight from ever appearing.
283
+ decorableNavigator.applyDecorations(
284
+ listOf(
285
+ Decoration(
286
+ id = "tts",
287
+ locator = locator,
288
+ style = Decoration.Style.Highlight(
289
+ tint = android.graphics.Color.argb(89, 0xF2, 0xCA, 0x50) // #f2ca50 @ 35%
289
290
  )
290
291
  )
291
- )
292
+ ),
293
+ "tts"
292
294
  )
293
295
  }
294
296
 
295
297
  private fun clearTTSDecoration() {
296
- applyDecorations(mapOf("tts" to emptyList()))
298
+ if (!isNavigatorReady) return
299
+ val decorableNavigator = navigator as? DecorableNavigator ?: return
300
+ decorableNavigator.applyDecorations(emptyList(), "tts")
297
301
  }
298
302
 
299
303
  override fun onDestroyView() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dr33m/react-native-readium",
3
- "version": "5.0.0-rc.21",
3
+ "version": "5.0.0-rc.22",
4
4
  "description": "A react-native wrapper for https://readium.org/",
5
5
  "main": "lib/src/index",
6
6
  "types": "lib/src/index.d.ts",