1 /*
2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "core/interfaces/native/node/node_date_picker_modifier.h"
17
18 #include <string>
19
20 #include "base/geometry/dimension.h"
21 #include "base/i18n/localization.h"
22 #include "base/utils/utils.h"
23 #include "bridge/common/utils/utils.h"
24 #include "core/components/picker/picker_theme.h"
25 #include "core/components_ng/pattern/picker/datepicker_model_ng.h"
26 #include "core/components_ng/pattern/picker/picker_type_define.h"
27 #include "core/components_ng/pattern/text_picker/textpicker_model_ng.h"
28 #include "core/interfaces/arkoala/arkoala_api.h"
29 #include "core/interfaces/native/node/node_api.h"
30 #include "core/pipeline/base/element_register.h"
31 #include "frameworks/core/components/common/properties/text_style.h"
32 #include "core/pipeline_ng/pipeline_context.h"
33
34 namespace OHOS::Ace::NG {
35 namespace {
36 constexpr int32_t POS_0 = 0;
37 constexpr int32_t POS_1 = 1;
38 constexpr int32_t POS_2 = 2;
39 constexpr int YEAR_1900 = 1900;
40 constexpr int YEAR_1970 = 1970;
41 const char DEFAULT_DELIMITER = '|';
42 const int32_t ERROR_INT_CODE = -1;
43 std::string g_strValue;
44 const std::vector<OHOS::Ace::FontStyle> FONT_STYLES = { OHOS::Ace::FontStyle::NORMAL, OHOS::Ace::FontStyle::ITALIC };
45
GetSelectedTextStyle(ArkUINodeHandle node)46 ArkUI_CharPtr GetSelectedTextStyle(ArkUINodeHandle node)
47 {
48 auto* frameNode = reinterpret_cast<FrameNode*>(node);
49 CHECK_NULL_RETURN(frameNode, "");
50 PickerTextStyle pickerTextStyle = DatePickerModelNG::getSelectedTextStyle(frameNode);
51 std::vector<std::string> fontFamilies = pickerTextStyle.fontFamily.value_or(std::vector<std::string>());
52 if (fontFamilies.size() == 0) {
53 fontFamilies.emplace_back("HarmonyOS Sans");
54 }
55 std::string families;
56 //set index start
57 int index = 0;
58 for (auto& family : fontFamilies) {
59 families += family;
60 if (index != static_cast<int>(fontFamilies.size()) - 1) {
61 families += ",";
62 }
63 index++;
64 }
65 g_strValue = pickerTextStyle.textColor->ColorToString() + ";";
66 g_strValue = g_strValue + std::to_string(static_cast<int>(pickerTextStyle.fontSize->ConvertToFp())) + ";";
67 g_strValue =
68 g_strValue + StringUtils::ToString(pickerTextStyle.fontWeight.value_or(FontWeight::W100)) + ";";
69 g_strValue = g_strValue + families + ";";
70 g_strValue = g_strValue + StringUtils::ToStringNDK(pickerTextStyle.fontStyle.value_or(FontStyle::NORMAL));
71 return g_strValue.c_str();
72 }
73
SetSelectedTextStyle(ArkUINodeHandle node,const char * fontInfo,uint32_t color,int32_t style)74 void SetSelectedTextStyle(ArkUINodeHandle node, const char* fontInfo, uint32_t color, int32_t style)
75 {
76 auto* frameNode = reinterpret_cast<FrameNode*>(node);
77 CHECK_NULL_VOID(frameNode);
78 auto pipeline = frameNode->GetContext();
79 CHECK_NULL_VOID(pipeline);
80 auto themeManager = pipeline->GetThemeManager();
81 CHECK_NULL_VOID(themeManager);
82 auto theme = themeManager->GetTheme<PickerTheme>();
83 CHECK_NULL_VOID(theme);
84
85 NG::PickerTextStyle textStyle;
86 std::vector<std::string> res;
87 std::string fontValues = std::string(fontInfo);
88 StringUtils::StringSplitter(fontValues, DEFAULT_DELIMITER, res);
89 textStyle.fontSize = StringUtils::StringToCalcDimension(res[POS_0], false, DimensionUnit::FP);
90 if (style >= 0 && style < static_cast<int32_t>(FONT_STYLES.size())) {
91 textStyle.fontStyle = FONT_STYLES[style];
92 } else {
93 textStyle.fontStyle = FONT_STYLES[0];
94 }
95 textStyle.fontFamily = Framework::ConvertStrToFontFamilies(res[POS_2]);
96 textStyle.fontWeight = StringUtils::StringToFontWeight(res[POS_1]);
97 textStyle.textColor = Color(color);
98 DatePickerModelNG::SetSelectedTextStyle(frameNode, theme, textStyle);
99 }
100
ResetSelectedTextStyle(ArkUINodeHandle node)101 void ResetSelectedTextStyle(ArkUINodeHandle node)
102 {
103 auto* frameNode = reinterpret_cast<FrameNode*>(node);
104 CHECK_NULL_VOID(frameNode);
105 auto pipeline = frameNode->GetContext();
106 CHECK_NULL_VOID(pipeline);
107 auto themeManager = pipeline->GetThemeManager();
108 CHECK_NULL_VOID(themeManager);
109 auto theme = themeManager->GetTheme<PickerTheme>();
110 CHECK_NULL_VOID(theme);
111
112 NG::PickerTextStyle textStyle;
113 auto selectedStyle = theme->GetOptionStyle(true, false);
114 textStyle.textColor = selectedStyle.GetTextColor();
115 textStyle.fontSize = selectedStyle.GetFontSize();
116 textStyle.fontWeight = selectedStyle.GetFontWeight();
117 DatePickerModelNG::SetSelectedTextStyle(frameNode, theme, textStyle);
118 }
119
GetDatePickerTextStyle(ArkUINodeHandle node)120 ArkUI_CharPtr GetDatePickerTextStyle(ArkUINodeHandle node)
121 {
122 auto* frameNode = reinterpret_cast<FrameNode*>(node);
123 CHECK_NULL_RETURN(frameNode, "");
124 PickerTextStyle pickerTextStyle = DatePickerModelNG::getNormalTextStyle(frameNode);
125 std::vector<std::string> fontFamilies = pickerTextStyle.fontFamily.value_or(std::vector<std::string>());
126 std::string families;
127 if (fontFamilies.size() == 0) {
128 fontFamilies.emplace_back("HarmonyOS Sans");
129 }
130 //set index start
131 int index = 0;
132 for (auto& family : fontFamilies) {
133 families += family;
134 if (index != static_cast<int>(fontFamilies.size()) - 1) {
135 families += ",";
136 }
137 index++;
138 }
139 g_strValue = pickerTextStyle.textColor->ColorToString() + ";";
140 g_strValue = g_strValue + std::to_string(static_cast<int>(pickerTextStyle.fontSize->ConvertToFp())) + ";";
141 g_strValue =
142 g_strValue + StringUtils::ToString(pickerTextStyle.fontWeight.value_or(FontWeight::W100)) + ";";
143 g_strValue = g_strValue + families + ";";
144 g_strValue = g_strValue + StringUtils::ToStringNDK(pickerTextStyle.fontStyle.value_or(FontStyle::NORMAL));
145 return g_strValue.c_str();
146 }
147
SetDatePickerTextStyle(ArkUINodeHandle node,const char * fontInfo,uint32_t color,int32_t style)148 void SetDatePickerTextStyle(ArkUINodeHandle node, const char* fontInfo, uint32_t color, int32_t style)
149 {
150 auto* frameNode = reinterpret_cast<FrameNode*>(node);
151 CHECK_NULL_VOID(frameNode);
152 auto pipeline = frameNode->GetContext();
153 CHECK_NULL_VOID(pipeline);
154 auto themeManager = pipeline->GetThemeManager();
155 CHECK_NULL_VOID(themeManager);
156 auto theme = themeManager->GetTheme<PickerTheme>();
157 CHECK_NULL_VOID(theme);
158
159 NG::PickerTextStyle textStyle;
160 std::vector<std::string> res;
161 std::string fontValues = std::string(fontInfo);
162 StringUtils::StringSplitter(fontValues, DEFAULT_DELIMITER, res);
163
164 textStyle.fontSize = StringUtils::StringToCalcDimension(res[POS_0], false, DimensionUnit::FP);
165 if (style >= 0 && style < static_cast<int32_t>(FONT_STYLES.size())) {
166 textStyle.fontStyle = FONT_STYLES[style];
167 } else {
168 textStyle.fontStyle = FONT_STYLES[0];
169 }
170 textStyle.fontFamily = Framework::ConvertStrToFontFamilies(res[POS_2]);
171 textStyle.fontWeight = StringUtils::StringToFontWeight(res[POS_1]);
172 textStyle.textColor = Color(color);
173 DatePickerModelNG::SetNormalTextStyle(frameNode, theme, textStyle);
174 }
175
ResetDatePickerTextStyle(ArkUINodeHandle node)176 void ResetDatePickerTextStyle(ArkUINodeHandle node)
177 {
178 auto* frameNode = reinterpret_cast<FrameNode*>(node);
179 CHECK_NULL_VOID(frameNode);
180 auto pipeline = frameNode->GetContext();
181 CHECK_NULL_VOID(pipeline);
182 auto themeManager = pipeline->GetThemeManager();
183 CHECK_NULL_VOID(themeManager);
184 auto theme = themeManager->GetTheme<PickerTheme>();
185 CHECK_NULL_VOID(theme);
186
187 NG::PickerTextStyle textStyle;
188 auto normalStyle = theme->GetOptionStyle(false, false);
189 textStyle.textColor = normalStyle.GetTextColor();
190 textStyle.fontSize = normalStyle.GetFontSize();
191 textStyle.fontWeight = normalStyle.GetFontWeight();
192 DatePickerModelNG::SetNormalTextStyle(frameNode, theme, textStyle);
193 }
194
GetDisappearTextStyle(ArkUINodeHandle node)195 ArkUI_CharPtr GetDisappearTextStyle(ArkUINodeHandle node)
196 {
197 auto* frameNode = reinterpret_cast<FrameNode*>(node);
198 CHECK_NULL_RETURN(frameNode, "");
199 PickerTextStyle pickerTextStyle = DatePickerModelNG::getDisappearTextStyle(frameNode);
200 std::vector<std::string> fontFamilies = pickerTextStyle.fontFamily.value_or(std::vector<std::string>());
201 std::string families;
202 if (fontFamilies.size() == 0) {
203 fontFamilies.emplace_back("HarmonyOS Sans");
204 }
205 //set index start
206 int index = 0;
207 for (auto& family : fontFamilies) {
208 families += family;
209 if (index != static_cast<int>(fontFamilies.size()) - 1) {
210 families += ",";
211 }
212 index++;
213 }
214 g_strValue = pickerTextStyle.textColor->ColorToString() + ";";
215 g_strValue = g_strValue + std::to_string(static_cast<int>(pickerTextStyle.fontSize->ConvertToFp())) + ";";
216 g_strValue =
217 g_strValue + StringUtils::ToString(pickerTextStyle.fontWeight.value_or(FontWeight::W100)) + ";";
218 g_strValue = g_strValue + families + ";";
219 g_strValue = g_strValue + StringUtils::ToStringNDK(pickerTextStyle.fontStyle.value_or(FontStyle::NORMAL));
220 return g_strValue.c_str();
221 }
222
SetDisappearTextStyle(ArkUINodeHandle node,const char * fontInfo,uint32_t color,int32_t style)223 void SetDisappearTextStyle(ArkUINodeHandle node, const char* fontInfo, uint32_t color, int32_t style)
224 {
225 auto* frameNode = reinterpret_cast<FrameNode*>(node);
226 CHECK_NULL_VOID(frameNode);
227 auto pipeline = frameNode->GetContext();
228 CHECK_NULL_VOID(pipeline);
229 auto themeManager = pipeline->GetThemeManager();
230 CHECK_NULL_VOID(themeManager);
231 auto theme = themeManager->GetTheme<PickerTheme>();
232 CHECK_NULL_VOID(theme);
233
234 NG::PickerTextStyle textStyle;
235 std::vector<std::string> res;
236 std::string fontValues = std::string(fontInfo);
237 StringUtils::StringSplitter(fontValues, DEFAULT_DELIMITER, res);
238
239 textStyle.fontSize = StringUtils::StringToCalcDimension(res[POS_0], false, DimensionUnit::FP);
240 if (style >= 0 && style < static_cast<int32_t>(FONT_STYLES.size())) {
241 textStyle.fontStyle = FONT_STYLES[style];
242 } else {
243 textStyle.fontStyle = FONT_STYLES[0];
244 }
245 textStyle.fontFamily = Framework::ConvertStrToFontFamilies(res[POS_2]);
246 textStyle.fontWeight = StringUtils::StringToFontWeight(res[POS_1]);
247 textStyle.textColor = Color(color);
248 DatePickerModelNG::SetDisappearTextStyle(frameNode, theme, textStyle);
249 }
250
ResetDisappearTextStyle(ArkUINodeHandle node)251 void ResetDisappearTextStyle(ArkUINodeHandle node)
252 {
253 auto* frameNode = reinterpret_cast<FrameNode*>(node);
254 CHECK_NULL_VOID(frameNode);
255 auto pipeline = frameNode->GetContext();
256 CHECK_NULL_VOID(pipeline);
257 auto themeManager = pipeline->GetThemeManager();
258 CHECK_NULL_VOID(themeManager);
259 auto theme = themeManager->GetTheme<PickerTheme>();
260 CHECK_NULL_VOID(theme);
261
262 NG::PickerTextStyle textStyle;
263 auto disappearStyle = theme->GetDisappearOptionStyle();
264 textStyle.textColor = disappearStyle.GetTextColor();
265 textStyle.fontSize = disappearStyle.GetFontSize();
266 textStyle.fontWeight = disappearStyle.GetFontWeight();
267 DatePickerModelNG::SetDisappearTextStyle(frameNode, theme, textStyle);
268 }
269
GetLunar(ArkUINodeHandle node)270 ArkUI_Int32 GetLunar(ArkUINodeHandle node)
271 {
272 auto* frameNode = reinterpret_cast<FrameNode*>(node);
273 CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
274 return DatePickerModelNG::getLunar(frameNode);
275 }
276
SetLunar(ArkUINodeHandle node,int lunar)277 void SetLunar(ArkUINodeHandle node, int lunar)
278 {
279 auto* frameNode = reinterpret_cast<FrameNode*>(node);
280 CHECK_NULL_VOID(frameNode);
281 DatePickerModelNG::SetShowLunar(frameNode, lunar);
282 }
283
ResetLunar(ArkUINodeHandle node)284 void ResetLunar(ArkUINodeHandle node)
285 {
286 auto* frameNode = reinterpret_cast<FrameNode*>(node);
287 CHECK_NULL_VOID(frameNode);
288 DatePickerModelNG::SetShowLunar(frameNode, false);
289 }
290
GetDatePickerBackgroundColor(ArkUINodeHandle node)291 ArkUI_Uint32 GetDatePickerBackgroundColor(ArkUINodeHandle node)
292 {
293 auto* frameNode = reinterpret_cast<FrameNode*>(node);
294 CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
295 return DatePickerModelNG::getBackgroundColor(frameNode);
296 }
297
SetDatePickerBackgroundColor(ArkUINodeHandle node,uint32_t color)298 void SetDatePickerBackgroundColor(ArkUINodeHandle node, uint32_t color)
299 {
300 auto* frameNode = reinterpret_cast<FrameNode*>(node);
301 CHECK_NULL_VOID(frameNode);
302 DatePickerModelNG::SetBackgroundColor(frameNode, Color(color));
303 }
304
ResetDatePickerBackgroundColor(ArkUINodeHandle node)305 void ResetDatePickerBackgroundColor(ArkUINodeHandle node)
306 {
307 auto* frameNode = reinterpret_cast<FrameNode*>(node);
308 CHECK_NULL_VOID(frameNode);
309 DatePickerModelNG::SetBackgroundColor(frameNode, Color(Color::TRANSPARENT));
310 }
311
GetStartDate(ArkUINodeHandle node)312 ArkUI_CharPtr GetStartDate(ArkUINodeHandle node)
313 {
314 auto* frameNode = reinterpret_cast<FrameNode*>(node);
315 CHECK_NULL_RETURN(frameNode, "");
316 LunarDate lunarDate = DatePickerModelNG::getStartDate(frameNode);
317 g_strValue = std::to_string(static_cast<uint32_t>(lunarDate.year)) + "-";
318 g_strValue = g_strValue + std::to_string(static_cast<uint32_t>(lunarDate.month)) + "-";
319 g_strValue = g_strValue + std::to_string(static_cast<uint32_t>(lunarDate.day));
320 return g_strValue.c_str();
321 }
322
SetStartDate(ArkUINodeHandle node,uint32_t year,uint32_t month,uint32_t day)323 void SetStartDate(ArkUINodeHandle node, uint32_t year, uint32_t month, uint32_t day)
324 {
325 auto* frameNode = reinterpret_cast<FrameNode*>(node);
326 CHECK_NULL_VOID(frameNode);
327 auto pickerDate = PickerDate(year, month, day);
328 if (pickerDate.GetYear() < YEAR_1900) {
329 pickerDate.SetYear(YEAR_1970);
330 pickerDate.SetMonth(1);
331 pickerDate.SetDay(1);
332 }
333 DatePickerModelNG::SetStartDate(frameNode, pickerDate);
334 }
335
ResetStartDate(ArkUINodeHandle node)336 void ResetStartDate(ArkUINodeHandle node)
337 {
338 auto* frameNode = reinterpret_cast<FrameNode*>(node);
339 CHECK_NULL_VOID(frameNode);
340 DatePickerModelNG::SetStartDate(frameNode, PickerDate(1970, 1, 1));
341 }
342
GetEndDate(ArkUINodeHandle node)343 ArkUI_CharPtr GetEndDate(ArkUINodeHandle node)
344 {
345 auto* frameNode = reinterpret_cast<FrameNode*>(node);
346 CHECK_NULL_RETURN(frameNode, "");
347 LunarDate lunarDate = DatePickerModelNG::getEndDate(frameNode);
348 g_strValue = std::to_string(static_cast<uint32_t>(lunarDate.year)) + "-";
349 g_strValue = g_strValue + std::to_string(static_cast<uint32_t>(lunarDate.month)) + "-";
350 g_strValue = g_strValue + std::to_string(static_cast<uint32_t>(lunarDate.day));
351 return g_strValue.c_str();
352 }
353
SetEndDate(ArkUINodeHandle node,uint32_t year,uint32_t month,uint32_t day)354 void SetEndDate(ArkUINodeHandle node, uint32_t year, uint32_t month, uint32_t day)
355 {
356 auto* frameNode = reinterpret_cast<FrameNode*>(node);
357 CHECK_NULL_VOID(frameNode);
358 DatePickerModelNG::SetEndDate(frameNode, PickerDate(year, month, day));
359 }
360
ResetEndDate(ArkUINodeHandle node)361 void ResetEndDate(ArkUINodeHandle node)
362 {
363 auto* frameNode = reinterpret_cast<FrameNode*>(node);
364 CHECK_NULL_VOID(frameNode);
365 DatePickerModelNG::SetEndDate(frameNode, PickerDate(2100, 12, 31));
366 }
367
GetSelectedDate(ArkUINodeHandle node)368 ArkUI_CharPtr GetSelectedDate(ArkUINodeHandle node)
369 {
370 auto* frameNode = reinterpret_cast<FrameNode*>(node);
371 CHECK_NULL_RETURN(frameNode, "");
372 LunarDate lunarDate = DatePickerModelNG::getSelectedDate(frameNode);
373 g_strValue = std::to_string(static_cast<uint32_t>(lunarDate.year)) + "-";
374 g_strValue = g_strValue + std::to_string(static_cast<uint32_t>(lunarDate.month)) + "-";
375 g_strValue = g_strValue + std::to_string(static_cast<uint32_t>(lunarDate.day));
376 return g_strValue.c_str();
377 }
378
SetSelectedDate(ArkUINodeHandle node,uint32_t year,uint32_t month,uint32_t day)379 void SetSelectedDate(ArkUINodeHandle node, uint32_t year, uint32_t month, uint32_t day)
380 {
381 auto* frameNode = reinterpret_cast<FrameNode*>(node);
382 CHECK_NULL_VOID(frameNode);
383 DatePickerModelNG::SetSelectedDate(frameNode, PickerDate(year, month, day));
384 }
385
ResetSelectedDate(ArkUINodeHandle node)386 void ResetSelectedDate(ArkUINodeHandle node)
387 {
388 auto* frameNode = reinterpret_cast<FrameNode*>(node);
389 CHECK_NULL_VOID(frameNode);
390 time_t now = time(nullptr);
391 auto currentTm = localtime(&now);
392 CHECK_NULL_VOID(currentTm);
393 PickerDate pickerDate(currentTm->tm_year + 1900, currentTm->tm_mon + 1, currentTm->tm_mday);
394
395 DatePickerModelNG::SetSelectedDate(frameNode, pickerDate);
396 }
397 } // namespace
398
399 namespace NodeModifier {
GetDatePickerModifier()400 const ArkUIDatePickerModifier* GetDatePickerModifier()
401 {
402 static const ArkUIDatePickerModifier modifier = { GetSelectedTextStyle, SetSelectedTextStyle,
403 ResetSelectedTextStyle, GetDatePickerTextStyle, SetDatePickerTextStyle, ResetDatePickerTextStyle,
404 GetDisappearTextStyle, SetDisappearTextStyle, ResetDisappearTextStyle, GetLunar, SetLunar, ResetLunar,
405 GetStartDate, SetStartDate, ResetStartDate, GetEndDate, SetEndDate, ResetEndDate, GetSelectedDate,
406 SetSelectedDate, ResetSelectedDate, GetDatePickerBackgroundColor, SetDatePickerBackgroundColor,
407 ResetDatePickerBackgroundColor };
408
409 return &modifier;
410 }
411
GetCJUIDatePickerModifier()412 const CJUIDatePickerModifier* GetCJUIDatePickerModifier()
413 {
414 static const CJUIDatePickerModifier modifier = { GetSelectedTextStyle, SetSelectedTextStyle,
415 ResetSelectedTextStyle, GetDatePickerTextStyle, SetDatePickerTextStyle, ResetDatePickerTextStyle,
416 GetDisappearTextStyle, SetDisappearTextStyle, ResetDisappearTextStyle, GetLunar, SetLunar, ResetLunar,
417 GetStartDate, SetStartDate, ResetStartDate, GetEndDate, SetEndDate, ResetEndDate, GetSelectedDate,
418 SetSelectedDate, ResetSelectedDate, GetDatePickerBackgroundColor, SetDatePickerBackgroundColor,
419 ResetDatePickerBackgroundColor };
420
421 return &modifier;
422 }
423
SetDatePickerOnDateChange(ArkUINodeHandle node,void * extraParam)424 void SetDatePickerOnDateChange(ArkUINodeHandle node, void* extraParam)
425 {
426 auto* frameNode = reinterpret_cast<FrameNode*>(node);
427 CHECK_NULL_VOID(frameNode);
428 auto onDateChange = [extraParam](const BaseEventInfo* info) {
429 ArkUINodeEvent event;
430 event.kind = COMPONENT_ASYNC_EVENT;
431 event.extraParam = reinterpret_cast<intptr_t>(extraParam);
432 event.componentAsyncEvent.subKind = ON_DATE_PICKER_DATE_CHANGE;
433 const auto* eventInfo = TypeInfoHelper::DynamicCast<DatePickerChangeEvent>(info);
434 std::unique_ptr<JsonValue> argsPtr = JsonUtil::ParseJsonString(eventInfo->GetSelectedStr());
435 if (!argsPtr) {
436 event.componentAsyncEvent.data[0].i32 = 1970;
437 event.componentAsyncEvent.data[1].i32 = 1;
438 event.componentAsyncEvent.data[1].i32 = 1;
439 event.componentAsyncEvent.data[1].i32 = 0;
440 event.componentAsyncEvent.data[1].i32 = 0;
441 }
442 auto year = argsPtr->GetValue("year");
443 auto month = argsPtr->GetValue("month");
444 auto day = argsPtr->GetValue("day");
445 auto hour = argsPtr->GetValue("hour");
446 auto minute = argsPtr->GetValue("minute");
447 if (year && year->IsNumber()) {
448 event.componentAsyncEvent.data[0].i32 = year->GetInt();
449 }
450 if (month && month->IsNumber()) {
451 event.componentAsyncEvent.data[1].i32 = month->GetInt();
452 }
453 if (day && day->IsNumber()) {
454 event.componentAsyncEvent.data[2].i32 = day->GetInt();
455 }
456 if (hour && hour->IsNumber()) {
457 event.componentAsyncEvent.data[3].i32 = hour->GetInt();
458 }
459 if (minute && minute->IsNumber()) {
460 event.componentAsyncEvent.data[4].i32 = minute->GetInt();
461 }
462 SendArkUIAsyncEvent(&event);
463 };
464 DatePickerModelNG::SetOnDateChange(frameNode, std::move(onDateChange));
465 }
466 } // namespace NodeModifier
467 } // namespace OHOS::Ace::NG
468