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/tabs/tab_content_model_ng.h"
17
18 #include "base/memory/ace_type.h"
19 #include "base/memory/referenced.h"
20 #include "base/utils/utils.h"
21 #include "core/components/tab_bar/tab_theme.h"
22 #include "core/components_ng/base/frame_node.h"
23 #include "core/components_ng/base/view_stack_processor.h"
24 #include "core/components_ng/pattern/image/image_layout_property.h"
25 #include "core/components_ng/pattern/image/image_pattern.h"
26 #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h"
27 #include "core/components_ng/pattern/swiper/swiper_pattern.h"
28 #include "core/components_ng/pattern/tabs/tab_bar_pattern.h"
29 #include "core/components_ng/pattern/tabs/tab_content_node.h"
30 #include "core/components_ng/pattern/tabs/tab_content_pattern.h"
31 #include "core/components_ng/pattern/tabs/tabs_node.h"
32 #include "core/components_ng/pattern/text/text_pattern.h"
33 #include "core/components_v2/inspector/inspector_constants.h"
34
35 namespace OHOS::Ace::NG {
36
Create(std::function<void ()> && deepRenderFunc)37 void TabContentModelNG::Create(std::function<void()>&& deepRenderFunc)
38 {
39 auto* stack = ViewStackProcessor::GetInstance();
40 auto nodeId = stack->ClaimNodeId();
41 auto deepRender = [nodeId, deepRenderFunc = std::move(deepRenderFunc)]() -> RefPtr<UINode> {
42 CHECK_NULL_RETURN(deepRenderFunc, nullptr);
43 ScopedViewStackProcessor scopedViewStackProcessor;
44 deepRenderFunc();
45 auto deepChild = ViewStackProcessor::GetInstance()->Finish();
46 auto parent = FrameNode::GetFrameNode(V2::TAB_CONTENT_ITEM_ETS_TAG, nodeId);
47 if (deepChild && parent) {
48 deepChild->MountToParent(parent);
49 }
50 return deepChild;
51 };
52 auto frameNode = TabContentNode::GetOrCreateTabContentNode(V2::TAB_CONTENT_ITEM_ETS_TAG, nodeId,
53 [shallowBuilder = AceType::MakeRefPtr<ShallowBuilder>(std::move(deepRender))]() {
54 return AceType::MakeRefPtr<TabContentPattern>(shallowBuilder);
55 });
56 stack->Push(frameNode);
57 auto pipelineContext = PipelineContext::GetCurrentContext();
58 CHECK_NULL_VOID(pipelineContext);
59 auto tabTheme = pipelineContext->GetTheme<TabTheme>();
60 CHECK_NULL_VOID(tabTheme);
61 SetTabBar(tabTheme->GetDefaultTabBarName(), "", nullptr, true); // Set default tab bar.
62 ACE_UPDATE_LAYOUT_PROPERTY(TabContentLayoutProperty, Text, tabTheme->GetDefaultTabBarName());
63 }
64
Create()65 void TabContentModelNG::Create()
66 {
67 auto* stack = ViewStackProcessor::GetInstance();
68 int32_t nodeId = stack->ClaimNodeId();
69 auto frameNode = TabContentNode::GetOrCreateTabContentNode(
70 V2::TAB_CONTENT_ITEM_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr<TabContentPattern>(nullptr); });
71 stack->Push(frameNode);
72 auto pipelineContext = PipelineContext::GetCurrentContext();
73 CHECK_NULL_VOID(pipelineContext);
74 auto tabTheme = pipelineContext->GetTheme<TabTheme>();
75 CHECK_NULL_VOID(tabTheme);
76 SetTabBar(tabTheme->GetDefaultTabBarName(), "", nullptr, true); // Set default tab bar.
77 ACE_UPDATE_LAYOUT_PROPERTY(TabContentLayoutProperty, Text, tabTheme->GetDefaultTabBarName());
78 }
79
Pop()80 void TabContentModelNG::Pop()
81 {
82 auto tabContent = NG::ViewStackProcessor::GetInstance()->GetMainFrameNode();
83 AddTabBarItem(tabContent, DEFAULT_NODE_SLOT, true);
84 NG::ViewStackProcessor::GetInstance()->PopContainer();
85 }
86
FindTabsNode(const RefPtr<UINode> & tabContent)87 RefPtr<TabsNode> TabContentModelNG::FindTabsNode(const RefPtr<UINode>& tabContent)
88 {
89 CHECK_NULL_RETURN(tabContent, nullptr);
90 RefPtr<UINode> parent = tabContent->GetParent();
91
92 while (parent) {
93 if (AceType::InstanceOf<TabsNode>(parent)) {
94 return AceType::DynamicCast<TabsNode>(parent);
95 }
96 parent = parent->GetParent();
97 }
98 return nullptr;
99 }
100
AddTabBarItem(const RefPtr<UINode> & tabContent,int32_t position,bool update)101 void TabContentModelNG::AddTabBarItem(const RefPtr<UINode>& tabContent, int32_t position, bool update)
102 {
103 LOGD("position %{public}d", position);
104 CHECK_NULL_VOID(tabContent);
105 auto tabContentId = tabContent->GetId();
106
107 auto tabContentNode = AceType::DynamicCast<TabContentNode>(tabContent);
108 CHECK_NULL_VOID(tabContentNode);
109
110 if (update && !tabContentNode->HasTabBarItemId()) {
111 LOGD("Update only, return");
112 return;
113 }
114
115 auto tabsNode = FindTabsNode(tabContent);
116 CHECK_NULL_VOID(tabsNode);
117
118 auto tabBarNode = tabsNode->GetTabBar();
119 CHECK_NULL_VOID(tabBarNode);
120 auto tabContentPattern = tabContentNode->GetPattern<TabContentPattern>();
121 CHECK_NULL_VOID(tabContentPattern);
122 const auto& tabBarParam = tabContentPattern->GetTabBarParam();
123
124 // Create column node to contain image and text or builder.
125 auto columnNode = FrameNode::GetOrCreateFrameNode(V2::COLUMN_ETS_TAG, tabContentNode->GetTabBarItemId(),
126 []() { return AceType::MakeRefPtr<LinearLayoutPattern>(true); });
127 auto pipelineContext = PipelineContext::GetCurrentContext();
128 CHECK_NULL_VOID(pipelineContext);
129 auto tabTheme = pipelineContext->GetTheme<TabTheme>();
130 CHECK_NULL_VOID(tabTheme);
131 auto linearLayoutProperty = columnNode->GetLayoutProperty<LinearLayoutProperty>();
132 CHECK_NULL_VOID(linearLayoutProperty);
133 linearLayoutProperty->UpdateMainAxisAlign(FlexAlign::CENTER);
134 linearLayoutProperty->UpdateCrossAxisAlign(FlexAlign::CENTER);
135 linearLayoutProperty->UpdateSpace(tabTheme->GetBottomTabBarSpace());
136 auto columnRenderContext = columnNode->GetRenderContext();
137 CHECK_NULL_VOID(columnRenderContext);
138 columnRenderContext->UpdateClipEdge(true);
139 auto tabBarFrameNode = AceType::DynamicCast<FrameNode>(tabBarNode);
140 CHECK_NULL_VOID(tabBarFrameNode);
141 auto tabBarPattern = tabBarFrameNode->GetPattern<TabBarPattern>();
142 CHECK_NULL_VOID(tabBarPattern);
143 tabBarPattern->SetTabBarStyle(tabBarParam.GetTabBarStyle());
144 auto selectedMode = tabContentPattern->GetSelectedMode();
145 auto indicatorStyle = tabContentPattern->GetIndicatorStyle();
146 auto boardStyle = tabContentPattern->GetBoardStyle();
147 auto bottomTabBarStyle = tabContentPattern->GetBottomTabBarStyle();
148 auto padding = tabContentPattern->GetPadding();
149
150 auto linearLayoutPattern = columnNode->GetPattern<LinearLayoutPattern>();
151 CHECK_NULL_VOID(linearLayoutPattern);
152
153 if (tabBarParam.GetTabBarStyle() == TabBarStyle::BOTTOMTABBATSTYLE) {
154 if (bottomTabBarStyle.layoutMode == LayoutMode::HORIZONTAL) {
155 linearLayoutProperty->UpdateFlexDirection(FlexDirection::ROW);
156 linearLayoutProperty->UpdateSpace(tabTheme->GetHorizontalBottomTabBarSpace());
157 linearLayoutProperty->UpdateCrossAxisAlign(bottomTabBarStyle.verticalAlign);
158 linearLayoutProperty->SetIsVertical(false);
159 } else {
160 linearLayoutProperty->UpdateFlexDirection(FlexDirection::COLUMN);
161 linearLayoutProperty->UpdateSpace(tabTheme->GetBottomTabBarSpace());
162 linearLayoutProperty->UpdateMainAxisAlign(bottomTabBarStyle.verticalAlign);
163 linearLayoutProperty->SetIsVertical(true);
164 }
165 }
166
167 auto swiperNode = AceType::DynamicCast<FrameNode>(tabsNode->GetTabs());
168 CHECK_NULL_VOID(swiperNode);
169 auto myIndex = swiperNode->GetChildFlatIndex(tabContentId).second;
170
171 tabBarPattern->SetTabBarStyle(tabBarParam.GetTabBarStyle(), myIndex);
172 tabBarPattern->SetBottomTabBarStyle(bottomTabBarStyle, myIndex);
173 auto tabBarStyle = tabContentPattern->GetTabBarStyle();
174 if (tabBarStyle == TabBarStyle::SUBTABBATSTYLE) {
175 auto renderContext = columnNode->GetRenderContext();
176 CHECK_NULL_VOID(renderContext);
177 BorderRadiusProperty borderRadiusProperty;
178 borderRadiusProperty.SetRadius(boardStyle.borderRadius);
179 renderContext->UpdateBorderRadius(borderRadiusProperty);
180 }
181 if (tabBarStyle != TabBarStyle::SUBTABBATSTYLE) {
182 indicatorStyle.marginTop = 0.0_vp;
183 }
184 tabBarPattern->SetSelectedMode(selectedMode, myIndex);
185 tabBarPattern->SetIndicatorStyle(indicatorStyle, myIndex);
186 tabBarPattern->UpdateSubTabBoard();
187
188 // Create tab bar with builder.
189 if (tabBarParam.HasBuilder()) {
190 ScopedViewStackProcessor builderViewStackProcessor;
191 tabBarParam.ExecuteBuilder();
192 auto builderNode = ViewStackProcessor::GetInstance()->Finish();
193 if (static_cast<int32_t>(columnNode->GetChildren().size()) != 0) {
194 columnNode->Clean();
195 }
196 builderNode->MountToParent(columnNode);
197 auto oldColumnNode = tabsNode->GetBuilderByContentId(tabContentId, columnNode);
198 if (!oldColumnNode) {
199 columnNode->MountToParent(tabBarNode, myIndex);
200 } else {
201 tabBarNode->ReplaceChild(oldColumnNode, columnNode);
202 }
203 tabBarPattern->AddTabBarItemType(tabContentId, true);
204 tabBarFrameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
205 return;
206 }
207 if (tabBarParam.GetText().empty()) {
208 LOGW("Text is empty.");
209 } else {
210 LOGD("Text %{public}s", tabBarParam.GetText().c_str());
211 }
212
213 // Create text node and image node.
214 RefPtr<FrameNode> textNode;
215 RefPtr<FrameNode> imageNode;
216 auto layoutProperty = columnNode->GetLayoutProperty();
217 CHECK_NULL_VOID(layoutProperty);
218 if (tabBarStyle == TabBarStyle::SUBTABBATSTYLE || tabBarStyle == TabBarStyle::BOTTOMTABBATSTYLE) {
219 layoutProperty->UpdatePadding(padding);
220 } else {
221 auto deviceType = SystemProperties::GetDeviceType();
222 auto tabBarItemPadding = deviceType == DeviceType::PHONE ? tabTheme->GetSubTabHorizontalPadding()
223 : tabTheme->GetSubtabLandscapeHorizontalPadding();
224 layoutProperty->UpdatePadding({ CalcLength(tabBarItemPadding), CalcLength(tabBarItemPadding),
225 CalcLength(tabBarItemPadding), CalcLength(tabBarItemPadding) });
226 }
227
228 if (static_cast<int32_t>(columnNode->GetChildren().size()) == 0) {
229 ImageSourceInfo imageSourceInfo(tabBarParam.GetIcon());
230 imageNode = FrameNode::GetOrCreateFrameNode(V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
231 []() { return AceType::MakeRefPtr<ImagePattern>(); });
232 textNode = FrameNode::GetOrCreateFrameNode(V2::TEXT_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
233 []() { return AceType::MakeRefPtr<TextPattern>(); });
234 CHECK_NULL_VOID(textNode);
235 CHECK_NULL_VOID(imageNode);
236 columnNode->MountToParent(tabBarNode, position);
237 imageNode->MountToParent(columnNode);
238 textNode->MountToParent(columnNode);
239 } else {
240 imageNode = AceType::DynamicCast<FrameNode>(columnNode->GetChildren().front());
241 textNode = AceType::DynamicCast<FrameNode>(columnNode->GetChildren().back());
242 }
243 CHECK_NULL_VOID(textNode);
244 CHECK_NULL_VOID(imageNode);
245
246 auto swiperPattern = swiperNode->GetPattern<SwiperPattern>();
247 CHECK_NULL_VOID(swiperPattern);
248 auto swiperLayoutProperty = swiperNode->GetLayoutProperty<SwiperLayoutProperty>();
249 CHECK_NULL_VOID(swiperLayoutProperty);
250 int32_t indicator = swiperLayoutProperty->GetIndexValue(0);
251 int32_t totalCount = swiperPattern->TotalCount();
252 if (indicator > totalCount - 1 || indicator < 0) {
253 indicator = 0;
254 }
255
256 // Update property of text.
257 auto textLayoutProperty = textNode->GetLayoutProperty<TextLayoutProperty>();
258 CHECK_NULL_VOID(textLayoutProperty);
259 if (myIndex == indicator) {
260 textLayoutProperty->UpdateTextColor(tabTheme->GetActiveIndicatorColor());
261 } else {
262 textLayoutProperty->UpdateTextColor(tabTheme->GetSubTabTextOffColor());
263 }
264 auto textRenderContext = textNode->GetRenderContext();
265 CHECK_NULL_VOID(textRenderContext);
266 textRenderContext->UpdateClipEdge(true);
267 textLayoutProperty->UpdateContent(tabBarParam.GetText());
268 textLayoutProperty->UpdateFontSize(tabTheme->GetSubTabTextDefaultFontSize());
269 textLayoutProperty->UpdateTextAlign(TextAlign::CENTER);
270 if (tabBarStyle == TabBarStyle::BOTTOMTABBATSTYLE && bottomTabBarStyle.layoutMode == LayoutMode::HORIZONTAL) {
271 textLayoutProperty->UpdateTextAlign(TextAlign::LEFT);
272 }
273 textLayoutProperty->UpdateMaxLines(1);
274 textLayoutProperty->UpdateTextOverflow(TextOverflow::ELLIPSIS);
275 if (tabBarStyle == TabBarStyle::BOTTOMTABBATSTYLE) {
276 textLayoutProperty->UpdateFlexShrink(1.0f);
277 }
278
279 // Update property of image.
280 auto imageProperty = imageNode->GetLayoutProperty<ImageLayoutProperty>();
281 CHECK_NULL_VOID(imageProperty);
282 if (!tabBarParam.GetIcon().empty() || tabBarStyle == TabBarStyle::BOTTOMTABBATSTYLE) {
283 textLayoutProperty->UpdateFontSize(tabTheme->GetBottomTabTextSize());
284 imageProperty->UpdateUserDefinedIdealSize(CalcSize(
285 NG::CalcLength(tabTheme->GetBottomTabImageSize()), NG::CalcLength(tabTheme->GetBottomTabImageSize())));
286 } else {
287 imageProperty->UpdateUserDefinedIdealSize(CalcSize());
288 }
289 if (tabBarStyle == TabBarStyle::BOTTOMTABBATSTYLE) {
290 textLayoutProperty->UpdateFontWeight(FontWeight::MEDIUM);
291 }
292 auto labelStyle = tabContentPattern->GetLabelStyle();
293 UpdateLabelStyle(labelStyle, textLayoutProperty);
294 ImageSourceInfo imageSourceInfo(tabBarParam.GetIcon());
295 if (imageSourceInfo.IsSvg()) {
296 if (myIndex == indicator) {
297 imageSourceInfo.SetFillColor(tabTheme->GetBottomTabIconOn());
298 } else {
299 imageSourceInfo.SetFillColor(tabTheme->GetBottomTabIconOff());
300 }
301 }
302
303 imageProperty->UpdateImageSourceInfo(imageSourceInfo);
304 columnNode->MarkModifyDone();
305 textNode->MarkModifyDone();
306 textNode->MarkDirtyNode();
307 imageNode->MarkModifyDone();
308 tabBarPattern->AddTabBarItemType(tabContentId, false);
309 tabBarFrameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
310 }
311
RemoveTabBarItem(const RefPtr<TabContentNode> & tabContentNode)312 void TabContentModelNG::RemoveTabBarItem(const RefPtr<TabContentNode>& tabContentNode)
313 {
314 CHECK_NULL_VOID(tabContentNode);
315 if (!tabContentNode->HasTabBarItemId()) {
316 return;
317 }
318
319 auto tabBarItemId = tabContentNode->GetTabBarItemId();
320 LOGD("Tab ID: %{public}d, Bar item ID: %{public}d", tabContentNode->GetId(), tabBarItemId);
321 auto tabBarItemNode = ElementRegister::GetInstance()->GetUINodeById(tabBarItemId);
322 CHECK_NULL_VOID(tabBarItemNode);
323 auto tabBarNode = tabBarItemNode->GetParent();
324 tabBarNode->RemoveChild(tabBarItemNode);
325 CHECK_NULL_VOID(tabBarNode);
326 tabContentNode->ResetTabBarItemId();
327
328 auto tabsNode = FindTabsNode(tabContentNode);
329 CHECK_NULL_VOID(tabsNode);
330 tabsNode->RemoveBuilderByContentId(tabContentNode->GetId());
331 auto tabBar = tabsNode->GetTabBar();
332 CHECK_NULL_VOID(tabBar);
333 auto tabBarFrameNode = AceType::DynamicCast<FrameNode>(tabBar);
334 CHECK_NULL_VOID(tabBarFrameNode);
335 tabBarFrameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
336 }
337
SetTabBar(const std::optional<std::string> & text,const std::optional<std::string> & icon,TabBarBuilderFunc && builder,bool)338 void TabContentModelNG::SetTabBar(const std::optional<std::string>& text, const std::optional<std::string>& icon,
339 TabBarBuilderFunc&& builder, bool /*useContentOnly*/)
340 {
341 ACE_UPDATE_LAYOUT_PROPERTY(TabContentLayoutProperty, Icon, icon.value_or(""));
342 ACE_UPDATE_LAYOUT_PROPERTY(TabContentLayoutProperty, Text, text.value_or(""));
343 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
344 CHECK_NULL_VOID(frameNodePattern);
345 frameNodePattern->SetTabBar(text.value_or(""), icon.value_or(""), std::move(builder));
346 }
347
SetTabBarStyle(TabBarStyle tabBarStyle)348 void TabContentModelNG::SetTabBarStyle(TabBarStyle tabBarStyle)
349 {
350 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
351 CHECK_NULL_VOID(frameNodePattern);
352 frameNodePattern->SetTabBarStyle(tabBarStyle);
353 }
354
SetIndicator(const IndicatorStyle & indicator)355 void TabContentModelNG::SetIndicator(const IndicatorStyle& indicator)
356 {
357 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
358 CHECK_NULL_VOID(frameNodePattern);
359 frameNodePattern->SetIndicatorStyle(indicator);
360 }
361
SetBoard(const BoardStyle & board)362 void TabContentModelNG::SetBoard(const BoardStyle& board)
363 {
364 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
365 CHECK_NULL_VOID(frameNodePattern);
366 frameNodePattern->SetBoardStyle(board);
367 }
368
SetSelectedMode(SelectedMode selectedMode)369 void TabContentModelNG::SetSelectedMode(SelectedMode selectedMode)
370 {
371 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
372 CHECK_NULL_VOID(frameNodePattern);
373 frameNodePattern->SetSelectedMode(selectedMode);
374 }
375
SetLabelStyle(const LabelStyle & labelStyle)376 void TabContentModelNG::SetLabelStyle(const LabelStyle& labelStyle)
377 {
378 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
379 CHECK_NULL_VOID(frameNodePattern);
380 frameNodePattern->SetLabelStyle(labelStyle);
381 }
382
SetPadding(const PaddingProperty & padding)383 void TabContentModelNG::SetPadding(const PaddingProperty& padding)
384 {
385 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
386 CHECK_NULL_VOID(frameNodePattern);
387 frameNodePattern->SetPadding(padding);
388 }
389
SetLayoutMode(LayoutMode layoutMode)390 void TabContentModelNG::SetLayoutMode(LayoutMode layoutMode)
391 {
392 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
393 CHECK_NULL_VOID(frameNodePattern);
394 frameNodePattern->SetLayoutMode(layoutMode);
395 }
396
SetVerticalAlign(FlexAlign verticalAlign)397 void TabContentModelNG::SetVerticalAlign(FlexAlign verticalAlign)
398 {
399 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
400 CHECK_NULL_VOID(frameNodePattern);
401 frameNodePattern->SetVerticalAlign(verticalAlign);
402 }
403
SetSymmetricExtensible(bool isExtensible)404 void TabContentModelNG::SetSymmetricExtensible(bool isExtensible)
405 {
406 auto frameNodePattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern<TabContentPattern>();
407 CHECK_NULL_VOID(frameNodePattern);
408 frameNodePattern->SetSymmetricExtensible(isExtensible);
409 }
410
UpdateLabelStyle(const LabelStyle & labelStyle,RefPtr<TextLayoutProperty> textLayoutProperty)411 void TabContentModelNG::UpdateLabelStyle(const LabelStyle& labelStyle, RefPtr<TextLayoutProperty> textLayoutProperty)
412 {
413 CHECK_NULL_VOID(textLayoutProperty);
414
415 if (labelStyle.fontSize.has_value()) {
416 textLayoutProperty->UpdateFontSize(labelStyle.fontSize.value());
417 }
418 if (labelStyle.fontWeight.has_value()) {
419 textLayoutProperty->UpdateFontWeight(labelStyle.fontWeight.value());
420 }
421 if (labelStyle.fontStyle.has_value()) {
422 textLayoutProperty->UpdateItalicFontStyle(labelStyle.fontStyle.value());
423 }
424 if (labelStyle.fontFamily.has_value()) {
425 textLayoutProperty->UpdateFontFamily(labelStyle.fontFamily.value());
426 }
427 if (labelStyle.textOverflow.has_value()) {
428 textLayoutProperty->UpdateTextOverflow(labelStyle.textOverflow.value());
429 }
430 if (labelStyle.maxLines.has_value()) {
431 textLayoutProperty->UpdateMaxLines(labelStyle.maxLines.value());
432 }
433 if (labelStyle.minFontSize.has_value()) {
434 textLayoutProperty->UpdateAdaptMinFontSize(labelStyle.minFontSize.value());
435 }
436 if (labelStyle.maxFontSize.has_value()) {
437 textLayoutProperty->UpdateAdaptMaxFontSize(labelStyle.maxFontSize.value());
438 }
439 if (labelStyle.heightAdaptivePolicy.has_value()) {
440 textLayoutProperty->UpdateHeightAdaptivePolicy(labelStyle.heightAdaptivePolicy.value());
441 }
442 }
443 } // namespace OHOS::Ace::NG
444