rn-system-bar 3.2.3 → 3.2.4
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/README.md +180 -650
- package/android/src/main/java/com/systembar/SystemBarModule.kt +0 -222
- package/index.ts +3 -2
- package/ios/SystemBarModule.m +1 -8
- package/ios/SystemBarModule.swift +55 -68
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -2
- package/lib/src/SystemBar.d.ts +33 -64
- package/lib/src/SystemBar.js +95 -131
- package/lib/src/types.d.ts +43 -43
- package/lib/src/useSystemBar.d.ts +25 -24
- package/lib/src/useSystemBar.js +101 -69
- package/package.json +1 -1
- package/src/SystemBar.ts +111 -128
- package/src/types.ts +68 -51
- package/src/useSystemBar.ts +106 -135
package/lib/src/SystemBar.d.ts
CHANGED
|
@@ -1,42 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/**
|
|
3
|
-
* Set the navigation bar background colour.
|
|
4
|
-
*
|
|
5
|
-
* @param color
|
|
6
|
-
* - Any hex string → solid colour e.g. `"#1a1a2e"`
|
|
7
|
-
* - `"transparent"` → fully transparent (content draws behind bar)
|
|
8
|
-
* - `"translucent"` → semi-transparent (system scrim over content)
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* setNavigationBarColor("#000000"); // solid black
|
|
12
|
-
* setNavigationBarColor("transparent"); // glass / edge-to-edge
|
|
13
|
-
* setNavigationBarColor("translucent"); // frosted glass
|
|
14
|
-
*/
|
|
1
|
+
import type { BatteryInfo, FontScaleInfo, HapticPattern, NavigationBarBehavior, NavigationBarButtonStyle, NavigationBarColorValue, NavigationBarStyle, NavigationBarVisibility, NetworkInfo, Orientation, StatusBarColorValue, StatusBarStyle, SystemScreencastInfo, VolumeStream } from "./types";
|
|
15
2
|
export declare const setNavigationBarColor: (color: NavigationBarColorValue) => void;
|
|
16
|
-
/**
|
|
17
|
-
* Hide or show the navigation bar.
|
|
18
|
-
*
|
|
19
|
-
* @param mode `"visible"` | `"hidden"`
|
|
20
|
-
*/
|
|
21
3
|
export declare const setNavigationBarVisibility: (mode: NavigationBarVisibility) => void;
|
|
22
4
|
export declare const setNavigationBarButtonStyle: (style: NavigationBarButtonStyle) => void;
|
|
23
5
|
export declare const setNavigationBarStyle: (style: NavigationBarStyle) => void;
|
|
24
6
|
export declare const setNavigationBarBehavior: (behavior: NavigationBarBehavior) => void;
|
|
25
|
-
/**
|
|
26
|
-
* Set the status bar background colour (Android only).
|
|
27
|
-
*
|
|
28
|
-
* @param color
|
|
29
|
-
* - Any hex string → solid colour
|
|
30
|
-
* - `"transparent"` → fully transparent
|
|
31
|
-
* - `"translucent"` → semi-transparent
|
|
32
|
-
*/
|
|
33
7
|
export declare const setStatusBarColor: (color: StatusBarColorValue) => void;
|
|
34
8
|
export declare const setStatusBarStyle: (style: StatusBarStyle) => void;
|
|
35
9
|
export declare const setStatusBarVisibility: (visible: boolean) => void;
|
|
36
10
|
export declare const setBrightness: (level: number) => void;
|
|
37
11
|
export declare const getBrightness: () => Promise<number>;
|
|
38
12
|
/**
|
|
39
|
-
* Subscribe to system brightness changes
|
|
13
|
+
* Subscribe to system brightness changes.
|
|
14
|
+
* Android: polls every 500 ms. iOS: UIScreen brightness.
|
|
40
15
|
* @returns unsubscribe function
|
|
41
16
|
*/
|
|
42
17
|
export declare const onBrightnessChange: (callback: (brightness: number) => void) => (() => void);
|
|
@@ -44,7 +19,7 @@ export declare const setVolume: (level: number, stream?: VolumeStream) => void;
|
|
|
44
19
|
export declare const getVolume: (stream?: VolumeStream) => Promise<number>;
|
|
45
20
|
export declare const setVolumeHUDVisible: (visible: boolean) => void;
|
|
46
21
|
/**
|
|
47
|
-
* Subscribe to system volume changes
|
|
22
|
+
* Subscribe to system volume changes.
|
|
48
23
|
* @returns unsubscribe function
|
|
49
24
|
*/
|
|
50
25
|
export declare const onVolumeChange: (callback: (volume: number, stream: VolumeStream) => void) => (() => void);
|
|
@@ -53,55 +28,49 @@ export declare const immersiveMode: (enable: boolean) => void;
|
|
|
53
28
|
export declare const setSecureScreen: (enable: boolean) => void;
|
|
54
29
|
export declare const setOrientation: (mode: Orientation) => void;
|
|
55
30
|
/**
|
|
56
|
-
* One-shot snapshot of
|
|
57
|
-
* Works on both Android (DisplayManager) and iOS (UIScreen.screens).
|
|
31
|
+
* One-shot snapshot of the current network state.
|
|
58
32
|
*/
|
|
59
|
-
export declare const
|
|
33
|
+
export declare const getNetworkInfo: () => Promise<NetworkInfo>;
|
|
60
34
|
/**
|
|
61
|
-
* Subscribe to
|
|
62
|
-
* Fires when an HDMI / Miracast / AirPlay display connects or disconnects.
|
|
35
|
+
* Subscribe to network changes (connectivity, type).
|
|
63
36
|
* @returns unsubscribe function
|
|
64
37
|
*/
|
|
65
|
-
export declare const
|
|
66
|
-
/** @deprecated Use getSystemScreencastInfo() */
|
|
67
|
-
export declare const getScreencastInfo: () => Promise<SystemScreencastInfo>;
|
|
68
|
-
/** @deprecated Use onSystemScreencastChange() */
|
|
69
|
-
export declare const onScreencastChange: (callback: (info: SystemScreencastInfo) => void) => (() => void);
|
|
38
|
+
export declare const onNetworkChange: (callback: (info: NetworkInfo) => void) => (() => void);
|
|
70
39
|
/**
|
|
71
|
-
*
|
|
72
|
-
* Listen for results via `onAppCastChange`.
|
|
73
|
-
* Android: uses MediaRouter. iOS: no-op (AirPlay is system-only).
|
|
40
|
+
* One-shot snapshot of the current battery state.
|
|
74
41
|
*/
|
|
75
|
-
export declare const
|
|
42
|
+
export declare const getBatteryInfo: () => Promise<BatteryInfo>;
|
|
76
43
|
/**
|
|
77
|
-
*
|
|
44
|
+
* Subscribe to battery level / state changes.
|
|
45
|
+
* @returns unsubscribe function
|
|
78
46
|
*/
|
|
79
|
-
export declare const
|
|
47
|
+
export declare const onBatteryChange: (callback: (info: BatteryInfo) => void) => (() => void);
|
|
80
48
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
49
|
+
* Trigger a haptic feedback pattern.
|
|
50
|
+
* iOS: UIFeedbackGenerator. Android: Vibrator.
|
|
51
|
+
*
|
|
52
|
+
* @param pattern "light" | "medium" | "heavy" | "success" | "warning" | "error" | "selection"
|
|
84
53
|
*/
|
|
85
|
-
export declare const
|
|
54
|
+
export declare const haptic: (pattern?: HapticPattern) => void;
|
|
86
55
|
/**
|
|
87
|
-
*
|
|
56
|
+
* One-shot snapshot of system-level external display state.
|
|
88
57
|
*/
|
|
89
|
-
export declare const
|
|
58
|
+
export declare const getSystemScreencastInfo: () => Promise<SystemScreencastInfo>;
|
|
90
59
|
/**
|
|
91
|
-
*
|
|
60
|
+
* Subscribe to external-display connect / disconnect events.
|
|
61
|
+
* @returns unsubscribe function
|
|
92
62
|
*/
|
|
93
|
-
export declare const
|
|
63
|
+
export declare const onSystemScreencastChange: (callback: (info: SystemScreencastInfo) => void) => (() => void);
|
|
94
64
|
/**
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*
|
|
100
|
-
* const unsub = onAppCastChange((info) => {
|
|
101
|
-
* if (info.state === "connected") console.log("Casting to", info.connectedDevice?.name);
|
|
102
|
-
* if (info.error) console.warn("Cast error:", info.error);
|
|
103
|
-
* });
|
|
104
|
-
*
|
|
65
|
+
* One-shot snapshot of the system font scale and screen density.
|
|
66
|
+
*/
|
|
67
|
+
export declare const getFontScaleInfo: () => Promise<FontScaleInfo>;
|
|
68
|
+
/**
|
|
69
|
+
* Subscribe to font scale / accessibility text size changes.
|
|
105
70
|
* @returns unsubscribe function
|
|
106
71
|
*/
|
|
107
|
-
export declare const
|
|
72
|
+
export declare const onFontScaleChange: (callback: (info: FontScaleInfo) => void) => (() => void);
|
|
73
|
+
/** @deprecated Use getSystemScreencastInfo() */
|
|
74
|
+
export declare const getScreencastInfo: () => Promise<SystemScreencastInfo>;
|
|
75
|
+
/** @deprecated Use onSystemScreencastChange() */
|
|
76
|
+
export declare const onScreencastChange: (callback: (info: SystemScreencastInfo) => void) => (() => void);
|
package/lib/src/SystemBar.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// ─────────────────────────────────────────────
|
|
3
3
|
// rn-system-bar · SystemBar.ts
|
|
4
|
-
//
|
|
5
|
-
// All APIs → native Kotlin / iOS Swift.
|
|
4
|
+
// All APIs → native Kotlin (Android) / Swift (iOS)
|
|
6
5
|
// ─────────────────────────────────────────────
|
|
7
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
7
|
+
exports.onScreencastChange = exports.getScreencastInfo = exports.onFontScaleChange = exports.getFontScaleInfo = exports.onSystemScreencastChange = exports.getSystemScreencastInfo = exports.haptic = exports.onBatteryChange = exports.getBatteryInfo = exports.onNetworkChange = exports.getNetworkInfo = exports.setOrientation = exports.setSecureScreen = exports.immersiveMode = exports.keepScreenOn = exports.onVolumeChange = exports.setVolumeHUDVisible = exports.getVolume = exports.setVolume = exports.onBrightnessChange = exports.getBrightness = exports.setBrightness = exports.setStatusBarVisibility = exports.setStatusBarStyle = exports.setStatusBarColor = exports.setNavigationBarBehavior = exports.setNavigationBarStyle = exports.setNavigationBarButtonStyle = exports.setNavigationBarVisibility = exports.setNavigationBarColor = void 0;
|
|
9
8
|
const react_native_1 = require("react-native");
|
|
10
9
|
const { SystemBar: Native } = react_native_1.NativeModules;
|
|
11
10
|
const isAndroid = react_native_1.Platform.OS === "android";
|
|
@@ -24,33 +23,15 @@ const checkNative = (method) => {
|
|
|
24
23
|
throw new Error(`[rn-system-bar] Native.${method} not found. Rebuild your project.`);
|
|
25
24
|
};
|
|
26
25
|
// ═══════════════════════════════════════════════
|
|
27
|
-
// NAVIGATION BAR (Android
|
|
26
|
+
// NAVIGATION BAR (Android only)
|
|
28
27
|
// ═══════════════════════════════════════════════
|
|
29
|
-
/**
|
|
30
|
-
* Set the navigation bar background colour.
|
|
31
|
-
*
|
|
32
|
-
* @param color
|
|
33
|
-
* - Any hex string → solid colour e.g. `"#1a1a2e"`
|
|
34
|
-
* - `"transparent"` → fully transparent (content draws behind bar)
|
|
35
|
-
* - `"translucent"` → semi-transparent (system scrim over content)
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* setNavigationBarColor("#000000"); // solid black
|
|
39
|
-
* setNavigationBarColor("transparent"); // glass / edge-to-edge
|
|
40
|
-
* setNavigationBarColor("translucent"); // frosted glass
|
|
41
|
-
*/
|
|
42
28
|
const setNavigationBarColor = (color) => {
|
|
43
29
|
if (!androidOnly("setNavigationBarColor"))
|
|
44
30
|
return;
|
|
45
31
|
checkNative();
|
|
46
|
-
Native.setNavigationBarColor(color);
|
|
32
|
+
Native.setNavigationBarColor(color);
|
|
47
33
|
};
|
|
48
34
|
exports.setNavigationBarColor = setNavigationBarColor;
|
|
49
|
-
/**
|
|
50
|
-
* Hide or show the navigation bar.
|
|
51
|
-
*
|
|
52
|
-
* @param mode `"visible"` | `"hidden"`
|
|
53
|
-
*/
|
|
54
35
|
const setNavigationBarVisibility = (mode) => {
|
|
55
36
|
if (!androidOnly("setNavigationBarVisibility"))
|
|
56
37
|
return;
|
|
@@ -80,16 +61,8 @@ const setNavigationBarBehavior = (behavior) => {
|
|
|
80
61
|
};
|
|
81
62
|
exports.setNavigationBarBehavior = setNavigationBarBehavior;
|
|
82
63
|
// ═══════════════════════════════════════════════
|
|
83
|
-
// STATUS BAR
|
|
64
|
+
// STATUS BAR
|
|
84
65
|
// ═══════════════════════════════════════════════
|
|
85
|
-
/**
|
|
86
|
-
* Set the status bar background colour (Android only).
|
|
87
|
-
*
|
|
88
|
-
* @param color
|
|
89
|
-
* - Any hex string → solid colour
|
|
90
|
-
* - `"transparent"` → fully transparent
|
|
91
|
-
* - `"translucent"` → semi-transparent
|
|
92
|
-
*/
|
|
93
66
|
const setStatusBarColor = (color) => {
|
|
94
67
|
if (!androidOnly("setStatusBarColor"))
|
|
95
68
|
return;
|
|
@@ -121,7 +94,8 @@ const getBrightness = () => {
|
|
|
121
94
|
};
|
|
122
95
|
exports.getBrightness = getBrightness;
|
|
123
96
|
/**
|
|
124
|
-
* Subscribe to system brightness changes
|
|
97
|
+
* Subscribe to system brightness changes.
|
|
98
|
+
* Android: polls every 500 ms. iOS: UIScreen brightness.
|
|
125
99
|
* @returns unsubscribe function
|
|
126
100
|
*/
|
|
127
101
|
const onBrightnessChange = (callback) => {
|
|
@@ -156,7 +130,7 @@ const setVolumeHUDVisible = (visible) => {
|
|
|
156
130
|
};
|
|
157
131
|
exports.setVolumeHUDVisible = setVolumeHUDVisible;
|
|
158
132
|
/**
|
|
159
|
-
* Subscribe to system volume changes
|
|
133
|
+
* Subscribe to system volume changes.
|
|
160
134
|
* @returns unsubscribe function
|
|
161
135
|
*/
|
|
162
136
|
const onVolumeChange = (callback) => {
|
|
@@ -201,12 +175,76 @@ const setOrientation = (mode) => {
|
|
|
201
175
|
};
|
|
202
176
|
exports.setOrientation = setOrientation;
|
|
203
177
|
// ═══════════════════════════════════════════════
|
|
204
|
-
//
|
|
205
|
-
//
|
|
178
|
+
// NETWORK
|
|
179
|
+
// ═══════════════════════════════════════════════
|
|
180
|
+
/**
|
|
181
|
+
* One-shot snapshot of the current network state.
|
|
182
|
+
*/
|
|
183
|
+
const getNetworkInfo = () => {
|
|
184
|
+
checkNative("getNetworkInfo");
|
|
185
|
+
return Native.getNetworkInfo();
|
|
186
|
+
};
|
|
187
|
+
exports.getNetworkInfo = getNetworkInfo;
|
|
188
|
+
/**
|
|
189
|
+
* Subscribe to network changes (connectivity, type).
|
|
190
|
+
* @returns unsubscribe function
|
|
191
|
+
*/
|
|
192
|
+
const onNetworkChange = (callback) => {
|
|
193
|
+
checkNative();
|
|
194
|
+
const { DeviceEventEmitter } = require("react-native");
|
|
195
|
+
Native.startNetworkListener();
|
|
196
|
+
const sub = DeviceEventEmitter.addListener("SystemBar_NetworkChange", callback);
|
|
197
|
+
return () => {
|
|
198
|
+
sub.remove();
|
|
199
|
+
Native.stopNetworkListener();
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
exports.onNetworkChange = onNetworkChange;
|
|
203
|
+
// ═══════════════════════════════════════════════
|
|
204
|
+
// BATTERY
|
|
205
|
+
// ═══════════════════════════════════════════════
|
|
206
|
+
/**
|
|
207
|
+
* One-shot snapshot of the current battery state.
|
|
208
|
+
*/
|
|
209
|
+
const getBatteryInfo = () => {
|
|
210
|
+
checkNative("getBatteryInfo");
|
|
211
|
+
return Native.getBatteryInfo();
|
|
212
|
+
};
|
|
213
|
+
exports.getBatteryInfo = getBatteryInfo;
|
|
214
|
+
/**
|
|
215
|
+
* Subscribe to battery level / state changes.
|
|
216
|
+
* @returns unsubscribe function
|
|
217
|
+
*/
|
|
218
|
+
const onBatteryChange = (callback) => {
|
|
219
|
+
checkNative();
|
|
220
|
+
const { DeviceEventEmitter } = require("react-native");
|
|
221
|
+
Native.startBatteryListener();
|
|
222
|
+
const sub = DeviceEventEmitter.addListener("SystemBar_BatteryChange", callback);
|
|
223
|
+
return () => {
|
|
224
|
+
sub.remove();
|
|
225
|
+
Native.stopBatteryListener();
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
exports.onBatteryChange = onBatteryChange;
|
|
229
|
+
// ═══════════════════════════════════════════════
|
|
230
|
+
// HAPTICS
|
|
231
|
+
// ═══════════════════════════════════════════════
|
|
232
|
+
/**
|
|
233
|
+
* Trigger a haptic feedback pattern.
|
|
234
|
+
* iOS: UIFeedbackGenerator. Android: Vibrator.
|
|
235
|
+
*
|
|
236
|
+
* @param pattern "light" | "medium" | "heavy" | "success" | "warning" | "error" | "selection"
|
|
237
|
+
*/
|
|
238
|
+
const haptic = (pattern = "medium") => {
|
|
239
|
+
checkNative();
|
|
240
|
+
Native.haptic(pattern);
|
|
241
|
+
};
|
|
242
|
+
exports.haptic = haptic;
|
|
243
|
+
// ═══════════════════════════════════════════════
|
|
244
|
+
// SYSTEM SCREENCAST (external display / HDMI / Miracast / AirPlay)
|
|
206
245
|
// ═══════════════════════════════════════════════
|
|
207
246
|
/**
|
|
208
247
|
* One-shot snapshot of system-level external display state.
|
|
209
|
-
* Works on both Android (DisplayManager) and iOS (UIScreen.screens).
|
|
210
248
|
*/
|
|
211
249
|
const getSystemScreencastInfo = () => {
|
|
212
250
|
if (!Native || typeof Native.getSystemScreencastInfo !== "function") {
|
|
@@ -222,8 +260,7 @@ const getSystemScreencastInfo = () => {
|
|
|
222
260
|
};
|
|
223
261
|
exports.getSystemScreencastInfo = getSystemScreencastInfo;
|
|
224
262
|
/**
|
|
225
|
-
* Subscribe to
|
|
226
|
-
* Fires when an HDMI / Miracast / AirPlay display connects or disconnects.
|
|
263
|
+
* Subscribe to external-display connect / disconnect events.
|
|
227
264
|
* @returns unsubscribe function
|
|
228
265
|
*/
|
|
229
266
|
const onSystemScreencastChange = (callback) => {
|
|
@@ -237,109 +274,36 @@ const onSystemScreencastChange = (callback) => {
|
|
|
237
274
|
};
|
|
238
275
|
};
|
|
239
276
|
exports.onSystemScreencastChange = onSystemScreencastChange;
|
|
240
|
-
// ─────────────────────────────────────────────
|
|
241
|
-
// Legacy aliases (backward compat)
|
|
242
|
-
// ─────────────────────────────────────────────
|
|
243
|
-
/** @deprecated Use getSystemScreencastInfo() */
|
|
244
|
-
exports.getScreencastInfo = exports.getSystemScreencastInfo;
|
|
245
|
-
/** @deprecated Use onSystemScreencastChange() */
|
|
246
|
-
exports.onScreencastChange = exports.onSystemScreencastChange;
|
|
247
277
|
// ═══════════════════════════════════════════════
|
|
248
|
-
//
|
|
249
|
-
// Mirrors only this app's screen — NOT the whole system.
|
|
250
|
-
// Flow: startAppCastScan() → onAppCastChange (devices arrive)
|
|
251
|
-
// → connectAppCast(deviceId) → onAppCastChange (state = "connected")
|
|
252
|
-
// → disconnectAppCast()
|
|
278
|
+
// FONT SCALE
|
|
253
279
|
// ═══════════════════════════════════════════════
|
|
254
280
|
/**
|
|
255
|
-
*
|
|
256
|
-
* Listen for results via `onAppCastChange`.
|
|
257
|
-
* Android: uses MediaRouter. iOS: no-op (AirPlay is system-only).
|
|
258
|
-
*/
|
|
259
|
-
const startAppCastScan = () => {
|
|
260
|
-
if (!androidOnly("startAppCastScan"))
|
|
261
|
-
return;
|
|
262
|
-
checkNative();
|
|
263
|
-
Native.startAppCastScan();
|
|
264
|
-
};
|
|
265
|
-
exports.startAppCastScan = startAppCastScan;
|
|
266
|
-
/**
|
|
267
|
-
* Stop the device discovery scan.
|
|
268
|
-
*/
|
|
269
|
-
const stopAppCastScan = () => {
|
|
270
|
-
if (!androidOnly("stopAppCastScan"))
|
|
271
|
-
return;
|
|
272
|
-
checkNative();
|
|
273
|
-
Native.stopAppCastScan();
|
|
274
|
-
};
|
|
275
|
-
exports.stopAppCastScan = stopAppCastScan;
|
|
276
|
-
/**
|
|
277
|
-
* Connect to a discovered device and begin casting this app's screen.
|
|
278
|
-
* @param deviceId The `id` field from `AppCastDevice` (MediaRouter route ID).
|
|
279
|
-
* @param pairingPin Optional PIN string if `requiresPairing` is true.
|
|
280
|
-
*/
|
|
281
|
-
const connectAppCast = (deviceId, pairingPin) => {
|
|
282
|
-
if (!androidOnly("connectAppCast"))
|
|
283
|
-
return;
|
|
284
|
-
checkNative();
|
|
285
|
-
Native.connectAppCast(deviceId, pairingPin !== null && pairingPin !== void 0 ? pairingPin : null);
|
|
286
|
-
};
|
|
287
|
-
exports.connectAppCast = connectAppCast;
|
|
288
|
-
/**
|
|
289
|
-
* Disconnect the active in-app cast session.
|
|
281
|
+
* One-shot snapshot of the system font scale and screen density.
|
|
290
282
|
*/
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
checkNative();
|
|
295
|
-
Native.disconnectAppCast();
|
|
283
|
+
const getFontScaleInfo = () => {
|
|
284
|
+
checkNative("getFontScaleInfo");
|
|
285
|
+
return Native.getFontScaleInfo();
|
|
296
286
|
};
|
|
297
|
-
exports.
|
|
287
|
+
exports.getFontScaleInfo = getFontScaleInfo;
|
|
298
288
|
/**
|
|
299
|
-
*
|
|
300
|
-
*/
|
|
301
|
-
const getAppCastInfo = () => {
|
|
302
|
-
if (!isAndroid) {
|
|
303
|
-
return Promise.resolve({
|
|
304
|
-
state: "idle",
|
|
305
|
-
devices: [],
|
|
306
|
-
connectedDevice: null,
|
|
307
|
-
error: null,
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
checkNative();
|
|
311
|
-
return Native.getAppCastInfo();
|
|
312
|
-
};
|
|
313
|
-
exports.getAppCastInfo = getAppCastInfo;
|
|
314
|
-
/**
|
|
315
|
-
* Subscribe to in-app cast state changes.
|
|
316
|
-
* Fires on: device discovered/lost, state changes (scanning → connecting → connected),
|
|
317
|
-
* pairing requests, errors.
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* const unsub = onAppCastChange((info) => {
|
|
321
|
-
* if (info.state === "connected") console.log("Casting to", info.connectedDevice?.name);
|
|
322
|
-
* if (info.error) console.warn("Cast error:", info.error);
|
|
323
|
-
* });
|
|
324
|
-
*
|
|
289
|
+
* Subscribe to font scale / accessibility text size changes.
|
|
325
290
|
* @returns unsubscribe function
|
|
326
291
|
*/
|
|
327
|
-
const
|
|
328
|
-
if (!isAndroid) {
|
|
329
|
-
// iOS: immediately call with idle state, return no-op
|
|
330
|
-
callback({
|
|
331
|
-
state: "idle",
|
|
332
|
-
devices: [],
|
|
333
|
-
connectedDevice: null,
|
|
334
|
-
error: null,
|
|
335
|
-
});
|
|
336
|
-
return () => { };
|
|
337
|
-
}
|
|
292
|
+
const onFontScaleChange = (callback) => {
|
|
338
293
|
checkNative();
|
|
339
294
|
const { DeviceEventEmitter } = require("react-native");
|
|
340
|
-
|
|
295
|
+
Native.startFontScaleListener();
|
|
296
|
+
const sub = DeviceEventEmitter.addListener("SystemBar_FontScaleChange", callback);
|
|
341
297
|
return () => {
|
|
342
298
|
sub.remove();
|
|
299
|
+
Native.stopFontScaleListener();
|
|
343
300
|
};
|
|
344
301
|
};
|
|
345
|
-
exports.
|
|
302
|
+
exports.onFontScaleChange = onFontScaleChange;
|
|
303
|
+
// ─────────────────────────────────────────────
|
|
304
|
+
// Legacy aliases (backward compat)
|
|
305
|
+
// ─────────────────────────────────────────────
|
|
306
|
+
/** @deprecated Use getSystemScreencastInfo() */
|
|
307
|
+
exports.getScreencastInfo = exports.getSystemScreencastInfo;
|
|
308
|
+
/** @deprecated Use onSystemScreencastChange() */
|
|
309
|
+
exports.onScreencastChange = exports.onSystemScreencastChange;
|
package/lib/src/types.d.ts
CHANGED
|
@@ -5,33 +5,22 @@ export type NavigationBarVisibility = "visible" | "hidden";
|
|
|
5
5
|
export type StatusBarStyle = "light" | "dark";
|
|
6
6
|
/**
|
|
7
7
|
* Navigation bar color value.
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
* - `"
|
|
11
|
-
* transparent color; content draws behind bar)
|
|
12
|
-
* - `"translucent"` → semi-transparent (FLAG_TRANSLUCENT_NAVIGATION)
|
|
8
|
+
* - Any hex string → solid colour e.g. "#1a1a2e"
|
|
9
|
+
* - `"transparent"` → fully transparent
|
|
10
|
+
* - `"translucent"` → semi-transparent
|
|
13
11
|
*/
|
|
14
12
|
export type NavigationBarColorValue = string | "transparent" | "translucent";
|
|
15
13
|
/**
|
|
16
14
|
* Status bar background color value.
|
|
17
|
-
*
|
|
18
|
-
* -
|
|
19
|
-
* - `"
|
|
20
|
-
* - `"translucent"` → semi-transparent
|
|
15
|
+
* - Any hex string → solid colour
|
|
16
|
+
* - `"transparent"` → fully transparent
|
|
17
|
+
* - `"translucent"` → semi-transparent
|
|
21
18
|
*/
|
|
22
19
|
export type StatusBarColorValue = string | "transparent" | "translucent";
|
|
23
|
-
/**
|
|
24
|
-
* "system" → follow the OS Appearance (dark/light).
|
|
25
|
-
* "dark" → force dark.
|
|
26
|
-
* "light" → force light.
|
|
27
|
-
*/
|
|
28
20
|
export type ThemeMode = "system" | "dark" | "light";
|
|
29
21
|
export interface ThemeState {
|
|
30
|
-
/** Resolved dark-mode flag. Always a concrete boolean. */
|
|
31
22
|
isDark: boolean;
|
|
32
|
-
/** Currently active override ("system" = following OS). */
|
|
33
23
|
mode: ThemeMode;
|
|
34
|
-
/** Set the override mode. Pass "system" to revert to OS. */
|
|
35
24
|
setMode: (mode: ThemeMode) => void;
|
|
36
25
|
}
|
|
37
26
|
export type Orientation = "portrait" | "landscape" | "landscape-left" | "landscape-right" | "auto";
|
|
@@ -41,37 +30,48 @@ export interface ScreencastDisplay {
|
|
|
41
30
|
name: string;
|
|
42
31
|
isValid: boolean;
|
|
43
32
|
}
|
|
44
|
-
/** Result of getSystemScreencastInfo() — physical/HDMI/Miracast external display. */
|
|
45
33
|
export interface SystemScreencastInfo {
|
|
46
34
|
isCasting: boolean;
|
|
47
35
|
displayName: string | null;
|
|
48
36
|
displays: ScreencastDisplay[];
|
|
49
37
|
}
|
|
50
|
-
/** Connection state of the in-app cast session. */
|
|
51
|
-
export type AppCastState = "idle" | "scanning" | "connecting" | "connected" | "disconnecting";
|
|
52
|
-
/** A discovered castable device (TV, Chromecast, etc.). */
|
|
53
|
-
export interface AppCastDevice {
|
|
54
|
-
/** Unique route ID from MediaRouter. */
|
|
55
|
-
id: string;
|
|
56
|
-
/** Human-readable device name e.g. "Living Room TV". */
|
|
57
|
-
name: string;
|
|
58
|
-
/** Device description / model string (may be null). */
|
|
59
|
-
description: string | null;
|
|
60
|
-
/** Signal strength 0–100, or null if unavailable. */
|
|
61
|
-
signalStrength: number | null;
|
|
62
|
-
/** Whether a pairing/PIN step is required. */
|
|
63
|
-
requiresPairing: boolean;
|
|
64
|
-
}
|
|
65
|
-
/** Full snapshot of in-app cast state. */
|
|
66
|
-
export interface AppCastInfo {
|
|
67
|
-
state: AppCastState;
|
|
68
|
-
/** Devices found during the last scan. */
|
|
69
|
-
devices: AppCastDevice[];
|
|
70
|
-
/** The device currently connected (or connecting). */
|
|
71
|
-
connectedDevice: AppCastDevice | null;
|
|
72
|
-
/** Error message from the last failed operation. */
|
|
73
|
-
error: string | null;
|
|
74
|
-
}
|
|
75
38
|
/** @deprecated Use SystemScreencastInfo */
|
|
76
39
|
export interface ScreencastInfo extends SystemScreencastInfo {
|
|
77
40
|
}
|
|
41
|
+
export type NetworkType = "wifi" | "cellular" | "none" | "unknown";
|
|
42
|
+
export interface NetworkInfo {
|
|
43
|
+
/** Connection medium. */
|
|
44
|
+
type: NetworkType;
|
|
45
|
+
/** True when the device has an active internet connection. */
|
|
46
|
+
isConnected: boolean;
|
|
47
|
+
/** True when airplane mode is on (Android only; always false on iOS). */
|
|
48
|
+
isAirplaneMode: boolean;
|
|
49
|
+
/** Wi-Fi SSID — Android only, requires location permission; null on iOS. */
|
|
50
|
+
ssid: string | null;
|
|
51
|
+
/** Cellular generation e.g. "4g" | "5g" — Android only; null on iOS. */
|
|
52
|
+
cellularGeneration: string | null;
|
|
53
|
+
}
|
|
54
|
+
export type BatteryState = "charging" | "discharging" | "full" | "unknown";
|
|
55
|
+
export interface BatteryInfo {
|
|
56
|
+
/** Battery level 0–100, or -1 if unknown. */
|
|
57
|
+
level: number;
|
|
58
|
+
state: BatteryState;
|
|
59
|
+
isCharging: boolean;
|
|
60
|
+
/** True when level ≤ 20 and not charging. */
|
|
61
|
+
isLow: boolean;
|
|
62
|
+
}
|
|
63
|
+
export type HapticPattern = "light" | "medium" | "heavy" | "success" | "warning" | "error" | "selection";
|
|
64
|
+
export interface FontScaleInfo {
|
|
65
|
+
/**
|
|
66
|
+
* System font scale multiplier (1.0 = default).
|
|
67
|
+
* Android: from Configuration.fontScale.
|
|
68
|
+
* iOS: derived from UIContentSizeCategory.
|
|
69
|
+
*/
|
|
70
|
+
fontScale: number;
|
|
71
|
+
/**
|
|
72
|
+
* Screen pixel density.
|
|
73
|
+
* Android: DisplayMetrics.density.
|
|
74
|
+
* iOS: UIScreen.main.scale.
|
|
75
|
+
*/
|
|
76
|
+
density: number;
|
|
77
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BatteryInfo, FontScaleInfo, NavigationBarBehavior, NavigationBarButtonStyle, NavigationBarColorValue, NavigationBarStyle, NavigationBarVisibility, NetworkInfo, Orientation, ScreencastInfo, StatusBarColorValue, StatusBarStyle, SystemScreencastInfo, ThemeMode, ThemeState } from "./types";
|
|
2
2
|
export interface SystemBarConfig {
|
|
3
3
|
navigationBarColor?: NavigationBarColorValue;
|
|
4
4
|
navigationBarVisibility?: NavigationBarVisibility;
|
|
@@ -8,7 +8,6 @@ export interface SystemBarConfig {
|
|
|
8
8
|
statusBarColor?: StatusBarColorValue;
|
|
9
9
|
statusBarStyle?: StatusBarStyle;
|
|
10
10
|
statusBarVisible?: boolean;
|
|
11
|
-
statusBarAnimated?: boolean;
|
|
12
11
|
keepScreenOn?: boolean;
|
|
13
12
|
immersiveMode?: boolean;
|
|
14
13
|
brightness?: number;
|
|
@@ -17,34 +16,36 @@ export interface SystemBarConfig {
|
|
|
17
16
|
}
|
|
18
17
|
export declare const useSystemBar: (config: SystemBarConfig) => void;
|
|
19
18
|
export interface ThemedSystemBarConfig {
|
|
20
|
-
/** Config applied when the resolved theme is DARK. */
|
|
21
19
|
dark?: SystemBarConfig;
|
|
22
|
-
/** Config applied when the resolved theme is LIGHT. */
|
|
23
20
|
light?: SystemBarConfig;
|
|
24
|
-
/**
|
|
25
|
-
* Static config merged under both themes.
|
|
26
|
-
* Theme-specific (dark/light) values always win.
|
|
27
|
-
*/
|
|
28
21
|
base?: SystemBarConfig;
|
|
29
22
|
}
|
|
30
23
|
export declare const useThemeSystemBar: (config: ThemedSystemBarConfig) => ThemeState;
|
|
31
24
|
export { useTheme } from "./useTheme";
|
|
32
25
|
export type { ThemeMode, ThemeState };
|
|
33
26
|
export declare const useSystemScreencast: () => SystemScreencastInfo;
|
|
34
|
-
/** @deprecated
|
|
27
|
+
/** @deprecated Use useSystemScreencast() */
|
|
35
28
|
export declare const useScreencast: () => ScreencastInfo;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Subscribe to network state. Fires immediately with the current snapshot,
|
|
31
|
+
* then on every connectivity change.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const { isConnected, type } = useNetwork();
|
|
35
|
+
*/
|
|
36
|
+
export declare const useNetwork: () => NetworkInfo;
|
|
37
|
+
/**
|
|
38
|
+
* Subscribe to battery state. Fires immediately with the current snapshot,
|
|
39
|
+
* then on every level / state change.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const { level, isCharging, isLow } = useBattery();
|
|
43
|
+
*/
|
|
44
|
+
export declare const useBattery: () => BatteryInfo;
|
|
45
|
+
/**
|
|
46
|
+
* Subscribe to system font scale changes (accessibility text size).
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const { fontScale, density } = useFontScale();
|
|
50
|
+
*/
|
|
51
|
+
export declare const useFontScale: () => FontScaleInfo;
|