@amazon-devices/expo-system-ui 2.0.9000000002 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/build/ExpoSystemUI.kepler.js +2 -2
  2. package/build/ExpoSystemUI.kepler.js.map +1 -1
  3. package/lib/aarch64-release/libexpo-system-ui-3.so +0 -0
  4. package/lib/armv7-release/libexpo-system-ui-3.so +0 -0
  5. package/lib/x86_64-release/libexpo-system-ui-3.so +0 -0
  6. package/package.json +1 -1
  7. package/react-native.config.js +5 -4
  8. package/.eslintrc.js +0 -2
  9. package/CHANGELOG.md +0 -116
  10. package/CMakeLists.txt +0 -46
  11. package/THIRD_PARTY_NOTICES.txt +0 -4
  12. package/android/build.gradle +0 -112
  13. package/android/src/main/AndroidManifest.xml +0 -2
  14. package/android/src/main/java/expo/modules/systemui/SystemUIModule.kt +0 -74
  15. package/android/src/main/java/expo/modules/systemui/SystemUIPackage.kt +0 -11
  16. package/android/src/main/java/expo/modules/systemui/SystemUIReactActivityLifecycleListener.kt +0 -18
  17. package/android/src/main/java/expo/modules/systemui/singletons/SystemUI.kt +0 -36
  18. package/android/src/main/res/values/strings.xml +0 -4
  19. package/app.plugin.js +0 -1
  20. package/expo-module.config.json +0 -10
  21. package/ios/ExpoSystemUI/ExpoSystemUIModule.swift +0 -72
  22. package/ios/ExpoSystemUI.podspec +0 -31
  23. package/kepler/ExpoSystemUI.cpp +0 -47
  24. package/kepler/ExpoSystemUI.h +0 -29
  25. package/kepler/ExpoSystemUIImpl.cpp +0 -39
  26. package/kepler/ExpoSystemUIImpl.h +0 -29
  27. package/kepler/ExpoSystemUITurboModule.cpp +0 -57
  28. package/kepler/ExpoSystemUITurboModule.h +0 -32
  29. package/kepler/KeplerInit.cpp +0 -28
  30. package/kepler/test/ExpoSystemUI.cpp +0 -154
  31. package/kepler-compatibility.json +0 -8
  32. package/plugin/babel.config.js +0 -1
  33. package/plugin/build/withAndroidRootViewBackgroundColor.d.ts +0 -6
  34. package/plugin/build/withAndroidRootViewBackgroundColor.js +0 -40
  35. package/plugin/build/withAndroidUserInterfaceStyle.d.ts +0 -8
  36. package/plugin/build/withAndroidUserInterfaceStyle.js +0 -42
  37. package/plugin/build/withIosRootViewBackgroundColor.d.ts +0 -5
  38. package/plugin/build/withIosRootViewBackgroundColor.js +0 -41
  39. package/plugin/build/withIosUserInterfaceStyle.d.ts +0 -5
  40. package/plugin/build/withIosUserInterfaceStyle.js +0 -38
  41. package/plugin/build/withSystemUI.d.ts +0 -3
  42. package/plugin/build/withSystemUI.js +0 -17
  43. package/plugin/src/withAndroidRootViewBackgroundColor.ts +0 -47
  44. package/plugin/src/withAndroidUserInterfaceStyle.ts +0 -53
  45. package/plugin/src/withIosRootViewBackgroundColor.ts +0 -41
  46. package/plugin/src/withIosUserInterfaceStyle.ts +0 -47
  47. package/plugin/src/withSystemUI.ts +0 -19
  48. package/plugin/tsconfig.json +0 -9
  49. package/src/ExpoSystemUI.kepler.ts +0 -27
  50. package/src/ExpoSystemUI.ts +0 -2
  51. package/src/ExpoSystemUI.web.ts +0 -21
  52. package/src/SystemUI.ts +0 -35
  53. package/tsconfig.json +0 -9
@@ -1,29 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * PROPRIETARY/CONFIDENTIAL
5
- *
6
- * Use is subject to license terms.
7
- */
8
-
9
- #include <KeplerScript/components/KeplerViewComponent.h>
10
- #include <KeplerScript/modules/KeplerTurboModule.h>
11
- #include <Volta/graphics/Color.h>
12
-
13
- #include "ExpoSystemUIImpl.h"
14
- #include "IKeplerUIManager.h"
15
-
16
- class KEPLERSCRIPT_EXPORT ExpoSystemUI {
17
- public:
18
- explicit ExpoSystemUI(volta::react::IKeplerUIManager&);
19
-
20
- volta::react::Promise getBackgroundColorAsync();
21
- volta::react::Promise resetBackgroundColorAsync();
22
- volta::react::Promise setBackgroundColorAsync(int64_t color);
23
-
24
- private:
25
- #ifdef UNIT_TEST
26
- public:
27
- #endif
28
- ExpoSystemUIImpl syncDelegate;
29
- };
@@ -1,39 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * PROPRIETARY/CONFIDENTIAL
5
- *
6
- * Use is subject to license terms.
7
- */
8
-
9
- #include "ExpoSystemUIImpl.h"
10
-
11
- #include <KeplerScript/logger/KPLog.h>
12
- #include <Volta/graphics/Color.h>
13
-
14
- #include <iomanip>
15
- #include <sstream>
16
-
17
- ExpoSystemUIImpl::ExpoSystemUIImpl(volta::react::IKeplerUIManager& uiManager) {
18
- view = uiManager.getComponentViewByTag(1);
19
- if (view == nullptr) {
20
- throw std::runtime_error("Failing getting view instance (view can't be nullptr)");
21
- }
22
- systemBackgroundColor = view->getBackgroundColor();
23
- }
24
-
25
- std::string ExpoSystemUIImpl::getBackgroundColor() {
26
- volta::graphics::Color color = view->getBackgroundColor();
27
- std::ostringstream rgbColor;
28
- rgbColor << "#" << std::setfill('0') << std::hex << std::setw(2) << color.r() << std::setw(2) << color.g()
29
- << std::setw(2) << color.b();
30
- return rgbColor.str();
31
- }
32
-
33
- void ExpoSystemUIImpl::resetBackgroundColor() {
34
- view->setBackgroundColor(systemBackgroundColor.argb());
35
- }
36
-
37
- void ExpoSystemUIImpl::setBackgroundColor(int64_t color) {
38
- view->setBackgroundColor(color);
39
- }
@@ -1,29 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * PROPRIETARY/CONFIDENTIAL
5
- *
6
- * Use is subject to license terms.
7
- */
8
-
9
- #include <KeplerScript/components/KeplerViewComponent.h>
10
- #include <KeplerScript/modules/KeplerTurboModule.h>
11
- #include <Volta/graphics/Color.h>
12
-
13
- #include "IKeplerUIManager.h"
14
-
15
- class KEPLERSCRIPT_EXPORT ExpoSystemUIImpl {
16
- public:
17
- explicit ExpoSystemUIImpl(volta::react::IKeplerUIManager&);
18
-
19
- std::string getBackgroundColor();
20
- void resetBackgroundColor();
21
- void setBackgroundColor(int64_t color);
22
-
23
- private:
24
- #ifdef UNIT_TEST
25
- public:
26
- #endif
27
- std::shared_ptr<volta::react::KeplerViewComponent> view;
28
- volta::graphics::Color systemBackgroundColor{0, 0, 0, 0};
29
- };
@@ -1,57 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * PROPRIETARY/CONFIDENTIAL
5
- *
6
- * Use is subject to license terms.
7
- */
8
-
9
- #include "ExpoSystemUITurboModule.h"
10
-
11
- #include <KeplerScript/logger/KPLog.h>
12
- #include <Volta/graphics/Color.h>
13
-
14
- #include <memory>
15
-
16
- #include "ExpoUIManager.h"
17
-
18
- ExpoSystemUITurboModule::ExpoSystemUITurboModule() : volta::react::KeplerTurboModule("ExpoSystemUI") {
19
- volta::react::KPLog.debug("ExpoSystemUI constructor {}", name());
20
- }
21
-
22
- void ExpoSystemUITurboModule::aggregateMethods(
23
- volta::react::MethodAggregator<volta::react::KeplerTurboModule>& methodAggregator) const noexcept {
24
- volta::react::KPLog.debug("ExpoSystemUITurboModule::aggregateMethods");
25
-
26
- methodAggregator.addMethod("getBackgroundColorAsync", 0, &ExpoSystemUITurboModule::getBackgroundColorAsync);
27
- methodAggregator.addMethod("resetBackgroundColorAsync", 0, &ExpoSystemUITurboModule::resetBackgroundColorAsync);
28
- methodAggregator.addMethod("setBackgroundColorAsync", 1, &ExpoSystemUITurboModule::setBackgroundColorAsync);
29
- }
30
-
31
- volta::react::Promise ExpoSystemUITurboModule::getBackgroundColorAsync() {
32
- volta::react::KPLog.debug("ExpoSystemUI::getBackgroundColorAsync");
33
- ensureSystemUIInitialized();
34
- return lazyDelegate->getBackgroundColorAsync();
35
- }
36
-
37
- volta::react::Promise ExpoSystemUITurboModule::resetBackgroundColorAsync() {
38
- volta::react::KPLog.debug("ExpoSystemUI::resetBackgroundColorAsync");
39
- ensureSystemUIInitialized();
40
- return lazyDelegate->resetBackgroundColorAsync();
41
- }
42
-
43
- volta::react::Promise ExpoSystemUITurboModule::setBackgroundColorAsync(int64_t color) {
44
- volta::react::KPLog.debug("ExpoSystemUI::setBackgroundColorAsync, color {}", color);
45
- ensureSystemUIInitialized();
46
- return lazyDelegate->setBackgroundColorAsync(color);
47
- }
48
-
49
- void ExpoSystemUITurboModule::ensureSystemUIInitialized() {
50
- volta::react::KPLog.debug("ExpoSystemUI::ensureSystemUIInitialized");
51
- if (lazyDelegate) {
52
- return;
53
- }
54
-
55
- volta::react::ExpoUIManager expoUIManager;
56
- lazyDelegate = std::make_unique<ExpoSystemUI>(expoUIManager);
57
- }
@@ -1,32 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * PROPRIETARY/CONFIDENTIAL
5
- *
6
- * Use is subject to license terms.
7
- */
8
-
9
- #include <KeplerScript/components/KeplerViewComponent.h>
10
- #include <KeplerScript/modules/KeplerTurboModule.h>
11
- #include <Volta/graphics/Color.h>
12
-
13
- #include "ExpoSystemUI.h"
14
- #include "ExpoUIManager.h"
15
-
16
- class KEPLERSCRIPT_EXPORT ExpoSystemUITurboModule : public volta::react::KeplerTurboModule {
17
- public:
18
- ExpoSystemUITurboModule();
19
-
20
- protected:
21
- void aggregateMethods(
22
- volta::react::MethodAggregator<volta::react::KeplerTurboModule>& methodAggregator) const noexcept override;
23
-
24
- volta::react::Promise getBackgroundColorAsync();
25
- volta::react::Promise resetBackgroundColorAsync();
26
- volta::react::Promise setBackgroundColorAsync(int64_t color);
27
-
28
- private:
29
- void ensureSystemUIInitialized();
30
-
31
- std::unique_ptr<ExpoSystemUI> lazyDelegate;
32
- };
@@ -1,28 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * PROPRIETARY/CONFIDENTIAL
5
- *
6
- * Use is subject to license terms.
7
- */
8
-
9
- #include <KeplerScript/logger/KPLog.h>
10
- #include <KeplerScript/utils/autolink/KeplerAutoLinkInfo.h>
11
- #include <keplerui-072/keplerscript-export.h>
12
-
13
- #include "ExpoSystemUITurboModule.h"
14
- #include "RegisterModule.h"
15
-
16
- extern "C" {
17
- KEPLERSCRIPT_EXPORT void keplerAutoLinkInitV1(const kepler::autolink::v1::KeplerAutoLinkInfo* autoLinkInfo) noexcept {
18
- volta::react::KPLog.debug("keplerAutoLinkInitV1 for ExpoSystemUI");
19
-
20
- REGISTER_MODULE(autoLinkInfo, ExpoSystemUITurboModule, "ExpoSystemUI");
21
-
22
- volta::react::KPLog.debug("after registering module");
23
- }
24
- }
25
-
26
- int main() {
27
- return 0;
28
- }
@@ -1,154 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- *
4
- * PROPRIETARY/CONFIDENTIAL
5
- *
6
- * Use is subject to license terms.
7
- */
8
-
9
- #include <JsonContainer/JsonContainer.h>
10
- #include <KeplerScript/components/KeplerViewComponent.h>
11
- #include <KeplerScript/modules/KeplerTurboModule.h>
12
- #include <KeplerScript/modules/Promise.h>
13
- #include <KeplerScript/private/modules/CallbackParameterTypes.h>
14
- #include <gmock/gmock-actions.h>
15
- #include <gmock/gmock.h>
16
- #include <gtest/gtest.h>
17
-
18
- #include <exception>
19
- #include <memory>
20
- #include <variant>
21
-
22
- #include "../ExpoSystemUITurboModule.h"
23
- #include "JSObjectsConversion.h"
24
- #include "catch.hpp"
25
- #include "gtest/gtest.h"
26
-
27
- namespace volta::react {
28
-
29
- using namespace std::string_literals;
30
- using CallbackArgs = std::vector<std::variant<CALLBACK_PARAM_SUPPORTED_TYPES>>;
31
-
32
- namespace {
33
-
34
- class MockKeplerUIManager : public IKeplerUIManager {
35
- public:
36
- MOCK_METHOD((std::shared_ptr<KeplerViewComponent>), getComponentViewByTag, (int32_t), (override));
37
- MOCK_METHOD((bool), isOnUIThread, (), (override));
38
- MOCK_METHOD((void), executeOnUIThread, (const std::function<void()>&), (override));
39
- };
40
-
41
- // TODO: uncomment and use once Callback and Promise become testable
42
- // void reject(CallbackArgs& vargs) {
43
- // std::string errorMsg;
44
- // try {
45
- // REQUIRE(vargs.size() == 1);
46
- // auto& jsonContainer = std::get<utils::json::JsonContainer>(vargs.front());
47
- // auto jsonMap = ExpoUtils::convertJsonContainerToNativeJSObject(jsonContainer);
48
- // errorMsg = std::get<std::string>(jsonMap.at("message"));
49
- // } catch (std::exception& e) {
50
- // errorMsg = e.what();
51
- // }
52
- // FAIL("Promise invoked rejectedCallback: "s + errorMsg);
53
- // }
54
-
55
- // void evalPromise(const Promise& promise, std::function<void(CallbackArgs&)>&& resolve) {
56
- // auto pAction = std::make_shared<Promise>(Callback(std::move(resolve)), Callback(reject));
57
- // promise.promiseOperation_(pAction);
58
- // }
59
-
60
- // auto getBackgroundColorSync(ExpoSystemUI& systemUI) {
61
- // auto pColor = systemUI.getBackgroundColorAsync();
62
- // std::string color;
63
- // auto resolve = [&color](auto& vargs) {
64
- // REQUIRE(vargs.size() == 1);
65
- // color = std::get<std::string>(vargs.front());
66
- // };
67
-
68
- // evalPromise(pColor, resolve);
69
- // return color;
70
- // }
71
- using testing::Ne;
72
- using testing::Return;
73
-
74
- ExpoSystemUIImpl createModule(const std::shared_ptr<KeplerViewComponent>& mockRootView) {
75
- MockKeplerUIManager mock;
76
- EXPECT_CALL(mock, getComponentViewByTag(Ne(1))).Times(0);
77
- EXPECT_CALL(mock, getComponentViewByTag(1)).WillRepeatedly(Return(mockRootView));
78
- return ExpoSystemUIImpl(mock);
79
- }
80
-
81
- } // namespace
82
-
83
- TEST_CASE("ExpoSystemUI fails to initialise") {
84
- MockKeplerUIManager mock;
85
- EXPECT_CALL(mock, getComponentViewByTag(Ne(1))).Times(0);
86
- EXPECT_CALL(mock, getComponentViewByTag(1)).WillOnce(Return(nullptr));
87
- REQUIRE_THROWS(ExpoSystemUI(mock));
88
- }
89
-
90
- TEST_CASE("ExpoSystemUI") {
91
- // setup
92
- constexpr int iBlack = static_cast<int>(0xff000000);
93
- constexpr int iWhite = static_cast<int>(0xffffffff);
94
- const auto sBlack = "#000000"s;
95
- const auto sWhite = "#ffffff"s; // outputs are case-sensitive
96
-
97
- auto mockRootView = std::make_shared<KeplerViewComponent>();
98
- mockRootView->setBackgroundColor(iBlack);
99
- auto expoSystemUI = createModule(mockRootView);
100
-
101
- SECTION("getBackgroundColorAsync") {
102
- REQUIRE(mockRootView->getBackgroundColor() == volta::graphics::Color::Black);
103
- REQUIRE(expoSystemUI.getBackgroundColor() == sBlack);
104
- }
105
-
106
- SECTION("setBackgroundColorAsync") {
107
- REQUIRE(mockRootView->getBackgroundColor() == volta::graphics::Color::Black);
108
- REQUIRE(expoSystemUI.getBackgroundColor() == sBlack);
109
-
110
- expoSystemUI.setBackgroundColor(iWhite);
111
-
112
- REQUIRE(mockRootView->getBackgroundColor() == volta::graphics::Color::White);
113
- REQUIRE(expoSystemUI.getBackgroundColor() == sWhite);
114
- }
115
-
116
- SECTION("resetBackgroundColorAsync") {
117
- REQUIRE(mockRootView->getBackgroundColor() == volta::graphics::Color::Black);
118
- REQUIRE(expoSystemUI.getBackgroundColor() == sBlack);
119
-
120
- mockRootView->setBackgroundColor(iWhite);
121
-
122
- REQUIRE(mockRootView->getBackgroundColor() == volta::graphics::Color::White);
123
- REQUIRE(expoSystemUI.getBackgroundColor() == sWhite);
124
-
125
- expoSystemUI.resetBackgroundColor();
126
-
127
- REQUIRE(mockRootView->getBackgroundColor() == volta::graphics::Color::Black);
128
- REQUIRE(expoSystemUI.getBackgroundColor() == sBlack);
129
- }
130
- }
131
-
132
- TEST_CASE("ExpoSystemUITurboModule") {
133
- ExpoSystemUITurboModule tmodule;
134
-
135
- SECTION("aggregateMethods") {
136
- std::weak_ptr<facebook::react::Instance> instance;
137
- REQUIRE(tmodule.methodContainerMap_.empty());
138
-
139
- tmodule.triggerMethodAggregation(*tmodule.jsQueue_, instance);
140
-
141
- auto registeredMethods = {
142
- "getBackgroundColorAsync",
143
- "resetBackgroundColorAsync",
144
- "setBackgroundColorAsync",
145
- };
146
- for (const auto& methodName : registeredMethods) {
147
- REQUIRE(tmodule.methodContainerMap_.find(methodName) != tmodule.methodContainerMap_.end());
148
- }
149
-
150
- REQUIRE(tmodule.methodContainerMap_.size() ==
151
- registeredMethods.size() + 2); // "addListener" and "removeListeners" are added by default
152
- }
153
- }
154
- } // namespace volta::react
@@ -1,8 +0,0 @@
1
- {
2
- "versions": {
3
- "2.0.0": "/com.amazon.kepler.expo_system_ui_2@IExpoSystemUI_0",
4
- "2.0.9000000000": "/com.amazon.kepler.expo_system_ui_2@IExpoSystemUI_0",
5
- "2.0.9000000001": "/com.amazon.kepler.expo_system_ui_2@IExpoSystemUI_0",
6
- "2.0.9000000002": "/com.amazon.kepler.expo_system_ui_2@IExpoSystemUI_0"
7
- }
8
- }
@@ -1 +0,0 @@
1
- module.exports = require('expo-module-scripts/babel.config.plugin');
@@ -1,6 +0,0 @@
1
- import { ExpoConfig } from 'expo/config';
2
- import { ConfigPlugin } from 'expo/config-plugins';
3
- export declare const withAndroidRootViewBackgroundColor: ConfigPlugin;
4
- export declare const withRootViewBackgroundColorColors: ConfigPlugin;
5
- export declare const withRootViewBackgroundColorStyles: ConfigPlugin;
6
- export declare function getRootViewBackgroundColor(config: Pick<ExpoConfig, 'android' | 'backgroundColor'>): string | null;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withRootViewBackgroundColorStyles = exports.withRootViewBackgroundColorColors = exports.withAndroidRootViewBackgroundColor = void 0;
4
- exports.getRootViewBackgroundColor = getRootViewBackgroundColor;
5
- const config_plugins_1 = require("expo/config-plugins");
6
- const { assignColorValue } = config_plugins_1.AndroidConfig.Colors;
7
- const { assignStylesValue, getAppThemeLightNoActionBarGroup } = config_plugins_1.AndroidConfig.Styles;
8
- const ANDROID_WINDOW_BACKGROUND = 'android:windowBackground';
9
- const WINDOW_BACKGROUND_COLOR = 'activityBackground';
10
- const withAndroidRootViewBackgroundColor = (config) => {
11
- config = (0, exports.withRootViewBackgroundColorColors)(config);
12
- config = (0, exports.withRootViewBackgroundColorStyles)(config);
13
- return config;
14
- };
15
- exports.withAndroidRootViewBackgroundColor = withAndroidRootViewBackgroundColor;
16
- const withRootViewBackgroundColorColors = (config) => {
17
- return (0, config_plugins_1.withAndroidColors)(config, async (config) => {
18
- config.modResults = assignColorValue(config.modResults, {
19
- value: getRootViewBackgroundColor(config),
20
- name: WINDOW_BACKGROUND_COLOR,
21
- });
22
- return config;
23
- });
24
- };
25
- exports.withRootViewBackgroundColorColors = withRootViewBackgroundColorColors;
26
- const withRootViewBackgroundColorStyles = (config) => {
27
- return (0, config_plugins_1.withAndroidStyles)(config, async (config) => {
28
- config.modResults = assignStylesValue(config.modResults, {
29
- add: !!getRootViewBackgroundColor(config),
30
- parent: getAppThemeLightNoActionBarGroup(),
31
- name: ANDROID_WINDOW_BACKGROUND,
32
- value: `@color/${WINDOW_BACKGROUND_COLOR}`,
33
- });
34
- return config;
35
- });
36
- };
37
- exports.withRootViewBackgroundColorStyles = withRootViewBackgroundColorStyles;
38
- function getRootViewBackgroundColor(config) {
39
- return config.android?.backgroundColor || config.backgroundColor || null;
40
- }
@@ -1,8 +0,0 @@
1
- import { ExpoConfig } from 'expo/config';
2
- import { AndroidConfig, ConfigPlugin } from 'expo/config-plugins';
3
- export type Props = {
4
- userInterfaceStyle?: ExpoConfig['userInterfaceStyle'];
5
- };
6
- export declare const withAndroidUserInterfaceStyle: ConfigPlugin<void>;
7
- export declare function resolveProps(config: Pick<ExpoConfig, 'userInterfaceStyle' | 'android'>): Props;
8
- export declare function setStrings(strings: AndroidConfig.Resources.ResourceXML, { userInterfaceStyle }: Props): AndroidConfig.Resources.ResourceXML;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withAndroidUserInterfaceStyle = void 0;
7
- exports.resolveProps = resolveProps;
8
- exports.setStrings = setStrings;
9
- const assert_1 = __importDefault(require("assert"));
10
- const config_plugins_1 = require("expo/config-plugins");
11
- // strings.xml keys, this should not change.
12
- const USER_INTERFACE_STYLE_KEY = 'expo_system_ui_user_interface_style';
13
- const withAndroidUserInterfaceStyle = (config) => {
14
- return (0, config_plugins_1.withStringsXml)(config, (config) => {
15
- config.modResults = setStrings(config.modResults, resolveProps(config));
16
- return config;
17
- });
18
- };
19
- exports.withAndroidUserInterfaceStyle = withAndroidUserInterfaceStyle;
20
- function resolveProps(config) {
21
- const userInterfaceStyle = config.android?.userInterfaceStyle ?? config.userInterfaceStyle;
22
- (0, assert_1.default)(!userInterfaceStyle || ['automatic', 'light', 'dark'].includes(userInterfaceStyle), `expo-system-ui: Invalid userInterfaceStyle: "${userInterfaceStyle}"`);
23
- return { userInterfaceStyle };
24
- }
25
- function setStrings(strings, { userInterfaceStyle }) {
26
- const pairs = [[USER_INTERFACE_STYLE_KEY, userInterfaceStyle]];
27
- const stringItems = [];
28
- for (const [key, value] of pairs) {
29
- if (value == null) {
30
- // Since we're using custom strings, we can remove them for convenience between prebuilds.
31
- strings = config_plugins_1.AndroidConfig.Strings.removeStringItem(key, strings);
32
- }
33
- else {
34
- stringItems.push(config_plugins_1.AndroidConfig.Resources.buildResourceItem({
35
- name: key,
36
- value: String(value),
37
- translatable: false,
38
- }));
39
- }
40
- }
41
- return config_plugins_1.AndroidConfig.Strings.setStringItem(stringItems, strings);
42
- }
@@ -1,5 +0,0 @@
1
- import { ExpoConfig } from 'expo/config';
2
- import { ConfigPlugin, InfoPlist } from 'expo/config-plugins';
3
- export declare const withIosRootViewBackgroundColor: ConfigPlugin;
4
- export declare function setRootViewBackgroundColor(config: Pick<ExpoConfig, 'backgroundColor' | 'ios'>, infoPlist: InfoPlist): InfoPlist;
5
- export declare function getRootViewBackgroundColor(config: Pick<ExpoConfig, 'ios' | 'backgroundColor'>): string | null;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withIosRootViewBackgroundColor = void 0;
7
- exports.setRootViewBackgroundColor = setRootViewBackgroundColor;
8
- exports.getRootViewBackgroundColor = getRootViewBackgroundColor;
9
- // @ts-ignore: uses flow
10
- const normalize_color_1 = __importDefault(require("@react-native/normalize-color"));
11
- const config_plugins_1 = require("expo/config-plugins");
12
- // Maps to the template AppDelegate.m
13
- const BACKGROUND_COLOR_KEY = 'RCTRootViewBackgroundColor';
14
- const debug = require('debug')('expo:system-ui:plugin:ios');
15
- const withIosRootViewBackgroundColor = (config) => {
16
- config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
17
- config.modResults = setRootViewBackgroundColor(config, config.modResults);
18
- return config;
19
- });
20
- return config;
21
- };
22
- exports.withIosRootViewBackgroundColor = withIosRootViewBackgroundColor;
23
- function setRootViewBackgroundColor(config, infoPlist) {
24
- const backgroundColor = getRootViewBackgroundColor(config);
25
- if (!backgroundColor) {
26
- delete infoPlist[BACKGROUND_COLOR_KEY];
27
- }
28
- else {
29
- let color = (0, normalize_color_1.default)(backgroundColor);
30
- if (!color) {
31
- throw new Error('Invalid background color on iOS');
32
- }
33
- color = ((color << 24) | (color >>> 8)) >>> 0;
34
- infoPlist[BACKGROUND_COLOR_KEY] = color;
35
- debug(`Convert color: ${backgroundColor} -> ${color}`);
36
- }
37
- return infoPlist;
38
- }
39
- function getRootViewBackgroundColor(config) {
40
- return config.ios?.backgroundColor || config.backgroundColor || null;
41
- }
@@ -1,5 +0,0 @@
1
- import { ExpoConfig } from 'expo/config';
2
- import { InfoPlist, ConfigPlugin } from 'expo/config-plugins';
3
- export declare const withIosUserInterfaceStyle: ConfigPlugin;
4
- export declare function getUserInterfaceStyle(config: Pick<ExpoConfig, 'ios' | 'userInterfaceStyle'>): string;
5
- export declare function setUserInterfaceStyle(config: Pick<ExpoConfig, 'ios' | 'userInterfaceStyle'>, { UIUserInterfaceStyle, ...infoPlist }: InfoPlist): InfoPlist;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withIosUserInterfaceStyle = void 0;
4
- exports.getUserInterfaceStyle = getUserInterfaceStyle;
5
- exports.setUserInterfaceStyle = setUserInterfaceStyle;
6
- const config_plugins_1 = require("expo/config-plugins");
7
- const withIosUserInterfaceStyle = (config) => {
8
- return (0, config_plugins_1.withInfoPlist)(config, (config) => {
9
- config.modResults = setUserInterfaceStyle(config, config.modResults);
10
- return config;
11
- });
12
- };
13
- exports.withIosUserInterfaceStyle = withIosUserInterfaceStyle;
14
- function getUserInterfaceStyle(config) {
15
- return config.ios?.userInterfaceStyle ?? config.userInterfaceStyle ?? 'light';
16
- }
17
- function setUserInterfaceStyle(config, { UIUserInterfaceStyle, ...infoPlist }) {
18
- const userInterfaceStyle = getUserInterfaceStyle(config);
19
- const style = mapUserInterfaceStyleForInfoPlist(userInterfaceStyle);
20
- if (!style) {
21
- return infoPlist;
22
- }
23
- return {
24
- ...infoPlist,
25
- UIUserInterfaceStyle: style,
26
- };
27
- }
28
- function mapUserInterfaceStyleForInfoPlist(userInterfaceStyle) {
29
- switch (userInterfaceStyle) {
30
- case 'light':
31
- return 'Light';
32
- case 'dark':
33
- return 'Dark';
34
- case 'automatic':
35
- return 'Automatic';
36
- }
37
- return null;
38
- }
@@ -1,3 +0,0 @@
1
- import { ConfigPlugin } from 'expo/config-plugins';
2
- declare const _default: ConfigPlugin<void>;
3
- export default _default;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config_plugins_1 = require("expo/config-plugins");
4
- const withAndroidRootViewBackgroundColor_1 = require("./withAndroidRootViewBackgroundColor");
5
- const withAndroidUserInterfaceStyle_1 = require("./withAndroidUserInterfaceStyle");
6
- const withIosRootViewBackgroundColor_1 = require("./withIosRootViewBackgroundColor");
7
- const withIosUserInterfaceStyle_1 = require("./withIosUserInterfaceStyle");
8
- const pkg = require('expo-system-ui/package.json');
9
- const withSystemUI = (config) => {
10
- return (0, config_plugins_1.withPlugins)(config, [
11
- withAndroidRootViewBackgroundColor_1.withAndroidRootViewBackgroundColor,
12
- withIosRootViewBackgroundColor_1.withIosRootViewBackgroundColor,
13
- withAndroidUserInterfaceStyle_1.withAndroidUserInterfaceStyle,
14
- withIosUserInterfaceStyle_1.withIosUserInterfaceStyle,
15
- ]);
16
- };
17
- exports.default = (0, config_plugins_1.createRunOncePlugin)(withSystemUI, pkg.name, pkg.version);
@@ -1,47 +0,0 @@
1
- import { ExpoConfig } from 'expo/config';
2
- import {
3
- AndroidConfig,
4
- ConfigPlugin,
5
- withAndroidColors,
6
- withAndroidStyles,
7
- } from 'expo/config-plugins';
8
-
9
- const { assignColorValue } = AndroidConfig.Colors;
10
- const { assignStylesValue, getAppThemeLightNoActionBarGroup } = AndroidConfig.Styles;
11
-
12
- const ANDROID_WINDOW_BACKGROUND = 'android:windowBackground';
13
- const WINDOW_BACKGROUND_COLOR = 'activityBackground';
14
-
15
- export const withAndroidRootViewBackgroundColor: ConfigPlugin = (config) => {
16
- config = withRootViewBackgroundColorColors(config);
17
- config = withRootViewBackgroundColorStyles(config);
18
- return config;
19
- };
20
-
21
- export const withRootViewBackgroundColorColors: ConfigPlugin = (config) => {
22
- return withAndroidColors(config, async (config) => {
23
- config.modResults = assignColorValue(config.modResults, {
24
- value: getRootViewBackgroundColor(config),
25
- name: WINDOW_BACKGROUND_COLOR,
26
- });
27
- return config;
28
- });
29
- };
30
-
31
- export const withRootViewBackgroundColorStyles: ConfigPlugin = (config) => {
32
- return withAndroidStyles(config, async (config) => {
33
- config.modResults = assignStylesValue(config.modResults, {
34
- add: !!getRootViewBackgroundColor(config),
35
- parent: getAppThemeLightNoActionBarGroup(),
36
- name: ANDROID_WINDOW_BACKGROUND,
37
- value: `@color/${WINDOW_BACKGROUND_COLOR}`,
38
- });
39
- return config;
40
- });
41
- };
42
-
43
- export function getRootViewBackgroundColor(
44
- config: Pick<ExpoConfig, 'android' | 'backgroundColor'>
45
- ) {
46
- return config.android?.backgroundColor || config.backgroundColor || null;
47
- }