expo-android-glass-view 0.1.3 → 0.1.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 +154 -67
- package/package.json +1 -1
- package/src/AndroidGlassComponents.types.ts +1 -1
- package/tsconfig.json +20 -5
- package/build/AndroidGlassBottomTabs.android.d.ts +0 -4
- package/build/AndroidGlassBottomTabs.android.d.ts.map +0 -1
- package/build/AndroidGlassBottomTabs.android.js +0 -51
- package/build/AndroidGlassBottomTabs.android.js.map +0 -1
- package/build/AndroidGlassBottomTabs.d.ts +0 -5
- package/build/AndroidGlassBottomTabs.d.ts.map +0 -1
- package/build/AndroidGlassBottomTabs.js +0 -34
- package/build/AndroidGlassBottomTabs.js.map +0 -1
- package/build/AndroidGlassButton.android.d.ts +0 -4
- package/build/AndroidGlassButton.android.d.ts.map +0 -1
- package/build/AndroidGlassButton.android.js +0 -32
- package/build/AndroidGlassButton.android.js.map +0 -1
- package/build/AndroidGlassButton.d.ts +0 -5
- package/build/AndroidGlassButton.d.ts.map +0 -1
- package/build/AndroidGlassButton.js +0 -38
- package/build/AndroidGlassButton.js.map +0 -1
- package/build/AndroidGlassComponents.types.d.ts +0 -72
- package/build/AndroidGlassComponents.types.d.ts.map +0 -1
- package/build/AndroidGlassComponents.types.js +0 -2
- package/build/AndroidGlassComponents.types.js.map +0 -1
- package/build/AndroidGlassSlider.android.d.ts +0 -4
- package/build/AndroidGlassSlider.android.d.ts.map +0 -1
- package/build/AndroidGlassSlider.android.js +0 -27
- package/build/AndroidGlassSlider.android.js.map +0 -1
- package/build/AndroidGlassSlider.d.ts +0 -5
- package/build/AndroidGlassSlider.d.ts.map +0 -1
- package/build/AndroidGlassSlider.js +0 -47
- package/build/AndroidGlassSlider.js.map +0 -1
- package/build/AndroidGlassTab.d.ts +0 -9
- package/build/AndroidGlassTab.d.ts.map +0 -1
- package/build/AndroidGlassTab.js +0 -22
- package/build/AndroidGlassTab.js.map +0 -1
- package/build/AndroidGlassToggle.android.d.ts +0 -4
- package/build/AndroidGlassToggle.android.d.ts.map +0 -1
- package/build/AndroidGlassToggle.android.js +0 -27
- package/build/AndroidGlassToggle.android.js.map +0 -1
- package/build/AndroidGlassToggle.d.ts +0 -5
- package/build/AndroidGlassToggle.d.ts.map +0 -1
- package/build/AndroidGlassToggle.js +0 -7
- package/build/AndroidGlassToggle.js.map +0 -1
- package/build/AndroidGlassView.android.d.ts +0 -4
- package/build/AndroidGlassView.android.d.ts.map +0 -1
- package/build/AndroidGlassView.android.js +0 -10
- package/build/AndroidGlassView.android.js.map +0 -1
- package/build/AndroidGlassView.d.ts +0 -8
- package/build/AndroidGlassView.d.ts.map +0 -1
- package/build/AndroidGlassView.js +0 -18
- package/build/AndroidGlassView.js.map +0 -1
- package/build/AndroidGlassView.types.d.ts +0 -34
- package/build/AndroidGlassView.types.d.ts.map +0 -1
- package/build/AndroidGlassView.types.js +0 -2
- package/build/AndroidGlassView.types.js.map +0 -1
- package/build/MinimizeOnScroll.d.ts +0 -41
- package/build/MinimizeOnScroll.d.ts.map +0 -1
- package/build/MinimizeOnScroll.js +0 -76
- package/build/MinimizeOnScroll.js.map +0 -1
- package/build/index.d.ts +0 -10
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -12
- package/build/index.js.map +0 -1
- package/build/utils.d.ts +0 -5
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -9
- package/build/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src=".github/assets/hero.png" alt="Liquid Glass — expo-android-glass-view" width="1040" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
#
|
|
2
6
|
|
|
3
7
|
Liquid Glass for React Native on **Android**: real refraction, blur, vibrancy and rim
|
|
4
8
|
highlights behind any React content, rendered with Jetpack Compose — plus ready-made glass
|
|
@@ -30,12 +34,12 @@ the same window, and keeps up with scrolling lists, animations and layout change
|
|
|
30
34
|
|
|
31
35
|
## Platforms
|
|
32
36
|
|
|
33
|
-
| Platform
|
|
34
|
-
|
|
|
35
|
-
| Android 13+ (API 33)
|
|
37
|
+
| Platform | Result |
|
|
38
|
+
| ---------------------- | ------------------------------------------------------------- |
|
|
39
|
+
| Android 13+ (API 33) | Full effect: refraction, chromatic aberration, blur, vibrancy |
|
|
36
40
|
| Android 12 (API 31–32) | Blur and vibrancy, no refraction (needs AGSL runtime shaders) |
|
|
37
|
-
| Android 11 and older
|
|
38
|
-
| iOS, web
|
|
41
|
+
| Android 11 and older | Plain translucent surface (`fallbackColor`) |
|
|
42
|
+
| iOS, web | Same components, plain fallbacks with the same API — no crash |
|
|
39
43
|
|
|
40
44
|
Requires a development build (it is a native module, so it does not run in Expo Go) and the
|
|
41
45
|
React Native New Architecture. Built against Expo SDK 57 / React Native 0.86.
|
|
@@ -59,22 +63,24 @@ A container: children render on top of the glass and stay fully interactive.
|
|
|
59
63
|
</AndroidGlassView>
|
|
60
64
|
```
|
|
61
65
|
|
|
66
|
+
<img src=".github/assets/glasses.gif" alt="AndroidGlassView with different props: default, frosted, lens, prism, tint, no shadow" width="480" />
|
|
67
|
+
|
|
62
68
|
Accepts every `View` prop plus:
|
|
63
69
|
|
|
64
|
-
| Prop
|
|
65
|
-
|
|
|
66
|
-
| `cornerRadius`
|
|
67
|
-
| `blurRadius`
|
|
68
|
-
| `refractionHeight`
|
|
69
|
-
| `refractionAmount`
|
|
70
|
-
| `chromaticAberration` | `boolean`
|
|
71
|
-
| `depthEffect`
|
|
72
|
-
| `vibrancy`
|
|
73
|
-
| `highlight`
|
|
74
|
-
| `shadow`
|
|
75
|
-
| `tintColor`
|
|
76
|
-
| `surfaceColor`
|
|
77
|
-
| `fallbackColor`
|
|
70
|
+
| Prop | Type | Default | Description |
|
|
71
|
+
| --------------------- | ------------ | ------------------------------- | ------------------------------------------------------------------------------------- |
|
|
72
|
+
| `cornerRadius` | `number` | `style.borderRadius`, else `24` | Corner radius of the glass shape in dp. Use a large value (e.g. `999`) for a capsule. |
|
|
73
|
+
| `blurRadius` | `number` | `2` | Backdrop blur in dp. `0` disables it. |
|
|
74
|
+
| `refractionHeight` | `number` | `12` | Width of the refracting rim in dp. `0` disables refraction. |
|
|
75
|
+
| `refractionAmount` | `number` | `24` | How far content is bent at the rim, in dp. |
|
|
76
|
+
| `chromaticAberration` | `boolean` | `false` | Split the refraction per colour channel (prism fringe). |
|
|
77
|
+
| `depthEffect` | `boolean` | `false` | Stronger, depth-like bending towards the rim. |
|
|
78
|
+
| `vibrancy` | `boolean` | `true` | Boost the saturation of what is behind the glass. |
|
|
79
|
+
| `highlight` | `boolean` | `true` | Specular highlight along the rim. |
|
|
80
|
+
| `shadow` | `boolean` | `true` | Soft drop shadow around the shape. |
|
|
81
|
+
| `tintColor` | `ColorValue` | — | Colour tint mixed into the glass. |
|
|
82
|
+
| `surfaceColor` | `ColorValue` | — | Flat colour painted over the glass, on top of the refraction. |
|
|
83
|
+
| `fallbackColor` | `ColorValue` | `rgba(255,255,255,0.7)` | Surface used where the effect cannot run (see _Platforms_). |
|
|
78
84
|
|
|
79
85
|
Don't set `backgroundColor` on a glass view — it would paint over the effect. Use `tintColor`
|
|
80
86
|
or `surfaceColor` instead.
|
|
@@ -84,6 +90,8 @@ or `surfaceColor` instead.
|
|
|
84
90
|
Kyant's liquid button: while pressed, the glass swells, stretches towards the finger and a
|
|
85
91
|
highlight follows it.
|
|
86
92
|
|
|
93
|
+
<img src=".github/assets/buttons.gif" alt="AndroidGlassButton" width="480" />
|
|
94
|
+
|
|
87
95
|
```tsx
|
|
88
96
|
<AndroidGlassButton title="Save" onPress={save} />
|
|
89
97
|
<AndroidGlassButton title="Continue" tintColor="#0088FF" onPress={next} />
|
|
@@ -95,29 +103,31 @@ highlight follows it.
|
|
|
95
103
|
|
|
96
104
|
Takes every `AndroidGlassView` prop (`cornerRadius` defaults to a capsule) plus:
|
|
97
105
|
|
|
98
|
-
| Prop
|
|
99
|
-
|
|
|
100
|
-
| `onPress`
|
|
101
|
-
| `title`
|
|
102
|
-
| `titleStyle`
|
|
103
|
-
| `interactive` | `boolean`
|
|
106
|
+
| Prop | Type | Default | Description |
|
|
107
|
+
| ------------- | ------------ | ------- | ---------------------------------------------------- |
|
|
108
|
+
| `onPress` | `() => void` | — | Called on tap. |
|
|
109
|
+
| `title` | `string` | — | Convenience label (15 sp; white on a tinted button). |
|
|
110
|
+
| `titleStyle` | `TextStyle` | — | Style for `title`. |
|
|
111
|
+
| `interactive` | `boolean` | `true` | Press and drag deformation. |
|
|
104
112
|
|
|
105
113
|
The default size is 48 dp high with 16 dp horizontal padding; override it with `style`. The
|
|
106
|
-
children are drawn
|
|
114
|
+
children are drawn _inside_ the glass (clipped to it, deformed with it), so they are decorative:
|
|
107
115
|
don't put interactive elements in a button.
|
|
108
116
|
|
|
109
117
|
## `AndroidGlassToggle`
|
|
110
118
|
|
|
119
|
+
<img src=".github/assets/toggles.gif" alt="AndroidGlassToggle" width="480" />
|
|
120
|
+
|
|
111
121
|
```tsx
|
|
112
122
|
<AndroidGlassToggle value={enabled} onValueChange={setEnabled} />
|
|
113
123
|
```
|
|
114
124
|
|
|
115
|
-
| Prop
|
|
116
|
-
|
|
|
117
|
-
| `value`
|
|
118
|
-
| `onValueChange` | `(value: boolean) => void` | —
|
|
119
|
-
| `accentColor`
|
|
120
|
-
| `trackColor`
|
|
125
|
+
| Prop | Type | Default | Description |
|
|
126
|
+
| --------------- | -------------------------- | ---------------- | ------------------------------------------------------------- |
|
|
127
|
+
| `value` | `boolean` | `false` | |
|
|
128
|
+
| `onValueChange` | `(value: boolean) => void` | — | Called on tap or when the thumb is dropped on the other side. |
|
|
129
|
+
| `accentColor` | `ColorValue` | iOS green | Track colour when on. |
|
|
130
|
+
| `trackColor` | `ColorValue` | translucent grey | Track colour when off. |
|
|
121
131
|
|
|
122
132
|
The track is 64 × 28 dp; the thumb turns into refracting glass and grows past it while dragged.
|
|
123
133
|
|
|
@@ -127,18 +137,20 @@ new value, the switch returns to `value`.
|
|
|
127
137
|
|
|
128
138
|
## `AndroidGlassSlider`
|
|
129
139
|
|
|
140
|
+
<img src=".github/assets/sliders.gif" alt="AndroidGlassSlider" width="480" />
|
|
141
|
+
|
|
130
142
|
```tsx
|
|
131
143
|
<AndroidGlassSlider value={volume} maximumValue={100} onValueChange={setVolume} />
|
|
132
144
|
```
|
|
133
145
|
|
|
134
|
-
| Prop
|
|
135
|
-
|
|
|
136
|
-
| `value`
|
|
137
|
-
| `minimumValue` / `maximumValue` | `number`
|
|
138
|
-
| `onValueChange`
|
|
139
|
-
| `onSlidingComplete`
|
|
140
|
-
| `accentColor`
|
|
141
|
-
| `trackColor`
|
|
146
|
+
| Prop | Type | Default | Description |
|
|
147
|
+
| ------------------------------- | ------------------------- | ---------------- | -------------------------------------------------------------- |
|
|
148
|
+
| `value` | `number` | `0` | |
|
|
149
|
+
| `minimumValue` / `maximumValue` | `number` | `0` / `1` | |
|
|
150
|
+
| `onValueChange` | `(value: number) => void` | — | Called continuously while dragging. |
|
|
151
|
+
| `onSlidingComplete` | `(value: number) => void` | — | Called when the finger is lifted, or after a tap on the track. |
|
|
152
|
+
| `accentColor` | `ColorValue` | system blue | Filled part of the track. |
|
|
153
|
+
| `trackColor` | `ColorValue` | translucent grey | Unfilled part of the track. |
|
|
142
154
|
|
|
143
155
|
It stretches to the width of its parent and is 36 dp high by default.
|
|
144
156
|
|
|
@@ -153,6 +165,8 @@ Kyant's iOS 26 style tab bar: a glass capsule with a liquid selection droplet yo
|
|
|
153
165
|
between tabs. Under the droplet the tab content takes the accent colour and is magnified while
|
|
154
166
|
pressed.
|
|
155
167
|
|
|
168
|
+
<img src=".github/assets/tabbar.gif" alt="AndroidGlassBottomTabs" width="480" />
|
|
169
|
+
|
|
156
170
|
```tsx
|
|
157
171
|
<AndroidGlassBottomTabs
|
|
158
172
|
selectedIndex={tab}
|
|
@@ -164,14 +178,14 @@ pressed.
|
|
|
164
178
|
</AndroidGlassBottomTabs>
|
|
165
179
|
```
|
|
166
180
|
|
|
167
|
-
| Prop
|
|
168
|
-
|
|
|
169
|
-
| `selectedIndex`
|
|
170
|
-
| `onTabSelected`
|
|
171
|
-
| `minimized`
|
|
172
|
-
| `onMinimizedChange` | `(minimized: boolean) => void` | —
|
|
173
|
-
| `accentColor`
|
|
174
|
-
| `containerColor`
|
|
181
|
+
| Prop | Type | Default | Description |
|
|
182
|
+
| ------------------- | ------------------------------ | ----------------- | ------------------------------------------------------------------------------------------- |
|
|
183
|
+
| `selectedIndex` | `number` | `0` | |
|
|
184
|
+
| `onTabSelected` | `(index: number) => void` | — | Called on tap, or when the droplet is dropped on a tab. |
|
|
185
|
+
| `minimized` | `boolean` | `false` | Minimized look: shorter and narrower, labels faded out. Animated. See _Minimize on scroll_. |
|
|
186
|
+
| `onMinimizedChange` | `(minimized: boolean) => void` | — | Called with `false` when the user expands the minimized bar by touching it. |
|
|
187
|
+
| `accentColor` | `ColorValue` | system blue | Colour of the selected tab's content. |
|
|
188
|
+
| `containerColor` | `ColorValue` | translucent white | Colour of the glass bar. |
|
|
175
189
|
|
|
176
190
|
Each child is one tab (equal widths). `AndroidGlassTab` is an icon over a 12 sp label, but any
|
|
177
191
|
view works — as with buttons, the tabs are drawn inside the glass, so keep them decorative. The
|
|
@@ -184,8 +198,8 @@ droplet returns to `selectedIndex`.
|
|
|
184
198
|
|
|
185
199
|
### Minimize on scroll
|
|
186
200
|
|
|
187
|
-
|
|
188
|
-
they scroll up, get back to the top or touch it. It gets shorter and narrower; every tab keeps its
|
|
201
|
+
Added by this package, on top of Kyant's tab bar: the bar can shrink while the user scrolls
|
|
202
|
+
down a list, and come back when they scroll up, get back to the top or touch it. It gets shorter and narrower; every tab keeps its
|
|
189
203
|
first child (the icon) while the rest (the label) fades out.
|
|
190
204
|
|
|
191
205
|
Wrap the bar and the screens in `MinimizeOnScrollProvider`, and give each list the handler from
|
|
@@ -237,7 +251,8 @@ import {
|
|
|
237
251
|
function GlassTabBar({ state, descriptors, navigation }: BottomTabBarProps) {
|
|
238
252
|
// Routes hidden with `href: null` reach a custom bar as `display: 'none'`.
|
|
239
253
|
const routes = state.routes.filter(
|
|
240
|
-
(route) =>
|
|
254
|
+
(route) =>
|
|
255
|
+
StyleSheet.flatten(descriptors[route.key].options.tabBarItemStyle)?.display !== 'none'
|
|
241
256
|
);
|
|
242
257
|
const focusedKey = state.routes[state.index].key;
|
|
243
258
|
return (
|
|
@@ -245,7 +260,11 @@ function GlassTabBar({ state, descriptors, navigation }: BottomTabBarProps) {
|
|
|
245
260
|
selectedIndex={routes.findIndex((route) => route.key === focusedKey)}
|
|
246
261
|
onTabSelected={(index) => {
|
|
247
262
|
const route = routes[index];
|
|
248
|
-
const event = navigation.emit({
|
|
263
|
+
const event = navigation.emit({
|
|
264
|
+
type: 'tabPress',
|
|
265
|
+
target: route.key,
|
|
266
|
+
canPreventDefault: true,
|
|
267
|
+
});
|
|
249
268
|
if (!event.defaultPrevented) navigation.navigate(route.name, route.params);
|
|
250
269
|
}}
|
|
251
270
|
style={{ position: 'absolute', left: 24, right: 24, bottom: 32 }}>
|
|
@@ -298,20 +317,88 @@ are told a native gesture started. Vertical drags still scroll.
|
|
|
298
317
|
|
|
299
318
|
## How it works
|
|
300
319
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
320
|
+
In short: every glass view takes a live snapshot of what is drawn behind it, runs it through a
|
|
321
|
+
GPU lens (blur, refraction, vibrancy) and draws the result in its own shape.
|
|
322
|
+
|
|
323
|
+
### A Compose layer inside a React Native view
|
|
324
|
+
|
|
325
|
+
Each glass component is a React Native view (`GlassHostView`) whose first child is a Jetpack
|
|
326
|
+
Compose view drawing Kyant's `drawBackdrop` modifier. Your React children are regular React
|
|
327
|
+
Native views on top of that layer — except in `AndroidGlassButton`, where they are drawn _inside_
|
|
328
|
+
the glass so they stretch and swell with it.
|
|
329
|
+
|
|
330
|
+
### Seeing the React Native screen behind it
|
|
331
|
+
|
|
332
|
+
Kyant's library can only see Compose content behind a glass. Here the backdrop is the Android
|
|
333
|
+
view tree of the window — your React Native screen — captured with an approach adapted from
|
|
334
|
+
[QWEA0/Liquid-Glass-Android](https://github.com/QWEA0/Liquid-Glass-Android):
|
|
335
|
+
|
|
336
|
+
1. The glass records the area of the window around itself (plus a 32 dp margin for blur and for
|
|
337
|
+
glass that grows while pressed) into a `RenderNode`.
|
|
338
|
+
2. Its own ancestors are being drawn at that very moment, and calling their `draw()` again would
|
|
339
|
+
crash, so their background and children are drawn one by one instead, in their real drawing
|
|
340
|
+
order (`zIndex` included).
|
|
341
|
+
3. Every other subtree is recorded as a _reference_ to its RenderNode rather than as pixels, so
|
|
342
|
+
when content behind the glass animates, the glass shows it without capturing again.
|
|
343
|
+
4. Other glass views are left out of the capture, except the glass's own ancestors: a toggle on
|
|
344
|
+
a glass card sees the card. This rules out cycles (glass A → glass B → glass A).
|
|
345
|
+
|
|
346
|
+
### The effects
|
|
347
|
+
|
|
348
|
+
The capture goes through Kyant's effect chain on the GPU: blur (`RenderEffect`, Android 12+),
|
|
349
|
+
refraction at the rim (an AGSL runtime shader, Android 13+) with optional chromatic aberration,
|
|
350
|
+
vibrancy, a rim highlight and a drop shadow. Where these APIs are missing, the glass falls back
|
|
351
|
+
to a flat `fallbackColor` surface.
|
|
352
|
+
|
|
353
|
+
### When it captures again
|
|
354
|
+
|
|
355
|
+
The capture is cached in one RenderNode with its own GPU layer, and every glass layer of a view
|
|
356
|
+
(the tab bar has three) samples that same texture. It is recorded again only when:
|
|
357
|
+
|
|
358
|
+
- the glass moves on screen (layout, transform, dragging),
|
|
359
|
+
- a parent scrolls,
|
|
360
|
+
- a glass view is added or removed.
|
|
361
|
+
|
|
362
|
+
A glass view that is off screen waits until it is visible again. Pressing or dragging a glass
|
|
363
|
+
control only re-runs the GPU effects, not the capture.
|
|
364
|
+
|
|
365
|
+
### Controlled props
|
|
366
|
+
|
|
367
|
+
Toggles, sliders and the tab bar are dragged natively. So that a late `value` from JS never
|
|
368
|
+
pulls the thumb back, a prop only wins once JS has handled every event the control sent — the
|
|
369
|
+
handshake React Native's `TextInput` uses.
|
|
370
|
+
|
|
371
|
+
### Minimize on scroll
|
|
372
|
+
|
|
373
|
+
JS decides the direction (`useMinimizeOnScrollHandler`) and sends the bar a single boolean; the
|
|
374
|
+
shrinking itself is animated natively in Compose. The provider shares that state between every
|
|
375
|
+
screen.
|
|
376
|
+
|
|
377
|
+
## Performance
|
|
378
|
+
|
|
379
|
+
The glass costs nothing while nothing moves. The cost comes when many glass views have to be
|
|
380
|
+
redrawn in the same frame: every one of them runs its blur and refraction on the GPU.
|
|
381
|
+
|
|
382
|
+
Measured with `adb shell dumpsys gfxinfo` in the example app on a mid-range phone: Xiaomi
|
|
383
|
+
24117RN76E, MediaTek Helio G99, Android 16, 120 Hz. The app was a debuggable development build.
|
|
384
|
+
That mostly slows the UI thread; the glass effects run on Android's RenderThread and GPU,
|
|
385
|
+
which a release build does not speed up much.
|
|
386
|
+
|
|
387
|
+
| Screen | Glass views visible | Result |
|
|
388
|
+
| -------------------------------------------------------------------------- | ------------------- | --------------------------------------------------------------------------------- |
|
|
389
|
+
| Static screen, nothing moving | 2 | 0 frames rendered while idle |
|
|
390
|
+
| Scrolling a list under a glass header, a glass button and the tab bar | 3 | 94% of frames on time |
|
|
391
|
+
| 6 glass tiles over an animated backdrop, plus glass panels and controls | 15+ | about 20–24 fps; the RenderThread spends about 40 ms per frame issuing GPU work |
|
|
392
|
+
|
|
393
|
+
In practice:
|
|
394
|
+
|
|
395
|
+
- A glass header, a tab bar and a few glass controls on a scrolling screen stay smooth.
|
|
396
|
+
- Many glass views redrawing at once — over an animation, or all scrolling together — will
|
|
397
|
+
drop frames on mid-range GPUs. Keep those to a handful.
|
|
398
|
+
- Don't put a glass view inside every item of a long list: each visible item captures and
|
|
399
|
+
redraws on every scroll frame.
|
|
400
|
+
- Glass views scrolled out of view don't capture again until they are visible.
|
|
401
|
+
- On Android 11 and older the glass is a flat surface and costs nothing extra.
|
|
315
402
|
|
|
316
403
|
## Limitations
|
|
317
404
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-android-glass-view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Liquid Glass views, buttons, sliders and toggles for React Native on Android (Jetpack Compose, powered by Kyant0/AndroidLiquidGlass)",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -51,7 +51,7 @@ export type AndroidGlassBottomTabsProps = ViewProps & {
|
|
|
51
51
|
/** Called when the user taps a tab or drops the droplet on one. */
|
|
52
52
|
onTabSelected?: (index: number) => void;
|
|
53
53
|
/**
|
|
54
|
-
* Minimizes the bar
|
|
54
|
+
* Minimizes the bar (an addition of this package): it gets shorter and narrower, each tab keeps
|
|
55
55
|
* only its first child (the icon) and the rest (the label) fades out. Animated natively. Inside a
|
|
56
56
|
* `MinimizeOnScrollProvider`, leave it out: the bar follows the provider. Android only.
|
|
57
57
|
*/
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"lib": [
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
"lib": [
|
|
4
|
+
"dom",
|
|
5
|
+
"DOM.Iterable",
|
|
6
|
+
"esnext"
|
|
7
|
+
],
|
|
8
|
+
"types": [
|
|
9
|
+
"jest"
|
|
10
|
+
],
|
|
11
|
+
"typeRoots": [
|
|
12
|
+
"./ts-declarations",
|
|
13
|
+
"./node_modules/@types"
|
|
14
|
+
],
|
|
6
15
|
"jsx": "react-native",
|
|
7
16
|
"target": "esnext",
|
|
8
17
|
"moduleResolution": "bundler",
|
|
@@ -23,6 +32,12 @@
|
|
|
23
32
|
"rootDir": "./src",
|
|
24
33
|
"outDir": "./build"
|
|
25
34
|
},
|
|
26
|
-
"include": [
|
|
27
|
-
|
|
35
|
+
"include": [
|
|
36
|
+
"./src"
|
|
37
|
+
],
|
|
38
|
+
"exclude": [
|
|
39
|
+
"**/__mocks__/*",
|
|
40
|
+
"**/__tests__/*"
|
|
41
|
+
],
|
|
42
|
+
"extends": "expo/tsconfig.base"
|
|
28
43
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';
|
|
3
|
-
export default function AndroidGlassBottomTabs({ selectedIndex, onTabSelected, minimized, onMinimizedChange, accentColor, containerColor, children, style, ...rest }: AndroidGlassBottomTabsProps): React.JSX.Element;
|
|
4
|
-
//# sourceMappingURL=AndroidGlassBottomTabs.android.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AndroidGlassBottomTabs.android.d.ts","sourceRoot":"","sources":["../src/AndroidGlassBottomTabs.android.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAuBlF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,aAAa,EACb,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,KAAK,EACL,GAAG,IAAI,EACR,EAAE,2BAA2B,qBAgD7B"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { requireNativeView } from 'expo';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { StyleSheet, View } from 'react-native';
|
|
4
|
-
import { MinimizedStateContext } from './MinimizeOnScroll';
|
|
5
|
-
import { toNativeColor } from './utils';
|
|
6
|
-
const NativeAndroidGlassBottomTabs = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassBottomTabs');
|
|
7
|
-
export default function AndroidGlassBottomTabs({ selectedIndex, onTabSelected, minimized, onMinimizedChange, accentColor, containerColor, children, style, ...rest }) {
|
|
8
|
-
const tabs = React.Children.toArray(children).filter(React.isValidElement);
|
|
9
|
-
// Without a `selectedIndex` prop, the bar keeps the user's selection.
|
|
10
|
-
const [ownIndex, setOwnIndex] = React.useState(0);
|
|
11
|
-
// Sent back with `selectedIndex`, so the native side can tell a stale index (JS still catching
|
|
12
|
-
// up with earlier selections) from a current one.
|
|
13
|
-
const [eventCount, setEventCount] = React.useState(0);
|
|
14
|
-
const selected = selectedIndex ?? ownIndex;
|
|
15
|
-
// Inside a MinimizeOnScrollProvider, the bar follows the shared state unless `minimized` is given.
|
|
16
|
-
const shared = React.useContext(MinimizedStateContext);
|
|
17
|
-
const followsProvider = minimized === undefined;
|
|
18
|
-
return (<NativeAndroidGlassBottomTabs accessibilityRole="tablist" {...rest} style={[styles.bar, style]} selectedIndex={selected} tabsCount={tabs.length} mostRecentEventCount={eventCount} minimized={minimized ?? shared?.minimized ?? false} accentColor={toNativeColor(accentColor)} containerColor={toNativeColor(containerColor)} onTabSelected={(event) => {
|
|
19
|
-
const { index, eventCount: count } = event.nativeEvent;
|
|
20
|
-
setEventCount((current) => Math.max(current, count));
|
|
21
|
-
setOwnIndex(index);
|
|
22
|
-
onTabSelected?.(index);
|
|
23
|
-
}} onMinimizedChange={(event) => {
|
|
24
|
-
const value = event.nativeEvent.minimized;
|
|
25
|
-
if (followsProvider)
|
|
26
|
-
shared?.setMinimized(value);
|
|
27
|
-
onMinimizedChange?.(value);
|
|
28
|
-
}}>
|
|
29
|
-
{tabs.map((tab, index) => (
|
|
30
|
-
// The native bar handles taps and drags, and draws these views itself (inside the glass
|
|
31
|
-
// and, tinted, under the droplet), so they must stay real views and not take touches.
|
|
32
|
-
<View key={tab.key ?? index} collapsable={false} pointerEvents="none" accessibilityRole="tab" accessibilityState={{ selected: index === selected }} style={styles.tab}>
|
|
33
|
-
{tab}
|
|
34
|
-
</View>))}
|
|
35
|
-
</NativeAndroidGlassBottomTabs>);
|
|
36
|
-
}
|
|
37
|
-
const styles = StyleSheet.create({
|
|
38
|
-
// 4 dp side padding keeps the tabs aligned with the droplet: (width - 8 dp) / count each.
|
|
39
|
-
bar: {
|
|
40
|
-
height: 64,
|
|
41
|
-
flexDirection: 'row',
|
|
42
|
-
paddingHorizontal: 4,
|
|
43
|
-
},
|
|
44
|
-
tab: {
|
|
45
|
-
flex: 1,
|
|
46
|
-
alignItems: 'center',
|
|
47
|
-
justifyContent: 'center',
|
|
48
|
-
gap: 2,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=AndroidGlassBottomTabs.android.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AndroidGlassBottomTabs.android.js","sourceRoot":"","sources":["../src/AndroidGlassBottomTabs.android.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAkB1D,MAAM,4BAA4B,GAChC,iBAAiB,CAAC,sBAAsB,EAAE,wBAAwB,CAAC,CAAC;AAEtE,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,aAAa,EACb,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,KAAK,EACL,GAAG,IAAI,EACqB;IAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc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AAiB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC;YAC1C,IAAI,eAAe;gBAAE,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YACjD,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC,CAAC,CACF;MAAA,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;QACxB,wFAAwF;QACxF,sFAAsF;QACtF,CAAC,IAAI,CACH,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,KAAK,CAAC,CACtB,WAAW,CAAC,CAAC,KAAK,CAAC,CACnB,aAAa,CAAC,MAAM,CACpB,iBAAiB,CAAC,KAAK,CACvB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,KAAK,QAAQ,EAAE,CAAC,CACrD,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAClB;UAAA,CAAC,GAAG,CACN;QAAA,EAAE,IAAI,CAAC,CACR,CAAC,CACJ;IAAA,EAAE,4BAA4B,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,0FAA0F;IAC1F,GAAG,EAAE;QACH,MAAM,EAAE,EAAE;QACV,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,CAAC;KACrB;IACD,GAAG,EAAE;QACH,IAAI,EAAE,CAAC;QACP,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,GAAG,EAAE,CAAC;KACP;CACF,CAAC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { StyleSheet, View } from 'react-native';\n\nimport type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';\nimport { MinimizedStateContext } from './MinimizeOnScroll';\nimport { type NativeColor, toNativeColor } from './utils';\n\ntype IndexEvent = { nativeEvent: { index: number; eventCount: number } };\ntype MinimizedEvent = { nativeEvent: { minimized: boolean } };\n\ntype NativeAndroidGlassBottomTabsProps = Omit<\n AndroidGlassBottomTabsProps,\n 'onTabSelected' | 'onMinimizedChange' | 'accentColor' | 'containerColor'\n> & {\n tabsCount: number;\n /** Count of the last selection event handled here (see ControlledProp on the native side). */\n mostRecentEventCount: number;\n onTabSelected: (event: IndexEvent) => void;\n onMinimizedChange: (event: MinimizedEvent) => void;\n accentColor?: NativeColor;\n containerColor?: NativeColor;\n};\n\nconst NativeAndroidGlassBottomTabs: React.ComponentType<NativeAndroidGlassBottomTabsProps> =\n requireNativeView('ExpoAndroidGlassView', 'AndroidGlassBottomTabs');\n\nexport default function AndroidGlassBottomTabs({\n selectedIndex,\n onTabSelected,\n minimized,\n onMinimizedChange,\n accentColor,\n containerColor,\n children,\n style,\n ...rest\n}: AndroidGlassBottomTabsProps) {\n const tabs = React.Children.toArray(children).filter(React.isValidElement);\n // Without a `selectedIndex` prop, the bar keeps the user's selection.\n const [ownIndex, setOwnIndex] = React.useState(0);\n // Sent back with `selectedIndex`, so the native side can tell a stale index (JS still catching\n // up with earlier selections) from a current one.\n const [eventCount, setEventCount] = React.useState(0);\n const selected = selectedIndex ?? ownIndex;\n // Inside a MinimizeOnScrollProvider, the bar follows the shared state unless `minimized` is given.\n const shared = React.useContext(MinimizedStateContext);\n const followsProvider = minimized === undefined;\n return (\n <NativeAndroidGlassBottomTabs\n accessibilityRole=\"tablist\"\n {...rest}\n style={[styles.bar, style]}\n selectedIndex={selected}\n tabsCount={tabs.length}\n mostRecentEventCount={eventCount}\n minimized={minimized ?? shared?.minimized ?? false}\n accentColor={toNativeColor(accentColor)}\n containerColor={toNativeColor(containerColor)}\n onTabSelected={(event) => {\n const { index, eventCount: count } = event.nativeEvent;\n setEventCount((current) => Math.max(current, count));\n setOwnIndex(index);\n onTabSelected?.(index);\n }}\n onMinimizedChange={(event) => {\n const value = event.nativeEvent.minimized;\n if (followsProvider) shared?.setMinimized(value);\n onMinimizedChange?.(value);\n }}>\n {tabs.map((tab, index) => (\n // The native bar handles taps and drags, and draws these views itself (inside the glass\n // and, tinted, under the droplet), so they must stay real views and not take touches.\n <View\n key={tab.key ?? index}\n collapsable={false}\n pointerEvents=\"none\"\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: index === selected }}\n style={styles.tab}>\n {tab}\n </View>\n ))}\n </NativeAndroidGlassBottomTabs>\n );\n}\n\nconst styles = StyleSheet.create({\n // 4 dp side padding keeps the tabs aligned with the droplet: (width - 8 dp) / count each.\n bar: {\n height: 64,\n flexDirection: 'row',\n paddingHorizontal: 4,\n },\n tab: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n },\n});\n"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';
|
|
3
|
-
/** iOS and web fallback: a plain tab bar with the same API (it does not minimize). */
|
|
4
|
-
export default function AndroidGlassBottomTabs({ selectedIndex, onTabSelected, minimized: _minimized, onMinimizedChange: _onMinimizedChange, accentColor: _accentColor, containerColor, children, style, ...rest }: AndroidGlassBottomTabsProps): React.JSX.Element;
|
|
5
|
-
//# sourceMappingURL=AndroidGlassBottomTabs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AndroidGlassBottomTabs.d.ts","sourceRoot":"","sources":["../src/AndroidGlassBottomTabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAElF,sFAAsF;AACtF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,aAAiB,EACjB,aAAa,EACb,SAAS,EAAE,UAAU,EACrB,iBAAiB,EAAE,kBAAkB,EACrC,WAAW,EAAE,YAAY,EACzB,cAAc,EACd,QAAQ,EACR,KAAK,EACL,GAAG,IAAI,EACR,EAAE,2BAA2B,qBAuB7B"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
-
/** iOS and web fallback: a plain tab bar with the same API (it does not minimize). */
|
|
4
|
-
export default function AndroidGlassBottomTabs({ selectedIndex = 0, onTabSelected, minimized: _minimized, onMinimizedChange: _onMinimizedChange, accentColor: _accentColor, containerColor, children, style, ...rest }) {
|
|
5
|
-
const tabs = React.Children.toArray(children).filter(React.isValidElement);
|
|
6
|
-
return (<View accessibilityRole="tablist" {...rest} style={[
|
|
7
|
-
styles.bar,
|
|
8
|
-
{ backgroundColor: containerColor ?? 'rgba(250, 250, 250, 0.9)' },
|
|
9
|
-
style,
|
|
10
|
-
]}>
|
|
11
|
-
{tabs.map((tab, index) => (<Pressable key={tab.key ?? index} accessibilityRole="tab" accessibilityState={{ selected: index === selectedIndex }} onPress={() => onTabSelected?.(index)} style={[styles.tab, index === selectedIndex && styles.selected]}>
|
|
12
|
-
{tab}
|
|
13
|
-
</Pressable>))}
|
|
14
|
-
</View>);
|
|
15
|
-
}
|
|
16
|
-
const styles = StyleSheet.create({
|
|
17
|
-
bar: {
|
|
18
|
-
height: 64,
|
|
19
|
-
flexDirection: 'row',
|
|
20
|
-
padding: 4,
|
|
21
|
-
borderRadius: 32,
|
|
22
|
-
},
|
|
23
|
-
tab: {
|
|
24
|
-
flex: 1,
|
|
25
|
-
alignItems: 'center',
|
|
26
|
-
justifyContent: 'center',
|
|
27
|
-
gap: 2,
|
|
28
|
-
borderRadius: 28,
|
|
29
|
-
},
|
|
30
|
-
selected: {
|
|
31
|
-
backgroundColor: 'rgba(0, 0, 0, 0.08)',
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=AndroidGlassBottomTabs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3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AA,EAAE,SAAS,CAAC,CACb,CAAC,CACJ;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,GAAG,EAAE;QACH,MAAM,EAAE,EAAE;QACV,aAAa,EAAE,KAAK;QACpB,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,EAAE;KACjB;IACD,GAAG,EAAE;QACH,IAAI,EAAE,CAAC;QACP,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,GAAG,EAAE,CAAC;QACN,YAAY,EAAE,EAAE;KACjB;IACD,QAAQ,EAAE;QACR,eAAe,EAAE,qBAAqB;KACvC;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { Pressable, StyleSheet, View } from 'react-native';\n\nimport type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';\n\n/** iOS and web fallback: a plain tab bar with the same API (it does not minimize). */\nexport default function AndroidGlassBottomTabs({\n selectedIndex = 0,\n onTabSelected,\n minimized: _minimized,\n onMinimizedChange: _onMinimizedChange,\n accentColor: _accentColor,\n containerColor,\n children,\n style,\n ...rest\n}: AndroidGlassBottomTabsProps) {\n const tabs = React.Children.toArray(children).filter(React.isValidElement);\n return (\n <View\n accessibilityRole=\"tablist\"\n {...rest}\n style={[\n styles.bar,\n { backgroundColor: containerColor ?? 'rgba(250, 250, 250, 0.9)' },\n style,\n ]}>\n {tabs.map((tab, index) => (\n <Pressable\n key={tab.key ?? index}\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: index === selectedIndex }}\n onPress={() => onTabSelected?.(index)}\n style={[styles.tab, index === selectedIndex && styles.selected]}>\n {tab}\n </Pressable>\n ))}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n bar: {\n height: 64,\n flexDirection: 'row',\n padding: 4,\n borderRadius: 32,\n },\n tab: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n borderRadius: 28,\n },\n selected: {\n backgroundColor: 'rgba(0, 0, 0, 0.08)',\n },\n});\n"]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { AndroidGlassButtonProps } from './AndroidGlassComponents.types';
|
|
3
|
-
export default function AndroidGlassButton({ onPress, title, titleStyle, cornerRadius, tintColor, surfaceColor, fallbackColor, style, children, ...rest }: AndroidGlassButtonProps): React.JSX.Element;
|
|
4
|
-
//# sourceMappingURL=AndroidGlassButton.android.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AndroidGlassButton.android.d.ts","sourceRoot":"","sources":["../src/AndroidGlassButton.android.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAgB9E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,OAAO,EACP,KAAK,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,aAAa,EACb,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,uBAAuB,qBAoBzB"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { requireNativeView } from 'expo';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { StyleSheet, Text } from 'react-native';
|
|
4
|
-
import { toNativeColor } from './utils';
|
|
5
|
-
const NativeAndroidGlassButton = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassButton');
|
|
6
|
-
export default function AndroidGlassButton({ onPress, title, titleStyle, cornerRadius, tintColor, surfaceColor, fallbackColor, style, children, ...rest }) {
|
|
7
|
-
const borderRadius = StyleSheet.flatten(style)?.borderRadius;
|
|
8
|
-
return (<NativeAndroidGlassButton accessibilityRole="button" {...rest} style={[styles.button, style]} cornerRadius={cornerRadius ?? (typeof borderRadius === 'number' ? borderRadius : undefined)} tintColor={toNativeColor(tintColor)} surfaceColor={toNativeColor(surfaceColor)} fallbackColor={toNativeColor(fallbackColor)} onPress={onPress ? () => onPress() : undefined}>
|
|
9
|
-
{title != null ? (<Text style={[styles.title, tintColor != null && styles.titleOnTint, titleStyle]}>
|
|
10
|
-
{title}
|
|
11
|
-
</Text>) : null}
|
|
12
|
-
{children}
|
|
13
|
-
</NativeAndroidGlassButton>);
|
|
14
|
-
}
|
|
15
|
-
const styles = StyleSheet.create({
|
|
16
|
-
button: {
|
|
17
|
-
height: 48,
|
|
18
|
-
paddingHorizontal: 16,
|
|
19
|
-
flexDirection: 'row',
|
|
20
|
-
alignItems: 'center',
|
|
21
|
-
justifyContent: 'center',
|
|
22
|
-
gap: 8,
|
|
23
|
-
},
|
|
24
|
-
title: {
|
|
25
|
-
fontSize: 15,
|
|
26
|
-
color: '#000000',
|
|
27
|
-
},
|
|
28
|
-
titleOnTint: {
|
|
29
|
-
color: '#ffffff',
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=AndroidGlassButton.android.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AndroidGlassButton.android.js","sourceRoot":"","sources":["../src/AndroidGlassButton.android.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAY1D,MAAM,wBAAwB,GAC5B,iBAAiB,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;AAElE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,OAAO,EACP,KAAK,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,aAAa,EACb,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACiB;IACxB,MAAM,YAAY,G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;QACZ,KAAK,EAAE,SAAS;KACjB;IACD,WAAW,EAAE;QACX,KAAK,EAAE,SAAS;KACjB;CACF,CAAC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { StyleSheet, Text } from 'react-native';\n\nimport type { AndroidGlassButtonProps } from './AndroidGlassComponents.types';\nimport { type NativeColor, toNativeColor } from './utils';\n\ntype NativeAndroidGlassButtonProps = Omit<\n AndroidGlassButtonProps,\n 'tintColor' | 'surfaceColor' | 'fallbackColor' | 'onPress' | 'title' | 'titleStyle'\n> & {\n tintColor?: NativeColor;\n surfaceColor?: NativeColor;\n fallbackColor?: NativeColor;\n onPress?: () => void;\n};\n\nconst NativeAndroidGlassButton: React.ComponentType<NativeAndroidGlassButtonProps> =\n requireNativeView('ExpoAndroidGlassView', 'AndroidGlassButton');\n\nexport default function AndroidGlassButton({\n onPress,\n title,\n titleStyle,\n cornerRadius,\n tintColor,\n surfaceColor,\n fallbackColor,\n style,\n children,\n ...rest\n}: AndroidGlassButtonProps) {\n const borderRadius = StyleSheet.flatten(style)?.borderRadius;\n return (\n <NativeAndroidGlassButton\n accessibilityRole=\"button\"\n {...rest}\n style={[styles.button, style]}\n cornerRadius={cornerRadius ?? (typeof borderRadius === 'number' ? borderRadius : undefined)}\n tintColor={toNativeColor(tintColor)}\n surfaceColor={toNativeColor(surfaceColor)}\n fallbackColor={toNativeColor(fallbackColor)}\n onPress={onPress ? () => onPress() : undefined}>\n {title != null ? (\n <Text style={[styles.title, tintColor != null && styles.titleOnTint, titleStyle]}>\n {title}\n </Text>\n ) : null}\n {children}\n </NativeAndroidGlassButton>\n );\n}\n\nconst styles = StyleSheet.create({\n button: {\n height: 48,\n paddingHorizontal: 16,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 8,\n },\n title: {\n fontSize: 15,\n color: '#000000',\n },\n titleOnTint: {\n color: '#ffffff',\n },\n});\n"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { AndroidGlassButtonProps } from './AndroidGlassComponents.types';
|
|
3
|
-
/** iOS and web fallback: a translucent capsule button with the same API. */
|
|
4
|
-
export default function AndroidGlassButton({ onPress, title, titleStyle, cornerRadius, tintColor, surfaceColor, fallbackColor, style, children, blurRadius: _blurRadius, refractionHeight: _refractionHeight, refractionAmount: _refractionAmount, chromaticAberration: _chromaticAberration, depthEffect: _depthEffect, vibrancy: _vibrancy, highlight: _highlight, shadow: _shadow, interactive: _interactive, ...rest }: AndroidGlassButtonProps): React.JSX.Element;
|
|
5
|
-
//# sourceMappingURL=AndroidGlassButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AndroidGlassButton.d.ts","sourceRoot":"","sources":["../src/AndroidGlassButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAI9E,4EAA4E;AAC5E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,OAAO,EACP,KAAK,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,aAAa,EACb,KAAK,EACL,QAAQ,EACR,UAAU,EAAE,WAAW,EACvB,gBAAgB,EAAE,iBAAiB,EACnC,gBAAgB,EAAE,iBAAiB,EACnC,mBAAmB,EAAE,oBAAoB,EACzC,WAAW,EAAE,YAAY,EACzB,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,YAAY,EACzB,GAAG,IAAI,EACR,EAAE,uBAAuB,qBAuBzB"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Pressable, StyleSheet, Text } from 'react-native';
|
|
3
|
-
const DEFAULT_FALLBACK_COLOR = 'rgba(255, 255, 255, 0.7)';
|
|
4
|
-
/** iOS and web fallback: a translucent capsule button with the same API. */
|
|
5
|
-
export default function AndroidGlassButton({ onPress, title, titleStyle, cornerRadius, tintColor, surfaceColor, fallbackColor, style, children, blurRadius: _blurRadius, refractionHeight: _refractionHeight, refractionAmount: _refractionAmount, chromaticAberration: _chromaticAberration, depthEffect: _depthEffect, vibrancy: _vibrancy, highlight: _highlight, shadow: _shadow, interactive: _interactive, ...rest }) {
|
|
6
|
-
return (<Pressable accessibilityRole="button" {...rest} onPress={onPress} style={({ pressed }) => [
|
|
7
|
-
styles.button,
|
|
8
|
-
{
|
|
9
|
-
backgroundColor: tintColor ?? surfaceColor ?? fallbackColor ?? DEFAULT_FALLBACK_COLOR,
|
|
10
|
-
borderRadius: cornerRadius ?? 999,
|
|
11
|
-
opacity: pressed ? 0.75 : 1,
|
|
12
|
-
},
|
|
13
|
-
style,
|
|
14
|
-
]}>
|
|
15
|
-
{title != null ? (<Text style={[styles.title, tintColor != null && styles.titleOnTint, titleStyle]}>
|
|
16
|
-
{title}
|
|
17
|
-
</Text>) : null}
|
|
18
|
-
{children}
|
|
19
|
-
</Pressable>);
|
|
20
|
-
}
|
|
21
|
-
const styles = StyleSheet.create({
|
|
22
|
-
button: {
|
|
23
|
-
height: 48,
|
|
24
|
-
paddingHorizontal: 16,
|
|
25
|
-
flexDirection: 'row',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
justifyContent: 'center',
|
|
28
|
-
gap: 8,
|
|
29
|
-
},
|
|
30
|
-
title: {
|
|
31
|
-
fontSize: 15,
|
|
32
|
-
color: '#000000',
|
|
33
|
-
},
|
|
34
|
-
titleOnTint: {
|
|
35
|
-
color: '#ffffff',
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=AndroidGlassButton.js.map
|