${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uiservice/include\r
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/include\r
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/\r
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/UIInitializer/\r
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/InitComponent/include\r
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uisample/uitest/framework/include\r
${UI_SAMPLE_ROOT}/components\r
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/uiservice/src/ui_service.cpp\r
${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/src/slices/main/MainPresenter.cpp\r
${CMAKE_CURRENT_SOURCE_DIR}/nativelauncher/src/slices/main/MainView.cpp\r
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/UIInitializer/UIInitializer.cpp\r
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainViewSample.cpp\r
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainPresenterSample.cpp\r
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/src/MainSwipeViewGroup.cpp\r
--- /dev/null
+/*
+ * Description: nativeui
+ * Author:Caiking
+ * Create: 2023-12-25
+ */
+
+// ComponentConfig.h
+#ifndef COMPONENT_CONFIG_H
+#define COMPONENT_CONFIG_H
+
+#include <string>
+/**
+ * @brief UI元素的通用属性
+ */
+struct UIgenerality
+{
+ int left; ///< 元素的左边界位置
+ int top; ///< 元素的顶部位置
+ int width; ///< 元素的宽度
+ int height; ///< 元素的高度
+ const char *viewId; ///< 元素的视图ID
+};
+
+/**
+ * @brief 标签结构体
+ */
+struct UILabelConfig : public UIgenerality
+{
+ const char *text; ///< 标签显示的文本
+ const char *fontName; ///< 标签的字体名称
+ int fontSize; ///< 标签的字体大小
+
+ UILabelConfig(int l, int t, int w, int h, const char *id, const char *txt, const char *fName, int fSize)
+ : UIgenerality{l, t, w, h, id}, text(txt), fontName(fName), fontSize(fSize) {}
+};
+
+/**
+ * @brief 按键结构体
+ */
+struct UIButtonConfig : public UIgenerality
+{
+ UIButtonConfig(int l, int t, int w, int h, const char *id)
+ : UIgenerality{l, t, w, h, id} {}
+};
+
+/**
+ * @brief 图片结构体
+ */
+struct UIImageConfig : public UIgenerality
+{
+ const char *imagePath; ///< 图片的文件路径
+
+ UIImageConfig(int l, int t, int w, int h, const char *id, const char *path)
+ : UIgenerality{l, t, w, h, id}, imagePath(path) {}
+};
+#endif
\ No newline at end of file
--- /dev/null
+
+#include "common/image_cache_manager.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "UIInitializer.h"
+
+namespace OHOS
+{
+ /**
+ * @brief 初始化按键
+ * @param label 要初始化的标签对象的引用
+ * @param labelconfig 包含标签配置信息的对象
+ * @return 如果初始化成功返回 true,否则返回 false
+ */
+ void UIInitializer::InitLabel(UILabel *&label, const UILabelConfig &labelconfig)
+ {
+ // 检查标签指针是否为空
+ if (label == nullptr)
+ {
+ label = new UILabel();
+ }
+ // 设置标签的位置和大小
+ label->SetPosition(labelconfig.left, labelconfig.top);
+ label->Resize(labelconfig.width, labelconfig.height);
+ // 设置标签的视图 ID
+ label->SetViewId(labelconfig.viewId);
+ // 设置标签的样式
+ label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize);
+ label->SetFont(labelconfig.fontName, labelconfig.fontSize);
+ // 设置标签的文本和其他属性
+ label->SetText(labelconfig.text);
+ label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label->SetRollSpeed(0);
+ // 设置标签可见
+ label->SetVisible(true);
+ }
+
+ /**
+ * @brief 初始化按键
+ * @param button 要初始化的按键对象的引用
+ * @param buttonconfig 包含按键配置信息的对象
+ * @return 如果初始化成功返回 true,否则返回 false
+ */
+ void UIInitializer::InitButton(UIButton *&button, const UIButtonConfig &buttonconfig)
+ {
+ }
+
+ /**
+ * @brief 初始化图像视图
+ * @param imageview 要初始化的图像视图对象的引用
+ * @param imageconfig 包含图像视图配置信息的对象
+ * @return 如果初始化成功返回 true,否则返回 false
+ */
+ void UIInitializer::InitImageView(UIImageView *&imageview, const UIImageConfig &imageconfig)
+ {
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Description: nativeui
+ * Author:Caiking
+ * Create: 2023-12-25
+ */
+
+// UIInitializer.h
+#ifndef UI_INITIALIZER_H
+#define UI_INITIALIZER_H
+
+#include "ComponentConfig.h" // 包含组件配置结构体的头文件
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+
+namespace OHOS
+{
+
+ class UIInitializer
+ {
+ public:
+ static void InitLabel(UILabel *&label, const UILabelConfig &labelconfig);
+ static void InitButton(UIButton *&button, const UIButtonConfig &buttonconfig);
+ static void InitImageView(UIImageView *&imageview, const UIImageConfig &imageconfig);
+ };
+
+}
+
+#endif
\ No newline at end of file
#include "ui_resource_image.h"\r
#include <ui_scroll_view.h>\r
#include "components/ui_button.h"\r
+#include "UIInitializer.h"\r
namespace OHOS\r
{\r
static TraingView *g_pTraingView{nullptr};\r
container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
}\r
\r
- // Add Label to App\r
+ /* Add Label to App\r
if (label1_ == nullptr)\r
{\r
label1_ = new UILabel();\r
// Add to rootView\r
container_->Add(label1_);\r
label1_->SetVisible(true);\r
+ */\r
+\r
+ // 创建一个 ComponentConfig 结构体实例\r
+ UILabelConfig labelConfig = {173, 52, 200, 60, "label1", "快速训练", DEFAULT_VECTOR_FONT_FILENAME, 30};\r
+\r
+ // 使用 UIInitializer 类中的初始化函数来初始化标签\r
+ UIInitializer::InitLabel(label1_, labelConfig);\r
\r
// Add Button to App\r
if (button3_ == nullptr)\r