#782 AIGC表盘电量图标
authorCaisking <3449750381@qq.com>
Fri, 20 Sep 2024 12:51:04 +0000 (20:51 +0800)
committerCaisking <3449750381@qq.com>
Fri, 20 Sep 2024 12:51:04 +0000 (20:51 +0800)
code/sdk/application/wearable/fd230app/nativeui/clock/src/MainClockView.cpp

index b940dae..af48dce 100644 (file)
 
 #include "MainClockView.h"
 #include "MainPresenterSample.h"
+#include "SetDialModel.h"
+#include "battery_hal.h"
+#include "common/image_cache_manager.h"
 #include "components/ui_label.h"
-#include "wearable_log.h"
+#include "custom_runtime.h"
+#include "main/include/PullUpDownView.h"
+#include "message/include/MessageControlView.h"
 #include "ui_resource_image.h"
-#include "common/image_cache_manager.h"
-#include <time.h>
+#include "wearable_log.h"
+#include <cwchar>
+#include <iomanip>
 #include <iostream>
 #include <sstream>
-#include <iomanip>
 #include <string>
 #include <sys/stat.h>
+#include <time.h>
 #include <unistd.h>
-#include "custom_runtime.h"
-#include "main/include/PullUpDownView.h"
-#include "battery_hal.h"
-#include "message/include/MessageControlView.h"
-#include "SetDialModel.h"
 extern uint8_t battery_get_voltage(float *voltage);
 
 #define TIMEVIEW_UP 0
@@ -371,26 +372,30 @@ namespace OHOS
         // 设置位置
         batteryicon->SetPosition(186, 52, 100, 100);
         batteryiamge->SetPosition(173, 52, 100, 100);
+
         batteryprogress->SetPosition(180, 58, 30, 18);
         batteryprogress->SetViewId("progress");
-        batteryprogress->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+        batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+        batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00);
+
         batterylabel->SetPosition(228, 52, 200, 60);
         batterylabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);
 
         // 设置图标和颜色
-        switch (type)
-        {
+        switch (type) {
         case BATTERY_DISPLAY_BLACK:
-            batteryiamge->SetSrc(BLACK_BATTERY);
-            batterylabel->SetTextColor(Color::Black());
-            batteryprogress->SetBackgroundStyle(STYLE_TEXT_COLOR, 0xff000000);
-            break;
+          batteryiamge->SetSrc(BLACK_BATTERY);
+          batterylabel->SetTextColor(Color::Black());
+          batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR,
+                                              0xff000000);
+          break;
         case BATTERY_DISPLAY_WHITE:
-        default: // 默认不做额外操作,保持白色
-            batteryiamge->SetSrc(WHITE_BATTERY);
-            batterylabel->SetTextColor(Color::White());
-            batteryprogress->SetBackgroundStyle(STYLE_TEXT_COLOR, 0xffffffff);
-            break;
+        default:
+          batteryiamge->SetSrc(WHITE_BATTERY);
+          batterylabel->SetTextColor(Color::White());
+          batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR,
+                                              0xffffffff);
+          break;
         }
         batteryicon->SetSrc(CHAGE_BATTERY);
         batteryicon->SetVisible(false); // 设置不可见
@@ -521,6 +526,8 @@ namespace OHOS
             return;
 
         power_ = power;
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryprogress power_:%d",
+                      power_);
         if (batteryprogress != nullptr && batterylabel != nullptr)
         {
             batteryprogress->SetValue(power_);