挑单Toast组件

Signed-off-by: zhangwenbin00001 <zhangwenbin35@h-partners.com>
This commit is contained in:
zhangwenbin00001 2024-09-06 09:51:51 +08:00
parent edb7cd1ac9
commit 81907dec06
2 changed files with 14 additions and 3 deletions

View File

@ -152,8 +152,7 @@ void ToastView::UpdateToastContext(const RefPtr<FrameNode>& toastNode)
toastContext->UpdateOuterBorderColor(outerColorProp);
}
auto toastInfo = pattern->GetToastInfo();
ShadowStyle shadowStyle = static_cast<ShadowStyle>(toastTheme->GetShadowNormal());
toastContext->UpdateBackShadow(toastInfo.shadow.value_or(Shadow::CreateShadow(shadowStyle)));
toastContext->UpdateBackShadow(toastInfo.shadow.value_or(Shadow::CreateShadow(ShadowStyle::OuterDefaultMD)));
if (Container::GreatOrEqualAPITargetVersion(PlatformVersion::VERSION_TWELVE)) {
auto defaultBGcolor = toastTheme->GetDefaultBGColor();
toastContext->UpdateBackgroundColor(defaultBGcolor);

View File

@ -22,6 +22,8 @@
#include "bridge/common/utils/engine_helper.h"
#include "core/common/ace_engine.h"
#include "core/components/theme/shadow_theme.h"
#include "core/components/toast/toast_theme.h"
#include "core/pipeline/pipeline_base.h"
namespace OHOS::Ace::Napi {
namespace {
@ -311,6 +313,16 @@ void GetToastObjectShadow(napi_env env, napi_value shadowNApi, Shadow& shadowPro
shadowProps.SetIsFilled(isFilled);
}
void GetDefaultShadow(Shadow& shadowProps)
{
auto pipelineContext = PipelineBase::GetCurrentContext();
CHECK_NULL_VOID(pipelineContext);
auto toastTheme = pipelineContext->GetTheme<ToastTheme>();
CHECK_NULL_VOID(toastTheme);
ShadowStyle shadowStyle = static_cast<ShadowStyle>(toastTheme->GetShadowNormal());
GetShadowFromTheme(shadowStyle, shadowProps);
}
void GetToastShadow(napi_env env, napi_value shadowNApi, std::optional<Shadow>& shadow)
{
Shadow shadowProps;
@ -354,7 +366,7 @@ void GetToastShadow(napi_env env, napi_value shadowNApi, std::optional<Shadow>&
}
GetToastObjectShadow(env, shadowNApi, shadowProps);
} else {
GetShadowFromTheme(ShadowStyle::OuterDefaultMD, shadowProps);
GetDefaultShadow(shadowProps);
}
shadow = shadowProps;
}