-
Notifications
You must be signed in to change notification settings - Fork 105
Revisit the new fxl navigator and introduce a reflowable one #680
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
Merged
Merged
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
4d36e99
Add a rough reflowable navigator
qnga d094fda
Add user settings
qnga 7d6c6fd
Upgrade to Readium CSS2 and fix snapping bug
qnga 3a67b27
Implement scroll mode
qnga 52b2a5b
Fix padding and background color
qnga 2b7e402
Use FontFamilyDeclarations
qnga 865d806
Invalidates Webview when stylesheet to inject has changed
qnga 54b0c27
Fix scroll with vertical writings
qnga c50feea
Factorise nested scroll connections
qnga ea7e32d
Fix tap offsets
qnga 5b8f7e6
Detect tap on padding
qnga c4b0a8a
Fix regression in snapping related to padding
qnga 6d7f5b6
Try to fix scroll position of previous pages
qnga 33b1e60
Bump minSdk to 23
qnga 0e6c6f8
Restore default behavior in Scrollable2D: pre/postScroll are called w…
qnga c60089d
Implement a different nested scroll strategy
qnga 0e166cf
Fix restore location in reflowable
qnga 45228ed
Fix taps in reflowable
qnga 90205b1
Cosmetic changes in demo
qnga 735cf0c
Add missing ExperimentalReadiumApi markers and fix licenses
qnga e657294
Rename NavigatorFactory to RenditionFactory
qnga 0cae14b
Untie reflowable and fixed navigators
qnga 83ae72a
Various Compose fixes
qnga 9bb7944
Introduce ReflowableResourceState to fix readyToScroll
qnga 2b9aeab
Remove glitch on location restoration
qnga 302ab99
Refactor ReflowableResource
qnga 354de42
Various changes in reflowable preferences and preference editor
qnga 87449da
Redesign reflowable scroll. Breaks FXL
qnga 39d55b9
Clean up
qnga 3527573
Repair FXL
qnga de0889a
Ugrade Readium CSS to 2.0.0-beta08
qnga 1cb097d
Clean up
qnga 855bed8
Fix Readium CSS upgrade
qnga 32875e8
Add virtual column when necessary
qnga ab2c42a
Fix snapping issue due to padding included in page size
qnga cb8cfa7
Fix snapping issue
qnga adefc50
Fix location restoration on preference or orientation change
qnga a287779
Remove Progression sealed class
qnga 15cb734
Better fix location restoration on preference change
qnga 64097e8
Small fixes and cosmetic changes
qnga 88d464a
Renaming
qnga daef1b5
Cosmetic changes in fixed layout
qnga 7942a9f
Cosmetic changes
qnga 0aced63
Fix fixed layout scroll after changing preferences
qnga 4af0f63
Fix crash in two columns mode
qnga 944d275
Merge branch 'develop' into compose-reflowable
qnga ce7b8f5
Small fixes
qnga c1d5b1d
Fix scroll issue in fixed layout
qnga d74659c
Commit missing file
qnga 3e507fd
Simplify scroll dispatching by directly using ScrollableState and Fli…
qnga 78381a9
Various big cosmetic changes
qnga 35a7411
Fix scroll behavior in RTL mode
qnga 2b8d47b
Refactoring + fix thread safety in webapis
qnga 0c77906
Update Readium CSS to 2.0.0-beta-13
qnga 1b594c3
Make Readium CSS stuff internal
qnga 245790e
Fix multi columns and allow more than two columns
qnga 34fc3c3
Add table of contents to demo
qnga b762353
Introduce different types for Preferences API and Overflow
qnga 1f407ec
Modularize
qnga 9c38ed6
Merge remote-tracking branch 'origin/develop' into compose-reflowable
qnga aaf2d31
Fix GitHub action
qnga 88f6221
Fix scroll mode, broken since the fix for multicolumns
qnga 6a19ae4
Add dirty decorations on reflowable
qnga f57011d
Refactor TS events
qnga 9fb735f
Add support for selection and decorations in fixed layout
qnga 4c953b9
Make safe calls to web API
qnga 98bf284
Add decoration listener to fixed layout
qnga 9f02302
Refactor document state api
qnga 48df2e5
Clean up and optimize with MutableRef
qnga 2d945d0
Move every web api adapter to internals
qnga 2bc3c0a
Fix action mode background color
qnga 05d77b4
Get rid of explicite State in overflow, location and settings
qnga 056280c
Remove unchecked cast related to action mode in demo
qnga 8e33ffd
Use PersistentMap in DecorationController
qnga 4418cf3
Implement new locations strategy without LocationsAdapters
qnga fc9589b
Remove files committed unintentionally
qnga 88e2859
Add DecorationLocation
qnga b81aedb
Simplify output locations: interfaces are not needed
qnga fd791f6
Remove HyperlinkListener and cosmetic changes
qnga 30b25f5
Simplify the choice of the rendition engine in demo
qnga 0039f8d
Improve DecorationLocations
qnga 6e502ab
Improve highlight UI
qnga f84ce52
Clean up and doc
qnga 87a738e
Fix goTo(Url) in reflowable
qnga 89e2735
Cosmetic changes
qnga d00a170
Open Annotation dialog on annotation mark activated
qnga 98d53ff
Add configurations for both reflowable and fixed layout renditions
qnga a586758
Fix crash in edge case
qnga b1d3c3c
Add Readium CSS 2 custom theming properties
qnga dcc15d1
Revisit colum count computation
qnga 4df323f
Merge branch 'develop' of github.com:readium/kotlin-toolkit into comp…
qnga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+806 KB
demos/navigator/src/main/assets/fonts/Literata-Italic-VariableFont_opsz,wght.ttf
Binary file not shown.
Binary file added
BIN
+845 KB
demos/navigator/src/main/assets/fonts/Literata-VariableFont_opsz,wght.ttf
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
.../navigator/src/main/java/org/readium/demo/navigator/decorations/CustomDecorationStyles.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
* Copyright 2025 Readium Foundation. All rights reserved. | ||
* Use of this source code is governed by the BSD-style license | ||
* available in the top-level LICENSE file of the project. | ||
*/ | ||
|
||
@file:OptIn(ExperimentalReadiumApi::class) | ||
|
||
package org.readium.demo.navigator.decorations | ||
|
||
import android.graphics.Color | ||
import androidx.annotation.ColorInt | ||
import kotlinx.collections.immutable.PersistentList | ||
import kotlinx.collections.immutable.toPersistentList | ||
import org.readium.navigator.common.Decoration | ||
import org.readium.navigator.web.common.WebDecorationTemplate | ||
import org.readium.navigator.web.reflowable.ReflowableWebDecorationLocation | ||
import org.readium.r2.navigator.epub.EpubNavigatorFragment | ||
import org.readium.r2.navigator.html.toCss | ||
import org.readium.r2.shared.ExperimentalReadiumApi | ||
import org.readium.r2.shared.publication.Publication | ||
import org.readium.r2.shared.publication.epub.pageList | ||
|
||
/** | ||
* Decoration Style for a page margin icon. | ||
* | ||
* This is an example of a custom Decoration Style declaration. | ||
*/ | ||
data class DecorationStyleAnnotationMark(@ColorInt val tint: Int) : Decoration.Style | ||
|
||
/** | ||
* Decoration Style for a page number label. | ||
* | ||
* This is an example of a custom Decoration Style declaration. | ||
* | ||
* @param label Page number label as declared in the `page-list` link object. | ||
*/ | ||
data class DecorationStylePageNumber(val label: String) : Decoration.Style | ||
|
||
/** | ||
* This decoration template will display a tinted "pen" icon in the page margin to show that a highlight | ||
* has an associated note. | ||
* | ||
* Note that the icon is served from the app assets folder. | ||
*/ | ||
fun annotationMarkTemplate(@ColorInt defaultTint: Int = Color.YELLOW): WebDecorationTemplate { | ||
val className = "demo-annotation-mark" | ||
val iconUrl = checkNotNull(EpubNavigatorFragment.assetUrl("annotation-icon.svg")) | ||
return WebDecorationTemplate( | ||
layout = WebDecorationTemplate.Layout.BOUNDS, | ||
width = WebDecorationTemplate.Width.PAGE, | ||
element = { | ||
val style = it as? DecorationStyleAnnotationMark | ||
val tint = style?.tint ?: defaultTint | ||
// Using `data-activable=1` prevents the whole decoration container from being | ||
// clickable. Only the icon will respond to activation events. | ||
""" | ||
<div><div data-activable="1" class="$className" style="background-color: ${tint.toCss()} !important"/></div>" | ||
""" | ||
}, | ||
stylesheet = """ | ||
.$className { | ||
float: left; | ||
margin-left: 8px; | ||
width: 30px; | ||
height: 30px; | ||
border-radius: 50%; | ||
background: url('$iconUrl') no-repeat center; | ||
background-size: auto 50%; | ||
opacity: 0.8; | ||
} | ||
""" | ||
) | ||
} | ||
|
||
/** | ||
* This decoration template is used to display the page number labels in the margins, when a book | ||
* provides a `page-list`. The label is stored in the [DecorationStylePageNumber] itself. | ||
* | ||
* See http://kb.daisy.org/publishing/docs/navigation/pagelist.html | ||
*/ | ||
fun pageNumberTemplate(): WebDecorationTemplate { | ||
val className = "demo-page-number" | ||
return WebDecorationTemplate( | ||
layout = WebDecorationTemplate.Layout.BOUNDS, | ||
width = WebDecorationTemplate.Width.PAGE, | ||
element = { | ||
val style = it as? DecorationStylePageNumber | ||
|
||
// Using `var(--RS__backgroundColor)` is a trick to use the same background color as | ||
// the Readium theme. If we don't set it directly inline in the HTML, it might be | ||
// forced transparent by Readium CSS. | ||
""" | ||
<div><span class="$className" style="background-color: var(--RS__backgroundColor) !important">${style?.label}</span></div>" | ||
""" | ||
}, | ||
stylesheet = """ | ||
.$className { | ||
float: left; | ||
margin-left: 8px; | ||
padding: 0px 4px 0px 4px; | ||
border: 1px solid; | ||
border-radius: 20%; | ||
box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px; | ||
opacity: 0.8; | ||
} | ||
""" | ||
) | ||
} | ||
|
||
/** | ||
* Decorations to display margin labels next to page numbers in an EPUB publication with a `page-list` | ||
* navigation document. | ||
* | ||
* See http://kb.daisy.org/publishing/docs/navigation/pagelist.html | ||
*/ | ||
val Publication.pageNumberDecorations: PersistentList<Decoration<ReflowableWebDecorationLocation>> get() = | ||
pageList | ||
.mapIndexedNotNull { index, link -> | ||
val label = link.title ?: return@mapIndexedNotNull null | ||
|
||
val location = locatorFromLink(link) | ||
?.let { ReflowableWebDecorationLocation(it) } | ||
?: return@mapIndexedNotNull null | ||
|
||
Decoration<ReflowableWebDecorationLocation>( | ||
id = Decoration.Id("page-$index"), | ||
location = location, | ||
style = DecorationStylePageNumber(label = label) | ||
) | ||
}.toPersistentList() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.