mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
[bugfix]:[toast shadow radius支持解析资源]
Signed-off-by: Zhang Jinyu <zhangjinyu101@huawei.com>
This commit is contained in:
parent
87b2b4179e
commit
b69475abde
@ -252,6 +252,26 @@ bool GetShadowFromTheme(ShadowStyle shadowStyle, Shadow& shadow)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseResource(const ResourceInfo resource, CalcDimension& result)
|
||||
{
|
||||
auto resourceWrapper = CreateResourceWrapper(resource);
|
||||
CHECK_NULL_RETURN(resourceWrapper, false);
|
||||
if (resource.type == static_cast<uint32_t>(ResourceType::STRING)) {
|
||||
auto value = resourceWrapper->GetString(resource.resId);
|
||||
return StringUtils::StringToCalcDimensionNG(value, result, false);
|
||||
}
|
||||
if (resource.type == static_cast<uint32_t>(ResourceType::INTEGER)) {
|
||||
auto value = std::to_string(resourceWrapper->GetInt(resource.resId));
|
||||
StringUtils::StringToDimensionWithUnitNG(value, result);
|
||||
return true;
|
||||
}
|
||||
if (resource.type == static_cast<uint32_t>(ResourceType::FLOAT)) {
|
||||
result = resourceWrapper->GetDimension(resource.resId);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GetToastObjectShadow(napi_env env, napi_value shadowNApi, Shadow& shadowProps)
|
||||
{
|
||||
napi_value radiusApi = nullptr;
|
||||
@ -262,12 +282,20 @@ void GetToastObjectShadow(napi_env env, napi_value shadowNApi, Shadow& shadowPro
|
||||
napi_get_named_property(env, shadowNApi, "color", &colorApi);
|
||||
napi_get_named_property(env, shadowNApi, "type", &typeApi);
|
||||
napi_get_named_property(env, shadowNApi, "fill", &fillApi);
|
||||
double radius = 0.0;
|
||||
napi_get_value_double(env, radiusApi, &radius);
|
||||
if (LessNotEqual(radius, 0.0)) {
|
||||
radius = 0.0;
|
||||
ResourceInfo recv;
|
||||
double radiusValue = 0.0;
|
||||
if (ParseResourceParam(env, radiusApi, recv)) {
|
||||
CalcDimension radius;
|
||||
if (ParseResource(recv, radius)) {
|
||||
radiusValue = LessNotEqual(radius.Value(), 0.0) ? 0.0 : radius.Value();
|
||||
}
|
||||
} else {
|
||||
napi_get_value_double(env, radiusApi, &radiusValue);
|
||||
if (LessNotEqual(radiusValue, 0.0)) {
|
||||
radiusValue = 0.0;
|
||||
}
|
||||
}
|
||||
shadowProps.SetBlurRadius(radius);
|
||||
shadowProps.SetBlurRadius(radiusValue);
|
||||
Color color;
|
||||
ShadowColorStrategy shadowColorStrategy;
|
||||
if (ParseShadowColorStrategy(env, colorApi, shadowColorStrategy)) {
|
||||
@ -294,26 +322,6 @@ void GetToastObjectShadow(napi_env env, napi_value shadowNApi, Shadow& shadowPro
|
||||
shadowProps.SetIsFilled(isFilled);
|
||||
}
|
||||
|
||||
bool ParseResource(const ResourceInfo resource, CalcDimension& result)
|
||||
{
|
||||
auto resourceWrapper = CreateResourceWrapper(resource);
|
||||
CHECK_NULL_RETURN(resourceWrapper, false);
|
||||
if (resource.type == static_cast<uint32_t>(ResourceType::STRING)) {
|
||||
auto value = resourceWrapper->GetString(resource.resId);
|
||||
return StringUtils::StringToCalcDimensionNG(value, result, false);
|
||||
}
|
||||
if (resource.type == static_cast<uint32_t>(ResourceType::INTEGER)) {
|
||||
auto value = std::to_string(resourceWrapper->GetInt(resource.resId));
|
||||
StringUtils::StringToDimensionWithUnitNG(value, result);
|
||||
return true;
|
||||
}
|
||||
if (resource.type == static_cast<uint32_t>(ResourceType::FLOAT)) {
|
||||
result = resourceWrapper->GetDimension(resource.resId);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GetToastShadow(napi_env env, napi_value shadowNApi, std::optional<Shadow>& shadow)
|
||||
{
|
||||
Shadow shadowProps;
|
||||
|
Loading…
Reference in New Issue
Block a user