1 /* 2 * Copyright (c) 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 JS_UI_APPEARANCE_H 17 #define JS_UI_APPEARANCE_H 18 19 #include <string> 20 21 #include "napi/native_api.h" 22 #include "napi/native_common.h" 23 #include "napi/native_node_api.h" 24 #include "ui_appearance_ability_client.h" 25 26 namespace OHOS { 27 namespace ArkUi::UiAppearance { 28 struct AsyncContext { 29 napi_async_work work = nullptr; 30 napi_deferred deferred = nullptr; 31 napi_ref callbackRef = nullptr; 32 int32_t jsSetArg = -1; 33 std::string errMsg; 34 UiAppearanceAbilityInterface::ErrCode status; 35 UiAppearanceAbilityInterface::DarkMode mode; 36 }; 37 38 class JsUiAppearance final { 39 public: 40 static void OnExecute(napi_env env, void* data); 41 static void OnComplete(napi_env env, napi_status status, void* data); 42 static napi_status CheckArgs(napi_env env, size_t argc, napi_value* argv); 43 static UiAppearanceAbilityInterface::DarkMode ConvertJsDarkMode2Enum(int32_t jsVal); 44 }; 45 46 napi_value JSSetDarkModeSync(napi_env env, napi_callback_info info); 47 napi_value JSGetDarkModeSync(napi_env env, napi_callback_info info); 48 } // namespace ArkUi::UiAppearance 49 } // namespace OHOS 50 #endif // JS_UI_APPEARANCE_H