From b8a63b27a3aa77e8951e8ba85ed24e6c008c7560 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 25 Mar 2025 10:23:21 +0800 Subject: [PATCH] =?utf8?q?UIComponents=E5=85=AC=E5=85=B1UI=E6=96=87?= =?utf8?q?=E4=BB=B6=E5=90=88=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230/nativeapp/CMakeLists.txt | 3 + .../include/ui_resource_string.h | 692 ++++++++++++++ .../config/target_config/brandy/config.py | 2 +- code/sdk/zhihui/UI/CMakeLists.txt | 1 + .../UI/CustomUIComponentTool/CMakeLists.txt | 112 +++ .../uicomponents/UIComponents.cpp | 875 ++++++++++++++++++ .../uicomponents/UIComponents.h | 315 +++++++ 7 files changed, 1999 insertions(+), 1 deletion(-) create mode 100644 code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/ui_resource_string.h create mode 100644 code/sdk/zhihui/UI/CustomUIComponentTool/CMakeLists.txt create mode 100644 code/sdk/zhihui/UI/CustomUIComponentTool/uicomponents/UIComponents.cpp create mode 100644 code/sdk/zhihui/UI/CustomUIComponentTool/uicomponents/UIComponents.h diff --git a/code/sdk/application/wearable/fd230/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/fd230/nativeapp/CMakeLists.txt index d84ffc846..40506f364 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230/nativeapp/CMakeLists.txt @@ -91,6 +91,9 @@ set(PRIVATE_HEADER ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/utils/include ${ROOT_DIR}/open_source/openharmony/utils/native/lite/include ${ROOT_DIR}/open_source/openharmony/utils/native/lite/kv_store/innerkits + + + ${ROOT_DIR}/zhihui/UI/CustomUIComponentTool/ ) file(GLOB_RECURSE SOURCES "${NativeApp}/nativeui/*.cpp") diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/ui_resource_string.h b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/ui_resource_string.h new file mode 100644 index 000000000..7127be443 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/ui_resource_string.h @@ -0,0 +1,692 @@ +/* +* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. +* Description: language +* Author: Graphic develop team +* Create: 2021-07-06 +*/ + +#ifndef UI_RESOURCE_STRING_H +#define UI_RESOURCE_STRING_H +#include +namespace OHOS { +enum UIResourceTextId : uint16_t { + STR_EXERCISE_OUTDOORWALKING = 0, + STR_EXERCISE_OUTDOORRUNNING = 1, + STR_EXERCISE_OUTDOORBIKING = 2, + STR_EXERCISE_GENERAL = 3, + STR_EXERCISE_FREETRAINING = 4, + STR_EXERCISE_RESISTANCETRAINING = 5, + STR_EXERCISE_SPINBIKE = 6, + STR_EXERCISE_TREADMILL = 7, + STR_EXERCISE_STROLLMACHINE = 8, + STR_EXERCISE_HIIT = 9, + STR_EXERCISE_CROSSFIT = 10, + STR_EXERCISE_GROUPCALISTHENICS = 11, + STR_EXERCISE_YOGA = 12, + STR_EXERCISE_YOGACAT = 13, + STR_EXERCISE_YOGACOW = 14, + STR_EXERCISE_YOGACOBRA = 15, + STR_EXERCISE_YOGAHERO1 = 16, + STR_EXERCISE_YOGAHERO2 = 17, + STR_EXERCISE_YOGAHERO3 = 18, + STR_EXERCISE_YOGAROLLING = 19, + STR_EXERCISE_INDOORWALKING = 20, + STR_EXERCISE_INDOORRUNNING = 21, + STR_EXERCISE_JUMPINGROPE = 22, + STR_EXERCISE_PILATES = 23, + STR_EXERCISE_CROSS_FIT = 24, + STR_EXERCISE_FUNCTIONALTRAINING = 25, + STR_EXERCISE_PHYSICALTRAINING = 26, + STR_EXERCISE_TAEKWONDO = 27, + STR_EXERCISE_BOXING = 28, + STR_EXERCISE_KICKBOXING = 29, + STR_EXERCISE_KARATE = 30, + STR_EXERCISE_FENCING = 31, + STR_EXERCISE_CORETRAINING = 32, + STR_EXERCISE_BODYCOMBAT = 33, + STR_EXERCISE_KENDO = 34, + STR_EXERCISE_HORIZONTALBAR = 35, + STR_EXERCISE_PARALLELBARS = 36, + STR_EXERCISE_CIRCUIT = 37, + STR_EXERCISE_AEROBICS = 38, + STR_EXERCISE_CALISTHENICE = 39, + STR_EXERCISE_P90X = 40, + STR_EXERCISE_KETTLEBELLTRAINING = 41, + STR_EXERCISE_MIXEDMARTIALARTS = 42, + STR_EXERCISE_STAIRCLIMBINGMACHINE = 43, + STR_EXERCISE_WEIGHTLIFTING = 44, + STR_EXERCISE_BARRE = 45, + STR_EXERCISE_HANDCYCLING = 46, + STR_EXERCISE_TRACKFIELD = 47, + STR_EXERCISE_WRESTLING = 48, + STR_EXERCISE_MINDBODY = 49, + STR_EXERCISE_FLEXIBILITY = 50, + STR_EXERCISE_MIXEDCARDIO = 51, + STR_EXERCISE_TRADITIONALSTRENGTHTRAINING = 52, + STR_EXERCISE_CROSSTRAINING = 53, + STR_EXERCISE_GYMNASTICS = 54, + STR_EXERCISE_STEPTRAINING = 55, + STR_EXERCISE_ELLIPTICALTRAINER = 56, + STR_EXERCISE_ROWINGMACHINE = 57, + STR_DANCING_GENERAL = 58, + STR_DANCING_BELLY = 59, + STR_DANCING_JAZZ = 60, + STR_DANCING_LATIN = 61, + STR_DANCING_BALLET = 62, + STR_DANCING_STREET = 63, + STR_DANCING_PUBLICSQUARE = 64, + STR_DANCING_ZUMBA = 65, + STR_DANCING_SOCIALDANCE = 66, + STR_DANCING_TAPDANCE = 67, + STR_RECREATIONAL_SPORTS = 68, + STR_RECREATIONAL_SKATING = 69, + STR_RECREATIONAL_MARTIALARTS = 70, + STR_RECREATIONAL_TAICHI = 71, + STR_RECREATIONAL_HULAHOOP = 72, + STR_RECREATIONAL_DISCSPORT = 73, + STR_RECREATIONAL_DARTS = 74, + STR_RECREATIONAL_ARCHERY = 75, + STR_RECREATIONAL_HORSERIDING = 76, + STR_RECREATIONAL_BATTLEGAME = 77, + STR_RECREATIONAL_KITE = 78, + STR_RECREATIONAL_TUGOFWAR = 79, + STR_RECREATIONAL_SWING = 80, + STR_RECREATIONAL_STAIRCLIMBING = 81, + STR_RECREATIONAL_OBSTACLERACE = 82, + STR_RECREATIONAL_FISHING = 83, + STR_RECREATIONAL_HUNTING = 84, + STR_RECREATIONAL_SCOOTERRIDING = 85, + STR_RECREATIONAL_PARAGLIDING = 86, + STR_RECREATIONAL_TEAMSPORTS = 87, + STR_RECREATIONAL_FINESSGAMING = 88, + STR_RECREATIONAL_HIKING = 89, + STR_RECREATIONAL_EQUESTRIANSPORTS = 90, + STR_RECREATIONAL_PLAY = 91, + STR_BALL_GAMES = 92, + STR_BALL_BADMINTON = 93, + STR_BALL_TABLETENNIS = 94, + STR_BALL_TENNIS = 95, + STR_BALL_BILLIARDS = 96, + STR_BALL_BOWLING = 97, + STR_BALL_VOLLEYBALL = 98, + STR_BALL_SHUTTLECOCK = 99, + STR_BALL_HANDBALL = 100, + STR_BALL_BASEBALL = 101, + STR_BALL_SOFTBALL = 102, + STR_BALL_CRICKET = 103, + STR_BALL_FOOTBALL = 104, + STR_BALL_BEACHSOCCER = 105, + STR_BALL_BEACHVOLLEYBALL = 106, + STR_BALL_CROQUET = 107, + STR_BALL_HOCKEY = 108, + STR_BALL_SQUASH = 109, + STR_BALL_SEPAKTAKRAW = 110, + STR_BALL_DODGEBALL = 111, + STR_BALL_BASKETBALL = 112, + STR_BALL_SOCCER = 113, + STR_BALL_GOLF = 114, + STR_BALL_POLO = 115, + STR_BALL_RACQUETBALL = 116, + STR_BALL_RUGBY = 117, + STR_BALL_GATEBALL = 118, + STR_BALL_PICKLEBALL = 119, + STR_BALL_LACROSSE = 120, + STR_WATER_ACTIVITIES = 121, + STR_WATER_SAILING = 122, + STR_WATER_SURFING = 123, + STR_WATER_WHITEWATERRAFTING = 124, + STR_WATER_CANOEING = 125, + STR_WATER_KAYAKING = 126, + STR_WATER_ROWING = 127, + STR_WATER_MOTORBOAT = 128, + STR_WATER_SUP = 129, + STR_WATER_SCUBADIVING = 130, + STR_WATER_DIVING = 131, + STR_WATER_KITESURFING = 132, + STR_WATER_WAKEBOARDING = 133, + STR_WATER_POLO = 134, + STR_WATER_WINDSURFING = 135, + STR_WATER_DRIFTING = 136, + STR_WATER_FITNESS = 137, + STR_WATER_SPORTS = 138, + STR_WATER_OUTDOORSWIM = 139, + STR_WATER_INDOORSWIM = 140, + STR_WATER_SWIMFREESTYLE = 141, + STR_WATER_SWIMBREASTSTROKE = 142, + STR_WATER_SWIMBACKSTROKE = 143, + STR_WATER_SWIMBUTTERFLY = 144, + STR_ICE_SPORTS = 145, + STR_ICE_SKATING = 146, + STR_ICE_HOCKEY = 147, + STR_ICE_CURLING = 148, + STR_ICE_SNOWMOBILING = 149, + STR_ICE_SLED = 150, + STR_ICE_BIATHLON = 151, + STR_ICE_CROSSCOUNTRYSKING = 152, + STR_ICE_SKIING = 153, + STR_ICE_SNOWBOARDING = 154, + STR_ICE_SNOWSHOEING = 155, + STR_ICE_SNOWSPORTS = 156, + STR_EXTREME_SPORTS = 157, + STR_EXTREME_SKATEBOARDING = 158, + STR_EXTREME_ROCKCLIMBING = 159, + STR_EXTREME_BUNGEEJUMPING = 160, + STR_EXTREME_PARKOUR = 161, + STR_EXTREME_BMX = 162, + STR_EXTREME_ORIENTEERING = 163, + STR_EXTREME_PARACHUTE = 164, + STR_EXTREME_RACING = 165, + STR_EXTREME_TRIATHLONS = 166, + STR_OTHER_ELEVATOR = 167, + STR_OTHER_ESCALATOR = 168, + STR_OTHER_GARDENING = 169, + STR_OTHER_HORSEWORK = 170, + STR_OTHER_INVEHICLE = 171, + STR_OTHER_MEDITATION = 172, + STR_OTHER_STILL = 173, + STR_OTHER_TILTING = 174, + STR_OTHER_WHEELCHAIR = 175, + STR_HEART_RATE = 176, + STR_BLOOD_OXYGEN = 177, + STR_TRAINING = 178, + STR_TRAINING_RECORD = 179, + STR_COMPASS = 180, + STR_TELEPHONE = 181, + STR_FAVORITE_CONTACTS = 182, + STR_WEATHER = 183, + STR_ACTIVITY = 184, + STR_WATCH_FACE = 185, + STR_DISPLAY_MODE = 186, + STR_CARD_MANAGEMENT = 187, + STR_MUSIC = 188, + STR_SLEEP = 189, + STR_RECORD = 190, + STR_BREATH_TRAINING = 191, + STR_REMOTE_SHOOTING = 192, + STR_VOICE_ASSISTANT = 193, + STR_ALIPAY = 194, + STR_TIMER = 195, + STR_ALARM = 196, + STR_STOPWATCH = 197, + STR_CALCULATOR = 198, + STR_FIND_PHONE = 199, + STR_BRIGHTNESS_ADJUSTMENT = 200, + STR_SOUND = 201, + STR_BLUETOOTH = 202, + STR_DO_NOT_DISTURB = 203, + STR_MESSAGE_NOTIFICATION = 204, + STR_POWER_SAVE_MODE = 205, + STR_FLASHLIGHT = 206, + STR_SETTINGS = 207, + STR_EXERCISE_LIST = 208, + STR_BALL_LIST = 209, + STR_WATER_LIST = 210, + STR_DANCING_LIST = 211, + STR_EXTREME_LIST = 212, + STR_ICE_LIST = 213, + STR_RECREATIONAL_LIST = 214, + STR_OTHER_LIST = 215, + STR_DANCING_TITLE = 216, + STR_BALL_LIST_TITLE = 217, + STR_OTHER_TITLE = 218, + STR_EXERCISE_TITLE = 219, + STR_RAPID_TRAINING = 220, + STR_SET_GOALS = 221, + STR_DURATION = 222, + STR_DURATION_SETTING = 223, + STR_CALORIE = 224, + STR_CALORIE_SETTING = 225, + STR_DISTANCE = 226, + STR_RANGE_SETTING = 227, + STR_STEP_NUMBER = 228, + STR_STEP_SETTING = 229, + STR_HEART_RATE_SETTING = 230, + STR_MEAN_HEART_RATE = 231, + STR_TIMES_PER_MIN = 232, + STR_MEAN_HEART_RATE_MIN = 233, + STR_LOWER_STRENGTH = 234, + STR_MEDIUM_STRENGTH = 235, + STR_HIGH_STRENGTH = 236, + STR_ULTRA_HIGH_STRENGTH = 237, + STR_TRAINING_INTENSITY = 238, + STR_TRAINING_IN_PROGRESS = 239, + STR_BREAK_TRAINING = 240, + STR_FINISH = 241, + STR_PAUSE = 242, + STR_RESUME = 243, + STR_GOAL_ACHIEVED = 244, + STR_ACCOMPLISH_GOAL = 245, + STR_OK = 246, + STR_LOOK_OUT = 247, + STR_INSUFFICIENT_EXERCISE_AMOUNT = 248, + STR_END_MOVEMENT = 249, + STR_END_THIS_MOVEMENT = 250, + STR_GOAL_ACCOMPLISHMENT_DEGREE = 251, + STR_TRAINING_DURATION = 252, + STR_RANGE_MILE = 253, + STR_CLOSE = 254, + STR_MORE = 255, + STR_MORE_APP = 256, + STR_SAVENOTE = 257, + STR_SAVEBACK = 258, + STR_SAVEASK = 259, + STR_BLOOD = 260, + STR_CHECK = 261, + STR_CHECKNEW = 262, + STR_CHECKTIME = 263, + STR_CHECKLONG = 264, + STR_CHECKNO = 265, + STR_CHECKNOTE = 266, + STR_CHECKON = 267, + STR_CHECKSTOP = 268, + STR_CHECKERROR = 269, + STR_WAERKEEP = 270, + STR_WEARRE = 271, + STR_WEARREADY = 272, + STR_RECHECK = 273, + STR_CHECKEWARN = 274, + STR_BLOODSHORT = 275, + STR_HEARTNOTE = 276, + STR_KONW = 277, + STR_EXPLAIN = 278, + STR_HEARTREST = 279, + STR_HEARTDATA = 280, + STR_HEARTTITLE = 281, + STR_HEARTMAX = 282, + STR_HEARTMIN = 283, + STR_TRAINGNO = 284, + STR_TRAINGGO = 285, + STR_MESSAGENO = 286, + STR_CLEAN = 287, + STR_CLEANALL = 288, + STR_SLEEP_YESTERDAY = 289, + STR_HOUR = 290, + STR_MIN = 291, + STR_SLEEPMGOAL = 292, + STR_REATTIME = 293, + STR_SLEEPTIME = 294, + STR_WALKTIME = 295, + STR_APPMORE = 296, + STR_DISTURB = 297, + STR_DISTURBNOTE = 298, + STR_MORNNING = 299, + STR_NOW = 300, + STR_NAP = 301, + STR_TACK = 302, + STR_CLICK = 303, + STR_TACKNUM = 304, + STR_SCREEN_AND_BRIGHTNESS = 305, + STR_NETWORKANDCALL = 306, + STR_SOUND_AND_VIBRATION = 307, + STR_MOTION_RECOGNITION = 308, + STR_SYSTEM = 309, + STR_SHUTDOWN_AND_RESTART = 310, + STR_SCREEN_ON_DURATION = 311, + STR_RAISE_TO_WAKE = 312, + STR_5_SECONDS = 313, + STR_10_SECONDS = 314, + STR_15_SECONDS = 315, + STR_30_SECONDS = 316, + STR_60_SECONDS = 317, + STR_300_SECONDS = 318, + STR_4G_CAPABILITY = 319, + STR_VOLTE_CALL = 320, + STR_MOBILE_DATA_OPTION = 321, + STR_SYSTEM_UPDATE = 322, + STR_ONLINE_MUSIC = 323, + STR_BLUETOOTH_HEADPHONES = 324, + STR_TRADITIONAL_BLUETOOTH = 325, + STR_AUTO_OFF_BLUETOOTH_NOTE = 326, + STR_BLUETOOTH_SERVICE_OPTIONS = 327, + STR_HFP = 328, + STR_A2DP = 329, + STR_SYSTEM_VOLUME = 330, + STR_MEDIA_VOLUME = 331, + STR_CALL_VOLUME = 332, + STR_VIBRATION_MODE = 333, + STR_SILENT_MODE = 334, + STR_LIST_DISPLAY = 335, + STR_GRID_DISPLAY = 336, + STR_CELLULAR_DISPLAY = 337, + STR_AUTO_DETECT = 338, + STR_ABOUT_WATCH = 339, + STR_WATCH_QR_CODE = 340, + STR_SYSTEM_LANGUAGE = 341, + STR_RESTART = 342, + STR_SHUTDOWN = 343, + STR_FACTORY_RESET = 344, + STR_WATCH_NAME = 345, + STR_FIRMWARE_VERSION = 346, + STR_BLUETOOTH_NAME = 347, + STR_BLUETOOTH_ADDRESS = 348, + STR_UPDATENOW = 349, + STR_LATEST_VERSION = 350, + STR_LATER = 351, + STR_UP_TO_DATE = 352, + STR_NO_UPDATE = 353, + STR_LANGUAGE_SELECTION = 354, + STR_RESET_CONFIRM = 355, + STR_SHUTDOWN_CONFIRM = 356, + STR_RESET_CONFIRM_NOTE = 357, + STR_RECORDER = 358, + STR_CLICK_TO_RECORD = 359, + STR_RECORDING = 360, + STR_AUDIO_XX = 361, + STR_VOICE_RECORDING_REMINDER = 362, + STR_VOICE_RECORDING_REMINDER_NOTE = 363, + STR_DELETE_RECORDING = 364, + STR_DELETE_PERMANENTLY = 365, + STR_RECORDING_LIST = 366, + STR_CRLEMPTY = 367, + STR_DO_NOT_DISTURB_MODE = 368, + STR_CONNECTION_STATUS = 369, + STR_PHONE = 370, + STR_HEADSET = 371, + STR_CONNECTED = 372, + STR_DISCONNECTED = 373, + STR_PHONE_RINGING_VIBRATING = 374, + STR_BLUETOOTH_DISCONNECTED = 375, + STR_STOP = 376, + STR_WORKDAY = 377, + STR_REPEAT_NO = 378, + STR_EVERYDAY = 379, + STR_ADD_A_NEW_ALARM = 380, + STR_TIME = 381, + STR_NEXT_STEP = 382, + STR_MON = 383, + STR_TUES = 384, + STR_WEDNES = 385, + STR_THURS = 386, + STR_FRI = 387, + STR_SATUR = 388, + STR_SUN = 389, + STR_MONDAY = 390, + STR_TUESDAY = 391, + STR_WEDNESDAY = 392, + STR_THURSDAY = 393, + STR_FRIDAY = 394, + STR_SATURDAY = 395, + STR_SUNDAY = 396, + STR_CALIBRATE_COMPASS = 397, + STR_CALIBRATE_COMPASS_NOTE = 398, + STR_EAST = 399, + STR_SOUTH = 400, + STR_WEST = 401, + STR_NORTH = 402, + STR_SOUTHEAST = 403, + STR_SOUTHWEST = 404, + STR_NORTHEAST = 405, + STR_NORTHWEST = 406, + STR_KEEP_STILL_FOCUS_ON_BREATHING = 407, + STR_EXHALE_NOW = 408, + STR_INHALE_NOW = 409, + STR_TRAINING_COMPLETE = 410, + STR_THIS_BREATH = 411, + STR_TODAYS_BREATHING_TRAINING = 412, + STR_RECENT_CALLS = 413, + STR_NO_CALLS = 414, + STR_MISSED_CALLS = 415, + STR_DIALED_CALLS = 416, + STR_RECEIVED_CALLS = 417, + STR_NOTE_RECENT_CALLS_LIMITATION = 418, + STR_NO_CONTACTS_ADDED = 419, + STR_DIAL_MODE = 420, + STR_DIAL_VIA_WATCH_SIM = 421, + STR_DIAL_VIA_PHONE = 422, + STR_KUMI_TECHNOLOGY = 423, + STR_CALLING = 424, + STR_NOT_PAIRED = 425, + STR_PAIRED = 426, + STR_UNPAIR = 427, + STR_CONNECTION_ERROR = 428, + STR_INSERT_WATCH_SIM_OR_CONNECT_PHONE = 429, + STR_ENABLE_BLUETOOTH_CALL = 430, + STR_SOLUTION = 431, + STR_IPHONE = 432, + STR_ANDROID = 433, + STR_ENABLE_BLUETOOTH_CALL_NOTE_IPHONE = 434, + STR_ENABLE_BLUETOOTH_CALL_NOTE_ANDROID = 435, + STR_SIM_CARD_ERROR = 436, + STR_CHECK_SIM_CARD_INSERTION = 437, + STR_WEATHER_REPORT = 438, + STR_ULTRAVIOLET = 439, + STR_WIND_SPEED = 440, + STR_HUMIDITY = 441, + STR_NEXT_7_DAYS = 442, + STR_GET_WEATHER_ERROR = 443, + STR_MUSIC_SOURCE = 444, + STR_MOBILE_MUSIC = 445, + STR_WATCH_MUSIC = 446, + STR_MUSIC_LIST = 447, + STR_BLUETOOTH_CONNECTION_FAILED = 448, + STR_SCANNING_BINDING = 449, + STR_DEVICE_BINDING = 450, + STR_DEVICE_BINDING_NOTE = 451, + STR_EQUIPMENT_UNTYING = 452, + STR_EQUIPMENT_UNTYING_NOTE = 453, + STR_DRINK_WATER_REMINDER = 454, + STR_DRINK_WATER_REMINDER_NOTE = 455, + STR_SEDENTARY_REMINDER = 456, + STR_SEDENTARY_REMINDER_NOTE = 457, + STR_SYSTEM_UPGRADING = 458, + STR_NEWDEVICE_BIND_REMIND_NOTE1 = 459, + STR_NEWDEVICE_BIND_REMIND_NOTE2 = 460, + STR_NEWDEVICE_BIND_REMIND_NOTE3 = 461, + STR_AI_VOICE = 462, + STR_AI_INTELLIGENT_ASSISTANT = 463, + STR_START_CHAT = 464, + STR_BOOT_FAILED = 465, + STR_ENABLE_MOBILE_DATA_FIRST = 466, + STR_ENABLE_BLUETOOTH_FIRST = 467, + STR_LISTENING = 468, + STR_FINISH_SPEAKING = 469, + STR_THINKING = 470, + STR_CANCEL = 471, + STR_CONNECT_TIMEOUT = 472, + STR_PLEASE_RESTART_CHAT = 473, + STR_CONTINUE_CHAT = 474, + STR_AIMODELS_DOUBAO = 475, + STR_AIMODES_WENXINYIYAN = 476, + STR_AIMODES_KIMI = 477, + STR_AIMODES_CHATGPT = 478, + STR_SLIDE_TO_SHUTDOWN = 479, + STR_SLIDE_TO_REBOOT = 480, + STR_AI_FAMILY_MEALS = 481, + STR_CHAT = 482, + STR_PCY4GC_OR_AS = 483, + STR_API_KEYS = 484, + STR_PGTTAF = 485, + STR_DAFBS = 486, + STR_OPENAI_API_KEYS = 487, + STR_KHBB = 488, + STR_GTAS = 489, + STR_DYWTDAK = 490, + STR_CONNECTING = 491, + STR_CONNECTION_FAIL = 492, + STR_PTALORTM = 493, + STR_MOTION_DETECTION_WALK_NOTE = 494, + STR_MOTION_DETECTION_RUN_NOTE = 495, + STR_MOTION_DETECTION_RIDE_NOTE = 496, + STR_MOTION_DETECTION_ROWING_NOTE = 497, + STR_MOTION_DETECTION_ELLIPTICAL_NOTE = 498, + STR_PE4GC = 499, + STR_OBU_MESSAGE = 500, + STR_DELETE = 501, + STR_CHARGE = 502, + STR_CHARGE_NOTE = 503, + STR_STEP_FREQUENCY = 504, + STR_STEP_LENGTH = 505, + STR_AVG_PACE = 506, + STR_TONGYI_QIANWEN = 507, + STR_IFLYTEK_SPARK = 508, + STR_DISTURBNOTE_OFF = 509, + STR_4G_NOTE = 510, + STR_MUSIC_PLAYER_SOURCE_NOTE = 511, + STR_MUSIC_LIST_IS_EMPTY = 512, + STR_BT_HEADSET_RESCAN = 513, + STR_BT_HEADSET_NOFOND = 514, + STR_SCHEDULE = 515, + STR_SCHEDULE_TITLE = 516, + STR_SCHEDULE_NO_DATA = 517, + STR_SCHEDULE_NO_DATA_PROMPT = 518, + STR_NO_PAIRED_DEV = 519, + STR_IGNORE = 520, + STR_START = 521, + STR_ARC_SCALE_LIST_DISPLAY = 522, + STR_COUNT_DOWN = 523, + STR_CUSTOM_TIME = 524, + STR_QUICK_START = 525, + STR_1_MIN = 526, + STR_5_MIN = 527, + STR_10_MIN = 528, + STR_30_MIN = 529, + STR_SET_COUNT_DOWN_NOTE = 530, + STR_COUNTDOWN_ENDS = 531, + STR_MAXIMUM_TIME_REACH_NOTE = 532, + STR_STOPWATCH_STOP_NOTE = 533, + STR_TMCHBR = 534, + STR_SCHEDULE_TOPIC = 535, + STR_SCHEDULE_TIME = 536, + STR_SCHEDULE_NOTES = 537, + STR_SCHEDULE_DELETE_PROMPT = 538, + STR_HANG_UP_OR_ANSWER = 539, + STR_WATCH_CALL = 540, + STR_PHONE_CALL = 541, + STR_STEPS_OF_THE_DAY = 542, + STR_MILEAGE = 543, + STR_FAT_BURNING_TIME = 544, + STR_NUMBER_OF_STANDS = 545, + STR_CONSUME_CALORIES = 546, + STR_GOAL_HINT = 547, + STR_SLEEPMODE = 548, + STR_SLEEP_MODE_PROMPT_ON = 549, + STR_LOW_POWER_NOTIF_1 = 550, + STR_LOW_POWER_NOTIF_2 = 551, + STR_CONNECTION_SUCC = 552, + STR_RETRY = 553, + STR_BTEARPHONE_CONN_FAIL_TIP = 554, + STR_FLASHLIGHT_SETTING = 555, + STR_LIGHT_COLOR = 556, + STR_FLICKER_FREQUENCY = 557, + STR_NO_FLICKER = 558, + STR_FAST_FLICKER = 559, + STR_SLOW_FLICKER = 560, + STR_BROWSING_SPECIAL_EFFECTS = 561, + STR_OVERLAY_FLOW = 562, + STR_ROLLER = 563, + STR_DIAL_BROWSING_SPECIAL_EFFECTS = 564, + STR_SET_TARGET = 565, + STR_PWUWC = 566, + STR_CALENDAR = 567, + STR_ALARM_DELETE_NOTE = 568, + STR_ALARM_TIME_CHANGE = 569, + STR_ALARM_WEEK_CHANGE = 570, + STR_ALARM_REPEAT = 571, + STR_ALARM_ADD_LIMIT_NOTE = 572, + STR_MOTION_RECOGNITION_NOTE = 573, + STR_DURATION_SETTINGS = 574, + STR_2_MIN = 575, + STR_3_MIN = 576, + STR_4_MIN = 577, + STR_ONE_MIN = 578, + STR_TWO_MIN = 579, + STR_THREE_MIN = 580, + STR_FOUR_MIN = 581, + STR_FIVE_MIN = 582, + STR_MUSIC_TRANSMIT = 583, + STR_MUSIC_TRANSMIT_NOTE = 584, + STR_MUSIC_TRANSMIT_SUCCESS_NOTE = 585, + STR_OTA_DOWNLOAD = 586, + STR_OTA_DOWNLOADING = 587, + STR_OTA_DOWNLOADFIAL = 588, + STR_OTA_DOWNLOADFIAL_TRY = 589, + STR_OTA_DOWNLOADSUCC = 590, + STR_OTA_DOWNLOADSUCC_UPDATA = 591, + STR_DIAL_DOWNLOADING_TITLE = 592, + STR_DIAL_DOWNLOADING_LABEL = 593, + STR_MP3_SUCC_TITLE = 594, + STR_DIAL_SUCC_TITLE = 595, + STR_DIAL_SUCC_LABEL = 596, + STR_DIAL_FAIL_TITLE = 597, + STR_DIAL_FAIL_LABEL = 598, + STR_MP3_FAIL_TITL = 599, + STR_MP3_FAIL_LABEL = 600, + STR_CALLSOMEONE = 601, + STR_BLUENOTE = 602, + STR_VOICE_FAIL = 603, + STR_WAKE_VOIVE = 604, + STR_TIME_SET = 605, + STR_FORMAT = 606, + STR_FORMAT_NOTE = 607, + STR_SLEEP_UPDATE = 608, + STR_CAMERA = 609, + STR_GOAL_TITLE = 610, + STR_HEART_HIAGER = 611, + STR_CHARG_DOWN = 612, + STR_CHAEGING = 613, + STR_GOAL_DOWN = 614, + STR_OPERAT_FAIL = 615, + STR_DIAL_NOTE = 616, + STR_HEART_UNKOWN = 617, + STR_HEART_AVAILABLE = 618, + STR_HEART_JUST = 619, + STR_HEART_MIN_AGO = 620, + STR_HEART_HOUR_AGO = 621, + STR_RECORDS_20 = 622, + STR_RECORDS_NOTE = 623, + STR_RECORDS_DELETE = 624, + STR_NEW_INCOM = 625, + STR_NET_ERROR = 626, + STR_LANGUAGE_SELECTION_NOTE = 627, + STR_AUTO_OFF_BLUETOOTH_NOTE2 = 628, + STR_PHONE_MUSCI_NOTE = 629, + STR_TIME_FORMAT_SET = 630, + STR_DIAL_PLATE = 631, + STR_SLEEP_NOTIFY = 632, + STR_SLEEP_NOTE = 633, + STR_MAX_CARD = 634, + STR_NUM_LENGTH = 635, + STR_CALL_LIST = 636, + STR_DELETE_ALL = 637, + STR_FRE_CONTACT = 638, + STR_RECORD_MAX = 639, + STR_CLEAR_ALL_RECORDS = 640, + STR_DEEPSEEK = 641, + STR_MAX_ID = 642, +}; // UIResourceTextId + +enum FontLanguageId : uint8_t { + LANGUAGE_ID_AR, + LANGUAGE_ID_AZ, + LANGUAGE_ID_CS, + LANGUAGE_ID_DE, + LANGUAGE_ID_EL, + LANGUAGE_ID_EN, + LANGUAGE_ID_ES, + LANGUAGE_ID_FA, + LANGUAGE_ID_FI, + LANGUAGE_ID_FR, + LANGUAGE_ID_HE, + LANGUAGE_ID_HI, + LANGUAGE_ID_HR, + LANGUAGE_ID_ID, + LANGUAGE_ID_IT, + LANGUAGE_ID_JA, + LANGUAGE_ID_KO, + LANGUAGE_ID_MS, + LANGUAGE_ID_NL, + LANGUAGE_ID_PL, + LANGUAGE_ID_PT, + LANGUAGE_ID_RO, + LANGUAGE_ID_RU, + LANGUAGE_ID_SV, + LANGUAGE_ID_TH, + LANGUAGE_ID_TR, + LANGUAGE_ID_UK, + LANGUAGE_ID_UZ, + LANGUAGE_ID_VI, + LANGUAGE_ID_ZH, + LANGUAGE_ID_MAX +}; // UITextLanguageTextId +} +#endif /* UI_RESOURCE_STRING_H */ diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index 8c4257fee..4cbce82c0 100644 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -392,7 +392,7 @@ target = { # "slip", # "cat1_service", "audio_manager", - # "CustomUIcomponentTool", + "CustomUIcomponentTool", "custom_utils", "custom_utilscpp", "custom_config", diff --git a/code/sdk/zhihui/UI/CMakeLists.txt b/code/sdk/zhihui/UI/CMakeLists.txt index 961cbff4c..63f3832ab 100644 --- a/code/sdk/zhihui/UI/CMakeLists.txt +++ b/code/sdk/zhihui/UI/CMakeLists.txt @@ -1 +1,2 @@ +add_subdirectory_if_exist(CustomUIComponentTool) add_subdirectory_if_exist(producttest) \ No newline at end of file diff --git a/code/sdk/zhihui/UI/CustomUIComponentTool/CMakeLists.txt b/code/sdk/zhihui/UI/CustomUIComponentTool/CMakeLists.txt new file mode 100644 index 000000000..5867d248b --- /dev/null +++ b/code/sdk/zhihui/UI/CustomUIComponentTool/CMakeLists.txt @@ -0,0 +1,112 @@ +set(COMPONENT_NAME "CustomUIcomponentTool") +set(UI_SAMPLE_ROOT ${ROOT_DIR}/middleware/services/gui/uikit/sample/uitest) + +set(PUBLIC_HEADER + ${CMAKE_CURRENT_SOURCE_DIR} +) + +set(PRIVATE_HEADER + ${ROOT_DIR}/open_source/openharmony/foundation/ace/ace_engine_lite/interfaces/base + ${ROOT_DIR}/open_source/openharmony/third_party/cJSON + ${UI_SAMPLE_ROOT}/components + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/ui/frameworks + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/ui/innerkits + ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include/components + + ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits + ${ROOT_DIR}/middleware/services/gui/lvgl/src/hal + ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/kits/events + ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/kits + + ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits + ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits/gfx_utils + ${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/innerkits + ${ROOT_DIR}/middleware/services/gui/uikit/surface/interfaces/kits + ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/kits + ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/kits/components + ${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/kits/events + ${ROOT_DIR}/middleware/services/gui/uikit/ui/frameworks/ + + + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/interfaces/kits/events + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/interfaces/kits + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/utils/interfaces/kits + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/utils/interfaces/kits/gfx_utils + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/utils/interfaces/innerkits + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/interfaces/innerkits + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/frameworks + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/surface/interfaces/kits + ${ROOT_DIR}/open_source/openharmony/foundation/graphic/ui/interfaces/kits/components + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/player/interfaces/kits/ + ${ROOT_DIR}/open_source/openharmony/third_party/qrcodegen/cpp + ${ROOT_DIR}/include/middleware/services/bts/common + ${ROOT_DIR}/include/middleware/services/bts/ble + ${ROOT_DIR}/include/middleware/services/bts/br + + + ${ROOT_DIR}/include/middleware/services/bts/common + ${ROOT_DIR}/include/middleware/services/bts/ble + ${ROOT_DIR}/include/middleware/services/bts/br + + ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include + ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/cywee/ + ${ROOT_DIR}/open_source/openharmony/foundation/distributedschedule/samgr_lite/interfaces/kits/samgr + + + ${ROOT_DIR}/middleware/services/media/foundation/sample/wrapper + ${ROOT_DIR}/application/wearable/service/msg_center/include + ${ROOT_DIR}/application/wearable/service/ble_service/bleservice + ${ROOT_DIR}/application/wearable/service/ble_service/blemoder + ${ROOT_DIR}/application/wearable/nativeabilityfwk/include + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/audio_player/interfaces/kits + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/audiomanager/interfaces/kits/audiomanager + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/audiomanager/interfaces/kits/audiocommon + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/player/interfaces/kits/ + ${ROOT_DIR}/open_source/openharmony/foundation/multimedia/utils/include + ${ROOT_DIR}/open_source/openharmony/utils/native/lite/include + ${ROOT_DIR}/open_source/openharmony/utils/native/lite/kv_store/innerkits +) + +set(SOURCES + #UI组件初始化 + ${CMAKE_CURRENT_SOURCE_DIR}/uicomponents/UIComponents.cpp + +) + +set(COMPONENT_PUBLIC_CCFLAGS +) + +set(COMPONENT_CCFLAGS + -std=c++11 + -Wno-error + -Wno-unused-parameter + -fno-exceptions + -fno-unwind-tables + -fno-asynchronous-unwind-tables + -Wno-undef + -Wno-bitwise-op-parentheses + -Wno-shift-op-parentheses + -nostdlibinc + -nostdinc + -nostdlib + -Wno-c++11-narrowing + -Wno-error=unused-function +) + +set(WHOLE_LINK + true +) + +set(MAIN_COMPONENT + false +) + +set(PUBLIC_DEFINES +) + +set(PRIVATE_DEFINES +) + +build_component() diff --git a/code/sdk/zhihui/UI/CustomUIComponentTool/uicomponents/UIComponents.cpp b/code/sdk/zhihui/UI/CustomUIComponentTool/uicomponents/UIComponents.cpp new file mode 100644 index 000000000..b2313a51b --- /dev/null +++ b/code/sdk/zhihui/UI/CustomUIComponentTool/uicomponents/UIComponents.cpp @@ -0,0 +1,875 @@ +#include "uicomponents/UIComponents.h" +#include "common/text.h" +#include "common/typed_text.h" +#include "font/ui_font.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace OHOS { + +// 定义按键颜色宏 +#define DEFAULT_BACKGROUND_COLOR 0xff191919 +#define PRESSED_BACKGROUND_COLOR 0xff249115 +#define PRESSED_BORDER_COLOR 0xff0b1928 +/*** + * @description: 初始化标签 + * @param {UILabel} * + * @param {int} left + * @param {int} top + * @param {int} width + * @param {int} height + * @param {char} *viewId + * @param {char} *text + * @param {char} *fontName + * @param {int} fontSize + * @return + * @brief 初始化标签 + */ +bool InitUILabel(UILabel *&label, int left, int top, int width, int height, + const char *viewId, const char *text, const char *fontName, + int fontSize) { + // 检查标签指针是否为空 + if (label == nullptr) { + label = new UILabel(); + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitUILabel is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitUILabel is not nullptr"); + return false; // 内存分配失败,返回false + } + // 设置标签的位置和大小 + label->SetPosition(left, top); + label->Resize(width, height); + // 设置标签的视图 ID + label->SetViewId(viewId); + // 设置标签的样式 + label->SetStyle(STYLE_TEXT_FONT, fontSize); + label->SetFont(fontName, fontSize); + // 设置标签的文本和其他属性 + label->SetText(text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + return true; +} +/*** + * @description: 初始化标签 + * @param {UILabel} * + * @param {int} left + * @param {int} top + * @param {int} width + * @param {int} height + * @param {char} *viewId + * @param {char} *text + * @param {char} *fontName + * @param {int} fontSize + * @return + * @brief 初始化标签 + */ +bool InitRollLabel(UILabelExt *&label, int left, int top, int width, int height, + const char *viewId, UIResourceTextId id, + const char *fontName, int fontSize) { + // 检查标签指针是否为空 + if (label == nullptr) { + label = new UILabelExt(); + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is not nullptr"); + return false; // 内存分配失败,返回false + } + // 设置标签的位置和大小 + label->SetPosition(left, top); + label->Resize(width, height); + // 设置标签的视图 ID + label->SetViewId(viewId); + // 设置标签的样式 + label->SetStyle(STYLE_TEXT_FONT, fontSize); + label->SetFont(fontName, fontSize); + // 设置标签的文本和其他属性 + label->SetTextId(id); + label->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + label->SetRollSpeed(23); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + return true; +} +/*** + * @description: 初始化标签 + * @param {UILabel} * + * @param {int} left + * @param {int} top + * @param {int} width + * @param {int} height + * @param {char} *viewId + * @param {char} *text + * @param {char} *fontName + * @param {int} fontSize + * @return + * @brief 初始化标签 + */ +bool InitLabel(UILabelExt *&label, int left, int top, int width, int height, + const char *viewId, const char *text, const char *fontName, + int fontSize) { + // 检查标签指针是否为空 + if (label == nullptr) { + label = new UILabelExt(); + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is not nullptr"); + return false; // 内存分配失败,返回false + } + // 设置标签的位置和大小 + label->SetPosition(left, top); + label->Resize(width, height); + // 设置标签的视图 ID + label->SetViewId(viewId); + // 设置标签的样式 + label->SetStyle(STYLE_TEXT_FONT, fontSize); + label->SetFont(fontName, fontSize); + // 设置标签的文本和其他属性 + label->SetText(text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + + return true; +} +bool InitLabelAdapt(UILabelExt *&label, int left, int top, int width, + int height, const char *viewId, const char *text, + const char *fontName, int fontSize) { + // 检查标签指针是否为空 + if (label == nullptr) { + label = new UILabelExt(); + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is not nullptr"); + return false; // 内存分配失败,返回false + } + // 设置标签的位置和大小 + label->SetPosition(left, top); + label->Resize(width, height); + // 设置标签的视图 ID + label->SetViewId(viewId); + // 设置标签的样式 + label->SetStyle(STYLE_TEXT_FONT, fontSize); + label->SetFont(fontName, fontSize); + // 设置标签的文本和其他属性 + label->SetText(text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + return true; +} +#ifdef FD230 +/*** + * @description: + * @param {UILabelExt} * + * @param {int} left + * @param {int} top + * @param {int} width + * @param {int} height + * @param {char} *viewId + * @param {char} *text + * @param {char} *fontName + * @param {int} fontSize + * @return {*} + * @brief 初始化多国语言标签 + */ +bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, + const char *viewId, UIResourceTextId id, const char *fontName, + int fontSize) { + // 检查标签指针是否为空 + if (label == nullptr) { + label = new UILabelExt(); + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelExt is not nullptr"); + return false; // 内存分配失败,返回false + } + // 设置标签的位置和大小 + label->SetPosition(left, top); + label->Resize(width, height); + // 设置标签的视图 ID + label->SetViewId(viewId); + // 设置标签的样式 + label->SetStyle(STYLE_TEXT_FONT, fontSize); + label->SetFont(fontName, fontSize); + // 设置标签的文本和其他属性 + label->SetTextId(id); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + return true; +} + +/*** + * @description: + * @param {UILabelButtonExt} * + * @param {int} left + * @param {int} top + * @param {int} width + * @param {int} height + * @param {char} *viewId + * @param {UIResourceTextId} id + * @param {int} fontSize + * @return {*} + * @brief 初始化带label的button + */ +bool InitButtonExt(UILabelButtonExt *&button, int left, int top, int width, + int height, const char *viewId, UIResourceTextId id, + int fontSize) { + // 创建新按钮(如果当前按钮为空) + if (button == nullptr) { + button = new UILabelButtonExt(); + if (button == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "UILabelButtonExt UILabelButtonExt is not nullptr"); + return false; // 内存分配失败,返回false + } + button->SetPosition(left, top); + button->Resize(width, height); + button->SetViewId(viewId); + button->SetTextId(id); + button->SetStyle(STYLE_TEXT_FONT, fontSize); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontSize); + button->SetStyle(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, + UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, PRESSED_BORDER_COLOR, + UIButton::PRESSED); + button->SetVisible(true); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is succeed"); + return true; +} +/*** + * @description: + * @param {UILabelButton} * + * @param {int} left + * @param {int} top + * @param {int} width + * @param {int} height + * @param {char} *viewId + * @param {UIResourceTextId} id + * @param {int} fontSize + * @return {*} + * @brief 初始化带label的button + */ +bool InitLabelButton(UILabelButton *&button, int left, int top, int width, + int height, const char *viewId, const char *text, + int fontSize) { + // 创建新按钮(如果当前按钮为空) + if (button == nullptr) { + button = new UILabelButton(); + if (button == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "UILabelButton UILabelButton is not nullptr"); + return false; // 内存分配失败,返回false + } + button->SetPosition(left, top); + button->Resize(width, height); + button->SetViewId(viewId); + button->SetText(text); + button->SetStyle(STYLE_TEXT_FONT, fontSize); + button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontSize); + button->SetStyle(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, + UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, PRESSED_BORDER_COLOR, + UIButton::PRESSED); + button->SetVisible(true); + return true; +} +/* -------------------------------------------------------------------------- */ +/*替换字符串中的变量*/ +std::string UpdateLabelText(UILabelExt *&label, const std::string &newText, + UIResourceTextId id) { + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateLabelText label is nullptr"); + return nullptr; + } + /*取Id对应的字符串*/ + UILabelExt *labelext = new UILabelExt(); + labelext->SetTextId(id); + std::string text = labelext->GetText(); + + // printf("UpdateLabel:%s->%s\r\n", text.c_str(), newText.c_str()); + + // 找到标志"XX"在字符串中的位置 + size_t pos = text.find("XX"); + if (pos != std::string::npos) { + // 替换标志"XX"为更新字符串 + text.replace(pos, 2, newText); // 2 是标志"XX"的长度 + // printf("newText:%s\r\n", text.c_str()); + label->SetText(text.c_str()); + } else { + printf("找不到变量标志位XX,请注意是否已经被修改!\r\n"); + } + + delete labelext; + return text; +} +/*更新数字*/ +std::string UpdateLabel(UILabelExt *&label, int num, UIResourceTextId id) { + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label is error"); + return nullptr; + } + std::string str = UpdateLabelText(label, std::to_string(num), id); + return str; +} + +/*更新文本*/ +std::string UpdateLabel(UILabelExt *&label, const std::string &updateStr, + UIResourceTextId id) { + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label is error"); + return nullptr; + } + + std::string str = UpdateLabelText(label, updateStr, id); + return str; +} + +/*设置label的Id*/ +void SetLabelId(UILabel *&label, UIResourceTextId id) { + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "label is error"); + return; + } + + UILabelExt *labelext = new UILabelExt(); + labelext->SetTextId(id); + + const std::string text = labelext->GetText(); + if (!text.empty()) { + // printf("SetLabelId:%s\r\n", text.c_str()); + label->SetText(text.c_str()); + } + + delete labelext; +} +#endif +/*** + * @description: + * @param {UIButton} * + * @param {int} left + * @param {int} top + * @param {int} width + * @param {int} height + * @param {char} *viewId + * @return + * @brief 初始化按钮 + */ +bool InitButton(UIButton *&button, int left, int top, int width, int height, + const char *viewId) { + // 创建新按钮(如果当前按钮为空) + if (button == nullptr) { + button = new UIButton(); + if (button == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new UIButton fail"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is not nullptr"); + return false; // 内存分配失败,返回false + } + button->SetPosition(left, top); + button->Resize(width, height); + button->SetViewId(viewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, + UIButton::PRESSED); + button->SetStyleForState(STYLE_BORDER_COLOR, PRESSED_BORDER_COLOR, + UIButton::PRESSED); + return true; +} + +/*** + * @description: + * @param {UIImageView} * + * @param {int} left + * @param {int} top + * @param {int} width + * @param {int} height + * @param {char} *viewId + * @param {char} *imagePath + * @return {*} + * @brief 初始化图片 + */ +bool InitImageView(UIImageView *&imageView, int left, int top, int width, + int height, const char *viewId, const char *imagePath) { + if (imagePath == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imagePath is fail"); + return false; + } + // 创建新图片(如果当前图片为空) + if (imageView == nullptr) { + imageView = new UIImageView(); + if (imageView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "imagePath %s fail", imagePath); + return false; + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitImageView is not nullptr"); + return false; // 内存分配失败,返回false + } + + imageView->SetPosition(left, top); + imageView->SetAutoEnable(true); + imageView->SetViewId(viewId); + + ImageInfo *image = + ImageCacheManager::GetInstance().LoadSingleRes(imagePath, false); + if (image == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "LoadAllDialFromRam loadimage %s fail", imagePath); + return false; + } + imageView->SetSrc(image); + return true; +} +/*带默认参数的初始化label*/ +void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, + const char *viewId, const char *text, int fontSize, + const char *fontName) { + InitLabel(label, x, y, width, height, viewId, text, fontName, fontSize); +} +void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, + ImageAnimatorInfo *imageAnimatorInfo, + const ImageInfo **imageInfo, int numFrames, + int left, int top, int width, int height, + const char *viewId, int time) { + if (imageAnimator == nullptr) { + imageAnimator = new UIImageAnimatorView(); + } + imageAnimator->SetPosition(left, top); + imageAnimator->Resize(width, height); + imageAnimator->SetViewId(viewId); + // imageAnimator->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // imageAnimatorInfo = new ImageAnimatorInfo[numFrames]; + for (int i = 0; i < numFrames; i++) { + imageAnimatorInfo[i].imageInfo = imageInfo[i]; + imageAnimatorInfo[i].pos.x = left; + imageAnimatorInfo[i].pos.y = top; + imageAnimatorInfo[i].width = width; + imageAnimatorInfo[i].height = height; + imageAnimatorInfo[i].imageType = IMG_SRC_IMAGE_INFO; + } + + imageAnimator->SetImageAnimatorSrc(imageAnimatorInfo, numFrames, + time); // 200 is the default delay time + imageAnimator->SetTimeOfPause(time); + imageAnimator->SetRepeat(true); +} +void ReleaseImageAnimatorSource(ImageAnimatorInfo *&imageAnimatorInfo, + int numFrames) { + if (imageAnimatorInfo) { + for (int i = 0; i < numFrames; i++) { + delete[] imageAnimatorInfo[i].imagePath; // 释放每个 imagePath 的内存 + } + delete[] imageAnimatorInfo; // 释放 ImageAnimatorInfo 数组的内存 + imageAnimatorInfo = nullptr; // 避免悬挂指针 + } +} +/* -------------------------------------------------------------------------- */ +// UILabel 初始化 +bool InitUILabel(UILabel *&label, const GeneralConfig &config, + const LabelConfig &labelConfig) { + // 检查标签指针是否为空 + if (label == nullptr) { + label = new UILabel(); + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitUILabel is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitUILabel is not nullptr"); + return false; // 标签已存在,返回false + } + + // 设置标签的位置和大小 + label->SetPosition(config.x, config.y); + label->Resize(config.width, config.height); + // 设置标签的视图 ID + label->SetViewId(config.viewId); + // 设置标签的样式 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); + label->SetFont(labelConfig.fontName, labelConfig.fontSize); + // 设置标签的文本和其他属性 + label->SetText(labelConfig.text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + return true; +} + +// UILabelExt 初始化 +bool InitLabel(UILabelExt *&label, const GeneralConfig &config, + const LabelConfig &labelConfig) { + // 检查标签指针是否为空 + if (label == nullptr) { + label = new UILabelExt(); + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel is not nullptr"); + return false; // 标签已存在,返回false + } + + // 设置标签的位置和大小 + label->SetPosition(config.x, config.y); + label->Resize(config.width, config.height); + // 设置标签的视图 ID + label->SetViewId(config.viewId); + // 设置标签的样式 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); + label->SetFont(labelConfig.fontName, labelConfig.fontSize); + // 设置标签的文本和其他属性 + label->SetText(labelConfig.text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + + return true; +} + +// 自适应 UILabel 初始化 +bool InitLabelAdapt(UILabelExt *&label, const GeneralConfig &config, + const LabelConfig &labelConfig) { + // 检查标签指针是否为空 + if (label == nullptr) { + label = new UILabelExt(); + if (label == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelAdapt is not nullptr"); + return false; // 标签已存在,返回false + } + + // 设置标签的位置和大小 + label->SetPosition(config.x, config.y); + label->Resize(config.width, config.height); + // 设置标签的视图 ID + label->SetViewId(config.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); + + return true; +} +// UIButton 初始化 +bool InitButton(UIButton *&button, const GeneralConfig &config) { + // 检查按钮指针是否为空 + if (button == nullptr) { + button = new UIButton(); + if (button == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButton is not nullptr"); + return false; // 按钮已存在,返回false + } + + // 设置按钮的位置和大小 + button->SetPosition(config.x, config.y); + button->Resize(config.width, config.height); + // 设置按钮的视图 ID + button->SetViewId(config.viewId); + + return true; +} + +// UILabelButton 初始化 +bool InitLabelButton(UILabelButton *&button, const GeneralConfig &config, + const LabelConfig &labelConfig) { + // 检查标签按钮指针是否为空 + if (button == nullptr) { + button = new UILabelButton(); + if (button == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabelButton is not nullptr"); + return false; // 标签按钮已存在,返回false + } + + // 设置标签按钮的位置和大小 + button->SetPosition(config.x, config.y); + button->Resize(config.width, config.height); + // 设置标签按钮的视图 ID + button->SetViewId(config.viewId); + // 设置标签按钮的样式 + button->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); + button->SetFont(labelConfig.fontName, labelConfig.fontSize); + // 设置标签按钮的文本 + button->SetText(labelConfig.text); + + return true; +} + +// UIImageView 初始化 +bool InitImageView(UIImageView *&imageView, const GeneralConfig &config, + const char *imagePath) { + // 检查图片视图指针是否为空 + if (imageView == nullptr) { + imageView = new UIImageView(); + if (imageView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitImageView is error"); + return false; // 内存分配失败,返回false + } + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitImageView is not nullptr"); + return false; // 图片视图已存在,返回false + } + + // 设置图片视图的位置和大小 + imageView->SetPosition(config.x, config.y); + imageView->Resize(config.width, config.height); + // 设置图片视图的视图 ID + imageView->SetViewId(config.viewId); + // 设置图片的路径 + imageView->SetSrc(imagePath); + + return true; +} +// 创建线条的通用函数 +bool CreateLine(UIImageView *&imageView, int x, int y, int width, + int height, const char *viewId) { + if (imageView == nullptr) { + imageView = new UIImageView(); + if (imageView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateLine is error"); + return false; + } + } + + // 设置线条的位置和大小 + imageView->SetPosition(x, y); + imageView->Resize(width, height); // 线高 = height, 线宽 = width + + // 设置线条的样式(背景颜色等) + imageView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff333333); // 设置线条颜色 + imageView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); // 设置线条透明度 + imageView->SetViewId(viewId); // 设置视图 ID + imageView->SetVisible(true); // 显示线条 + + return true; +} +/* -------------------------------------------------------------------------- */ +/** + * 创建包含图片文件路径的数组 + * @param basePath 包含图片文件的基本路径 PullUp_%d.bin + * @param fileExtension 图片文件的扩展名 + * @param numImages 图片文件的数量 + * @return 返回包含图片文件info的数组 + */ + +const ImageInfo **CreateImageInfoArray(const char *basePath, int numImages, + const char *fileExtension) { + const ImageInfo **imageinfo_array = static_cast( + UIMalloc(numImages * sizeof(const ImageInfo *))); + if (imageinfo_array == nullptr) { + return nullptr; // 检查内存分配是否成功 + } + for (int i = 0; i < numImages; i++) { + char buffer[256] = {0}; + snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension); + imageinfo_array[i] = ImageCacheManager::GetInstance().LoadSingleRes(buffer); + // imageinfo_array[i] = + // ImageCacheManager::GetInstance().LoadSingleRes(buffer); if + // (imageinfo_array[i] == nullptr) + // { + // UIFree(imageinfo_array); + // return nullptr; // 检查内存分配是否成功 + // } + } + return imageinfo_array; +} +/** + * 释放创建的图片路径数组 + * @param imagePaths 包含图片路径的数组 + * @param numImages 图片文件的数量 + */ +void FreeImageInfoArray(const ImageInfo **imagePaths, int numImages) { + if (imagePaths != nullptr) { + for (int i = 0; i < numImages; i++) { + ImageCacheManager::GetInstance().UnloadSingleRes((char *)imagePaths[i]); + } + UIFree(const_cast(imagePaths)); // 释放整个数组 + } +} +void FreeImageInfoArray(const ImageInfo **array, const char *basePath, + int numImages, const char *fileExtension) { + for (int i = 0; i < numImages; i++) { + char buffer[256] = {0}; + snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension); + ImageCacheManager::GetInstance().UnloadSingleRes(buffer); + } + UIFree(array); + return; +} +/* -------------------------------------------------------------------------- */ +/** + * 创建包含图片文件路径的数组 + * @param basePath 包含图片文件的基本路径 + * @param fileExtension 图片文件的扩展名 + * @param numImages 图片文件的数量 + * @return 返回包含图片文件路径的数组 + */ +const char **CreateImagePathsArray(const char *basePath, int numImages, + const char *fileExtension) { + const char **imagePaths = + static_cast(UIMalloc(numImages * sizeof(const char *))); + if (imagePaths == nullptr) { + return nullptr; // 检查内存分配是否成功 + } + + char buffer[256]; + for (int i = 0; i < numImages; i++) { + snprintf(buffer, sizeof(buffer), "%s/%d.%s", basePath, i + 1, + fileExtension); + imagePaths[i] = static_cast( + UIMalloc(strlen(buffer) + 1)); // 分配内存来存储每个路径 + if (imagePaths[i] == nullptr) { + // 如果分配失败,释放已经分配的内存并返回 nullptr + for (int j = 0; j < i; j++) { + UIFree(const_cast(imagePaths[j])); // 释放已分配的内存 + } + UIFree(imagePaths); + return nullptr; + } + strcpy(const_cast(imagePaths[i]), buffer); // 使用 strcpy 拷贝字符串 + } + return imagePaths; +} +/** + * 释放创建的图片路径数组 + * @param imagePaths 包含图片路径的数组 + * @param numImages 图片文件的数量 + */ +void FreeImagePathsArray(const char **imagePaths, int numImages) { + if (imagePaths != nullptr) { + for (int i = 0; i < numImages; i++) { + UIFree(const_cast(imagePaths[i])); // 释放每个路径字符串 + } + UIFree(const_cast(imagePaths)); // 释放整个数组 + } +} +/*解析动画资源数组 imageche*/ +std::vector AnalysisArray(const char *filename, uint32_t startId, + uint32_t lastId) { + std::vector imageArray; + + for (uint32_t i = startId; i <= lastId; i++) { + ImageInfo *image = + ImageCacheManager::GetInstance().LoadOneInMultiRes(i, filename); + if (image == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LoadAppMultiImages %x fail", i); + // 如果加载失败,可以选择继续加载下一个,或者在这里处理其他逻辑 + continue; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LoadAppMultiImages %x", i); + imageArray.push_back(image); + } + return imageArray; +} + +void updata_char(char *str_, char *str, uint32_t max_len) { + strcpy_s(str_, max_len, str); + uint32_t j = 0; + uint32_t letter = 0; + if (str == nullptr) { + return; + } + while (str[j] != '\0') { + int i = j; + letter = TypedText::GetUTF8Next(str, j, j); + int len = j - i; + UIFont *fontEngine = UIFont::GetInstance(); + GlyphPathData path; + if (!fontEngine->GetGlyphPathData(letter, 0, path)) { + // printf("********************* letter%d %d %d not exist\r\n", i, j,letter); + char *buf = "□"; + uint16_t buf_len = strlen(buf); + uint16_t offset = 0; + int num = len / buf_len; + int mod_num = len % buf_len; + for (int x = 0; x < num; x++) { + memcpy_s(&str_[i + offset], buf_len, buf, buf_len); + offset += buf_len; + } + if (mod_num != 0) { + for (int x = 0; x < mod_num; x++) { + str_[i + offset] = ' '; + offset += 1; + } + } + } + } + // printf("%s\r\n", str_); +} + +/*创建文件夹*/ +void CreateDirectoryIfNotExists(const std::string &path) { + struct stat info; + if (stat(path.c_str(), &info) != 0) { + if (mkdir(path.c_str(), 0755) != 0) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Error: Could not create directory %s. Errno: %d", + path.c_str(), errno); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Created directory: %s", + path.c_str()); + } + } else if (info.st_mode & S_IFDIR) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Directory already exists: %s", + path.c_str()); + } +} + +// 检查文件是否可打开并且不为空 +bool IsFileAccessibleAndNotEmpty(const std::string &filePath) { + std::ifstream file(filePath); + return file.is_open() && file.peek() != std::ifstream::traits_type::eof(); +} + +} // namespace OHOS diff --git a/code/sdk/zhihui/UI/CustomUIComponentTool/uicomponents/UIComponents.h b/code/sdk/zhihui/UI/CustomUIComponentTool/uicomponents/UIComponents.h new file mode 100644 index 000000000..f55de114b --- /dev/null +++ b/code/sdk/zhihui/UI/CustomUIComponentTool/uicomponents/UIComponents.h @@ -0,0 +1,315 @@ +#ifndef UICOMPONENTS_H +#define UICOMPONENTS_H + + +#include "View.h" +#include + +// UI 组件 +#include "components/ui_scroll_view.h" +#include "components/ui_view_group.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.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 "components/ui_card_page.h" +#include "common/screen.h" +// 日志和类型定义 +#include "wearable_log.h" +#include "ohos_types.h" +#include "common/image_cache_manager.h" + +#ifdef FD230 +#include "ui_resource_string.h" +#endif + +namespace OHOS +{ + /* -------------------------------------------------------------------------- */ + // 初始化和创建 UI 组件 + // ======================= + /* 初始化 UILabel */ + bool InitLabel(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); + bool InitUILabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); + + /* 初始化 UIButton */ + bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); + + /* 初始化 UILabelButton */ + bool InitLabelButton(UILabelButton *&button, int left, int top, int width, int height, const char *viewId, const char *text, int fontSize); + + /* 初始化 UIImageView */ + bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + /*创建线条的通用函数*/ + bool CreateLine(UIImageView *&imageView, int x, int y, int width, int height, const char *viewId); + /* 初始化动画资源 */ + void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const std::vector &imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time); + + /* 自适应 UILabel */ + bool InitLabelAdapt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); + + // 默认参数的 UILabel 初始化 + void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, const char *viewId, const char *text, int fontSize = 30, const char *fontName = DEFAULT_VECTOR_FONT_FILENAME); + // 滚动 + bool InitRollLabel(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, const char *fontName, int fontSize); + bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, const char *fontName, int fontSize); + bool InitButtonExt(UILabelButtonExt *&button, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, int fontSize); + + void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *&imageAnimatorInfo, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time); + + void FreeImageInfoArray(const ImageInfo **array, const char *basePath, int numImages, const char *fileExtension = "bin"); + + // 更新 Label 的文本 + /* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + // 封装位置和尺寸信息的结构体 + struct GeneralConfig + { + int x, y, width, height; // 位置和尺寸 + const char *viewId; // 视图 ID + + // 构造函数,允许初始化默认值 + GeneralConfig(int x = 0, int y = 0, int width = 100, int height = 100, const char *viewId = "defaultId") + : x(x), y(y), width(width), height(height), viewId(viewId) {} + }; + + // 封装动画相关配置 + struct ImageAnimatorConfig + { + const char **imagePaths; // 图像路径数组 + int numFrames; // 帧数 + int time; // 动画时间 + + // 构造函数,允许初始化默认值 + ImageAnimatorConfig(const char **paths = nullptr, int frames = 0, int time = 100) + : imagePaths(paths), numFrames(frames), time(time) {} + }; + + // 封装标签相关配置 + struct LabelConfig + { + const char *text; // 标签文本 + const char *fontName; // 字体名称 + int fontSize; // 字体大小 + + // 构造函数,允许初始化默认值 + LabelConfig(const char *text = "", const char *fontName = DEFAULT_VECTOR_FONT_FILENAME, int fontSize = 30) + : text(text), fontName(fontName), fontSize(fontSize) {} + }; + + // 初始化和创建 UI 组件 + // ======================= + + /** + * @brief 初始化 UILabel 对象。 + * + * 此函数检查传入的 UILabel 指针是否为空,若为空则分配内存并设置其相关属性。 + * + * @param label 要初始化的 UILabel 对象的引用。 + * @param config 带有位置、尺寸和视图 ID 的配置。 + * @param labelConfig 标签的样式和文本配置。 + * @return true 初始化成功;false 创建失败。 + */ + bool InitUILabel(UILabel *&label, const GeneralConfig &config, const LabelConfig &labelConfig); + + /** + * @brief 初始化 UILabelExt 对象。 + * + * 与 InitUILabel 类似,但用于扩展的 UILabel。 + * + * @param label 要初始化的 UILabelExt 对象的引用。 + * @param config 配置参数。 + * @param labelConfig 标签的样式和文本配置。 + * @return true 初始化成功;false 创建失败。 + */ + bool InitLabel(UILabelExt *&label, const GeneralConfig &config, const LabelConfig &labelConfig); + + /** + * @brief 初始化可自适应的 UILabelExt 对象。 + * + * @param label 要初始化的 UILabelExt 对象的引用。 + * @param config 配置参数。 + * @param labelConfig 标签的样式和文本配置。 + * @return true 初始化成功;false 创建失败。 + */ + bool InitLabelAdapt(UILabelExt *&label, const GeneralConfig &config, const LabelConfig &labelConfig); + + /** + * @brief 初始化 UIButton 对象。 + * + * 此函数将创建 UIButton,并设置其位置、大小和视图 ID。 + * + * @param button 要初始化的 UIButton 对象的引用。 + * @param config 配置参数(位置、大小、视图 ID)。 + * @return true 初始化成功;false 创建失败。 + */ + bool InitButton(UIButton *&button, const GeneralConfig &config); + + /** + * @brief 初始化 UILabelButton 对象。 + * + * 这个函数将创建 UILabelButton,设置它的文本、位置和样式。 + * + * @param button 要初始化的 UILabelButton 对象的引用。 + * @param config 配置参数。 + * @param labelConfig 标签样式和文本配置。 + * @return true 初始化成功;false 创建失败。 + */ + bool InitLabelButton(UILabelButton *&button, const GeneralConfig &config, const LabelConfig &labelConfig); + + /** + * @brief 初始化 UIImageView 对象。 + * + * 初始化UIImageView并设置位置、大小和视图 ID,同时加载图像。 + * + * @param imageView 要初始化的 UIImageView 对象的引用。 + * @param config 配置参数。 + * @param imagePath 图像路径。 + * @return true 初始化成功;false 创建失败。 + */ + bool InitImageView(UIImageView *&imageView, const GeneralConfig &config, const char *imagePath); + + // 动画资源数组生成 + // ======================= + + /** + * @brief 创建动态图像路径数组。 + * + * 根据给定路径、数量和文件扩展名生成图像路径数组。 + * + * @param basePath 基础路径。 + * @param numImages 图像数量。 + * @param fileExtension 文件扩展名(默认 "bin")。 + * @return const char** 动态分配的图像路径数组。 + */ + const char **CreateImagePathsArray(const char *basePath, int numImages, const char *fileExtension = "bin"); + + /** + * @brief 创建图像信息数组。 + * + * 根据路径和数量生成图像信息数组。 + * + * @param basePath 基础路径。 + * @param numImages 图像数量。 + * @param fileExtension 文件扩展名(默认 "bin")。 + * @return const ImageInfo** 动态分配的图像信息数组。 + */ + const ImageInfo **CreateImageInfoArray(const char *basePath, int numImages, const char *fileExtension = "bin"); + + /** + * @brief 释放图像信息数组。 + * + * 释放由 CreateImageInfoArray 创建的图像信息数组的内存。 + * + * @param array 要释放的图像信息数组。 + * @param numImages 数组长度。 + */ + void FreeImageInfoArray(const ImageInfo **array, int numImages); + + /** + * @brief 释放图像路径数组。 + * + * 释放由 CreateImagePathsArray 创建的图像路径数组的内存。 + * + * @param imagePaths 要释放的图像路径数组。 + * @param numImages 数组长度。 + */ + void FreeImageInfoArray(const ImageInfo **imagePaths, int numImages); + + void FreeImagePathsArray(const char **imagePaths, int numImages); + /** + * @brief 初始化 UIImageAnimatorView,并设置为 GIF 动画。 + * + * @param imageAnimator 初始化的 UIImageAnimatorView 对象的引用。 + * @param imageAnimatorInfo 储存 GIF 动画信息的数组指针。 + * @param config 动画相关的配置(包括路径和帧信息)。 + * @param generalConfig 视图的基本配置(位置、大小、视图 ID 等)。 + */ + void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, ImageAnimatorInfo *imageAnimatorInfo, const ImageInfo **imageInfo, int numFrames, int left, int top, int width, int height, const char *viewId, int time); + + /** + * @brief 释放 UIImageAnimatorView 的资源。 + * + * @param imageAnimatorInfo 要释放的动画信息。 + */ + void ReleaseImageAnimatorSource(ImageAnimatorInfo *&imageAnimatorInfo, int numFrames); + +#ifdef FD230 + // 扩展功能 + // ======================= + /** + * @brief 初始化带扩展功能的 UILabelExt 对象。 + * + * @param label 要初始化的 UILabelExt 对象的引用。 + * @param config 配置参数。 + * @param id 资源文本 ID。 + * @param labelConfig 标签样式和文本配置。 + * @return true 初始化成功;false 创建失败。 + */ + bool InitLabelExt(UILabelExt *&label, const GeneralConfig &config, UIResourceTextId id, const LabelConfig &labelConfig); + + /** + * @brief 初始化带扩展功能的 UILabelButtonExt 对象。 + * + * @param button 要初始化的 UILabelButtonExt 对象的引用。 + * @param config 配置参数。 + * @param id 资源文本 ID。 + * @param fontSize 字体大小。 + * @return true 初始化成功;false 创建失败。 + */ + bool InitButtonExt(UILabelButtonExt *&button, const GeneralConfig &config, UIResourceTextId id, int fontSize); + + /** + * @brief 更新 UILabelExt 对象的文本。 + * + * @param label 要更新的 UILabelExt 对象的引用。 + * @param newText 新的文本。 + * @param id 资源文本 ID。 + * @return std::string 更新后的文本。 + */ + std::string UpdateLabelText(UILabelExt *&label, const std::string &newText, UIResourceTextId id); + + /** + * @brief 更新 UILabelExt 对象的文本,允许数字。 + * + * @param label 要更新的 UILabelExt 对象的引用。 + * @param num 需要更新的数字。 + * @param id 资源文本 ID。 + * @return std::string 更新后的文本。 + */ + std::string UpdateLabel(UILabelExt *&label, int num, UIResourceTextId id); + + /** + * @brief 更新 UILabelExt 对象的文本,允许字符串更新。 + * + * @param label 要更新的 UILabelExt 对象的引用。 + * @param updatestr 需要更新的字符串。 + * @param id 资源文本 ID。 + * @return std::string 更新后的文本。 + */ + std::string UpdateLabel(UILabelExt *&label, const std::string &updatestr, UIResourceTextId id); + + /** + * @brief 设置 UILabel 的 ID。 + * + * @param label 要设置 ID 的 UILabel 对象的引用。 + * @param id 资源文本 ID。 + */ + void SetLabelId(UILabel *&label, UIResourceTextId id); + + void updata_char(char *str_,char *str,uint32_t max_len); + + void CreateDirectoryIfNotExists(const std::string &path); + + bool IsFileAccessibleAndNotEmpty(const std::string& filePath); + +#endif + +} // namespace OHOS + +#endif // UICOMPONENTS_H \ No newline at end of file -- 2.17.1