1 /*
2 * Copyright (c) 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 "js_input_method_panel.h"
17
18 #include "global.h"
19 #include "js_runtime_utils.h"
20 #include "js_util.h"
21 #include "panel_info.h"
22
23 namespace OHOS {
24 namespace MiscServices {
Init(napi_env env,napi_value exports)25 napi_value JsInputMethodPanel::Init(napi_env env, napi_value exports)
26 {
27 napi_set_named_property(env, exports, "PanelType", GetJsPanelTypeProperty(env));
28 napi_set_named_property(env, exports, "PanelFlag", GetJsPanelFlagProperty(env));
29 return exports;
30 }
31
GetJsPanelTypeProperty(napi_env env)32 napi_value JsInputMethodPanel::GetJsPanelTypeProperty(napi_env env)
33 {
34 napi_value obj = nullptr;
35 napi_create_object(env, &obj);
36
37 auto ret = JsUtil::Object::WriteProperty(env, obj, "SOFT_KEYBOARD", static_cast<int32_t>(PanelType::SOFT_KEYBOARD));
38 ret = ret && JsUtil::Object::WriteProperty(env, obj, "STATUS_BAR", static_cast<int32_t>(PanelType::STATUS_BAR));
39 IMSA_HILOGI("init module inputMethod.Panel.PanelType ret: %{public}d", ret);
40 return obj;
41 }
42
GetJsPanelFlagProperty(napi_env env)43 napi_value JsInputMethodPanel::GetJsPanelFlagProperty(napi_env env)
44 {
45 napi_value obj = nullptr;
46 napi_create_object(env, &obj);
47
48 auto ret = JsUtil::Object::WriteProperty(env, obj, "FLAG_FIXED", static_cast<int32_t>(PanelFlag::FLG_FIXED));
49 ret = ret
50 && JsUtil::Object::WriteProperty(env, obj, "FLAG_FLOATING", static_cast<int32_t>(PanelFlag::FLG_FLOATING));
51 ret = ret
52 && JsUtil::Object::WriteProperty(
53 env, obj, "FLAG_CANDIDATE", static_cast<int32_t>(PanelFlag::FLG_CANDIDATE_COLUMN));
54 IMSA_HILOGI("init module inputMethod.Panel.PanelFlag ret: %{public}d", ret);
55 return obj;
56 }
57 } // namespace MiscServices
58 } // namespace OHOS