系统:修改UI与figma保持一致
authorCaisking <3449750381@qq.com>
Mon, 11 Nov 2024 10:02:26 +0000 (18:02 +0800)
committerCaisking <3449750381@qq.com>
Mon, 11 Nov 2024 10:02:26 +0000 (18:02 +0800)
code/sdk/application/wearable/fd230app/nativeui/set_time_format/include/SetTimeFormatView.h
code/sdk/application/wearable/fd230app/nativeui/set_time_format/src/SetTimeFormatView.cpp
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp
code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp

index da583f6..2fb5384 100644 (file)
@@ -32,23 +32,10 @@ private:
   UILabelExt labelTitle_;
 
   UILabelExt labelFormat24H_;
-  UILabelExt labelFormat12H_;
-
   UIToggleButton btnFormat24H_;
-  UIToggleButton btnFormat12H_;
-
   UIImageView Format24H_Image_;
-  UIImageView Format12H_Image_;
-
-  struct {
-    UIToggleButton *btn;
-    TimeFormat style;
-  }
 
-  styleTable_[static_cast<int>(TimeFormat::MAX_FORMAT_NUM)] = {
-      {&btnFormat24H_, TimeFormat::TIME_FORMAT_24H},
-      {&btnFormat12H_, TimeFormat::TIME_FORMAT_12H},
-  };
+  UILabelExt labelNote_;
 };
 } // OHOS
 #endif
\ No newline at end of file
index aaad3cc..f87a67a 100644 (file)
-/*** 
+/***
  * @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
index f8036af..17580ce 100644 (file)
@@ -60,11 +60,7 @@ namespace OHOS
             Icon.SetSrc(itemInfo.icon);
             settingLabelExt.SetVisible(true);
             settingLabelExt.SetPosition(SETTINGLABELEXT_X, SETTINGLABELEXT_Y, SETTINGLABELEXT_W, SETTINGLABELEXT_H);
-            if (itemInfo.viewId == VIEW_SET_TIME_FORMAT) {
-                settingLabelExt.SetText("时间显示样式");//TODO:多国语言
-            } else {
-                settingLabelExt.SetTextId(itemInfo.textId);
-            }
+            settingLabelExt.SetTextId(itemInfo.textId);
             settingLabelExt.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
             settingLabelButtonExt.SetVisible(true);
             SetHeight(120);
index 3e4f954..58362b4 100644 (file)
@@ -45,7 +45,6 @@ namespace OHOS
         settings[index++] = {VIEW_ADD_CARD, PNG_SETTINGS_CARDSET_IMAGE, STR_CARD_MANAGEMENT, true};
         settings[index++] = {VIEW_SET_DIAL_STYLE, PNG_SETTINGS_CHANGEDIAL_IMAGE, STR_DIAL_BROWSING_SPECIAL_EFFECTS, true};
         settings[index++] = {VIEW_SAVEELE, PNG_SETTINGS_SAVEELE_IMAGE, STR_POWER_SAVE_MODE, true};
-        settings[index++] = {VIEW_SET_TIME_FORMAT, PNG_SETTINGS_CHANGEDIAL_IMAGE, STR_TIME, true};//测试24小时格式与12小时
         settings[index++] = {VIEW_SYSTEM, PNG_SETTINGS_SYSTEM, STR_SYSTEM, true};
         settings[index++] = {VIEW_INVALID, nullptr, STR_MAX_ID, false};
         usedLen = index;
index 16239fa..ba33350 100644 (file)
@@ -35,6 +35,7 @@ namespace OHOS
     static constexpr const char *RESTART = "RestartButton";                     // 重启\r
     static constexpr const char *SHUTDOWN = "ShutdownButton";                   // 关机\r
     static constexpr const char *FACTORY_RESET = "FactoryResetButton";          // 恢复出厂设置\r
+    static constexpr const char *SET_TIME_FORMAT = "SetTimeFormatButton";       // 设置时间格式\r
 \r
     typedef enum\r
     {\r
index a494869..cf89974 100644 (file)
@@ -165,6 +165,11 @@ namespace OHOS
             p_SystemView->ChangeView(SYSTEMVIEW, ABOUTTHEWATCHVIEW);\r
             return true;\r
         }\r
+        else if (strcmp(view.GetViewId(), SET_TIME_FORMAT) == 0) // 点击进入设置时间格式\r
+        {\r
+            NativeAbility::GetInstance().EnterSlice(VIEW_SET_TIME_FORMAT);\r
+            return true;\r
+        }\r
         else if (strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) // 点击进入系统升级视图\r
         {\r
             NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_UPDATE);\r
index a92489d..057508b 100644 (file)
@@ -134,7 +134,10 @@ namespace OHOS
         label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height);\r
         label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize);\r
         label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh);\r
-        label->SetTextId(labelconfig.textId);\r
+        if (labelconfig.textId == STR_TIME)\r
+          label->SetText("时间格式设置");\r
+        else\r
+          label->SetTextId(labelconfig.textId);\r
         label->SetLineBreakMode(labelconfig.lineBreakMode);\r
         label->SetRollSpeed(70);\r
         label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);\r
@@ -172,6 +175,7 @@ namespace OHOS
         LabelSetup labelSetups[] = {\r
             {153, STR_ABOUT_WATCH},\r
             // {273, STR_SYSTEM_UPDATE},\r
+            {273, STR_TIME},\r
             {393, STR_WATCH_QR_CODE},\r
             {513, STR_SYSTEM_LANGUAGE},\r
             {633, STR_RESTART},\r
@@ -217,6 +221,7 @@ namespace OHOS
         ButtonSetup buttonSetups[] = {\r
             {120, ABOUT_THE_WATCH},\r
             // {240, SYSTEM_UPGRADE},\r
+            {300, SET_TIME_FORMAT},\r
             {360, WATCH_QR_CODE},\r
             {480, SYSTEM_LANGUAGE},\r
             {600, RESTART},\r