!38332 自定义键盘切换至小窗口后的高度与在小窗口中重新拉起时的高度不一致

Merge pull request !38332 from kangshihui/text_dev
This commit is contained in:
openharmony_ci 2024-07-20 16:10:10 +00:00 committed by Gitee
commit 13a80930d3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 40 additions and 33 deletions

View File

@ -4857,25 +4857,10 @@ void OverlayManager::PlayKeyboardTransition(const RefPtr<FrameNode>& customKeybo
option.SetFillMode(FillMode::FORWARDS);
auto context = customKeyboard->GetRenderContext();
CHECK_NULL_VOID(context);
auto pipeline = PipelineContext::GetMainPipelineContext();
CHECK_NULL_VOID(pipeline);
auto pageNode = pipeline->GetStageManager()->GetLastPage();
if (pageNode == nullptr) {
auto parent = customKeyboard->GetParent();
CHECK_NULL_VOID(parent);
parent->RemoveChild(customKeyboard);
return;
}
auto pageHeight = pageNode->GetGeometryNode()->GetFrameSize().Height();
auto keyboardHeight = customKeyboard->GetGeometryNode()->GetFrameSize().Height();
auto rootNode = rootNodeWeak_.Upgrade();
CHECK_NULL_VOID(rootNode);
auto finalOffset = rootNode->GetTag() == "Stack"
? (pageHeight - keyboardHeight) - (pageHeight - keyboardHeight) / NUM_FLOAT_2
: 0.0f;
auto keyboardOffsetInfo = CalcCustomKeyboardOffset(customKeyboard);
if (isTransitionIn) {
context->OnTransformTranslateUpdate({ 0.0f, pageHeight, 0.0f });
AnimationUtils::Animate(option, [context, finalOffset]() {
context->OnTransformTranslateUpdate({ 0.0f, keyboardOffsetInfo.inAniStartOffset, 0.0f });
AnimationUtils::Animate(option, [context, finalOffset = keyboardOffsetInfo.finalOffset]() {
if (context) {
context->OnTransformTranslateUpdate({ 0.0f, finalOffset, 0.0f });
}
@ -4889,11 +4874,12 @@ void OverlayManager::PlayKeyboardTransition(const RefPtr<FrameNode>& customKeybo
});
AnimationUtils::Animate(
option,
[context, keyboardHeight, finalOffset]() {
[context, outAniEndOffset = keyboardOffsetInfo.outAniEndOffset]() {
if (context) {
context->OnTransformTranslateUpdate({ 0.0f, finalOffset + keyboardHeight, 0.0f });
context->OnTransformTranslateUpdate({ 0.0f, outAniEndOffset, 0.0f });
}
}, option.GetOnFinishEvent());
},
option.GetOnFinishEvent());
}
}
@ -4910,21 +4896,35 @@ void OverlayManager::UpdateCustomKeyboardPosition()
}
auto renderContext = customKeyboardNode->GetRenderContext();
CHECK_NULL_VOID(renderContext);
auto pipeline = PipelineContext::GetMainPipelineContext();
CHECK_NULL_VOID(pipeline);
auto pageNode = pipeline->GetStageManager()->GetLastPage();
CHECK_NULL_VOID(pageNode);
auto pageHeight = pageNode->GetGeometryNode()->GetFrameSize().Height();
auto keyboardHeight = customKeyboardNode->GetGeometryNode()->GetFrameSize().Height();
auto rootNode = rootNodeWeak_.Upgrade();
CHECK_NULL_VOID(rootNode);
auto finalOffset = rootNode->GetTag() == V2::STACK_ETS_TAG
? (pageHeight - keyboardHeight) - (pageHeight - keyboardHeight) / NUM_FLOAT_2
: 0.0f;
renderContext->OnTransformTranslateUpdate({ 0.0f, finalOffset, 0.0f });
auto keyboardOffsetInfo = CalcCustomKeyboardOffset(customKeyboardNode);
renderContext->OnTransformTranslateUpdate({ 0.0f, keyboardOffsetInfo.finalOffset, 0.0f });
}
}
CustomKeyboardOffsetInfo OverlayManager::CalcCustomKeyboardOffset(const RefPtr<FrameNode>& customKeyboard)
{
CustomKeyboardOffsetInfo keyboardOffsetInfo;
CHECK_NULL_RETURN(customKeyboard, keyboardOffsetInfo);
auto pipeline = PipelineContext::GetMainPipelineContext();
CHECK_NULL_RETURN(pipeline, keyboardOffsetInfo);
auto pageNode = pipeline->GetStageManager()->GetLastPage();
CHECK_NULL_RETURN(pageNode, keyboardOffsetInfo);
auto pageHeight = pageNode->GetGeometryNode()->GetFrameSize().Height();
auto keyboardHeight = customKeyboard->GetGeometryNode()->GetFrameSize().Height();
auto rootNode = rootNodeWeak_.Upgrade();
CHECK_NULL_RETURN(rootNode, keyboardOffsetInfo);
auto finalOffset = 0.0f;
if (rootNode->GetTag() == V2::STACK_ETS_TAG) {
auto rootNd = AceType::DynamicCast<FrameNode>(rootNode);
pageHeight = rootNd->GetGeometryNode()->GetFrameSize().Height();
finalOffset = (pageHeight - keyboardHeight) - (pageHeight - keyboardHeight) / NUM_FLOAT_2;
}
keyboardOffsetInfo.finalOffset = finalOffset;
keyboardOffsetInfo.inAniStartOffset = pageHeight;
keyboardOffsetInfo.outAniEndOffset = finalOffset + keyboardHeight;
return keyboardOffsetInfo;
}
void OverlayManager::BindKeyboard(const std::function<void()>& keyboardBuilder, int32_t targetId)
{
if (customKeyboardMap_.find(targetId) != customKeyboardMap_.end()) {

View File

@ -88,6 +88,12 @@ struct DismissTarget {
bool targetIsSheet = false;
};
struct CustomKeyboardOffsetInfo {
float finalOffset = 0.0f;
float inAniStartOffset = 0.0f;
float outAniEndOffset = 0.0f;
};
// StageManager is the base class for root render node to perform page switch.
class ACE_FORCE_EXPORT OverlayManager : public virtual AceType {
DECLARE_ACE_TYPE(OverlayManager, AceType);
@ -755,6 +761,7 @@ private:
RefPtr<FrameNode> GetOverlayFrameNode();
void MountToParentWithService(const RefPtr<UINode>& rootNode, const RefPtr<FrameNode>& node);
void RemoveChildWithService(const RefPtr<UINode>& rootNode, const RefPtr<FrameNode>& node);
CustomKeyboardOffsetInfo CalcCustomKeyboardOffset(const RefPtr<FrameNode>& customKeyboard);
RefPtr<FrameNode> overlayNode_;
// Key: frameNode Id, Value: index