@symbiote-native/brightness 1.0.0 → 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.
- package/README.md +72 -61
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -20,6 +20,10 @@ depended on directly and never the `expo` meta-package, why the upstream JS is h
|
|
|
20
20
|
npm install @symbiote-native/brightness
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
Scaffolding or extending a SymbioteNative app? `npx @symbiote-native/cli new --brightness` (or
|
|
24
|
+
`add --brightness` in an existing app) installs and wires this for you — see
|
|
25
|
+
[`@symbiote-native/cli`](../cli).
|
|
26
|
+
|
|
23
27
|
`expo-brightness` and `expo-modules-core` come along as regular, pinned dependencies — never
|
|
24
28
|
install either yourself, and never add the `expo` meta-package to this project (it bundles its own
|
|
25
29
|
Metro/Babel pipeline that conflicts with this project's own).
|
|
@@ -72,7 +76,6 @@ verbatim by every adapter.
|
|
|
72
76
|
```tsx
|
|
73
77
|
// React — trimmed from examples/expo-react/screens/BrightnessScreen.tsx
|
|
74
78
|
import { useEffect, useState } from 'react';
|
|
75
|
-
import { Pressable, Text, View } from '@symbiote-native/react';
|
|
76
79
|
import {
|
|
77
80
|
addBrightnessListener,
|
|
78
81
|
getBrightnessAsync,
|
|
@@ -94,18 +97,18 @@ function BrightnessScreen() {
|
|
|
94
97
|
}, []);
|
|
95
98
|
|
|
96
99
|
return (
|
|
97
|
-
<
|
|
98
|
-
<
|
|
100
|
+
<view>
|
|
101
|
+
<text>
|
|
99
102
|
{brightness === null ? 'checking…' : `${Math.round(brightness * 100)}%`}
|
|
100
|
-
</
|
|
101
|
-
<
|
|
102
|
-
<
|
|
103
|
-
</
|
|
104
|
-
<
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
</
|
|
108
|
-
</
|
|
103
|
+
</text>
|
|
104
|
+
<pressable onPress={() => setBrightnessAsync(0.5)}>
|
|
105
|
+
<text>Set to 50%</text>
|
|
106
|
+
</pressable>
|
|
107
|
+
<text>{permissionStatus?.status ?? 'checking…'}</text>
|
|
108
|
+
<pressable onPress={() => requestPermission()}>
|
|
109
|
+
<text>Request permission</text>
|
|
110
|
+
</pressable>
|
|
111
|
+
</view>
|
|
109
112
|
);
|
|
110
113
|
}
|
|
111
114
|
```
|
|
@@ -114,7 +117,6 @@ function BrightnessScreen() {
|
|
|
114
117
|
<!-- Vue — trimmed from examples/expo-vue-sfc/screens/BrightnessScreen.vue -->
|
|
115
118
|
<script setup lang="ts">
|
|
116
119
|
import { onMounted, onUnmounted, ref } from 'vue';
|
|
117
|
-
import { Pressable, Text, View } from '@symbiote-native/vue';
|
|
118
120
|
import {
|
|
119
121
|
addBrightnessListener,
|
|
120
122
|
getBrightnessAsync,
|
|
@@ -139,25 +141,24 @@ onUnmounted(() => subscription?.remove());
|
|
|
139
141
|
</script>
|
|
140
142
|
|
|
141
143
|
<template>
|
|
142
|
-
<
|
|
143
|
-
<
|
|
144
|
+
<view>
|
|
145
|
+
<text>{{
|
|
144
146
|
brightness === null ? 'checking…' : `${Math.round(brightness * 100)}%`
|
|
145
|
-
}}</
|
|
146
|
-
<
|
|
147
|
-
<
|
|
148
|
-
</
|
|
149
|
-
<
|
|
150
|
-
<
|
|
151
|
-
<
|
|
152
|
-
</
|
|
153
|
-
</
|
|
147
|
+
}}</text>
|
|
148
|
+
<pressable @press="setBrightnessAsync(0.5)">
|
|
149
|
+
<text>Set to 50%</text>
|
|
150
|
+
</pressable>
|
|
151
|
+
<text>{{ permissionStatus?.status ?? 'checking…' }}</text>
|
|
152
|
+
<pressable @press="requestPermission()">
|
|
153
|
+
<text>Request permission</text>
|
|
154
|
+
</pressable>
|
|
155
|
+
</view>
|
|
154
156
|
</template>
|
|
155
157
|
```
|
|
156
158
|
|
|
157
159
|
```svelte
|
|
158
160
|
<!-- Svelte — trimmed from examples/expo-svelte/screens/BrightnessScreen.svelte -->
|
|
159
161
|
<script lang="ts">
|
|
160
|
-
import { Pressable, Text, View } from '@symbiote-native/svelte';
|
|
161
162
|
import {
|
|
162
163
|
addBrightnessListener,
|
|
163
164
|
getBrightnessAsync,
|
|
@@ -173,27 +174,32 @@ onUnmounted(() => subscription?.remove());
|
|
|
173
174
|
|
|
174
175
|
$effect(() => {
|
|
175
176
|
void getBrightnessAsync().then(value => (brightness = value));
|
|
176
|
-
subscription = addBrightnessListener(
|
|
177
|
+
subscription = addBrightnessListener(
|
|
178
|
+
event => (brightness = event.brightness),
|
|
179
|
+
);
|
|
177
180
|
return () => subscription?.remove();
|
|
178
181
|
});
|
|
179
182
|
</script>
|
|
180
183
|
|
|
181
|
-
<
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
<
|
|
188
|
-
<
|
|
189
|
-
</
|
|
190
|
-
</
|
|
184
|
+
<view>
|
|
185
|
+
<text
|
|
186
|
+
>{brightness === null
|
|
187
|
+
? 'checking…'
|
|
188
|
+
: `${Math.round(brightness * 100)}%`}</text
|
|
189
|
+
>
|
|
190
|
+
<pressable onPress={() => setBrightnessAsync(0.5)}>
|
|
191
|
+
<text>Set to 50%</text>
|
|
192
|
+
</pressable>
|
|
193
|
+
<text>{permissions.status?.status ?? 'checking…'}</text>
|
|
194
|
+
<pressable onPress={() => permissions.request()}>
|
|
195
|
+
<text>Request permission</text>
|
|
196
|
+
</pressable>
|
|
197
|
+
</view>
|
|
191
198
|
```
|
|
192
199
|
|
|
193
200
|
```tsx
|
|
194
201
|
// Solid — trimmed from examples/expo-solid/screens/BrightnessScreen.tsx
|
|
195
202
|
import { createSignal, onCleanup } from 'solid-js';
|
|
196
|
-
import { Pressable, Text, View } from '@symbiote-native/solid';
|
|
197
203
|
import {
|
|
198
204
|
addBrightnessListener,
|
|
199
205
|
getBrightnessAsync,
|
|
@@ -203,25 +209,30 @@ import { createPermissions } from '@symbiote-native/brightness/solid';
|
|
|
203
209
|
|
|
204
210
|
function BrightnessScreen() {
|
|
205
211
|
const [brightness, setBrightness] = createSignal<number | null>(null);
|
|
206
|
-
const { status: permissionStatus, request: requestPermission } =
|
|
212
|
+
const { status: permissionStatus, request: requestPermission } =
|
|
213
|
+
createPermissions();
|
|
207
214
|
|
|
208
215
|
getBrightnessAsync().then(setBrightness);
|
|
209
|
-
const subscription = addBrightnessListener(event =>
|
|
216
|
+
const subscription = addBrightnessListener(event =>
|
|
217
|
+
setBrightness(event.brightness),
|
|
218
|
+
);
|
|
210
219
|
onCleanup(() => subscription.remove());
|
|
211
220
|
|
|
212
221
|
return (
|
|
213
|
-
<
|
|
214
|
-
<
|
|
215
|
-
{brightness() === null
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
<view>
|
|
223
|
+
<text>
|
|
224
|
+
{brightness() === null
|
|
225
|
+
? 'checking…'
|
|
226
|
+
: `${Math.round(brightness()! * 100)}%`}
|
|
227
|
+
</text>
|
|
228
|
+
<pressable onPress={() => setBrightnessAsync(0.5)}>
|
|
229
|
+
<text>Set to 50%</text>
|
|
230
|
+
</pressable>
|
|
231
|
+
<text>{permissionStatus()?.status ?? 'checking…'}</text>
|
|
232
|
+
<pressable onPress={() => requestPermission()}>
|
|
233
|
+
<text>Request permission</text>
|
|
234
|
+
</pressable>
|
|
235
|
+
</view>
|
|
225
236
|
);
|
|
226
237
|
}
|
|
227
238
|
```
|
|
@@ -229,7 +240,7 @@ function BrightnessScreen() {
|
|
|
229
240
|
```ts
|
|
230
241
|
// Angular — trimmed from examples/expo-angular/src/screens/BrightnessScreen.ts
|
|
231
242
|
import { Component, inject, signal } from '@angular/core';
|
|
232
|
-
import {
|
|
243
|
+
import { SYMBIOTE_ELEMENTS } from '@symbiote-native/angular';
|
|
233
244
|
import {
|
|
234
245
|
PermissionsService,
|
|
235
246
|
addBrightnessListener,
|
|
@@ -240,18 +251,18 @@ import {
|
|
|
240
251
|
@Component({
|
|
241
252
|
selector: 'BrightnessScreen',
|
|
242
253
|
standalone: true,
|
|
243
|
-
imports: [
|
|
254
|
+
imports: [SYMBIOTE_ELEMENTS],
|
|
244
255
|
template: `
|
|
245
|
-
<
|
|
246
|
-
<
|
|
247
|
-
<
|
|
248
|
-
><
|
|
256
|
+
<view>
|
|
257
|
+
<text>{{ brightnessLabel() }}</text>
|
|
258
|
+
<pressable (press)="setBrightnessAsync(0.5)"
|
|
259
|
+
><text>Set to 50%</text></pressable
|
|
249
260
|
>
|
|
250
|
-
<
|
|
251
|
-
<
|
|
252
|
-
><
|
|
261
|
+
<text>{{ permissionStatus()?.status ?? 'checking…' }}</text>
|
|
262
|
+
<pressable (press)="permissionsService.request()"
|
|
263
|
+
><text>Request permission</text></pressable
|
|
253
264
|
>
|
|
254
|
-
</
|
|
265
|
+
</view>
|
|
255
266
|
`,
|
|
256
267
|
})
|
|
257
268
|
export class BrightnessScreen {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbiote-native/brightness",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "expo-brightness wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, Svelte, Solid, and Angular adapters. Screen brightness get/set, Android-only system-brightness-mode control, an iOS-only brightness-change listener, and permission get/request.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -80,12 +80,12 @@
|
|
|
80
80
|
"solid-js": ">=1.9.0",
|
|
81
81
|
"svelte": ">=5.56.0",
|
|
82
82
|
"vue": ">=3.5.0",
|
|
83
|
-
"@symbiote-native/angular": "^
|
|
84
|
-
"@symbiote-native/engine": "^0.
|
|
85
|
-
"@symbiote-native/react": "^
|
|
86
|
-
"@symbiote-native/solid": "^
|
|
87
|
-
"@symbiote-native/svelte": "^
|
|
88
|
-
"@symbiote-native/vue": "^
|
|
83
|
+
"@symbiote-native/angular": "^3.0.0",
|
|
84
|
+
"@symbiote-native/engine": "^1.0.0",
|
|
85
|
+
"@symbiote-native/react": "^3.0.0",
|
|
86
|
+
"@symbiote-native/solid": "^3.0.0",
|
|
87
|
+
"@symbiote-native/svelte": "^3.0.0",
|
|
88
|
+
"@symbiote-native/vue": "^3.0.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependenciesMeta": {
|
|
91
91
|
"@symbiote-native/angular": {
|
|
@@ -133,13 +133,13 @@
|
|
|
133
133
|
"solid-js": "^1.9.14",
|
|
134
134
|
"svelte": "^5.56.0",
|
|
135
135
|
"typescript": "~6.0.0",
|
|
136
|
-
"@symbiote-native/angular": "
|
|
137
|
-
"@symbiote-native/engine": "0.
|
|
138
|
-
"@symbiote-native/react": "
|
|
139
|
-
"@symbiote-native/solid": "
|
|
140
|
-
"@symbiote-native/svelte": "
|
|
141
|
-
"@symbiote-native/test-utils": "0.3.
|
|
142
|
-
"@symbiote-native/vue": "
|
|
136
|
+
"@symbiote-native/angular": "3.0.0",
|
|
137
|
+
"@symbiote-native/engine": "1.0.0",
|
|
138
|
+
"@symbiote-native/react": "3.0.0",
|
|
139
|
+
"@symbiote-native/solid": "3.0.0",
|
|
140
|
+
"@symbiote-native/svelte": "3.0.0",
|
|
141
|
+
"@symbiote-native/test-utils": "0.3.1",
|
|
142
|
+
"@symbiote-native/vue": "3.0.0"
|
|
143
143
|
},
|
|
144
144
|
"scripts": {
|
|
145
145
|
"typecheck": "tsc --build",
|