mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 13:57:10 +09:00
Quick enter SAM — smooth animation on enter (#1107)
This commit is contained in:
parent
91e93df296
commit
a4ddf06439
2 changed files with 17 additions and 6 deletions
|
@ -47,6 +47,7 @@ import com.anytypeio.anytype.core_ui.features.page.scrollandmove.ScrollAndMoveTa
|
|||
import com.anytypeio.anytype.core_ui.menu.DocumentPopUpMenu
|
||||
import com.anytypeio.anytype.core_ui.menu.ProfilePopUpMenu
|
||||
import com.anytypeio.anytype.core_ui.reactive.clicks
|
||||
import com.anytypeio.anytype.core_ui.reactive.layoutChanges
|
||||
import com.anytypeio.anytype.core_ui.tools.ClipboardInterceptor
|
||||
import com.anytypeio.anytype.core_ui.tools.FirstItemInvisibilityDetector
|
||||
import com.anytypeio.anytype.core_ui.tools.MentionFooterItemDecorator
|
||||
|
@ -964,15 +965,14 @@ open class PageFragment :
|
|||
|
||||
val offset = recycler.computeVerticalScrollOffset()
|
||||
|
||||
recycler.addItemDecoration(scrollAndMoveTargetHighlighter)
|
||||
|
||||
if (offset < screen.y / 3) {
|
||||
lifecycleScope.launch {
|
||||
delay(100)
|
||||
recycler.smoothScrollBy(0, screen.y / 3)
|
||||
lifecycleScope.launch {
|
||||
recycler.layoutChanges().take(1).collect {
|
||||
if (offset < screen.y / 3) recycler.scrollBy(0, screen.y / 3)
|
||||
}
|
||||
}
|
||||
|
||||
recycler.addItemDecoration(scrollAndMoveTargetHighlighter)
|
||||
|
||||
showTargeterWithAnimation()
|
||||
|
||||
recycler.addOnScrollListener(scrollAndMoveStateListener)
|
||||
|
@ -988,6 +988,8 @@ open class PageFragment :
|
|||
searchScrollAndMoveTarget()
|
||||
recycler.invalidate()
|
||||
}
|
||||
} else {
|
||||
Timber.d("Skipping enter scroll-and-move")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,15 @@ fun EditText.afterTextChanges(): Flow<CharSequence> = callbackFlow<CharSequence>
|
|||
awaitClose { removeTextChangedListener(listener) }
|
||||
}.conflate()
|
||||
|
||||
@CheckResult
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun View.layoutChanges(): Flow<Unit> = callbackFlow {
|
||||
checkMainThread()
|
||||
val listener = View.OnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> safeOffer(Unit) }
|
||||
addOnLayoutChangeListener(listener)
|
||||
awaitClose { removeOnLayoutChangeListener(listener) }
|
||||
}.conflate()
|
||||
|
||||
@CheckResult
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun TextView.editorActionEvents(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue