Skip to content

Commit

Permalink
Fix notes being scrolled to the bottom when opening them #227
Browse files Browse the repository at this point in the history
  • Loading branch information
alialbaali committed Sep 16, 2023
1 parent 32a92e9 commit 49a82e7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/src/main/java/com/noto/app/note/NoteFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,24 @@ class NoteFragment : Fragment() {

etNoteTitle.textAsFlow(emitInitialText = true)
.filterNotNull()
.onEach { etNoteTitle.post { nsv.smoothScrollTo(0, etNoteTitle.currentLineScrollPosition, DefaultAnimationDuration.toInt()) } }
.onEach {
if (etNoteTitle.isFocused) {
etNoteTitle.post {
nsv.smoothScrollTo(0, etNoteTitle.currentLineScrollPosition, DefaultAnimationDuration.toInt())
}
}
}
.launchIn(lifecycleScope)

etNoteBody.textAsFlow(emitInitialText = true)
.filterNotNull()
.onEach { etNoteBody.post { nsv.smoothScrollTo(0, etNoteBody.currentLineScrollPosition, DefaultAnimationDuration.toInt()) } }
.onEach {
if (etNoteBody.isFocused) {
etNoteBody.post {
nsv.smoothScrollTo(0, etNoteBody.currentLineScrollPosition, DefaultAnimationDuration.toInt())
}
}
}
.launchIn(lifecycleScope)

savedStateHandle?.getLiveData<String>(Constants.NoteTitle)
Expand Down

0 comments on commit 49a82e7

Please sign in to comment.