From: 罗正yun <1732036298@qq.com> Date: Wed, 20 Dec 2023 02:21:19 +0000 (+0800) Subject: 提醒视图四个,还差一个下午补上 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=b70ab96408d1923076394fd7d7e92df8dcae24aa;p=mirrors%2FFD230.git 提醒视图四个,还差一个下午补上 --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 998aed11a..efe8fb63f 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -361,6 +361,13 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp + #提醒 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/MainRemindPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/MainRemindView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/RemindView1.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/RemindView2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/RemindView3.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/remind/src/RemindView4.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index bdca4b662..2ea449685 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -151,6 +151,8 @@ typedef enum : uint16_t VIEW_SYSTEM_FACTORY_RESET, // 系统:恢复出厂设置 VIEW_BRIGHTNESS_CONTROL, // 亮度调节 VIEW_SCREEN_DURATION, // 亮屏时长 + //提醒 + VIEW_REMIND, // 按键按下进入的视图 VIEW_QUICK_ACCESS, // 快速访问 VIEW_FAST_TRAINING, // 快速训练 diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index de432c81f..9b7e1402f 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -129,6 +129,7 @@ public: void InitStartCountDownSlice(void); void InitCountDownTimeNotNullSlice(void); void InitMainStopWatchSlice(void); + void InitRemindSlice(void); private: void InitAllNativeSlices(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index b606c0e79..47144f3b2 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -235,6 +235,8 @@ #include "countdown/include/CountDownTimeNotNullView.h" #include "stopwatch/include/MainStopWatchPresenter.h" #include "stopwatch/include/MainStopWatchView.h" +#include "remind/include/MainRemindPresenter.h" +#include "remind/include/MainRemindView.h" namespace OHOS { struct AppViewMapper @@ -356,6 +358,7 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_START_COUNTDOWN,&NativeLauncher::InitStartCountDownSlice}, //开始倒计时 {VIEW_COUNTDOWN_TIME_NOT_NULL,&NativeLauncher::InitCountDownTimeNotNullSlice}, //倒计时不能为0 {VIEW_MAIN_STOPWATCH,&NativeLauncher::InitMainStopWatchSlice}, //秒表主视图 + {VIEW_REMIND,&NativeLauncher::InitRemindSlice}, //提醒 {VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice} }; @@ -1375,4 +1378,13 @@ void NativeLauncher::InitMainStopWatchSlice(void) //倒计时时间不能为0 } NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_STOPWATCH, mainstopwatch); } + +void NativeLauncher::InitRemindSlice(void) //提醒 +{ + SliceProxy *remind = new AbilitySliceProxy; + if (remind == nullptr) { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_REMIND, remind); +} } 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 8f34224b5..54cd8e53c 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp @@ -31,7 +31,7 @@ namespace OHOS {VIEW_CONNECT_BLUETOOTH, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_BLUETOOTH_IMAGE, "蓝牙", nullptr}, {VIEW_MAIN_ALARM, PNG_APPLIST_ALARM_IMAGE, PNG_APPLIST_ALARM_IMAGE, "闹钟", nullptr}, {VIEW_MAIN_STOPWATCH, PNG_APPLIST_CHRONOMETER_IMAGE, PNG_APPLIST_CHRONOMETER_IMAGE, "秒表", nullptr}, - //{VIEW_SPORT, PNG_APPLIST_SPORT_IMAGE, PNG_APPLIST_SPORT_IMAGE, "活动", nullptr}, + {VIEW_REMIND, PNG_APPLIST_SPORT_IMAGE, PNG_APPLIST_SPORT_IMAGE, "提醒", nullptr}, {VIEW_MAIN_COUNTDOWN, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_COUNTDOWN_IMAGE, "计时器", nullptr}, {VIEW_BLOODOXY_SAMPLE, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_SPO2_IMAGE, "血氧饱和度", nullptr}, {VIEW_INDOORWALK, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_WALK_IMAGE, "室内步行", nullptr}, diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/include/MainRemindPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/MainRemindPresenter.h new file mode 100644 index 000000000..70c668dc1 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/MainRemindPresenter.h @@ -0,0 +1,42 @@ +#ifndef MAIN_REMIND_PRESENTER_H +#define MAIN_REMIND_PRESENTER_H + +#include "Presenter.h" +#include "MainRemindView.h" + +namespace OHOS +{ + static const char *REMINDVIEW1_RETURN_VIEWID = "REMINDVIEW1_RETURN_VIEWID"; // 提醒视图1的返回按钮视图 + static const char *REMINDVIEW2_BIND_VIEWID = "REMINDVIEW2_BIND_VIEWID"; // 提醒视图2的绑定按钮 + static const char *REMINDVIEW2_UNBIND_VIEWID = "REMINDVIEW2_UNBIND_VIEWID"; // 提醒视图2的不绑定按钮 + static const char *REMINDVIEW3_BIND_VIEWID = "REMINDVIEW3_BIND_VIEWID"; // 提醒视图3的不解绑按钮 + 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的不继续解绑按钮 + class MainRemindView; + class MainRemindPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + MainRemindPresenter(); + virtual ~MainRemindPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + void SetDeviceNameLabel(UILabel *DeviceNameLabel); + void SetUnBindImageAnimator(UIImageAnimatorView *UnBindImageAnimator); + static MainRemindPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + UILabel *m_DeviceNameLabel{nullptr}; + UIImageAnimatorView *m_UnBindImageAnimator{nullptr}; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/include/MainRemindView.h b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/MainRemindView.h new file mode 100644 index 000000000..39df12341 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/MainRemindView.h @@ -0,0 +1,49 @@ +#ifndef MAIN_REMIND_VIEW_H +#define MAIN_REMIND_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "remind/include/RemindView1.h" +#include "remind/include/RemindView2.h" +#include "remind/include/RemindView3.h" +#include "remind/include/RemindView4.h" +namespace OHOS +{ + class MainRemindPresenter; + class MainRemindView : public View + { + + public: + MainRemindView(); + virtual ~MainRemindView(); + static MainRemindView *GetInstance(void); + void InitView(void); + void DeInitView(void); + void PreLoad(void); + bool ChangeMainRemind(int16_t thisView); + bool ChangeRemindView1(int16_t thisView); + bool ChangeRemindView2(int16_t thisView); + bool ChangeRemindView3(int16_t thisView); + bool ChangeRemindView4(int16_t thisView); + bool ClickFunc(int16_t interface); + void ChangeView(int16_t hideView, int16_t showView); + + public: + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + RemindView1 *p_RemindView1{nullptr}; // 提醒视图1 + RemindView2 *p_RemindView2{nullptr}; // 提醒视图2 + RemindView3 *p_RemindView3{nullptr}; // 提醒视图3 + RemindView4 *p_RemindView4{nullptr}; // 提醒视图4 + UIViewGroup *container_{nullptr}; + UIScrollView *scrollView[6]{nullptr}; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView1.h b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView1.h new file mode 100644 index 000000000..042ad64ad --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView1.h @@ -0,0 +1,32 @@ +#ifndef REMIND_1_VIEW_H +#define REMIND_1_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 RemindView1 + { + + public: + RemindView1(); + virtual ~RemindView1(); + static RemindView1 *GetInstance(void); + + UIScrollView *InitRemindView1(void); + void DeInitRemindView1(void); + + private: + UIScrollView *scrollView1_{nullptr}; + UILabel *label11_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label13_ = nullptr; + UIButton *button1_ = nullptr; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView2.h b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView2.h new file mode 100644 index 000000000..4f419e7e8 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView2.h @@ -0,0 +1,33 @@ +#ifndef REMIND_2_VIEW_H +#define REMIND_2_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_button.h" +namespace OHOS +{ + class RemindView2 + { + + public: + RemindView2(); + virtual ~RemindView2(); + static RemindView2 *GetInstance(void); + + UIScrollView *InitRemindView2(void); + void DeInitRemindView2(void); + + private: + UIScrollView *scrollView1_ = nullptr; + UILabel *label1 = nullptr; + UILabel *DeviceNameLabel = nullptr; // 要绑定的设备名称 + UILabel *label2 = nullptr; + UILabel *label3 = nullptr; + UIButton *BindButton = nullptr; // 绑定按钮 + UIButton *UnBindButton = nullptr; // 不绑定按钮 + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView3.h b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView3.h new file mode 100644 index 000000000..31e5bbb5a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView3.h @@ -0,0 +1,35 @@ +#ifndef REMIND_3_VIEW_H +#define REMIND_3_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_animator.h" +#include "components/ui_button.h" +namespace OHOS +{ + class RemindView3 + { + + public: + RemindView3(); + virtual ~RemindView3(); + static RemindView3 *GetInstance(void); + + UIScrollView *InitRemindView3(void); + void DeInitRemindView3(void); + + private: + UIScrollView *scrollView1_ = nullptr; + UIImageAnimatorView *UnBindImageAnimator = nullptr; //解绑的图标动画 + UILabel *label11_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label13_ = nullptr; + UIButton *button1_ = nullptr; + UIButton *button3_ = nullptr; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView4.h b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView4.h new file mode 100644 index 000000000..ab937a58a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/include/RemindView4.h @@ -0,0 +1,35 @@ +#ifndef REMIND_4_VIEW_H +#define REMIND_4_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 RemindView4 + { + + public: + RemindView4(); + virtual ~RemindView4(); + static RemindView4 *GetInstance(void); + + UIScrollView *InitRemindView4(void); + void DeInitRemindView4(void); + + private: + UIScrollView *scrollView1_ = nullptr; + UILabel *label1 = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label2 = nullptr; + UILabel *label3 = nullptr; + UIButton *button3_ = nullptr; + UIButton *button1_ = nullptr; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/src/MainRemindPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/MainRemindPresenter.cpp new file mode 100644 index 000000000..b9bf7c666 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/MainRemindPresenter.cpp @@ -0,0 +1,112 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "remind/include/MainRemindPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static MainRemindPresenter *g_pMainRemindPresenter = nullptr; + + MainRemindPresenter::MainRemindPresenter() + { + + g_pMainRemindPresenter = this; + } + + MainRemindPresenter::~MainRemindPresenter() + { + + g_pMainRemindPresenter = nullptr; + } + + MainRemindPresenter *MainRemindPresenter::GetInstance() + { + + return g_pMainRemindPresenter; + } + + void MainRemindPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void MainRemindPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void MainRemindPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void MainRemindPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + // 设备名标签赋值 + void MainRemindPresenter::SetDeviceNameLabel(UILabel *DeviceNameLabel) + { + m_DeviceNameLabel = DeviceNameLabel; + } + + void MainRemindPresenter::SetUnBindImageAnimator(UIImageAnimatorView *UnBindImageAnimator) + { + m_UnBindImageAnimator = UnBindImageAnimator; + } + + bool MainRemindPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + UNUSED(event); + return true; + } + + bool MainRemindPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), REMINDVIEW1_RETURN_VIEWID) == 0) + { + uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + NativeAbility::GetInstance().ChangeSlice(preSlice); + } + else if (strcmp(view.GetViewId(), REMINDVIEW2_UNBIND_VIEWID) == 0) + { + m_DeviceNameLabel->SetRollSpeed(0); // 点击不绑定按钮跳转上一视图,将绑定设备名标签文字滚动速度设置为0 + uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + NativeAbility::GetInstance().ChangeSlice(preSlice); + } + else if (strcmp(view.GetViewId(), REMINDVIEW2_BIND_VIEWID) == 0) + { + printf("bind...\n"); + } + else if (strcmp(view.GetViewId(), REMINDVIEW3_BIND_VIEWID) == 0) + { + m_UnBindImageAnimator->Stop(); + uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + NativeAbility::GetInstance().ChangeSlice(preSlice); + } + else if (strcmp(view.GetViewId(), REMINDVIEW3_UNBIND_VIEWID) == 0) + { + m_UnBindImageAnimator->Stop(); + MainRemindView::GetInstance()->ChangeView(3,4); + } + else if (strcmp(view.GetViewId(), REMINDVIEW4_UNBIND_OPT_CONTINUE_YES_VIEWID) == 0) + { + printf("continue yes...\n"); + } + else if (strcmp(view.GetViewId(), REMINDVIEW4_UNBIND_OPT_CONTINUE_NO_VIEWID) == 0) + { + m_UnBindImageAnimator->Start(); + MainRemindView::GetInstance()->ChangeView(4,3); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/src/MainRemindView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/MainRemindView.cpp new file mode 100644 index 000000000..7d0554c34 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/MainRemindView.cpp @@ -0,0 +1,236 @@ +#include "remind/include/MainRemindView.h" +#include "remind/include/MainRemindPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + + static MainRemindView *g_pMainRemindView{nullptr}; + + MainRemindView::MainRemindView() + { + + g_pMainRemindView = this; + } + + MainRemindView::~MainRemindView() + { + if (viewInitStatus == true) + { + DeInitView(); + } + g_pMainRemindView = nullptr; + } + + MainRemindView *MainRemindView::GetInstance() + { + + return g_pMainRemindView; + } + + bool MainRemindView::ChangeMainRemind(int16_t thisView) + { + container_->Add(scrollView[thisView]); + return true; + } + + // 提醒视图1:输入字数上限后弹出该视图 + bool MainRemindView::ChangeRemindView1(int16_t thisView) + { + if (scrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainRemindView::RemindView1"); + p_RemindView1 = new RemindView1(); + if (p_RemindView1 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainRemindView:: new scrollView[%d] fail", thisView); + return false; + } + scrollView[thisView] = p_RemindView1->InitRemindView1(); + container_->Add(scrollView[thisView]); + } + return true; + } + + // 提醒视图2:进行设备绑定时弹出该视图 + bool MainRemindView::ChangeRemindView2(int16_t thisView) + { + if (scrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainRemindView::RemindView2"); + p_RemindView2 = new RemindView2(); + if (p_RemindView2 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainRemindView:: new scrollView[%d] fail", thisView); + return false; + } + scrollView[thisView] = p_RemindView2->InitRemindView2(); + container_->Add(scrollView[thisView]); + } + return true; + } + + // 提醒视图3:进行设备解绑时弹出该视图 + bool MainRemindView::ChangeRemindView3(int16_t thisView) + { + if (scrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainRemindView::RemindView3"); + p_RemindView3 = new RemindView3(); + if (p_RemindView3 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainRemindView:: new scrollView[%d] fail", thisView); + return false; + } + scrollView[thisView] = p_RemindView3->InitRemindView3(); + container_->Add(scrollView[thisView]); + } + return true; + } + + // 提醒视图4:进行设备解绑时弹出的注意事项视图,该视图会询问你是否继续解绑设备,连接新设备会将手表恢复出厂设置 + bool MainRemindView::ChangeRemindView4(int16_t thisView) + { + if (scrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainRemindView::RemindView4"); + p_RemindView4 = new RemindView4(); + if (p_RemindView4 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainRemindView:: new scrollView[%d] fail", thisView); + return false; + } + scrollView[thisView] = p_RemindView4->InitRemindView4(); + container_->Add(scrollView[thisView]); + } + return true; + } + + /* -------------------------------------------------------------------------- */ + // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 + struct MainRemindViewMapper + { + const int16_t viewId; + bool (MainRemindView::*func)(int16_t thisView); + }; + + // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 + static const MainRemindViewMapper ViewMapper[] = { + {0, &MainRemindView::ChangeMainRemind}, + {1, &MainRemindView::ChangeRemindView1}, + {2, &MainRemindView::ChangeRemindView2}, + {3, &MainRemindView::ChangeRemindView3}, + {4, &MainRemindView::ChangeRemindView4}, + }; + + // 3.根据传入的interface参数执行相应视图ID关联的成员函数。 + bool MainRemindView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + // 4.切换视图 + void MainRemindView::ChangeView(int16_t hideView, int16_t showView) + { + if (hideView > 6) + { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: StopWatchViewId Overstep ones bounds"); + return; + } + scrollView[hideView]->SetVisible(false); + ClickFunc(showView); + scrollView[showView]->SetVisible(true); + Draw(); + } + /* -------------------------------------------------------------------------- */ + + void MainRemindView::InitView() + { + // container_容器属性 new + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + // container_容器属性 扩展 + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetTouchable(true); + scrollView[0] = new UIScrollView(); + if (scrollView[0] == nullptr) + { + scrollView[0] = new UIScrollView(); + } + scrollView[0]->SetPosition(0, 0, 466, 466); + scrollView[0]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView[0]); + } + + void MainRemindView::DeInitView() + { + if (p_RemindView1 != nullptr) + { + delete p_RemindView1; + p_RemindView1 = nullptr; + } + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + for (int i = 0; i < 6; i++) + { + delete scrollView[i]; + scrollView[i] = nullptr; + } + } + void MainRemindView::PreLoad(void) + { + if (!viewInitStatus) + { + InitView(); + viewInitStatus = true; + ChangeView(0, 3); + } + } + void MainRemindView::OnStart() + { + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void MainRemindView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void MainRemindView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void MainRemindView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView1.cpp b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView1.cpp new file mode 100644 index 000000000..ad7415486 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView1.cpp @@ -0,0 +1,157 @@ +#include "remind/include/RemindView1.h" +#include "remind/include/MainRemindPresenter.h" +namespace OHOS +{ + + static RemindView1 *g_pRemindView1{nullptr}; + + RemindView1::RemindView1() + { + g_pRemindView1 = this; + } + + RemindView1::~RemindView1() + { + if (viewInitStatus == true) + { + DeInitRemindView1(); + } + g_pRemindView1 = nullptr; + } + + RemindView1 *RemindView1::GetInstance() + { + + return g_pRemindView1; + } + + //提醒视图1:输入字数上限后弹出该视图 + UIScrollView *RemindView1::InitRemindView1() + { + // 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_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Label to App + if (label11_ == nullptr) + { + label11_ = new UILabel(); + } + label11_->SetPosition(203, 52); + label11_->Resize(120, 35); + label11_->SetViewId("label11"); + label11_->SetStyle(STYLE_TEXT_FONT, 30); + label11_->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + 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); + /* -------------------------------------------------------------------------- */ + // Add to scrollView1 + scrollView1_->Add(label11_); + label11_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(193, 121); + image1_->Resize(100, 100); + image1_->SetViewId("image1"); + image1_->SetStyle(STYLE_BORDER_RADIUS, 100); + char *image1imagesPath = "/user/res/countdown/COUNTDOWN_ATTENTION.bin"; + image1_->SetSrc(image1imagesPath); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + + // Add Label to App + if (label13_ == nullptr) + { + label13_ = new UILabel(); + } + label13_->SetPosition(66, 235); + label13_->Resize(100, 60); + label13_->SetViewId("label13"); + label13_->SetStyle(STYLE_TEXT_FONT, 30); + label13_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label13_->SetText("可输入字符串长度为20个\n两行文字"); + label13_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label13_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label13_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label13_->SetRollSpeed(0); + label13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + scrollView1_->Add(label13_); + label13_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(0, 366); + button1_->Resize(466, 100); + button1_->SetViewId(REMINDVIEW1_RETURN_VIEWID); + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + char *button1defaultImgSrc = "/user/res/countdown/COUNTDOWN_BUTTON.bin"; + button1_->SetImageSrc(button1defaultImgSrc, nullptr); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(MainRemindPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + viewInitStatus = true; + return scrollView1_; + } + + void RemindView1::DeInitRemindView1() + { + if (scrollView1_ != nullptr) + { + scrollView1_->RemoveAll(); + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label11_ != nullptr) + { + delete label11_; + label11_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label13_ != nullptr) + { + delete label13_; + label13_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView2.cpp b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView2.cpp new file mode 100644 index 000000000..07fb12fc6 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView2.cpp @@ -0,0 +1,209 @@ +#include "remind/include/RemindView2.h" +#include "remind/include/MainRemindPresenter.h" +namespace OHOS +{ + + static RemindView2 *g_pRemindView2{nullptr}; + + RemindView2::RemindView2() + { + g_pRemindView2 = this; + } + + RemindView2::~RemindView2() + { + if (viewInitStatus == true) + { + DeInitRemindView2(); + } + g_pRemindView2 = nullptr; + } + + RemindView2 *RemindView2::GetInstance() + { + + return g_pRemindView2; + } + + // 提醒视图2:进行设备绑定时弹出该视图 + UIScrollView *RemindView2::InitRemindView2() + { + // 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_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Label to App + if (label1 == nullptr) + { + label1 = new UILabel(); + } + label1->SetPosition(173, 52); + label1->Resize(120, 35); + label1->SetStyle(STYLE_TEXT_FONT, 30); + label1->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + label1->SetText("设备绑定"); + 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 scrollView1 + scrollView1_->Add(label1); + label1->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Label to App + if (DeviceNameLabel == nullptr) + { + DeviceNameLabel = new UILabel(); + } + DeviceNameLabel->SetPosition(33, 230); + DeviceNameLabel->Resize(220, 40); + DeviceNameLabel->SetViewId("label2"); + DeviceNameLabel->SetStyle(STYLE_TEXT_FONT, 30); + DeviceNameLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + DeviceNameLabel->SetText("LZ 的 Iphone 14 Pro"); + DeviceNameLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);//设备名称标签上的文字可能过长需滚动显示 + DeviceNameLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + DeviceNameLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + MainRemindPresenter::GetInstance()->SetDeviceNameLabel(DeviceNameLabel); + + // Add to scrollView1 + scrollView1_->Add(DeviceNameLabel); + DeviceNameLabel->SetVisible(true); + + // Add Label to App + if (label2 == nullptr) + { + label2 = new UILabel(); + } + label2->SetPosition(250, 230); + label2->Resize(400, 70); + label2->SetViewId("label1"); + label2->SetStyle(STYLE_TEXT_FONT, 30); + label2->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + label2->SetText("想要进行连接\n"); + label2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label2->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2->SetRollSpeed(0); + label2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + scrollView1_->Add(label2); + label2->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Label to App + if (label3 == nullptr) + { + label3 = new UILabel(); + } + label3->SetPosition(173, 269); + label3->Resize(100, 60); + label3->SetViewId("label13"); + label3->SetStyle(STYLE_TEXT_FONT, 30); + label3->SetStyle(STYLE_LINE_HEIGHT, 35); + // Set additional property + label3->SetText("是否同意"); + label3->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label3->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + scrollView1_->Add(label3); + label3->SetVisible(true); + // Add Button to App + if (BindButton == nullptr) + { + BindButton = new UIButton(); + } + BindButton->SetPosition(111, 320); + BindButton->Resize(100, 100); + BindButton->SetViewId(REMINDVIEW2_UNBIND_VIEWID); + BindButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + BindButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + BindButton->SetStyle(STYLE_BORDER_RADIUS, 100); + BindButton->SetImageSrc("/user/res/SYSTEM_CheckOff.bin", nullptr); + BindButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); + BindButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + BindButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + BindButton->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + scrollView1_->Add(BindButton); + BindButton->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Button to App + if (UnBindButton == nullptr) + { + UnBindButton = new UIButton(); + } + UnBindButton->SetPosition(256, 320); + UnBindButton->Resize(100, 100); + UnBindButton->SetViewId(REMINDVIEW2_BIND_VIEWID); + UnBindButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + UnBindButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + UnBindButton->SetStyle(STYLE_BORDER_RADIUS, 100); + UnBindButton->SetImageSrc("/user/res/SYSTEM_CheckOn.bin", nullptr); + UnBindButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); + UnBindButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + UnBindButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + UnBindButton->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *buttonClick = static_cast(MainRemindPresenter::GetInstance()); + BindButton->SetOnClickListener(buttonClick); + UnBindButton->SetOnClickListener(buttonClick); + // Add to rootView + scrollView1_->Add(UnBindButton); + UnBindButton->SetVisible(true); + viewInitStatus = true; + return scrollView1_; + } + + void RemindView2::DeInitRemindView2() + { + if (label1 != nullptr) + { + delete label1; + label1 = nullptr; + } + if (DeviceNameLabel != nullptr) + { + DeviceNameLabel->SetRollSpeed(0); + delete DeviceNameLabel; + DeviceNameLabel = nullptr; + } + if (label2 != nullptr) + { + delete label2; + label2 = nullptr; + } + if (label3 != nullptr) + { + delete label3; + label3 = nullptr; + } + if (BindButton != nullptr) + { + delete BindButton; + BindButton = nullptr; + } + if (UnBindButton != nullptr) + { + delete UnBindButton; + UnBindButton = nullptr; + } + if (scrollView1_ != nullptr) + { + scrollView1_->RemoveAll(); + delete scrollView1_; + scrollView1_ = nullptr; + } + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView3.cpp b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView3.cpp new file mode 100644 index 000000000..04357abc6 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView3.cpp @@ -0,0 +1,252 @@ +#include "remind/include/RemindView3.h" +#include "remind/include/MainRemindPresenter.h" + +namespace OHOS +{ + + static ImageAnimatorInfo g_imageAnimator1Info[2] = { + {"/user/res/1.bin", {193, 112}, 80, 80, IMG_SRC_FILE_PATH}, + {"/user/res/15.bin", {193, 112}, 80, 80, IMG_SRC_FILE_PATH},//图片桢有52å¼  + }; + /* -------------------------------------------------------------------------- */ + static RemindView3 *g_pRemindView2{nullptr}; + + RemindView3::RemindView3() + { + g_pRemindView2 = this; + } + + RemindView3::~RemindView3() + { + if (viewInitStatus == true) + { + DeInitRemindView3(); + } + g_pRemindView2 = nullptr; + } + + RemindView3 *RemindView3::GetInstance() + { + + return g_pRemindView2; + } + + // 提醒视图3:进行设备解绑时弹出该视图 + UIScrollView *RemindView3::InitRemindView3() + { + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetViewId("scrollView1"); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + 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); + // Set additional property + 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); + // Add to scrollView1 + scrollView1_->Add(label11_); + label11_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add ImageAnimatorView to App + if (UnBindImageAnimator == nullptr) + { + UnBindImageAnimator = new UIImageAnimatorView(); + } + UnBindImageAnimator->SetPosition(193, 112); + UnBindImageAnimator->Resize(80, 80); + UnBindImageAnimator->SetViewId("imageAnimator1"); + UnBindImageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0x00); + UnBindImageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + UnBindImageAnimator->SetImageAnimatorSrc(g_imageAnimator1Info, 2, 200); + UnBindImageAnimator->SetTimeOfPause(200); + UnBindImageAnimator->SetRepeatTimes(1); + UnBindImageAnimator->SetReverse(true); + UnBindImageAnimator->Start(); + + // Add to scrollView1 + scrollView1_->Add(UnBindImageAnimator); + UnBindImageAnimator->SetVisible(true); + + // Add Label to App + if (label2_ == nullptr) + { + label2_ = new UILabel(); + } + label2_->SetPosition(32, 229); + label2_->Resize(220, 40); + label2_->SetViewId("label2"); + label2_->SetStyle(STYLE_TEXT_FONT, 30); + label2_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label2_->SetText("Iphone 14 Pro "); + label2_->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label2_->SetRollSpeed(0); + label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label2_); + label2_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(250, 230); + label1_->Resize(400, 70); + label1_->SetViewId("label1"); + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1_->SetText("想要进行解绑\n"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add Label to App + if (label13_ == nullptr) + { + label13_ = new UILabel(); + } + label13_->SetPosition(173, 269); + label13_->Resize(100, 60); + label13_->SetViewId("label13"); + label13_->SetStyle(STYLE_TEXT_FONT, 30); + label13_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label13_->SetText("是否同意"); + label13_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label13_->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); + label13_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label13_->SetRollSpeed(0); + label13_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label13_); + label13_->SetVisible(true); + + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(111, 320); + button1_->Resize(100, 100); + button1_->SetViewId(REMINDVIEW3_BIND_VIEWID); + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button1_->SetStyle(STYLE_BORDER_RADIUS, 100); + button1_->SetImageSrc("/user/res/SYSTEM_CheckOff.bin", nullptr); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + + // Add the CallBack about events + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + + // Add Button to App + if (button3_ == nullptr) + { + button3_ = new UIButton(); + } + button3_->SetPosition(256, 320); + button3_->Resize(100, 100); + button3_->SetViewId(REMINDVIEW3_UNBIND_VIEWID); + button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button3_->SetStyle(STYLE_BORDER_RADIUS, 100); + button3_->SetImageSrc("/user/res/SYSTEM_CheckOn.bin", 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); + button3_->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *buttonClick = static_cast(MainRemindPresenter::GetInstance()); + MainRemindPresenter::GetInstance()->SetUnBindImageAnimator(UnBindImageAnimator); + button1_->SetOnClickListener(buttonClick); + button3_->SetOnClickListener(buttonClick); + // Add to rootView + scrollView1_->Add(button3_); + button3_->SetVisible(true); + viewInitStatus = true; + return scrollView1_; + } + + void RemindView3::DeInitRemindView3() + { + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label11_ != nullptr) + { + delete label11_; + label11_ = nullptr; + } + if (UnBindImageAnimator != nullptr) + { + delete UnBindImageAnimator; + UnBindImageAnimator = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label13_ != nullptr) + { + delete label13_; + label13_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView4.cpp b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView4.cpp new file mode 100644 index 000000000..8214376cb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/remind/src/RemindView4.cpp @@ -0,0 +1,191 @@ +#include "remind/include/RemindView4.h" +#include "remind/include/MainRemindPresenter.h" + +namespace OHOS +{ + + static RemindView4 *g_pRemindView2{nullptr}; + RemindView4::RemindView4() + { + g_pRemindView2 = this; + } + + RemindView4::~RemindView4() + { + if (viewInitStatus == true) + { + DeInitRemindView4(); + } + g_pRemindView2 = nullptr; + } + + RemindView4 *RemindView4::GetInstance() + { + return g_pRemindView2; + } + + // 提醒视图4:进行设备解绑时弹出的注意事项视图,该视图会询问你是否继续解绑设备,连接新设备会将手表恢复出厂设置 + UIScrollView *RemindView4::InitRemindView4() + { + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0, 466, 466); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView1_->SetScrollBlankSize(20); + scrollView1_->SetReboundSize(50); + scrollView1_->SetDirection(1); + scrollView1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (label1 == nullptr) + { + label1 = new UILabel(); + } + label1->SetPosition(203, 52); + label1->Resize(120, 35); + label1->SetViewId("label11"); + label1->SetStyle(STYLE_TEXT_FONT, 30); + label1->SetStyle(STYLE_LINE_HEIGHT, 35); + label1->SetText("注意"); + label1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1->SetRollSpeed(0); + label1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView1_->Add(label1); + label1->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(193, 121); + image1_->Resize(100, 100); + image1_->SetStyle(STYLE_BORDER_RADIUS, 100); + char *imageimagesPath = "/user/res/countdown/COUNTDOWN_ATTENTION.bin"; + image1_->SetSrc(imageimagesPath); + scrollView1_->Add(image1_); + image1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (label2 == nullptr) + { + label2 = new UILabel(); + } + label2->SetPosition(33, 217); + label2->Resize(400, 70); + label2->SetStyle(STYLE_TEXT_FONT, 31); + label2->SetStyle(STYLE_LINE_HEIGHT, 40); + label2->SetText("当前设备已经与 Iphone 13 pro 绑定"); + 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 (label3 == nullptr) + { + label3 = new UILabel(); + } + label3->SetPosition(33, 330); + label3->Resize(400, 80); + label3->SetViewId("label1"); + label3->SetStyle(STYLE_TEXT_FONT, 30); + label3->SetStyle(STYLE_LINE_HEIGHT, 40); + label3->SetText("继续连接操作会解除与 \nIphone 13 pro 的绑定并将\n手表恢复出厂设置(会清空手表数据)\n\n是否继续此操作"); + label3->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + label3->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); + label3->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3->SetRollSpeed(0); + label3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView1_->Add(label3); + label3->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Button to App + if (button3_ == nullptr) + { + button3_ = new UIButton(); + } + button3_->SetPosition(255, 600); + button3_->Resize(100, 100); + button3_->SetViewId(REMINDVIEW4_UNBIND_OPT_CONTINUE_YES_VIEWID); + button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button3_->SetStyle(STYLE_BORDER_RADIUS, 100); + button3_->SetImageSrc("/user/res/SYSTEM_CheckOn.bin", 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); + button3_->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + scrollView1_->Add(button3_); + button3_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(110, 600); + button1_->Resize(100, 100); + button1_->SetViewId(REMINDVIEW4_UNBIND_OPT_CONTINUE_NO_VIEWID); + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button1_->SetStyle(STYLE_BORDER_RADIUS, 100); + button1_->SetImageSrc("/user/res/SYSTEM_CheckOff.bin", nullptr); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *buttonClick = static_cast(MainRemindPresenter::GetInstance()); + button1_->SetOnClickListener(buttonClick); + button3_->SetOnClickListener(buttonClick); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + viewInitStatus = true; + return scrollView1_; + } + + void RemindView4::DeInitRemindView4() + { + + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1 != nullptr) + { + delete label1; + label1 = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label2 != nullptr) + { + delete label2; + label2 = nullptr; + } + if (label3 != nullptr) + { + delete label3; + label3 = nullptr; + } + if (button3_ != nullptr) + { + delete button3_; + button3_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } + +} \ No newline at end of file