mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
!44969 【ModalUec】Support isAllowAddChildBelowModalUec
Merge pull request !44969 from dujingcheng/isAllowAddChildBelowCurNode
This commit is contained in:
commit
871ef7e41e
@ -3218,9 +3218,11 @@ int32_t UIContentImpl::CreateModalUIExtension(
|
||||
TAG_LOGI(AceLogTag::ACE_UIEXTENSIONCOMPONENT,
|
||||
"[%{public}s][%{public}s][%{public}d]: create modal page, "
|
||||
"sessionId=%{public}d, isProhibitBack=%{public}d, isAsyncModalBinding=%{public}d, "
|
||||
"isAllowedBeCovered=%{public}d, prohibitedRemoveByRouter=%{public}d",
|
||||
"isAllowedBeCovered=%{public}d, prohibitedRemoveByRouter=%{public}d, "
|
||||
"isAllowAddChildBelowModalUec=%{public}d",
|
||||
bundleName_.c_str(), moduleName_.c_str(), instanceId_, sessionId, config.isProhibitBack,
|
||||
config.isAsyncModalBinding, config.isAllowedBeCovered, config.prohibitedRemoveByRouter);
|
||||
config.isAsyncModalBinding, config.isAllowedBeCovered, config.prohibitedRemoveByRouter,
|
||||
config.isAllowAddChildBelowModalUec);
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
|
@ -109,13 +109,6 @@ void UINode::AddChild(const RefPtr<UINode>& child, int32_t slot,
|
||||
bool silently, bool addDefaultTransition, bool addModalUiextension)
|
||||
{
|
||||
CHECK_NULL_VOID(child);
|
||||
if (!addModalUiextension && modalUiextensionCount_ > 0) {
|
||||
LOGW("Current Node(id: %{public}d) is prohibited add child(tag %{public}s, id: %{public}d), "
|
||||
"Current modalUiextension count is : %{public}d",
|
||||
GetId(), child->GetTag().c_str(), child->GetId(), modalUiextensionCount_);
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = std::find(children_.begin(), children_.end(), child);
|
||||
if (it != children_.end()) {
|
||||
return;
|
||||
@ -125,9 +118,51 @@ void UINode::AddChild(const RefPtr<UINode>& child, int32_t slot,
|
||||
RemoveDisappearingChild(child);
|
||||
it = children_.begin();
|
||||
std::advance(it, slot);
|
||||
if (!addModalUiextension && modalUiextensionCount_ > 0) {
|
||||
bool canAddChild = CanAddChildWhenTopNodeIsModalUec(it);
|
||||
if (!canAddChild) {
|
||||
LOGW("Current Node(id: %{public}d) is prohibited add child(tag %{public}s, id: %{public}d), "
|
||||
"Current modalUiextension count is : %{public}d",
|
||||
GetId(), child->GetTag().c_str(), child->GetId(), modalUiextensionCount_);
|
||||
return;
|
||||
} else {
|
||||
LOGI("Child(tag %{public}s, id: %{public}d) must under modalUec, which count is: %{public}d",
|
||||
child->GetTag().c_str(), child->GetId(), modalUiextensionCount_);
|
||||
}
|
||||
}
|
||||
DoAddChild(it, child, silently, addDefaultTransition);
|
||||
}
|
||||
|
||||
bool UINode::CanAddChildWhenTopNodeIsModalUec(std::list<RefPtr<UINode>>::iterator& curIter)
|
||||
{
|
||||
if (children_.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto preIter = curIter;
|
||||
preIter--;
|
||||
// Gernerally, uiContent instance is allowwd to have multiple modalUecs.
|
||||
// Therefore, need to check all modalUec's isAllowAddChildBelowModalUec.
|
||||
while (preIter != children_.begin()) {
|
||||
if (preIter == children_.end()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((*preIter)->GetTag() != V2::MODAL_PAGE_TAG) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(*preIter)->IsAllowAddChildBelowModalUec()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
curIter--;
|
||||
preIter--;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UINode::AddChildAfter(const RefPtr<UINode>& child, const RefPtr<UINode>& siblingNode)
|
||||
{
|
||||
CHECK_NULL_VOID(child);
|
||||
|
@ -715,6 +715,16 @@ public:
|
||||
destroyCallback_(GetId());
|
||||
}
|
||||
|
||||
bool IsAllowAddChildBelowModalUec() const
|
||||
{
|
||||
return isAllowAddChildBelowModalUec_;
|
||||
}
|
||||
|
||||
void SetIsAllowAddChildBelowModalUec(bool isAllowAddChildBelowModalUec)
|
||||
{
|
||||
isAllowAddChildBelowModalUec_ = isAllowAddChildBelowModalUec;
|
||||
}
|
||||
|
||||
void SetBuilderFunc(std::function<void()>&& lazyBuilderFunc)
|
||||
{
|
||||
lazyBuilderFunc_ = lazyBuilderFunc;
|
||||
@ -864,6 +874,7 @@ protected:
|
||||
private:
|
||||
void DoAddChild(std::list<RefPtr<UINode>>::iterator& it, const RefPtr<UINode>& child, bool silently = false,
|
||||
bool addDefaultTransition = false);
|
||||
bool CanAddChildWhenTopNodeIsModalUec(std::list<RefPtr<UINode>>::iterator& curIter);
|
||||
|
||||
std::list<RefPtr<UINode>> children_;
|
||||
// disappearingChild、index、branchId
|
||||
@ -898,6 +909,7 @@ private:
|
||||
bool useOffscreenProcess_ = false;
|
||||
|
||||
bool isCNode_ = false;
|
||||
bool isAllowAddChildBelowModalUec_ = true;
|
||||
|
||||
std::function<void(int32_t)> updateJSInstanceCallback_;
|
||||
std::function<void()> lazyBuilderFunc_;
|
||||
|
@ -32,12 +32,15 @@ struct ModalStyle {
|
||||
std::optional<Color> backgroundColor;
|
||||
bool isUIExtension = false;
|
||||
bool prohibitedRemoveByRouter = false;
|
||||
bool isAllowAddChildBelowModalUec = true;
|
||||
|
||||
bool operator==(const ModalStyle& modelStyle) const
|
||||
{
|
||||
return !(modalTransition != modelStyle.modalTransition || backgroundColor != modelStyle.backgroundColor ||
|
||||
return !(modalTransition != modelStyle.modalTransition ||
|
||||
backgroundColor != modelStyle.backgroundColor ||
|
||||
isUIExtension != modelStyle.isUIExtension ||
|
||||
prohibitedRemoveByRouter != modelStyle.prohibitedRemoveByRouter);
|
||||
prohibitedRemoveByRouter != modelStyle.prohibitedRemoveByRouter ||
|
||||
isAllowAddChildBelowModalUec != modelStyle.isAllowAddChildBelowModalUec);
|
||||
}
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -3877,10 +3877,12 @@ void OverlayManager::HandleModalShow(std::function<void(const std::string&)>&& c
|
||||
if (!isAllowedBeCovered_) {
|
||||
TAG_LOGI(AceLogTag::ACE_OVERLAY,
|
||||
"modalNode->GetParent() %{public}d mark IsProhibitedAddChildNode when sessionId %{public}d,"
|
||||
"prohibitedRemoveByRouter: %{public}d.",
|
||||
modalNodeParent->GetId(), targetId, modalStyle.prohibitedRemoveByRouter);
|
||||
"prohibitedRemoveByRouter: %{public}d, isAllowAddChildBelowModalUec: %{public}d.",
|
||||
modalNodeParent->GetId(), targetId, modalStyle.prohibitedRemoveByRouter,
|
||||
modalStyle.isAllowAddChildBelowModalUec);
|
||||
if (AddCurSessionId(targetId)) {
|
||||
modalNodeParent->UpdateModalUiextensionCount(true);
|
||||
modalNode->SetIsAllowAddChildBelowModalUec(modalStyle.isAllowAddChildBelowModalUec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5971,6 +5973,7 @@ int32_t OverlayManager::CreateModalUIExtension(
|
||||
modalStyle.modalTransition = NG::ModalTransition::NONE;
|
||||
modalStyle.isUIExtension = true;
|
||||
modalStyle.prohibitedRemoveByRouter = config.prohibitedRemoveByRouter;
|
||||
modalStyle.isAllowAddChildBelowModalUec = config.isAllowAddChildBelowModalUec;
|
||||
SetIsAllowedBeCovered(config.isAllowedBeCovered);
|
||||
// Convert the sessionId into a negative number to distinguish it from the targetId of other modal pages
|
||||
BindContentCover(true, nullptr, std::move(buildNodeFunc), modalStyle, nullptr, nullptr, nullptr, nullptr,
|
||||
@ -5980,6 +5983,7 @@ int32_t OverlayManager::CreateModalUIExtension(
|
||||
auto bindModalCallback = [weak = WeakClaim(this), buildNodeFunc, sessionId, id = Container::CurrentId(),
|
||||
isAllowedBeCovered = config.isAllowedBeCovered,
|
||||
prohibitedRemoveByRouter = config.prohibitedRemoveByRouter,
|
||||
isAllowAddChildBelowModalUec = config.isAllowAddChildBelowModalUec,
|
||||
doAfterAsyncModalBinding = std::move(config.doAfterAsyncModalBinding)]() {
|
||||
ContainerScope scope(id);
|
||||
auto overlayManager = weak.Upgrade();
|
||||
@ -5989,6 +5993,7 @@ int32_t OverlayManager::CreateModalUIExtension(
|
||||
modalStyle.modalTransition = NG::ModalTransition::NONE;
|
||||
modalStyle.isUIExtension = true;
|
||||
modalStyle.prohibitedRemoveByRouter = prohibitedRemoveByRouter;
|
||||
modalStyle.isAllowAddChildBelowModalUec = isAllowAddChildBelowModalUec;
|
||||
overlayManager->BindContentCover(true, nullptr, std::move(buildNodeFunc), modalStyle, nullptr, nullptr,
|
||||
nullptr, nullptr, ContentCoverParam(), nullptr, -(sessionId));
|
||||
overlayManager->SetIsAllowedBeCovered(true);
|
||||
|
@ -35,6 +35,7 @@ struct ModalUIExtensionConfig {
|
||||
bool isAllowedBeCovered = false;
|
||||
std::function<void()> doAfterAsyncModalBinding = nullptr;
|
||||
bool prohibitedRemoveByRouter = false;
|
||||
bool isAllowAddChildBelowModalUec = false;
|
||||
};
|
||||
|
||||
struct ModalUIExtensionCallbacks {
|
||||
|
Loading…
Reference in New Issue
Block a user