• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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/components_ng/pattern/calendar/calendar_pattern.h"
17 
18 #include <optional>
19 
20 #include "base/geometry/offset.h"
21 #include "base/i18n/localization.h"
22 #include "base/memory/ace_type.h"
23 #include "base/utils/utils.h"
24 #include "core/components_ng/base/frame_node.h"
25 #include "core/components_ng/base/inspector_filter.h"
26 #include "core/components_ng/pattern/badge/badge_layout_property.h"
27 #include "core/components_ng/pattern/calendar/calendar_month_pattern.h"
28 #include "core/components_ng/pattern/calendar_picker/calendar_dialog_view.h"
29 #include "core/components_ng/pattern/swiper/swiper_event_hub.h"
30 #include "core/components_ng/pattern/swiper/swiper_layout_property.h"
31 #include "core/components_ng/pattern/swiper/swiper_pattern.h"
32 #include "core/components_ng/pattern/text/text_pattern.h"
33 
34 namespace OHOS::Ace::NG {
35 constexpr uint8_t TOTAL_COUNT = 3;
OnAttachToFrameNode()36 void CalendarPattern::OnAttachToFrameNode()
37 {
38     auto host = GetHost();
39     CHECK_NULL_VOID(host);
40     host->GetRenderContext()->SetClipToFrame(true);
41 }
42 
OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper> & dirty,bool skipMeasure,bool skipLayout)43 bool CalendarPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, bool skipMeasure, bool skipLayout)
44 {
45     return false;
46 }
47 
SetCalendarControllerNg(const RefPtr<CalendarControllerNg> & calendarController)48 void CalendarPattern::SetCalendarControllerNg(const RefPtr<CalendarControllerNg>& calendarController)
49 {
50     calendarControllerNg_ = calendarController;
51     if (calendarControllerNg_) {
52         calendarControllerNg_->SetCalendarPattern(AceType::WeakClaim(this));
53     }
54 }
55 
OnModifyDone()56 void CalendarPattern::OnModifyDone()
57 {
58     Pattern::OnModifyDone();
59     auto host = GetHost();
60     CHECK_NULL_VOID(host);
61     auto hostNode = DynamicCast<FrameNode>(host);
62     CHECK_NULL_VOID(hostNode);
63     auto hostLayoutProperty = hostNode->GetLayoutProperty();
64     CHECK_NULL_VOID(hostLayoutProperty);
65     auto textDirection = hostLayoutProperty->GetNonAutoLayoutDirection();
66     auto swiperNode = host->GetChildren().front();
67     CHECK_NULL_VOID(swiperNode);
68     auto swiperFrameNode = DynamicCast<FrameNode>(swiperNode);
69     CHECK_NULL_VOID(swiperFrameNode);
70     auto swiperLayoutProperty = swiperFrameNode->GetLayoutProperty();
71     CHECK_NULL_VOID(swiperLayoutProperty);
72     swiperLayoutProperty->UpdateLayoutDirection(textDirection);
73     auto calendarEventHub = host->GetOrCreateEventHub<CalendarEventHub>();
74     CHECK_NULL_VOID(calendarEventHub);
75     if (swiperFrameNode->GetChildren().size() < 3) {
76         return;
77     }
78     auto preFrameNode = AceType::DynamicCast<FrameNode>(swiperFrameNode->GetChildren().front());
79     CHECK_NULL_VOID(preFrameNode);
80     auto prePattern = preFrameNode->GetPattern<CalendarMonthPattern>();
81     CHECK_NULL_VOID(prePattern);
82     auto iterator = swiperFrameNode->GetChildren().begin();
83     auto currentFrameNode = AceType::DynamicCast<FrameNode>(*(++iterator));
84     CHECK_NULL_VOID(currentFrameNode);
85     auto currentPattern = currentFrameNode->GetPattern<CalendarMonthPattern>();
86     CHECK_NULL_VOID(currentPattern);
87     auto nextFrameNode = AceType::DynamicCast<FrameNode>(swiperFrameNode->GetChildren().back());
88     CHECK_NULL_VOID(nextFrameNode);
89     auto nextPattern = nextFrameNode->GetPattern<CalendarMonthPattern>();
90     CHECK_NULL_VOID(nextPattern);
91 
92     // Set the calendarDay.
93     prePattern->SetCalendarDay(calendarDay_);
94     currentPattern->SetCalendarDay(calendarDay_);
95     nextPattern->SetCalendarDay(calendarDay_);
96 
97     // Set the startDate and endDate.
98     prePattern->SetStartDate(startDate_);
99     currentPattern->SetStartDate(startDate_);
100     nextPattern->SetStartDate(startDate_);
101     prePattern->SetEndDate(endDate_);
102     currentPattern->SetEndDate(endDate_);
103     nextPattern->SetEndDate(endDate_);
104 
105     prePattern->SetMarkToday(markToday_);
106     currentPattern->SetMarkToday(markToday_);
107     nextPattern->SetMarkToday(markToday_);
108 
109     prePattern->SetDisabledDateRange(disabledDateRange_);
110     currentPattern->SetDisabledDateRange(disabledDateRange_);
111     nextPattern->SetDisabledDateRange(disabledDateRange_);
112 
113     // Flush the focus.
114     FlushFocus(preMonth_);
115     FlushFocus(currentMonth_);
116     FlushFocus(nextMonth_);
117     if (currentPattern->IsCalendarDialog()) {
118         FlushDialogData();
119         UpdateTitleNode();
120     }
121 
122     // Initialize the calendar.
123     if (initialize_) {
124         prePattern->SetMonthData(preMonth_, MonthState::PRE_MONTH);
125         currentPattern->SetMonthData(currentMonth_, MonthState::CUR_MONTH);
126         nextPattern->SetMonthData(nextMonth_, MonthState::NEXT_MONTH);
127         if (currentMonth_.days.empty() && calendarEventHub->GetOnRequestDataEvent()) {
128             FireFirstRequestData();
129         } else {
130             initialize_ = false;
131         }
132         InitSwiperChangeDoneEvent();
133         return;
134     }
135 
136     InitSwiperChangeDoneEvent();
137     // Check JumpTo and BackToToday function.
138     if (backToToday_ || goTo_) {
139         JumpTo(preFrameNode, currentFrameNode, nextFrameNode, swiperFrameNode);
140         return;
141     }
142     auto swiperPattern = swiperFrameNode->GetPattern<SwiperPattern>();
143     CHECK_NULL_VOID(swiperPattern);
144     auto currentIndex = swiperPattern->GetCurrentIndex();
145     currentMonthIndex_ = currentIndex;
146 
147     // Set calendat data according to the index.
148     switch (currentIndex) {
149         case 0: {
150             currentPattern->SetMonthData(nextMonth_, MonthState::NEXT_MONTH);
151             currentFrameNode->MarkModifyDone();
152             currentFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
153             prePattern->SetMonthData(currentMonth_, MonthState::CUR_MONTH);
154             preFrameNode->MarkModifyDone();
155             preFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
156             nextPattern->SetMonthData(preMonth_, MonthState::PRE_MONTH);
157             nextFrameNode->MarkModifyDone();
158             nextFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
159             return;
160         }
161         case 1: {
162             currentPattern->SetMonthData(currentMonth_, MonthState::CUR_MONTH);
163             currentFrameNode->MarkModifyDone();
164             currentFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
165             prePattern->SetMonthData(preMonth_, MonthState::PRE_MONTH);
166             preFrameNode->MarkModifyDone();
167             preFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
168             nextPattern->SetMonthData(nextMonth_, MonthState::NEXT_MONTH);
169             nextFrameNode->MarkModifyDone();
170             nextFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
171             return;
172         }
173         case 2: {
174             currentPattern->SetMonthData(preMonth_, MonthState::PRE_MONTH);
175             currentFrameNode->MarkModifyDone();
176             currentFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
177             prePattern->SetMonthData(nextMonth_, MonthState::NEXT_MONTH);
178             preFrameNode->MarkModifyDone();
179             preFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
180             nextPattern->SetMonthData(currentMonth_, MonthState::CUR_MONTH);
181             nextFrameNode->MarkModifyDone();
182             nextFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
183             return;
184         }
185         default:
186             return;
187     }
188 }
189 
InitSwiperChangeDoneEvent()190 void CalendarPattern::InitSwiperChangeDoneEvent()
191 {
192     auto host = GetHost();
193     CHECK_NULL_VOID(host);
194     auto hostNode = DynamicCast<FrameNode>(host);
195     CHECK_NULL_VOID(hostNode);
196     auto hostLayoutProperty = hostNode->GetLayoutProperty();
197     CHECK_NULL_VOID(hostLayoutProperty);
198     auto textDirection = hostLayoutProperty->GetNonAutoLayoutDirection();
199 
200     auto swiperNode = host->GetChildren().front();
201     CHECK_NULL_VOID(swiperNode);
202     auto swiperFrameNode = DynamicCast<FrameNode>(swiperNode);
203     CHECK_NULL_VOID(swiperFrameNode);
204     auto swiperEventHub = swiperFrameNode->GetOrCreateEventHub<SwiperEventHub>();
205     CHECK_NULL_VOID(swiperEventHub);
206     auto swiperPattern = swiperFrameNode->GetPattern<SwiperPattern>();
207     uint8_t totalCount = swiperPattern ? static_cast<uint8_t>(swiperPattern->TotalCount()) : TOTAL_COUNT;
208     CHECK_EQUAL_VOID(totalCount, 0);
209 
210     auto changeEventWithPreIndex = std::make_shared<ChangeEventWithPreIndex>(
211         [weak = WeakClaim(this), &curMonthIndex = curMonthIndex_, totalCount](int32_t preIndex, int32_t currentIndex) {
212             CHECK_EQUAL_VOID(curMonthIndex, currentIndex);
213             auto pattern = weak.Upgrade();
214             CHECK_NULL_VOID(pattern);
215 
216             if ((currentIndex == (curMonthIndex + 1) % totalCount) ||
217                 (currentIndex == 0 && curMonthIndex == (totalCount - 1))) {
218                     pattern->FireRequestData(MonthState::NEXT_MONTH);
219                     pattern->SetMoveDirection(NG::Direction::NEXT);
220             } else {
221                 pattern->FireRequestData(MonthState::PRE_MONTH);
222                 pattern->SetMoveDirection(NG::Direction::PRE);
223             }
224             curMonthIndex = static_cast<uint8_t>(currentIndex);
225             pattern->ReadTitleNode();
226             pattern->ClearChildrenFocus();
227     });
228     swiperEventHub->AddOnChangeEventWithPreIndex(changeEventWithPreIndex);
229 
230     for (const auto& calendarMonthNode : swiperNode->GetChildren()) {
231         auto calenderMonthFrameNode = AceType::DynamicCast<FrameNode>(calendarMonthNode);
232         CHECK_NULL_VOID(calenderMonthFrameNode);
233         auto monthLayoutProperty = calenderMonthFrameNode->GetLayoutProperty();
234         CHECK_NULL_VOID(monthLayoutProperty);
235         monthLayoutProperty->UpdateLayoutDirection(textDirection);
236         calenderMonthFrameNode->MarkModifyDone();
237         calenderMonthFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
238     }
239 }
240 
FireFirstRequestData()241 void CalendarPattern::FireFirstRequestData()
242 {
243     auto host = GetHost();
244     CHECK_NULL_VOID(host);
245     auto eventHub = GetOrCreateEventHub<CalendarEventHub>();
246     CHECK_NULL_VOID(eventHub);
247     auto json = JsonUtil::Create(true);
248     auto currentMonth = calendarDay_.month;
249     json->Put("currentYear", currentMonth.year);
250     json->Put("currentMonth", currentMonth.month);
251     json->Put("year", currentMonth.year);
252     json->Put("month", currentMonth.month);
253     json->Put("MonthState", 0);
254     eventHub->UpdateRequestDataEvent(json->ToString());
255 }
256 
FireRequestData(MonthState monthState)257 void CalendarPattern::FireRequestData(MonthState monthState)
258 {
259     auto host = GetHost();
260     CHECK_NULL_VOID(host);
261     auto eventHub = GetOrCreateEventHub<CalendarEventHub>();
262     CHECK_NULL_VOID(eventHub);
263     auto json = JsonUtil::Create(true);
264     if (monthState == MonthState::PRE_MONTH) {
265         json->Put("MonthState", 1);
266         json->Put("year", preMonth_.year);
267         json->Put("month", preMonth_.month);
268     } else if (monthState == MonthState::NEXT_MONTH) {
269         json->Put("MonthState", 2);
270         json->Put("year", nextMonth_.year);
271         json->Put("month", nextMonth_.month);
272     }
273     json->Put("currentYear", calendarDay_.month.year);
274     json->Put("currentMonth", calendarDay_.month.month);
275     eventHub->UpdateRequestDataEvent(json->ToString());
276 }
277 
FireGoToRequestData(int32_t year,int32_t month,int32_t day)278 void CalendarPattern::FireGoToRequestData(int32_t year, int32_t month, int32_t day)
279 {
280     auto host = GetHost();
281     CHECK_NULL_VOID(host);
282     auto eventHub = GetOrCreateEventHub<CalendarEventHub>();
283     CHECK_NULL_VOID(eventHub);
284     auto json = JsonUtil::Create(true);
285     auto currentMonth = calendarDay_.month;
286     json->Put("currentYear", currentMonth.year);
287     json->Put("currentMonth", currentMonth.month);
288     json->Put("year", year);
289     json->Put("month", month);
290     json->Put("MonthState", 0);
291     goToCalendarDay_ = day;
292     goToCalendarMonth_ = month;
293     goToCalendarYear_ = year;
294     eventHub->UpdateRequestDataEvent(json->ToString());
295 }
296 
JumpTo(ObtainedMonth & obtainedMonth)297 void CalendarPattern::JumpTo(ObtainedMonth& obtainedMonth)
298 {
299     for (auto& day : obtainedMonth.days) {
300         if (day.month.year == goToCalendarYear_ && day.month.month == goToCalendarMonth_ &&
301             day.day == goToCalendarDay_) {
302             day.focused = true;
303         } else {
304             day.focused = false;
305         }
306     }
307 }
308 
JumpTo(const RefPtr<FrameNode> & preFrameNode,const RefPtr<FrameNode> & curFrameNode,const RefPtr<FrameNode> & nextFrameNode,const RefPtr<FrameNode> & swiperFrameNode)309 void CalendarPattern::JumpTo(const RefPtr<FrameNode>& preFrameNode, const RefPtr<FrameNode>& curFrameNode,
310     const RefPtr<FrameNode>& nextFrameNode, const RefPtr<FrameNode>& swiperFrameNode)
311 {
312     auto prePattern = preFrameNode->GetPattern<CalendarMonthPattern>();
313     CHECK_NULL_VOID(prePattern);
314     auto currentPattern = curFrameNode->GetPattern<CalendarMonthPattern>();
315     CHECK_NULL_VOID(currentPattern);
316     auto nextPattern = nextFrameNode->GetPattern<CalendarMonthPattern>();
317     CHECK_NULL_VOID(nextPattern);
318     auto swiperPattern = swiperFrameNode->GetPattern<SwiperPattern>();
319     CHECK_NULL_VOID(swiperPattern);
320     auto currentIndex = swiperPattern->GetCurrentIndex();
321     currentMonthIndex_ = currentIndex;
322     if (goTo_) {
323         JumpTo(currentMonth_);
324     }
325     switch (currentIndex) {
326         case 0: {
327             prePattern->SetMonthData(currentMonth_, MonthState::CUR_MONTH);
328             if (backToToday_) {
329                 prePattern->SetCalendarDay(calendarDay_);
330             }
331             currentPattern->SetMonthData(nextMonth_, MonthState::NEXT_MONTH);
332             nextPattern->SetMonthData(preMonth_, MonthState::PRE_MONTH);
333             curFrameNode->MarkModifyDone();
334             curFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
335             preFrameNode->MarkModifyDone();
336             preFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
337             nextFrameNode->MarkModifyDone();
338             nextFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
339             break;
340         }
341         case 1: {
342             prePattern->SetMonthData(preMonth_, MonthState::PRE_MONTH);
343             currentPattern->SetMonthData(currentMonth_, MonthState::CUR_MONTH);
344             if (backToToday_) {
345                 currentPattern->SetCalendarDay(calendarDay_);
346             }
347             nextPattern->SetMonthData(nextMonth_, MonthState::NEXT_MONTH);
348             curFrameNode->MarkModifyDone();
349             curFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
350             preFrameNode->MarkModifyDone();
351             preFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
352             nextFrameNode->MarkModifyDone();
353             nextFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
354             break;
355         }
356         case 2: {
357             prePattern->SetMonthData(nextMonth_, MonthState::NEXT_MONTH);
358             currentPattern->SetMonthData(preMonth_, MonthState::PRE_MONTH);
359             nextPattern->SetMonthData(currentMonth_, MonthState::CUR_MONTH);
360             if (backToToday_) {
361                 nextPattern->SetCalendarDay(calendarDay_);
362             }
363             curFrameNode->MarkModifyDone();
364             curFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
365             preFrameNode->MarkModifyDone();
366             preFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
367             nextFrameNode->MarkModifyDone();
368             nextFrameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
369             break;
370         }
371         default:
372             break;
373     }
374     backToToday_ = false;
375     goTo_ = false;
376 }
377 
FlushFocus(ObtainedMonth & obtainedMonth)378 void CalendarPattern::FlushFocus(ObtainedMonth& obtainedMonth)
379 {
380     if (obtainedMonth.days.empty()) {
381         LOGE("month data is empty");
382         return;
383     }
384     bool flag = false;
385     for (auto& day : obtainedMonth.days) {
386         day.focused = day.month.year == calendarDay_.month.year && day.month.month == calendarDay_.month.month &&
387                       day.day == calendarDay_.day;
388         if (!flag && day.focused == true) {
389             flag = true;
390         }
391     }
392     if (!flag) {
393         obtainedMonth.days[0].focused = true;
394     }
395 }
396 
FlushDialogData()397 void CalendarPattern::FlushDialogData()
398 {
399     FlushDialogMonthData(preMonth_);
400     FlushDialogMonthData(currentMonth_);
401     FlushDialogMonthData(nextMonth_);
402 }
403 
FlushDialogMonthData(ObtainedMonth & obtainedMonth)404 void CalendarPattern::FlushDialogMonthData(ObtainedMonth& obtainedMonth)
405 {
406     if (obtainedMonth.days.empty()) {
407         return;
408     }
409     for (auto& day : obtainedMonth.days) {
410         day.isSelected = day.month.year == static_cast<int32_t>(selectedDay_.GetYear()) &&
411                          day.month.month == static_cast<int32_t>(selectedDay_.GetMonth()) &&
412                          day.day == static_cast<int32_t>(selectedDay_.GetDay());
413     }
414 }
415 
ClearChildrenFocus()416 void CalendarPattern::ClearChildrenFocus()
417 {
418     auto host = GetHost();
419     CHECK_NULL_VOID(host);
420     auto swiperNode = host->GetChildren().front();
421     CHECK_NULL_VOID(swiperNode);
422     auto swiperFrameNode = DynamicCast<FrameNode>(swiperNode);
423     CHECK_NULL_VOID(swiperFrameNode);
424     auto preFrameNode = AceType::DynamicCast<FrameNode>(swiperFrameNode->GetChildren().front());
425     CHECK_NULL_VOID(preFrameNode);
426     auto prePattern = preFrameNode->GetPattern<CalendarMonthPattern>();
427     CHECK_NULL_VOID(prePattern);
428     auto iterator = swiperFrameNode->GetChildren().begin();
429     auto currentFrameNode = AceType::DynamicCast<FrameNode>(*(++iterator));
430     CHECK_NULL_VOID(currentFrameNode);
431     auto currentPattern = currentFrameNode->GetPattern<CalendarMonthPattern>();
432     CHECK_NULL_VOID(currentPattern);
433     auto nextFrameNode = AceType::DynamicCast<FrameNode>(swiperFrameNode->GetChildren().back());
434     CHECK_NULL_VOID(nextFrameNode);
435     auto nextPattern = nextFrameNode->GetPattern<CalendarMonthPattern>();
436     CHECK_NULL_VOID(nextPattern);
437     prePattern->ClearFocusCalendarDay();
438     currentPattern->ClearFocusCalendarDay();
439     nextPattern->ClearFocusCalendarDay();
440 }
441 
ReadTitleNode()442 void CalendarPattern::ReadTitleNode()
443 {
444     auto host = GetHost();
445     CHECK_NULL_VOID(host);
446     host->OnAccessibilityEvent(AccessibilityEventType::ANNOUNCE_FOR_ACCESSIBILITY, selectedMonth_);
447 }
448 
UpdateTitleNode()449 void CalendarPattern::UpdateTitleNode()
450 {
451     if (!HasTitleNode()) {
452         return;
453     }
454     auto textTitleNode = FrameNode::GetOrCreateFrameNode(
455         V2::TEXT_ETS_TAG, GetTitleId(), []() { return AceType::MakeRefPtr<TextPattern>(); });
456     CHECK_NULL_VOID(textTitleNode);
457     auto textLayoutProperty = textTitleNode->GetLayoutProperty<TextLayoutProperty>();
458     CHECK_NULL_VOID(textLayoutProperty);
459 
460     DateTime date;
461     date.year = currentMonth_.year < 0 ? 0 : static_cast<uint32_t>(currentMonth_.year);
462     date.month = currentMonth_.month - 1 < 0
463                      ? 0
464                      : static_cast<uint32_t>(currentMonth_.month - 1); // W3C's month start from 0 to 11
465     auto titleDate = Localization::GetInstance()->FormatDateTime(date, "YYYYMM");
466     textLayoutProperty->UpdateContent(titleDate);
467     selectedMonth_ = titleDate;
468     auto pipelineContext = GetHost()->GetContext();
469     CHECK_NULL_VOID(pipelineContext);
470     RefPtr<CalendarTheme> theme = pipelineContext->GetTheme<CalendarTheme>();
471     CHECK_NULL_VOID(theme);
472     auto fontSizeScale = pipelineContext->GetFontScale();
473     auto fontSize = theme->GetCalendarTitleFontSize();
474 #ifndef ARKUI_WEARABLE
475     if (fontSizeScale < theme->GetCalendarPickerLargeScale() || CalendarDialogView::CheckOrientationChange()) {
476 #else
477     if (fontSizeScale < theme->GetCalendarPickerLargeScale()) {
478 #endif
479         textLayoutProperty->UpdateFontSize(fontSize);
480     } else {
481         textLayoutProperty->UpdateMaxLines(2);
482         fontSizeScale = fontSizeScale > theme->GetCalendarPickerLargerScale() ? theme->GetCalendarPickerLargerScale()
483                                                                               : fontSizeScale;
484         textLayoutProperty->UpdateFontSize(fontSize * fontSizeScale);
485     }
486 
487     textTitleNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
488     textTitleNode->MarkModifyDone();
489 }
490 
491 void CalendarPattern::ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const
492 {
493     /* no fixed attr below, just return */
494     if (filter.IsFastFilter()) {
495         return;
496     }
497     auto host = GetHost();
498     CHECK_NULL_VOID(host);
499     auto swiperNode = AceType::DynamicCast<FrameNode>(host->GetChildren().front());
500     CHECK_NULL_VOID(swiperNode);
501     auto swiperLayoutProperty = swiperNode->GetLayoutProperty<SwiperLayoutProperty>();
502     CHECK_NULL_VOID(swiperLayoutProperty);
503     json->PutExtAttr("needSlide",
504         !swiperLayoutProperty->GetDisableSwipe().value_or(false) ? "true" : "false", filter);
505     json->PutExtAttr("direction",
506         swiperLayoutProperty->GetDirection().value_or(Axis::HORIZONTAL) == Axis::VERTICAL ? "0" : "1", filter);
507 }
508 
509 } // namespace OHOS::Ace::NG
510