1.添加计时器视图,差最重要的功能未实现
authorluozheng <1732036298@qq.com>
Mon, 8 Apr 2024 08:33:52 +0000 (16:33 +0800)
committerluozheng <1732036298@qq.com>
Mon, 8 Apr 2024 08:33:52 +0000 (16:33 +0800)
2.添加秒表图标和计时器图标,删除不必要图片

25 files changed:
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h
code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp
code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeConfigView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeNotNullView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeNotNullView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_COUNTDOWN.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_STOPWATCH.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_FIVE_MINUTE.bin [deleted file]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_ONE_MINUTE.bin [deleted file]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TEN_MINUTE.bin [deleted file]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_THIRTY_MINUTE.bin [deleted file]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TIMER_ICON.bin [new file with mode: 0644]

index e2ff02f..197ad7b 100644 (file)
@@ -252,6 +252,13 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/src/HeartCardView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/health_service/health_service.cpp
 
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/countdown/src/MainCountDownPresenter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/countdown/src/CountDownModel.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/countdown/src/MainCountDownView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/countdown/src/CountDownTimeConfigView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/countdown/src/CountDownTimeNotNullView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/countdown/src/StartCountDownView.cpp
+
     # 语言切换
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/src/LanguageSwitchListAdapter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/src/LanguageSwitchListitemView.cpp
index 113b71d..45da6f1 100644 (file)
@@ -57,6 +57,7 @@ typedef enum : uint16_t
     VIEW_FIND_PHONE,              // 查找手机
     VIEW_LANGUAGE_SWITCH,         // 语言切换
     VIEW_MAIN_STOPWATCH,          // 秒表
+    VIEW_MAIN_COUNTDOWN,          // 计时器
     /* ----------------------------------- 录音 ----------------------------------- */
     VIEW_RECORD,
     /* ---------------------------------- 界面 ---------------------------------- */
index 830bad2..12e0fd7 100644 (file)
@@ -46,6 +46,7 @@ namespace OHOS
         void InitFindPhoneSlice(void);
         void InitLanguageSwitchSlice(void);
         void InitMainStopWatchSlice(void);
+        void InitMainCountDownSlice(void);
         /* --------------------------------界面------------------------------------ */
         void InitRotateSlice(void);
         void InitBloodSlice(void);
index 61bea2d..ba63c7a 100644 (file)
@@ -220,6 +220,7 @@ namespace OHOS
     static constexpr const char *PNG_APPLIST_TRAINING_IMAGE = APP_RES_PATH "/APPLIST_TRAINING.bin";               // 训练
     static constexpr const char *PNG_APPLIST_TRAINING_RECORD_IMAGE = APP_RES_PATH "/APPLIST_TRAINING_RECORD.bin"; // 训练记录
     static constexpr const char *PNG_APPLIST_STOPWATCH_IMAGE = APP_RES_PATH "/APPLIST_STOPWATCH.bin";             // 秒表
+    static constexpr const char *PNG_APPLIST_COUNTDOWN_IMAGE = APP_RES_PATH "/APPLIST_COUNTDOWN.bin";             // 计时器
     /* ---------------------------------- 快速训练 ---------------------------------- */
     static constexpr const char *PNG_TRAING_BOUTTONMORE_IMAGE = APP_RES_PATH "/Training/More.bin";
     static constexpr const char *PNG_TRAING_BUTTONGRONG_IMAGE = APP_RES_PATH "/Training/Bouttonground.bin";
index ae32d00..cfadc51 100644 (file)
 
 #include "stopwatch/include/MainStopWatchPresenter.h"
 #include "stopwatch/include/MainStopWatchView.h"
+
+#include "countdown/include/MainCountDownPresenter.h"
+#include "countdown/include/MainCountDownView.h"
 /* -------------------------------------------------------------------------- */
 #include "traing/include/TraingView.h"
 #include "traing/include/TraingPresenter.h"
@@ -265,6 +268,8 @@ namespace OHOS
         {VIEW_FIND_PHONE, &NativeLauncher::InitFindPhoneSlice},
         {VIEW_LANGUAGE_SWITCH, &NativeLauncher::InitLanguageSwitchSlice},
         {VIEW_MAIN_STOPWATCH, &NativeLauncher::InitMainStopWatchSlice},
+        {VIEW_MAIN_COUNTDOWN, &NativeLauncher::InitMainCountDownSlice},
+
         {VIEW_MESSAGE, &NativeLauncher::InitMessageSlice},
         {VIEW_ROTATE, &NativeLauncher::InitRotateSlice},
         {VIEW_DIALUPDATE, &NativeLauncher::InitDialUpdateSlice},
@@ -1111,9 +1116,22 @@ namespace OHOS
         SliceProxy *mainstopwatch = new AbilitySliceProxy<MainStopWatchView, MainStopWatchPresenter>;
         if (mainstopwatch == nullptr)
         {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainstopwatch");
             return;
         }
         NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_STOPWATCH, mainstopwatch);
     }
     
+    /*倒计时*/
+    void NativeLauncher::InitMainCountDownSlice(void)
+    {
+        SliceProxy *maincountdown = new AbilitySliceProxy<MainCountDownView, MainCountDownPresenter>;
+        if (maincountdown == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "maincountdown");
+            return;
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_COUNTDOWN, maincountdown);
+    }
+
 }
index 5cfe6b5..661cafe 100644 (file)
@@ -37,6 +37,7 @@ namespace OHOS
         {VIEW_CALLER_LOG, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_CALLLOG_IMAGE, "通话记录", nullptr},
         {VIEW_PHONE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, "电话", nullptr},
         {VIEW_MAIN_STOPWATCH, PNG_APPLIST_STOPWATCH_IMAGE, PNG_APPLIST_STOPWATCH_IMAGE, "秒表", nullptr},
+        {VIEW_MAIN_COUNTDOWN, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_COUNTDOWN_IMAGE, "计时器", nullptr},
         //{VIEW_CONNECT_PHONE, PNG_CONNECT_PHONE_IMAGE, PNG_CONNECT_PHONE_IMAGE, "连接手机", nullptr},
         //{VIEW_LANGUAGE_SWITCH, PNG_CONNECT_PHONE_IMAGE, PNG_CONNECT_PHONE_IMAGE, "语言切换", nullptr},
 #ifdef SUPPORT_ALIPAY_SEC
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h
new file mode 100644 (file)
index 0000000..47b8e6e
--- /dev/null
@@ -0,0 +1,33 @@
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-04-07 18:15:53\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-04-07 21:14:31\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h\r
+ */\r
+#ifndef COUNTDOWN_MODEL_H\r
+#define COUNTDOWN_MODEL_H\r
+\r
+#include <iostream>\r
+namespace OHOS\r
+{\r
+    class CountDownModel\r
+    {\r
+    public:\r
+        \r
+        static CountDownModel *GetInstance(); // shared_ptr:当没有引用指向这个实例时会自动释放内存\r
+        \r
+        void SetCountDownTime(const std::string &countdowntime); // 设置倒计时时间\r
+        std::string GetCountDownTime(void);                      // 获取倒计时时间\r
+        void SetRingTime(const std::string &ringtime);           // 设置响铃时间\r
+        std::string GetRingTime(void);                           // 获取响铃时间\r
+\r
+    private:\r
+        CountDownModel() {}\r
+        ~CountDownModel() {}\r
+\r
+        std::string RingTime{"00:00:00"};  // 响铃时间\r
+        std::string CountTime{"00:00:00"}; // 倒计时时间\r
+    };\r
+}\r
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeConfigView.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeConfigView.h
new file mode 100644 (file)
index 0000000..d225853
--- /dev/null
@@ -0,0 +1,43 @@
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-04-07 18:15:53\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-04-08 10:17:48\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeConfigView.h\r
+ */\r
+#ifndef COUNTDOWN_TIME_CONFIG_VIEW_H\r
+#define COUNTDOWN_TIME_CONFIG_VIEW_H\r
+\r
+#include "BaseView.h"\r
+#include "View.h"\r
+#include "components/ui_view_group.h"\r
+#include "components/ui_scroll_view.h"\r
+#include "components/ui_label_ext.h"\r
+#include "components/ui_time_picker.h"\r
+#include "components/ui_image_view.h"\r
+#include "components/ui_button.h"\r
+/*倒计时时间配置*/\r
+namespace OHOS\r
+{\r
+    static constexpr const char *COLONEIMAGESPATH = "/user/res/countdown/COUNTDOWN_COLONE.bin";                // 冒号图片\r
+    static constexpr const char *START_COUNTDOWN_BUTTON_IMAGEPATH = "/user/res/countdown/COUNTDOWM_PAUSE.bin"; // 开始倒计时按钮图片\r
+    static constexpr const char *STARTCOUNTDOWN_BUTTON = "startCountdownButton";                               // 开始倒计时按钮视图id\r
+    static constexpr const char *COUNTDOWN_TIMECONFIG_VIEW = "CountDownTimeConfigView";\r
+    class CountDownTimeConfigView\r
+    {\r
+    public:\r
+        CountDownTimeConfigView();\r
+        virtual ~CountDownTimeConfigView();\r
+        static CountDownTimeConfigView *GetInstance(void);\r
+        UIScrollView *CountDownTimeConfigViewInit(void);\r
+        void ClearAll(void);\r
+\r
+    private:\r
+        UIScrollView *scrollView = nullptr;\r
+        UILabelExt *Title = nullptr;\r
+        UITimePicker *timePicker = nullptr;\r
+        UIImageView *Img[2]{nullptr};\r
+        UIButton *startCountdownButton{nullptr};\r
+    };\r
+}\r
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeNotNullView.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeNotNullView.h
new file mode 100644 (file)
index 0000000..0e3d777
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-04-07 18:15:53\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-04-08 14:52:37\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownTimeNotNullView.h\r
+ */\r
+#ifndef COUNTDOWN_TIME_NOT_NULL_VIEW_H\r
+#define COUNTDOWN_TIME_NOT_NULL_VIEW_H\r
+\r
+#include "BaseView.h"\r
+#include "View.h"\r
+#include "components/ui_scroll_view.h"\r
+#include "components/ui_label_ext.h"\r
+#include "components/ui_image_view.h"\r
+#include "components/ui_label_button_ext.h"\r
+\r
+/*倒计时时间不能为0*/\r
+namespace OHOS\r
+{\r
+    static constexpr const char *COUNTDOWNTIMENOTNULLVIEWRETURNBUTTON = "ReturnButton"; // 点击该按钮后回到倒计时设置界面\r
+    static constexpr const char *COUNTDOWNTIMENOTNULLVIEW = "CountDownTimeNotNullView";\r
+    class CountDownTimeNotNullView\r
+    {\r
+\r
+    public:\r
+        CountDownTimeNotNullView();\r
+        virtual ~CountDownTimeNotNullView();\r
+        static CountDownTimeNotNullView *GetInstance(void);\r
+        UIScrollView * CountDownTimeNotNullViewInit(void);\r
+        void ClearAll(void);\r
+\r
+    private:\r
+        UIScrollView *scrollView = nullptr;\r
+        UILabelExt *Title = nullptr;\r
+        UIImageView *Attention = nullptr;\r
+        UILabelExt *AttentionLabel = nullptr;\r
+        UILabelButtonExt *button = nullptr;\r
+    };\r
+} // namespace OHOS\r
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownPresenter.h
new file mode 100644 (file)
index 0000000..c3b8ead
--- /dev/null
@@ -0,0 +1,60 @@
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-04-07 18:15:53\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-04-08 14:39:58\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownPresenter.h\r
+ */\r
+#ifndef MAIN_COUNTDOWN_PRESENTER_H\r
+#define MAIN_COUNTDOWN_PRESENTER_H\r
+\r
+#include "View.h"\r
+#include "Presenter.h"\r
+#include "MainCountDownView.h"\r
+\r
+/*倒计时的主界面*/\r
+namespace OHOS\r
+{\r
+    typedef enum\r
+    {\r
+        MAIN_COUNTDOWN = 0,    // 倒计时主视图\r
+        TIMECONFIG_COUNTDOWN,  // 自定义倒计时\r
+        START_COUNTDOWN,       // 开始倒计时\r
+        COUNTDOWN_TIMENOTNULL, // 倒计时时间不能为空\r
+        COUNTDOWN_MAX,\r
+    } CountDownViewId;\r
+\r
+    class MainCountDownView;\r
+    class MainCountDownPresenter : public Presenter<MainCountDownView>,\r
+                                   public UIView::OnClickListener,\r
+                                   public UIView::OnDragListener,\r
+                                   UITimePicker::SelectedListener,\r
+                                   public UICheckBox::OnChangeListener,\r
+                                   public RootView::OnKeyActListener\r
+    {\r
+    public:\r
+        MainCountDownPresenter();\r
+        virtual ~MainCountDownPresenter();\r
+\r
+        void OnStart() override;\r
+        void OnPause() override;\r
+        void OnResume() override;\r
+        void OnStop() override;\r
+\r
+        static MainCountDownPresenter *GetInstance();\r
+\r
+    private:\r
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
+        bool OnClick(UIView &view, const ClickEvent &event) override;\r
+        bool OnDrag(UIView &view, const DragEvent &event) override;\r
+        bool OnDragEnd(UIView &view, const DragEvent &event) override;\r
+        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
+        bool OnChange(UICheckBox::UICheckBoxState state) override;\r
+        void OnTimePickerStoped(UITimePicker &picker) override;\r
+\r
+        std::string countdowntime{0};\r
+        std::string ringtime{0};\r
+    };\r
+}\r
+\r
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownView.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownView.h
new file mode 100644 (file)
index 0000000..2eaf8ca
--- /dev/null
@@ -0,0 +1,83 @@
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-04-07 18:15:53\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-04-08 16:15:10\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/MainCountDownView.h\r
+ */\r
+#ifndef MAIN_COUNTDOWN_VIEW_H\r
+#define MAIN_COUNTDOWN_VIEW_H\r
+\r
+#include "BaseView.h"\r
+#include "View.h"\r
+#include "components/ui_view_group.h"\r
+#include "components/ui_scroll_view.h"\r
+#include "components/ui_label_ext.h"\r
+#include "components/ui_label_button_ext.h"\r
+#include "countdown/include/CountDownTimeConfigView.h"\r
+#include "countdown/include/CountDownTimeNotNullView.h"\r
+#include "countdown/include/StartCountDownView.h"\r
+/*倒计时的主界面*/\r
+namespace OHOS\r
+{\r
+#define CountDownImageSrc "/user/res/countdown/"\r
+\r
+    // 图片路径\r
+    static const char *COUNTDOWM_TIMER_ICON = CountDownImageSrc "COUNTDOWM_TIMER_ICON.bin";\r
+\r
+    // 视图ID\r
+    static constexpr const char *COUNTDOWN_LABELBUTTON_VIEWID = "COUNTDOWN_LABELBUTTON";                   // 自定义时间ID\r
+    static constexpr const char *COUNTDOWN_ONE_MINUTE_BUTTON_VIEWID = "COUNTDOWN_ONE_MINUTE_BUTTON";       // 1分钟\r
+    static constexpr const char *COUNTDOWN_FIVE_MINUTE_BUTTON_VIEWID = "COUNTDOWN_FIVE_MINUTE_BUTTON";     // 5分钟\r
+    static constexpr const char *COUNTDOWN_TEN_MINUTE_BUTTON_VIEWID = "COUNTDOWN_TEN_MINUTE_BUTTON";       // 10分钟\r
+    static constexpr const char *COUNTDOWN_THIRTY_MINUTE_BUTTON_VIEWID = "COUNTDOWN_THIRTY_MINUTE_BUTTON"; // 30 分钟\r
+    static constexpr const char *MAINCOUNTDOWNVIEW = "MainCountDownView";\r
+}\r
+namespace OHOS\r
+{\r
+#define COUNTDOWN_MAX_VIEW 4\r
+\r
+    class MainCountDownPresenter;\r
+    class MainCountDownView : public View<MainCountDownPresenter>\r
+    {\r
+\r
+    public:\r
+        MainCountDownView();\r
+        virtual ~MainCountDownView();\r
+        static MainCountDownView *GetInstance(void);\r
+        bool ClickFunc(int16_t interface);\r
+        void ChangeView(int16_t hideView, int16_t showView);\r
+        bool ChangeMainCountDown(int16_t thisView);\r
+        bool ChangeTimeConfigCountdown(int16_t thisView);\r
+        bool ChangeCountdownTimeNotNull(int16_t thisView);\r
+        bool ChangeStartCountDown(int16_t thisView);\r
+        StartCountDownView *GetStartCountDownView(void);\r
+\r
+    public:\r
+        void OnStart() override;\r
+        void OnSetUpView() override;\r
+        void OnTearDownView() override;\r
+        void OnStop() override;\r
+\r
+    private:\r
+        CountDownTimeConfigView *p_CountDownTimeConfigView{nullptr};\r
+        CountDownTimeNotNullView *p_CountDownTimeNotNullView{nullptr};\r
+        StartCountDownView *p_StartCountDownView{nullptr};\r
+\r
+    private:\r
+        void MainCountDownViewInit(void);\r
+        void ClearAll(void);\r
+        UILabelButtonExt *SetUILabelButton(int x, int y, int w, int h, const char *id, const char *text);\r
+        UIViewGroup *group = nullptr;\r
+        UIScrollView *scrollView[COUNTDOWN_MAX_VIEW]{nullptr};\r
+        UILabelExt *Title{nullptr};\r
+        UILabelExt *QuickStart{nullptr};\r
+        UILabelButtonExt *CUSTOM_COUNTDOWN{nullptr}; // 自定义倒计时\r
+        UILabelButtonExt *COUNTDOWN_ONE_MINUTE_BUTTON = nullptr;\r
+        UILabelButtonExt *COUNTDOWN_FIVE_MINUTE_BUTTON = nullptr;\r
+        UILabelButtonExt *COUNTDOWN_TEN_MINUTE_BUTTON = nullptr;\r
+        UILabelButtonExt *COUNTDOWN_THIRTY_MINUTE_BUTTON = nullptr;\r
+        bool viewInitStatus{false};\r
+    };\r
+} // namespace OHOS\r
+#endif // MainCountDown_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h b/code/sdk/application/wearable/fd230app/nativeui/countdown/include/StartCountDownView.h
new file mode 100644 (file)
index 0000000..b8ac24e
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef START_COUNTDOWN_VIEW_H\r
+#define START_COUNTDOWN_VIEW_H\r
+\r
+#include "BaseView.h"\r
+#include "View.h"\r
+\r
+#include "components/ui_scroll_view.h"\r
+#include "components/ui_label_ext.h"\r
+#include "components/ui_image_view.h"\r
+#include "components/ui_toggle_button.h"\r
+#include "components/ui_button.h"\r
+#include "components/ui_checkbox.h"\r
+\r
+/*开始倒计时*/\r
+namespace OHOS\r
+{\r
+    static constexpr const char *EndButton_ImagePath = "/user/res/countdown/COUNTDOWM_END.bin";         // 结束返回按钮图片\r
+    static constexpr const char *CountDown_Play_ImagePath = "/user/res/countdown/COUNTDOWM_PLAY.bin";   // 开始倒计时image\r
+    static constexpr const char *CountDown_PAUSE_ImagePath = "/user/res/countdown/COUNTDOWM_PAUSE.bin"; // 暂停倒计时image\r
+    static constexpr const char *VectorImagesPath = "/user/res/countdown/COUNTDOWM_VECTOR.bin";\r
+    static constexpr const char *PlayOrPauseToggleButton_ViewID = "PlayOrPauseToggleButton"; // 暂停和开始toggleButton视图id\r
+    static constexpr const char *STARTCOUNTDOWNVIEWRETURNBUTTON = "StartCountDownViewReturnButton";\r
+    static constexpr const char *STARTCOUNTDOWNVIEW = "StartCountDownView";\r
+    class StartCountDownView\r
+    {\r
+\r
+    public:\r
+        StartCountDownView();\r
+        virtual ~StartCountDownView();\r
+        static StartCountDownView *GetInstance(void);\r
+        UIScrollView *StartCountDownViewInit(void);\r
+        void ClearAll(void);\r
+        UILabelExt *GetShowCountDownTimelabel(void); // 获取显示倒计时时间标签\r
+        UILabelExt *GetShowTheRingTimelabel(void);    // 获取显示响铃时间标签\r
+    private:\r
+        UIScrollView *scrollView = nullptr;\r
+        UILabelExt *Title = nullptr;\r
+        UILabelExt *showCountDownTimelabel = nullptr;\r
+        UILabelExt *showTheRingTime = nullptr;\r
+        UIImageView *vectorImage = nullptr;\r
+        UIToggleButton *play_or_pause_toggleButton = nullptr;\r
+        UIButton *endbutton = nullptr;\r
+        bool viewInitStatus{false};\r
+    };\r
+} // namespace OHOS\r
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp
new file mode 100644 (file)
index 0000000..61ad9b7
--- /dev/null
@@ -0,0 +1,82 @@
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-04-07 18:15:53\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-04-07 21:13:35\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp\r
+ */\r
+#include "countdown/include/CountDownModel.h"\r
+#include <sstream>\r
+#include <sstream>\r
+#include <iomanip>\r
+namespace OHOS\r
+{\r
+    /* -------------------------------------------------------------------------- */\r
+    struct Time\r
+    {\r
+        int hour;\r
+        int minute;\r
+        int second;\r
+    };\r
+    // 解析时间字符串并返回 Time 结构体\r
+    static Time ParseTimeString(const std::string &timeString)\r
+    {\r
+        Time time;\r
+\r
+        std::stringstream ss(timeString);\r
+        char delimiter;\r
+\r
+        ss >> time.hour >> delimiter >> time.minute >> delimiter >> time.second;\r
+\r
+        return time;\r
+    }\r
+    // 格式化时间:确保它是 “hh:mm:ss” 格式\r
+    std::string FormatTime(int hours, int minutes, int seconds)\r
+    {\r
+        std::ostringstream oss;\r
+        oss << std::setw(2) << std::setfill('0') << hours << ":"\r
+            << std::setw(2) << std::setfill('0') << minutes << ":"\r
+            << std::setw(2) << std::setfill('0') << seconds;\r
+\r
+        return oss.str();\r
+    }\r
+    /* -------------------------------------------------------------------------- */\r
+    // 定义了 GetInstance() 方法来获取 CountDownModel 的实例,确保只有一个全局实例存在。\r
+    CountDownModel *CountDownModel::GetInstance()\r
+    {\r
+        static CountDownModel instance;\r
+        return &instance;\r
+    }\r
+\r
+    // 设置倒计时时间\r
+    void CountDownModel::SetCountDownTime(const std::string &countdowntime)\r
+    {\r
+        CountTime = countdowntime;\r
+    }\r
+\r
+    // 获取倒计时时间\r
+    std::string CountDownModel::GetCountDownTime(void)\r
+    {\r
+        return CountTime;\r
+    }\r
+\r
+    // 设置响铃时间\r
+    void CountDownModel::SetRingTime(const std::string &ringtime)\r
+    {\r
+        Time time = ParseTimeString(ringtime);\r
+        if (time.hour == 0) // 如果倒计时时间小于一小时就只显示分钟和秒\r
+        {\r
+            std::string rt = ringtime.substr(3, 5); //"00:05:00":从第3个位置开始截图5个字符 ,substr不会修改原来的字符串\r
+            RingTime = rt;\r
+            return;\r
+        }\r
+        RingTime = ringtime;\r
+    }\r
+\r
+    // 获取响铃时间\r
+    std::string CountDownModel::GetRingTime(void)\r
+    {\r
+        return RingTime;\r
+    }\r
+\r
+}\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeConfigView.cpp
new file mode 100644 (file)
index 0000000..ca9fdfc
--- /dev/null
@@ -0,0 +1,165 @@
+#include "countdown/include/CountDownTimeConfigView.h"
+#include "countdown/include/MainCountDownPresenter.h"
+#include "countdown/include/CountDownModel.h"
+#include "UiConfig.h"
+#include "wearable_log.h"
+/*倒计时时间配置*/
+namespace OHOS
+{
+
+    static CountDownTimeConfigView *g_pCountDownTimeConfigView{nullptr};
+
+    CountDownTimeConfigView::CountDownTimeConfigView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CountDownTimeConfigView::CountDownTimeConfigView");
+        g_pCountDownTimeConfigView = this;
+    }
+
+    CountDownTimeConfigView::~CountDownTimeConfigView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CountDownTimeConfigView::~CountDownTimeConfigView");
+        ClearAll();
+        g_pCountDownTimeConfigView = nullptr;
+    }
+
+    CountDownTimeConfigView *CountDownTimeConfigView::GetInstance()
+    {
+        return g_pCountDownTimeConfigView;
+    }
+
+    void CountDownTimeConfigView::ClearAll()
+    {
+        scrollView->RemoveAll();
+
+        if (Title != nullptr)
+        {
+            delete Title;
+            Title = nullptr;
+        }
+
+        if (timePicker != nullptr)
+        {
+            delete timePicker;
+            timePicker = nullptr;
+        }
+
+        for (int i = 0; i < 2; i++)
+        {
+            delete Img[i];
+            Img[i] = nullptr;
+        }
+
+        if (startCountdownButton != nullptr)
+        {
+            delete startCountdownButton;
+            startCountdownButton = nullptr;
+        }
+
+        if (scrollView != nullptr)
+        {
+            delete scrollView;
+            scrollView = nullptr;
+        }
+    }
+
+    UIScrollView *CountDownTimeConfigView::CountDownTimeConfigViewInit()
+    {
+        if (scrollView == nullptr)
+        {
+            scrollView = new UIScrollView();
+            if (scrollView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownTimeConfigView::scrollView is new fail!!");
+                return nullptr;
+            }
+            scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(MainCountDownPresenter::GetInstance());
+            if (dragListener == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is nullptr!!");
+                return nullptr;
+            }
+            scrollView->SetViewId(COUNTDOWN_TIMECONFIG_VIEW);
+            scrollView->SetOnDragListener(dragListener);
+            scrollView->SetHorizontalScrollState(false);
+            scrollView->SetVerticalScrollState(false);
+            /* -------------------------------------------------------------------------- */
+            Title = new UILabelExt();
+            if (Title == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownTimeConfigView::Title is new fail!!");
+                return nullptr;
+            }
+            Title->SetPosition(83, 52, 300, 40);
+            Title->SetStyle(STYLE_TEXT_FONT, 30);
+            Title->SetStyle(STYLE_LINE_HEIGHT, 35);
+            Title->SetText("倒计时");
+            Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+            Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            Title->SetRollSpeed(40);
+            Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            /* -------------------------------------------------------------------------- */
+            timePicker = new UITimePicker();
+            if (timePicker == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownTimeConfigView::timePicker is new fail!!");
+                return nullptr;
+            }
+            timePicker->SetPosition(74, 121, 320, 180);
+            timePicker->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            timePicker->SetStyle(STYLE_BORDER_RADIUS, 51);
+            timePicker->SetItemHeight(60);                                                                                              // 设置时间选择器中每个项目的高度。
+            timePicker->EnableSecond(true);                                                                                             // 设置在时间选择器中启用秒。
+            timePicker->SetSelected(CountDownModel::GetInstance()->GetCountDownTime().c_str());                                         // 设置时间选择器中当前选择的时间。
+            timePicker->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff), Color::GetColorFromRGBA(0xff, 0xa8, 0x00, 0xff)); // 设置时间选择器中的文本颜色。
+            timePicker->SetLoopState(UITimePicker::PickerType::PICKER_HOUR, true);                                                      // 设置是否开启循环 :时
+            timePicker->SetLoopState(UITimePicker::PickerType::PICKER_MIN, true);                                                       // 设置是否开启循环:分
+            timePicker->SetLoopState(UITimePicker::PickerType::PICKER_SEC, true);                                                       // 设置是否开启循环:秒
+            timePicker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, 60);                                                             // 设置突出显示文本的字体名称和大小。
+            timePicker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, 30);                                                            // 设置背景文本的字体名称和大小。
+            UITimePicker::SelectedListener *selectTimeListener =
+                (UITimePicker::SelectedListener *)OHOS::MainCountDownPresenter::GetInstance();
+            timePicker->RegisterSelectedListener(selectTimeListener);
+            /* -------------------------------------------------------------------------- */
+            for (int i = 0; i < 2; i++)
+            {
+                // 计算每个图片的x位置,这里第一张图片的x坐标是 175,第二张图片的x坐标是 280
+                int xpos = (i == 0) ? 175 : 280;
+                Img[i] = new UIImageView();
+                if (Img[i] == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownTimeConfigView::Img[%d] is new fail!!", i);
+                    return nullptr;
+                }
+
+                Img[i]->SetPosition(xpos, 200, 18, 79);
+                Img[i]->SetSrc(COLONEIMAGESPATH);
+            }
+            /* -------------------------------------------------------------------------- */
+            startCountdownButton = new UIButton();
+            if (startCountdownButton == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownTimeConfigView::startCountdownButton is new fail!!");
+                return nullptr;
+            }
+            startCountdownButton->SetPosition(183, 321, 100, 100);
+            startCountdownButton->SetViewId(STARTCOUNTDOWN_BUTTON);
+            startCountdownButton->SetStyle(STYLE_BORDER_RADIUS, 52);
+            startCountdownButton->SetImageSrc(START_COUNTDOWN_BUTTON_IMAGEPATH, START_COUNTDOWN_BUTTON_IMAGEPATH);
+            startCountdownButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffa800, UIButton::PRESSED);
+            startCountdownButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+            startCountdownButton->SetStyleForState(STYLE_BORDER_RADIUS, 52, UIButton::PRESSED);
+            UIView::OnClickListener *start_countdown_button_Click = static_cast<UIView::OnClickListener *>(MainCountDownPresenter::GetInstance());
+            startCountdownButton->SetOnClickListener(start_countdown_button_Click);
+
+            /* ----------------------------------- Add ---------------------------------- */
+            scrollView->Add(Title);
+            scrollView->Add(timePicker);
+            scrollView->Add(Img[0]);
+            scrollView->Add(Img[1]);
+            scrollView->Add(startCountdownButton);
+        }
+        return scrollView;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeNotNullView.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownTimeNotNullView.cpp
new file mode 100644 (file)
index 0000000..dbb2cd9
--- /dev/null
@@ -0,0 +1,133 @@
+#include "countdown/include/CountDownTimeNotNullView.h"\r
+#include "countdown/include/MainCountDownPresenter.h"\r
+#include "UiConfig.h"\r
+#include "wearable_log.h"\r
+/*倒计时时间不能为0*/\r
+namespace OHOS\r
+{\r
+\r
+    static CountDownTimeNotNullView *g_pCountDownTimeNotNullView{nullptr};\r
+\r
+    CountDownTimeNotNullView::CountDownTimeNotNullView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CountDownTimeNotNullView::CountDownTimeNotNullView");\r
+\r
+        g_pCountDownTimeNotNullView = this;\r
+    }\r
+\r
+    CountDownTimeNotNullView::~CountDownTimeNotNullView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CountDownTimeNotNullView::~CountDownTimeNotNullView");\r
+        ClearAll();\r
+        g_pCountDownTimeNotNullView = nullptr;\r
+    }\r
+\r
+    CountDownTimeNotNullView *CountDownTimeNotNullView::GetInstance()\r
+    {\r
+\r
+        return g_pCountDownTimeNotNullView;\r
+    }\r
+\r
+    void CountDownTimeNotNullView::ClearAll()\r
+    {\r
+        scrollView->RemoveAll();\r
+        if (Title != nullptr)\r
+        {\r
+            delete Title;\r
+            Title = nullptr;\r
+        }\r
+        if (Attention != nullptr)\r
+        {\r
+            delete Attention;\r
+            Attention = nullptr;\r
+        }\r
+        if (AttentionLabel != nullptr)\r
+        {\r
+            delete AttentionLabel;\r
+            AttentionLabel = nullptr;\r
+        }\r
+        if (button != nullptr)\r
+        {\r
+            delete button;\r
+            button = nullptr;\r
+        }\r
+        if (scrollView != nullptr)\r
+        {\r
+            delete scrollView;\r
+            scrollView = nullptr;\r
+        }\r
+    }\r
+\r
+    UIScrollView *CountDownTimeNotNullView::CountDownTimeNotNullViewInit()\r
+    {\r
+        if (scrollView == nullptr)\r
+        {\r
+            scrollView = new UIScrollView();\r
+            scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+            scrollView->SetViewId(COUNTDOWNTIMENOTNULLVIEW);\r
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+            /* -------------------------------------------------------------------------- */\r
+            Title = new UILabelExt();\r
+            if (Title == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownTimeNotNullView::Title is new fail!!");\r
+                return nullptr;\r
+            }\r
+            Title->SetPosition(83, 52, 300, 40);\r
+            Title->SetStyle(STYLE_TEXT_FONT, 30);\r
+            Title->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+            Title->SetText("倒计时");\r
+            Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+            Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+            Title->SetRollSpeed(40);\r
+            Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+            /* -------------------------------------------------------------------------- */\r
+            Attention = new UIImageView();\r
+            if (Attention == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownTimeNotNullView::Attention is new fail!!");\r
+                return nullptr;\r
+            }\r
+            Attention->SetPosition(193, 121, 80, 80);\r
+            Attention->SetStyle(STYLE_BORDER_RADIUS, 100);\r
+            Attention->SetSrc(PNG_ATTENTION_IMAGE);\r
+            /* -------------------------------------------------------------------------- */\r
+            AttentionLabel = new UILabelExt();\r
+            if (AttentionLabel == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownTimeNotNullView::AttentionLabel is new fail!!");\r
+                return nullptr;\r
+            }\r
+            AttentionLabel->SetPosition(33, 253, 400, 40);\r
+            AttentionLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
+            AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+            AttentionLabel->SetText("请先设置好倒计时间");\r
+            AttentionLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+            AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+            AttentionLabel->SetRollSpeed(40);\r
+            AttentionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+            /* -------------------------------------------------------------------------- */\r
+            if (button == nullptr)\r
+            {\r
+                button = new UILabelButtonExt();\r
+            }\r
+            button->SetPosition(0, 366, 466, 100);\r
+            button->SetViewId(COUNTDOWNTIMENOTNULLVIEWRETURNBUTTON);\r
+            button->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE);\r
+            button->SetText("知道了");\r
+            button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+            button->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+            button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);\r
+            UIView::OnClickListener *buttonClick = static_cast<UIView::OnClickListener *>(MainCountDownPresenter::GetInstance());\r
+            button->SetOnClickListener(buttonClick);\r
+            /* ----------------------------------- Add ---------------------------------- */\r
+            scrollView->Add(Title);\r
+            scrollView->Add(Attention);\r
+            scrollView->Add(AttentionLabel);\r
+            scrollView->Add(button);\r
+        }\r
+\r
+        return scrollView;\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownPresenter.cpp
new file mode 100644 (file)
index 0000000..0d96461
--- /dev/null
@@ -0,0 +1,209 @@
+#include "AppViewIDs.h"\r
+#include "NativeAbility.h"\r
+#include "countdown/include/MainCountDownPresenter.h"\r
+#include "countdown/include/CountDownModel.h"\r
+#include "common/key_code.h"\r
+#include <custom_utils.h>\r
+/*倒计时的主界面*/\r
+\r
+namespace OHOS\r
+{\r
+    static constexpr const char *OneMinuteTime = "00:01:00";    // 1分钟\r
+    static constexpr const char *FiveMinuteTime = "00:05:00";   // 5分钟\r
+    static constexpr const char *TenMinuteTime = "00:10:00";    // 10分钟\r
+    static constexpr const char *ThirtyMinuteTime = "00:30:00"; // 30分钟\r
+\r
+    // 当前Presenter属性实例化的内存指针\r
+    static MainCountDownPresenter *g_pMainCountDownPresenter = nullptr;\r
+\r
+    MainCountDownPresenter::MainCountDownPresenter()\r
+    {\r
+\r
+        g_pMainCountDownPresenter = this;\r
+    }\r
+\r
+    MainCountDownPresenter::~MainCountDownPresenter()\r
+    {\r
+\r
+        g_pMainCountDownPresenter = nullptr;\r
+    }\r
+\r
+    MainCountDownPresenter *MainCountDownPresenter::GetInstance()\r
+    {\r
+\r
+        return g_pMainCountDownPresenter;\r
+    }\r
+\r
+    void MainCountDownPresenter::OnStart()\r
+    {\r
+\r
+        Presenter<MainCountDownView>::OnStart();\r
+    }\r
+\r
+    void MainCountDownPresenter::OnPause(void)\r
+    {\r
+\r
+        Presenter<MainCountDownView>::OnPause();\r
+    }\r
+\r
+    void MainCountDownPresenter::OnResume(void)\r
+    {\r
+\r
+        Presenter<MainCountDownView>::OnResume();\r
+    }\r
+\r
+    void MainCountDownPresenter::OnStop(void)\r
+    {\r
+\r
+        Presenter<MainCountDownView>::OnStop();\r
+    }\r
+\r
+    bool MainCountDownPresenter::OnDrag(UIView &view, const DragEvent &event)\r
+    {\r
+        UNUSED(view);\r
+        UNUSED(event);\r
+        return true;\r
+    }\r
+\r
+    bool MainCountDownPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
+    {\r
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && strcmp(view.GetViewId(), MAINCOUNTDOWNVIEW) == 0)\r
+        {\r
+            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);\r
+        }\r
+        else if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && strcmp(view.GetViewId(), COUNTDOWN_TIMECONFIG_VIEW) == 0)\r
+        {\r
+            MainCountDownView::GetInstance()->ChangeView(TIMECONFIG_COUNTDOWN, MAIN_COUNTDOWN);\r
+        }\r
+        return true;\r
+    }\r
+\r
+    static bool SetCountDownAndChangeView(MainCountDownView *p_MainCountDownView, const std::string &timeValue)\r
+    {\r
+        CountDownModel *model = CountDownModel::GetInstance();\r
+        model->SetCountDownTime(timeValue);\r
+        model->SetRingTime(timeValue);\r
+\r
+        // Update label texts if necessary\r
+        if (p_MainCountDownView->GetStartCountDownView() != nullptr)\r
+        {\r
+            p_MainCountDownView->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText(timeValue.c_str());\r
+            p_MainCountDownView->GetStartCountDownView()->GetShowTheRingTimelabel()->SetText(timeValue.c_str());\r
+        }\r
+\r
+        p_MainCountDownView->ChangeView(MAIN_COUNTDOWN, START_COUNTDOWN);\r
+        return true;\r
+    }\r
+\r
+    bool MainCountDownPresenter::OnClick(UIView &view, const ClickEvent &event)\r
+    {\r
+        UNUSED(event);\r
+        MainCountDownView *p_MainCountDownView = MainCountDownView::GetInstance();\r
+        if (p_MainCountDownView == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCountDownView::GetInstance fail!!");\r
+            return false;\r
+        }\r
+\r
+        if (strcmp(view.GetViewId(), COUNTDOWN_LABELBUTTON_VIEWID) == 0)\r
+        {\r
+            p_MainCountDownView->ChangeView(MAIN_COUNTDOWN, TIMECONFIG_COUNTDOWN);\r
+            return true;\r
+        }\r
+\r
+        /*四个快速开始倒计时按钮*/\r
+        if (strcmp(view.GetViewId(), COUNTDOWN_ONE_MINUTE_BUTTON_VIEWID) == 0)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "COUNTDOWN_ONE_MINUTE_BUTTON_VIEWID");\r
+            return SetCountDownAndChangeView(p_MainCountDownView, OneMinuteTime);\r
+        }\r
+        else if (strcmp(view.GetViewId(), COUNTDOWN_FIVE_MINUTE_BUTTON_VIEWID) == 0)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "COUNTDOWN_FIVE_MINUTE_BUTTON_VIEWID");\r
+            return SetCountDownAndChangeView(p_MainCountDownView, FiveMinuteTime);\r
+        }\r
+        else if (strcmp(view.GetViewId(), COUNTDOWN_TEN_MINUTE_BUTTON_VIEWID) == 0)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "COUNTDOWN_TEN_MINUTE_BUTTON_VIEWID");\r
+            return SetCountDownAndChangeView(p_MainCountDownView, TenMinuteTime);\r
+        }\r
+        else if (strcmp(view.GetViewId(), COUNTDOWN_THIRTY_MINUTE_BUTTON_VIEWID) == 0)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "COUNTDOWN_THIRTY_MINUTE_BUTTON_VIEWID");\r
+            return SetCountDownAndChangeView(p_MainCountDownView, ThirtyMinuteTime);\r
+        }\r
+\r
+        if (strcmp(view.GetViewId(), STARTCOUNTDOWN_BUTTON) == 0) // 在自定义倒计时界面点击开始按钮跳转到开始倒计时界面\r
+        {\r
+            if (strcmp(CountDownModel::GetInstance()->GetCountDownTime().c_str(), "00:00:00") == 0)\r
+            {\r
+                p_MainCountDownView->ChangeView(TIMECONFIG_COUNTDOWN, COUNTDOWN_TIMENOTNULL);\r
+                return true;\r
+            }\r
+            else\r
+            {\r
+                if (p_MainCountDownView->GetStartCountDownView() != nullptr)\r
+                {\r
+                    p_MainCountDownView->GetStartCountDownView()->GetShowCountDownTimelabel()->SetText(CountDownModel::GetInstance()->GetCountDownTime().c_str());\r
+                    p_MainCountDownView->GetStartCountDownView()->GetShowTheRingTimelabel()->SetText(CountDownModel::GetInstance()->GetRingTime().c_str());\r
+                }\r
+\r
+                p_MainCountDownView->ChangeView(TIMECONFIG_COUNTDOWN, START_COUNTDOWN);\r
+                return true;\r
+            }\r
+        }\r
+\r
+        if (strcmp(view.GetViewId(), COUNTDOWNTIMENOTNULLVIEWRETURNBUTTON) == 0) // 从倒计时不为空视图退到自定义倒计时界面\r
+        {\r
+            p_MainCountDownView->ChangeView(COUNTDOWN_TIMENOTNULL, TIMECONFIG_COUNTDOWN);\r
+            return true;\r
+        }\r
+\r
+        if (strcmp(view.GetViewId(), STARTCOUNTDOWNVIEWRETURNBUTTON) == 0) // 从开始倒计时视图退到倒计时主视图\r
+        {\r
+            CountDownModel::GetInstance()->SetCountDownTime("00:00:00");\r
+            CountDownModel::GetInstance()->SetRingTime("");\r
+            p_MainCountDownView->ChangeView(START_COUNTDOWN, MAIN_COUNTDOWN);\r
+            return true;\r
+        }\r
+        return true;\r
+    }\r
+\r
+    // 增加按键事件\r
+    bool MainCountDownPresenter::OnKeyAct(UIView &view, const KeyEvent &event)\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCountDownPresenter::OnKeyAct");\r
+        uint16_t keyID = event.GetKeyId();\r
+        uint16_t keyState = event.GetState();\r
+        // 如果是power键就返回上一级\r
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)\r
+        {\r
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();\r
+            NativeAbility::GetInstance().ChangeSlice(preSlice);\r
+        }\r
+        return true;\r
+    }\r
+\r
+    bool MainCountDownPresenter::OnChange(UICheckBox::UICheckBoxState state)\r
+    {\r
+        switch (state)\r
+        {\r
+        case UICheckBox::SELECTED:\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "start countdown...");\r
+\r
+        case UICheckBox::UNSELECTED:\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "countdown pause...");\r
+            break;\r
+        default:\r
+            break;\r
+        }\r
+        return true;\r
+    }\r
+\r
+    void MainCountDownPresenter::OnTimePickerStoped(UITimePicker &picker)\r
+    {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "picker.GetSelectValue = %s", picker.GetSelectValue());\r
+        CountDownModel::GetInstance()->SetCountDownTime(picker.GetSelectValue()); // 设置倒计时时间\r
+        CountDownModel::GetInstance()->SetRingTime(picker.GetSelectValue());      // 设置响铃时间\r
+    }\r
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/MainCountDownView.cpp
new file mode 100644 (file)
index 0000000..4b47462
--- /dev/null
@@ -0,0 +1,402 @@
+#include "countdown/include/MainCountDownView.h"\r
+#include "countdown/include/MainCountDownPresenter.h"\r
+#include "wearable_log.h"\r
+#include "common/image_cache_manager.h"\r
+/*倒计时的主界面*/\r
+namespace OHOS\r
+{\r
+#define VISIBLE_XBAR(visible)\r
+\r
+    static MainCountDownView *g_pMainCountDownView{nullptr};\r
+\r
+    MainCountDownView::MainCountDownView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCountDownView::MainCountDownView");\r
+        g_pMainCountDownView = this;\r
+    }\r
+\r
+    MainCountDownView::~MainCountDownView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCountDownView::~MainCountDownView");\r
+        ClearAll();\r
+        g_pMainCountDownView = nullptr;\r
+    }\r
+\r
+    MainCountDownView *MainCountDownView::GetInstance()\r
+    {\r
+        return g_pMainCountDownView;\r
+    }\r
+\r
+    void MainCountDownView::ClearAll()\r
+    {\r
+        group->RemoveAll();\r
+        scrollView[MAIN_COUNTDOWN]->RemoveAll();\r
+        ImageCacheManager::GetInstance().UnloadSingleRes(COUNTDOWM_TIMER_ICON);\r
+\r
+        if (Title != nullptr)\r
+        {\r
+            delete Title;\r
+            Title = nullptr;\r
+        }\r
+\r
+        if (QuickStart != nullptr)\r
+        {\r
+            delete QuickStart;\r
+            QuickStart = nullptr;\r
+        }\r
+\r
+        if (CUSTOM_COUNTDOWN != nullptr)\r
+        {\r
+            delete CUSTOM_COUNTDOWN;\r
+            CUSTOM_COUNTDOWN = nullptr;\r
+        }\r
+\r
+        if (COUNTDOWN_ONE_MINUTE_BUTTON != nullptr)\r
+        {\r
+            delete COUNTDOWN_ONE_MINUTE_BUTTON;\r
+            COUNTDOWN_ONE_MINUTE_BUTTON = nullptr;\r
+        }\r
+\r
+        if (COUNTDOWN_FIVE_MINUTE_BUTTON != nullptr)\r
+        {\r
+            delete COUNTDOWN_FIVE_MINUTE_BUTTON;\r
+            COUNTDOWN_FIVE_MINUTE_BUTTON = nullptr;\r
+        }\r
+\r
+        if (COUNTDOWN_TEN_MINUTE_BUTTON != nullptr)\r
+        {\r
+            delete COUNTDOWN_TEN_MINUTE_BUTTON;\r
+            COUNTDOWN_TEN_MINUTE_BUTTON = nullptr;\r
+        }\r
+\r
+        if (COUNTDOWN_THIRTY_MINUTE_BUTTON != nullptr)\r
+        {\r
+            delete COUNTDOWN_THIRTY_MINUTE_BUTTON;\r
+            COUNTDOWN_THIRTY_MINUTE_BUTTON = nullptr;\r
+        }\r
+\r
+        if (p_CountDownTimeConfigView != nullptr)\r
+        {\r
+            delete p_CountDownTimeConfigView;\r
+            p_CountDownTimeConfigView = nullptr;\r
+        }\r
+\r
+        if (p_CountDownTimeNotNullView != nullptr)\r
+        {\r
+            delete p_CountDownTimeNotNullView;\r
+            p_CountDownTimeNotNullView = nullptr;\r
+        }\r
+\r
+        if (p_StartCountDownView != nullptr)\r
+        {\r
+            delete p_StartCountDownView;\r
+            p_StartCountDownView = nullptr;\r
+        }\r
+\r
+        if (scrollView[MAIN_COUNTDOWN] != nullptr)\r
+        {\r
+            delete scrollView[MAIN_COUNTDOWN];\r
+            scrollView[MAIN_COUNTDOWN] = nullptr;\r
+        }\r
+\r
+        if (group != nullptr)\r
+        {\r
+            delete group;\r
+            group = nullptr;\r
+        }\r
+    }\r
+\r
+    void MainCountDownView::MainCountDownViewInit()\r
+    {\r
+        if (group == nullptr)\r
+        {\r
+            /* ---------------------------------- group --------------------------------- */\r
+            group = new UIViewGroup();\r
+            group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+            UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(MainCountDownPresenter::GetInstance());\r
+            if (draglistener == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "draglistener is nullptr!!");\r
+                return;\r
+            }\r
+            group->SetOnDragListener(draglistener);\r
+            group->SetTouchable(true);\r
+            group->SetDraggable(true);\r
+            /* ----------------------- scrollView[MAIN_COUNTDOWN] ----------------------- */\r
+            scrollView[MAIN_COUNTDOWN] = new UIScrollView();\r
+            if (scrollView[MAIN_COUNTDOWN] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollView[MAIN_COUNTDOWN] is new fail!!");\r
+                return;\r
+            }\r
+            scrollView[MAIN_COUNTDOWN]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+            scrollView[MAIN_COUNTDOWN]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+            scrollView[MAIN_COUNTDOWN]->SetViewId(MAINCOUNTDOWNVIEW);\r
+            scrollView[MAIN_COUNTDOWN]->SetReboundSize(50);              // 设置回弹大小\r
+            scrollView[MAIN_COUNTDOWN]->SetHorizontalScrollState(false); // 设置横向不可以滚动\r
+            scrollView[MAIN_COUNTDOWN]->SetScrollBlankSize(50);          // 设置高位50可滑动空白区域\r
+            /* ---------------------------------- Title --------------------------------- */\r
+            Title = new UILabelExt();\r
+            if (Title == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Title is new fail!!");\r
+                return;\r
+            }\r
+            Title->SetPosition(83, 55, 300, 40);\r
+            Title->SetStyle(STYLE_TEXT_FONT, 30);\r
+            Title->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+            Title->SetText("倒计时");\r
+            Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+            Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+            Title->SetRollSpeed(40);\r
+            Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+            /* -------------------------- CUSTOM_COUNTDOWN ------------------------- */\r
+            CUSTOM_COUNTDOWN = new UILabelButtonExt();\r
+            if (CUSTOM_COUNTDOWN == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CUSTOM_COUNTDOWN is new fail!!");\r
+                return;\r
+            }\r
+            CUSTOM_COUNTDOWN->SetPosition(43, 130, 380, 100);\r
+            CUSTOM_COUNTDOWN->SetViewId(COUNTDOWN_LABELBUTTON_VIEWID);\r
+            CUSTOM_COUNTDOWN->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffa800);\r
+            CUSTOM_COUNTDOWN->SetStyle(STYLE_BORDER_RADIUS, 100);\r
+            CUSTOM_COUNTDOWN->SetText("自定义时间");\r
+            CUSTOM_COUNTDOWN->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+            CUSTOM_COUNTDOWN->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+            CUSTOM_COUNTDOWN->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffa800, UIButton::PRESSED);\r
+            /* ------------------------------- QuickStart ------------------------------- */\r
+            QuickStart = new UILabelExt();\r
+            if (QuickStart == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickStart is new fail!!");\r
+                return;\r
+            }\r
+            QuickStart->SetPosition(83, 270, 300, 40);\r
+            QuickStart->SetStyle(STYLE_TEXT_FONT, 30);\r
+            QuickStart->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+            QuickStart->SetText("快速开始");\r
+            QuickStart->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+            QuickStart->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+            QuickStart->SetRollSpeed(40);\r
+            QuickStart->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+            /* ----------------------- COUNTDOWN_ONE_MINUTE_BUTTON ---------------------- */\r
+            COUNTDOWN_ONE_MINUTE_BUTTON = SetUILabelButton(43, 345, 180, 150, COUNTDOWN_ONE_MINUTE_BUTTON_VIEWID, "1分钟");\r
+            if (COUNTDOWN_ONE_MINUTE_BUTTON == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "COUNTDOWN_ONE_MINUTE_BUTTON is new fail!!");\r
+                return;\r
+            }\r
+            /* ---------------------- COUNTDOWN_FIVE_MINUTE_BUTTON ---------------------- */\r
+            COUNTDOWN_FIVE_MINUTE_BUTTON = SetUILabelButton(243, 345, 180, 150, COUNTDOWN_FIVE_MINUTE_BUTTON_VIEWID, "5分钟");\r
+            if (COUNTDOWN_FIVE_MINUTE_BUTTON == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "COUNTDOWN_FIVE_MINUTE_BUTTON is new fail!!");\r
+                return;\r
+            }\r
+            /* ----------------------- COUNTDOWN_TEN_MINUTE_BUTTON ---------------------- */\r
+            COUNTDOWN_TEN_MINUTE_BUTTON = SetUILabelButton(43, 515, 180, 150, COUNTDOWN_TEN_MINUTE_BUTTON_VIEWID, "10分钟");\r
+            if (COUNTDOWN_TEN_MINUTE_BUTTON == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "COUNTDOWN_TEN_MINUTE_BUTTON is new fail!!");\r
+                return;\r
+            }\r
+            /* --------------------- COUNTDOWN_THIRTY_MINUTE_BUTTON --------------------- */\r
+            COUNTDOWN_THIRTY_MINUTE_BUTTON = SetUILabelButton(243, 515, 180, 150, COUNTDOWN_THIRTY_MINUTE_BUTTON_VIEWID, "30分钟");\r
+            if (COUNTDOWN_THIRTY_MINUTE_BUTTON == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "COUNTDOWN_THIRTY_MINUTE_BUTTON is new fail!!");\r
+                return;\r
+            }\r
+            /* -------------------------------------------------------------------------- */\r
+            UIView::OnClickListener *ButtonOnClick = static_cast<UIView::OnClickListener *>(MainCountDownPresenter::GetInstance());\r
+            CUSTOM_COUNTDOWN->SetOnClickListener(ButtonOnClick);\r
+            COUNTDOWN_ONE_MINUTE_BUTTON->SetOnClickListener(ButtonOnClick);\r
+            COUNTDOWN_FIVE_MINUTE_BUTTON->SetOnClickListener(ButtonOnClick);\r
+            COUNTDOWN_TEN_MINUTE_BUTTON->SetOnClickListener(ButtonOnClick);\r
+            COUNTDOWN_THIRTY_MINUTE_BUTTON->SetOnClickListener(ButtonOnClick);\r
+        }\r
+    }\r
+\r
+    UILabelButtonExt *MainCountDownView::SetUILabelButton(int x, int y, int w, int h, const char *id, const char *text)\r
+    {\r
+        UILabelButtonExt *button = new UILabelButtonExt();\r
+        if (button == nullptr)\r
+        {\r
+            return nullptr;\r
+        }\r
+        button->SetPosition(x, y, w, h);\r
+        button->SetViewId(id);\r
+        button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+        button->SetStyle(STYLE_BORDER_RADIUS, 50);\r
+        button->SetImagePosition(72, 30);\r
+        ImageInfo *img = ImageCacheManager::GetInstance().LoadSingleRes(COUNTDOWM_TIMER_ICON);\r
+        button->SetImageSrc(img, img);\r
+        button->SetText(text);\r
+        button->SetAlign(TEXT_ALIGNMENT_LEFT);\r
+        button->SetLabelPosition(51, 61);\r
+        button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        button->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+        button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffa800, UIButton::PRESSED);\r
+        button->SetStyleForState(STYLE_BORDER_RADIUS, 50, UIButton::PRESSED);\r
+        return button;\r
+    }\r
+\r
+    StartCountDownView *MainCountDownView::GetStartCountDownView(void)\r
+    {\r
+        return p_StartCountDownView;\r
+    }\r
+\r
+    /*1.切换到主倒计时视图*/\r
+    bool MainCountDownView::ChangeMainCountDown(int16_t thisView)\r
+    {\r
+        if (scrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCountDownView::ChangeMainCountDown");\r
+            group->Add(scrollView[thisView]);\r
+        }\r
+        return true;\r
+    }\r
+\r
+    /*2.切换到自定义倒计时界面*/\r
+    bool MainCountDownView::ChangeTimeConfigCountdown(int16_t thisView)\r
+    {\r
+        if (scrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCountDownView::ChangeTimeConfigCountdown");\r
+            p_CountDownTimeConfigView = new CountDownTimeConfigView();\r
+            if (p_CountDownTimeConfigView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCountDownView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
+            }\r
+            scrollView[thisView] = p_CountDownTimeConfigView->CountDownTimeConfigViewInit();\r
+            group->Add(scrollView[thisView]);\r
+        }\r
+        return true;\r
+    }\r
+\r
+    /*3.开始倒计时*/\r
+    bool MainCountDownView::ChangeStartCountDown(int16_t thisView)\r
+    {\r
+        if (scrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCountDownView::ChangeCountdownTimeNotNull");\r
+            p_StartCountDownView = new StartCountDownView();\r
+            if (p_StartCountDownView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCountDownView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
+            }\r
+            scrollView[thisView] = p_StartCountDownView->StartCountDownViewInit();\r
+            group->Add(scrollView[thisView]);\r
+        }\r
+        return true;\r
+    }\r
+\r
+    /*4.切换到倒计时不能为空界面*/\r
+    bool MainCountDownView::ChangeCountdownTimeNotNull(int16_t thisView)\r
+    {\r
+        if (scrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainCountDownView::ChangeCountdownTimeNotNull");\r
+            p_CountDownTimeNotNullView = new CountDownTimeNotNullView();\r
+            if (p_CountDownTimeNotNullView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCountDownView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
+            }\r
+            scrollView[thisView] = p_CountDownTimeNotNullView->CountDownTimeNotNullViewInit();\r
+            group->Add(scrollView[thisView]);\r
+        }\r
+        return true;\r
+    }\r
+\r
+    /* -------------------------------------------------------------------------- */\r
+    // 1.MainCountDownViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。\r
+    struct MainCountDownViewMapper\r
+    {\r
+        const int16_t viewId;\r
+        bool (MainCountDownView::*func)(int16_t thisView);\r
+    };\r
+\r
+    // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainCountDownView类中的特定成员函数指针进行了绑定。\r
+    static const MainCountDownViewMapper ViewMapper[] = {\r
+        {MAIN_COUNTDOWN, &MainCountDownView::ChangeMainCountDown},\r
+        {TIMECONFIG_COUNTDOWN, &MainCountDownView::ChangeTimeConfigCountdown},\r
+        {START_COUNTDOWN, &MainCountDownView::ChangeStartCountDown},\r
+        {COUNTDOWN_TIMENOTNULL, &MainCountDownView::ChangeCountdownTimeNotNull},\r
+    };\r
+\r
+    // 3.根据传入的interface参数执行相应视图ID关联的成员函数。\r
+    bool MainCountDownView::ClickFunc(int16_t interface)\r
+    {\r
+        int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);\r
+        for (int i = 0; i < funcSize; i++)\r
+        {\r
+            if (interface == ViewMapper[i].viewId)\r
+            {\r
+                bool jug = (this->*(ViewMapper[i].func))(interface);\r
+                if (jug == false)\r
+                {\r
+                    return false;\r
+                }\r
+                return true;\r
+            }\r
+        }\r
+        return false;\r
+    }\r
+\r
+    // 4.切换视图\r
+    void MainCountDownView::ChangeView(int16_t hideView, int16_t showView)\r
+    {\r
+        if (hideView > COUNTDOWN_MAX)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainCountDownView:: CountDownViewId Overstep ones bounds");\r
+            return;\r
+        }\r
+        scrollView[hideView]->SetVisible(false);\r
+        ClickFunc(showView);\r
+        scrollView[showView]->SetVisible(true);\r
+        Draw();\r
+    }\r
+    /* -------------------------------------------------------------------------- */\r
+\r
+    void MainCountDownView::OnStart()\r
+    {\r
+        View<MainCountDownPresenter>::OnStart();\r
+        MainCountDownViewInit();\r
+        // 增加按键监听\r
+        RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MainCountDownPresenter::GetInstance();\r
+        RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
+    }\r
+\r
+    void MainCountDownView::OnSetUpView()\r
+    {\r
+        View<MainCountDownPresenter>::OnSetUpView();\r
+        scrollView[MAIN_COUNTDOWN]->Add(Title);\r
+        scrollView[MAIN_COUNTDOWN]->Add(CUSTOM_COUNTDOWN);\r
+        scrollView[MAIN_COUNTDOWN]->Add(QuickStart);\r
+        scrollView[MAIN_COUNTDOWN]->Add(COUNTDOWN_ONE_MINUTE_BUTTON);\r
+        scrollView[MAIN_COUNTDOWN]->Add(COUNTDOWN_FIVE_MINUTE_BUTTON);\r
+        scrollView[MAIN_COUNTDOWN]->Add(COUNTDOWN_TEN_MINUTE_BUTTON);\r
+        scrollView[MAIN_COUNTDOWN]->Add(COUNTDOWN_THIRTY_MINUTE_BUTTON);\r
+        group->Add(scrollView[MAIN_COUNTDOWN]);\r
+        RootView::GetInstance()->Add(group);\r
+        Draw();\r
+    }\r
+\r
+    void MainCountDownView::OnTearDownView()\r
+    {\r
+        View<MainCountDownPresenter>::OnTearDownView();\r
+        return;\r
+    }\r
+\r
+    void MainCountDownView::OnStop()\r
+    {\r
+        View<MainCountDownPresenter>::OnStop();\r
+        RootView::GetInstance()->ClearOnKeyActListener();\r
+        RootView::GetInstance()->RemoveAll();\r
+        return;\r
+    }\r
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/StartCountDownView.cpp
new file mode 100644 (file)
index 0000000..4f4bb9a
--- /dev/null
@@ -0,0 +1,190 @@
+#include "countdown/include/StartCountDownView.h"\r
+#include "countdown/include/MainCountDownPresenter.h"\r
+#include "countdown/include/CountDownModel.h"\r
+#include "UiConfig.h"\r
+#include "wearable_log.h"\r
+\r
+/*开始倒计时*/\r
+namespace OHOS\r
+{\r
+\r
+    static StartCountDownView *g_pStartCountDownView{nullptr};\r
+\r
+    StartCountDownView::StartCountDownView()\r
+    {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountDownView::StartCountDownView");\r
+        g_pStartCountDownView = this;\r
+    }\r
+\r
+    StartCountDownView::~StartCountDownView()\r
+    {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartCountDownView::~StartCountDownView");\r
+        ClearAll();\r
+        g_pStartCountDownView = nullptr;\r
+    }\r
+\r
+    StartCountDownView *StartCountDownView::GetInstance()\r
+    {\r
+        return g_pStartCountDownView;\r
+    }\r
+\r
+    void StartCountDownView::ClearAll()\r
+    {\r
+        scrollView->RemoveAll();\r
+\r
+        if (Title != nullptr)\r
+        {\r
+            delete Title;\r
+            Title = nullptr;\r
+        }\r
+\r
+        if (showCountDownTimelabel != nullptr)\r
+        {\r
+            delete showCountDownTimelabel;\r
+            showCountDownTimelabel = nullptr;\r
+        }\r
+\r
+        if (vectorImage != nullptr)\r
+        {\r
+            delete vectorImage;\r
+            vectorImage = nullptr;\r
+        }\r
+        if (showTheRingTime != nullptr)\r
+        {\r
+            delete showTheRingTime;\r
+            showTheRingTime = nullptr;\r
+        }\r
+\r
+        if (play_or_pause_toggleButton != nullptr)\r
+        {\r
+            delete play_or_pause_toggleButton;\r
+            play_or_pause_toggleButton = nullptr;\r
+        }\r
+\r
+        if (endbutton != nullptr)\r
+        {\r
+            delete endbutton;\r
+            endbutton = nullptr;\r
+        }\r
+\r
+        if (scrollView != nullptr)\r
+        {\r
+            delete scrollView;\r
+            scrollView = nullptr;\r
+        }\r
+    }\r
+\r
+    UIScrollView *StartCountDownView::StartCountDownViewInit()\r
+    {\r
+        if (scrollView == nullptr)\r
+        {\r
+            scrollView = new UIScrollView();\r
+            scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+            scrollView->SetViewId(STARTCOUNTDOWNVIEW);\r
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+            /* -------------------------------------------------------------------------- */\r
+            Title = new UILabelExt();\r
+            if (Title == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownTimeNotNullView::Title is  is new fail!!");\r
+                return nullptr;\r
+            }\r
+            Title->SetPosition(83, 52, 300, 40);\r
+            Title->SetStyle(STYLE_TEXT_FONT, 30);\r
+            Title->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+            Title->SetText("倒计时");\r
+            Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);\r
+            Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+            Title->SetRollSpeed(40);\r
+            Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+            /* -------------------------------------------------------------------------- */\r
+            showCountDownTimelabel = new UILabelExt();\r
+            if (showCountDownTimelabel == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showCountDownTimelabel  is new fail!!");\r
+                return nullptr;\r
+            }\r
+            showCountDownTimelabel->SetPosition(73, 138);\r
+            showCountDownTimelabel->SetStyle(STYLE_TEXT_FONT, 80);\r
+            showCountDownTimelabel->SetStyle(STYLE_LINE_HEIGHT, 94);\r
+            showCountDownTimelabel->SetText(CountDownModel::GetInstance()->GetCountDownTime().c_str());\r
+            showCountDownTimelabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+            showCountDownTimelabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+            showCountDownTimelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 84);\r
+            /* -------------------------------------------------------------------------- */\r
+            vectorImage = new UIImageView();\r
+            if (vectorImage == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "vectorImage  is new fail!!");\r
+                return nullptr;\r
+            }\r
+            vectorImage->SetPosition(174, 247, 28, 28);\r
+            vectorImage->SetSrc(VectorImagesPath);\r
+            /* -------------------------------------------------------------------------- */\r
+            showTheRingTime = new UILabelExt();\r
+            if (showTheRingTime == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showTheRingTime  is new fail!!");\r
+                return nullptr;\r
+            }\r
+            showTheRingTime->SetPosition(209, 241, 84, 41);\r
+            showTheRingTime->SetStyle(STYLE_TEXT_FONT, 35);\r
+            showTheRingTime->SetStyle(STYLE_LINE_HEIGHT, 41);\r
+            showTheRingTime->SetText(CountDownModel::GetInstance()->GetRingTime().c_str());\r
+            showTheRingTime->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+            showTheRingTime->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));\r
+            showTheRingTime->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+            showTheRingTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35);\r
+            /* -------------------------------------------------------------------------- */\r
+            if (play_or_pause_toggleButton == nullptr)\r
+            {\r
+                play_or_pause_toggleButton = new UIToggleButton();\r
+            }\r
+            play_or_pause_toggleButton->SetPosition(248, 321, 100, 100);\r
+            play_or_pause_toggleButton->SetViewId(PlayOrPauseToggleButton_ViewID);\r
+            play_or_pause_toggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+            play_or_pause_toggleButton->SetStyle(STYLE_BORDER_RADIUS, 100);\r
+            play_or_pause_toggleButton->SetImages(CountDown_Play_ImagePath, CountDown_PAUSE_ImagePath);\r
+            UICheckBox::OnChangeListener *ToggleButtonChange = static_cast<UICheckBox::OnChangeListener *>(MainCountDownPresenter::GetInstance());\r
+            play_or_pause_toggleButton->SetOnChangeListener(ToggleButtonChange);\r
+            /* -------------------------------------------------------------------------- */\r
+            // Add Button to App\r
+            if (endbutton == nullptr)\r
+            {\r
+                endbutton = new UIButton();\r
+            }\r
+            endbutton->SetPosition(118, 321);\r
+            endbutton->Resize(100, 100);\r
+            endbutton->SetViewId(STARTCOUNTDOWNVIEWRETURNBUTTON);\r
+            endbutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+            endbutton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+            endbutton->SetStyle(STYLE_BORDER_RADIUS, 100);\r
+            endbutton->SetImageSrc(EndButton_ImagePath, EndButton_ImagePath);\r
+            endbutton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffa800, UIButton::PRESSED);\r
+            endbutton->SetStyleForState(STYLE_BORDER_RADIUS, 100, UIButton::PRESSED);\r
+            UIView::OnClickListener *buttonClick = static_cast<UIView::OnClickListener *>(MainCountDownPresenter::GetInstance());\r
+            endbutton->SetOnClickListener(buttonClick);\r
+            /* ----------------------------------- Add ---------------------------------- */\r
+            scrollView->Add(Title);\r
+            scrollView->Add(showCountDownTimelabel);\r
+            scrollView->Add(vectorImage);\r
+            scrollView->Add(showTheRingTime);\r
+            scrollView->Add(endbutton);\r
+            scrollView->Add(play_or_pause_toggleButton);\r
+        }\r
+\r
+        return scrollView;\r
+    }\r
+\r
+    // 获取显示倒计时时间标签\r
+    UILabelExt *StartCountDownView::GetShowCountDownTimelabel(void)\r
+    {\r
+        return showCountDownTimelabel;\r
+    }\r
+\r
+    // 获取显示响铃时间标签\r
+    UILabelExt *StartCountDownView::GetShowTheRingTimelabel(void)\r
+    {\r
+        return showTheRingTime;\r
+    }\r
+}
\ No newline at end of file
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_COUNTDOWN.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_COUNTDOWN.bin
new file mode 100644 (file)
index 0000000..16a718d
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_COUNTDOWN.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_STOPWATCH.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_STOPWATCH.bin
new file mode 100644 (file)
index 0000000..2284a6a
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/APPLIST_STOPWATCH.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_FIVE_MINUTE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_FIVE_MINUTE.bin
deleted file mode 100644 (file)
index 7dd2cf8..0000000
Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_FIVE_MINUTE.bin and /dev/null differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_ONE_MINUTE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_ONE_MINUTE.bin
deleted file mode 100644 (file)
index d0efbc5..0000000
Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_ONE_MINUTE.bin and /dev/null differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TEN_MINUTE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TEN_MINUTE.bin
deleted file mode 100644 (file)
index 7a2e102..0000000
Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TEN_MINUTE.bin and /dev/null differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_THIRTY_MINUTE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_THIRTY_MINUTE.bin
deleted file mode 100644 (file)
index ba69e92..0000000
Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_THIRTY_MINUTE.bin and /dev/null differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TIMER_ICON.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TIMER_ICON.bin
new file mode 100644 (file)
index 0000000..ff8eb2d
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TIMER_ICON.bin differ