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
{2, &MainRemindView::ChangeRemindView2},
{3, &MainRemindView::ChangeRemindView3},
{4, &MainRemindView::ChangeRemindView4},
+ {5, &MainRemindView::ChangeRemindView5},
};
// 3.根据传入的interface参数执行相应视图ID关联的成员函数。
{
InitView();
viewInitStatus = true;
- ChangeView(0, 3);
+ ChangeView(0, 5);
}
}
void MainRemindView::OnStart()
--- /dev/null
+#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