@onekeyfe/react-native-device-utils 6.7.0-alpha.385 → 6.7.0-alpha.388
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.
- package/android/src/main/java/com/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtils.kt +29 -0
- package/ios/DualScreenDetector.swift +158 -0
- package/ios/MainMenuController.swift +170 -0
- package/ios/ReactNativeDeviceUtils.swift +29 -4
- package/ios/WindowControlsInsetsObserver.swift +149 -0
- package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts +46 -0
- package/nitrogen/generated/android/c++/JFunc_void_MainMenuCommand.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_WindowControlsInsets.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.cpp +45 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.hpp +6 -0
- package/nitrogen/generated/android/c++/JMainMenuCommand.hpp +61 -0
- package/nitrogen/generated/android/c++/JMainMenuConfig.hpp +90 -0
- package/nitrogen/generated/android/c++/JMainMenuLink.hpp +61 -0
- package/nitrogen/generated/android/c++/JWindowControlsInsets.hpp +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/Func_void_MainMenuCommand.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/Func_void_WindowControlsInsets.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/HybridReactNativeDeviceUtilsSpec.kt +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/MainMenuCommand.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/MainMenuConfig.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/MainMenuLink.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/WindowControlsInsets.kt +66 -0
- package/nitrogen/generated/android/reactnativedeviceutilsOnLoad.cpp +4 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.cpp +16 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.hpp +73 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp +12 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeDeviceUtilsSpecSwift.hpp +55 -1
- package/nitrogen/generated/ios/swift/Func_void_MainMenuCommand.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_WindowControlsInsets.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec.swift +6 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec_cxx.swift +79 -0
- package/nitrogen/generated/ios/swift/MainMenuCommand.swift +44 -0
- package/nitrogen/generated/ios/swift/MainMenuConfig.swift +50 -0
- package/nitrogen/generated/ios/swift/MainMenuLink.swift +34 -0
- package/nitrogen/generated/ios/swift/WindowControlsInsets.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.cpp +6 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.hpp +15 -0
- package/nitrogen/generated/shared/c++/MainMenuCommand.hpp +80 -0
- package/nitrogen/generated/shared/c++/MainMenuConfig.hpp +98 -0
- package/nitrogen/generated/shared/c++/MainMenuLink.hpp +87 -0
- package/nitrogen/generated/shared/c++/WindowControlsInsets.hpp +95 -0
- package/package.json +1 -1
- package/src/ReactNativeDeviceUtils.nitro.ts +54 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// WindowControlsInsets.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (WindowControlsInsets).
|
|
39
|
+
*/
|
|
40
|
+
struct WindowControlsInsets final {
|
|
41
|
+
public:
|
|
42
|
+
double top SWIFT_PRIVATE;
|
|
43
|
+
double left SWIFT_PRIVATE;
|
|
44
|
+
double bottom SWIFT_PRIVATE;
|
|
45
|
+
double right SWIFT_PRIVATE;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
WindowControlsInsets() = default;
|
|
49
|
+
explicit WindowControlsInsets(double top, double left, double bottom, double right): top(top), left(left), bottom(bottom), right(right) {}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
friend bool operator==(const WindowControlsInsets& lhs, const WindowControlsInsets& rhs) = default;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
56
|
+
|
|
57
|
+
namespace margelo::nitro {
|
|
58
|
+
|
|
59
|
+
// C++ WindowControlsInsets <> JS WindowControlsInsets (object)
|
|
60
|
+
template <>
|
|
61
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::WindowControlsInsets> final {
|
|
62
|
+
static inline margelo::nitro::reactnativedeviceutils::WindowControlsInsets fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
63
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
64
|
+
return margelo::nitro::reactnativedeviceutils::WindowControlsInsets(
|
|
65
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "top"))),
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "left"))),
|
|
67
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bottom"))),
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "right")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativedeviceutils::WindowControlsInsets& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "top"), JSIConverter<double>::toJSI(runtime, arg.top));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "left"), JSIConverter<double>::toJSI(runtime, arg.left));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "bottom"), JSIConverter<double>::toJSI(runtime, arg.bottom));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "right"), JSIConverter<double>::toJSI(runtime, arg.right));
|
|
77
|
+
return obj;
|
|
78
|
+
}
|
|
79
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
80
|
+
if (!value.isObject()) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
jsi::Object obj = value.getObject(runtime);
|
|
84
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "top")))) return false;
|
|
88
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "left")))) return false;
|
|
89
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bottom")))) return false;
|
|
90
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "right")))) return false;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-device-utils",
|
|
3
|
-
"version": "6.7.0-alpha.
|
|
3
|
+
"version": "6.7.0-alpha.388",
|
|
4
4
|
"description": "Native device, launch, system appearance and boot recovery utilities for OneKey",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -26,6 +26,39 @@ export interface DualScreenInfoRect {
|
|
|
26
26
|
height: number;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Extra room, in points beyond the safe area, that content near the window
|
|
31
|
+
* corners must leave for system window controls (the iPadOS window controls in
|
|
32
|
+
* the top-leading corner, for example). All zero when no controls are shown.
|
|
33
|
+
*/
|
|
34
|
+
export interface WindowControlsInsets {
|
|
35
|
+
top: number;
|
|
36
|
+
left: number;
|
|
37
|
+
bottom: number;
|
|
38
|
+
right: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** App commands in the iPadOS menu bar that JS performs. */
|
|
42
|
+
export type MainMenuCommand = 'about' | 'preferences' | 'lockNow';
|
|
43
|
+
|
|
44
|
+
export interface MainMenuLink {
|
|
45
|
+
title: string;
|
|
46
|
+
url: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Localized content of the custom main menu (the iPadOS menu bar). Help links
|
|
51
|
+
* open in the system browser natively; the other items notify JS. An empty
|
|
52
|
+
* `aboutTitle` removes the About item and empty `helpLinks` remove the Help
|
|
53
|
+
* menu.
|
|
54
|
+
*/
|
|
55
|
+
export interface MainMenuConfig {
|
|
56
|
+
aboutTitle: string;
|
|
57
|
+
preferencesTitle: string;
|
|
58
|
+
lockNowTitle: string;
|
|
59
|
+
helpLinks: MainMenuLink[];
|
|
60
|
+
}
|
|
61
|
+
|
|
29
62
|
export interface LaunchOptions {
|
|
30
63
|
launchType: string;
|
|
31
64
|
deepLink?: string;
|
|
@@ -67,6 +100,27 @@ export interface ReactNativeDeviceUtils
|
|
|
67
100
|
addSpanningChangedListener(callback: (isSpanning: boolean) => void): number;
|
|
68
101
|
removeSpanningChangedListener(id: number): void;
|
|
69
102
|
setUserInterfaceStyle(style: UserInterfaceStyle): void;
|
|
103
|
+
/**
|
|
104
|
+
* Window-controls insets of the app's main window, for content that adapts
|
|
105
|
+
* horizontally (a header row beside the controls). iOS 26+ reads UIKit's
|
|
106
|
+
* safe area with horizontal corner adaptation; Android and older iOS return
|
|
107
|
+
* all zeros. Listeners fire on the main thread when the value changes.
|
|
108
|
+
*/
|
|
109
|
+
getWindowControlsInsets(): WindowControlsInsets;
|
|
110
|
+
addWindowControlsInsetsChangedListener(
|
|
111
|
+
callback: (insets: WindowControlsInsets) => void
|
|
112
|
+
): number;
|
|
113
|
+
removeWindowControlsInsetsChangedListener(id: number): void;
|
|
114
|
+
/**
|
|
115
|
+
* Replaces the custom main menu content and rebuilds the menu bar. The menu
|
|
116
|
+
* only shows on iPadOS (and in windows with a menu bar); Android ignores it.
|
|
117
|
+
*/
|
|
118
|
+
setMainMenuConfig(config: MainMenuConfig): void;
|
|
119
|
+
/** Listeners fire on the main thread when the user picks an app command. */
|
|
120
|
+
addMainMenuCommandListener(
|
|
121
|
+
callback: (command: MainMenuCommand) => void
|
|
122
|
+
): number;
|
|
123
|
+
removeMainMenuCommandListener(id: number): void;
|
|
70
124
|
|
|
71
125
|
// LaunchOptionsManager
|
|
72
126
|
getLaunchOptions(): Promise<LaunchOptions>;
|