From: luozheng <1732036298@qq.com> Date: Fri, 7 Jun 2024 09:49:46 +0000 (+0800) Subject: 秒表视图添加退出动画 X-Git-Tag: release_V1.2.70_20241020_135402~1030 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=820a72e5a7d52d83c135357a6a401a5715f2e590;p=mirrors%2FFD230.git 秒表视图添加退出动画 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp index 0de9bc177..95175ac50 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp @@ -12,6 +12,7 @@ #include "traing/include/TraingModel.h" #include "components/ui_hexagons_list.h" #include "TransitionType.h" +#include "AppViewIDs.h" namespace OHOS { ApplistPresenter::ApplistPresenter() @@ -84,7 +85,8 @@ namespace OHOS { AppViewId viewId = itemView->GetViewId(); if (FloatMore(hexagonsView->GetGlobalScale(), 2.0f)) { // 2.0 threshold for beginning transition hexagonsView->StopRotateAnimator(); - NativeAbility::GetInstance().ChangeSlice(viewId, TransitionType::TRANSITION_HEXAGONS); + //NativeAbility::GetInstance().ChangeSlice(viewId, TransitionType::TRANSITION_HEXAGONS); + NativeAbility::GetInstance().EnterSlice(viewId, TransitionType::TRANSITION_HEXAGONS); hexagonsView->ClearFocus(); } return true; @@ -117,7 +119,7 @@ namespace OHOS { hexagonsView->Scale(1.0f, itemView->GetViewIndex()); // switch focus to click view type = TransitionType::TRANSITION_HEXAGONS; } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d", viewId); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d type = %d", viewId,type); if (viewId < VIEW_MAX_INTER_APP) { //NativeAbility::GetInstance().ChangeSlice(viewId, type); NativeAbility::GetInstance().EnterSlice(viewId, type); diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_desktop/include/SetDesktopModel.h b/code/sdk/application/wearable/fd230app/nativeui/set_desktop/include/SetDesktopModel.h index 2ef2793dc..500f1a030 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_desktop/include/SetDesktopModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/set_desktop/include/SetDesktopModel.h @@ -1,8 +1,9 @@ /* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SetDesktopModel.h - * Author: - * Create: 2021-11-23 + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-07 09:21:47 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-07 15:03:40 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/include/SetDesktopModel.h */ #ifndef SET_DESKTOP_MODEL_H @@ -15,8 +16,8 @@ #include "SetDesktopPresenter.h" typedef enum { - APPLIST_STYLE, - HEXAGONS_STYLE, + APPLIST_STYLE, //列表显示 + HEXAGONS_STYLE, //蜂窝显示 } DesktopStyle; namespace OHOS { diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopModel.cpp index 43c523e4f..c84a75079 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopModel.cpp @@ -1,8 +1,9 @@ /* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: SettingModel.cpp - * Author: - * Create: 2021-11-23 + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-07 09:21:47 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-07 11:17:14 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_desktop/src/SetDesktopModel.cpp */ #include "SetDesktopModel.h" @@ -21,6 +22,7 @@ namespace OHOS { return instance; } + //获取applist的显示样式 DesktopStyle SetDesktopModel::GetDesktopStyle(void) { DesktopStyle style; diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h index 253b6a2c7..f866b60ae 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-04 15:13:51 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-07 17:22:21 + * @LastEditTime: 2024-06-07 17:07:38 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h */ #ifndef MAIN_STOPWATCH_PRESENTER_H @@ -50,6 +50,7 @@ namespace OHOS // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnChange(UICheckBox::UICheckBoxState state) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 private: @@ -63,6 +64,7 @@ namespace OHOS List *m_listdata = nullptr; uint64_t lastRecordTime = 0; // 上次记录时间 int RecordCycleNumber{0}; // 用来记录计时圈数 + bool X_DRAG_FLAG{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp index 8b4c1c6e3..1c58e32b9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp @@ -1,5 +1,6 @@ #include "AppViewIDs.h" #include "NativeAbility.h" +#include "UiConfig.h" #include "stopwatch/include/MainStopWatchPresenter.h" #include "stopwatch/include/StopWatchModel.h" #include "common/key_code.h" @@ -100,11 +101,23 @@ namespace OHOS bool MainStopWatchPresenter::OnDrag(UIView &view, const DragEvent &event) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainStopWatchPresenter::OnDrag"); UNUSED(view); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && - (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + MainStopWatchPresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool MainStopWatchPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainStopWatchPresenter::OnDragEnd"); + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && MainStopWatchPresenter::X_DRAG_FLAG) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + X_DRAG_FLAG = false; } return true; } @@ -274,10 +287,9 @@ namespace OHOS // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); } - return true; + return false; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp index b2d8ba4b6..165ae0266 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp @@ -390,6 +390,7 @@ namespace OHOS scrollView[MAIN_STOPWATCH]->Add(ResetOrMarkbutton); group->Add(scrollView[MAIN_STOPWATCH]); RootView::GetInstance()->Add(group); + container_ = group; Draw(); }