1 /*
2  * Copyright (c) 2021-2022 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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_FLEX_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_FLEX_H
18 
19 #include <list>
20 
21 #include "base/log/ace_trace.h"
22 #include "core/components/common/layout/constants.h"
23 #include "core/components/flex/flex_component.h"
24 #include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h"
25 
26 namespace OHOS::Ace::Framework {
27 
28 class JSFlex : public JSContainerBase {
29 public:
30     static void SetFillParent();
31     static void SetWrapContent();
32 
33     /**
34      * JS JustifyContent function definition:
35      * Main axis alignment format of the current row of the flex container. The options are as follows:
36      * flexstart: The project is at the beginning of the container.
37      * flexend: The project is at the end of the container.
38      * center: The project is located in the center of the container.
39      * spacebetween: The project is located in a container with a blank space between lines.
40      * spacearound: The item is located in a container with blank space before, between, and after each line.
41      */
42     static void SetJustifyContent(int32_t value);
43 
44     /**
45      * JS AlignItems function definition:
46      * Alignment format of the cross axis of the current row of the flex container. The options are as follows:
47      *	stretch: The elastic element is stretched to the same height or width as the container in the cross axis
48      *  direction.
49      * flexstart: The element is aligned to the start point of the cross axis.
50      * flexend: The element is aligned to the end of the cross axis.
51      * center: The element is centered on the cross axis.
52      */
53     static void SetAlignItems(int32_t value);
54 
55     static void SetAlignContent(int32_t value);
56 
57     static void SetWrap(bool value);
58 
59     static void JsHeight(const JSCallbackInfo& info);
60 
61     static void JsWidth(const JSCallbackInfo& info);
62 
63     static void JsSize(const JSCallbackInfo& info);
64 
65 private:
66     static void SetWidth(const JSRef<JSVal>& jsValue);
67 
68     static void SetHeight(const JSRef<JSVal>& jsValue);
69 }; // JSFlex class
70 
71 } // namespace OHOS::Ace::Framework
72 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_FLEX_H
73