1 /*
2  * Copyright (c) 2021-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 #ifndef FOUNDATION_ACE_FRAMEWORK_JAVASCRIPT_BRIDGE_JS_VIEW_JS_TAB_CONTENT_H
17 #define FOUNDATION_ACE_FRAMEWORK_JAVASCRIPT_BRIDGE_JS_VIEW_JS_TAB_CONTENT_H
18 
19 #include "bridge/declarative_frontend/engine/bindings_defines.h"
20 #include "bridge/declarative_frontend/engine/js_types.h"
21 #include "frameworks/bridge/declarative_frontend/engine/functions/js_function.h"
22 #include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h"
23 #include "frameworks/core/components/tab_bar/tab_content_component.h"
24 #include "frameworks/core/components_v2/tabs/tab_content_item_component.h"
25 #include "frameworks/core/components_v2/tabs/tabs_component.h"
26 #include "frameworks/core/components_ng/pattern/tabs/tab_content_model.h"
27 #include "frameworks/core/components_ng/pattern/tabs/tabs_model_ng.h"
28 
29 namespace OHOS::Ace::Framework {
30 
31 class JSTabContent : public JSContainerBase {
32 public:
33     static void JSBind(BindingTarget globalObj);
34     static void Create(const JSCallbackInfo& info);
35     static void Pop();
36 
37     static void SetTabBar(const JSCallbackInfo& info);
38 
39 protected:
40 
41     // The width and height of tabcontent depend on the size constraints of tabs and tabbar.
SetTabContentWidth(const JSCallbackInfo & info)42     static void SetTabContentWidth(const JSCallbackInfo& info)
43     {
44         LOGW("TabContent does not support width and height settings");
45     }
46 
SetTabContentHeight(const JSCallbackInfo & info)47     static void SetTabContentHeight(const JSCallbackInfo& info)
48     {
49         LOGW("TabContent does not support width and height settings");
50     }
51 
SetTabContentSize(const JSCallbackInfo & info)52     static void SetTabContentSize(const JSCallbackInfo& info)
53     {
54         LOGW("TabContent does not support width and height settings");
55     }
56 
57 private:
58     static void CreateForPartialUpdate(const JSCallbackInfo& info);
59     static void CreateForNG(const JSCallbackInfo& info);
60     static void SetTabBarForNG(const JSCallbackInfo& info);
61     static void SetIndicator(const JSRef<JSVal>& info);
62     static void SetBoard(const JSRef<JSVal>& info);
63     static void SetSelectedMode(const JSRef<JSVal>& info);
64     static void SetSubTabBarStyle(const JSRef<JSObject>& paramObject);
65     static void SetLabelStyle(const JSRef<JSVal>& info, bool isSubTabStyle);
66     static void SetIconStyle(const JSRef<JSVal>& info);
67     static void SetPadding(const JSRef<JSVal>& info, bool isSubTabStyle);
68     static void GetFontContent(JSRef<JSVal> font, LabelStyle& labelStyle, bool isSubTabStyle);
69     static void GetLabelUnselectedContent(JSRef<JSVal> unselectedColorValue, LabelStyle& labelStyle);
70     static void GetLabelSelectedContent(JSRef<JSVal> selectedColorValue, LabelStyle& labelStyle);
71     static void CompleteParameters(LabelStyle& buttonParameters, bool isSubTabStyle);
72     static void SetLayoutMode(const JSRef<JSVal>& info);
73     static void SetVerticalAlign(const JSRef<JSVal>& info);
74     static void SetSymmetricExtensible(const JSRef<JSVal>& info);
75     static void SetId(const JSRef<JSVal>& info);
76     static void SetBottomTabBarStyle(const JSCallbackInfo& info);
77     static void SetOnWillShow(const JSCallbackInfo& info);
78     static void SetOnWillHide(const JSCallbackInfo& info);
79 };
80 
81 } // namespace OHOS::Ace::Framework
82 
83 #endif // FOUNDATION_ACE_FRAMEWORK_JAVASCRIPT_BRIDGE_JS_VIEW_JS_TAB_CONTENT_H
84