From 8c706c171b3becb716962004b6f14be787232749 Mon Sep 17 00:00:00 2001 From: zhangjing243 Date: Sat, 31 Aug 2024 11:12:17 +0800 Subject: [PATCH] =?UTF-8?q?dialog=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangjing243 --- .../declarative_frontend/engine/jsEnumStyle.js | 4 ++-- .../components_ng/pattern/dialog/dialog_pattern.cpp | 12 +++++++----- .../core/components_ng/pattern/picker/picker_model.h | 2 +- .../pattern/text_picker/textpicker_model.h | 2 +- interfaces/napi/kits/promptaction/prompt_action.cpp | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js b/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js index ec7ac17c3c1..5ee7c7614ab 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js +++ b/frameworks/bridge/declarative_frontend/engine/jsEnumStyle.js @@ -902,8 +902,8 @@ var DialogAlignment; let HoverModeAreaType; (function (HoverModeAreaType) { - HoverModeAreaType[HoverModeAreaType["TOP_SCREEN"] = 0] = "TOP_SCREEN"; - HoverModeAreaType[HoverModeAreaType["BOTTOM_SCREEN"] = 1] = "BOTTOM_SCREEN"; + HoverModeAreaType.TOP_SCREEN = 0; + HoverModeAreaType.BOTTOM_SCREEN = 1; })(HoverModeAreaType || (HoverModeAreaType = {})); var DialogButtonStyle; diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp index f4118c75b76..d3ba316aabb 100644 --- a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp +++ b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp @@ -137,15 +137,13 @@ void DialogPattern::OnAttachToFrameNode() void DialogPattern::RegisterHoverModeChangeCallback() { - auto host = GetHost(); - CHECK_NULL_VOID(host); - auto context = host->GetContext(); - CHECK_NULL_VOID(context); - auto hoverModeChangeCallback = [weak = WeakClaim(this), context](bool isHalfFoldHover) { + auto hoverModeChangeCallback = [weak = WeakClaim(this)](bool isHalfFoldHover) { auto pattern = weak.Upgrade(); CHECK_NULL_VOID(pattern); auto host = pattern->GetHost(); CHECK_NULL_VOID(host); + auto context = host->GetContext(); + CHECK_NULL_VOID(context); AnimationOption optionPosition; auto motion = AceType::MakeRefPtr(0.35f, 1.0f, 0.0f); optionPosition.SetCurve(motion); @@ -155,6 +153,10 @@ void DialogPattern::RegisterHoverModeChangeCallback() context->FlushUITasks(); }); }; + auto host = GetHost(); + CHECK_NULL_VOID(host); + auto context = host->GetContext(); + CHECK_NULL_VOID(context); auto hoverModeCallId = context->RegisterHalfFoldHoverChangedCallback(std::move(hoverModeChangeCallback)); UpdateHoverModeChangedCallbackId(hoverModeCallId); } diff --git a/frameworks/core/components_ng/pattern/picker/picker_model.h b/frameworks/core/components_ng/pattern/picker/picker_model.h index ff0353bc816..c3ab1542547 100644 --- a/frameworks/core/components_ng/pattern/picker/picker_model.h +++ b/frameworks/core/components_ng/pattern/picker/picker_model.h @@ -35,7 +35,7 @@ struct PickerDialogInfo { bool isStartDate; bool isEndDate; bool isSelectedDate; - bool enableHoverMode; + bool enableHoverMode = false; std::optional alignment; std::optional offset; std::optional maskRect; diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_model.h b/frameworks/core/components_ng/pattern/text_picker/textpicker_model.h index 33269be58b8..bd44a319a4a 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_model.h +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_model.h @@ -29,7 +29,7 @@ struct TextPickerDialog { uint32_t selectedValue; std::vector getRangeVector; bool isDefaultHeight; - bool enableHoverMode; + bool enableHoverMode = false; std::optional alignment; std::optional offset; std::optional maskRect; diff --git a/interfaces/napi/kits/promptaction/prompt_action.cpp b/interfaces/napi/kits/promptaction/prompt_action.cpp index 0bea470e13e..920cb6bc43b 100644 --- a/interfaces/napi/kits/promptaction/prompt_action.cpp +++ b/interfaces/napi/kits/promptaction/prompt_action.cpp @@ -833,7 +833,7 @@ void GetNapiBlurStyleAndHoverModeProps(napi_env env, const std::shared_ptrbackgroundBlurStyleApi, &blurStyleValueType); if (blurStyleValueType == napi_number) { - int32_t num; + int32_t num = 0; napi_get_value_int32(env, asyncContext->backgroundBlurStyleApi, &num); if (num >= 0 && num < BG_BLUR_STYLE_MAX_INDEX) { backgroundBlurStyle = num; @@ -843,7 +843,7 @@ void GetNapiBlurStyleAndHoverModeProps(napi_env env, const std::shared_ptrhoverModeAreaApi, &hoverModeValueType); if (hoverModeValueType == napi_number) { - int32_t num; + int32_t num = 0; napi_get_value_int32(env, asyncContext->hoverModeAreaApi, &num); if (num >= 0 && num < static_cast(HOVER_MODE_AREA_TYPE.size())) { hoverModeArea = HOVER_MODE_AREA_TYPE[num];