From: Caisking <3449750381@qq.com> Date: Mon, 15 Jan 2024 11:43:50 +0000 (+0800) Subject: 主界面增加心率卡片 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=229c8f66194cf2b2d138da778e5f68fbeef4514f;p=mirrors%2FFD230.git 主界面增加心率卡片 --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 4f1e9c341..dc557da50 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -231,7 +231,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/getpic/src/TakePicView.cpp #Ѫ�� ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodShowView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodShowPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/blood/src/BloodCheckView.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index 9953661ae..2dc381c3b 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -48,7 +48,7 @@ typedef enum : uint16_t VIEW_GETPIC, // 手势拍照 VIEW_TAKEPIC, // 拍照 - VIEW_BLOOD, // 血氧 + //VIEW_BLOOD, // 血氧 VIEW_BLOODSHOW, // 血氧说明 VIEW_BLOODCHECK, // 血氧检查 VIEW_BLOODERROR, // 血氧监测错误 diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index 3afa01ac5..d91b014d4 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -89,7 +89,7 @@ #include "phone/include/PhoneRingView.h" #include "phone/include/PhoneRingPresenter.h" #include "blood/include/BloodView.h" -#include "blood/include/BloodPresenter.h" + #include "blood/include/BloodCheckPresenter.h" #include "blood/include/BloodCheckView.h" #include "blood/include/BloodShowPresenter.h" @@ -285,7 +285,7 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_PHONECALLING, &NativeLauncher::InitPhoneCallingSlice}, {VIEW_PHONECALLUP, &NativeLauncher::InitPhoneCallupSlice}, {VIEW_PHONERING, &NativeLauncher::InitPhoneRingSlice}, - {VIEW_BLOOD, &NativeLauncher::InitBloodSlice}, //血氧 + //{VIEW_BLOOD, &NativeLauncher::InitBloodSlice}, //血氧 {VIEW_BLOODSHOW, &NativeLauncher::InitBloodShowSlice}, {VIEW_BLOODCHECK, &NativeLauncher::InitBloodCheckSlice}, {VIEW_BLOODERROR, &NativeLauncher::InitBloodErrorSlice}, @@ -820,17 +820,17 @@ void NativeLauncher::InitPhoneRingSlice(void) NativeAbility::GetInstance().AddSliceProxy(VIEW_PHONERING, phoneringview); } -void NativeLauncher::InitBloodSlice(void) //血氧 -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice"); - SliceProxy *bloodview = new AbilitySliceProxy; - if (bloodview == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodview"); - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOOD, bloodview); -} +// void NativeLauncher::InitBloodSlice(void) //血氧 +// { +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice"); +// SliceProxy *bloodview = new AbilitySliceProxy; +// if (bloodview == nullptr) +// { +// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodview"); +// return; +// } +// NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOOD, bloodview); +// } void NativeLauncher::InitBloodShowSlice(void) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp index 74cf39440..ea03f2a80 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp @@ -40,7 +40,7 @@ namespace OHOS {VIEW_OFFLINEVOICE, PNG_APPLIST_VOCASSIST_IMAGE, PNG_APPLIST_VOCASSIST_IMAGE, "语音助手", nullptr}, {VIEW_BLOODPRESSURE, PNG_APPLIST_BLOODPRESSURE_IMAGE, PNG_APPLIST_BLOODPRESSURE_IMAGE, "睡眠监测", nullptr}, {VIEW_MAIN_TEMP, PNG_APPLIST_TEMP_IMAGE, PNG_APPLIST_TEMP_IMAGE, "体温检测", nullptr}, - {VIEW_BLOOD, PNG_APPLIST_BLOOD_IMAGE, PNG_APPLIST_BLOOD_IMAGE, "血氧监测", nullptr}, + //{VIEW_BLOOD, PNG_APPLIST_BLOOD_IMAGE, PNG_APPLIST_BLOOD_IMAGE, "血氧监测", nullptr}, {VIEW_HEARTRATEREMIND, PNG_APPLIST_HEARTRATE_IMAGE, PNG_APPLIST_HEARTRATE_IMAGE, "心率检测", nullptr}, {VIEW_UISAMPLE, PNG_APPLIST_UI_SAMPLE_IMAGE, PNG_APPLIST_UI_SAMPLE_IMAGE, "示例", nullptr}, }; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodPresenter.h deleted file mode 100755 index 9a0911bda..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodPresenter.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _Blood_PRESENTER_H -#define _Blood_PRESENTER_H - -#include "Presenter.h" -#include "BloodView.h" - -namespace OHOS -{ - class BloodView; - - class BloodPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - BloodPresenter(); - virtual ~BloodPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static BloodPresenter *GetInstance(); - - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - }; -} // namespace OHOS - -#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h index 12f88cd3e..3a40c122a 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h @@ -1,3 +1,13 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-15 17:21:42 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/blood/include/BloodView.h + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ #ifndef _Blood_VIEW_H #define _Blood_VIEW_H @@ -10,16 +20,17 @@ #include "components/ui_button.h" #include "components/ui_image_animator.h" #include "components/ui_label_button_ext.h" +#include "components/ui_card_page.h" + + -#include "BloodPresenter.h" namespace OHOS { #define WARNING "button1" #define CHECK "button2" - class BloodPresenter; - class BloodView : public View + class BloodView : public UICardPage { public: @@ -27,27 +38,28 @@ namespace OHOS virtual ~BloodView(); static BloodView *GetInstance(void); - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - void Init(); + bool InitView(); void DeInit(); - UIView *GetView(); + bool AddButton(); + bool InitLable(); + bool Initbackground(); + + void PreLoad(void) override; + void UnLoad(void) override; private: UIView::OnDragListener *draglistener{nullptr}; BloodView(BloodView &&) = delete; BloodView &operator=(BloodView &&) = delete; - UIViewGroup *container_ = nullptr; - UIImageView *image1_ = nullptr; - UIButton *button1_ = nullptr; - UILabelButtonExt *labelButton1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label3_ = nullptr; + UIImageView *background = nullptr; + UIButton *warnButton = nullptr; + UILabelButtonExt *monitorButton = nullptr; + UILabel *titleLabel = nullptr; + UILabel *bloodLabel = nullptr; + UILabel *timeLabel = nullptr; + bool viewiInitStatus{false}; }; } // namespace OHOS #endif // Blood_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorPresenter.cpp index a9cb09e46..1fe207822 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodErrorPresenter.cpp @@ -72,7 +72,7 @@ namespace OHOS } if (strcmp(view.GetViewId(), LABELBUTTONSTOP) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); + //NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); } return true; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNotePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNotePresenter.cpp index d93ea9fcb..1c6af0687 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNotePresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNotePresenter.cpp @@ -1,3 +1,13 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-15 17:48:26 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodNotePresenter.cpp + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ #include "AppViewIDs.h" #include "NativeAbility.h" @@ -68,7 +78,7 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), NOTEBUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); + //NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); } return true; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodPresenter.cpp deleted file mode 100755 index 3f67e44d1..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodPresenter.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" - -#include "blood/include/BloodPresenter.h" - -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static BloodPresenter *g_pBloodPresenter = nullptr; - - BloodPresenter::BloodPresenter() - { - - g_pBloodPresenter = this; - } - - BloodPresenter::~BloodPresenter() - { - - g_pBloodPresenter = nullptr; - } - - BloodPresenter *BloodPresenter::GetInstance() - { - - return g_pBloodPresenter; - } - - void BloodPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void BloodPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void BloodPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void BloodPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool BloodPresenter::OnDrag(UIView &view, const DragEvent &event) - { - - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) - { - printf("draglistene is ok!\n"); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - UNUSED(view); - return true; - } - - bool BloodPresenter::OnClick(UIView &view, const ClickEvent &event) - { - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), WARNING) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODSHOW); - } - if (strcmp(view.GetViewId(), CHECK) == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODCHECK); - } - return true; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowPresenter.cpp index 0c3c7663c..f3544c44f 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowPresenter.cpp @@ -1,3 +1,13 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-15 17:48:43 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodShowPresenter.cpp + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ #include "AppViewIDs.h" #include "NativeAbility.h" @@ -57,7 +67,7 @@ namespace OHOS if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) { printf("draglistene is ok!\n"); - NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); + //NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD); } UNUSED(view); return true; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp index a08a934d2..55a47120e 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp @@ -1,4 +1,13 @@ - +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-15 17:31:26 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/blood/src/BloodView.cpp + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ #include "blood/include/BloodView.h" @@ -7,13 +16,16 @@ #include "ui_resource_image.h" #include #include "components/ui_button.h" +#include "MainViewSample.h" +#include "components/ui_view_group.h" + namespace OHOS { static BloodView *g_pBloodView{nullptr}; BloodView::BloodView() { - + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); g_pBloodView = this; } @@ -25,230 +37,218 @@ namespace OHOS BloodView *BloodView::GetInstance() { - return g_pBloodView; } - -void BloodView::Init() -{ - if (container_ == nullptr) { - container_ = new UIViewGroup(); - container_->SetPosition(0, 0, 466, 466); - container_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - // Add ImageView to App - if (image1_ == nullptr) { - image1_ = new UIImageView(); - } - image1_->SetPosition(0, 0); // widget's left position and top position - image1_->Resize(100, 100); // widget's width and height - image1_->SetViewId("image1");// Set style - - // Set additional property -#ifdef _WIN32 - char* image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/BloodOxygen/beijing.bin"; -#else - char* image1imagesPath = "/user/res/Blood/beijing.bin"; -#endif - image1_->SetSrc(image1imagesPath); - - // Add to rootView - container_->Add(image1_); - image1_->SetVisible(true); - - // Add Button to App - if (button1_ == nullptr) { - button1_ = new UIButton(); - } - button1_->SetPosition(300, 57); // widget's left position and top position - button1_->Resize(26, 26); // widget's width and height - button1_->SetViewId(WARNING);// Set style - button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - - // Set additional property -#ifdef _WIN32 - char* button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/BloodOxygen/Vector.bin"; -#else - char* button1defaultImgSrc = "/user/res/Blood/Vector.bin"; -#endif - char * button1triggeredImgSrc = nullptr; - button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); - button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener* button1Click = static_cast(BloodPresenter::GetInstance()); - button1_->SetOnClickListener(button1Click); - // Add to rootView - container_->Add(button1_); - button1_->SetVisible(true); - - // Add LabelButtonExt to App - if (labelButton1_ == nullptr) { - labelButton1_ = new UILabelButtonExt(); - } - labelButton1_->SetPosition(118, 336); // widget's left position and top position - labelButton1_->Resize(230, 80); // widget's width and height - labelButton1_->SetViewId(CHECK);// Set style - labelButton1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffcd492c); - - // Set additional property - labelButton1_->SetText("检测"); - labelButton1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - labelButton1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - // Add the CallBack about events - UIView::OnClickListener* labelButton1Click = static_cast(BloodPresenter::GetInstance()); - labelButton1_->SetOnClickListener(labelButton1Click); - // Add to rootView - container_->Add(labelButton1_); - labelButton1_->SetVisible(true); - - // Add Label to App - if (label2_ == nullptr) { - label2_ = new UILabel(); - } - label2_->SetPosition(157, 105); // widget's left position and top position - label2_->Resize(200, 60); // widget's width and height - label2_->SetViewId("label2");// Set style - label2_->SetStyle(STYLE_TEXT_FONT, 140); - - // Set additional property - label2_->SetText("98"); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 140); - - // Add to rootView - container_->Add(label2_); - label2_->SetVisible(true); - - // Add Label to App - if (label1_ == nullptr) { - label1_ = new UILabel(); - } - label1_->SetPosition(141, 263); // widget's left position and top position - label1_->Resize(185, 35); // widget's width and height - label1_->SetViewId("label1");// Set style - label1_->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property - label1_->SetText("20分钟前检测"); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to rootView - container_->Add(label1_); - label1_->SetVisible(true); - - // Add Label to App - if (label3_ == nullptr) { - label3_ = new UILabel(); - } - label3_->SetPosition(143, 52); // widget's left position and top position - label3_->Resize(200, 60); // widget's width and height - label3_->SetViewId("label3");// Set style - label3_->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property - label3_->SetText("血氧饱和度"); - label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label3_->SetRollSpeed(0); - label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to rootView - container_->Add(label3_); - label3_->SetVisible(true); - -} - -void BloodView::DeInit() -{ - if (container_ != nullptr) { - container_->RemoveAll(); - delete container_ ; - container_ = nullptr; - } - if (image1_ != nullptr) { - delete image1_; - image1_ = nullptr; - } - if (button1_ != nullptr) { - delete button1_; - button1_ = nullptr; - } - if (labelButton1_ != nullptr) { - delete labelButton1_; - labelButton1_ = nullptr; - } - if (label2_ != nullptr) { - delete label2_; - label2_ = nullptr; - } - if (label1_ != nullptr) { - delete label1_; - label1_ = nullptr; - } - if (label3_ != nullptr) { - delete label3_; - label3_ = nullptr; - } -} - -UIView* BloodView::GetView() -{ - Init(); - return container_; -} - void BloodView::OnStart() + /*** + * @description: + * @return 添加按键是否成功 + */ + bool BloodView::AddButton() { - container_ = new UIScrollView(); - if (container_ == nullptr) + // Add Button to App + if (warnButton == nullptr) { - return; + warnButton = new UIButton(); } - container_->SetPosition(0, 0); - container_->SetWidth(Screen::GetInstance().GetWidth()); - container_->SetHeight(Screen::GetInstance().GetHeight()); - - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(BloodPresenter::GetInstance()); - if (draglistener == nullptr) + warnButton->SetPosition(300, 57); // widget's left position and top position + warnButton->Resize(26, 26); // widget's width and height + warnButton->SetViewId(WARNING); // Set style + warnButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + warnButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + + // Set additional property + char *button1defaultImgSrc = "/user/res/Blood/Vector.bin"; + char *button1triggeredImgSrc = nullptr; + warnButton->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + warnButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + // UIView::OnClickListener *button1Click = static_cast(BloodPresenter::GetInstance()); + // warnButton->SetOnClickListener(button1Click); + // Add to rootView + Add(warnButton); + + // Add LabelButtonExt to App + if (monitorButton == nullptr) { - return; + monitorButton = new UILabelButtonExt(); } - container_->SetOnDragListener(draglistener); - - container_->SetTouchable(true); - container_->SetDraggable(true); - - GetView(); - RootView::GetInstance()->Add(container_); - } - - void BloodView::OnSetUpView() + monitorButton->SetPosition(118, 336); // widget's left position and top position + monitorButton->Resize(230, 80); // widget's width and height + monitorButton->SetViewId(CHECK); // Set style + monitorButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffcd492c); + + // Set additional property + monitorButton->SetText("检测"); + monitorButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + monitorButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // UIView::OnClickListener *labelButton1Click = static_cast(BloodPresenter::GetInstance()); + // monitorButton->SetOnClickListener(labelButton1Click); + Add(monitorButton); + return true; + } + /*** + * @description: + * @return 初始化标签是否成功 + */ + bool BloodView::InitLable() + { + // Add Label to App + if (bloodLabel == nullptr) + { + bloodLabel = new UILabel(); + } + bloodLabel->SetPosition(157, 105); // widget's left position and top position + bloodLabel->Resize(200, 60); // widget's width and height + bloodLabel->SetViewId("label2"); // Set style + bloodLabel->SetStyle(STYLE_TEXT_FONT, 140); + + // Set additional property + int bloodoxygen = 98; + bloodLabel->SetText(std::to_string(bloodoxygen).c_str()); + bloodLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + bloodLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + bloodLabel->SetRollSpeed(0); + bloodLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 140); + + // Add to rootView + Add(bloodLabel); + + // Add Label to App + if (timeLabel == nullptr) + { + timeLabel = new UILabel(); + } + timeLabel->SetPosition(141, 263); // widget's left position and top position + timeLabel->Resize(185, 35); // widget's width and height + timeLabel->SetViewId("label1"); // Set style + timeLabel->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + timeLabel->SetText("20分钟前检测"); + timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + timeLabel->SetRollSpeed(0); + timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + Add(timeLabel); + + // Add Label to App + if (titleLabel == nullptr) + { + titleLabel = new UILabel(); + } + titleLabel->SetPosition(143, 52); // widget's left position and top position + titleLabel->Resize(200, 60); // widget's width and height + titleLabel->SetViewId("label3"); // Set style + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + + // Set additional property + titleLabel->SetText("血氧饱和度"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetRollSpeed(0); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to rootView + Add(titleLabel); + return true; + } + /*** + * @description: + * @return 初始化背景是否成功 + */ + bool BloodView::Initbackground() + { + // Add ImageView to App + if (background == nullptr) + { + background = new UIImageView(); + } + background->SetPosition(0, 0); // widget's left position and top position + background->Resize(466, 466); // widget's width and height + background->SetViewId("image1"); // Set style + // Set additional property + char *image1imagesPath = "/user/res/Blood/beijing.bin"; + background->SetSrc(image1imagesPath); + + // Add to rootView + Add(background); + return true; + } + /*** + * @description: + * @return 是否初始化成功 + */ + bool BloodView::InitView() + { + printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); + if (!Initbackground()) + { + printf("Initbackground error!\n"); + }; + if (!InitLable()) + { + printf("InitLable error!\n"); + }; + if (!AddButton()) + { + printf("AddButton error!\n"); + }; + SetCoverable(true); + return true; + } + /*** + * @description: + * @return 删除组件 + */ + void BloodView::DeInit() { - View::OnSetUpView(); - Draw(); + if (background != nullptr) + { + delete background; + background = nullptr; + } + if (warnButton != nullptr) + { + delete warnButton; + warnButton = nullptr; + } + if (monitorButton != nullptr) + { + delete monitorButton; + monitorButton = nullptr; + } + if (bloodLabel != nullptr) + { + delete bloodLabel; + bloodLabel = nullptr; + } + if (timeLabel != nullptr) + { + delete timeLabel; + timeLabel = nullptr; + } + if (titleLabel != nullptr) + { + delete titleLabel; + titleLabel = nullptr; + } } - - void BloodView::OnTearDownView() + void BloodView::PreLoad(void) { - - View::OnTearDownView(); - return; + //printf("Function: %s, Line: %d\n", __PRETTY_FUNCTION__, __LINE__); + if (InitView()) + { + viewiInitStatus = true; + } } - void BloodView::OnStop() + void BloodView::UnLoad(void) { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; } + } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h index 60b65563f..1dab4a37e 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/include/Digital_clockView.h @@ -23,7 +23,6 @@ #include "components/ui_sweep_clock.h" #include #include -#include #include "battery.h" #include "cJSON.h" #include "sys/time.h" diff --git a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp index 7dbc6cd99..6b24e8a5d 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/dial/src/Digital_clockView.cpp @@ -619,7 +619,6 @@ namespace OHOS { std::string Dialtype = cJSON_GetObjectItem(cjson_json, "Dialtype")->valuestring; Initbackground(); - if (Dialtype == "pointer") { Initpointer(); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h index 6e8527a4e..e9753612a 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h @@ -2,7 +2,7 @@ * @Author: Caisking 3449750381@qq.com * @Date: 2023-12-12 16:55:29 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-15 16:40:09 + * @LastEditTime: 2024-01-15 17:19:52 * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h * @Description: * @ @@ -39,6 +39,7 @@ #include "PullUpDownView.h" #include "components/ui_cross_view.h" #include "dial/include/Digital_clockView.h" +#include "blood/include/BloodView.h" namespace OHOS { class MainPresenterSample; class MainViewSample : public View { @@ -56,6 +57,8 @@ public: UICardPage *InitCompassPage(void); UICardPage *InitMusicPlayerPage(void); UICardPage *InitNewDialPage(void); + UICardPage *InitBloodOxygenPage(void); + void AnimatorStart(int pageIndex); void AnimatorStop(void); uint16_t GetHorCurrentPage() const @@ -79,12 +82,17 @@ private: PullUpDownView *dropDownView{nullptr}; UICardPage *messageView{nullptr}; UILabel *messageLable{nullptr}; + + /* -------------------------------------------------------------------------- */ Digital_clockView *mainClockView{nullptr}; ActivityWeekView *activityWeekView{nullptr}; PlayersView *playersView{nullptr}; + /* -------------------------------------------------------------------------- */ + CompassControlView *compassControlView{nullptr}; HeartRateView *heartRateView{nullptr}; Digital_clockView*dialView{nullptr}; + BloodView*bloodView{nullptr}; UICardPage *recordCard[MAX_CARD]{nullptr}; bool pageStatus[MAX_CARD]{false}; UICrossView *mainSwipeGroup{nullptr}; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp index dca3e92bc..70c61adae 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainSwipeViewGroup.cpp @@ -112,10 +112,11 @@ bool MainSwipeViewGroup::OnDragEvent(const DragEvent& event) swipeDirect = VERTICAL_SWIPE; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "vertical->OnDragEvent2, direct:%d index: %d", swipeDirect, vertical->GetCurrentPage()); vertical->OnDragEvent(event); - } else if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) && - (event.GetStartPoint().y > 300) && (horizontal->GetCurrentPage() == MUSIC_PLAYER)) { - PlayersPresenter::GetInstance()->ShowPlayerListGroup(); } + // } else if ((event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) && + // (event.GetStartPoint().y > 300) && (horizontal->GetCurrentPage() == MUSIC_PLAYER)) { + // PlayersPresenter::GetInstance()->ShowPlayerListGroup(); + // } } } else if (swipeDirect == HORIZONTAL_SWIPE) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "horizontal->OnDragEvent2, direct:%d index: %d", swipeDirect, horizontal->GetCurrentPage()); 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 212d5b3d9..e5b1fae9a 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -1,3 +1,13 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2023-12-12 16:55:29 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-01-15 18:54:40 + * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp + * @Description: + * @ + * @Copyright (c) 2024 by Caisking , All Rights Reserved. + */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: MainViewSample @@ -8,381 +18,414 @@ #include "MainViewSample.h" #include "graphic_service.h" -namespace OHOS { - -static MainViewSample *g_pMainView = nullptr; -static constexpr uint16_t MESLABLE_X_TMP = 177; -static constexpr uint16_t MESLABLE_Y_TMP = 212; -static constexpr uint16_t MESLABLE_WIDTH_TMP = 100; -static constexpr uint16_t MESLABLE_HEIGHT_TMP = 30; -static constexpr uint8_t FONT_SIZE_TMP = 24; -static constexpr uint8_t PULL_MIDDLE_VIEW_OPA = 0; - -struct MainViewMapper { - CardId id; - UICardPage *(MainViewSample::*func)(void); -}; - -static const MainViewMapper PageMapper[] = { - {HEART_RATE, &MainViewSample::InitHeartRatePage}, - {COMPASS, &MainViewSample::InitCompassPage}, - {ACTIVITY, &MainViewSample::InitActivityPage}, - {MUSIC_PLAYER, &MainViewSample::InitMusicPlayerPage}, - {NEW_DAIL,&MainViewSample::InitNewDialPage}, -}; - -MainViewSample::MainViewSample() +namespace OHOS { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::MainViewSample"); - g_pMainView = this; -} -MainViewSample::~MainViewSample() -{ - dropDownView->ClearBackgroundBlur(); - messageView->ClearBackgroundBlur(); - - for (int32_t i = 0; i < maxPage; i++) { - recordCard[i] = nullptr; - pageStatus[i] = false; + static MainViewSample *g_pMainView = nullptr; + static constexpr uint16_t MESLABLE_X_TMP = 177; + static constexpr uint16_t MESLABLE_Y_TMP = 212; + static constexpr uint16_t MESLABLE_WIDTH_TMP = 100; + static constexpr uint16_t MESLABLE_HEIGHT_TMP = 30; + static constexpr uint8_t FONT_SIZE_TMP = 24; + static constexpr uint8_t PULL_MIDDLE_VIEW_OPA = 0; + + struct MainViewMapper + { + CardId id; + UICardPage *(MainViewSample::*func)(void); + }; + + static const MainViewMapper PageMapper[] = { + {NEW_DAIL, &MainViewSample::InitNewDialPage}, + {HEART_RATE, &MainViewSample::InitHeartRatePage}, + {COMPASS, &MainViewSample::InitCompassPage}, + {BloodOxygen, &MainViewSample::InitBloodOxygenPage}, + }; + + MainViewSample::MainViewSample() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::MainViewSample"); + g_pMainView = this; } - if (mainSwipeGroup != nullptr) { - delete mainSwipeGroup; - mainSwipeGroup = nullptr; - } - - if (mainClockView != nullptr) { - delete mainClockView; - mainClockView = nullptr; - } - - if (activityWeekView != nullptr) { - delete activityWeekView; - activityWeekView = nullptr; - } + MainViewSample::~MainViewSample() + { + dropDownView->ClearBackgroundBlur(); + messageView->ClearBackgroundBlur(); - if (playersView != nullptr) { - delete playersView; - playersView = nullptr; - } - - if (heartRateView != nullptr) { - delete heartRateView; - heartRateView = nullptr; - } + for (int32_t i = 0; i < maxPage; i++) + { + recordCard[i] = nullptr; + pageStatus[i] = false; + } - if (dropDownView != nullptr) { - delete dropDownView; - dropDownView = nullptr; - } + if (mainSwipeGroup != nullptr) + { + delete mainSwipeGroup; + mainSwipeGroup = nullptr; + } - if (messageView != nullptr) { - messageView->RemoveAll(); - delete messageView; - messageView = nullptr; - } + if (mainClockView != nullptr) + { + delete mainClockView; + mainClockView = nullptr; + } - if (messageLable != nullptr) { - delete messageLable; - messageLable = nullptr; - } + if (activityWeekView != nullptr) + { + delete activityWeekView; + activityWeekView = nullptr; + } - if (compassControlView != nullptr) { - delete compassControlView; - compassControlView = nullptr; - } + if (playersView != nullptr) + { + delete playersView; + playersView = nullptr; + } - if (dialView != nullptr) { - delete dialView; - dialView = nullptr; - } + if (heartRateView != nullptr) + { + delete heartRateView; + heartRateView = nullptr; + } - g_pMainView = nullptr; -} + if (dropDownView != nullptr) + { + delete dropDownView; + dropDownView = nullptr; + } + if (messageView != nullptr) + { + messageView->RemoveAll(); + delete messageView; + messageView = nullptr; + } + if (messageLable != nullptr) + { + delete messageLable; + messageLable = nullptr; + } -MainViewSample *MainViewSample::GetInstance(void) -{ - return g_pMainView; -} + if (compassControlView != nullptr) + { + delete compassControlView; + compassControlView = nullptr; + } -void MainViewSample::OnStart() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnStart"); - View::OnStart(); - BaseView::RootView(Color::Black().full); + if (dialView != nullptr) + { + delete dialView; + dialView = nullptr; + } + if (bloodView != nullptr) + { + delete bloodView; + bloodView = nullptr; + } + g_pMainView = nullptr; + } - mainSwipeGroup = new UICrossView(); - if (mainSwipeGroup == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSwipeGroup new fail"); - return; + MainViewSample *MainViewSample::GetInstance(void) + { + return g_pMainView; } - if (callback == nullptr) { - callback = new ZoomEffect(); - if (callback == nullptr) { - delete mainSwipeGroup; - mainSwipeGroup = nullptr; - GRAPHIC_LOGE("SwipeCallback new fail\n"); + void MainViewSample::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnStart"); + View::OnStart(); + BaseView::RootView(Color::Black().full); + + mainSwipeGroup = new UICrossView(); + if (mainSwipeGroup == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSwipeGroup new fail"); return; } - } - HorizontalViewInit(); - HorViewLoad(); - VerticalViewInit(); - VertViewLoad(); - mainSwipeGroup->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - mainSwipeGroup->SetAnimatorTime(50); // 50: animator drag time(ms); - mainSwipeGroup->SetLoopState(true); - mainSwipeGroup->EnableScreenCap(true); - mainSwipeGroup->RegisterSwipeCallback(callback); - mainSwipeGroup->SetHorCurrentPage(dialView->GetViewIndex()); - SetContainerView(mainSwipeGroup); -} + if (callback == nullptr) + { + callback = new ZoomEffect(); + if (callback == nullptr) + { + delete mainSwipeGroup; + mainSwipeGroup = nullptr; + GRAPHIC_LOGE("SwipeCallback new fail\n"); + return; + } + } -bool MainViewSample::HorizontalViewInit(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::HorizontalViewInit"); - UISwipeView::OnSwipeListener *listener = nullptr; + HorizontalViewInit(); + HorViewLoad(); + VerticalViewInit(); + VertViewLoad(); + mainSwipeGroup->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + mainSwipeGroup->SetAnimatorTime(50); // 50: animator drag time(ms); + mainSwipeGroup->SetLoopState(true); + mainSwipeGroup->EnableScreenCap(true); + mainSwipeGroup->RegisterSwipeCallback(callback); + mainSwipeGroup->SetHorCurrentPage(dialView->GetViewIndex()); + SetContainerView(mainSwipeGroup); + } - maxPage = ScreenModels::GetInstance()->GetMaxCard(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::HorizontalViewInit1"); + bool MainViewSample::HorizontalViewInit(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::HorizontalViewInit"); + UISwipeView::OnSwipeListener *listener = nullptr; + + maxPage = ScreenModels::GetInstance()->GetMaxCard(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::HorizontalViewInit1"); + + for (int16_t i = 0; i < maxPage; i++) + { + recordCard[i] = CreatePage(i); + if (recordCard[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard %d error", i); + return false; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard[%d]:%p", i, recordCard[i]); + } - for (int16_t i = 0; i < maxPage; i++) { - recordCard[i] = CreatePage(i); - if (recordCard[i] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard %d error", i); + listener = static_cast(MainPresenterSample::GetInstance()); + if (listener == nullptr) + { return false; } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard[%d]:%p", i, recordCard[i]); + MainPresenterSample::GetInstance()->setCallback(callback); + mainSwipeGroup->SetOnSwipeListener(listener); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitPage over"); + return true; } - listener = static_cast(MainPresenterSample::GetInstance()); - if (listener == nullptr) { - return false; + void MainViewSample::HorViewLoad(void) + { + for (int16_t i = 0; i < maxPage; i++) + { + mainSwipeGroup->HorAdd(recordCard[i]); + } } - MainPresenterSample::GetInstance()->setCallback(callback); - mainSwipeGroup->SetOnSwipeListener(listener); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitPage over"); - return true; -} -void MainViewSample::HorViewLoad(void) -{ - for (int16_t i = 0; i < maxPage; i++) { - mainSwipeGroup->HorAdd(recordCard[i]); + void MainViewSample::VerticalViewInit(void) + { + dropDownView = new PullUpDownView(); + if (dropDownView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dropDownView new fail"); + return; + } + dropDownView->PreLoad(); + dropDownView->SetViewId("dropDownView"); + dropDownView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + dropDownView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + + messageView = new UICardPage(); + if (messageView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageView new fail"); + return; + } + messageView->SetPosition(0, 0); + messageView->SetWidth(Screen::GetInstance().GetWidth()); + messageView->SetHeight(Screen::GetInstance().GetHeight()); + messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); + messageView->SetViewId("messageView"); + messageView->SetTouchable(true); + messageView->SetIntercept(true); + messageLable = new UILabel(); + if (messageLable == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLable new fail"); + return; + } + messageLable->SetPosition(MESLABLE_X_TMP, MESLABLE_Y_TMP, MESLABLE_WIDTH_TMP, MESLABLE_HEIGHT_TMP); + messageLable->SetText("无消息"); + messageLable->SetAlign(TEXT_ALIGNMENT_CENTER); + messageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_SIZE_TMP); + messageLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); + messageView->Add(messageLable); } -} -void MainViewSample::VerticalViewInit(void) -{ - dropDownView = new PullUpDownView(); - if (dropDownView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dropDownView new fail"); - return; + void MainViewSample::VertViewLoad(void) + { + mainSwipeGroup->VerAdd(dropDownView, UICrossView::VPage::UP_PAGE); + mainSwipeGroup->VerAdd(messageView, UICrossView::VPage::DOWN_PAGE); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::PullViewLoad::Pull View Load complete"); } - dropDownView->PreLoad(); - dropDownView->SetViewId("dropDownView"); - dropDownView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - dropDownView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - - messageView = new UICardPage(); - if (messageView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageView new fail"); - return; - } - messageView->SetPosition(0, 0); - messageView->SetWidth(Screen::GetInstance().GetWidth()); - messageView->SetHeight(Screen::GetInstance().GetHeight()); - messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); - messageView->SetViewId("messageView"); - messageView->SetTouchable(true); - messageView->SetIntercept(true); - messageLable = new UILabel(); - if (messageLable == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageLable new fail"); - return; - } - messageLable->SetPosition(MESLABLE_X_TMP, MESLABLE_Y_TMP, MESLABLE_WIDTH_TMP, MESLABLE_HEIGHT_TMP); - messageLable->SetText("无消息"); - messageLable->SetAlign(TEXT_ALIGNMENT_CENTER); - messageLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_SIZE_TMP); - messageLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT); - messageView->Add(messageLable); -} -void MainViewSample::VertViewLoad(void) -{ - mainSwipeGroup->VerAdd(dropDownView, UICrossView::VPage::UP_PAGE); - mainSwipeGroup->VerAdd(messageView, UICrossView::VPage::DOWN_PAGE); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::PullViewLoad::Pull View Load complete"); -} + void MainViewSample::OnSetUpView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnSetUpView"); + View::OnSetUpView(); -void MainViewSample::OnSetUpView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnSetUpView"); - View::OnSetUpView(); + // show timerView + Draw(); + } - // show timerView - Draw(); -} + void MainViewSample::OnTearDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnTearDownView"); + View::OnTearDownView(); + return; + } + void MainViewSample::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnStop"); + View::OnStop(); + container_ = nullptr; -void MainViewSample::OnTearDownView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnTearDownView"); - View::OnTearDownView(); - return; -} - -void MainViewSample::OnStop() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::OnStop"); - View::OnStop(); - container_ = nullptr; - - messageView->RemoveAll(); - RootView::GetInstance()->ClearOnKeyActListener(); - RootView::GetInstance()->RemoveAll(); - return; -} - -UICardPage *MainViewSample::InitWatchFacePage(void) -{ - mainClockView = new Digital_clockView(); - if (mainClockView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail"); - return nullptr; + messageView->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); + RootView::GetInstance()->RemoveAll(); + return; } - return mainClockView; -} -UICardPage *MainViewSample::InitHeartRatePage(void) -{ - - heartRateView = new HeartRateView(); - if (heartRateView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateView new fail"); - return nullptr; + /* -------------------------------------------------------------------------- */ + UICardPage *MainViewSample::InitWatchFacePage(void) + { + mainClockView = new Digital_clockView(); + if (mainClockView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail"); + return nullptr; + } + return mainClockView; } - return heartRateView; -} - -UICardPage *MainViewSample::InitActivityPage(void) -{ - - activityWeekView = new ActivityWeekView(); - if (activityWeekView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "activityWeekView new fail"); - return nullptr; + UICardPage *MainViewSample::InitActivityPage(void) + { + + activityWeekView = new ActivityWeekView(); + if (activityWeekView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "activityWeekView new fail"); + return nullptr; + } + return activityWeekView; } - return activityWeekView; -} - -UICardPage *MainViewSample::InitCompassPage(void) -{ - - compassControlView = new CompassControlView(); - if (compassControlView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "compassControlView new fail"); - return nullptr; + UICardPage *MainViewSample::InitMusicPlayerPage(void) + { + + playersView = new PlayersView(); + if (playersView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView new fail"); + return nullptr; + } + return playersView; + } + /* -------------------------------------------------------------------------- */ + // 主界面心率卡片 + UICardPage *MainViewSample::InitHeartRatePage(void) + { + + heartRateView = new HeartRateView(); + if (heartRateView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRateView new fail"); + return nullptr; + } + return heartRateView; + } + // 主界面指南针卡片 + UICardPage *MainViewSample::InitCompassPage(void) + { + compassControlView = new CompassControlView(); + if (compassControlView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "compassControlView new fail"); + return nullptr; + } + return compassControlView; + } + // 主界面表盘卡片 + UICardPage *MainViewSample::InitNewDialPage(void) + { + dialView = new Digital_clockView(); + if (dialView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialView new fail"); + return nullptr; + } + return dialView; + } + // 主界面血氧卡片 + UICardPage *MainViewSample::InitBloodOxygenPage(void) + { + bloodView = new BloodView(); + if (bloodView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView new fail"); + return nullptr; + } + return bloodView; } - return compassControlView; -} -UICardPage *MainViewSample::InitMusicPlayerPage(void) -{ - - playersView = new PlayersView(); - if (playersView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView new fail"); + UICardPage *MainViewSample::CreatePage(int32_t StreamId) + { + uint16_t i; + UICardPage *view = nullptr; + int32_t cardId = ScreenModels::GetInstance()->GetCardPage(StreamId); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage cardId:%d", cardId); + for (i = 0; i < sizeof(PageMapper) / sizeof(PageMapper[0]); i++) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d", PageMapper[i].id, cardId, StreamId); + //printf("MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d\n", PageMapper[i].id, cardId, StreamId); + if (PageMapper[i].id == cardId) + { + view = (this->*(PageMapper[i].func))(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage view:%p", view); + return view; + } + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreatePage view error!"); return nullptr; } - return playersView; -} -UICardPage *MainViewSample::InitNewDialPage(void) -{ - - dialView = new Digital_clockView(); - if (dialView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialView new fail"); - return nullptr; + void MainViewSample::AnimatorStart(int pageIndex) + { + if (heartRateView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(HEART_RATE)) + { + heartRateView->HeartbeatImageAnimatorStart(); + } } - return dialView; -} -UICardPage *MainViewSample::CreatePage(int32_t StreamId) -{ - - uint16_t i; - UICardPage *view = nullptr; - int32_t cardId = ScreenModels::GetInstance()->GetCardPage(StreamId); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage cardId:%d", cardId); - for (i = 0; i < sizeof(PageMapper) / sizeof(PageMapper[0]); i++) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::CreatePage PageMapper[i].id=%d, cardId=%d, StreamId=%d", PageMapper[i].id, cardId, StreamId); - - if (PageMapper[i].id == cardId) { - - view = (this->*(PageMapper[i].func))(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CreatePage view:%p", view); - return view; + void MainViewSample::AnimatorStop(void) + { + if (heartRateView != nullptr) + { + heartRateView->HeartbeatImageAnimatorStop(); } + // if (mainClockView != nullptr) { + // mainClockView->ClockAnimatorStop(); + // } } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreatePage view error!"); - return nullptr; -} + bool MainViewSample::IsMainView(void) + { -void MainViewSample::AnimatorStart(int pageIndex) -{ - - if (heartRateView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(HEART_RATE)) { - heartRateView->HeartbeatImageAnimatorStart(); - } - // if ((mainClockView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(WATCH_FACE)) && - // mainSwipeGroup->GetCurrentPageId(UISwipeView::VERTICAL) == 2) { - // mainClockView->ClockAnimatorStart(); - // } - if ((dialView != nullptr && pageIndex == ScreenModels::GetInstance()->GetCardPage(NEW_DAIL)) && - mainSwipeGroup->GetCurrentPageId(UISwipeView::VERTICAL) == 1) { - dialView->PreLoad(); + if (mainSwipeGroup->GetCurrentPageId(0) == ScreenModels::GetInstance()->GetCardPage(NEW_DAIL) && + mainSwipeGroup->GetCurrentPageId(1) == 1) + { // 0: horizontal; 1: vertical + return true; + } + else + { + return false; + } } -} -void MainViewSample::AnimatorStop(void) -{ - if (heartRateView != nullptr) { - heartRateView->HeartbeatImageAnimatorStop(); + void MainViewSample::SetDragFg(bool continFg) + { + continuDragFg = continFg; } - // if (mainClockView != nullptr) { - // mainClockView->ClockAnimatorStop(); - // } -} -bool MainViewSample::IsMainView(void) -{ - - if (mainSwipeGroup->GetCurrentPageId(0) == ScreenModels::GetInstance()->GetCardPage(NEW_DAIL) && - mainSwipeGroup->GetCurrentPageId(1) == 1) { // 0: horizontal; 1: vertical - return true; - } else { - return false; + bool MainViewSample::GetDragFg(void) + { + return continuDragFg; } -} - -void MainViewSample::SetDragFg(bool continFg) -{ - continuDragFg = continFg; -} - -bool MainViewSample::GetDragFg(void) -{ - return continuDragFg; -} - } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h index cc19892d7..50063c540 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h @@ -2,18 +2,12 @@ * @Author: Caisking 3449750381@qq.com * @Date: 2023-12-15 14:33:22 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-01-11 19:29:58 + * @LastEditTime: 2024-01-15 19:34:47 * @FilePath: /1.FD230/FD230/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h * @Description: * @ * @Copyright (c) 2024 by Caisking , All Rights Reserved. */ -/* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: ScreenModels - * Author: - * Create: 2022-01-22 - */ #ifndef SCREEN_MODEL_H #define SCREEN_MODEL_H @@ -21,42 +15,45 @@ #include "gfx_utils/list.h" #include "ui_image_view.h" -namespace OHOS { -typedef enum { - NEW_DAIL = 0, - HEART_RATE, - COMPASS, - ACTIVITY, - MUSIC_PLAYER, - MAX_CARD, -} CardId; +namespace OHOS +{ + typedef enum + { + NEW_DAIL = 0, + HEART_RATE, + COMPASS, + BloodOxygen, + MAX_CARD, + } CardId; + struct CardInfo + { + int16_t cardId; + }; -struct CardInfo { - int16_t cardId; -}; + class ScreenModels + { + public: + ScreenModels(); + ~ScreenModels(); + static ScreenModels *GetInstance(void); + // card funtion + bool SetUpListCase(void); + bool SaveCardConfig(void); + bool InitCardConfig(void); + void SetCardConfigDefault(void); + int16_t GetCardPage(uint16_t page); + bool CardInsertFirst(int32_t card); + bool CardDelete(int32_t card); + int16_t GetMaxCard(void); + int16_t GetLastCardPage(void); + bool LoadAppImages(std::string file, UIImageView *view, uint32_t resId); + void PreLoadAppimages(void); -class ScreenModels { -public: - ScreenModels(); - ~ScreenModels(); - static ScreenModels *GetInstance(void); - // card funtion - bool SetUpListCase(void); - bool SaveCardConfig(void); - bool InitCardConfig(void); - void SetCardConfigDefault(void); - int16_t GetCardPage(uint16_t page); - bool CardInsertFirst(int32_t card); - bool CardDelete(int32_t card); - int16_t GetMaxCard(void); - int16_t GetLastCardPage(void); - bool LoadAppImages(std::string file, UIImageView *view, uint32_t resId); - void PreLoadAppimages(void); -private: - void LoadAppMultiImages(std::string file, uint32_t startId, uint32_t lastId); - List *listMainView{nullptr}; // record main view pages - int16_t maxPage = MAX_CARD; -}; + private: + void LoadAppMultiImages(std::string file, uint32_t startId, uint32_t lastId); + List *listMainView{nullptr}; // record main view pages + int16_t maxPage = MAX_CARD; + }; } #endif