#include "string"
#include "vibrator_service.h"
#include "UiConfig.h"
+#include "ConfigModel.h"
extern "C" void custom_VibratorFunc(OHOS::VibratorType vibratorType);
namespace OHOS
UILabelExt *sleepnotifylabel{nullptr}; // 详细label
UILabelButtonExt *sleepbutton{nullptr}; // 删除按键
- static std::string titleStr, timeStr, sleepStr;
+ UILabelExt *alarmtitle{nullptr}; // 标题
+ UIImageView *backimage{nullptr};
+ UIImageView *sunnyicon{nullptr};
+ UIImageView *alarmicon{nullptr};
+ UILabelExt *nowlabel{nullptr};
+ UILabelExt *walklabel{nullptr}; // 早安时间
+ UILabelButtonExt *closebutton{nullptr}; // 关闭按键
+ UILabelButtonExt *nopbutton{nullptr}; // 小睡按键
+
+ static std::string titleStr;
+ static constexpr const char *PNG_SLEEP_SUUNY_IMAGE = "/user/res/Sleep/sunny.bin";
+ static constexpr const char *PNG_SLEEP_ALARM_IMAGE = "/user/res/Sleep/alarmicon.bin";
+ static constexpr const char *PNG_SLEEP_BACK_IMAGE = "/user/res/Sleep/goodmorning.bin";
#define DELETEBUTTON "delete_button"
+#define NOPBUTTON "nop_button"
SleepViewEventListener::SleepViewEventListener()
{
{
NotificationManager::GetInstance()->StopNotify();
}
-
return true;
}
bool SleepViewEventListener::OnDrag(UIView &view, const DragEvent &event)
break;
case SLEEPSTATE::WALK:
titleStr = SleepModel::GetInstance().get_walk_notifiy();
+ textId = STR_MORNNING;
ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰
+ SetAlarmClockView(); // 设置为早安视图
+ return SleepGroupView;
break;
default:
break;
SleepGroupView->Add(sleepbutton);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!");
- // 震动提醒
- custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO);
+ custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒
return SleepGroupView;
}
+ void SetAlarmClockView()
+ {
+ /*初始化图片*/
+ InitImageView(backimage, 0, 0, 466, 466, "image", PNG_SLEEP_BACK_IMAGE);
+ InitImageView(sunnyicon, 153, 95, 160, 160, "image", PNG_SLEEP_SUUNY_IMAGE);
+ InitImageView(alarmicon, 149, 260, 29, 29, "image", PNG_SLEEP_ALARM_IMAGE);
+ /*初始化固定label*/
+ InitLabelExt(alarmtitle, 83, 50, 300, 35, "labletitle", STR_MORNNING, DEFAULT_VECTOR_FONT_FILENAME, 30);
+ InitLabelExt(nowlabel, 110, 243, 200, 60, "labletitle", STR_NOW, DEFAULT_VECTOR_FONT_FILENAME, 30);
+ /*获取起床时间labe*/
+ std::string walkStr = SleepModel::GetInstance().get_walk_notifiy();
+ InitLabel(walklabel, 190, 245, 200, 60, "labletitle", walkStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 30);
+ /*设置按键*/
+ InitButtonExt(nopbutton, 58, 320, 170, 90, NOPBUTTON, STR_NAP, 30);
+ nopbutton->SetOnTouchListener(static_cast<UIView::OnTouchListener *>(&SleepViewEventListener::GetInstance()));
+ nopbutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c);
+ nopbutton->SetStyle(STYLE_BORDER_RADIUS, 100);
+
+ InitButtonExt(closebutton, 238, 320, 170, 90, DELETEBUTTON, STR_CLOSE, 30);
+ closebutton->SetOnTouchListener(static_cast<UIView::OnTouchListener *>(&SleepViewEventListener::GetInstance()));
+ closebutton->SetStyle(STYLE_BORDER_RADIUS, 100);
+
+ /* -------------------------------------------------------------------------- */
+ SleepGroupView->Add(backimage);
+ SleepGroupView->Add(sunnyicon);
+ SleepGroupView->Add(alarmicon);
+ SleepGroupView->Add(nowlabel);
+ SleepGroupView->Add(walklabel);
+ SleepGroupView->Add(nopbutton);
+ SleepGroupView->Add(closebutton);
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!");
+ custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒
+ }
/*释放消息弹窗视图*/
void FreeSleepView(void)
{