-
Notifications
You must be signed in to change notification settings - Fork 893
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
Fix: Scroll state in retained in the partial translation mode #2643
Fix: Scroll state in retained in the partial translation mode #2643
Conversation
|
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.
jazakumAllah khairan, really appreciate the great work on this and looking forward to merging it! just one small comment in the PR that I think will simplify the PR a bit.
@@ -38,11 +38,11 @@ class InlineTranslationPresenter @Inject constructor( | |||
.launchIn(scope) | |||
} | |||
|
|||
suspend fun refresh(verseRange: VerseRange) { | |||
suspend fun refresh(verseRange: VerseRange, ayahHasBeenChanged: Boolean) { |
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.
if we keep track of the last verse range within InlineTranslationPresenter
, we can avoid having to update all the callers to pass in whether or not the ayah has changed - can we do that instead? i.e.:
private var lastVerseRange: VerseRange? = null
suspend fun refresh(verseRange: verseRange) {
val ayahHasBeenChanged = verseRange == lastVerseRange
// existing logic here
lastVerseRange = verseRange
}
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.
Looks good! I changed the PR (forced pushed to omit the old commit)
2208af5
to
089106c
Compare
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.
jazakumAllah khairan!
|
Fixes #2598 Retain scroll state in partial translation mode
The issue was with the call to
scrollTo(0, 0)
within thesetAyahs()
, so basically when the Ayahs are set the scroll is rested to 0,0.Removing
scrollTo(0, 0)
persists the scroll position sinceInlineTranslationView
extendsScrollView
and it saves the scroll state out of the box. but this introduce a new problem which is when you select a different ayah then the scroll will not be rested. to fix this I added a flag calledayahHasBeenChanged
to reset the scroll to 0,0 when ayah is changed