提交提醒视图最后一个:喝水提醒
author罗正yun <1732036298@qq.com>
Wed, 20 Dec 2023 07:06:43 +0000 (15:06 +0800)
committer罗正yun <1732036298@qq.com>
Wed, 20 Dec 2023 07:06:43 +0000 (15:06 +0800)
Resource/res/remind/REMIND_DRINK_WATER.bin [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/CMakeLists.txt
code/sdk/application/wearable/nativeapp/nativeui/remind/include/MainRemindPresenter.h
code/sdk/application/wearable/nativeapp/nativeui/remind/include/MainRemindView.h
code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView5.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/remind/src/MainRemindPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/remind/src/MainRemindView.cpp
code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView5.cpp [new file with mode: 0644]

diff --git a/Resource/res/remind/REMIND_DRINK_WATER.bin b/Resource/res/remind/REMIND_DRINK_WATER.bin
new file mode 100644 (file)
index 0000000..5efe981
Binary files /dev/null and b/Resource/res/remind/REMIND_DRINK_WATER.bin differ
index efe8fb6..f9f5ce6 100755 (executable)
@@ -368,7 +368,8 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/RemindView2.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/RemindView3.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/RemindView4.cpp\r
-\r
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/RemindView5.cpp\r
+    \r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessView.cpp\r
index 70c668d..a924d58 100644 (file)
@@ -13,6 +13,8 @@ namespace OHOS
     static const char *REMINDVIEW3_UNBIND_VIEWID = "REMINDVIEW3_UNBIND_VIEWID";                                   // 提醒视图3的解绑按钮
     static const char *REMINDVIEW4_UNBIND_OPT_CONTINUE_YES_VIEWID = "REMINDVIEW4_UNBIND_OPT_CONTINUE_YES_VIEWID"; // 提醒视图4的继续解绑按钮
     static const char *REMINDVIEW4_UNBIND_OPT_CONTINUE_NO_VIEWID = "REMINDVIEW4_UNBIND_OPT_CONTINUE_NO_VIEWID";   // 提醒视图4的不继续解绑按钮
+    static const char *REMINDVIEW5_RETURN_VIEWID = "REMINDVIEW5_RETURN_VIEWID";                                   // 提醒视图5的返回按钮视图id
+
     class MainRemindView;
     class MainRemindPresenter : public Presenter<MainRemindView>,
                                 public UIView::OnClickListener,
index 39df123..24b13e8 100644 (file)
@@ -9,6 +9,7 @@
 #include "remind/include/RemindView2.h"
 #include "remind/include/RemindView3.h"
 #include "remind/include/RemindView4.h"
+#include "remind/include/RemindView5.h"
 namespace OHOS
 {
     class MainRemindPresenter;
@@ -27,6 +28,7 @@ namespace OHOS
         bool ChangeRemindView2(int16_t thisView);
         bool ChangeRemindView3(int16_t thisView);
         bool ChangeRemindView4(int16_t thisView);
+        bool ChangeRemindView5(int16_t thisView);
         bool ClickFunc(int16_t interface);
         void ChangeView(int16_t hideView, int16_t showView);
 
@@ -41,6 +43,7 @@ namespace OHOS
         RemindView2 *p_RemindView2{nullptr}; // 提醒视图2
         RemindView3 *p_RemindView3{nullptr}; // 提醒视图3
         RemindView4 *p_RemindView4{nullptr}; // 提醒视图4
+        RemindView5 *p_RemindView5{nullptr}; // 提醒视图4
         UIViewGroup *container_{nullptr};
         UIScrollView *scrollView[6]{nullptr};
         bool viewInitStatus{false};
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView5.h b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView5.h
new file mode 100644 (file)
index 0000000..598063f
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef REMIND_5_VIEW_H
+#define REMIND_5_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+
+namespace OHOS
+{
+    class RemindView5
+    {
+
+    public:
+        RemindView5();
+        virtual ~RemindView5();
+        static RemindView5 *GetInstance(void);
+
+        UIScrollView *InitRemindView5(void);
+        void DeInitRemindView5(void);
+
+    private:
+        UIScrollView *scrollView1_ = nullptr;
+        UILabel *label11_ = nullptr;
+        UIImageView *image1_ = nullptr;
+        UILabel *label2_ = nullptr;
+        UIButton *button3_ = nullptr;
+        bool viewInitStatus{false};
+    };
+} // namespace OHOS
+#endif
\ No newline at end of file
index b9bf7c6..6f21d89 100644 (file)
@@ -96,7 +96,7 @@ namespace OHOS
         else if (strcmp(view.GetViewId(), REMINDVIEW3_UNBIND_VIEWID) == 0)
         {
             m_UnBindImageAnimator->Stop();
-            MainRemindView::GetInstance()->ChangeView(3,4);
+            MainRemindView::GetInstance()->ChangeView(3, 4);
         }
         else if (strcmp(view.GetViewId(), REMINDVIEW4_UNBIND_OPT_CONTINUE_YES_VIEWID) == 0)
         {
@@ -105,7 +105,12 @@ namespace OHOS
         else if (strcmp(view.GetViewId(), REMINDVIEW4_UNBIND_OPT_CONTINUE_NO_VIEWID) == 0)
         {
             m_UnBindImageAnimator->Start();
-            MainRemindView::GetInstance()->ChangeView(4,3);
+            MainRemindView::GetInstance()->ChangeView(4, 3);
+        }
+        else if (strcmp(view.GetViewId(), REMINDVIEW5_RETURN_VIEWID) == 0)
+        {
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            NativeAbility::GetInstance().ChangeSlice(preSlice);
         }
         return true;
     }
index 7d0554c..04f848d 100644 (file)
@@ -106,6 +106,24 @@ namespace OHOS
         return true;
     }
 
+    bool MainRemindView::ChangeRemindView5(int16_t thisView)
+    {
+        if (scrollView[thisView] == nullptr)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainRemindView::RemindView5");
+            p_RemindView5 = new RemindView5();
+            if (p_RemindView5 == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainRemindView:: new scrollView[%d] fail", thisView);
+                return false;
+            }
+            scrollView[thisView] = p_RemindView5->InitRemindView5();
+            container_->Add(scrollView[thisView]);
+        }
+        return true;
+    }
+
+
     /* -------------------------------------------------------------------------- */
     // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。
     struct MainRemindViewMapper
@@ -121,6 +139,7 @@ namespace OHOS
         {2, &MainRemindView::ChangeRemindView2},
         {3, &MainRemindView::ChangeRemindView3},
         {4, &MainRemindView::ChangeRemindView4},
+        {5, &MainRemindView::ChangeRemindView5},
     };
 
     // 3.根据传入的interface参数执行相应视图ID关联的成员函数。
@@ -203,7 +222,7 @@ namespace OHOS
         {
             InitView();
             viewInitStatus = true;
-            ChangeView(0, 3);
+            ChangeView(0, 5);
         }
     }
     void MainRemindView::OnStart()
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView5.cpp b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView5.cpp
new file mode 100644 (file)
index 0000000..394198e
--- /dev/null
@@ -0,0 +1,144 @@
+#include "remind/include/RemindView5.h"
+#include "remind/include/MainRemindPresenter.h"
+
+namespace OHOS
+{
+
+    static RemindView5 *g_pRemindView2{nullptr};
+    RemindView5::RemindView5()
+    {
+        g_pRemindView2 = this;
+    }
+
+    RemindView5::~RemindView5()
+    {
+        if (viewInitStatus == true)
+        {
+            DeInitRemindView5();
+        }
+        g_pRemindView2 = nullptr;
+    }
+
+    RemindView5 *RemindView5::GetInstance()
+    {
+        return g_pRemindView2;
+    }
+
+    // 提醒视图5:提醒用户该喝水了
+    UIScrollView *RemindView5::InitRemindView5()
+    {
+        // Add ScrollView to App
+        if (scrollView1_ == nullptr)
+        {
+            scrollView1_ = new UIScrollView();
+        }
+        scrollView1_->SetPosition(0, 0);        
+        scrollView1_->Resize(466, 466);        
+        scrollView1_->SetViewId("scrollView1"); 
+        scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+        scrollView1_->SetScrollBlankSize(20);
+        scrollView1_->SetReboundSize(50);
+        scrollView1_->SetDirection(1);
+        scrollView1_->SetVisible(true);
+        /* -------------------------------------------------------------------------- */
+        // Add Label to App
+        if (label11_ == nullptr)
+        {
+            label11_ = new UILabel();
+        }
+        label11_->SetPosition(173, 52); 
+        label11_->Resize(120, 35);     
+        label11_->SetViewId("label11"); 
+        label11_->SetStyle(STYLE_TEXT_FONT, 30);
+        label11_->SetStyle(STYLE_LINE_HEIGHT, 35);
+        label11_->SetText("喝水提醒");
+        label11_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+        label11_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        label11_->SetRollSpeed(0);
+        label11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+        scrollView1_->Add(label11_);
+        label11_->SetVisible(true);
+        /* -------------------------------------------------------------------------- */
+        // Add ImageView to App
+        if (image1_ == nullptr)
+        {
+            image1_ = new UIImageView();
+        }
+        image1_->SetPosition(193, 121); 
+        image1_->Resize(80, 80);       
+        char *imageimagesPath = "/user/res/remind/REMIND_DRINK_WATER.bin";
+        image1_->SetSrc(imageimagesPath);
+        scrollView1_->Add(image1_);
+        image1_->SetVisible(true);
+        /* -------------------------------------------------------------------------- */
+        // Add Label to App
+        if (label2_ == nullptr)
+        {
+            label2_ = new UILabel();
+        }
+        label2_->SetPosition(33, 217); 
+        label2_->Resize(400, 70);     
+        label2_->SetViewId("label2");  
+        label2_->SetStyle(STYLE_TEXT_FONT, 31);
+        label2_->SetStyle(STYLE_LINE_HEIGHT, 40);
+        label2_->SetText("该喝水啦!记得按时保持水分充足(๑•̀ㅂ•́)و✧");
+        label2_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+        label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        label2_->SetRollSpeed(0);
+        label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 31);
+        scrollView1_->Add(label2_);
+        label2_->SetVisible(true);
+        /* -------------------------------------------------------------------------- */
+        if (button3_ == nullptr)
+        {
+            button3_ = new UIButton();
+        }
+        button3_->SetPosition(0, 366);  
+        button3_->Resize(466, 100);    
+        button3_->SetViewId(REMINDVIEW5_RETURN_VIEWID); 
+        button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+        button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+        char *buttondefaultImgSrc = "/user/res/countdown/COUNTDOWN_BUTTON.bin";
+        button3_->SetImageSrc(buttondefaultImgSrc, nullptr);
+        button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED);
+        button3_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+        button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+        // Add the CallBack about events
+        UIView::OnClickListener *buttonClick = static_cast<UIView::OnClickListener *>(MainRemindPresenter::GetInstance());
+        button3_->SetOnClickListener(buttonClick);
+        scrollView1_->Add(button3_);
+        button3_->SetVisible(true);
+        viewInitStatus = true;
+        return scrollView1_;
+    }
+
+    void RemindView5::DeInitRemindView5()
+    {
+        if (scrollView1_ != nullptr)
+        {
+            delete scrollView1_;
+            scrollView1_ = nullptr;
+        }
+        if (label11_ != nullptr)
+        {
+            delete label11_;
+            label11_ = nullptr;
+        }
+        if (image1_ != nullptr)
+        {
+            delete image1_;
+            image1_ = nullptr;
+        }
+        if (label2_ != nullptr)
+        {
+            delete label2_;
+            label2_ = nullptr;
+        }
+        if (button3_ != nullptr)
+        {
+            delete button3_;
+            button3_ = nullptr;
+        }
+    }
+
+}
\ No newline at end of file