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 @@
|
|
|
1
|
+
{"version":3,"file":"useMinimizeOnScroll.js","sourceRoot":"","sources":["../src/useMinimizeOnScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtD,iFAAiF;AACjF,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,0EAA0E;AAC1E,MAAM,QAAQ,GAAG,CAAC,CAAC;AAWnB;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,CAAC,SAAS,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAE5B,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,IAAa,EAAE,EAAE;QACjD,8DAA8D;QAC9D,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;YACvB,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,KAA8C,EAAE,EAAE;QACjD,uFAAuF;QACvF,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC;QAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACxE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACvD,MAAM,IAAI,GAAG,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;QACnC,SAAS,CAAC,OAAO,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,QAAQ;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;aACjC,IAAI,IAAI,GAAG,QAAQ;YAAE,YAAY,CAAC,IAAI,CAAC,CAAC;aACxC,IAAI,IAAI,GAAG,CAAC,QAAQ;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAC/C,CAAC","sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport type { NativeScrollEvent, NativeSyntheticEvent } from 'react-native';\n\n/** Within this distance from the top of the list, the bar is always expanded. */\nconst TOP_ZONE = 24;\n/** Smallest scroll step between two events that counts as a direction. */\nconst MIN_STEP = 3;\n\nexport type MinimizeOnScroll = {\n /** Pass to `AndroidGlassBottomTabs`' `minimized`. */\n minimized: boolean;\n /** Pass to `AndroidGlassBottomTabs`' `onMinimizedChange`. Can also force a state. */\n setMinimized: (minimized: boolean) => void;\n /** Pass to the main list's `onScroll`, together with `scrollEventThrottle={16}`. */\n onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;\n};\n\n/**\n * Minimizes `AndroidGlassBottomTabs` while the user scrolls down a list, and expands it when they\n * scroll up or get back to the top, like iOS 26 tab bars. Works with ScrollView, FlatList,\n * SectionList and any list that reports `onScroll`. JS only decides the state; the animation\n * runs natively.\n */\nexport function useMinimizeOnScroll(): MinimizeOnScroll {\n const [minimized, setMinimizedState] = useState(false);\n const current = useRef(false);\n const previousY = useRef(0);\n\n const setMinimized = useCallback((next: boolean) => {\n // Scroll events arrive every frame; only a change re-renders.\n if (current.current !== next) {\n current.current = next;\n setMinimizedState(next);\n }\n }, []);\n\n const onScroll = useCallback(\n (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n // Clamped to the scrollable range, so overscroll can't flip the direction for a frame.\n const { contentOffset, contentSize, layoutMeasurement } = event.nativeEvent;\n const maxY = Math.max(contentSize.height - layoutMeasurement.height, 0);\n const y = Math.min(Math.max(contentOffset.y, 0), maxY);\n const step = y - previousY.current;\n previousY.current = y;\n if (y < TOP_ZONE) setMinimized(false);\n else if (step > MIN_STEP) setMinimized(true);\n else if (step < -MIN_STEP) setMinimized(false);\n },\n [setMinimized]\n );\n\n return { minimized, setMinimized, onScroll };\n}\n"]}
|
package/build/utils.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ColorValue } from 'react-native';
|
|
2
|
+
export type NativeColor = number | null;
|
|
3
|
+
/** Converts a React Native colour to the ARGB int the native views expect. */
|
|
4
|
+
export declare function toNativeColor(color: ColorValue | undefined): NativeColor;
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,cAAc,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;AAExC,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,CAIxE"}
|
package/build/utils.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { processColor } from 'react-native';
|
|
2
|
+
/** Converts a React Native colour to the ARGB int the native views expect. */
|
|
3
|
+
export function toNativeColor(color) {
|
|
4
|
+
if (color == null)
|
|
5
|
+
return null;
|
|
6
|
+
const processed = processColor(color);
|
|
7
|
+
return typeof processed === 'number' ? processed : null;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,YAAY,EAAE,MAAM,cAAc,CAAC;AAI7D,8EAA8E;AAC9E,MAAM,UAAU,aAAa,CAAC,KAA6B;IACzD,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1D,CAAC","sourcesContent":["import { type ColorValue, processColor } from 'react-native';\n\nexport type NativeColor = number | null;\n\n/** Converts a React Native colour to the ARGB int the native views expect. */\nexport function toNativeColor(color: ColorValue | undefined): NativeColor {\n if (color == null) return null;\n const processed = processColor(color);\n return typeof processed === 'number' ? processed : null;\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-android-glass-view",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Liquid Glass views, buttons, sliders and toggles for React Native on Android (Jetpack Compose, powered by Kyant0/AndroidLiquidGlass)",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "node internal/module_scripts/build.js",
|
|
9
|
+
"clean": "node internal/module_scripts/clean.js",
|
|
10
|
+
"lint": "eslint src/",
|
|
11
|
+
"test": "node internal/module_scripts/test.js",
|
|
12
|
+
"prepare": "node internal/module_scripts/prepare.js",
|
|
13
|
+
"open:ios": "node internal/module_scripts/open-ios.js",
|
|
14
|
+
"open:android": "node internal/module_scripts/open-android.js"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"react-native",
|
|
18
|
+
"expo",
|
|
19
|
+
"android",
|
|
20
|
+
"liquid-glass",
|
|
21
|
+
"glassmorphism",
|
|
22
|
+
"jetpack-compose",
|
|
23
|
+
"expo-android-glass-view"
|
|
24
|
+
],
|
|
25
|
+
"repository": "https://github.com/kagantemizkan/expo-android-glass-view",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/kagantemizkan/expo-android-glass-view/issues"
|
|
28
|
+
},
|
|
29
|
+
"author": "Kağan Temizkan <info@sailatlas.app> (https://sailatlas.app)",
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"homepage": "https://github.com/kagantemizkan/expo-android-glass-view#readme",
|
|
32
|
+
"dependencies": {},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/core": "^7.26.0",
|
|
35
|
+
"@types/jest": "^29.2.1",
|
|
36
|
+
"@types/react": "~19.2.2",
|
|
37
|
+
"babel-preset-expo": "~57.0.11",
|
|
38
|
+
"eslint": "~9.39.4",
|
|
39
|
+
"eslint-config-universe": "^15.0.3",
|
|
40
|
+
"expo": "^57.0.21",
|
|
41
|
+
"jest": "^29.7.0",
|
|
42
|
+
"jest-expo": "~57.0.5",
|
|
43
|
+
"prettier": "^3.0.0",
|
|
44
|
+
"react-native": "0.86.3",
|
|
45
|
+
"typescript": "~6.0.3"
|
|
46
|
+
},
|
|
47
|
+
"jest": {
|
|
48
|
+
"preset": "jest-expo",
|
|
49
|
+
"roots": [
|
|
50
|
+
"<rootDir>/src"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"expo": "*",
|
|
55
|
+
"react": "*",
|
|
56
|
+
"react-native": "*"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { StyleSheet, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';
|
|
6
|
+
import { type NativeColor, toNativeColor } from './utils';
|
|
7
|
+
|
|
8
|
+
type IndexEvent = { nativeEvent: { index: number; eventCount: number } };
|
|
9
|
+
type MinimizedEvent = { nativeEvent: { minimized: boolean } };
|
|
10
|
+
|
|
11
|
+
type NativeAndroidGlassBottomTabsProps = Omit<
|
|
12
|
+
AndroidGlassBottomTabsProps,
|
|
13
|
+
'onTabSelected' | 'onMinimizedChange' | 'accentColor' | 'containerColor'
|
|
14
|
+
> & {
|
|
15
|
+
tabsCount: number;
|
|
16
|
+
/** Count of the last selection event handled here (see ControlledProp on the native side). */
|
|
17
|
+
mostRecentEventCount: number;
|
|
18
|
+
onTabSelected: (event: IndexEvent) => void;
|
|
19
|
+
onMinimizedChange: (event: MinimizedEvent) => void;
|
|
20
|
+
accentColor?: NativeColor;
|
|
21
|
+
containerColor?: NativeColor;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const NativeAndroidGlassBottomTabs: React.ComponentType<NativeAndroidGlassBottomTabsProps> =
|
|
25
|
+
requireNativeView('ExpoAndroidGlassView', 'AndroidGlassBottomTabs');
|
|
26
|
+
|
|
27
|
+
export default function AndroidGlassBottomTabs({
|
|
28
|
+
selectedIndex,
|
|
29
|
+
onTabSelected,
|
|
30
|
+
minimized,
|
|
31
|
+
onMinimizedChange,
|
|
32
|
+
accentColor,
|
|
33
|
+
containerColor,
|
|
34
|
+
children,
|
|
35
|
+
style,
|
|
36
|
+
...rest
|
|
37
|
+
}: AndroidGlassBottomTabsProps) {
|
|
38
|
+
const tabs = React.Children.toArray(children).filter(React.isValidElement);
|
|
39
|
+
// Without a `selectedIndex` prop, the bar keeps the user's selection.
|
|
40
|
+
const [ownIndex, setOwnIndex] = React.useState(0);
|
|
41
|
+
// Sent back with `selectedIndex`, so the native side can tell a stale index (JS still catching
|
|
42
|
+
// up with earlier selections) from a current one.
|
|
43
|
+
const [eventCount, setEventCount] = React.useState(0);
|
|
44
|
+
const selected = selectedIndex ?? ownIndex;
|
|
45
|
+
return (
|
|
46
|
+
<NativeAndroidGlassBottomTabs
|
|
47
|
+
accessibilityRole="tablist"
|
|
48
|
+
{...rest}
|
|
49
|
+
style={[styles.bar, style]}
|
|
50
|
+
selectedIndex={selected}
|
|
51
|
+
tabsCount={tabs.length}
|
|
52
|
+
mostRecentEventCount={eventCount}
|
|
53
|
+
minimized={minimized ?? false}
|
|
54
|
+
accentColor={toNativeColor(accentColor)}
|
|
55
|
+
containerColor={toNativeColor(containerColor)}
|
|
56
|
+
onTabSelected={(event) => {
|
|
57
|
+
const { index, eventCount: count } = event.nativeEvent;
|
|
58
|
+
setEventCount((current) => Math.max(current, count));
|
|
59
|
+
setOwnIndex(index);
|
|
60
|
+
onTabSelected?.(index);
|
|
61
|
+
}}
|
|
62
|
+
onMinimizedChange={(event) => onMinimizedChange?.(event.nativeEvent.minimized)}>
|
|
63
|
+
{tabs.map((tab, index) => (
|
|
64
|
+
// The native bar handles taps and drags, and draws these views itself (inside the glass
|
|
65
|
+
// and, tinted, under the droplet), so they must stay real views and not take touches.
|
|
66
|
+
<View
|
|
67
|
+
key={tab.key ?? index}
|
|
68
|
+
collapsable={false}
|
|
69
|
+
pointerEvents="none"
|
|
70
|
+
accessibilityRole="tab"
|
|
71
|
+
accessibilityState={{ selected: index === selected }}
|
|
72
|
+
style={styles.tab}>
|
|
73
|
+
{tab}
|
|
74
|
+
</View>
|
|
75
|
+
))}
|
|
76
|
+
</NativeAndroidGlassBottomTabs>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const styles = StyleSheet.create({
|
|
81
|
+
// 4 dp side padding keeps the tabs aligned with the droplet: (width - 8 dp) / count each.
|
|
82
|
+
bar: {
|
|
83
|
+
height: 64,
|
|
84
|
+
flexDirection: 'row',
|
|
85
|
+
paddingHorizontal: 4,
|
|
86
|
+
},
|
|
87
|
+
tab: {
|
|
88
|
+
flex: 1,
|
|
89
|
+
alignItems: 'center',
|
|
90
|
+
justifyContent: 'center',
|
|
91
|
+
gap: 2,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { AndroidGlassBottomTabsProps } from './AndroidGlassComponents.types';
|
|
5
|
+
|
|
6
|
+
/** iOS and web fallback: a plain tab bar with the same API (it does not minimize). */
|
|
7
|
+
export default function AndroidGlassBottomTabs({
|
|
8
|
+
selectedIndex = 0,
|
|
9
|
+
onTabSelected,
|
|
10
|
+
minimized: _minimized,
|
|
11
|
+
onMinimizedChange: _onMinimizedChange,
|
|
12
|
+
accentColor: _accentColor,
|
|
13
|
+
containerColor,
|
|
14
|
+
children,
|
|
15
|
+
style,
|
|
16
|
+
...rest
|
|
17
|
+
}: AndroidGlassBottomTabsProps) {
|
|
18
|
+
const tabs = React.Children.toArray(children).filter(React.isValidElement);
|
|
19
|
+
return (
|
|
20
|
+
<View
|
|
21
|
+
accessibilityRole="tablist"
|
|
22
|
+
{...rest}
|
|
23
|
+
style={[
|
|
24
|
+
styles.bar,
|
|
25
|
+
{ backgroundColor: containerColor ?? 'rgba(250, 250, 250, 0.9)' },
|
|
26
|
+
style,
|
|
27
|
+
]}>
|
|
28
|
+
{tabs.map((tab, index) => (
|
|
29
|
+
<Pressable
|
|
30
|
+
key={tab.key ?? index}
|
|
31
|
+
accessibilityRole="tab"
|
|
32
|
+
accessibilityState={{ selected: index === selectedIndex }}
|
|
33
|
+
onPress={() => onTabSelected?.(index)}
|
|
34
|
+
style={[styles.tab, index === selectedIndex && styles.selected]}>
|
|
35
|
+
{tab}
|
|
36
|
+
</Pressable>
|
|
37
|
+
))}
|
|
38
|
+
</View>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const styles = StyleSheet.create({
|
|
43
|
+
bar: {
|
|
44
|
+
height: 64,
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
padding: 4,
|
|
47
|
+
borderRadius: 32,
|
|
48
|
+
},
|
|
49
|
+
tab: {
|
|
50
|
+
flex: 1,
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
gap: 2,
|
|
54
|
+
borderRadius: 28,
|
|
55
|
+
},
|
|
56
|
+
selected: {
|
|
57
|
+
backgroundColor: 'rgba(0, 0, 0, 0.08)',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { StyleSheet, Text } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import type { AndroidGlassButtonProps } from './AndroidGlassComponents.types';
|
|
6
|
+
import { type NativeColor, toNativeColor } from './utils';
|
|
7
|
+
|
|
8
|
+
type NativeAndroidGlassButtonProps = Omit<
|
|
9
|
+
AndroidGlassButtonProps,
|
|
10
|
+
'tintColor' | 'surfaceColor' | 'fallbackColor' | 'onPress' | 'title' | 'titleStyle'
|
|
11
|
+
> & {
|
|
12
|
+
tintColor?: NativeColor;
|
|
13
|
+
surfaceColor?: NativeColor;
|
|
14
|
+
fallbackColor?: NativeColor;
|
|
15
|
+
onPress?: () => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const NativeAndroidGlassButton: React.ComponentType<NativeAndroidGlassButtonProps> =
|
|
19
|
+
requireNativeView('ExpoAndroidGlassView', 'AndroidGlassButton');
|
|
20
|
+
|
|
21
|
+
export default function AndroidGlassButton({
|
|
22
|
+
onPress,
|
|
23
|
+
title,
|
|
24
|
+
titleStyle,
|
|
25
|
+
cornerRadius,
|
|
26
|
+
tintColor,
|
|
27
|
+
surfaceColor,
|
|
28
|
+
fallbackColor,
|
|
29
|
+
style,
|
|
30
|
+
children,
|
|
31
|
+
...rest
|
|
32
|
+
}: AndroidGlassButtonProps) {
|
|
33
|
+
const borderRadius = StyleSheet.flatten(style)?.borderRadius;
|
|
34
|
+
return (
|
|
35
|
+
<NativeAndroidGlassButton
|
|
36
|
+
accessibilityRole="button"
|
|
37
|
+
{...rest}
|
|
38
|
+
style={[styles.button, style]}
|
|
39
|
+
cornerRadius={cornerRadius ?? (typeof borderRadius === 'number' ? borderRadius : undefined)}
|
|
40
|
+
tintColor={toNativeColor(tintColor)}
|
|
41
|
+
surfaceColor={toNativeColor(surfaceColor)}
|
|
42
|
+
fallbackColor={toNativeColor(fallbackColor)}
|
|
43
|
+
onPress={onPress ? () => onPress() : undefined}>
|
|
44
|
+
{title != null ? (
|
|
45
|
+
<Text style={[styles.title, tintColor != null && styles.titleOnTint, titleStyle]}>
|
|
46
|
+
{title}
|
|
47
|
+
</Text>
|
|
48
|
+
) : null}
|
|
49
|
+
{children}
|
|
50
|
+
</NativeAndroidGlassButton>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const styles = StyleSheet.create({
|
|
55
|
+
button: {
|
|
56
|
+
height: 48,
|
|
57
|
+
paddingHorizontal: 16,
|
|
58
|
+
flexDirection: 'row',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'center',
|
|
61
|
+
gap: 8,
|
|
62
|
+
},
|
|
63
|
+
title: {
|
|
64
|
+
fontSize: 15,
|
|
65
|
+
color: '#000000',
|
|
66
|
+
},
|
|
67
|
+
titleOnTint: {
|
|
68
|
+
color: '#ffffff',
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Pressable, StyleSheet, Text } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { AndroidGlassButtonProps } from './AndroidGlassComponents.types';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_FALLBACK_COLOR = 'rgba(255, 255, 255, 0.7)';
|
|
7
|
+
|
|
8
|
+
/** iOS and web fallback: a translucent capsule button with the same API. */
|
|
9
|
+
export default function AndroidGlassButton({
|
|
10
|
+
onPress,
|
|
11
|
+
title,
|
|
12
|
+
titleStyle,
|
|
13
|
+
cornerRadius,
|
|
14
|
+
tintColor,
|
|
15
|
+
surfaceColor,
|
|
16
|
+
fallbackColor,
|
|
17
|
+
style,
|
|
18
|
+
children,
|
|
19
|
+
blurRadius: _blurRadius,
|
|
20
|
+
refractionHeight: _refractionHeight,
|
|
21
|
+
refractionAmount: _refractionAmount,
|
|
22
|
+
chromaticAberration: _chromaticAberration,
|
|
23
|
+
depthEffect: _depthEffect,
|
|
24
|
+
vibrancy: _vibrancy,
|
|
25
|
+
highlight: _highlight,
|
|
26
|
+
shadow: _shadow,
|
|
27
|
+
interactive: _interactive,
|
|
28
|
+
...rest
|
|
29
|
+
}: AndroidGlassButtonProps) {
|
|
30
|
+
return (
|
|
31
|
+
<Pressable
|
|
32
|
+
accessibilityRole="button"
|
|
33
|
+
{...rest}
|
|
34
|
+
onPress={onPress}
|
|
35
|
+
style={({ pressed }) => [
|
|
36
|
+
styles.button,
|
|
37
|
+
{
|
|
38
|
+
backgroundColor: tintColor ?? surfaceColor ?? fallbackColor ?? DEFAULT_FALLBACK_COLOR,
|
|
39
|
+
borderRadius: cornerRadius ?? 999,
|
|
40
|
+
opacity: pressed ? 0.75 : 1,
|
|
41
|
+
},
|
|
42
|
+
style,
|
|
43
|
+
]}>
|
|
44
|
+
{title != null ? (
|
|
45
|
+
<Text style={[styles.title, tintColor != null && styles.titleOnTint, titleStyle]}>
|
|
46
|
+
{title}
|
|
47
|
+
</Text>
|
|
48
|
+
) : null}
|
|
49
|
+
{children}
|
|
50
|
+
</Pressable>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const styles = StyleSheet.create({
|
|
55
|
+
button: {
|
|
56
|
+
height: 48,
|
|
57
|
+
paddingHorizontal: 16,
|
|
58
|
+
flexDirection: 'row',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'center',
|
|
61
|
+
gap: 8,
|
|
62
|
+
},
|
|
63
|
+
title: {
|
|
64
|
+
fontSize: 15,
|
|
65
|
+
color: '#000000',
|
|
66
|
+
},
|
|
67
|
+
titleOnTint: {
|
|
68
|
+
color: '#ffffff',
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ColorValue, StyleProp, TextStyle, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { AndroidGlassViewProps } from './AndroidGlassView.types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Accepts every `AndroidGlassView` glass prop. `cornerRadius` defaults to a capsule.
|
|
8
|
+
* Children (label, icon, …) are drawn inside the glass and follow its press deformation; they
|
|
9
|
+
* are decorative, so don't put interactive elements in a button.
|
|
10
|
+
*/
|
|
11
|
+
export type AndroidGlassButtonProps = AndroidGlassViewProps & {
|
|
12
|
+
/** Called when the button is tapped. */
|
|
13
|
+
onPress?: () => void;
|
|
14
|
+
/** Convenience label, rendered before the children. */
|
|
15
|
+
title?: string;
|
|
16
|
+
titleStyle?: StyleProp<TextStyle>;
|
|
17
|
+
/**
|
|
18
|
+
* Press and drag feedback: the glass stretches towards the finger and a highlight follows it.
|
|
19
|
+
* Default true.
|
|
20
|
+
*/
|
|
21
|
+
interactive?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type AndroidGlassToggleProps = ViewProps & {
|
|
25
|
+
value?: boolean;
|
|
26
|
+
onValueChange?: (value: boolean) => void;
|
|
27
|
+
/** Track colour when on. Default iOS green. */
|
|
28
|
+
accentColor?: ColorValue;
|
|
29
|
+
/** Track colour when off. */
|
|
30
|
+
trackColor?: ColorValue;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type AndroidGlassSliderProps = ViewProps & {
|
|
34
|
+
value?: number;
|
|
35
|
+
/** Default 0. */
|
|
36
|
+
minimumValue?: number;
|
|
37
|
+
/** Default 1. */
|
|
38
|
+
maximumValue?: number;
|
|
39
|
+
/** Called continuously while the thumb is dragged. */
|
|
40
|
+
onValueChange?: (value: number) => void;
|
|
41
|
+
/** Called once when the finger is lifted, or after a tap on the track. */
|
|
42
|
+
onSlidingComplete?: (value: number) => void;
|
|
43
|
+
/** Colour of the filled part of the track. Default system blue. */
|
|
44
|
+
accentColor?: ColorValue;
|
|
45
|
+
trackColor?: ColorValue;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type AndroidGlassBottomTabsProps = ViewProps & {
|
|
49
|
+
/** Index of the selected tab. */
|
|
50
|
+
selectedIndex?: number;
|
|
51
|
+
/** Called when the user taps a tab or drops the droplet on one. */
|
|
52
|
+
onTabSelected?: (index: number) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Minimizes the bar, like iOS 26 tab bars on scroll: it gets shorter and narrower, each tab keeps
|
|
55
|
+
* only its first child (the icon) and the rest (the label) fades out. Animated natively; usually
|
|
56
|
+
* driven by `useMinimizeOnScroll`. Android only.
|
|
57
|
+
*/
|
|
58
|
+
minimized?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Called with `false` when the user expands the minimized bar by touching it. Pass the
|
|
61
|
+
* `setMinimized` of `useMinimizeOnScroll`, so the next scroll down minimizes it again.
|
|
62
|
+
*/
|
|
63
|
+
onMinimizedChange?: (minimized: boolean) => void;
|
|
64
|
+
/** Colour the selected tab's content takes under the droplet. Default system blue. */
|
|
65
|
+
accentColor?: ColorValue;
|
|
66
|
+
/** Colour of the glass bar. */
|
|
67
|
+
containerColor?: ColorValue;
|
|
68
|
+
/** One child per tab, e.g. `AndroidGlassTab`. Tabs get equal widths. */
|
|
69
|
+
children?: ReactNode;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type AndroidGlassTabProps = {
|
|
73
|
+
icon?: ReactNode;
|
|
74
|
+
label?: string;
|
|
75
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
76
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import type { AndroidGlassSliderProps } from './AndroidGlassComponents.types';
|
|
6
|
+
import { type NativeColor, toNativeColor } from './utils';
|
|
7
|
+
|
|
8
|
+
type ValueEvent = { nativeEvent: { value: number; eventCount: number } };
|
|
9
|
+
|
|
10
|
+
type NativeAndroidGlassSliderProps = Omit<
|
|
11
|
+
AndroidGlassSliderProps,
|
|
12
|
+
'onValueChange' | 'onSlidingComplete' | 'accentColor' | 'trackColor'
|
|
13
|
+
> & {
|
|
14
|
+
/** Count of the last event handled here (see ControlledProp on the native side). */
|
|
15
|
+
mostRecentEventCount: number;
|
|
16
|
+
onValueChange: (event: ValueEvent) => void;
|
|
17
|
+
onSlidingComplete: (event: ValueEvent) => void;
|
|
18
|
+
accentColor?: NativeColor;
|
|
19
|
+
trackColor?: NativeColor;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const NativeAndroidGlassSlider: React.ComponentType<NativeAndroidGlassSliderProps> =
|
|
23
|
+
requireNativeView('ExpoAndroidGlassView', 'AndroidGlassSlider');
|
|
24
|
+
|
|
25
|
+
export default function AndroidGlassSlider({
|
|
26
|
+
value,
|
|
27
|
+
minimumValue,
|
|
28
|
+
maximumValue,
|
|
29
|
+
onValueChange,
|
|
30
|
+
onSlidingComplete,
|
|
31
|
+
accentColor,
|
|
32
|
+
trackColor,
|
|
33
|
+
style,
|
|
34
|
+
...rest
|
|
35
|
+
}: AndroidGlassSliderProps) {
|
|
36
|
+
const min = minimumValue ?? 0;
|
|
37
|
+
// Without a `value` prop, the slider keeps the position the user gives it.
|
|
38
|
+
const [ownValue, setOwnValue] = React.useState(min);
|
|
39
|
+
// Sent back with `value`, so the native side can tell a stale value (JS still catching up with
|
|
40
|
+
// earlier events) from a current one.
|
|
41
|
+
const [eventCount, setEventCount] = React.useState(0);
|
|
42
|
+
const handleEvent = (event: ValueEvent) => {
|
|
43
|
+
const { value: next, eventCount: count } = event.nativeEvent;
|
|
44
|
+
setEventCount((current) => Math.max(current, count));
|
|
45
|
+
setOwnValue(next);
|
|
46
|
+
return next;
|
|
47
|
+
};
|
|
48
|
+
return (
|
|
49
|
+
<NativeAndroidGlassSlider
|
|
50
|
+
accessibilityRole="adjustable"
|
|
51
|
+
{...rest}
|
|
52
|
+
style={[styles.slider, style]}
|
|
53
|
+
value={value ?? ownValue}
|
|
54
|
+
minimumValue={min}
|
|
55
|
+
maximumValue={maximumValue ?? 1}
|
|
56
|
+
mostRecentEventCount={eventCount}
|
|
57
|
+
accentColor={toNativeColor(accentColor)}
|
|
58
|
+
trackColor={toNativeColor(trackColor)}
|
|
59
|
+
onValueChange={(event) => onValueChange?.(handleEvent(event))}
|
|
60
|
+
onSlidingComplete={(event) => onSlidingComplete?.(handleEvent(event))}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const styles = StyleSheet.create({
|
|
66
|
+
slider: {
|
|
67
|
+
height: 36,
|
|
68
|
+
alignSelf: 'stretch',
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type GestureResponderEvent, StyleSheet, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { AndroidGlassSliderProps } from './AndroidGlassComponents.types';
|
|
5
|
+
|
|
6
|
+
/** iOS and web fallback: a plain slider with the same API. */
|
|
7
|
+
export default function AndroidGlassSlider({
|
|
8
|
+
value = 0,
|
|
9
|
+
minimumValue = 0,
|
|
10
|
+
maximumValue = 1,
|
|
11
|
+
onValueChange,
|
|
12
|
+
onSlidingComplete,
|
|
13
|
+
accentColor = '#0088FF',
|
|
14
|
+
trackColor = 'rgba(120, 120, 120, 0.2)',
|
|
15
|
+
style,
|
|
16
|
+
onLayout,
|
|
17
|
+
...rest
|
|
18
|
+
}: AndroidGlassSliderProps) {
|
|
19
|
+
const [width, setWidth] = React.useState(0);
|
|
20
|
+
const range = maximumValue - minimumValue || 1;
|
|
21
|
+
const progress = Math.min(1, Math.max(0, (value - minimumValue) / range));
|
|
22
|
+
|
|
23
|
+
const valueAt = (event: GestureResponderEvent) =>
|
|
24
|
+
minimumValue + Math.min(1, Math.max(0, event.nativeEvent.locationX / (width || 1))) * range;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<View
|
|
28
|
+
accessibilityRole="adjustable"
|
|
29
|
+
{...rest}
|
|
30
|
+
onStartShouldSetResponder={() => true}
|
|
31
|
+
onMoveShouldSetResponder={() => true}
|
|
32
|
+
onResponderTerminationRequest={() => false}
|
|
33
|
+
onResponderGrant={(event) => onValueChange?.(valueAt(event))}
|
|
34
|
+
onResponderMove={(event) => onValueChange?.(valueAt(event))}
|
|
35
|
+
onResponderRelease={(event) => onSlidingComplete?.(valueAt(event))}
|
|
36
|
+
onLayout={(event) => {
|
|
37
|
+
setWidth(event.nativeEvent.layout.width);
|
|
38
|
+
onLayout?.(event);
|
|
39
|
+
}}
|
|
40
|
+
style={[styles.container, style]}>
|
|
41
|
+
<View pointerEvents="none" style={[styles.track, { backgroundColor: trackColor }]}>
|
|
42
|
+
<View
|
|
43
|
+
style={[styles.fill, { width: `${progress * 100}%`, backgroundColor: accentColor }]}
|
|
44
|
+
/>
|
|
45
|
+
</View>
|
|
46
|
+
<View pointerEvents="none" style={[styles.thumb, { left: `${progress * 100}%` }]} />
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const styles = StyleSheet.create({
|
|
52
|
+
container: {
|
|
53
|
+
height: 36,
|
|
54
|
+
alignSelf: 'stretch',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
},
|
|
57
|
+
track: {
|
|
58
|
+
height: 6,
|
|
59
|
+
borderRadius: 3,
|
|
60
|
+
overflow: 'hidden',
|
|
61
|
+
},
|
|
62
|
+
fill: {
|
|
63
|
+
height: '100%',
|
|
64
|
+
},
|
|
65
|
+
thumb: {
|
|
66
|
+
position: 'absolute',
|
|
67
|
+
width: 40,
|
|
68
|
+
height: 24,
|
|
69
|
+
marginLeft: -20,
|
|
70
|
+
borderRadius: 12,
|
|
71
|
+
backgroundColor: '#ffffff',
|
|
72
|
+
shadowColor: '#000000',
|
|
73
|
+
shadowOpacity: 0.15,
|
|
74
|
+
shadowRadius: 4,
|
|
75
|
+
shadowOffset: { width: 0, height: 1 },
|
|
76
|
+
elevation: 2,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { AndroidGlassTabProps } from './AndroidGlassComponents.types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* An icon over a label, like Kyant's LiquidBottomTab. Use as a child of AndroidGlassBottomTabs.
|
|
8
|
+
* The icon gets a view of its own: a minimized tab bar keeps each tab's first child and fades the
|
|
9
|
+
* rest (the label) out.
|
|
10
|
+
*/
|
|
11
|
+
export default function AndroidGlassTab({ icon, label, labelStyle }: AndroidGlassTabProps) {
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
{icon != null ? <View collapsable={false}>{icon}</View> : null}
|
|
15
|
+
{label != null ? (
|
|
16
|
+
<Text numberOfLines={1} style={[styles.label, labelStyle]}>
|
|
17
|
+
{label}
|
|
18
|
+
</Text>
|
|
19
|
+
) : null}
|
|
20
|
+
</>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const styles = StyleSheet.create({
|
|
25
|
+
label: {
|
|
26
|
+
fontSize: 12,
|
|
27
|
+
color: '#000000',
|
|
28
|
+
},
|
|
29
|
+
});
|