From: 罗正yun <1732036298@qq.com> Date: Thu, 25 Jan 2024 09:41:38 +0000 (+0800) Subject: 系统视图左滑退出和其子视图分开 X-Git-Tag: release_V1.2.70_20241020_135402~1325 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=3ce123b7145aeba627b7d5469b9dfe8baafddf14;p=mirrors%2FFD230.git 系统视图左滑退出和其子视图分开 --- diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h index 7d23daf31..d48e2796a 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/include/SystemPresenter.h @@ -7,8 +7,8 @@ namespace OHOS { - static const char *SIMPLIFIED_CHINESE_CHECKBOX = "SimplifiedChineseCheckBox"; // 简体中文 - static const char *ENGLISH_CHECKBOX = "EnglishCheckBox"; // English + static const char *SIMPLIFIED_CHINESE_CHECKBOX = "SimplifiedChineseCheckBox"; // 简体中文 + static const char *ENGLISH_CHECKBOX = "EnglishCheckBox"; // English class RadiobuttonOnChangeListener : public UICheckBox::OnChangeListener { public: @@ -25,6 +25,16 @@ namespace OHOS UIRadioButton *m_uiView{nullptr}; }; + class SystemViewOnDragListener : public UIView::OnDragListener + { + public: + SystemViewOnDragListener() {} + + ~SystemViewOnDragListener() {} + + bool OnDrag(UIView &view, const DragEvent &event) override; + }; + class SystemView; class SystemPresenter : public Presenter, public UIView::OnClickListener, diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp index 617357c0c..a7d67a647 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemPresenter.cpp @@ -94,6 +94,16 @@ namespace OHOS return false; } + bool SystemViewOnDragListener::OnDrag(UIView &view, const DragEvent &event) + { + if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + } + return true; + } + /// @brief 简体中文单选按钮被选中 /// @param void /// @return true 表示选中 ,false 表示未选中 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp index 52d180a88..4760d3d53 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/system/src/SystemView.cpp @@ -64,7 +64,7 @@ namespace OHOS SystemScrollView[0]->SetScrollBlankSize(35); SystemScrollView[0]->SetReboundSize(50); SystemScrollView[0]->SetDirection(1); - UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); + UIView::OnDragListener *draglistener = static_cast(new SystemViewOnDragListener()); if (draglistener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!");