主界面上滑界面(目前是循环列表)
authorCaisking <3449750381@qq.com>
Thu, 25 Jan 2024 03:44:46 +0000 (11:44 +0800)
committerCaisking <3449750381@qq.com>
Thu, 25 Jan 2024 03:44:46 +0000 (11:44 +0800)
code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageAdapter.cpp
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageCardView.cpp
code/sdk/application/wearable/nativeapp/nativeui/message/src/MessageView.cpp
code/sdk/application/wearable/ohos_deps/wearable_log.h
code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_scroll_view.cpp

index 6e9f139..b4d46fb 100755 (executable)
@@ -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
index 4acd4b1..3e2778e 100644 (file)
@@ -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())
         {
index f642891..9b8bf45 100644 (file)
@@ -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();
index 383a2fe..cdc1f6e 100644 (file)
@@ -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<UIView::OnDragListener *>(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;
     }
index b56f669..80de22b 100755 (executable)
@@ -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
 /* -------------------------------------------------------------------------- */
 }
index 2920622..9f32247 100755 (executable)
@@ -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);
     }