-/***
+/***
* @Date: 2024-07-05 11:09:20
* @LastEditors: Caisking 3449750381@qq.com
* @LastEditTime: 2024-09-05 18:09:22
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_dial_style/src/SetTimeFormatView.cpp
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/set_dial_style/src/SetTimeFormatView.cpp
*/
-
-#include "set_time_format/include/SetTimeFormatModel.h"
#include "set_time_format/include/SetTimeFormatView.h"
+#include "set_time_format/include/SetTimeFormatModel.h"
#include "set_time_format/include/SetTimeFormatPresenter.h"
#include "UiConfig.h"
#include "ui_resource_string.h"
-namespace OHOS
-{
- SetTimeFormatView::SetTimeFormatView()
- {
- }
-
- SetTimeFormatView::~SetTimeFormatView()
- {
- }
-
- void SetTimeFormatView::OnStart()
- {
- View<SetTimeFormatPresenter>::OnStart();
- SetContainerView(new UIViewGroup);
- if (container_ == nullptr)
- {
- return;
- }
- container_->SetDraggable(true);
- container_->SetPosition(0, 0, 466, 466);
- container_->SetOnDragListener(presenter_);
- // 增加按键监听
- RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)(presenter_);
- RootView::GetInstance()->SetOnKeyActListener(keyactListener);
- container_->SetTouchable(true);
- }
-
- void SetTimeFormatView::OnSetUpView()
- {
- if (container_ == nullptr)
- {
- return;
- }
- View<SetTimeFormatPresenter>::OnSetUpView();
-
- Format24H_Image_.SetPosition(43, 120, 380, 100);
- Format24H_Image_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
- Format24H_Image_.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- Format24H_Image_.SetStyle(STYLE_BORDER_RADIUS, 100);
- container_->Add(&Format24H_Image_);
-
- Format12H_Image_.SetPosition(43, 240, 380, 100);
- Format12H_Image_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
- Format12H_Image_.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- Format12H_Image_.SetStyle(STYLE_BORDER_RADIUS, 100);
- container_->Add(&Format12H_Image_);
-
- labelTitle_.SetPosition(83, 50, 300, 60);
- labelTitle_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- // labelTitle_.SetTextId(STR_BROWSING_SPECIAL_EFFECTS);
- labelTitle_.SetText("设置时间格式");//TODO:多国语言
- labelTitle_.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 居中
- labelTitle_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- container_->Add(&labelTitle_);
-
- labelFormat24H_.SetPosition(90, 153, 200, 60);
- labelFormat24H_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- // labelFormat24H_.SetTextId(STR_OVERLAY_FLOW);
- labelFormat24H_.SetText("24小时显示");//TODO:多国语言
- container_->Add(&labelFormat24H_);
-
- labelFormat12H_.SetPosition(90, 273, 200, 60);
- labelFormat12H_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- // labelFormat12H_.SetTextId(STR_Format12H);
- labelFormat12H_.SetText("12小时显示");//TODO:多国语言
- container_->Add(&labelFormat12H_);
-
- btnFormat24H_.SetPosition(298, 145, 100, 50);
- btnFormat24H_.SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
- container_->Add(&btnFormat24H_);
- btnFormat12H_.SetPosition(298, 265, 100, 50);
- btnFormat12H_.SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
- container_->Add(&btnFormat12H_);
-
- const TimeFormat style = SetTimeFormatModel::GetInstance().GetTimeStyle();
- int len = sizeof(styleTable_) / sizeof(styleTable_[0]);
- for (int i = 0; i < len; ++i)
- {
- if (style == styleTable_[i].style)
- {
- styleTable_[i].btn->SetState(true);
- }
- else
- {
- styleTable_[i].btn->SetState(false);
- }
- }
-
- btnFormat24H_.SetOnClickListener(presenter_);
- btnFormat12H_.SetOnClickListener(presenter_);
- }
-
- void SetTimeFormatView::OnStop()
- {
- View<SetTimeFormatPresenter>::OnStop();
- if (container_ != nullptr)
- {
- container_->RemoveAll();
- delete container_;
- container_ = nullptr;
- }
- }
-
- void SetTimeFormatView::OnClick(UIView &view)
- {
- const UIToggleButton *ptr = dynamic_cast<UIToggleButton *>(&view);
- if (ptr == nullptr)
- {
- return;
- }
- int len = sizeof(styleTable_) / sizeof(styleTable_[0]);
- for (int i = 0; i < len; ++i)
- {
- if (ptr == styleTable_[i].btn)
- {
- styleTable_[i].btn->SetState(true);
- SetTimeFormatModel::GetInstance().SetStyle(styleTable_[i].style);
- }
- else
- {
- styleTable_[i].btn->SetState(false);
- }
- }
- // 切换到切换表盘Slice
- // NativeAbility::GetInstance().ChangeSlice(VIEW_SET_DIAL);
- }
-} // OHOS
\ No newline at end of file
+namespace OHOS {
+SetTimeFormatView::SetTimeFormatView() {}
+
+SetTimeFormatView::~SetTimeFormatView() {}
+
+void SetTimeFormatView::OnStart() {
+ View<SetTimeFormatPresenter>::OnStart();
+ SetContainerView(new UIViewGroup);
+ if (container_ == nullptr) {
+ return;
+ }
+ container_->SetDraggable(true);
+ container_->SetPosition(0, 0, 466, 466);
+ container_->SetOnDragListener(presenter_);
+ // 增加按键监听
+ RootView::OnKeyActListener *keyactListener =
+ (RootView::OnKeyActListener *)(presenter_);
+ RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+ container_->SetTouchable(true);
+}
+
+void SetTimeFormatView::OnSetUpView() {
+ if (container_ == nullptr) {
+ return;
+ }
+ View<SetTimeFormatPresenter>::OnSetUpView();
+
+ Format24H_Image_.SetPosition(43, 120, 380, 100);
+ Format24H_Image_.SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+ Format24H_Image_.SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ Format24H_Image_.SetStyle(STYLE_BORDER_RADIUS, 100);
+ container_->Add(&Format24H_Image_);
+
+ labelTitle_.SetPosition(83, 50, 300, 60);
+ labelTitle_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ // labelTitle_.SetTextId(STR_BROWSING_SPECIAL_EFFECTS);
+ labelTitle_.SetText("时间设置"); // TODO:多国语言
+ labelTitle_.SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 居中
+ labelTitle_.SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ container_->Add(&labelTitle_);
+
+ labelFormat24H_.SetPosition(90, 153, 200, 60);
+ labelFormat24H_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ // labelFormat24H_.SetTextId(STR_OVERLAY_FLOW);
+ labelFormat24H_.SetText("24小时制"); // TODO:多国语言
+ container_->Add(&labelFormat24H_);
+
+ btnFormat24H_.SetPosition(298, 145, 100, 50);
+ btnFormat24H_.SetImages(PNG_TOGGLEBUTTON_ON_IMAGE,
+ PNG_TOGGLEBUTTON_OFF_IMAGE);
+ container_->Add(&btnFormat24H_);
+
+ labelNote_.SetPosition(53, 240, 360, 100);
+ labelNote_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
+ labelNote_.SetText("注: 开启为24小时制显示,关闭则按照12小时制显示");
+ container_->Add(&labelNote_);
+
+ const TimeFormat style = SetTimeFormatModel::GetInstance().GetTimeStyle();
+ if (style == TimeFormat::TIME_FORMAT_24H) {
+ btnFormat24H_.SetState(true);
+ } else {
+ btnFormat24H_.SetState(false);
+ }
+
+ btnFormat24H_.SetOnClickListener(presenter_);
+}
+
+void SetTimeFormatView::OnStop() {
+ View<SetTimeFormatPresenter>::OnStop();
+ if (container_ != nullptr) {
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
+ }
+}
+
+void SetTimeFormatView::OnClick(UIView &view) {
+ const UIToggleButton *ptr = dynamic_cast<UIToggleButton *>(&view);
+ if (ptr == nullptr) {
+ return;
+ }
+ if (ptr->GetState() == true) {
+ btnFormat24H_.SetState(true);
+ SetTimeFormatModel::GetInstance().SetStyle(TimeFormat::TIME_FORMAT_24H);
+ } else {
+ btnFormat24H_.SetState(false);
+ SetTimeFormatModel::GetInstance().SetStyle(TimeFormat::TIME_FORMAT_12H);
+ }
+ // 切换到切换表盘Slice
+ // NativeAbility::GetInstance().ChangeSlice(VIEW_SET_DIAL);
+}
+} // namespace OHOS
\ No newline at end of file