"*.inc": "cpp",
"thread": "cpp",
"chrono": "cpp",
- "iostream": "cpp"
+ "iostream": "cpp",
+ "algorithm": "cpp",
+ "__bit_reference": "cpp",
+ "__bits": "cpp",
+ "__config": "cpp",
+ "__debug": "cpp",
+ "__errc": "cpp",
+ "__functional_base": "cpp",
+ "__hash_table": "cpp",
+ "__locale": "cpp",
+ "__mutex_base": "cpp",
+ "__node_handle": "cpp",
+ "__nullptr": "cpp",
+ "__split_buffer": "cpp",
+ "__string": "cpp",
+ "__threading_support": "cpp",
+ "__tree": "cpp",
+ "__tuple": "cpp",
+ "array": "cpp",
+ "atomic": "cpp",
+ "bit": "cpp",
+ "bitset": "cpp",
+ "cctype": "cpp",
+ "cinttypes": "cpp",
+ "clocale": "cpp",
+ "cmath": "cpp",
+ "codecvt": "cpp",
+ "condition_variable": "cpp",
+ "csignal": "cpp",
+ "cstdarg": "cpp",
+ "cstddef": "cpp",
+ "cstdint": "cpp",
+ "cstdio": "cpp",
+ "cstdlib": "cpp",
+ "cstring": "cpp",
+ "ctime": "cpp",
+ "cwchar": "cpp",
+ "cwctype": "cpp",
+ "deque": "cpp",
+ "exception": "cpp",
+ "forward_list": "cpp",
+ "fstream": "cpp",
+ "functional": "cpp",
+ "future": "cpp",
+ "initializer_list": "cpp",
+ "iomanip": "cpp",
+ "ios": "cpp",
+ "iosfwd": "cpp",
+ "istream": "cpp",
+ "iterator": "cpp",
+ "limits": "cpp",
+ "list": "cpp",
+ "locale": "cpp",
+ "map": "cpp",
+ "memory": "cpp",
+ "mutex": "cpp",
+ "new": "cpp",
+ "numeric": "cpp",
+ "optional": "cpp",
+ "ostream": "cpp",
+ "queue": "cpp",
+ "random": "cpp",
+ "ratio": "cpp",
+ "set": "cpp",
+ "sstream": "cpp",
+ "stack": "cpp",
+ "stdexcept": "cpp",
+ "streambuf": "cpp",
+ "string": "cpp",
+ "string_view": "cpp",
+ "strstream": "cpp",
+ "system_error": "cpp",
+ "tuple": "cpp",
+ "type_traits": "cpp",
+ "typeinfo": "cpp",
+ "unordered_map": "cpp",
+ "unordered_set": "cpp",
+ "utility": "cpp",
+ "vector": "cpp",
+ "*.tcc": "cpp",
+ "memory_resource": "cpp",
+ "shared_mutex": "cpp",
+ "cfenv": "cpp"
},
"C_Cpp.errorSquiggles": "disabled",
"cmake.sourceDirectory": "/home/luozheng/FD230/code/sdk"
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingNomalPresenter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetPresenter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetTimeView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetTimePresenter.cpp
#ָ����
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassCalibrationView.cpp
VIEW_TRAININGLIMIT, // 极限运动子列表
VIEW_TRAININGNOMAL, // 正常训练开始界面(除骑行,健走,跑步外)
VIEW_TRAININGSET, // 训练目标(时长,卡路里)
+ VIEW_TRAININGSETTIME, // 设置训练时长
VIEW_TRAINING_RECORD, // 训练记录
VIEW_BLOODPRESSURE, // 昨日睡眠时间
void InitTraingLimitSlice(void);
void InitTraingNomalSlice(void);
void InitTraingSetSlice(void);
+ void InitTraingSetTimeSlice(void);
void InitUIDisplayBrightnessSlice(void);
void InitBlueToothSettingSlice(void);
void InitBrightnessControlSlice(void);
#include "traing/include/TraingNomalView.h"
#include "traing/include/TraingSetPresenter.h"
#include "traing/include/TraingSetView.h"
+#include "traing/include/TraingSetTimePresenter.h"
+#include "traing/include/TraingSetTimeView.h"
#include "displaybrightness/include/DisplayBrightnessPresenter.h"
#include "displaybrightness/include/DisplayBrightnessView.h"
#include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h"
{VIEW_TRAININGLIMIT, &NativeLauncher::InitTraingLimitSlice}, //极限训练
{VIEW_TRAININGNOMAL, &NativeLauncher::InitTraingNomalSlice}, //正常训练初始界面
{VIEW_TRAININGSET, &NativeLauncher::InitTraingSetSlice}, //训练目标设置界面
+ {VIEW_TRAININGSETTIME, &NativeLauncher::InitTraingSetTimeSlice}, //设置目标时长
{VIEW_DISPLAY_BRIGHTNESS,&NativeLauncher::InitUIDisplayBrightnessSlice}, //显示与亮度的实例化地址
{VIEW_CONNECT_BLUETOOTH,&NativeLauncher::InitBlueToothSettingSlice}, //蓝牙设置的实例化地址
SliceProxy *traingsetview = new AbilitySliceProxy<TraingSetView, TraingSetPresenter>;
NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGSET, traingsetview);
}
+void NativeLauncher::InitTraingSetTimeSlice(void)
+{
+ SliceProxy *traingsettimeview = new AbilitySliceProxy<TraingSetTimeView, TraingSetTimePresenter>;
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGSETTIME, traingsettimeview);
+}
//DisplayBrightness的实例化
void NativeLauncher::InitUIDisplayBrightnessSlice(void)
return dialUserView;\r
#endif\r
\r
- #if 0\r
+ #if 1\r
mainClockView = new MainClockView();\r
if (mainClockView == nullptr) {\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail");\r
return mainClockView;\r
#endif\r
\r
- #if 1\r
+ #if 0\r
dialmalioview = new DialMalioView();\r
return dialmalioview;\r
#endif\r
--- /dev/null
+#ifndef _TraingSetTime_PRESENTER_H
+#define _TraingSetTime_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingSetTimeView.h"
+
+namespace OHOS
+{
+ class TraingSetTimeView;
+
+ class TraingSetTimePresenter : public Presenter<TraingSetTimeView>,
+ public UIView::OnClickListener,
+ public UIView::OnDragListener
+ {
+ public:
+ TraingSetTimePresenter();
+ virtual ~TraingSetTimePresenter();
+
+ void OnStart() override;
+ void OnPause() override;
+ void OnResume() override;
+ void OnStop() override;
+
+ static TraingSetTimePresenter *GetInstance();
+
+ private:
+ // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+ bool OnClick(UIView &view, const ClickEvent &event) override;
+ bool OnDrag(UIView &view, const DragEvent &event) override;
+ };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
--- /dev/null
+#ifndef _TraingSetTime_VIEW_H
+#define _TraingSetTime_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+#include "components/ui_picker.h"
+
+#include "TraingSetTimePresenter.h"
+namespace OHOS
+{
+#define BUTTONOK "button1"
+
+
+ class TraingSetTimePresenter;
+ class TraingSetTimeView : public View<TraingSetTimePresenter>
+ {
+
+ public:
+ TraingSetTimeView();
+ virtual ~TraingSetTimeView();
+ static TraingSetTimeView *GetInstance(void);
+
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+ void InitView();
+ void DeInit();
+ void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize);
+ void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId);
+ void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath);
+ void InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId);
+ void InitList();
+ void PreLoad(void);
+
+ private:
+ UIView::OnDragListener *draglistener{nullptr};
+ TraingSetTimeView(TraingSetTimeView &&) = delete;
+ TraingSetTimeView &operator=(TraingSetTimeView &&) = delete;
+
+ UIViewGroup *container_ = nullptr;
+ UILabel *label1_ = nullptr;
+ UIButton *button1_ = nullptr;
+ UIPicker *uiPicker1_ = nullptr;
+
+ bool viewiInitStatus{false};
+ };
+} // namespace OHOS
+#endif // TraingSetTime_PRESENTER_H
bool TraingSetPresenter::OnClick(UIView &view, const ClickEvent &event)
{
// 根据控件id查找是哪个控件触发了点击回调
- if (strcmp(view.GetViewId(), " ") == 0)
+ if (strcmp(view.GetViewId(), BUTTONTIME) == 0)
{
- NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGNOMAL);
+ NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSETTIME);
}
if (strcmp(view.GetViewId(), "Remind") == 0)
{
--- /dev/null
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/include/TraingSetTimePresenter.h"
+// #include "TraingSetTimeView.h"
+
+namespace OHOS
+{
+
+ // 当前Presenter属性实例化的内存指针
+ static TraingSetTimePresenter *g_pTraingSetTimePresenter = nullptr;
+
+ TraingSetTimePresenter::TraingSetTimePresenter()
+ {
+
+ g_pTraingSetTimePresenter = this;
+ }
+
+ TraingSetTimePresenter::~TraingSetTimePresenter()
+ {
+
+ g_pTraingSetTimePresenter = nullptr;
+ }
+
+ TraingSetTimePresenter *TraingSetTimePresenter::GetInstance()
+ {
+
+ return g_pTraingSetTimePresenter;
+ }
+
+ void TraingSetTimePresenter::OnStart()
+ {
+
+ Presenter<TraingSetTimeView>::OnStart();
+ }
+
+ void TraingSetTimePresenter::OnPause(void)
+ {
+
+ Presenter<TraingSetTimeView>::OnPause();
+ }
+
+ void TraingSetTimePresenter::OnResume(void)
+ {
+
+ Presenter<TraingSetTimeView>::OnResume();
+ }
+
+ void TraingSetTimePresenter::OnStop(void)
+ {
+
+ Presenter<TraingSetTimeView>::OnStop();
+ }
+
+ bool TraingSetTimePresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+ (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSET);
+ }
+ UNUSED(view);
+ return true;
+ }
+
+ bool TraingSetTimePresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ // 根据控件id查找是哪个控件触发了点击回调
+ if (strcmp(view.GetViewId(), " ") == 0)
+ {
+ NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGNOMAL);
+ }
+ if (strcmp(view.GetViewId(), "Remind") == 0)
+ {
+ // 模拟心率监测,等待20秒
+ // std::this_thread::sleep_for(std::chrono::seconds(20));
+ // NativeAbility::GetInstance().ChangeSlice(VIEW_TraingSetTimeREMIND);
+ }
+ return true;
+ }
+}
--- /dev/null
+
+#include "traing/include/TraingSetTimeView.h"
+
+#include "common/image_cache_manager.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "common/screen.h"
+#include <sstream>
+#include <string>
+#include <vector>
+
+namespace OHOS
+{
+
+ /***************************************************************************************/
+ // 动态生成包含指定时间区间内所有分钟数的字符串数组
+ std::vector<std::string> GenerateTimeValues(int minTime, int maxTime, int interval)
+ {
+ std::vector<std::string> values;
+ for (int i = minTime; i <= maxTime; i += interval)
+ {
+ values.push_back(std::to_string(i) + "分钟");
+ }
+ return values;
+ }
+ /***************************************************************************************/
+ static TraingSetTimeView *g_pTraingSetTimeView{nullptr};
+
+ TraingSetTimeView::TraingSetTimeView()
+ {
+ g_pTraingSetTimeView = this;
+ }
+
+ TraingSetTimeView::~TraingSetTimeView()
+ {
+ DeInit();
+ g_pTraingSetTimeView = nullptr;
+ }
+
+ TraingSetTimeView *TraingSetTimeView::GetInstance()
+ {
+
+ return g_pTraingSetTimeView;
+ }
+ /*
+ InitLabel:初始化标签
+ @param label 标签指针
+ @param left 标签左边位置
+ @param top 标签顶部位置
+ @param width 标签宽度
+ @param height 标签高度
+ @param viewId 标签的视图 ID
+ @param text 标签显示的文本
+ @param fontName 字体名称
+ @param fontSize 字体大小
+ */
+ void TraingSetTimeView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize)
+ {
+ // 检查标签指针是否为空
+ if (label == nullptr)
+ {
+ label = new UILabel();
+ }
+ // 设置标签的位置和大小
+ label->SetPosition(left, top);
+ label->Resize(width, height);
+ // 设置标签的视图 ID
+ label->SetViewId(viewId);
+ // 设置标签的样式
+ label->SetStyle(STYLE_TEXT_FONT, fontSize);
+ label->SetFont(fontName, fontSize);
+ // 设置标签的文本和其他属性
+ label->SetText(text);
+ label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label->SetRollSpeed(0);
+ // 设置标签可见
+ label->SetVisible(true);
+ }
+ /*
+ InitButton:初始化按钮
+ @param button 按钮指针
+ @param left 按钮左边位置
+ @param top 按钮顶部位置
+ @param width 按钮宽度
+ @param height 按钮高度
+ @param viewId 按钮的视图 ID
+ */
+ void TraingSetTimeView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId)
+ {
+ // 设置按钮的背景颜色
+ uint32_t backgroundColor = 0xff191919; // 默认背景颜色
+ uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色
+ uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色
+ // 创建新按钮(如果当前按钮为空)
+ if (button == nullptr)
+ {
+ button = new UIButton();
+ }
+ button->SetPosition(left, top);
+ button->Resize(width, height);
+ button->SetViewId(viewId);
+ button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor);
+ button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED);
+ button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED);
+ // 设置按钮的点击事件监听器为 TraingSetTimePresenter 的实例
+ button->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetTimePresenter::GetInstance()));
+ // 设置按钮可见
+ button->SetVisible(true);
+ }
+ /*
+ InitUIPicker: 初始化UIPicker组件
+ @param picker: 指向UIPicker的指针
+ @param x: UIPicker的左边位置
+ @param y: UIPicker的顶部位置
+ @param width: UIPicker的宽度
+ @param height: UIPicker的高度
+ @param viewId: UIPicker的视图 ID
+ @param values: 选项数组
+ @param count: 选项数量
+ @param backgroundFontSize: 普通文本大小
+ @highlightFontSize: 高光文本大小
+ */
+ void TraingSetTimeView::InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId)
+ {
+ // 文本大小
+ constexpr uint8_t BACKGROUND_FONT = 40;
+ constexpr uint8_t HIGHTLIGHT_FONT = 60;
+ // 获取value数组
+ int minTime = 10;
+ int maxTime = 600;
+ int interval = 10;
+ std::vector<std::string> timeValues = GenerateTimeValues(minTime, maxTime, interval);
+
+ const char **values = new const char *[timeValues.size()];
+ for (size_t i = 0; i < timeValues.size(); i++)
+ {
+ values[i] = timeValues[i].c_str();
+ }
+ // 创建 UIPicker
+ if (picker == nullptr)
+ {
+ picker = new UIPicker();
+ }
+
+ // 设置 UIPicker 的位置和大小
+ picker->SetPosition(x, y);
+ picker->Resize(width, height);
+ // 设置 UIPicker 的 ViewId
+ picker->SetViewId(viewId);
+ // 设置 UIPicker 的属性
+ picker->SetItemHeight(70);
+ picker->SetLoopState(true);
+ picker->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff), Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+ picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); // 设置普通文本大小
+ picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT); // 设置高光文本大小
+ picker->SetValues(values, timeValues.size());
+ // 将 UIPicker 设置为显示
+ picker->SetVisible(true);
+ }
+
+ /* InitView:初始化界面*/
+ void TraingSetTimeView ::InitView()
+ {
+ if (container_ == nullptr)
+ {
+ container_ = new UIViewGroup();
+ container_->SetPosition(0, 0, 466, 466);
+ container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ }
+ // 初始化Lable
+ InitLabel(label1_, 173, 52, 120, 35, "label1", "时长设定", DEFAULT_VECTOR_FONT_FILENAME, 30);
+ container_->Add(label1_);
+
+ // 初始化UIPicker
+ InitUIPicker(uiPicker1_, 43, 106, 380, 240, "uiPicker1");
+ container_->Add(uiPicker1_);
+ // 初始化Button
+ InitButton(button1_, 366, 0, 466, 100, BUTTONOK);
+ // Set additional property
+ char *button1defaultImgSrc = "/user/res/Training/buttonok.bin";
+ char *button1triggeredImgSrc = nullptr;
+ button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);
+ container_->Add(button1_);
+ }
+ /* DeInit:删除组件 */
+ void TraingSetTimeView::DeInit()
+ {
+ // 删除Label
+ if (label1_ != nullptr)
+ {
+ container_->Remove(label1_);
+ delete label1_;
+ label1_ = nullptr;
+ }
+ // 删除Button
+ if (button1_ != nullptr)
+ {
+ container_->Remove(button1_);
+ delete button1_;
+ button1_ = nullptr;
+ }
+
+ // 删除Image
+
+ // 删除滚动选择器
+ if (uiPicker1_ != nullptr)
+ {
+ container_->Remove(uiPicker1_);
+ delete uiPicker1_;
+ uiPicker1_ = nullptr;
+ }
+
+ // 删除容器
+ if (container_ != nullptr)
+ {
+ container_->RemoveAll(); // 移除容器中的所有组件
+ delete container_;
+ container_ = nullptr;
+ }
+ }
+
+ void TraingSetTimeView::PreLoad(void)
+ {
+ if (!viewiInitStatus)
+ {
+ InitView();
+ viewiInitStatus = true;
+ }
+ }
+ void TraingSetTimeView::OnStart()
+ {
+ container_ = new UIViewGroup();
+ if (container_ == nullptr)
+ {
+ return;
+ }
+ container_->SetPosition(0, 0);
+ container_->SetWidth(Screen::GetInstance().GetWidth());
+ container_->SetHeight(Screen::GetInstance().GetHeight());
+
+ // 创建 draglistener 实例并设置为拖动监听器
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingSetTimePresenter::GetInstance());
+ if (draglistener == nullptr)
+ {
+ return;
+ }
+ container_->SetOnDragListener(draglistener);
+
+ container_->SetTouchable(true);
+ container_->SetDraggable(true);
+
+ PreLoad();
+ RootView::GetInstance()->Add(container_);
+ }
+
+ void TraingSetTimeView::OnSetUpView()
+ {
+
+ View<TraingSetTimePresenter>::OnSetUpView();
+ Draw();
+ }
+
+ void TraingSetTimeView::OnTearDownView()
+ {
+
+ View<TraingSetTimePresenter>::OnTearDownView();
+ return;
+ }
+
+ void TraingSetTimeView::OnStop()
+ {
+ View<TraingSetTimePresenter>::OnStop();
+ RootView::GetInstance()->RemoveAll();
+ return;
+ }
+}