Skip to content

Commit

Permalink
Scroll selected annotation into view when opening sidebar. Closes #184.
Browse files Browse the repository at this point in the history
Upping versionCode to 117
  • Loading branch information
Dima-Android committed Nov 13, 2024
1 parent c32236a commit 094592e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ internal fun PdfReaderScreen(
navigateToPdfFilter()
}

is PdfReaderViewEffect.ScrollSideBar -> {
annotationsLazyListState.scrollToItem(index = consumedEffect.scrollToIndex)
}

is PdfReaderViewEffect.ShowPdfAnnotationAndUpdateAnnotationsList -> {
if (consumedEffect.showAnnotationPopup) {
if (!layoutType.isTablet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,9 @@ class PdfReaderViewModel @Inject constructor(
this.document.annotationProvider.removeAnnotationFromPage(annotation)
}
}
updateState {
copy(selectedAnnotationKey = null)
}

// if (viewState.selectedAnnotationKey?.key == annotation.key ) {
// _select(key = null, didSelectInDocument = false)
Expand Down Expand Up @@ -2238,10 +2241,7 @@ class PdfReaderViewModel @Inject constructor(
if (newShowSideBarState && selectedAnnotationKey != null) {
val index = viewState.sortedKeys.indexOf(selectedAnnotationKey)
triggerEffect(
PdfReaderViewEffect.ShowPdfAnnotationAndUpdateAnnotationsList(
index,
false
)
PdfReaderViewEffect.ScrollSideBar(index)
)
}
}
Expand Down Expand Up @@ -3371,6 +3371,7 @@ sealed class PdfReaderViewEffect : ViewEffect {
object ShowPdfAnnotationMore: PdfReaderViewEffect()
object ShowPdfColorPicker: PdfReaderViewEffect()
data class ShowPdfAnnotationAndUpdateAnnotationsList(val scrollToIndex: Int, val showAnnotationPopup: Boolean): PdfReaderViewEffect()
data class ScrollSideBar(val scrollToIndex: Int): PdfReaderViewEffect()
object ScreenRefresh: PdfReaderViewEffect()
object ClearFocus: PdfReaderViewEffect()
object NavigateToTagPickerScreen: PdfReaderViewEffect()
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object BuildConfig {
const val compileSdkVersion = 34
const val targetSdk = 34

val versionCode = 116 // Must be updated on every build
val versionCode = 117 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit 094592e

Please sign in to comment.