From: Caisking <3449750381@qq.com> Date: Thu, 25 Jan 2024 03:44:46 +0000 (+0800) Subject: 主界面上滑界面(目前是循环列表) X-Git-Tag: release_V1.2.70_20241020_135402~1330^2 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=6dcc797b0d45e34074943ee37e921c698d6c7e90;p=mirrors%2FFD230.git 主界面上滑界面(目前是循环列表) --- diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp index 6e9f13931..b4d46fb23 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -261,10 +261,25 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageView new fail"); return; } + if (MessageLable == nullptr) + { + MessageLable = new UILabel(); + } + MessageLable->SetPosition(173, 52, 120, 35); + MessageLable->Resize(120, 35); + MessageLable->SetStyle(STYLE_TEXT_FONT, 30); + MessageLable->SetStyle(STYLE_LINE_HEIGHT, 36); + MessageLable->SetText("信息通知"); + MessageLable->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + MessageLable->SetStyle(STYLE_TEXT_COLOR, Color::White().full); + MessageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + messageView->Add(MessageLable); + /* -------------------------------------------------------------------------- */ messageView->PreLoad(); messageView->SetViewId("messageView"); messageView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + messageView->SetDraggable(false); #endif /* -------------------------------------------------------------------------- */ #if 0 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp index 4acd4b125..3e2778e79 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp @@ -2,7 +2,7 @@ * @Author: Caisking 3449750381@qq.com * @Date: 2024-01-23 16:03:34 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-24 11:43:05 + * @LastEditTime: 2024-01-24 17:56:27 * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp * @Description: * @ @@ -45,7 +45,7 @@ namespace OHOS /// @return 返回该视图对象 UIView *MessageListAdapter::GetView(UIView *inView, int16_t index) { - DEBUG_PRINT("GetView::"); + //1.先检查列表数据是否为空,若为空则返回空指针 if (listData.empty()) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp index f642891c5..9b8bf45e7 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp @@ -16,7 +16,7 @@ namespace OHOS MessageCardView::MessageCardView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MessageCardView::MessageCardView()"); - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + SetPosition(43, 120, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); } MessageCardView::~MessageCardView() @@ -42,19 +42,16 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " ::InitView()"); messageview = new MessageView(); - DEBUG_PRINT("MessageCardView::"); if (messageview == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageView::new mainweatherView fail!"); return false; } - DEBUG_PRINT("MessageCardView::"); if (messageview->InitPage() == false) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageView->InitPage() == false!"); return false; } - DEBUG_PRINT("MessageCardView::"); if (messageview->SetupViewPage(messageview) == false) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageView->SetupViewPage() == false!"); @@ -66,7 +63,6 @@ namespace OHOS void MessageCardView::PreLoad(void) { - DEBUG_PRINT("PreLoad"); if (!viewiInitStatus) { InitView(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp index 383a2fedb..cdc1f6ecd 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp @@ -21,7 +21,7 @@ namespace OHOS MessageView::MessageView() { - UIViewGroup::SetPosition(0, 0, 466, 466); + UIViewGroup::SetPosition(43, 120, 466, 466); g_pMessageView = this; } @@ -146,6 +146,7 @@ namespace OHOS // 初始化页面 bool MessageView::InitPage() { +#if 0 if (scrollView == nullptr) { scrollView = new UIScrollView(); @@ -155,24 +156,13 @@ namespace OHOS scrollView->SetScrollBlankSize(20); scrollView->SetReboundSize(50); scrollView->SetTouchable(true); - scrollView->SetDraggable(true); + scrollView->SetDraggable(false); draglistener = static_cast(MessagePresenter::GetInstance()); scrollView->SetOnDragListener(draglistener); + //Add(scrollView); /* -------------------------------------------------------------------------- */ - if (title == nullptr) - { - title = new UILabel(); - } - title->SetPosition(173, 52, 120, 35); - title->Resize(120, 35); - title->SetStyle(STYLE_TEXT_FONT, 30); - title->SetStyle(STYLE_LINE_HEIGHT, 36); - title->SetText("信息通知"); - title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - title->SetStyle(STYLE_TEXT_COLOR, Color::White().full); - title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - scrollView->Add(title); /* -------------------------------------------------------------------------- */ +#endif // UIList 的适配器 p_MessageListAdapter = new MessageListAdapter(); p_MessageListAdapter->SetItemClickListener(presenter_); @@ -180,13 +170,12 @@ namespace OHOS { MessageList = new UIList(); } - MessageList->SetPosition(43, 120, 380, 600); + MessageList->SetPosition(0, 0, 380, 600); MessageList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - scrollView->Add(MessageList); + Add(MessageList); MessageList->SetAdapter(p_MessageListAdapter); + MessageList->SetLoopState(true); MessageList->SetVisible(true); - Add(scrollView); - scrollView->SetVisible(true); return true; } @@ -199,7 +188,7 @@ namespace OHOS for (int i = 0; i < g_MessageModel->GetMessageListNum(); i++) { messageView->AddMessageToList(itemInfo[i]); - printf("Index: %d, Icon: %s, Label: %s, Label Button: , Has Second Menu: \n", itemInfo[i].index, itemInfo[i].icon, itemInfo[i].label); + // printf("Index: %d, Icon: %s, Label: %s, Label Button: , Has Second Menu: \n", itemInfo[i].index, itemInfo[i].icon, itemInfo[i].label); } return true; } diff --git a/code/sdk/application/wearable/ohos_deps/wearable_log.h b/code/sdk/application/wearable/ohos_deps/wearable_log.h index b56f669d5..80de22b98 100755 --- a/code/sdk/application/wearable/ohos_deps/wearable_log.h +++ b/code/sdk/application/wearable/ohos_deps/wearable_log.h @@ -2,7 +2,7 @@ * @Author: Caisking 3449750381@qq.com * @Date: 2023-12-20 10:32:41 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-24 10:38:48 + * @LastEditTime: 2024-01-24 17:54:52 * @FilePath: /FD230/code/sdk/application/wearable/ohos_deps/wearable_log.h * @Description: * @ @@ -82,7 +82,7 @@ typedef enum { #if DEBUG #define DEBUG_PRINT(msg) printf("File: %s, Line: %d - %s\n", __FILE__, __LINE__, msg) #else -#define PRINT_DEBUG(msg) // 空语句,即关闭打印 +#define PRINT_DEBUG() // 空语句,即关闭打印 #endif /* -------------------------------------------------------------------------- */ } diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp index 2920622e1..9f322478e 100755 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp @@ -69,12 +69,13 @@ bool UIScrollView::OnDragEndEvent(const DragEvent& event) void UIScrollView::Drag(const DragEvent& event) { int16_t xDistance = event.GetDeltaX(); + int16_t yDistance = event.GetDeltaY(); if ((direction_ == HORIZONTAL || direction_ == HORIZONTAL_AND_VERTICAL) && xDistance != 0) { DragXInner(xDistance); } - if ((direction_ == VERTICAL || direction_ == HORIZONTAL_AND_VERTICAL) && yDistance != 0) { + if ((direction_ == VERTICAL || direction_ == HORIZONTAL_AND_VERTICAL) && yDistance < 120) { RefreshDelta(yDistance); DragYInner(yDistance); }