-
Notifications
You must be signed in to change notification settings - Fork 302
feat(compose): add bring-into-view support to auto-scroll focused input fields above the keyboard #1577
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
Open
RoeKun
wants to merge
13
commits into
Tencent-TDS:main
Choose a base branch
from
RoeKun:feature/valo_compose_keyboard_bringtoVisualView_build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(compose): add bring-into-view support to auto-scroll focused input fields above the keyboard #1577
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2b14699
feat(Compose): align keyboard IME with officical Compose
RoeKun e613c0c
feat(ohos): support windowinsets.ime by handling keyboard avoid area …
RoeKun a223a21
fix: update ScaffoldDemo
RoeKun e6b2afd
fix: update spec docs
RoeKun 169b4af
Merge remote-tracking branch 'origin/main' into feature/valo_compose_…
RoeKun abc232d
fix: update ime demo and unify spec docs
RoeKun 42dc699
fix: resolve missing immersive mode check when querying windowInsets.ime
RoeKun 2914e05
feat: Compose DSL 新增 bring-into-view 能力,输入框获焦被键盘遮挡时自动滚入可视区
RoeKun f50556c
feat: 归档 compose-bring-into-view-phase2 设计文档并同步 bring-into-view 主 spec
RoeKun 3f100bc
fix: remove debug log
RoeKun b99ccff
fix: address PR #1571 code review comments
RoeKun fd13baf
feat: Compose 文档补充 bring-into-view 能力说明(TextField 获焦自动滚入可视区与 BringInt…
RoeKun a020c43
feat: address bring-into-view review items, keep root coordinates wit…
RoeKun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
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
45 changes: 45 additions & 0 deletions
45
...onMain/kotlin/com/tencent/kuikly/compose/foundation/relocation/BringIntoViewCalculator.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,45 @@ | ||
| /* | ||
| * Tencent is pleased to support the open source community by making KuiklyUI | ||
| * available. | ||
| * Copyright (C) 2026 Tencent. All rights reserved. | ||
| * Licensed under the License of KuiklyUI; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * https://github.com/Tencent-TDS/KuiklyUI/blob/main/LICENSE | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.tencent.kuikly.compose.foundation.relocation | ||
|
|
||
| import com.tencent.kuikly.compose.ui.geometry.Rect | ||
| import kotlin.math.min | ||
|
|
||
| internal const val DefaultBringIntoViewThresholdPx = 1f | ||
| internal const val DefaultBringIntoViewExtraMarginPx = 12f | ||
|
|
||
| internal fun calculateBringIntoViewDelta( | ||
| targetRect: Rect, | ||
| containerRect: Rect, | ||
| windowBottom: Float, | ||
| imeBottomPx: Float, | ||
| extraMarginPx: Float = DefaultBringIntoViewExtraMarginPx, | ||
| ): Float { | ||
| val visibleTop = containerRect.top | ||
| val visibleBottom = min(containerRect.bottom, windowBottom - imeBottomPx.coerceAtLeast(0f)) | ||
| if (visibleBottom <= visibleTop) { | ||
| return 0f | ||
| } | ||
| return when { | ||
| targetRect.bottom > visibleBottom -> { | ||
| targetRect.bottom - visibleBottom + extraMarginPx | ||
| } | ||
| targetRect.top < visibleTop -> { | ||
| targetRect.top - visibleTop - extraMarginPx | ||
| } | ||
| else -> 0f | ||
| } | ||
| } |
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.
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.
建议留意一下与官方
isMaxVisible判定的细微差异:官方是用「旧的 focusedChild bounds 对比旧 viewport」+「新的 focusedChild bounds 对比新 viewport」,而checkViewportShrinkAndSchedule里两次都用同一个当前focusedRect去对比 old/new viewport。键盘弹起瞬间 child 一般还没动,影响不大;但如果 viewport shrink 和 child 重排发生在同一帧,可能会漏判或误判。当前 MVP 可接受,留个注释说明这个近似即可。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.
已解决:在
wasFocusedChildClippedByViewportShrink的 KDoc 里补了 Note,明确说明本 MVP 近似用「当前 bounds 同时对比 old/new viewport」,与官方「旧 bounds 对旧 viewport + 新 bounds 对新 viewport」的差异,以及「viewport shrink 与 child 重排同帧可能误判、键盘弹起瞬间 child 通常未动故可接受」的前提,与你的建议一致。