!45334 【toast】修复toast阴影热更新的bug

Merge pull request !45334 from 胡占江/hzj_toast_20241010
This commit is contained in:
openharmony_ci 2024-10-10 13:45:15 +00:00 committed by Gitee
commit 54ccfeded9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 14 additions and 3 deletions

View File

@ -41,6 +41,7 @@ struct ToastInfo {
std::optional<Shadow> shadow;
bool enableHoverMode = false;
HoverModeAreaType hoverModeArea = HoverModeAreaType::BOTTOM_SCREEN;
bool isTypeStyleShadow = true;
};
class ACE_EXPORT ToastLayoutProperty : public LayoutProperty {
DECLARE_ACE_TYPE(ToastLayoutProperty, LayoutProperty);

View File

@ -157,7 +157,16 @@ void ToastView::UpdateToastNodeStyle(const RefPtr<FrameNode>& toastNode)
auto toastTheme = pipelineContext->GetTheme<ToastTheme>();
CHECK_NULL_VOID(toastTheme);
auto toastInfo = pattern->GetToastInfo();
toastContext->UpdateBackShadow(toastInfo.shadow.value_or(Shadow::CreateShadow(ShadowStyle::OuterDefaultMD)));
auto shadow = toastInfo.shadow.value_or(Shadow::CreateShadow(ShadowStyle::OuterDefaultMD));
if (toastInfo.isTypeStyleShadow) {
auto colorMode = SystemProperties::GetColorMode();
auto shadowStyle = shadow.GetStyle();
auto shadowTheme = pipelineContext->GetTheme<ShadowTheme>();
if (shadowTheme) {
shadow = shadowTheme->GetShadow(shadowStyle, colorMode);
}
}
toastContext->UpdateBackShadow(shadow);
if (Container::GreatOrEqualAPITargetVersion(PlatformVersion::VERSION_TWELVE)) {
toastContext->UpdateBackgroundColor(toastInfo.backgroundColor.value_or(Color::TRANSPARENT));
BlurStyleOption styleOption;

View File

@ -314,7 +314,7 @@ void GetToastObjectShadow(napi_env env, napi_value shadowNApi, Shadow& shadowPro
shadowProps.SetIsFilled(isFilled);
}
void GetToastShadow(napi_env env, napi_value shadowNApi, std::optional<Shadow>& shadow)
void GetToastShadow(napi_env env, napi_value shadowNApi, std::optional<Shadow>& shadow, bool& isTypeStyleShadow)
{
Shadow shadowProps;
napi_valuetype valueType = napi_undefined;
@ -356,6 +356,7 @@ void GetToastShadow(napi_env env, napi_value shadowNApi, std::optional<Shadow>&
}
}
GetToastObjectShadow(env, shadowNApi, shadowProps);
isTypeStyleShadow = false;
} else {
GetShadowFromTheme(ShadowStyle::OuterDefaultMD, shadowProps);
}
@ -443,7 +444,7 @@ bool GetToastParams(napi_env env, napi_value argv, NG::ToastInfo& toastInfo)
GetToastBackgroundColor(env, backgroundColorNApi, toastInfo.backgroundColor);
GetToastTextColor(env, textColorNApi, toastInfo.textColor);
GetToastBackgroundBlurStyle(env, backgroundBlurStyleNApi, toastInfo.backgroundBlurStyle);
GetToastShadow(env, shadowNApi, toastInfo.shadow);
GetToastShadow(env, shadowNApi, toastInfo.shadow, toastInfo.isTypeStyleShadow);
return true;
}