expo-android-glass-view 0.1.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/CHANGELOG.md +13 -0
- package/LICENSE +55 -0
- package/README.md +260 -0
- package/THIRD_PARTY_NOTICES.md +44 -0
- package/android/build.gradle +39 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/androidglassview/AndroidGlassBottomTabs.kt +162 -0
- package/android/src/main/java/expo/modules/androidglassview/AndroidGlassButton.kt +45 -0
- package/android/src/main/java/expo/modules/androidglassview/AndroidGlassSlider.kt +84 -0
- package/android/src/main/java/expo/modules/androidglassview/AndroidGlassToggle.kt +59 -0
- package/android/src/main/java/expo/modules/androidglassview/AndroidGlassView.kt +21 -0
- package/android/src/main/java/expo/modules/androidglassview/ControlledProp.kt +30 -0
- package/android/src/main/java/expo/modules/androidglassview/ExpoAndroidGlassViewModule.kt +210 -0
- package/android/src/main/java/expo/modules/androidglassview/GlassHostView.kt +346 -0
- package/android/src/main/java/expo/modules/androidglassview/GlassRegistry.kt +31 -0
- package/android/src/main/java/expo/modules/androidglassview/GlassSurface.kt +96 -0
- package/android/src/main/java/expo/modules/androidglassview/ViewBackdrop.kt +151 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/Backdrop.kt +25 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/BackdropEffectScope.kt +82 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/DrawBackdropModifier.kt +397 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/Platform.kt +18 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/RuntimeShader.kt +94 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/RuntimeShaderCache.kt +28 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/Backdrop.kt +45 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/CanvasBackdrop.kt +43 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/CombinedBackdrop.kt +107 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/EmptyBackdrop.kt +33 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/LayerBackdrop.kt +82 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/backdrops/LayerBackdropModifier.kt +77 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/effects/Blur.kt +37 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/effects/ColorFilter.kt +83 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/effects/Lens.kt +117 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/effects/RenderEffect.kt +41 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/highlight/Highlight.kt +36 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/highlight/HighlightModifier.kt +174 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/highlight/HighlightStyle.kt +146 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/InverseLayerScope.kt +138 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/LayerRecorder.kt +34 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/Outline.kt +26 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/Paint.kt +24 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/RenderEffect.kt +58 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/Shaders.kt +206 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/internal/ShapeProvider.kt +52 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/shadow/InnerShadow.kt +49 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/shadow/InnerShadowModifier.kt +166 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/shadow/Shadow.kt +35 -0
- package/android/src/main/java/expo/modules/androidglassview/backdrop/shadow/ShadowModifier.kt +145 -0
- package/android/src/main/java/expo/modules/androidglassview/capture/ViewBackdropCapture.kt +176 -0
- package/android/src/main/java/expo/modules/androidglassview/components/CapsuleShape.kt +10 -0
- package/android/src/main/java/expo/modules/androidglassview/components/DampedDragAnimation.kt +152 -0
- package/android/src/main/java/expo/modules/androidglassview/components/DragGestureInspector.kt +91 -0
- package/android/src/main/java/expo/modules/androidglassview/components/InteractiveHighlight.kt +127 -0
- package/android/src/main/java/expo/modules/androidglassview/components/LiquidBottomTabs.kt +471 -0
- package/android/src/main/java/expo/modules/androidglassview/components/LiquidButton.kt +111 -0
- package/android/src/main/java/expo/modules/androidglassview/components/LiquidSlider.kt +227 -0
- package/android/src/main/java/expo/modules/androidglassview/components/LiquidToggle.kt +220 -0
- package/android/src/main/java/expo/modules/androidglassview/components/TabsFrame.kt +18 -0
- package/build/AndroidGlassBottomTabs.android.d.ts +4 -0
- package/build/AndroidGlassBottomTabs.android.d.ts.map +1 -0
- package/build/AndroidGlassBottomTabs.android.js +42 -0
- package/build/AndroidGlassBottomTabs.android.js.map +1 -0
- package/build/AndroidGlassBottomTabs.d.ts +5 -0
- package/build/AndroidGlassBottomTabs.d.ts.map +1 -0
- package/build/AndroidGlassBottomTabs.js +34 -0
- package/build/AndroidGlassBottomTabs.js.map +1 -0
- package/build/AndroidGlassButton.android.d.ts +4 -0
- package/build/AndroidGlassButton.android.d.ts.map +1 -0
- package/build/AndroidGlassButton.android.js +32 -0
- package/build/AndroidGlassButton.android.js.map +1 -0
- package/build/AndroidGlassButton.d.ts +5 -0
- package/build/AndroidGlassButton.d.ts.map +1 -0
- package/build/AndroidGlassButton.js +38 -0
- package/build/AndroidGlassButton.js.map +1 -0
- package/build/AndroidGlassComponents.types.d.ts +71 -0
- package/build/AndroidGlassComponents.types.d.ts.map +1 -0
- package/build/AndroidGlassComponents.types.js +2 -0
- package/build/AndroidGlassComponents.types.js.map +1 -0
- package/build/AndroidGlassSlider.android.d.ts +4 -0
- package/build/AndroidGlassSlider.android.d.ts.map +1 -0
- package/build/AndroidGlassSlider.android.js +27 -0
- package/build/AndroidGlassSlider.android.js.map +1 -0
- package/build/AndroidGlassSlider.d.ts +5 -0
- package/build/AndroidGlassSlider.d.ts.map +1 -0
- package/build/AndroidGlassSlider.js +47 -0
- package/build/AndroidGlassSlider.js.map +1 -0
- package/build/AndroidGlassTab.d.ts +9 -0
- package/build/AndroidGlassTab.d.ts.map +1 -0
- package/build/AndroidGlassTab.js +22 -0
- package/build/AndroidGlassTab.js.map +1 -0
- package/build/AndroidGlassToggle.android.d.ts +4 -0
- package/build/AndroidGlassToggle.android.d.ts.map +1 -0
- package/build/AndroidGlassToggle.android.js +27 -0
- package/build/AndroidGlassToggle.android.js.map +1 -0
- package/build/AndroidGlassToggle.d.ts +5 -0
- package/build/AndroidGlassToggle.d.ts.map +1 -0
- package/build/AndroidGlassToggle.js +7 -0
- package/build/AndroidGlassToggle.js.map +1 -0
- package/build/AndroidGlassView.android.d.ts +4 -0
- package/build/AndroidGlassView.android.d.ts.map +1 -0
- package/build/AndroidGlassView.android.js +10 -0
- package/build/AndroidGlassView.android.js.map +1 -0
- package/build/AndroidGlassView.d.ts +8 -0
- package/build/AndroidGlassView.d.ts.map +1 -0
- package/build/AndroidGlassView.js +18 -0
- package/build/AndroidGlassView.js.map +1 -0
- package/build/AndroidGlassView.types.d.ts +34 -0
- package/build/AndroidGlassView.types.d.ts.map +1 -0
- package/build/AndroidGlassView.types.js +2 -0
- package/build/AndroidGlassView.types.js.map +1 -0
- package/build/index.d.ts +10 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +12 -0
- package/build/index.js.map +1 -0
- package/build/useMinimizeOnScroll.d.ts +17 -0
- package/build/useMinimizeOnScroll.d.ts.map +1 -0
- package/build/useMinimizeOnScroll.js +39 -0
- package/build/useMinimizeOnScroll.js.map +1 -0
- package/build/utils.d.ts +5 -0
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +9 -0
- package/build/utils.js.map +1 -0
- package/expo-module.config.json +6 -0
- package/package.json +58 -0
- package/src/AndroidGlassBottomTabs.android.tsx +93 -0
- package/src/AndroidGlassBottomTabs.tsx +59 -0
- package/src/AndroidGlassButton.android.tsx +70 -0
- package/src/AndroidGlassButton.tsx +70 -0
- package/src/AndroidGlassComponents.types.ts +76 -0
- package/src/AndroidGlassSlider.android.tsx +70 -0
- package/src/AndroidGlassSlider.tsx +78 -0
- package/src/AndroidGlassTab.tsx +29 -0
- package/src/AndroidGlassToggle.android.tsx +64 -0
- package/src/AndroidGlassToggle.tsx +22 -0
- package/src/AndroidGlassView.android.tsx +41 -0
- package/src/AndroidGlassView.tsx +41 -0
- package/src/AndroidGlassView.types.ts +34 -0
- package/src/index.ts +11 -0
- package/src/useMinimizeOnScroll.ts +53 -0
- package/src/utils.ts +10 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,38 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassButton.js","sourceRoot":"","sources":["../src/AndroidGlassButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAI3D,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAE1D,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,EACiB;IACxB,OAAO,CACL,CAAC,SAAS,CACR,iBAAiB,CAAC,QAAQ,CAC1B,IAAI,IAAI,CAAC,CACT,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YACtB,MAAM,CAAC,MAAM;YACb;gBACE,eAAe,EAAE,SAAS,IAAI,YAAY,IAAI,aAAa,IAAI,sBAAsB;gBACrF,YAAY,EAAE,YAAY,IAAI,GAAG;gBACjC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAC5B;YACD,KAAK;SACN,CAAC,CACF;MAAA,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CACf,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,IAAI,IAAI,IAAI,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAC/E;UAAA,CAAC,KAAK,CACR;QAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,IAAI,CACR;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE;QACN,MAAM,EAAE,EAAE;QACV,iBAAiB,EAAE,EAAE;QACrB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,GAAG,EAAE,CAAC;KACP;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,SAAS;KACjB;IACD,WAAW,EAAE;QACX,KAAK,EAAE,SAAS;KACjB;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { Pressable, StyleSheet, Text } from 'react-native';\n\nimport type { AndroidGlassButtonProps } from './AndroidGlassComponents.types';\n\nconst DEFAULT_FALLBACK_COLOR = 'rgba(255, 255, 255, 0.7)';\n\n/** iOS and web fallback: a translucent capsule button with the same API. */\nexport default function AndroidGlassButton({\n onPress,\n title,\n titleStyle,\n cornerRadius,\n tintColor,\n surfaceColor,\n fallbackColor,\n style,\n children,\n blurRadius: _blurRadius,\n refractionHeight: _refractionHeight,\n refractionAmount: _refractionAmount,\n chromaticAberration: _chromaticAberration,\n depthEffect: _depthEffect,\n vibrancy: _vibrancy,\n highlight: _highlight,\n shadow: _shadow,\n interactive: _interactive,\n ...rest\n}: AndroidGlassButtonProps) {\n return (\n <Pressable\n accessibilityRole=\"button\"\n {...rest}\n onPress={onPress}\n style={({ pressed }) => [\n styles.button,\n {\n backgroundColor: tintColor ?? surfaceColor ?? fallbackColor ?? DEFAULT_FALLBACK_COLOR,\n borderRadius: cornerRadius ?? 999,\n opacity: pressed ? 0.75 : 1,\n },\n style,\n ]}>\n {title != null ? (\n <Text style={[styles.title, tintColor != null && styles.titleOnTint, titleStyle]}>\n {title}\n </Text>\n ) : null}\n {children}\n </Pressable>\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"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ColorValue, StyleProp, TextStyle, ViewProps } from 'react-native';
|
|
3
|
+
import type { AndroidGlassViewProps } from './AndroidGlassView.types';
|
|
4
|
+
/**
|
|
5
|
+
* Accepts every `AndroidGlassView` glass prop. `cornerRadius` defaults to a capsule.
|
|
6
|
+
* Children (label, icon, …) are drawn inside the glass and follow its press deformation; they
|
|
7
|
+
* are decorative, so don't put interactive elements in a button.
|
|
8
|
+
*/
|
|
9
|
+
export type AndroidGlassButtonProps = AndroidGlassViewProps & {
|
|
10
|
+
/** Called when the button is tapped. */
|
|
11
|
+
onPress?: () => void;
|
|
12
|
+
/** Convenience label, rendered before the children. */
|
|
13
|
+
title?: string;
|
|
14
|
+
titleStyle?: StyleProp<TextStyle>;
|
|
15
|
+
/**
|
|
16
|
+
* Press and drag feedback: the glass stretches towards the finger and a highlight follows it.
|
|
17
|
+
* Default true.
|
|
18
|
+
*/
|
|
19
|
+
interactive?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type AndroidGlassToggleProps = ViewProps & {
|
|
22
|
+
value?: boolean;
|
|
23
|
+
onValueChange?: (value: boolean) => void;
|
|
24
|
+
/** Track colour when on. Default iOS green. */
|
|
25
|
+
accentColor?: ColorValue;
|
|
26
|
+
/** Track colour when off. */
|
|
27
|
+
trackColor?: ColorValue;
|
|
28
|
+
};
|
|
29
|
+
export type AndroidGlassSliderProps = ViewProps & {
|
|
30
|
+
value?: number;
|
|
31
|
+
/** Default 0. */
|
|
32
|
+
minimumValue?: number;
|
|
33
|
+
/** Default 1. */
|
|
34
|
+
maximumValue?: number;
|
|
35
|
+
/** Called continuously while the thumb is dragged. */
|
|
36
|
+
onValueChange?: (value: number) => void;
|
|
37
|
+
/** Called once when the finger is lifted, or after a tap on the track. */
|
|
38
|
+
onSlidingComplete?: (value: number) => void;
|
|
39
|
+
/** Colour of the filled part of the track. Default system blue. */
|
|
40
|
+
accentColor?: ColorValue;
|
|
41
|
+
trackColor?: ColorValue;
|
|
42
|
+
};
|
|
43
|
+
export type AndroidGlassBottomTabsProps = ViewProps & {
|
|
44
|
+
/** Index of the selected tab. */
|
|
45
|
+
selectedIndex?: number;
|
|
46
|
+
/** Called when the user taps a tab or drops the droplet on one. */
|
|
47
|
+
onTabSelected?: (index: number) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Minimizes the bar, like iOS 26 tab bars on scroll: it gets shorter and narrower, each tab keeps
|
|
50
|
+
* only its first child (the icon) and the rest (the label) fades out. Animated natively; usually
|
|
51
|
+
* driven by `useMinimizeOnScroll`. Android only.
|
|
52
|
+
*/
|
|
53
|
+
minimized?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Called with `false` when the user expands the minimized bar by touching it. Pass the
|
|
56
|
+
* `setMinimized` of `useMinimizeOnScroll`, so the next scroll down minimizes it again.
|
|
57
|
+
*/
|
|
58
|
+
onMinimizedChange?: (minimized: boolean) => void;
|
|
59
|
+
/** Colour the selected tab's content takes under the droplet. Default system blue. */
|
|
60
|
+
accentColor?: ColorValue;
|
|
61
|
+
/** Colour of the glass bar. */
|
|
62
|
+
containerColor?: ColorValue;
|
|
63
|
+
/** One child per tab, e.g. `AndroidGlassTab`. Tabs get equal widths. */
|
|
64
|
+
children?: ReactNode;
|
|
65
|
+
};
|
|
66
|
+
export type AndroidGlassTabProps = {
|
|
67
|
+
icon?: ReactNode;
|
|
68
|
+
label?: string;
|
|
69
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=AndroidGlassComponents.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassComponents.types.d.ts","sourceRoot":"","sources":["../src/AndroidGlassComponents.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,qBAAqB,GAAG;IAC5D,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,+CAA+C;IAC/C,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,mEAAmE;IACnE,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,SAAS,GAAG;IACpD,iCAAiC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,sFAAsF;IACtF,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,+BAA+B;IAC/B,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassComponents.types.js","sourceRoot":"","sources":["../src/AndroidGlassComponents.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode } from 'react';\nimport type { ColorValue, StyleProp, TextStyle, ViewProps } from 'react-native';\n\nimport type { AndroidGlassViewProps } from './AndroidGlassView.types';\n\n/**\n * Accepts every `AndroidGlassView` glass prop. `cornerRadius` defaults to a capsule.\n * Children (label, icon, …) are drawn inside the glass and follow its press deformation; they\n * are decorative, so don't put interactive elements in a button.\n */\nexport type AndroidGlassButtonProps = AndroidGlassViewProps & {\n /** Called when the button is tapped. */\n onPress?: () => void;\n /** Convenience label, rendered before the children. */\n title?: string;\n titleStyle?: StyleProp<TextStyle>;\n /**\n * Press and drag feedback: the glass stretches towards the finger and a highlight follows it.\n * Default true.\n */\n interactive?: boolean;\n};\n\nexport type AndroidGlassToggleProps = ViewProps & {\n value?: boolean;\n onValueChange?: (value: boolean) => void;\n /** Track colour when on. Default iOS green. */\n accentColor?: ColorValue;\n /** Track colour when off. */\n trackColor?: ColorValue;\n};\n\nexport type AndroidGlassSliderProps = ViewProps & {\n value?: number;\n /** Default 0. */\n minimumValue?: number;\n /** Default 1. */\n maximumValue?: number;\n /** Called continuously while the thumb is dragged. */\n onValueChange?: (value: number) => void;\n /** Called once when the finger is lifted, or after a tap on the track. */\n onSlidingComplete?: (value: number) => void;\n /** Colour of the filled part of the track. Default system blue. */\n accentColor?: ColorValue;\n trackColor?: ColorValue;\n};\n\nexport type AndroidGlassBottomTabsProps = ViewProps & {\n /** Index of the selected tab. */\n selectedIndex?: number;\n /** Called when the user taps a tab or drops the droplet on one. */\n onTabSelected?: (index: number) => void;\n /**\n * Minimizes the bar, like iOS 26 tab bars on scroll: it gets shorter and narrower, each tab keeps\n * only its first child (the icon) and the rest (the label) fades out. Animated natively; usually\n * driven by `useMinimizeOnScroll`. Android only.\n */\n minimized?: boolean;\n /**\n * Called with `false` when the user expands the minimized bar by touching it. Pass the\n * `setMinimized` of `useMinimizeOnScroll`, so the next scroll down minimizes it again.\n */\n onMinimizedChange?: (minimized: boolean) => void;\n /** Colour the selected tab's content takes under the droplet. Default system blue. */\n accentColor?: ColorValue;\n /** Colour of the glass bar. */\n containerColor?: ColorValue;\n /** One child per tab, e.g. `AndroidGlassTab`. Tabs get equal widths. */\n children?: ReactNode;\n};\n\nexport type AndroidGlassTabProps = {\n icon?: ReactNode;\n label?: string;\n labelStyle?: StyleProp<TextStyle>;\n};\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AndroidGlassSliderProps } from './AndroidGlassComponents.types';
|
|
3
|
+
export default function AndroidGlassSlider({ value, minimumValue, maximumValue, onValueChange, onSlidingComplete, accentColor, trackColor, style, ...rest }: AndroidGlassSliderProps): React.JSX.Element;
|
|
4
|
+
//# sourceMappingURL=AndroidGlassSlider.android.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassSlider.android.d.ts","sourceRoot":"","sources":["../src/AndroidGlassSlider.android.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAoB9E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,KAAK,EACL,GAAG,IAAI,EACR,EAAE,uBAAuB,qBA4BzB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import { toNativeColor } from './utils';
|
|
5
|
+
const NativeAndroidGlassSlider = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassSlider');
|
|
6
|
+
export default function AndroidGlassSlider({ value, minimumValue, maximumValue, onValueChange, onSlidingComplete, accentColor, trackColor, style, ...rest }) {
|
|
7
|
+
const min = minimumValue ?? 0;
|
|
8
|
+
// Without a `value` prop, the slider keeps the position the user gives it.
|
|
9
|
+
const [ownValue, setOwnValue] = React.useState(min);
|
|
10
|
+
// Sent back with `value`, so the native side can tell a stale value (JS still catching up with
|
|
11
|
+
// earlier events) from a current one.
|
|
12
|
+
const [eventCount, setEventCount] = React.useState(0);
|
|
13
|
+
const handleEvent = (event) => {
|
|
14
|
+
const { value: next, eventCount: count } = event.nativeEvent;
|
|
15
|
+
setEventCount((current) => Math.max(current, count));
|
|
16
|
+
setOwnValue(next);
|
|
17
|
+
return next;
|
|
18
|
+
};
|
|
19
|
+
return (<NativeAndroidGlassSlider accessibilityRole="adjustable" {...rest} style={[styles.slider, style]} value={value ?? ownValue} minimumValue={min} maximumValue={maximumValue ?? 1} mostRecentEventCount={eventCount} accentColor={toNativeColor(accentColor)} trackColor={toNativeColor(trackColor)} onValueChange={(event) => onValueChange?.(handleEvent(event))} onSlidingComplete={(event) => onSlidingComplete?.(handleEvent(event))}/>);
|
|
20
|
+
}
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
slider: {
|
|
23
|
+
height: 36,
|
|
24
|
+
alignSelf: 'stretch',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=AndroidGlassSlider.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassSlider.android.js","sourceRoot":"","sources":["../src/AndroidGlassSlider.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,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAgB1D,MAAM,wBAAwB,GAC5B,iBAAiB,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;AAElE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,KAAK,EACL,GAAG,IAAI,EACiB;IACxB,MAAM,GAAG,GAAG,YAAY,IAAI,CAAC,CAAC;IAC9B,2EAA2E;IAC3E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpD,+FAA+F;IAC/F,sCAAsC;IACtC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,WAAW,GAAG,CAAC,KAAiB,EAAE,EAAE;QACxC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC;QAC7D,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QACrD,WAAW,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IACF,OAAO,CACL,CAAC,wBAAwB,CACvB,iBAAiB,CAAC,YAAY,CAC9B,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAC9B,KAAK,CAAC,CAAC,KAAK,IAAI,QAAQ,CAAC,CACzB,YAAY,CAAC,CAAC,GAAG,CAAC,CAClB,YAAY,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,CAChC,oBAAoB,CAAC,CAAC,UAAU,CAAC,CACjC,WAAW,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CACxC,UAAU,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CACtC,aAAa,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAC9D,iBAAiB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EACtE,CACH,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE;QACN,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,SAAS;KACrB;CACF,CAAC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport type { AndroidGlassSliderProps } from './AndroidGlassComponents.types';\nimport { type NativeColor, toNativeColor } from './utils';\n\ntype ValueEvent = { nativeEvent: { value: number; eventCount: number } };\n\ntype NativeAndroidGlassSliderProps = Omit<\n AndroidGlassSliderProps,\n 'onValueChange' | 'onSlidingComplete' | 'accentColor' | 'trackColor'\n> & {\n /** Count of the last event handled here (see ControlledProp on the native side). */\n mostRecentEventCount: number;\n onValueChange: (event: ValueEvent) => void;\n onSlidingComplete: (event: ValueEvent) => void;\n accentColor?: NativeColor;\n trackColor?: NativeColor;\n};\n\nconst NativeAndroidGlassSlider: React.ComponentType<NativeAndroidGlassSliderProps> =\n requireNativeView('ExpoAndroidGlassView', 'AndroidGlassSlider');\n\nexport default function AndroidGlassSlider({\n value,\n minimumValue,\n maximumValue,\n onValueChange,\n onSlidingComplete,\n accentColor,\n trackColor,\n style,\n ...rest\n}: AndroidGlassSliderProps) {\n const min = minimumValue ?? 0;\n // Without a `value` prop, the slider keeps the position the user gives it.\n const [ownValue, setOwnValue] = React.useState(min);\n // Sent back with `value`, so the native side can tell a stale value (JS still catching up with\n // earlier events) from a current one.\n const [eventCount, setEventCount] = React.useState(0);\n const handleEvent = (event: ValueEvent) => {\n const { value: next, eventCount: count } = event.nativeEvent;\n setEventCount((current) => Math.max(current, count));\n setOwnValue(next);\n return next;\n };\n return (\n <NativeAndroidGlassSlider\n accessibilityRole=\"adjustable\"\n {...rest}\n style={[styles.slider, style]}\n value={value ?? ownValue}\n minimumValue={min}\n maximumValue={maximumValue ?? 1}\n mostRecentEventCount={eventCount}\n accentColor={toNativeColor(accentColor)}\n trackColor={toNativeColor(trackColor)}\n onValueChange={(event) => onValueChange?.(handleEvent(event))}\n onSlidingComplete={(event) => onSlidingComplete?.(handleEvent(event))}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n slider: {\n height: 36,\n alignSelf: 'stretch',\n },\n});\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AndroidGlassSliderProps } from './AndroidGlassComponents.types';
|
|
3
|
+
/** iOS and web fallback: a plain slider with the same API. */
|
|
4
|
+
export default function AndroidGlassSlider({ value, minimumValue, maximumValue, onValueChange, onSlidingComplete, accentColor, trackColor, style, onLayout, ...rest }: AndroidGlassSliderProps): React.JSX.Element;
|
|
5
|
+
//# sourceMappingURL=AndroidGlassSlider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassSlider.d.ts","sourceRoot":"","sources":["../src/AndroidGlassSlider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,8DAA8D;AAC9D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAS,EACT,YAAgB,EAChB,YAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,WAAuB,EACvB,UAAuC,EACvC,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,uBAAuB,qBA+BzB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
/** iOS and web fallback: a plain slider with the same API. */
|
|
4
|
+
export default function AndroidGlassSlider({ value = 0, minimumValue = 0, maximumValue = 1, onValueChange, onSlidingComplete, accentColor = '#0088FF', trackColor = 'rgba(120, 120, 120, 0.2)', style, onLayout, ...rest }) {
|
|
5
|
+
const [width, setWidth] = React.useState(0);
|
|
6
|
+
const range = maximumValue - minimumValue || 1;
|
|
7
|
+
const progress = Math.min(1, Math.max(0, (value - minimumValue) / range));
|
|
8
|
+
const valueAt = (event) => minimumValue + Math.min(1, Math.max(0, event.nativeEvent.locationX / (width || 1))) * range;
|
|
9
|
+
return (<View accessibilityRole="adjustable" {...rest} onStartShouldSetResponder={() => true} onMoveShouldSetResponder={() => true} onResponderTerminationRequest={() => false} onResponderGrant={(event) => onValueChange?.(valueAt(event))} onResponderMove={(event) => onValueChange?.(valueAt(event))} onResponderRelease={(event) => onSlidingComplete?.(valueAt(event))} onLayout={(event) => {
|
|
10
|
+
setWidth(event.nativeEvent.layout.width);
|
|
11
|
+
onLayout?.(event);
|
|
12
|
+
}} style={[styles.container, style]}>
|
|
13
|
+
<View pointerEvents="none" style={[styles.track, { backgroundColor: trackColor }]}>
|
|
14
|
+
<View style={[styles.fill, { width: `${progress * 100}%`, backgroundColor: accentColor }]}/>
|
|
15
|
+
</View>
|
|
16
|
+
<View pointerEvents="none" style={[styles.thumb, { left: `${progress * 100}%` }]}/>
|
|
17
|
+
</View>);
|
|
18
|
+
}
|
|
19
|
+
const styles = StyleSheet.create({
|
|
20
|
+
container: {
|
|
21
|
+
height: 36,
|
|
22
|
+
alignSelf: 'stretch',
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
},
|
|
25
|
+
track: {
|
|
26
|
+
height: 6,
|
|
27
|
+
borderRadius: 3,
|
|
28
|
+
overflow: 'hidden',
|
|
29
|
+
},
|
|
30
|
+
fill: {
|
|
31
|
+
height: '100%',
|
|
32
|
+
},
|
|
33
|
+
thumb: {
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
width: 40,
|
|
36
|
+
height: 24,
|
|
37
|
+
marginLeft: -20,
|
|
38
|
+
borderRadius: 12,
|
|
39
|
+
backgroundColor: '#ffffff',
|
|
40
|
+
shadowColor: '#000000',
|
|
41
|
+
shadowOpacity: 0.15,
|
|
42
|
+
shadowRadius: 4,
|
|
43
|
+
shadowOffset: { width: 0, height: 1 },
|
|
44
|
+
elevation: 2,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=AndroidGlassSlider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassSlider.js","sourceRoot":"","sources":["../src/AndroidGlassSlider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA8B,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAI5E,8DAA8D;AAC9D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,GAAG,CAAC,EACT,YAAY,GAAG,CAAC,EAChB,YAAY,GAAG,CAAC,EAChB,aAAa,EACb,iBAAiB,EACjB,WAAW,GAAG,SAAS,EACvB,UAAU,GAAG,0BAA0B,EACvC,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACiB;IACxB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,YAAY,GAAG,YAAY,IAAI,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAE1E,MAAM,OAAO,GAAG,CAAC,KAA4B,EAAE,EAAE,CAC/C,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,SAAS,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IAE9F,OAAO,CACL,CAAC,IAAI,CACH,iBAAiB,CAAC,YAAY,CAC9B,IAAI,IAAI,CAAC,CACT,yBAAyB,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CACtC,wBAAwB,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CACrC,6BAA6B,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAC3C,gBAAgB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAC7D,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAC5D,kBAAkB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CACnE,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YAClB,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CACF,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CACjC;MAAA,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,CAAC,CAChF;QAAA,CAAC,IAAI,CACH,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,QAAQ,GAAG,GAAG,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,CAAC,EAExF;MAAA,EAAE,IAAI,CACN;MAAA,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,QAAQ,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC,EACnF;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,SAAS;QACpB,cAAc,EAAE,QAAQ;KACzB;IACD,KAAK,EAAE;QACL,MAAM,EAAE,CAAC;QACT,YAAY,EAAE,CAAC;QACf,QAAQ,EAAE,QAAQ;KACnB;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM;KACf;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,CAAC,EAAE;QACf,YAAY,EAAE,EAAE;QAChB,eAAe,EAAE,SAAS;QAC1B,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,IAAI;QACnB,YAAY,EAAE,CAAC;QACf,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QACrC,SAAS,EAAE,CAAC;KACb;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { type GestureResponderEvent, StyleSheet, View } from 'react-native';\n\nimport type { AndroidGlassSliderProps } from './AndroidGlassComponents.types';\n\n/** iOS and web fallback: a plain slider with the same API. */\nexport default function AndroidGlassSlider({\n value = 0,\n minimumValue = 0,\n maximumValue = 1,\n onValueChange,\n onSlidingComplete,\n accentColor = '#0088FF',\n trackColor = 'rgba(120, 120, 120, 0.2)',\n style,\n onLayout,\n ...rest\n}: AndroidGlassSliderProps) {\n const [width, setWidth] = React.useState(0);\n const range = maximumValue - minimumValue || 1;\n const progress = Math.min(1, Math.max(0, (value - minimumValue) / range));\n\n const valueAt = (event: GestureResponderEvent) =>\n minimumValue + Math.min(1, Math.max(0, event.nativeEvent.locationX / (width || 1))) * range;\n\n return (\n <View\n accessibilityRole=\"adjustable\"\n {...rest}\n onStartShouldSetResponder={() => true}\n onMoveShouldSetResponder={() => true}\n onResponderTerminationRequest={() => false}\n onResponderGrant={(event) => onValueChange?.(valueAt(event))}\n onResponderMove={(event) => onValueChange?.(valueAt(event))}\n onResponderRelease={(event) => onSlidingComplete?.(valueAt(event))}\n onLayout={(event) => {\n setWidth(event.nativeEvent.layout.width);\n onLayout?.(event);\n }}\n style={[styles.container, style]}>\n <View pointerEvents=\"none\" style={[styles.track, { backgroundColor: trackColor }]}>\n <View\n style={[styles.fill, { width: `${progress * 100}%`, backgroundColor: accentColor }]}\n />\n </View>\n <View pointerEvents=\"none\" style={[styles.thumb, { left: `${progress * 100}%` }]} />\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n height: 36,\n alignSelf: 'stretch',\n justifyContent: 'center',\n },\n track: {\n height: 6,\n borderRadius: 3,\n overflow: 'hidden',\n },\n fill: {\n height: '100%',\n },\n thumb: {\n position: 'absolute',\n width: 40,\n height: 24,\n marginLeft: -20,\n borderRadius: 12,\n backgroundColor: '#ffffff',\n shadowColor: '#000000',\n shadowOpacity: 0.15,\n shadowRadius: 4,\n shadowOffset: { width: 0, height: 1 },\n elevation: 2,\n },\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AndroidGlassTabProps } from './AndroidGlassComponents.types';
|
|
3
|
+
/**
|
|
4
|
+
* An icon over a label, like Kyant's LiquidBottomTab. Use as a child of AndroidGlassBottomTabs.
|
|
5
|
+
* The icon gets a view of its own: a minimized tab bar keeps each tab's first child and fades the
|
|
6
|
+
* rest (the label) out.
|
|
7
|
+
*/
|
|
8
|
+
export default function AndroidGlassTab({ icon, label, labelStyle }: AndroidGlassTabProps): React.JSX.Element;
|
|
9
|
+
//# sourceMappingURL=AndroidGlassTab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassTab.d.ts","sourceRoot":"","sources":["../src/AndroidGlassTab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,oBAAoB,qBAWxF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
/**
|
|
4
|
+
* An icon over a label, like Kyant's LiquidBottomTab. Use as a child of AndroidGlassBottomTabs.
|
|
5
|
+
* The icon gets a view of its own: a minimized tab bar keeps each tab's first child and fades the
|
|
6
|
+
* rest (the label) out.
|
|
7
|
+
*/
|
|
8
|
+
export default function AndroidGlassTab({ icon, label, labelStyle }) {
|
|
9
|
+
return (<>
|
|
10
|
+
{icon != null ? <View collapsable={false}>{icon}</View> : null}
|
|
11
|
+
{label != null ? (<Text numberOfLines={1} style={[styles.label, labelStyle]}>
|
|
12
|
+
{label}
|
|
13
|
+
</Text>) : null}
|
|
14
|
+
</>);
|
|
15
|
+
}
|
|
16
|
+
const styles = StyleSheet.create({
|
|
17
|
+
label: {
|
|
18
|
+
fontSize: 12,
|
|
19
|
+
color: '#000000',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=AndroidGlassTab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassTab.js","sourceRoot":"","sources":["../src/AndroidGlassTab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAItD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAwB;IACvF,OAAO,CACL,EACE;MAAA,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAC9D;MAAA,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CACf,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CACxD;UAAA,CAAC,KAAK,CACR;QAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,IAAI,CACV;IAAA,GAAG,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,SAAS;KACjB;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { StyleSheet, Text, View } from 'react-native';\n\nimport type { AndroidGlassTabProps } from './AndroidGlassComponents.types';\n\n/**\n * An icon over a label, like Kyant's LiquidBottomTab. Use as a child of AndroidGlassBottomTabs.\n * The icon gets a view of its own: a minimized tab bar keeps each tab's first child and fades the\n * rest (the label) out.\n */\nexport default function AndroidGlassTab({ icon, label, labelStyle }: AndroidGlassTabProps) {\n return (\n <>\n {icon != null ? <View collapsable={false}>{icon}</View> : null}\n {label != null ? (\n <Text numberOfLines={1} style={[styles.label, labelStyle]}>\n {label}\n </Text>\n ) : null}\n </>\n );\n}\n\nconst styles = StyleSheet.create({\n label: {\n fontSize: 12,\n color: '#000000',\n },\n});\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AndroidGlassToggleProps } from './AndroidGlassComponents.types';
|
|
3
|
+
export default function AndroidGlassToggle({ value, onValueChange, accentColor, trackColor, style, ...rest }: AndroidGlassToggleProps): React.JSX.Element;
|
|
4
|
+
//# sourceMappingURL=AndroidGlassToggle.android.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassToggle.android.d.ts","sourceRoot":"","sources":["../src/AndroidGlassToggle.android.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAmB9E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,KAAK,EACL,GAAG,IAAI,EACR,EAAE,uBAAuB,qBAyBzB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import { toNativeColor } from './utils';
|
|
5
|
+
const NativeAndroidGlassToggle = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassToggle');
|
|
6
|
+
export default function AndroidGlassToggle({ value, onValueChange, accentColor, trackColor, style, ...rest }) {
|
|
7
|
+
// Without a `value` prop, the switch keeps the user's choice.
|
|
8
|
+
const [ownValue, setOwnValue] = React.useState(false);
|
|
9
|
+
// Sent back with `value`, so the native side can tell a stale value (JS still catching up with
|
|
10
|
+
// earlier changes) from a current one.
|
|
11
|
+
const [eventCount, setEventCount] = React.useState(0);
|
|
12
|
+
const checked = value ?? ownValue;
|
|
13
|
+
return (<NativeAndroidGlassToggle accessibilityRole="switch" accessibilityState={{ checked }} {...rest} style={[styles.toggle, style]} value={checked} mostRecentEventCount={eventCount} accentColor={toNativeColor(accentColor)} trackColor={toNativeColor(trackColor)} onValueChange={(event) => {
|
|
14
|
+
const { value: next, eventCount: count } = event.nativeEvent;
|
|
15
|
+
setEventCount((current) => Math.max(current, count));
|
|
16
|
+
setOwnValue(next);
|
|
17
|
+
onValueChange?.(next);
|
|
18
|
+
}}/>);
|
|
19
|
+
}
|
|
20
|
+
const styles = StyleSheet.create({
|
|
21
|
+
// The track is 64 × 28 dp; the thumb grows past it while pressed.
|
|
22
|
+
toggle: {
|
|
23
|
+
width: 64,
|
|
24
|
+
height: 28,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=AndroidGlassToggle.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassToggle.android.js","sourceRoot":"","sources":["../src/AndroidGlassToggle.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,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAe1D,MAAM,wBAAwB,GAC5B,iBAAiB,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;AAElE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,KAAK,EACL,GAAG,IAAI,EACiB;IACxB,8DAA8D;IAC9D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,+FAA+F;IAC/F,uCAAuC;IACvC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC;IAClC,OAAO,CACL,CAAC,wBAAwB,CACvB,iBAAiB,CAAC,QAAQ,CAC1B,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAChC,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAC9B,KAAK,CAAC,CAAC,OAAO,CAAC,CACf,oBAAoB,CAAC,CAAC,UAAU,CAAC,CACjC,WAAW,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CACxC,UAAU,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CACtC,aAAa,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACvB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC;YAC7D,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YACrD,WAAW,CAAC,IAAI,CAAC,CAAC;YAClB,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC,EACF,CACH,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,kEAAkE;IAClE,MAAM,EAAE;QACN,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;KACX;CACF,CAAC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport type { AndroidGlassToggleProps } from './AndroidGlassComponents.types';\nimport { type NativeColor, toNativeColor } from './utils';\n\ntype ValueEvent = { nativeEvent: { value: boolean; eventCount: number } };\n\ntype NativeAndroidGlassToggleProps = Omit<\n AndroidGlassToggleProps,\n 'onValueChange' | 'accentColor' | 'trackColor'\n> & {\n /** Count of the last change event handled here (see ControlledProp on the native side). */\n mostRecentEventCount: number;\n onValueChange: (event: ValueEvent) => void;\n accentColor?: NativeColor;\n trackColor?: NativeColor;\n};\n\nconst NativeAndroidGlassToggle: React.ComponentType<NativeAndroidGlassToggleProps> =\n requireNativeView('ExpoAndroidGlassView', 'AndroidGlassToggle');\n\nexport default function AndroidGlassToggle({\n value,\n onValueChange,\n accentColor,\n trackColor,\n style,\n ...rest\n}: AndroidGlassToggleProps) {\n // Without a `value` prop, the switch keeps the user's choice.\n const [ownValue, setOwnValue] = React.useState(false);\n // Sent back with `value`, so the native side can tell a stale value (JS still catching up with\n // earlier changes) from a current one.\n const [eventCount, setEventCount] = React.useState(0);\n const checked = value ?? ownValue;\n return (\n <NativeAndroidGlassToggle\n accessibilityRole=\"switch\"\n accessibilityState={{ checked }}\n {...rest}\n style={[styles.toggle, style]}\n value={checked}\n mostRecentEventCount={eventCount}\n accentColor={toNativeColor(accentColor)}\n trackColor={toNativeColor(trackColor)}\n onValueChange={(event) => {\n const { value: next, eventCount: count } = event.nativeEvent;\n setEventCount((current) => Math.max(current, count));\n setOwnValue(next);\n onValueChange?.(next);\n }}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n // The track is 64 × 28 dp; the thumb grows past it while pressed.\n toggle: {\n width: 64,\n height: 28,\n },\n});\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AndroidGlassToggleProps } from './AndroidGlassComponents.types';
|
|
3
|
+
/** iOS and web fallback: the platform switch with the same API. */
|
|
4
|
+
export default function AndroidGlassToggle({ value, onValueChange, accentColor, trackColor, ...rest }: AndroidGlassToggleProps): React.JSX.Element;
|
|
5
|
+
//# sourceMappingURL=AndroidGlassToggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassToggle.d.ts","sourceRoot":"","sources":["../src/AndroidGlassToggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,mEAAmE;AACnE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,GAAG,IAAI,EACR,EAAE,uBAAuB,qBASzB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Switch } from 'react-native';
|
|
3
|
+
/** iOS and web fallback: the platform switch with the same API. */
|
|
4
|
+
export default function AndroidGlassToggle({ value, onValueChange, accentColor, trackColor, ...rest }) {
|
|
5
|
+
return (<Switch {...rest} value={value ?? false} onValueChange={onValueChange} trackColor={{ false: trackColor ?? undefined, true: accentColor ?? '#34C759' }}/>);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=AndroidGlassToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassToggle.js","sourceRoot":"","sources":["../src/AndroidGlassToggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,mEAAmE;AACnE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,GAAG,IAAI,EACiB;IACxB,OAAO,CACL,CAAC,MAAM,CACL,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,CACtB,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,IAAI,SAAS,EAAE,IAAI,EAAE,WAAW,IAAI,SAAS,EAAE,CAAC,EAC/E,CACH,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { Switch } from 'react-native';\n\nimport type { AndroidGlassToggleProps } from './AndroidGlassComponents.types';\n\n/** iOS and web fallback: the platform switch with the same API. */\nexport default function AndroidGlassToggle({\n value,\n onValueChange,\n accentColor,\n trackColor,\n ...rest\n}: AndroidGlassToggleProps) {\n return (\n <Switch\n {...rest}\n value={value ?? false}\n onValueChange={onValueChange}\n trackColor={{ false: trackColor ?? undefined, true: accentColor ?? '#34C759' }}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AndroidGlassViewProps } from './AndroidGlassView.types';
|
|
3
|
+
export default function AndroidGlassView({ cornerRadius, tintColor, surfaceColor, fallbackColor, style, ...rest }: AndroidGlassViewProps): React.JSX.Element;
|
|
4
|
+
//# sourceMappingURL=AndroidGlassView.android.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassView.android.d.ts","sourceRoot":"","sources":["../src/AndroidGlassView.android.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAiBtE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,aAAa,EACb,KAAK,EACL,GAAG,IAAI,EACR,EAAE,qBAAqB,qBAYvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import { toNativeColor } from './utils';
|
|
5
|
+
const NativeAndroidGlassView = requireNativeView('ExpoAndroidGlassView', 'AndroidGlassView');
|
|
6
|
+
export default function AndroidGlassView({ cornerRadius, tintColor, surfaceColor, fallbackColor, style, ...rest }) {
|
|
7
|
+
const borderRadius = StyleSheet.flatten(style)?.borderRadius;
|
|
8
|
+
return (<NativeAndroidGlassView {...rest} style={style} cornerRadius={cornerRadius ?? (typeof borderRadius === 'number' ? borderRadius : undefined)} tintColor={toNativeColor(tintColor)} surfaceColor={toNativeColor(surfaceColor)} fallbackColor={toNativeColor(fallbackColor)}/>);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=AndroidGlassView.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassView.android.js","sourceRoot":"","sources":["../src/AndroidGlassView.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,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAW1D,MAAM,sBAAsB,GAAqD,iBAAiB,CAChG,sBAAsB,EACtB,kBAAkB,CACnB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,aAAa,EACb,KAAK,EACL,GAAG,IAAI,EACe;IACtB,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC7D,OAAO,CACL,CAAC,sBAAsB,CACrB,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,YAAY,CAAC,CAAC,YAAY,IAAI,CAAC,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5F,SAAS,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CACpC,YAAY,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAC1C,aAAa,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,EAC5C,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport type { AndroidGlassViewProps } from './AndroidGlassView.types';\nimport { type NativeColor, toNativeColor } from './utils';\n\ntype NativeAndroidGlassViewProps = Omit<\n AndroidGlassViewProps,\n 'tintColor' | 'surfaceColor' | 'fallbackColor'\n> & {\n tintColor?: NativeColor;\n surfaceColor?: NativeColor;\n fallbackColor?: NativeColor;\n};\n\nconst NativeAndroidGlassView: React.ComponentType<NativeAndroidGlassViewProps> = requireNativeView(\n 'ExpoAndroidGlassView',\n 'AndroidGlassView'\n);\n\nexport default function AndroidGlassView({\n cornerRadius,\n tintColor,\n surfaceColor,\n fallbackColor,\n style,\n ...rest\n}: AndroidGlassViewProps) {\n const borderRadius = StyleSheet.flatten(style)?.borderRadius;\n return (\n <NativeAndroidGlassView\n {...rest}\n style={style}\n cornerRadius={cornerRadius ?? (typeof borderRadius === 'number' ? borderRadius : undefined)}\n tintColor={toNativeColor(tintColor)}\n surfaceColor={toNativeColor(surfaceColor)}\n fallbackColor={toNativeColor(fallbackColor)}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AndroidGlassViewProps } from './AndroidGlassView.types';
|
|
3
|
+
/**
|
|
4
|
+
* iOS and web fallback: the glass effect is Android-only, so render a plain translucent surface
|
|
5
|
+
* with the same shape. Children render as usual.
|
|
6
|
+
*/
|
|
7
|
+
export default function AndroidGlassView({ cornerRadius, fallbackColor, blurRadius: _blurRadius, refractionHeight: _refractionHeight, refractionAmount: _refractionAmount, chromaticAberration: _chromaticAberration, depthEffect: _depthEffect, vibrancy: _vibrancy, highlight: _highlight, shadow: _shadow, tintColor: _tintColor, surfaceColor: _surfaceColor, style, ...rest }: AndroidGlassViewProps): React.JSX.Element;
|
|
8
|
+
//# sourceMappingURL=AndroidGlassView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassView.d.ts","sourceRoot":"","sources":["../src/AndroidGlassView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAItE;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,YAAY,EACZ,aAAa,EACb,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,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,aAAa,EAC3B,KAAK,EACL,GAAG,IAAI,EACR,EAAE,qBAAqB,qBAcvB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
const DEFAULT_FALLBACK_COLOR = 'rgba(255, 255, 255, 0.7)';
|
|
4
|
+
/**
|
|
5
|
+
* iOS and web fallback: the glass effect is Android-only, so render a plain translucent surface
|
|
6
|
+
* with the same shape. Children render as usual.
|
|
7
|
+
*/
|
|
8
|
+
export default function AndroidGlassView({ cornerRadius, fallbackColor, blurRadius: _blurRadius, refractionHeight: _refractionHeight, refractionAmount: _refractionAmount, chromaticAberration: _chromaticAberration, depthEffect: _depthEffect, vibrancy: _vibrancy, highlight: _highlight, shadow: _shadow, tintColor: _tintColor, surfaceColor: _surfaceColor, style, ...rest }) {
|
|
9
|
+
return (<View {...rest} style={[
|
|
10
|
+
{
|
|
11
|
+
backgroundColor: fallbackColor ?? DEFAULT_FALLBACK_COLOR,
|
|
12
|
+
borderRadius: cornerRadius ?? 24,
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
},
|
|
15
|
+
style,
|
|
16
|
+
]}/>);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=AndroidGlassView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassView.js","sourceRoot":"","sources":["../src/AndroidGlassView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIpC,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,YAAY,EACZ,aAAa,EACb,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,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,aAAa,EAC3B,KAAK,EACL,GAAG,IAAI,EACe;IACtB,OAAO,CACL,CAAC,IAAI,CACH,IAAI,IAAI,CAAC,CACT,KAAK,CAAC,CAAC;YACL;gBACE,eAAe,EAAE,aAAa,IAAI,sBAAsB;gBACxD,YAAY,EAAE,YAAY,IAAI,EAAE;gBAChC,QAAQ,EAAE,QAAQ;aACnB;YACD,KAAK;SACN,CAAC,EACF,CACH,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\n\nimport type { AndroidGlassViewProps } from './AndroidGlassView.types';\n\nconst DEFAULT_FALLBACK_COLOR = 'rgba(255, 255, 255, 0.7)';\n\n/**\n * iOS and web fallback: the glass effect is Android-only, so render a plain translucent surface\n * with the same shape. Children render as usual.\n */\nexport default function AndroidGlassView({\n cornerRadius,\n fallbackColor,\n blurRadius: _blurRadius,\n refractionHeight: _refractionHeight,\n refractionAmount: _refractionAmount,\n chromaticAberration: _chromaticAberration,\n depthEffect: _depthEffect,\n vibrancy: _vibrancy,\n highlight: _highlight,\n shadow: _shadow,\n tintColor: _tintColor,\n surfaceColor: _surfaceColor,\n style,\n ...rest\n}: AndroidGlassViewProps) {\n return (\n <View\n {...rest}\n style={[\n {\n backgroundColor: fallbackColor ?? DEFAULT_FALLBACK_COLOR,\n borderRadius: cornerRadius ?? 24,\n overflow: 'hidden',\n },\n style,\n ]}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ColorValue, ViewProps } from 'react-native';
|
|
2
|
+
export type AndroidGlassViewProps = ViewProps & {
|
|
3
|
+
/**
|
|
4
|
+
* Corner radius of the glass shape, in dp. Falls back to `style.borderRadius`, then 24.
|
|
5
|
+
* Use a large value (e.g. 999) for a capsule.
|
|
6
|
+
*/
|
|
7
|
+
cornerRadius?: number;
|
|
8
|
+
/** Backdrop blur radius in dp. Default 2. `0` disables the blur. */
|
|
9
|
+
blurRadius?: number;
|
|
10
|
+
/** Width of the refracting rim in dp. Default 12. `0` disables refraction. */
|
|
11
|
+
refractionHeight?: number;
|
|
12
|
+
/** How far content is bent at the rim, in dp. Default 24. */
|
|
13
|
+
refractionAmount?: number;
|
|
14
|
+
/** Split the refraction per colour channel for a prism fringe. Default false. */
|
|
15
|
+
chromaticAberration?: boolean;
|
|
16
|
+
/** Stronger, depth-like bending towards the rim. Default false. */
|
|
17
|
+
depthEffect?: boolean;
|
|
18
|
+
/** Boost the saturation of what is behind the glass. Default true. */
|
|
19
|
+
vibrancy?: boolean;
|
|
20
|
+
/** Specular highlight along the rim. Default true. */
|
|
21
|
+
highlight?: boolean;
|
|
22
|
+
/** Soft drop shadow around the shape. Default true. */
|
|
23
|
+
shadow?: boolean;
|
|
24
|
+
/** Colour tint mixed into the glass. */
|
|
25
|
+
tintColor?: ColorValue;
|
|
26
|
+
/** Flat colour painted over the glass, on top of the refraction. */
|
|
27
|
+
surfaceColor?: ColorValue;
|
|
28
|
+
/**
|
|
29
|
+
* Surface colour used where the effect cannot run: Android 11 and older, iOS and web.
|
|
30
|
+
* Default `rgba(255, 255, 255, 0.7)`.
|
|
31
|
+
*/
|
|
32
|
+
fallbackColor?: ColorValue;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=AndroidGlassView.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassView.types.d.ts","sourceRoot":"","sources":["../src/AndroidGlassView.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG;IAC9C;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mEAAmE;IACnE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uDAAuD;IACvD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,oEAAoE;IACpE,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AndroidGlassView.types.js","sourceRoot":"","sources":["../src/AndroidGlassView.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ColorValue, ViewProps } from 'react-native';\n\nexport type AndroidGlassViewProps = ViewProps & {\n /**\n * Corner radius of the glass shape, in dp. Falls back to `style.borderRadius`, then 24.\n * Use a large value (e.g. 999) for a capsule.\n */\n cornerRadius?: number;\n /** Backdrop blur radius in dp. Default 2. `0` disables the blur. */\n blurRadius?: number;\n /** Width of the refracting rim in dp. Default 12. `0` disables refraction. */\n refractionHeight?: number;\n /** How far content is bent at the rim, in dp. Default 24. */\n refractionAmount?: number;\n /** Split the refraction per colour channel for a prism fringe. Default false. */\n chromaticAberration?: boolean;\n /** Stronger, depth-like bending towards the rim. Default false. */\n depthEffect?: boolean;\n /** Boost the saturation of what is behind the glass. Default true. */\n vibrancy?: boolean;\n /** Specular highlight along the rim. Default true. */\n highlight?: boolean;\n /** Soft drop shadow around the shape. Default true. */\n shadow?: boolean;\n /** Colour tint mixed into the glass. */\n tintColor?: ColorValue;\n /** Flat colour painted over the glass, on top of the refraction. */\n surfaceColor?: ColorValue;\n /**\n * Surface colour used where the effect cannot run: Android 11 and older, iOS and web.\n * Default `rgba(255, 255, 255, 0.7)`.\n */\n fallbackColor?: ColorValue;\n};\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as AndroidGlassView } from './AndroidGlassView';
|
|
2
|
+
export { default as AndroidGlassButton } from './AndroidGlassButton';
|
|
3
|
+
export { default as AndroidGlassToggle } from './AndroidGlassToggle';
|
|
4
|
+
export { default as AndroidGlassSlider } from './AndroidGlassSlider';
|
|
5
|
+
export { default as AndroidGlassBottomTabs } from './AndroidGlassBottomTabs';
|
|
6
|
+
export { default as AndroidGlassTab } from './AndroidGlassTab';
|
|
7
|
+
export { useMinimizeOnScroll, type MinimizeOnScroll } from './useMinimizeOnScroll';
|
|
8
|
+
export * from './AndroidGlassView.types';
|
|
9
|
+
export * from './AndroidGlassComponents.types';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACnF,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Each component resolves to its native Android implementation (*.android.tsx) on Android, and
|
|
2
|
+
// to a plain fallback with the same API on iOS and web.
|
|
3
|
+
export { default as AndroidGlassView } from './AndroidGlassView';
|
|
4
|
+
export { default as AndroidGlassButton } from './AndroidGlassButton';
|
|
5
|
+
export { default as AndroidGlassToggle } from './AndroidGlassToggle';
|
|
6
|
+
export { default as AndroidGlassSlider } from './AndroidGlassSlider';
|
|
7
|
+
export { default as AndroidGlassBottomTabs } from './AndroidGlassBottomTabs';
|
|
8
|
+
export { default as AndroidGlassTab } from './AndroidGlassTab';
|
|
9
|
+
export { useMinimizeOnScroll } from './useMinimizeOnScroll';
|
|
10
|
+
export * from './AndroidGlassView.types';
|
|
11
|
+
export * from './AndroidGlassComponents.types';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,wDAAwD;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAyB,MAAM,uBAAuB,CAAC;AACnF,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC","sourcesContent":["// Each component resolves to its native Android implementation (*.android.tsx) on Android, and\n// to a plain fallback with the same API on iOS and web.\nexport { default as AndroidGlassView } from './AndroidGlassView';\nexport { default as AndroidGlassButton } from './AndroidGlassButton';\nexport { default as AndroidGlassToggle } from './AndroidGlassToggle';\nexport { default as AndroidGlassSlider } from './AndroidGlassSlider';\nexport { default as AndroidGlassBottomTabs } from './AndroidGlassBottomTabs';\nexport { default as AndroidGlassTab } from './AndroidGlassTab';\nexport { useMinimizeOnScroll, type MinimizeOnScroll } from './useMinimizeOnScroll';\nexport * from './AndroidGlassView.types';\nexport * from './AndroidGlassComponents.types';\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { NativeScrollEvent, NativeSyntheticEvent } from 'react-native';
|
|
2
|
+
export type MinimizeOnScroll = {
|
|
3
|
+
/** Pass to `AndroidGlassBottomTabs`' `minimized`. */
|
|
4
|
+
minimized: boolean;
|
|
5
|
+
/** Pass to `AndroidGlassBottomTabs`' `onMinimizedChange`. Can also force a state. */
|
|
6
|
+
setMinimized: (minimized: boolean) => void;
|
|
7
|
+
/** Pass to the main list's `onScroll`, together with `scrollEventThrottle={16}`. */
|
|
8
|
+
onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Minimizes `AndroidGlassBottomTabs` while the user scrolls down a list, and expands it when they
|
|
12
|
+
* scroll up or get back to the top, like iOS 26 tab bars. Works with ScrollView, FlatList,
|
|
13
|
+
* SectionList and any list that reports `onScroll`. JS only decides the state; the animation
|
|
14
|
+
* runs natively.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useMinimizeOnScroll(): MinimizeOnScroll;
|
|
17
|
+
//# sourceMappingURL=useMinimizeOnScroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMinimizeOnScroll.d.ts","sourceRoot":"","sources":["../src/useMinimizeOnScroll.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAO5E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qDAAqD;IACrD,SAAS,EAAE,OAAO,CAAC;IACnB,qFAAqF;IACrF,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,oFAAoF;IACpF,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CACpE,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,CA6BtD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
/** Within this distance from the top of the list, the bar is always expanded. */
|
|
3
|
+
const TOP_ZONE = 24;
|
|
4
|
+
/** Smallest scroll step between two events that counts as a direction. */
|
|
5
|
+
const MIN_STEP = 3;
|
|
6
|
+
/**
|
|
7
|
+
* Minimizes `AndroidGlassBottomTabs` while the user scrolls down a list, and expands it when they
|
|
8
|
+
* scroll up or get back to the top, like iOS 26 tab bars. Works with ScrollView, FlatList,
|
|
9
|
+
* SectionList and any list that reports `onScroll`. JS only decides the state; the animation
|
|
10
|
+
* runs natively.
|
|
11
|
+
*/
|
|
12
|
+
export function useMinimizeOnScroll() {
|
|
13
|
+
const [minimized, setMinimizedState] = useState(false);
|
|
14
|
+
const current = useRef(false);
|
|
15
|
+
const previousY = useRef(0);
|
|
16
|
+
const setMinimized = useCallback((next) => {
|
|
17
|
+
// Scroll events arrive every frame; only a change re-renders.
|
|
18
|
+
if (current.current !== next) {
|
|
19
|
+
current.current = next;
|
|
20
|
+
setMinimizedState(next);
|
|
21
|
+
}
|
|
22
|
+
}, []);
|
|
23
|
+
const onScroll = useCallback((event) => {
|
|
24
|
+
// Clamped to the scrollable range, so overscroll can't flip the direction for a frame.
|
|
25
|
+
const { contentOffset, contentSize, layoutMeasurement } = event.nativeEvent;
|
|
26
|
+
const maxY = Math.max(contentSize.height - layoutMeasurement.height, 0);
|
|
27
|
+
const y = Math.min(Math.max(contentOffset.y, 0), maxY);
|
|
28
|
+
const step = y - previousY.current;
|
|
29
|
+
previousY.current = y;
|
|
30
|
+
if (y < TOP_ZONE)
|
|
31
|
+
setMinimized(false);
|
|
32
|
+
else if (step > MIN_STEP)
|
|
33
|
+
setMinimized(true);
|
|
34
|
+
else if (step < -MIN_STEP)
|
|
35
|
+
setMinimized(false);
|
|
36
|
+
}, [setMinimized]);
|
|
37
|
+
return { minimized, setMinimized, onScroll };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=useMinimizeOnScroll.js.map
|