From: Caisking <3449750381@qq.com> Date: Mon, 11 Nov 2024 10:02:26 +0000 (+0800) Subject: 系统:修改UI与figma保持一致 X-Git-Tag: fd230_release_V1.3.102~92^2~3 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=59763c10b98e244582128f7d8b195eaa0cfe727f;p=mirrors%2FFD230.git 系统:修改UI与figma保持一致 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_time_format/include/SetTimeFormatView.h b/code/sdk/application/wearable/fd230app/nativeui/set_time_format/include/SetTimeFormatView.h index da583f6ee..2fb5384a8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_time_format/include/SetTimeFormatView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/set_time_format/include/SetTimeFormatView.h @@ -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(TimeFormat::MAX_FORMAT_NUM)] = { - {&btnFormat24H_, TimeFormat::TIME_FORMAT_24H}, - {&btnFormat12H_, TimeFormat::TIME_FORMAT_12H}, - }; + UILabelExt labelNote_; }; } // OHOS #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_time_format/src/SetTimeFormatView.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_time_format/src/SetTimeFormatView.cpp index aaad3ccf2..f87a67a70 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_time_format/src/SetTimeFormatView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_time_format/src/SetTimeFormatView.cpp @@ -1,141 +1,106 @@ -/*** +/*** * @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::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::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::OnStop(); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } - } - - void SetTimeFormatView::OnClick(UIView &view) - { - const UIToggleButton *ptr = dynamic_cast(&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::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::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::OnStop(); + if (container_ != nullptr) { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } +} + +void SetTimeFormatView::OnClick(UIView &view) { + const UIToggleButton *ptr = dynamic_cast(&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 diff --git a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp index f8036af31..17580ce28 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp @@ -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); diff --git a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp index 3e4f9547e..58362b4cd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp @@ -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; diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h index 16239faee..ba3335044 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h @@ -35,6 +35,7 @@ namespace OHOS static constexpr const char *RESTART = "RestartButton"; // 重启 static constexpr const char *SHUTDOWN = "ShutdownButton"; // 关机 static constexpr const char *FACTORY_RESET = "FactoryResetButton"; // 恢复出厂设置 + static constexpr const char *SET_TIME_FORMAT = "SetTimeFormatButton"; // 设置时间格式 typedef enum { diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp index a4948697d..cf8997406 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp @@ -165,6 +165,11 @@ namespace OHOS p_SystemView->ChangeView(SYSTEMVIEW, ABOUTTHEWATCHVIEW); return true; } + else if (strcmp(view.GetViewId(), SET_TIME_FORMAT) == 0) // 点击进入设置时间格式 + { + NativeAbility::GetInstance().EnterSlice(VIEW_SET_TIME_FORMAT); + return true; + } else if (strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) // 点击进入系统升级视图 { NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_UPDATE); diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp index a92489d17..057508bee 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp @@ -134,7 +134,10 @@ namespace OHOS label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); - label->SetTextId(labelconfig.textId); + if (labelconfig.textId == STR_TIME) + label->SetText("时间格式设置"); + else + label->SetTextId(labelconfig.textId); label->SetLineBreakMode(labelconfig.lineBreakMode); label->SetRollSpeed(70); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); @@ -172,6 +175,7 @@ namespace OHOS LabelSetup labelSetups[] = { {153, STR_ABOUT_WATCH}, // {273, STR_SYSTEM_UPDATE}, + {273, STR_TIME}, {393, STR_WATCH_QR_CODE}, {513, STR_SYSTEM_LANGUAGE}, {633, STR_RESTART}, @@ -217,6 +221,7 @@ namespace OHOS ButtonSetup buttonSetups[] = { {120, ABOUT_THE_WATCH}, // {240, SYSTEM_UPGRADE}, + {300, SET_TIME_FORMAT}, {360, WATCH_QR_CODE}, {480, SYSTEM_LANGUAGE}, {600, RESTART},