diff --git a/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp b/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp index 4a215247516f70625086b1b65c91ae35f41c47c6..bf2e6515b2fe393c48f578b5f79775be4009eaa7 100644 --- a/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp +++ b/frameworks/bridge/declarative_frontend/frontend_delegate_declarative.cpp @@ -1970,6 +1970,10 @@ DialogProperties FrontendDelegateDeclarative::ParsePropertiesFromAttr(const Prom .borderWidth = dialogAttr.borderWidth, .borderColor = dialogAttr.borderColor, .borderStyle = dialogAttr.borderStyle, .shadow = dialogAttr.shadow, .width = dialogAttr.width, .height = dialogAttr.height, + .hasCustomMaskColor = dialogAttr.hasCustomMaskColor, + .hasCustomShadowColor = dialogAttr.hasCustomShadowColor, + .hasCustomBackgroundColor = dialogAttr.hasCustomBackgroundColor, + .hasCustomBorderColor = dialogAttr.hasCustomBorderColor, .isUserCreatedDialog = dialogAttr.isUserCreatedDialog, .maskRect = dialogAttr.maskRect, .transitionEffect = dialogAttr.transitionEffect, .dialogTransitionEffect = dialogAttr.dialogTransitionEffect, diff --git a/frameworks/bridge/declarative_frontend/jsview/action_sheet/js_action_sheet.cpp b/frameworks/bridge/declarative_frontend/jsview/action_sheet/js_action_sheet.cpp index d7e92f849ea8501e2decdc453d243231b99c4b89..953fdec479ee1a504e7450ab572036a12bb78266 100644 --- a/frameworks/bridge/declarative_frontend/jsview/action_sheet/js_action_sheet.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/action_sheet/js_action_sheet.cpp @@ -194,11 +194,28 @@ void ParseShadow(DialogProperties& properties, JSRef obj) // Parse shadow. auto shadowValue = obj->GetProperty("shadow"); Shadow shadow; - if ((shadowValue->IsObject() || shadowValue->IsNumber()) && JSActionSheet::ParseShadowProps(shadowValue, shadow)) { + if ((shadowValue->IsObject() || shadowValue->IsNumber()) && + JSActionSheet::ParseDialogShadowProps(shadowValue, shadow, properties.hasCustomShadowColor)) { properties.shadow = shadow; } } +void ParseBackgroundColor(DialogProperties& properties, JSRef obj) +{ + // Parse backgroundColor. + if (obj->IsEmpty()) { + return; + } + auto backgroundColorValue = obj->GetProperty("backgroundColor"); + Color backgroundColor; + if (JSViewAbstract::ParseJsColor(backgroundColorValue, backgroundColor)) { + if (SystemProperties::ConfigChangePerform()) { + properties.hasCustomBackgroundColor = true; + } + properties.backgroundColor = backgroundColor; + } +} + void ParseBorderWidthAndColor(DialogProperties& properties, JSRef obj) { auto borderWidthValue = obj->GetProperty("borderWidth"); @@ -208,6 +225,9 @@ void ParseBorderWidthAndColor(DialogProperties& properties, JSRef obj) auto colorValue = obj->GetProperty("borderColor"); NG::BorderColorProperty borderColor; if (JSActionSheet::ParseBorderColorProps(colorValue, borderColor)) { + if (SystemProperties::ConfigChangePerform()) { + properties.hasCustomBorderColor = true; + } properties.borderColor = borderColor; } else { borderColor.SetColor(Color::BLACK); @@ -487,11 +507,7 @@ void JSActionSheet::Show(const JSCallbackInfo& args) properties.isModal = isModalValue->ToBoolean(); } - auto backgroundColorValue = obj->GetProperty("backgroundColor"); - Color backgroundColor; - if (JSViewAbstract::ParseJsColor(backgroundColorValue, backgroundColor)) { - properties.backgroundColor = backgroundColor; - } + ParseBackgroundColor(properties, obj); auto backgroundBlurStyle = obj->GetProperty("backgroundBlurStyle"); if (backgroundBlurStyle->IsNumber()) { diff --git a/frameworks/bridge/declarative_frontend/jsview/dialog/js_alert_dialog.cpp b/frameworks/bridge/declarative_frontend/jsview/dialog/js_alert_dialog.cpp index f0aa2301a74f41bfd977545c3f56fb7cd61f4243..5a9e3b7d2756bd0cbdcc6c2c2d6cb06e07ba8d3b 100644 --- a/frameworks/bridge/declarative_frontend/jsview/dialog/js_alert_dialog.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/dialog/js_alert_dialog.cpp @@ -241,11 +241,28 @@ void ParseAlertShadow(DialogProperties& properties, JSRef obj) // Parse shadow. auto shadowValue = obj->GetProperty("shadow"); Shadow shadow; - if ((shadowValue->IsObject() || shadowValue->IsNumber()) && JSAlertDialog::ParseShadowProps(shadowValue, shadow)) { + if ((shadowValue->IsObject() || shadowValue->IsNumber()) && + JSAlertDialog::ParseDialogShadowProps(shadowValue, shadow, properties.hasCustomShadowColor)) { properties.shadow = shadow; } } +void ParseAlertBackgroundColor(DialogProperties& properties, JSRef obj) +{ + // Parse backgroundColor. + if (obj->IsEmpty()) { + return; + } + auto backgroundColorValue = obj->GetProperty("backgroundColor"); + Color backgroundColor; + if (JSViewAbstract::ParseJsColor(backgroundColorValue, backgroundColor)) { + if (SystemProperties::ConfigChangePerform()) { + properties.hasCustomBackgroundColor = true; + } + properties.backgroundColor = backgroundColor; + } +} + void ParseAlertBorderWidthAndColor(DialogProperties& properties, JSRef obj) { auto borderWidthValue = obj->GetProperty("borderWidth"); @@ -255,6 +272,9 @@ void ParseAlertBorderWidthAndColor(DialogProperties& properties, JSRef auto colorValue = obj->GetProperty("borderColor"); NG::BorderColorProperty borderColor; if (JSAlertDialog::ParseBorderColorProps(colorValue, borderColor)) { + if (SystemProperties::ConfigChangePerform()) { + properties.hasCustomBorderColor = true; + } properties.borderColor = borderColor; } else { borderColor.SetColor(Color::BLACK); @@ -523,11 +543,7 @@ void JSAlertDialog::Show(const JSCallbackInfo& args) properties.isModal = isModalValue->ToBoolean(); } - auto backgroundColorValue = obj->GetProperty("backgroundColor"); - Color backgroundColor; - if (JSViewAbstract::ParseJsColor(backgroundColorValue, backgroundColor)) { - properties.backgroundColor = backgroundColor; - } + ParseAlertBackgroundColor(properties, obj); auto backgroundBlurStyle = obj->GetProperty("backgroundBlurStyle"); if (backgroundBlurStyle->IsNumber()) { auto blurStyle = backgroundBlurStyle->ToNumber(); diff --git a/frameworks/bridge/declarative_frontend/jsview/dialog/js_custom_dialog_controller.cpp b/frameworks/bridge/declarative_frontend/jsview/dialog/js_custom_dialog_controller.cpp index 424c497d538a12599add71a0979d56940a354959..c08801f8c9d5d3f980c426b8404b34ab26c4da13 100644 --- a/frameworks/bridge/declarative_frontend/jsview/dialog/js_custom_dialog_controller.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/dialog/js_custom_dialog_controller.cpp @@ -108,6 +108,38 @@ void ParseCustomDialogFocusable(DialogProperties& properties, JSRef ob properties.focusable = focusableValue->ToBoolean(); } +void ParseCustomDialogBackgroundColor(DialogProperties& properties, JSRef obj) +{ + // Parse backgroundColor. + if (obj->IsEmpty()) { + return; + } + auto backgroundColorValue = obj->GetProperty("backgroundColor"); + Color backgroundColor; + if (JSViewAbstract::ParseJsColor(backgroundColorValue, backgroundColor)) { + if (SystemProperties::ConfigChangePerform()) { + properties.hasCustomBackgroundColor = true; + } + properties.backgroundColor = backgroundColor; + } +} + +void ParseCustomDialogMaskColor(DialogProperties& properties, JSRef obj) +{ + // Parse backgroundColor. + if (obj->IsEmpty()) { + return; + } + auto maskColorValue = obj->GetProperty("maskColor"); + Color maskColor; + if (JSViewAbstract::ParseJsColor(maskColorValue, maskColor)) { + if (SystemProperties::ConfigChangePerform()) { + properties.hasCustomMaskColor = true; + } + properties.maskColor = maskColor; + } +} + static std::atomic controllerId = 0; void JSCustomDialogController::ConstructorCallback(const JSCallbackInfo& info) @@ -238,11 +270,7 @@ void JSCustomDialogController::ConstructorCallback(const JSCallbackInfo& info) } // Parse maskColor. - auto maskColorValue = constructorArg->GetProperty("maskColor"); - Color maskColor; - if (JSViewAbstract::ParseJsColor(maskColorValue, maskColor)) { - instance->dialogProperties_.maskColor = maskColor; - } + ParseCustomDialogMaskColor(instance->dialogProperties_, constructorArg ); // Parse maskRect. auto maskRectValue = constructorArg->GetProperty("maskRect"); @@ -250,13 +278,9 @@ void JSCustomDialogController::ConstructorCallback(const JSCallbackInfo& info) if (JSViewAbstract::ParseJsDimensionRect(maskRectValue, maskRect)) { instance->dialogProperties_.maskRect = maskRect; } - // Parse backgroundColor. - auto backgroundColorValue = constructorArg->GetProperty("backgroundColor"); - Color backgroundColor; - if (JSViewAbstract::ParseJsColor(backgroundColorValue, backgroundColor)) { - instance->dialogProperties_.backgroundColor = backgroundColor; - } + ParseCustomDialogBackgroundColor(instance->dialogProperties_, constructorArg); + // Parse backgroundBlurStyle. auto backgroundBlurStyle = constructorArg->GetProperty("backgroundBlurStyle"); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp index 280c48f19853c3ccfd78f03e89ece98aa0c2dc73..432aca057583c1b911882422dce8e489bd532840 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp @@ -11802,6 +11802,64 @@ void JSViewAbstract::SetDragNumberBadge(const JSCallbackInfo& info, NG::DragPrev } } +void JSViewAbstract::ParseDialogJsColor( + RefPtr& colorResObj, const Color& color, Shadow& shadow, bool& hasCustomShadowColor) +{ + shadow.SetColor(color); + if (!SystemProperties::ConfigChangePerform()) { + return; + } + hasCustomShadowColor = true; + if (colorResObj) { + auto&& updateFunc = [](const RefPtr& colorResObj, Shadow& shadow) { + Color colorValue; + ResourceParseUtils::ParseResColor(colorResObj, colorValue); + shadow.SetColor(colorValue); + }; + shadow.AddResource("shadow.colorValue", colorResObj, std::move(updateFunc)); + } +} + +bool JSViewAbstract::ParseDialogShadowProps( + const JSRef& jsValue, Shadow& shadow, bool& hasCustomShadowColor, const bool configChangePerform) +{ + int32_t shadowStyle = 0; + if (ParseJsInteger(jsValue, shadowStyle)) { + auto style = static_cast(shadowStyle); + return GetShadowFromTheme(style, shadow, configChangePerform); + } + if (!jsValue->IsObject()) { + return false; + } + JSRef jsObj = JSRef::Cast(jsValue); + double radius = 0.0; + ParseShadowPropsUpdate(jsObj, radius, shadow); + if (LessNotEqual(radius, 0.0)) { + radius = 0.0; + } + shadow.SetBlurRadius(radius); + ParseShadowOffsetXY(jsObj, shadow); + Color color; + ShadowColorStrategy shadowColorStrategy; + auto jsColor = jsObj->GetProperty(static_cast(ArkUIIndex::COLOR)); + RefPtr colorResObj; + if (ParseJsShadowColorStrategy(jsColor, shadowColorStrategy)) { + shadow.SetShadowColorStrategy(shadowColorStrategy); + } else if (ParseJsColor(jsColor, color, colorResObj)) { + ParseDialogJsColor(colorResObj, color, shadow, hasCustomShadowColor); + } + + int32_t type = static_cast(ShadowType::COLOR); + JSViewAbstract::ParseJsInt32(jsObj->GetProperty(static_cast(ArkUIIndex::TYPE)), type); + if (type != static_cast(ShadowType::BLUR)) { + type = static_cast(ShadowType::COLOR); + } + shadow.SetShadowType(static_cast(type)); + bool isFilled = jsObj->GetPropertyValue(static_cast(ArkUIIndex::FILL), false); + shadow.SetIsFilled(isFilled); + return true; +} + void JSViewAbstract::SetDialogProperties(const JSRef& obj, DialogProperties& properties) { // Parse cornerRadius. @@ -11818,6 +11876,9 @@ void JSViewAbstract::SetDialogProperties(const JSRef& obj, DialogPrope auto colorValue = obj->GetProperty("borderColor"); NG::BorderColorProperty borderColor; if (ParseBorderColorProps(colorValue, borderColor)) { + if (SystemProperties::ConfigChangePerform()) { + properties.hasCustomBorderColor = true; + } properties.borderColor = borderColor; } else { borderColor.SetColor(Color::BLACK); @@ -11835,7 +11896,7 @@ void JSViewAbstract::SetDialogProperties(const JSRef& obj, DialogPrope } auto shadowValue = obj->GetProperty("shadow"); Shadow shadow; - if ((shadowValue->IsObject() || shadowValue->IsNumber()) && ParseShadowProps(shadowValue, shadow)) { + if ((shadowValue->IsObject() || shadowValue->IsNumber()) && ParseDialogShadowProps(shadowValue, shadow, properties.hasCustomShadowColor)) { properties.shadow = shadow; } auto widthValue = obj->GetProperty("width"); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h index 3313054f8ce47fc9d700773f9f3480d23ad53f18..b43f43ba334c085515f9e9758f77a8dcfe07d838 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h @@ -474,6 +474,9 @@ public: static bool GetJsMediaBundleInfo(const JSRef& jsValue, std::string& bundleName, std::string& moduleName); static void ParseShadowPropsUpdate(const JSRef& jsObj, double& radius, Shadow& shadow); static bool ParseShadowProps(const JSRef& jsValue, Shadow& shadow, const bool configChangePerform = false); + static bool ParseDialogShadowProps(const JSRef& jsValue, Shadow& shadow, bool& hasCustomShadowColor, + const bool configChangePerform = false); + static void ParseDialogJsColor(RefPtr& colorResObj, const Color& color, Shadow& shadow, bool& hasCustomShadowColor); static void ParseShadowOffsetXY(const JSRef& jsObj, Shadow& shadow); static bool GetShadowFromTheme(ShadowStyle shadowStyle, Shadow& shadow, const bool configChangePerform = false); static bool ParseJsResource(const JSRef& jsValue, CalcDimension& result); diff --git a/frameworks/bridge/declarative_frontend/ng/frontend_delegate_declarative_ng.cpp b/frameworks/bridge/declarative_frontend/ng/frontend_delegate_declarative_ng.cpp index f2f4f595983900c1d99ced5ab93f436d36999d80..3efcc52ed3ac8a310a516f7b7912a2fdcc9a87cc 100644 --- a/frameworks/bridge/declarative_frontend/ng/frontend_delegate_declarative_ng.cpp +++ b/frameworks/bridge/declarative_frontend/ng/frontend_delegate_declarative_ng.cpp @@ -885,6 +885,10 @@ DialogProperties FrontendDelegateDeclarativeNG::ParsePropertiesFromAttr(const Pr .borderWidth = dialogAttr.borderWidth, .borderColor = dialogAttr.borderColor, .borderStyle = dialogAttr.borderStyle, .shadow = dialogAttr.shadow, .width = dialogAttr.width, .height = dialogAttr.height, + .hasCustomMaskColor = dialogAttr.hasCustomMaskColor, + .hasCustomShadowColor = dialogAttr.hasCustomShadowColor, + .hasCustomBackgroundColor = dialogAttr.hasCustomBackgroundColor, + .hasCustomBorderColor = dialogAttr.hasCustomBorderColor, .isUserCreatedDialog = dialogAttr.isUserCreatedDialog, .maskRect = dialogAttr.maskRect, .transitionEffect = dialogAttr.transitionEffect, .contentNode = dialogAttr.contentNode, diff --git a/frameworks/core/components/dialog/dialog_properties.h b/frameworks/core/components/dialog/dialog_properties.h index 529ff1e6988a1e381ea1c431220339224d169a5c..62698054405fddb393d200c40574ea84a7bccb2d 100644 --- a/frameworks/core/components/dialog/dialog_properties.h +++ b/frameworks/core/components/dialog/dialog_properties.h @@ -338,6 +338,10 @@ struct PromptDialogAttr { std::optional width; std::optional height; std::optional hoverModeArea; + bool hasCustomMaskColor = false; + bool hasCustomShadowColor = false; + bool hasCustomBackgroundColor = false; + bool hasCustomBorderColor = false; WeakPtr contentNode; bool customStyle = false; diff --git a/frameworks/core/components_ng/pattern/action_sheet/action_sheet_model_ng.cpp b/frameworks/core/components_ng/pattern/action_sheet/action_sheet_model_ng.cpp index 9a44f37670ff6870507cb7cef7129c377eccf51c..a75b157cafbecef9c27574e465d5036ec66ee000 100644 --- a/frameworks/core/components_ng/pattern/action_sheet/action_sheet_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/action_sheet/action_sheet_model_ng.cpp @@ -62,6 +62,10 @@ void ActionSheetModelNG::ShowActionSheet(const DialogProperties& arg) Maskarg.autoCancel = arg.autoCancel; Maskarg.onWillDismiss = arg.onWillDismiss; Maskarg.shadow = arg.shadow; + Maskarg.hasCustomMaskColor = arg.hasCustomMaskColor; + Maskarg.hasCustomShadowColor = arg.hasCustomShadowColor; + Maskarg.hasCustomBackgroundColor = arg.hasCustomBackgroundColor; + Maskarg.hasCustomBorderColor = arg.hasCustomBorderColor; auto mask = overlayManager->ShowDialog(Maskarg, nullptr, false); CHECK_NULL_VOID(mask); overlayManager->SetMaskNodeId(dialog->GetId(), mask->GetId()); diff --git a/frameworks/core/components_ng/pattern/dialog/alert_dialog_model_ng.cpp b/frameworks/core/components_ng/pattern/dialog/alert_dialog_model_ng.cpp index d235fd7258dd9cad8e6e089d461a97c38ba37466..29e9ad3003d2b6b7de0a5030deffe2cc30e339a6 100644 --- a/frameworks/core/components_ng/pattern/dialog/alert_dialog_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/dialog/alert_dialog_model_ng.cpp @@ -82,6 +82,10 @@ void AlertDialogModelNG::SetShowDialog(const DialogProperties& arg) Maskarg.autoCancel = arg.autoCancel; Maskarg.onWillDismiss = arg.onWillDismiss; Maskarg.shadow = arg.shadow; + Maskarg.hasCustomMaskColor = arg.hasCustomMaskColor; + Maskarg.hasCustomShadowColor = arg.hasCustomShadowColor; + Maskarg.hasCustomBackgroundColor = arg.hasCustomBackgroundColor; + Maskarg.hasCustomBorderColor = arg.hasCustomBorderColor; auto mask = overlayManager->ShowDialog(Maskarg, nullptr, false); CHECK_NULL_VOID(mask); overlayManager->SetMaskNodeId(dialog->GetId(), mask->GetId()); diff --git a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp index 2eb39bc6bc59abb85200a5c65fa17cfdb86e58df..928911b296da52ac895a352b0a5011c8e49c3b89 100644 --- a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp +++ b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp @@ -3205,6 +3205,10 @@ RefPtr OverlayManager::SetDialogMask(const DialogProperties& dialogPr Maskarg.autoCancel = dialogProps.autoCancel; Maskarg.onWillDismiss = dialogProps.onWillDismiss; Maskarg.maskColor = dialogProps.maskColor; + Maskarg.hasCustomMaskColor = dialogProps.hasCustomMaskColor; + Maskarg.hasCustomShadowColor = dialogProps.hasCustomShadowColor; + Maskarg.hasCustomBackgroundColor = dialogProps.hasCustomBackgroundColor; + Maskarg.hasCustomBorderColor = dialogProps.hasCustomBorderColor; Maskarg.focusable = dialogProps.focusable; Maskarg.levelOrder = GetTopOrder(); return ShowDialog(Maskarg, nullptr, false); diff --git a/frameworks/core/components_ng/pattern/toast/toast_layout_property.h b/frameworks/core/components_ng/pattern/toast/toast_layout_property.h index 190383e951177d7ebc9c7bff4fad3f8013430594..e57a813b2f5db62da8d3ed403252d7731a97d433 100644 --- a/frameworks/core/components_ng/pattern/toast/toast_layout_property.h +++ b/frameworks/core/components_ng/pattern/toast/toast_layout_property.h @@ -39,6 +39,10 @@ struct ToastInfo { std::optional textColor; std::optional backgroundBlurStyle; std::optional shadow; + bool hasCustomMaskColor = false; + bool hasCustomShadowColor = false; + bool hasCustomBackgroundColor = false; + bool hasCustomBorderColor = false; bool enableHoverMode = false; HoverModeAreaType hoverModeArea = HoverModeAreaType::BOTTOM_SCREEN; bool isTypeStyleShadow = true; diff --git a/interfaces/napi/kits/promptaction/prompt_action.cpp b/interfaces/napi/kits/promptaction/prompt_action.cpp index 7de6930117541a9c0d8552db7e1934afdafce239..52f04e5b92322a7c3b9eea358e70e80a27d0c8ed 100644 --- a/interfaces/napi/kits/promptaction/prompt_action.cpp +++ b/interfaces/napi/kits/promptaction/prompt_action.cpp @@ -203,13 +203,16 @@ bool GetToastOffset(napi_env env, napi_value offsetApi, std::optional& backgroundColor) +void GetToastBackgroundColor(napi_env env, napi_value backgroundColorNApi, std::optional& backgroundColor, bool& hasCustomBackgroundColor) { napi_valuetype valueType = napi_undefined; napi_typeof(env, backgroundColorNApi, &valueType); Color color; backgroundColor = std::nullopt; if (ParseNapiColor(env, backgroundColorNApi, color)) { + if (SystemProperties::ConfigChangePerform()) { + hasCustomBackgroundColor = true; + } backgroundColor = color; } } @@ -277,7 +280,7 @@ bool ParseResource(const ResourceInfo resource, CalcDimension& result) return false; } -void GetToastObjectShadow(napi_env env, napi_value shadowNApi, Shadow& shadowProps) +void GetToastObjectShadow(napi_env env, napi_value shadowNApi, Shadow& shadowProps, bool& hasCustomShadowColor) { napi_value radiusApi = nullptr; napi_value colorApi = nullptr; @@ -306,6 +309,9 @@ void GetToastObjectShadow(napi_env env, napi_value shadowNApi, Shadow& shadowPro if (ParseShadowColorStrategy(env, colorApi, shadowColorStrategy)) { shadowProps.SetShadowColorStrategy(shadowColorStrategy); } else if (ParseNapiColor(env, colorApi, color)) { + if (SystemProperties::ConfigChangePerform()) { + hasCustomShadowColor = true; + } shadowProps.SetColor(color); } napi_valuetype valueType = GetValueType(env, typeApi); @@ -339,7 +345,7 @@ ShadowStyle GetToastDefaultShadowStyle() return toastTheme->GetToastShadowStyle(); } -void GetToastShadow(napi_env env, napi_value shadowNApi, std::optional& shadow, bool& isTypeStyleShadow) +void GetToastShadow(napi_env env, napi_value shadowNApi, std::optional& shadow, bool& isTypeStyleShadow, bool& hasCustomShadowColor) { Shadow shadowProps; napi_valuetype valueType = napi_undefined; @@ -380,7 +386,7 @@ void GetToastShadow(napi_env env, napi_value shadowNApi, std::optional& shadowProps.SetOffsetY(offsetY.Value()); } } - GetToastObjectShadow(env, shadowNApi, shadowProps); + GetToastObjectShadow(env, shadowNApi, shadowProps, hasCustomShadowColor); isTypeStyleShadow = false; } else { auto shadowStyle = GetToastDefaultShadowStyle(); @@ -467,10 +473,10 @@ bool GetToastParams(napi_env env, napi_value argv, NG::ToastInfo& toastInfo) return false; } GetToastHoverModeParams(env, argv, toastInfo); - GetToastBackgroundColor(env, backgroundColorNApi, toastInfo.backgroundColor); + GetToastBackgroundColor(env, backgroundColorNApi, toastInfo.backgroundColor, toastInfo.hasCustomBackgroundColor); GetToastTextColor(env, textColorNApi, toastInfo.textColor); GetToastBackgroundBlurStyle(env, backgroundBlurStyleNApi, toastInfo.backgroundBlurStyle); - GetToastShadow(env, shadowNApi, toastInfo.shadow, toastInfo.isTypeStyleShadow); + GetToastShadow(env, shadowNApi, toastInfo.shadow, toastInfo.isTypeStyleShadow, toastInfo.hasCustomShadowColor); return true; } @@ -1155,7 +1161,8 @@ std::optional GetBorderStyleProps( return std::nullopt; } -void GetNapiObjectShadow(napi_env env, const std::shared_ptr& asyncContext, Shadow& shadow) +void GetNapiObjectShadow( + napi_env env, const std::shared_ptr& asyncContext, Shadow& shadow, bool& hasCustomShadowColor) { napi_value radiusApi = nullptr; napi_value colorApi = nullptr; @@ -1176,6 +1183,9 @@ void GetNapiObjectShadow(napi_env env, const std::shared_ptr if (ParseShadowColorStrategy(env, colorApi, shadowColorStrategy)) { shadow.SetShadowColorStrategy(shadowColorStrategy); } else if (ParseNapiColor(env, colorApi, color)) { + if (SystemProperties::ConfigChangePerform()) { + hasCustomShadowColor = true; + } shadow.SetColor(color); } napi_valuetype valueType = GetValueType(env, typeApi); @@ -1197,7 +1207,8 @@ void GetNapiObjectShadow(napi_env env, const std::shared_ptr shadow.SetIsFilled(isFilled); } -std::optional GetShadowProps(napi_env env, const std::shared_ptr& asyncContext) +std::optional GetShadowProps( + napi_env env, const std::shared_ptr& asyncContext, bool& hasCustomShadowColor) { Shadow shadow; napi_valuetype valueType = napi_undefined; @@ -1218,6 +1229,7 @@ std::optional GetShadowProps(napi_env env, const std::shared_ptrshadowApi, "offsetX", &offsetXApi); napi_get_named_property(env, asyncContext->shadowApi, "offsetY", &offsetYApi); ResourceInfo recv; + CalcDimension offsetX; bool isRtl = AceApplicationInfo::GetInstance().IsRightToLeft(); if (ParseResourceParam(env, offsetXApi, recv)) { auto resourceWrapper = CreateResourceWrapper(recv); @@ -1225,25 +1237,20 @@ std::optional GetShadowProps(napi_env env, const std::shared_ptrGetDimension(recv.resId); double xValue = isRtl ? offsetX.Value() * (-1) : offsetX.Value(); shadow.SetOffsetX(xValue); - } else { - CalcDimension offsetX; - if (ParseNapiDimension(env, offsetX, offsetXApi, DimensionUnit::VP)) { - double xValue = isRtl ? offsetX.Value() * (-1) : offsetX.Value(); - shadow.SetOffsetX(xValue); - } + } else if (ParseNapiDimension(env, offsetX, offsetXApi, DimensionUnit::VP)) { + double xValue = isRtl ? offsetX.Value() * (-1) : offsetX.Value(); + shadow.SetOffsetX(xValue); } + CalcDimension offsetY; if (ParseResourceParam(env, offsetYApi, recv)) { auto resourceWrapper = CreateResourceWrapper(recv); CHECK_NULL_RETURN(resourceWrapper, std::nullopt); auto offsetY = resourceWrapper->GetDimension(recv.resId); shadow.SetOffsetY(offsetY.Value()); - } else { - CalcDimension offsetY; - if (ParseNapiDimension(env, offsetY, offsetYApi, DimensionUnit::VP)) { - shadow.SetOffsetY(offsetY.Value()); - } + } else if (ParseNapiDimension(env, offsetY, offsetYApi, DimensionUnit::VP)) { + shadow.SetOffsetY(offsetY.Value()); } - GetNapiObjectShadow(env, asyncContext, shadow); + GetNapiObjectShadow(env, asyncContext, shadow, hasCustomShadowColor); return shadow; } return std::nullopt; @@ -1621,6 +1628,8 @@ napi_value JSPromptShowDialog(napi_env env, napi_callback_info info) LevelMode dialogLevelMode = LevelMode::OVERLAY; int32_t dialogLevelUniqueId = -1; ImmersiveMode dialogImmersiveMode = ImmersiveMode::DEFAULT; + bool hasCustomShadowColor = false; + bool hasCustomBackgroundColor = false; PromptDialogAttr lifeCycleAttr = {}; for (size_t i = 0; i < argc; i++) { napi_valuetype valueType = napi_undefined; @@ -1658,7 +1667,10 @@ napi_value JSPromptShowDialog(napi_env env, napi_callback_info info) GetNapiString(env, asyncContext->messageNApi, asyncContext->messageString, valueType); GetNapiDialogProps(env, asyncContext, alignment, offset, maskRect); backgroundColor = GetColorProps(env, asyncContext->backgroundColorApi); - shadowProps = GetShadowProps(env, asyncContext); + if (backgroundColor && SystemProperties::ConfigChangePerform()) { + hasCustomBackgroundColor = true; + } + shadowProps = GetShadowProps(env, asyncContext, hasCustomShadowColor); GetNapiBlurStyleAndHoverModeProps(env, asyncContext, backgroundBlurStyle, hoverModeArea, enableHoverMode); GetBackgroundBlurStyleOption(env, asyncContext, blurStyleOption); GetBackgroundEffect(env, asyncContext, effectOption); @@ -1702,13 +1714,14 @@ napi_value JSPromptShowDialog(napi_env env, napi_callback_info info) return nullptr; } } - auto onLanguageChange = [shadowProps, alignment, offset, maskRect, + auto onLanguageChange = [shadowProps, alignment, offset, maskRect, hasCustomShadowColor, updateAlignment = UpdatePromptAlignment](DialogProperties& dialogProps) { bool isRtl = AceApplicationInfo::GetInstance().IsRightToLeft(); if (shadowProps.has_value()) { std::optional shadow = shadowProps.value(); double offsetX = isRtl ? shadow->GetOffset().GetX() * (-1) : shadow->GetOffset().GetX(); shadow->SetOffsetX(offsetX); + dialogProps.hasCustomShadowColor = hasCustomShadowColor; dialogProps.shadow = shadow.value(); } if (alignment.has_value()) { @@ -1829,6 +1842,8 @@ napi_value JSPromptShowDialog(napi_env env, napi_callback_info info) .effectOption = effectOption, .shadow = shadowProps, .hoverModeArea = hoverModeArea, + .hasCustomShadowColor = hasCustomShadowColor, + .hasCustomBackgroundColor = hasCustomBackgroundColor, .onLanguageChange = onLanguageChange, .levelOrder = GetLevelOrderParam(asyncContext->env, asyncContext), .onDidAppear = lifeCycleAttr.onDidAppear, @@ -2284,15 +2299,18 @@ void ParseDialogCallback(std::shared_ptr& asyncContext, } void ParseBorderColorAndStyle(napi_env env, const std::shared_ptr& asyncContext, - std::optional& borderWidthProps, std::optional& borderColorProps, - std::optional& borderStyleProps) + std::optional& borderColorProps, std::optional& borderStyleProps, + bool& hasCustomBorderColor) { + auto borderWidthProps = GetBorderWidthProps(env, asyncContext); if (borderWidthProps.has_value()) { borderColorProps = GetBorderColorProps(env, asyncContext); if (!borderColorProps.has_value()) { NG::BorderColorProperty borderColor; borderColor.SetColor(Color::BLACK); borderColorProps = borderColor; + } else if (SystemProperties::ConfigChangePerform()) { + hasCustomBorderColor = true; } borderStyleProps = GetBorderStyleProps(env, asyncContext); if (!borderStyleProps.has_value()) { @@ -2400,18 +2418,28 @@ PromptDialogAttr GetPromptActionDialog(napi_env env, const std::shared_ptr blurStyleOption; std::optional effectOption; std::optional enableHoverMode; + bool hasCustomMaskColor = false; + bool hasCustomShadowColor = false; + bool hasCustomBackgroundColor = false; + bool hasCustomBorderColor = false; GetNapiDialogProps(env, asyncContext, alignment, offset, maskRect); GetNapiBlurStyleAndHoverModeProps(env, asyncContext, backgroundBlurStyle, hoverModeArea, enableHoverMode); GetBackgroundBlurStyleOption(env, asyncContext, blurStyleOption); GetBackgroundEffect(env, asyncContext, effectOption); - auto borderWidthProps = GetBorderWidthProps(env, asyncContext); std::optional borderColorProps; std::optional borderStyleProps; - ParseBorderColorAndStyle(env, asyncContext, borderWidthProps, borderColorProps, borderStyleProps); + ParseBorderColorAndStyle(env, asyncContext, borderColorProps, borderStyleProps, hasCustomBorderColor); auto backgroundColorProps = GetColorProps(env, asyncContext->backgroundColorApi); + if (backgroundColorProps && SystemProperties::ConfigChangePerform()) { + hasCustomBackgroundColor = true; + } auto builder = GetCustomBuilder(env, asyncContext); auto* nodePtr = reinterpret_cast(asyncContext->nativePtr); auto maskColorProps = GetColorProps(env, asyncContext->maskColorApi); + if (maskColorProps && SystemProperties::ConfigChangePerform()) { + hasCustomMaskColor = true; + } + auto shadowProps = GetShadowProps(env, asyncContext, hasCustomShadowColor); auto transitionEffectProps = GetTransitionProps(env, asyncContext); auto dialogTransitionEffectProps = GetDialogTransitionProps(env, asyncContext); auto maskTransitionEffectProps = GetMaskTransitionProps(env, asyncContext); @@ -2434,16 +2462,20 @@ PromptDialogAttr GetPromptActionDialog(napi_env env, const std::shared_ptr