@fountain-ui/lab 3.0.0-alpha.2 → 3.0.0-alpha.20
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/build/commonjs/BottomSheet/BottomSheetNative.js +39 -12
- package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetWeb.js +15 -9
- package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +1 -7
- package/build/commonjs/BottomSheet/useDynamicSnapPoints.js.map +1 -1
- package/build/commonjs/BottomSheet/useDynamicSnapPoints.native.js +22 -0
- package/build/commonjs/BottomSheet/useDynamicSnapPoints.native.js.map +1 -0
- package/build/commonjs/Carousel/Carousel.js +4 -2
- package/build/commonjs/Carousel/Carousel.js.map +1 -1
- package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
- package/build/commonjs/Carousel/components/InternalContext.js +2 -1
- package/build/commonjs/Carousel/components/InternalContext.js.map +1 -1
- package/build/commonjs/Carousel/components/ItemView.js +3 -1
- package/build/commonjs/Carousel/components/ItemView.js.map +1 -1
- package/build/commonjs/ComicViewer/FastScroll.js +8 -10
- package/build/commonjs/ComicViewer/FastScroll.js.map +1 -1
- package/build/commonjs/StatusBarProvider/StatusBarProvider.js +1 -1
- package/build/commonjs/StatusBarProvider/StatusBarProvider.js.map +1 -1
- package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +1 -1
- package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetNative.js +37 -13
- package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetWeb.js +14 -9
- package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/module/BottomSheet/useDynamicSnapPoints.js +2 -8
- package/build/module/BottomSheet/useDynamicSnapPoints.js.map +1 -1
- package/build/module/BottomSheet/useDynamicSnapPoints.native.js +14 -0
- package/build/module/BottomSheet/useDynamicSnapPoints.native.js.map +1 -0
- package/build/module/Carousel/Carousel.js +4 -2
- package/build/module/Carousel/Carousel.js.map +1 -1
- package/build/module/Carousel/CarouselProps.js.map +1 -1
- package/build/module/Carousel/components/InternalContext.js +2 -1
- package/build/module/Carousel/components/InternalContext.js.map +1 -1
- package/build/module/Carousel/components/ItemView.js +3 -1
- package/build/module/Carousel/components/ItemView.js.map +1 -1
- package/build/module/ComicViewer/FastScroll.js +5 -8
- package/build/module/ComicViewer/FastScroll.js.map +1 -1
- package/build/module/StatusBarProvider/StatusBarProvider.js +1 -1
- package/build/module/StatusBarProvider/StatusBarProvider.js.map +1 -1
- package/build/module/hooks/useUnstableCollapsibleAppBar.js +1 -1
- package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/typescript/BottomSheet/BottomSheetProps.d.ts +9 -1
- package/build/typescript/BottomSheet/useDynamicSnapPoints.native.d.ts +21 -0
- package/build/typescript/Carousel/Carousel.d.ts +1 -1
- package/build/typescript/Carousel/CarouselProps.d.ts +7 -0
- package/build/typescript/Carousel/components/InternalContext.d.ts +1 -0
- package/package.json +5 -4
- package/src/BottomSheet/BottomSheetNative.tsx +51 -18
- package/src/BottomSheet/BottomSheetProps.ts +11 -1
- package/src/BottomSheet/BottomSheetWeb.tsx +15 -7
- package/src/BottomSheet/useDynamicSnapPoints.native.ts +15 -0
- package/src/BottomSheet/useDynamicSnapPoints.ts +2 -9
- package/src/Carousel/Carousel.tsx +3 -0
- package/src/Carousel/CarouselProps.ts +8 -0
- package/src/Carousel/components/InternalContext.ts +2 -0
- package/src/Carousel/components/ItemView.tsx +2 -0
- package/src/ComicViewer/FastScroll.tsx +6 -12
- package/src/StatusBarProvider/StatusBarProvider.tsx +2 -2
- package/src/hooks/useUnstableCollapsibleAppBar.ts +1 -1
|
@@ -15,6 +15,7 @@ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
|
|
|
15
15
|
itemHeight,
|
|
16
16
|
itemWidth,
|
|
17
17
|
loop = false,
|
|
18
|
+
needsOffscreenAlphaCompositingOnItem = false,
|
|
18
19
|
onIndexChange,
|
|
19
20
|
renderItem,
|
|
20
21
|
scrollEnabled = true,
|
|
@@ -73,8 +74,9 @@ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
|
|
|
73
74
|
itemHeight,
|
|
74
75
|
itemWidth,
|
|
75
76
|
itemVisibilityStore,
|
|
76
|
-
loop
|
|
77
|
-
|
|
77
|
+
loop,
|
|
78
|
+
needsOffscreenAlphaCompositingOnItem
|
|
79
|
+
}), [createItemStyle, data, globalInterpolation, itemHeight, itemWidth, itemVisibilityStore, loop, needsOffscreenAlphaCompositingOnItem]);
|
|
78
80
|
return /*#__PURE__*/React.createElement(InternalContext.Provider, {
|
|
79
81
|
value: contextValue
|
|
80
82
|
}, /*#__PURE__*/React.createElement(ViewabilityTrackerView, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","memo","useImperativeHandle","useMemo","ViewabilityTrackerView","useAutoplayController","useIndexController","useItemVisibilityStore","useLoopedData","usePagingAnimator","createDefaultItemStyle","createDefaultScrollAnimation","InternalContext","RootView","ScrollViewGesture","Carousel","props","ref","autoplay","autoplayInterval","createItemStyle","createScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","onIndexChange","renderItem","scrollEnabled","style","windowSize","itemVisibilityStore","onPositionChange","numberOfData","length","indexController","numberOfOriginalData","getCurrentIndex","gestureTranslationX","globalInterpolation","interruptAnimation","startPagingAnimation","autoplayController","enabled","intervalMillis","next","direction","prev","scrollTo","option","contextValue","Math","max","visible","resume","pause"],"sources":["Carousel.tsx"],"sourcesContent":["import React, { forwardRef, memo, useImperativeHandle, useMemo } from 'react';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimator,\n} from './hooks';\nimport { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';\nimport { InternalContext, RootView, ScrollViewGesture } from './components';\n\nconst Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {\n const {\n autoplay = false,\n autoplayInterval = 3000,\n createItemStyle = createDefaultItemStyle,\n createScrollAnimation = createDefaultScrollAnimation,\n data: originalData,\n disableSmartAutoplay = false,\n initialIndex = 0,\n itemHeight,\n itemWidth,\n loop = false,\n onIndexChange,\n renderItem,\n scrollEnabled = true,\n style,\n windowSize = 5,\n } = props;\n\n const data = useLoopedData(originalData, loop);\n\n const [itemVisibilityStore, onPositionChange] = useItemVisibilityStore({\n initialIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const indexController = useIndexController({\n initialIndex,\n itemWidth,\n numberOfData: data.length,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n onPositionChange,\n });\n\n const { getCurrentIndex } = indexController;\n\n const {\n gestureTranslationX,\n globalInterpolation,\n interruptAnimation,\n startPagingAnimation,\n } = usePagingAnimator({\n createScrollAnimation,\n itemWidth,\n indexController,\n initialIndex,\n loop,\n numberOfData: data.length,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getCurrentIndex,\n next: () => startPagingAnimation('directional', { direction: 'next' }),\n prev: () => startPagingAnimation('directional', { direction: 'prev' }),\n scrollTo: (option) => startPagingAnimation('index', option),\n }),\n [startPagingAnimation, getCurrentIndex],\n );\n\n const contextValue = useMemo(() => ({\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n }), [\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n ]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n <ViewabilityTrackerView\n enabled={autoplay && !disableSmartAutoplay}\n measurementIntervalMillis={Math.max(3000, autoplayInterval)}\n onViewabilityChange={({ visible }) => {\n if (visible) {\n autoplayController.resume();\n } else {\n autoplayController.pause();\n }\n }}\n >\n <ScrollViewGesture\n autoplayController={autoplayController}\n gestureTranslationX={gestureTranslationX}\n interruptAnimation={interruptAnimation}\n scrollEnabled={scrollEnabled}\n startPagingAnimation={startPagingAnimation}\n >\n <RootView\n data={data}\n itemHeight={itemHeight}\n originalData={originalData}\n renderItem={renderItem}\n style={style}\n />\n </ScrollViewGesture>\n </ViewabilityTrackerView>\n </InternalContext.Provider>\n );\n});\n\nexport default memo(Carousel);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAkCC,mBAAlC,EAAuDC,OAAvD,QAAsE,OAAtE;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAGA,SACIC,qBADJ,EAEIC,kBAFJ,EAGIC,sBAHJ,EAIIC,aAJJ,EAKIC,iBALJ,QAMO,SANP;AAOA,SAASC,sBAAT,EAAiCC,4BAAjC,QAAqE,aAArE;AACA,SAASC,eAAT,EAA0BC,QAA1B,EAAoCC,iBAApC,QAA6D,cAA7D;AAEA,MAAMC,QAAQ,gBAAGf,UAAU,CAAkC,SAASe,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EACvF,MAAM;IACFC,QAAQ,GAAG,KADT;IAEFC,gBAAgB,GAAG,IAFjB;IAGFC,eAAe,GAAGV,sBAHhB;IAIFW,qBAAqB,GAAGV,4BAJtB;IAKFW,IAAI,EAAEC,YALJ;IAMFC,oBAAoB,GAAG,KANrB;IAOFC,YAAY,GAAG,CAPb;IAQFC,UARE;IASFC,SATE;IAUFC,IAAI,GAAG,KAVL;IAWFC,
|
|
1
|
+
{"version":3,"names":["React","forwardRef","memo","useImperativeHandle","useMemo","ViewabilityTrackerView","useAutoplayController","useIndexController","useItemVisibilityStore","useLoopedData","usePagingAnimator","createDefaultItemStyle","createDefaultScrollAnimation","InternalContext","RootView","ScrollViewGesture","Carousel","props","ref","autoplay","autoplayInterval","createItemStyle","createScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","needsOffscreenAlphaCompositingOnItem","onIndexChange","renderItem","scrollEnabled","style","windowSize","itemVisibilityStore","onPositionChange","numberOfData","length","indexController","numberOfOriginalData","getCurrentIndex","gestureTranslationX","globalInterpolation","interruptAnimation","startPagingAnimation","autoplayController","enabled","intervalMillis","next","direction","prev","scrollTo","option","contextValue","Math","max","visible","resume","pause"],"sources":["Carousel.tsx"],"sourcesContent":["import React, { forwardRef, memo, useImperativeHandle, useMemo } from 'react';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimator,\n} from './hooks';\nimport { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';\nimport { InternalContext, RootView, ScrollViewGesture } from './components';\n\nconst Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {\n const {\n autoplay = false,\n autoplayInterval = 3000,\n createItemStyle = createDefaultItemStyle,\n createScrollAnimation = createDefaultScrollAnimation,\n data: originalData,\n disableSmartAutoplay = false,\n initialIndex = 0,\n itemHeight,\n itemWidth,\n loop = false,\n needsOffscreenAlphaCompositingOnItem = false,\n onIndexChange,\n renderItem,\n scrollEnabled = true,\n style,\n windowSize = 5,\n } = props;\n\n const data = useLoopedData(originalData, loop);\n\n const [itemVisibilityStore, onPositionChange] = useItemVisibilityStore({\n initialIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const indexController = useIndexController({\n initialIndex,\n itemWidth,\n numberOfData: data.length,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n onPositionChange,\n });\n\n const { getCurrentIndex } = indexController;\n\n const {\n gestureTranslationX,\n globalInterpolation,\n interruptAnimation,\n startPagingAnimation,\n } = usePagingAnimator({\n createScrollAnimation,\n itemWidth,\n indexController,\n initialIndex,\n loop,\n numberOfData: data.length,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getCurrentIndex,\n next: () => startPagingAnimation('directional', { direction: 'next' }),\n prev: () => startPagingAnimation('directional', { direction: 'prev' }),\n scrollTo: (option) => startPagingAnimation('index', option),\n }),\n [startPagingAnimation, getCurrentIndex],\n );\n\n const contextValue = useMemo(() => ({\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n needsOffscreenAlphaCompositingOnItem,\n }), [\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n needsOffscreenAlphaCompositingOnItem,\n ]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n <ViewabilityTrackerView\n enabled={autoplay && !disableSmartAutoplay}\n measurementIntervalMillis={Math.max(3000, autoplayInterval)}\n onViewabilityChange={({ visible }) => {\n if (visible) {\n autoplayController.resume();\n } else {\n autoplayController.pause();\n }\n }}\n >\n <ScrollViewGesture\n autoplayController={autoplayController}\n gestureTranslationX={gestureTranslationX}\n interruptAnimation={interruptAnimation}\n scrollEnabled={scrollEnabled}\n startPagingAnimation={startPagingAnimation}\n >\n <RootView\n data={data}\n itemHeight={itemHeight}\n originalData={originalData}\n renderItem={renderItem}\n style={style}\n />\n </ScrollViewGesture>\n </ViewabilityTrackerView>\n </InternalContext.Provider>\n );\n});\n\nexport default memo(Carousel);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAkCC,mBAAlC,EAAuDC,OAAvD,QAAsE,OAAtE;AACA,OAAOC,sBAAP,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;MAAF,CAAgB;;MAClC,IAAIA,OAAJ,EAAa;QACTX,kBAAkB,CAACY,MAAnB;MACH,CAFD,MAEO;QACHZ,kBAAkB,CAACa,KAAnB;MACH;IACJ;EATL,gBAWI,oBAAC,iBAAD;IACI,kBAAkB,EAAEb,kBADxB;IAEI,mBAAmB,EAAEJ,mBAFzB;IAGI,kBAAkB,EAAEE,kBAHxB;IAII,aAAa,EAAEZ,aAJnB;IAKI,oBAAoB,EAAEa;EAL1B,gBAOI,oBAAC,QAAD;IACI,IAAI,EAAEvB,IADV;IAEI,UAAU,EAAEI,UAFhB;IAGI,YAAY,EAAEH,YAHlB;IAII,UAAU,EAAEQ,UAJhB;IAKI,KAAK,EAAEE;EALX,EAPJ,CAXJ,CADJ,CADJ;AA+BH,CAzH0B,CAA3B;AA2HA,4BAAehC,IAAI,CAACc,QAAD,CAAnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type {\n CarouselInstance,\n CreateItemStyle,\n CreateScrollAnimation,\n ItemHeight,\n OnIndexChange,\n RenderItem,\n} from './types';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n ref?: RefObject<CarouselInstance>;\n\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * The item style creator function.\n * @default createDefaultItemStyle\n */\n createItemStyle?: CreateItemStyle;\n\n /**\n * The scroll animation creator function.\n * @default createDefaultScrollAnimation\n */\n createScrollAnimation?: CreateScrollAnimation;\n\n /**\n * Data for render items.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * If `true`, carousel will detect its own viewability and control autoplay automatically.\n * @default false\n */\n disableSmartAutoplay?: boolean;\n\n /**\n * Index of initial item that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * The item height.\n * For a performance reason, always consider to provide a number value.\n */\n itemHeight: ItemHeight;\n\n /**\n * The item width.\n */\n itemWidth: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n loop?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onIndexChange?: OnIndexChange;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: RenderItem<ItemT>;\n\n /**\n * Whether to enable scroll gesture.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * The maximum number of items that can respond to pan gesture events.\n * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)\n * 0 means all items will respond to pan gesture events.\n * @default 5\n */\n windowSize?: number;\n}> {}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type {\n CarouselInstance,\n CreateItemStyle,\n CreateScrollAnimation,\n ItemHeight,\n OnIndexChange,\n RenderItem,\n} from './types';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n ref?: RefObject<CarouselInstance>;\n\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * The item style creator function.\n * @default createDefaultItemStyle\n */\n createItemStyle?: CreateItemStyle;\n\n /**\n * The scroll animation creator function.\n * @default createDefaultScrollAnimation\n */\n createScrollAnimation?: CreateScrollAnimation;\n\n /**\n * Data for render items.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * If `true`, carousel will detect its own viewability and control autoplay automatically.\n * @default false\n */\n disableSmartAutoplay?: boolean;\n\n /**\n * Index of initial item that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * The item height.\n * For a performance reason, always consider to provide a number value.\n */\n itemHeight: ItemHeight;\n\n /**\n * The item width.\n */\n itemWidth: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n loop?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onIndexChange?: OnIndexChange;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: RenderItem<ItemT>;\n\n /**\n * Whether to enable scroll gesture.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * The maximum number of items that can respond to pan gesture events.\n * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)\n * 0 means all items will respond to pan gesture events.\n * @default 5\n */\n windowSize?: number;\n\n /**\n * Whether item views need to be rendered offscreen and composited with an alpha \n * in order to preserve 100% correct colors and blending behavior.\n * Use this when items have opacity animations and multiple overlapping elements.\n * @default false\n */\n needsOffscreenAlphaCompositingOnItem?: boolean;\n}> {}\n"],"mappings":""}
|
|
@@ -12,7 +12,8 @@ const initialValue = {
|
|
|
12
12
|
itemHeight: 0,
|
|
13
13
|
itemWidth: 0,
|
|
14
14
|
itemVisibilityStore: mockItemVisibilityStore,
|
|
15
|
-
loop: false
|
|
15
|
+
loop: false,
|
|
16
|
+
needsOffscreenAlphaCompositingOnItem: false
|
|
16
17
|
};
|
|
17
18
|
const InternalContext = /*#__PURE__*/createContext(initialValue);
|
|
18
19
|
export default InternalContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","Animated","mockItemVisibilityStore","dispatch","subscribe","removeAllListeners","initialValue","createItemStyle","data","globalInterpolation","add","Value","itemHeight","itemWidth","itemVisibilityStore","loop","InternalContext"],"sources":["InternalContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\nimport type { CreateItemStyle, ItemHeight, ItemVisibilityStore } from '../types';\n\nexport interface InternalContextValue<ItemT> {\n createItemStyle: CreateItemStyle;\n data: ReadonlyArray<ItemT>;\n globalInterpolation: Animated.AnimatedInterpolation;\n itemHeight: ItemHeight;\n itemWidth: number;\n itemVisibilityStore: ItemVisibilityStore;\n loop: boolean;\n}\n\nconst mockItemVisibilityStore: ItemVisibilityStore = {\n dispatch: () => void 0,\n subscribe: () => () => void 0,\n removeAllListeners: () => void 0,\n};\n\nconst initialValue: Readonly<InternalContextValue<any>> = {\n createItemStyle: () => ({}),\n data: [],\n globalInterpolation: Animated.add(new Animated.Value(0), 0),\n itemHeight: 0,\n itemWidth: 0,\n itemVisibilityStore: mockItemVisibilityStore,\n loop: false,\n};\n\nconst InternalContext = createContext<InternalContextValue<any>>(initialValue);\n\nexport default InternalContext;\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;
|
|
1
|
+
{"version":3,"names":["createContext","Animated","mockItemVisibilityStore","dispatch","subscribe","removeAllListeners","initialValue","createItemStyle","data","globalInterpolation","add","Value","itemHeight","itemWidth","itemVisibilityStore","loop","needsOffscreenAlphaCompositingOnItem","InternalContext"],"sources":["InternalContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\nimport type { CreateItemStyle, ItemHeight, ItemVisibilityStore } from '../types';\n\nexport interface InternalContextValue<ItemT> {\n createItemStyle: CreateItemStyle;\n data: ReadonlyArray<ItemT>;\n globalInterpolation: Animated.AnimatedInterpolation;\n itemHeight: ItemHeight;\n itemWidth: number;\n itemVisibilityStore: ItemVisibilityStore;\n loop: boolean;\n needsOffscreenAlphaCompositingOnItem: boolean;\n}\n\nconst mockItemVisibilityStore: ItemVisibilityStore = {\n dispatch: () => void 0,\n subscribe: () => () => void 0,\n removeAllListeners: () => void 0,\n};\n\nconst initialValue: Readonly<InternalContextValue<any>> = {\n createItemStyle: () => ({}),\n data: [],\n globalInterpolation: Animated.add(new Animated.Value(0), 0),\n itemHeight: 0,\n itemWidth: 0,\n itemVisibilityStore: mockItemVisibilityStore,\n loop: false,\n needsOffscreenAlphaCompositingOnItem: false,\n};\n\nconst InternalContext = createContext<InternalContextValue<any>>(initialValue);\n\nexport default InternalContext;\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAcA,MAAMC,uBAA4C,GAAG;EACjDC,QAAQ,EAAE,MAAM,KAAK,CAD4B;EAEjDC,SAAS,EAAE,MAAM,MAAM,KAAK,CAFqB;EAGjDC,kBAAkB,EAAE,MAAM,KAAK;AAHkB,CAArD;AAMA,MAAMC,YAAiD,GAAG;EACtDC,eAAe,EAAE,OAAO,EAAP,CADqC;EAEtDC,IAAI,EAAE,EAFgD;EAGtDC,mBAAmB,EAAER,QAAQ,CAACS,GAAT,CAAa,IAAIT,QAAQ,CAACU,KAAb,CAAmB,CAAnB,CAAb,EAAoC,CAApC,CAHiC;EAItDC,UAAU,EAAE,CAJ0C;EAKtDC,SAAS,EAAE,CAL2C;EAMtDC,mBAAmB,EAAEZ,uBANiC;EAOtDa,IAAI,EAAE,KAPgD;EAQtDC,oCAAoC,EAAE;AARgB,CAA1D;AAWA,MAAMC,eAAe,gBAAGjB,aAAa,CAA4BM,YAA5B,CAArC;AAEA,eAAeW,eAAf"}
|
|
@@ -13,7 +13,8 @@ export default function ItemView(props) {
|
|
|
13
13
|
createItemStyle,
|
|
14
14
|
itemHeight,
|
|
15
15
|
itemWidth,
|
|
16
|
-
itemVisibilityStore
|
|
16
|
+
itemVisibilityStore,
|
|
17
|
+
needsOffscreenAlphaCompositingOnItem
|
|
17
18
|
} = useContext(InternalContext);
|
|
18
19
|
const [visible, setVisible] = useState(false);
|
|
19
20
|
const interpolation = useItemInterpolation(index);
|
|
@@ -28,6 +29,7 @@ export default function ItemView(props) {
|
|
|
28
29
|
});
|
|
29
30
|
}, [index, itemVisibilityStore]);
|
|
30
31
|
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
32
|
+
needsOffscreenAlphaCompositing: needsOffscreenAlphaCompositingOnItem,
|
|
31
33
|
children: visible ? children(interpolation) : null,
|
|
32
34
|
onLayout: onLayout,
|
|
33
35
|
style: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useContext","useEffect","useMemo","useState","Animated","StyleSheet","useItemInterpolation","InternalContext","ItemView","props","children","index","onLayout","createItemStyle","itemHeight","itemWidth","itemVisibilityStore","visible","setVisible","interpolation","itemStyle","subscribe","ranges","nextVisible","some","from","to","width","height","undefined","styles","absolute","create","position"],"sources":["ItemView.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport useItemInterpolation from './useItemInterpolation';\nimport InternalContext from './InternalContext';\n\nexport interface ItemViewProps {\n children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;\n index: number;\n onLayout?: ViewProps['onLayout'];\n}\n\nexport default function ItemView(props: ItemViewProps) {\n const {\n children,\n index,\n onLayout,\n } = props;\n\n const {\n createItemStyle,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n } = useContext(InternalContext);\n\n const [visible, setVisible] = useState(false);\n\n const interpolation = useItemInterpolation(index);\n\n const itemStyle = useMemo(\n () => createItemStyle(interpolation, itemWidth),\n [createItemStyle, interpolation, itemWidth],\n );\n\n useEffect(() => {\n return itemVisibilityStore.subscribe(ranges => {\n const nextVisible = ranges.some(([from, to]) => index >= from && index <= to);\n setVisible(nextVisible);\n });\n }, [index, itemVisibilityStore]);\n\n return (\n <Animated.View\n children={visible ? children(interpolation) : null}\n onLayout={onLayout}\n style={[\n {\n width: itemWidth,\n height: itemHeight !== 'auto' ? itemHeight : undefined,\n },\n styles.absolute,\n // @ts-ignore\n itemStyle,\n ]}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: 'absolute',\n },\n});\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,EAAuCC,OAAvC,EAAgDC,QAAhD,QAAgE,OAAhE;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAQA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;EACnD,MAAM;IACFC,QADE;IAEFC,KAFE;IAGFC;EAHE,IAIFH,KAJJ;EAMA,MAAM;IACFI,eADE;IAEFC,UAFE;IAGFC,SAHE;IAIFC;
|
|
1
|
+
{"version":3,"names":["React","useContext","useEffect","useMemo","useState","Animated","StyleSheet","useItemInterpolation","InternalContext","ItemView","props","children","index","onLayout","createItemStyle","itemHeight","itemWidth","itemVisibilityStore","needsOffscreenAlphaCompositingOnItem","visible","setVisible","interpolation","itemStyle","subscribe","ranges","nextVisible","some","from","to","width","height","undefined","styles","absolute","create","position"],"sources":["ItemView.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport useItemInterpolation from './useItemInterpolation';\nimport InternalContext from './InternalContext';\n\nexport interface ItemViewProps {\n children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;\n index: number;\n onLayout?: ViewProps['onLayout'];\n}\n\nexport default function ItemView(props: ItemViewProps) {\n const {\n children,\n index,\n onLayout,\n } = props;\n\n const {\n createItemStyle,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n needsOffscreenAlphaCompositingOnItem,\n } = useContext(InternalContext);\n\n const [visible, setVisible] = useState(false);\n\n const interpolation = useItemInterpolation(index);\n\n const itemStyle = useMemo(\n () => createItemStyle(interpolation, itemWidth),\n [createItemStyle, interpolation, itemWidth],\n );\n\n useEffect(() => {\n return itemVisibilityStore.subscribe(ranges => {\n const nextVisible = ranges.some(([from, to]) => index >= from && index <= to);\n setVisible(nextVisible);\n });\n }, [index, itemVisibilityStore]);\n\n return (\n <Animated.View\n needsOffscreenAlphaCompositing={needsOffscreenAlphaCompositingOnItem}\n children={visible ? children(interpolation) : null}\n onLayout={onLayout}\n style={[\n {\n width: itemWidth,\n height: itemHeight !== 'auto' ? itemHeight : undefined,\n },\n styles.absolute,\n // @ts-ignore\n itemStyle,\n ]}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: 'absolute',\n },\n});\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,EAAuCC,OAAvC,EAAgDC,QAAhD,QAAgE,OAAhE;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAQA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;EACnD,MAAM;IACFC,QADE;IAEFC,KAFE;IAGFC;EAHE,IAIFH,KAJJ;EAMA,MAAM;IACFI,eADE;IAEFC,UAFE;IAGFC,SAHE;IAIFC,mBAJE;IAKFC;EALE,IAMFjB,UAAU,CAACO,eAAD,CANd;EAQA,MAAM,CAACW,OAAD,EAAUC,UAAV,IAAwBhB,QAAQ,CAAC,KAAD,CAAtC;EAEA,MAAMiB,aAAa,GAAGd,oBAAoB,CAACK,KAAD,CAA1C;EAEA,MAAMU,SAAS,GAAGnB,OAAO,CACrB,MAAMW,eAAe,CAACO,aAAD,EAAgBL,SAAhB,CADA,EAErB,CAACF,eAAD,EAAkBO,aAAlB,EAAiCL,SAAjC,CAFqB,CAAzB;EAKAd,SAAS,CAAC,MAAM;IACZ,OAAOe,mBAAmB,CAACM,SAApB,CAA8BC,MAAM,IAAI;MAC3C,MAAMC,WAAW,GAAGD,MAAM,CAACE,IAAP,CAAY;QAAA,IAAC,CAACC,IAAD,EAAOC,EAAP,CAAD;QAAA,OAAgBhB,KAAK,IAAIe,IAAT,IAAiBf,KAAK,IAAIgB,EAA1C;MAAA,CAAZ,CAApB;MACAR,UAAU,CAACK,WAAD,CAAV;IACH,CAHM,CAAP;EAIH,CALQ,EAKN,CAACb,KAAD,EAAQK,mBAAR,CALM,CAAT;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,8BAA8B,EAAEC,oCADpC;IAEI,QAAQ,EAAEC,OAAO,GAAGR,QAAQ,CAACU,aAAD,CAAX,GAA6B,IAFlD;IAGI,QAAQ,EAAER,QAHd;IAII,KAAK,EAAE,CACH;MACIgB,KAAK,EAAEb,SADX;MAEIc,MAAM,EAAEf,UAAU,KAAK,MAAf,GAAwBA,UAAxB,GAAqCgB;IAFjD,CADG,EAKHC,MAAM,CAACC,QALJ,EAMH;IACAX,SAPG;EAJX,EADJ;AAgBH;AAAA;AAED,MAAMU,MAAM,GAAG1B,UAAU,CAAC4B,MAAX,CAAkB;EAC7BD,QAAQ,EAAE;IACNE,QAAQ,EAAE;EADJ;AADmB,CAAlB,CAAf"}
|
|
@@ -3,15 +3,16 @@ import * as R from 'ramda';
|
|
|
3
3
|
import { View } from 'react-native';
|
|
4
4
|
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
5
5
|
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
|
|
6
|
-
import { ChevronDown, ChevronUp } from '@fountain-ui/icons';
|
|
6
|
+
import { ChevronDown, ChevronUp } from '@fountain-ui/icons/src/v2Icons';
|
|
7
7
|
import { StyleSheet } from '@fountain-ui/core';
|
|
8
|
+
import { baseColors, commonColors } from '@fountain-ui/styles';
|
|
8
9
|
import { offsetToPercentage, percentageToOffset } from './util';
|
|
9
10
|
const INDICATOR_WIDTH = 28;
|
|
10
11
|
const styles = StyleSheet.create({
|
|
11
12
|
indicator: {
|
|
12
13
|
width: INDICATOR_WIDTH,
|
|
13
14
|
height: 48,
|
|
14
|
-
backgroundColor: '
|
|
15
|
+
backgroundColor: baseColors.gray['650'],
|
|
15
16
|
flexDirection: 'column',
|
|
16
17
|
alignItems: 'center',
|
|
17
18
|
justifyContent: 'center',
|
|
@@ -139,13 +140,9 @@ const FastScroll = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
139
140
|
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
140
141
|
style: [animatedStyle, styles.indicator]
|
|
141
142
|
}, /*#__PURE__*/React.createElement(ChevronUp, {
|
|
142
|
-
fill:
|
|
143
|
-
height: 20,
|
|
144
|
-
width: 20
|
|
143
|
+
fill: commonColors.static.strongInverse
|
|
145
144
|
}), /*#__PURE__*/React.createElement(ChevronDown, {
|
|
146
|
-
fill:
|
|
147
|
-
height: 20,
|
|
148
|
-
width: 20
|
|
145
|
+
fill: commonColors.static.strongInverse
|
|
149
146
|
}))));
|
|
150
147
|
});
|
|
151
148
|
export default FastScroll;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useRef","useState","R","View","Gesture","GestureDetector","Animated","runOnJS","useAnimatedStyle","useSharedValue","withDelay","withTiming","ChevronDown","ChevronUp","StyleSheet","offsetToPercentage","percentageToOffset","INDICATOR_WIDTH","styles","create","indicator","width","height","backgroundColor","flexDirection","alignItems","justifyContent","borderRadius","view","position","FastScroll","forwardRef","props","ref","absolutePosition","additionalLength","contentLength","initialScrollPercentage","movementRange","scrollContentToOffset","visibleDurations","hideMillis","showMillis","totalContentLength","contentOffset","Math","floor","contentPercentage","initialLastIndicatorOffset","lastIndicatorOffset","indicatorOffset","value","isIndicatorDragging","indicatorOpacity","visible","setVisible","animatedStyle","transform","translateY","opacity","right","defaultTo","onContentScroll","event","current","nativeEvent","y","offset","getIsIndicatorDragging","handleUpdate","setIsIndicatorDragging","pan","Pan","onBegin","e","onUpdate","translationY","onFinalize","hide","duration","show"],"sources":["FastScroll.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport * as R from 'ramda';\nimport { NativeScrollEvent, NativeSyntheticEvent, View } from 'react-native';\nimport { Gesture, GestureDetector } from 'react-native-gesture-handler';\nimport Animated, { runOnJS, useAnimatedStyle, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';\nimport { ChevronDown, ChevronUp } from '@fountain-ui/icons';\nimport { StyleSheet } from '@fountain-ui/core';\nimport FastScrollProps from './FastScrollProps';\nimport { offsetToPercentage, percentageToOffset } from './util';\n\nconst INDICATOR_WIDTH = 28;\n\nconst styles = StyleSheet.create({\n indicator: {\n width: INDICATOR_WIDTH,\n height: 48,\n backgroundColor: '#767676',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: 16,\n },\n view: {\n position: 'absolute',\n width: 0,\n },\n});\n\nconst FastScroll = React.forwardRef((props: FastScrollProps, ref) => {\n const {\n absolutePosition,\n additionalLength = 0,\n contentLength,\n initialScrollPercentage = 0,\n movementRange,\n scrollContentToOffset,\n visibleDurations = { hideMillis: 200, showMillis: 350 },\n } = props;\n\n const totalContentLength = contentLength + additionalLength;\n\n const contentOffset = Math.floor((initialScrollPercentage / 100) * contentLength);\n const contentPercentage = offsetToPercentage(contentOffset, totalContentLength);\n const initialLastIndicatorOffset = percentageToOffset(contentPercentage, movementRange);\n\n const lastIndicatorOffset = useSharedValue(initialLastIndicatorOffset);\n const indicatorOffset = useSharedValue(lastIndicatorOffset.value);\n\n const isIndicatorDragging = useRef(false);\n\n const indicatorOpacity = useSharedValue(0);\n const [visible, setVisible] = useState(false);\n\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: indicatorOffset.value }],\n opacity: indicatorOpacity.value,\n }));\n\n const position = {\n ...absolutePosition,\n right: R.defaultTo(0)(absolutePosition?.right) + INDICATOR_WIDTH,\n };\n\n const onContentScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>) => {\n if (!isIndicatorDragging.current) {\n const contentPercentage = offsetToPercentage(event.nativeEvent.contentOffset.y, totalContentLength);\n const offset = percentageToOffset(contentPercentage, movementRange);\n\n if (offset < 0 || indicatorOffset.value < 0) {\n lastIndicatorOffset.value = 0;\n indicatorOffset.value = 0;\n return;\n }\n\n if (offset > movementRange || indicatorOffset.value > movementRange) {\n lastIndicatorOffset.value = movementRange;\n indicatorOffset.value = movementRange;\n return;\n }\n\n lastIndicatorOffset.value = offset;\n indicatorOffset.value = offset;\n } else {\n setVisible(true);\n }\n }, [totalContentLength, movementRange]);\n\n const getIsIndicatorDragging = () => isIndicatorDragging.current;\n\n useImperativeHandle(\n ref,\n () => ({\n getIsIndicatorDragging,\n onContentScroll,\n setVisible,\n }),\n [onContentScroll],\n );\n\n const handleUpdate = () => {\n const contentPercentage = offsetToPercentage(indicatorOffset.value, movementRange);\n const offset = percentageToOffset(contentPercentage, totalContentLength);\n\n scrollContentToOffset(offset);\n };\n\n const setIsIndicatorDragging = (value: boolean) => isIndicatorDragging.current = value;\n\n const pan = Gesture.Pan()\n .onBegin((e) => {\n indicatorOffset.value = lastIndicatorOffset.value;\n runOnJS(setIsIndicatorDragging)(true);\n })\n .onUpdate((e) => {\n if (indicatorOffset.value <= 0 && e.translationY < 0) {\n indicatorOffset.value = 0;\n return;\n }\n\n if (indicatorOffset.value >= movementRange && e.translationY > 0) {\n indicatorOffset.value = movementRange;\n return;\n }\n\n indicatorOffset.value = lastIndicatorOffset.value + e.translationY;\n\n runOnJS(handleUpdate)();\n })\n .onFinalize((e) => {\n lastIndicatorOffset.value = indicatorOffset.value;\n runOnJS(setIsIndicatorDragging)(false);\n });\n\n const hide = () => indicatorOpacity.value = withDelay(0, withTiming(0, { duration: visibleDurations.hideMillis }));\n\n const show = () => indicatorOpacity.value = withDelay(0, withTiming(1, { duration: visibleDurations.showMillis }));\n\n useEffect(() => {\n if (visible) {\n indicatorOffset.value = lastIndicatorOffset.value;\n show();\n } else {\n hide();\n }\n }, [visible]);\n\n return (\n <View\n style={[\n { height: movementRange },\n styles.view,\n position,\n ]}\n >\n <GestureDetector gesture={pan}>\n <Animated.View style={[\n animatedStyle,\n styles.indicator,\n ]}>\n <ChevronUp\n fill={'#ededed'}\n height={20}\n width={20}\n />\n <ChevronDown\n fill={'#ededed'}\n height={20}\n width={20}\n />\n </Animated.View>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Q,EAON,CAACxB,OAAD,CAPM,CAAT;EASA,oBACI,oBAAC,IAAD;IACI,KAAK,EAAE,CACH;MAAEhC,MAAM,EAAEgB;IAAV,CADG,EAEHpB,MAAM,CAACU,IAFJ,EAGHC,QAHG;EADX,gBAOI,oBAAC,eAAD;IAAiB,OAAO,EAAE0C;EAA1B,gBACI,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAE,CAClBf,aADkB,EAElBtC,MAAM,CAACE,SAFW;EAAtB,gBAII,oBAAC,SAAD;IACI,IAAI,EAAE,SADV;IAEI,MAAM,EAAE,EAFZ;IAGI,KAAK,EAAE;EAHX,EAJJ,eASI,oBAAC,WAAD;IACI,IAAI,EAAE,SADV;IAEI,MAAM,EAAE,EAFZ;IAGI,KAAK,EAAE;EAHX,EATJ,CADJ,CAPJ,CADJ;AA2BH,CAjJkB,CAAnB;AAmJA,eAAeU,UAAf"}
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useRef","useState","R","View","Gesture","GestureDetector","Animated","runOnJS","useAnimatedStyle","useSharedValue","withDelay","withTiming","ChevronDown","ChevronUp","StyleSheet","baseColors","commonColors","offsetToPercentage","percentageToOffset","INDICATOR_WIDTH","styles","create","indicator","width","height","backgroundColor","gray","flexDirection","alignItems","justifyContent","borderRadius","view","position","FastScroll","forwardRef","props","ref","absolutePosition","additionalLength","contentLength","initialScrollPercentage","movementRange","scrollContentToOffset","visibleDurations","hideMillis","showMillis","totalContentLength","contentOffset","Math","floor","contentPercentage","initialLastIndicatorOffset","lastIndicatorOffset","indicatorOffset","value","isIndicatorDragging","indicatorOpacity","visible","setVisible","animatedStyle","transform","translateY","opacity","right","defaultTo","onContentScroll","event","current","nativeEvent","y","offset","getIsIndicatorDragging","handleUpdate","setIsIndicatorDragging","pan","Pan","onBegin","e","onUpdate","translationY","onFinalize","hide","duration","show","static","strongInverse"],"sources":["FastScroll.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport * as R from 'ramda';\nimport { NativeScrollEvent, NativeSyntheticEvent, View } from 'react-native';\nimport { Gesture, GestureDetector } from 'react-native-gesture-handler';\nimport Animated, { runOnJS, useAnimatedStyle, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';\nimport { ChevronDown, ChevronUp } from '@fountain-ui/icons/src/v2Icons';\nimport { StyleSheet } from '@fountain-ui/core';\nimport { baseColors, commonColors } from '@fountain-ui/styles';\nimport FastScrollProps from './FastScrollProps';\nimport { offsetToPercentage, percentageToOffset } from './util';\n\nconst INDICATOR_WIDTH = 28;\n\nconst styles = StyleSheet.create({\n indicator: {\n width: INDICATOR_WIDTH,\n height: 48,\n backgroundColor: baseColors.gray['650'],\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: 16,\n },\n view: {\n position: 'absolute',\n width: 0,\n },\n});\n\nconst FastScroll = React.forwardRef((props: FastScrollProps, ref) => {\n const {\n absolutePosition,\n additionalLength = 0,\n contentLength,\n initialScrollPercentage = 0,\n movementRange,\n scrollContentToOffset,\n visibleDurations = { hideMillis: 200, showMillis: 350 },\n } = props;\n\n const totalContentLength = contentLength + additionalLength;\n\n const contentOffset = Math.floor((initialScrollPercentage / 100) * contentLength);\n const contentPercentage = offsetToPercentage(contentOffset, totalContentLength);\n const initialLastIndicatorOffset = percentageToOffset(contentPercentage, movementRange);\n\n const lastIndicatorOffset = useSharedValue(initialLastIndicatorOffset);\n const indicatorOffset = useSharedValue(lastIndicatorOffset.value);\n\n const isIndicatorDragging = useRef(false);\n\n const indicatorOpacity = useSharedValue(0);\n const [visible, setVisible] = useState(false);\n\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: indicatorOffset.value }],\n opacity: indicatorOpacity.value,\n }));\n\n const position = {\n ...absolutePosition,\n right: R.defaultTo(0)(absolutePosition?.right) + INDICATOR_WIDTH,\n };\n\n const onContentScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>) => {\n if (!isIndicatorDragging.current) {\n const contentPercentage = offsetToPercentage(event.nativeEvent.contentOffset.y, totalContentLength);\n const offset = percentageToOffset(contentPercentage, movementRange);\n\n if (offset < 0 || indicatorOffset.value < 0) {\n lastIndicatorOffset.value = 0;\n indicatorOffset.value = 0;\n return;\n }\n\n if (offset > movementRange || indicatorOffset.value > movementRange) {\n lastIndicatorOffset.value = movementRange;\n indicatorOffset.value = movementRange;\n return;\n }\n\n lastIndicatorOffset.value = offset;\n indicatorOffset.value = offset;\n } else {\n setVisible(true);\n }\n }, [totalContentLength, movementRange]);\n\n const getIsIndicatorDragging = () => isIndicatorDragging.current;\n\n useImperativeHandle(\n ref,\n () => ({\n getIsIndicatorDragging,\n onContentScroll,\n setVisible,\n }),\n [onContentScroll],\n );\n\n const handleUpdate = () => {\n const contentPercentage = offsetToPercentage(indicatorOffset.value, movementRange);\n const offset = percentageToOffset(contentPercentage, totalContentLength);\n\n scrollContentToOffset(offset);\n };\n\n const setIsIndicatorDragging = (value: boolean) => isIndicatorDragging.current = value;\n\n const pan = Gesture.Pan()\n .onBegin((e) => {\n indicatorOffset.value = lastIndicatorOffset.value;\n runOnJS(setIsIndicatorDragging)(true);\n })\n .onUpdate((e) => {\n if (indicatorOffset.value <= 0 && e.translationY < 0) {\n indicatorOffset.value = 0;\n return;\n }\n\n if (indicatorOffset.value >= movementRange && e.translationY > 0) {\n indicatorOffset.value = movementRange;\n return;\n }\n\n indicatorOffset.value = lastIndicatorOffset.value + e.translationY;\n\n runOnJS(handleUpdate)();\n })\n .onFinalize((e) => {\n lastIndicatorOffset.value = indicatorOffset.value;\n runOnJS(setIsIndicatorDragging)(false);\n });\n\n const hide = () => indicatorOpacity.value = withDelay(0, withTiming(0, { duration: visibleDurations.hideMillis }));\n\n const show = () => indicatorOpacity.value = withDelay(0, withTiming(1, { duration: visibleDurations.showMillis }));\n\n useEffect(() => {\n if (visible) {\n indicatorOffset.value = lastIndicatorOffset.value;\n show();\n } else {\n hide();\n }\n }, [visible]);\n\n return (\n <View\n style={[\n { height: movementRange },\n styles.view,\n position,\n ]}\n >\n <GestureDetector gesture={pan}>\n <Animated.View style={[\n animatedStyle,\n styles.indicator,\n ]}>\n <ChevronUp fill={commonColors.static.strongInverse}/>\n\n <ChevronDown fill={commonColors.static.strongInverse}/>\n </Animated.View>\n </GestureDetector>\n </View>\n );\n});\n\nexport default FastScroll;"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,mBAAxC,EAA6DC,MAA7D,EAAqEC,QAArE,QAAqF,OAArF;AACA,OAAO,KAAKC,CAAZ,MAAmB,OAAnB;AACA,SAAkDC,IAAlD,QAA8D,cAA9D;AACA,SAASC,OAAT,EAAkBC,eAAlB,QAAyC,8BAAzC;AACA,OAAOC,QAAP,IAAmBC,OAAnB,EAA4BC,gBAA5B,EAA8CC,cAA9C,EAA8DC,SAA9D,EAAyEC,UAAzE,QAA2F,yBAA3F;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,gCAAvC;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,qBAAzC;AAEA,SAASC,kBAAT,EAA6BC,kBAA7B,QAAuD,QAAvD;AAEA,MAAMC,eAAe,GAAG,EAAxB;AAEA,MAAMC,MAAM,GAAGN,UAAU,CAACO,MAAX,CAAkB;EAC7BC,SAAS,EAAE;IACPC,KAAK,EAAEJ,eADA;IAEPK,MAAM,EAAE,EAFD;IAGPC,eAAe,EAAEV,UAAU,CAACW,IAAX,CAAgB,KAAhB,CAHV;IAIPC,aAAa,EAAE,QAJR;IAKPC,UAAU,EAAE,QALL;IAMPC,cAAc,EAAE,QANT;IAOPC,YAAY,EAAE;EAPP,CADkB;EAU7BC,IAAI,EAAE;IACFC,QAAQ,EAAE,UADR;IAEFT,KAAK,EAAE;EAFL;AAVuB,CAAlB,CAAf;AAgBA,MAAMU,UAAU,gBAAGrC,KAAK,CAACsC,UAAN,CAAiB,CAAC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IC,UAAU,CAAC,CAAD,EAAI;IAAEuE,QAAQ,EAAEvC,gBAAgB,CAACE;EAA7B,CAAJ,CAAd,CAArD;;EAEA/C,SAAS,CAAC,MAAM;IACZ,IAAI2D,OAAJ,EAAa;MACTJ,eAAe,CAACC,KAAhB,GAAwBF,mBAAmB,CAACE,KAA5C;MACA6B,IAAI;IACP,CAHD,MAGO;MACHF,IAAI;IACP;EACJ,CAPQ,EAON,CAACxB,OAAD,CAPM,CAAT;EASA,oBACI,oBAAC,IAAD;IACI,KAAK,EAAE,CACH;MAAEjC,MAAM,EAAEiB;IAAV,CADG,EAEHrB,MAAM,CAACW,IAFJ,EAGHC,QAHG;EADX,gBAOI,oBAAC,eAAD;IAAiB,OAAO,EAAE0C;EAA1B,gBACI,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAE,CAClBf,aADkB,EAElBvC,MAAM,CAACE,SAFW;EAAtB,gBAII,oBAAC,SAAD;IAAW,IAAI,EAAEN,YAAY,CAACoE,MAAb,CAAoBC;EAArC,EAJJ,eAMI,oBAAC,WAAD;IAAa,IAAI,EAAErE,YAAY,CAACoE,MAAb,CAAoBC;EAAvC,EANJ,CADJ,CAPJ,CADJ;AAoBH,CA1IkB,CAAnB;AA4IA,eAAepD,UAAf"}
|
|
@@ -24,7 +24,7 @@ export default function StatusBarProvider(props) {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const theme = useTheme();
|
|
27
|
-
const defaultColor = theme.palette.background.
|
|
27
|
+
const defaultColor = theme.palette.background.base;
|
|
28
28
|
const [visible, setVisible] = React.useState(initialVisible);
|
|
29
29
|
const [backgroundViewColor, setBackgroundViewColor] = React.useState(defaultColor);
|
|
30
30
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRef","Platform","StatusBar","RNStatusBar","View","R","useSafeAreaInsets","useTheme","css","Provider","initialVisible","select","ios","android","StatusBarProvider","props","children","currentStatusBarPropsRef","initialStatusBarPropsStack","Array","statusBarPropsStackRef","mergeStatusBarPropsRef","current","theme","defaultColor","palette","background","default","visible","setVisible","useState","backgroundViewColor","setBackgroundViewColor","setBackgroundColor","value","backgroundColor","OS","setBarStyle","animated","barStyle","setHidden","hidden","setTranslucent","translucent","updateStatusBarProps","statusBarProps","animatedBarStyle","isNil","restoreInitialStack","length","initialStatusBar","clearStack","pushStack","push","replaceStack","popStack","prevStack","undefined","pop","getCurrentStatusBarProps","shouldRenderBackgroundView","inset","backgroundViewStyle","height","top","left","position","right","zIndex","statusBar"],"sources":["StatusBarProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport type { StatusBarStyle } from 'react-native';\nimport { Platform, StatusBar as RNStatusBar, View } from 'react-native';\nimport * as R from 'ramda';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { useTheme } from '@fountain-ui/core';\nimport { css } from '@fountain-ui/styles';\nimport Provider from './Provider';\nimport type { StatusBarProps } from './Provider';\nimport type StatusBarProviderProps from './StatusBarProviderProps';\n\nconst initialVisible = Platform.select({\n ios: true,\n android: false,\n});\n\nexport default function StatusBarProvider(props: StatusBarProviderProps) {\n const { children } = props;\n\n const currentStatusBarPropsRef = useRef<StatusBarProps | {}>({});\n\n const initialStatusBarPropsStack = new Array<StatusBarProps>();\n const statusBarPropsStackRef = useRef(initialStatusBarPropsStack);\n\n const mergeStatusBarPropsRef = (props: StatusBarProps) => {\n currentStatusBarPropsRef.current = {\n ...currentStatusBarPropsRef.current,\n ...props,\n };\n };\n\n const theme = useTheme();\n const defaultColor = theme.palette.background.default;\n\n const [visible, setVisible] = React.useState(initialVisible);\n const [backgroundViewColor, setBackgroundViewColor] = React.useState(defaultColor);\n\n const setBackgroundColor = (value: string) => {\n mergeStatusBarPropsRef({ backgroundColor: value });\n\n if (Platform.OS === 'android') {\n RNStatusBar.setBackgroundColor(value);\n }\n\n if (Platform.OS === 'ios') {\n setBackgroundViewColor(value);\n }\n };\n\n const setBarStyle = (value: StatusBarStyle, animated?: boolean) => {\n mergeStatusBarPropsRef({ barStyle: value });\n RNStatusBar.setBarStyle(value, animated);\n };\n\n const setHidden = (value: boolean) => {\n mergeStatusBarPropsRef({ hidden: value });\n\n if (Platform.OS === 'ios') {\n setVisible(!value);\n }\n\n RNStatusBar.setHidden(value);\n };\n\n const setTranslucent = (value: boolean) => {\n mergeStatusBarPropsRef({ translucent: value });\n\n if (Platform.OS === 'android') {\n RNStatusBar.setTranslucent(value);\n }\n };\n\n const updateStatusBarProps = (statusBarProps: StatusBarProps) => {\n const {\n barStyle,\n animatedBarStyle,\n backgroundColor,\n hidden,\n translucent,\n } = statusBarProps;\n\n if (!R.isNil(barStyle)) {\n setBarStyle(barStyle, animatedBarStyle);\n }\n\n if (!R.isNil(backgroundColor)) {\n setBackgroundColor(backgroundColor);\n }\n\n if (!R.isNil(hidden)) {\n setHidden(hidden);\n }\n\n if (!R.isNil(translucent)) {\n setTranslucent(translucent);\n }\n };\n\n const restoreInitialStack = () => {\n if (statusBarPropsStackRef.current.length === 0) {\n return;\n }\n\n const initialStatusBar = statusBarPropsStackRef.current[0];\n updateStatusBarProps(initialStatusBar);\n\n statusBarPropsStackRef.current = [statusBarPropsStackRef.current[0]];\n };\n\n const clearStack = () => {\n statusBarPropsStackRef.current = new Array<StatusBarProps>();\n };\n\n const pushStack = (statusBarProps: StatusBarProps) => {\n updateStatusBarProps(statusBarProps);\n statusBarPropsStackRef.current.push(currentStatusBarPropsRef.current);\n };\n\n const replaceStack = (statusBarProps: StatusBarProps) => {\n if (statusBarPropsStackRef.current.length === 0) {\n return;\n }\n\n updateStatusBarProps(statusBarProps);\n statusBarPropsStackRef.current[statusBarPropsStackRef.current.length - 1] = currentStatusBarPropsRef.current;\n };\n\n const popStack = () => {\n if (statusBarPropsStackRef.current.length === 0) {\n return;\n }\n\n const prevStack = statusBarPropsStackRef.current.length >= 2\n ? statusBarPropsStackRef.current[statusBarPropsStackRef.current.length - 2]\n : undefined;\n\n statusBarPropsStackRef.current.pop();\n\n if (R.isNil(prevStack)) {\n return;\n }\n\n updateStatusBarProps(prevStack);\n };\n\n const getCurrentStatusBarProps = () => currentStatusBarPropsRef.current;\n\n const shouldRenderBackgroundView = Platform.OS === 'ios' && visible;\n\n const inset = useSafeAreaInsets();\n const backgroundViewStyle = css([\n {\n backgroundColor: backgroundViewColor,\n height: inset.top,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n zIndex: theme.zIndex.statusBar,\n },\n ]);\n\n return (\n <Provider value={{\n setBackgroundColor,\n setBarStyle,\n setHidden,\n setTranslucent,\n pushStack,\n popStack,\n replaceStack,\n getCurrentStatusBarProps,\n restoreInitialStack,\n clearStack,\n }}>\n {shouldRenderBackgroundView ? (\n <View style={backgroundViewStyle}/>\n ) : null}\n {children}\n </Provider>\n );\n}"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,MAAhB,QAA8B,OAA9B;AAEA,SAASC,QAAT,EAAmBC,SAAS,IAAIC,WAAhC,EAA6CC,IAA7C,QAAyD,cAAzD;AACA,OAAO,KAAKC,CAAZ,MAAmB,OAAnB;AACA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,SAASC,QAAT,QAAyB,mBAAzB;AACA,SAASC,GAAT,QAAoB,qBAApB;AACA,OAAOC,QAAP,MAAqB,YAArB;AAIA,MAAMC,cAAc,GAAGT,QAAQ,CAACU,MAAT,CAAgB;EACnCC,GAAG,EAAE,IAD8B;EAEnCC,OAAO,EAAE;AAF0B,CAAhB,CAAvB;AAKA,eAAe,SAASC,iBAAT,CAA2BC,KAA3B,EAA0D;EACrE,MAAM;IAAEC;EAAF,IAAeD,KAArB;EAEA,MAAME,wBAAwB,GAAGjB,MAAM,CAAsB,EAAtB,CAAvC;EAEA,MAAMkB,0BAA0B,GAAG,IAAIC,KAAJ,EAAnC;EACA,MAAMC,sBAAsB,GAAGpB,MAAM,CAACkB,0BAAD,CAArC;;EAEA,MAAMG,sBAAsB,GAAIN,KAAD,IAA2B;IACtDE,wBAAwB,CAACK,OAAzB,GA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,KAAK,EAAE,CALX;IAMIH,GAAG,EAAE,CANT;IAOII,MAAM,EAAE7C,KAAK,CAAC6C,MAAN,CAAaC;EAPzB,CAD4B,CAAD,CAA/B;EAYA,oBACI,oBAAC,QAAD;IAAU,KAAK,EAAE;MACbpC,kBADa;MAEbI,WAFa;MAGbG,SAHa;MAIbE,cAJa;MAKbU,SALa;MAMbG,QANa;MAObD,YAPa;MAQbK,wBARa;MASbX,mBATa;MAUbG;IAVa;EAAjB,GAYKS,0BAA0B,gBACvB,oBAAC,IAAD;IAAM,KAAK,EAAEE;EAAb,EADuB,GAEvB,IAdR,EAeK9C,QAfL,CADJ;AAmBH"}
|
|
1
|
+
{"version":3,"names":["React","useRef","Platform","StatusBar","RNStatusBar","View","R","useSafeAreaInsets","useTheme","css","Provider","initialVisible","select","ios","android","StatusBarProvider","props","children","currentStatusBarPropsRef","initialStatusBarPropsStack","Array","statusBarPropsStackRef","mergeStatusBarPropsRef","current","theme","defaultColor","palette","background","base","visible","setVisible","useState","backgroundViewColor","setBackgroundViewColor","setBackgroundColor","value","backgroundColor","OS","setBarStyle","animated","barStyle","setHidden","hidden","setTranslucent","translucent","updateStatusBarProps","statusBarProps","animatedBarStyle","isNil","restoreInitialStack","length","initialStatusBar","clearStack","pushStack","push","replaceStack","popStack","prevStack","undefined","pop","getCurrentStatusBarProps","shouldRenderBackgroundView","inset","backgroundViewStyle","height","top","left","position","right","zIndex","statusBar"],"sources":["StatusBarProvider.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport type { StatusBarStyle } from 'react-native';\nimport { Platform, StatusBar as RNStatusBar, View } from 'react-native';\nimport * as R from 'ramda';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { useTheme } from '@fountain-ui/core';\nimport { css } from '@fountain-ui/styles';\nimport Provider from './Provider';\nimport type { StatusBarProps } from './Provider';\nimport type StatusBarProviderProps from './StatusBarProviderProps';\n\nconst initialVisible = Platform.select({\n ios: true,\n android: false,\n});\n\nexport default function StatusBarProvider(props: StatusBarProviderProps) {\n const { children } = props;\n\n const currentStatusBarPropsRef = useRef<StatusBarProps | {}>({});\n\n const initialStatusBarPropsStack = new Array<StatusBarProps>();\n const statusBarPropsStackRef = useRef(initialStatusBarPropsStack);\n\n const mergeStatusBarPropsRef = (props: StatusBarProps) => {\n currentStatusBarPropsRef.current = {\n ...currentStatusBarPropsRef.current,\n ...props,\n };\n };\n\n const theme = useTheme();\n const defaultColor = theme.palette.background.base;\n\n const [visible, setVisible] = React.useState(initialVisible);\n const [backgroundViewColor, setBackgroundViewColor] = React.useState(defaultColor);\n\n const setBackgroundColor = (value: string) => {\n mergeStatusBarPropsRef({ backgroundColor: value });\n\n if (Platform.OS === 'android') {\n RNStatusBar.setBackgroundColor(value);\n }\n\n if (Platform.OS === 'ios') {\n setBackgroundViewColor(value);\n }\n };\n\n const setBarStyle = (value: StatusBarStyle, animated?: boolean) => {\n mergeStatusBarPropsRef({ barStyle: value });\n RNStatusBar.setBarStyle(value, animated);\n };\n\n const setHidden = (value: boolean) => {\n mergeStatusBarPropsRef({ hidden: value });\n\n if (Platform.OS === 'ios') {\n setVisible(!value);\n }\n\n RNStatusBar.setHidden(value);\n };\n\n const setTranslucent = (value: boolean) => {\n mergeStatusBarPropsRef({ translucent: value });\n\n if (Platform.OS === 'android') {\n RNStatusBar.setTranslucent(value);\n }\n };\n\n const updateStatusBarProps = (statusBarProps: StatusBarProps) => {\n const {\n barStyle,\n animatedBarStyle,\n backgroundColor,\n hidden,\n translucent,\n } = statusBarProps;\n\n if (!R.isNil(barStyle)) {\n setBarStyle(barStyle, animatedBarStyle);\n }\n\n if (!R.isNil(backgroundColor)) {\n setBackgroundColor(backgroundColor);\n }\n\n if (!R.isNil(hidden)) {\n setHidden(hidden);\n }\n\n if (!R.isNil(translucent)) {\n setTranslucent(translucent);\n }\n };\n\n const restoreInitialStack = () => {\n if (statusBarPropsStackRef.current.length === 0) {\n return;\n }\n\n const initialStatusBar = statusBarPropsStackRef.current[0];\n updateStatusBarProps(initialStatusBar);\n\n statusBarPropsStackRef.current = [statusBarPropsStackRef.current[0]];\n };\n\n const clearStack = () => {\n statusBarPropsStackRef.current = new Array<StatusBarProps>();\n };\n\n const pushStack = (statusBarProps: StatusBarProps) => {\n updateStatusBarProps(statusBarProps);\n statusBarPropsStackRef.current.push(currentStatusBarPropsRef.current);\n };\n\n const replaceStack = (statusBarProps: StatusBarProps) => {\n if (statusBarPropsStackRef.current.length === 0) {\n return;\n }\n\n updateStatusBarProps(statusBarProps);\n statusBarPropsStackRef.current[statusBarPropsStackRef.current.length - 1] = currentStatusBarPropsRef.current;\n };\n\n const popStack = () => {\n if (statusBarPropsStackRef.current.length === 0) {\n return;\n }\n\n const prevStack = statusBarPropsStackRef.current.length >= 2\n ? statusBarPropsStackRef.current[statusBarPropsStackRef.current.length - 2]\n : undefined;\n\n statusBarPropsStackRef.current.pop();\n\n if (R.isNil(prevStack)) {\n return;\n }\n\n updateStatusBarProps(prevStack);\n };\n\n const getCurrentStatusBarProps = () => currentStatusBarPropsRef.current;\n\n const shouldRenderBackgroundView = Platform.OS === 'ios' && visible;\n\n const inset = useSafeAreaInsets();\n const backgroundViewStyle = css([\n {\n backgroundColor: backgroundViewColor,\n height: inset.top,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n zIndex: theme.zIndex.statusBar,\n },\n ]);\n\n return (\n <Provider value={{\n setBackgroundColor,\n setBarStyle,\n setHidden,\n setTranslucent,\n pushStack,\n popStack,\n replaceStack,\n getCurrentStatusBarProps,\n restoreInitialStack,\n clearStack,\n }}>\n {shouldRenderBackgroundView ? (\n <View style={backgroundViewStyle}/>\n ) : null}\n {children}\n </Provider>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,MAAhB,QAA8B,OAA9B;AAEA,SAASC,QAAT,EAAmBC,SAAS,IAAIC,WAAhC,EAA6CC,IAA7C,QAAyD,cAAzD;AACA,OAAO,KAAKC,CAAZ,MAAmB,OAAnB;AACA,SAASC,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wC,CAAvE,CADY,GAEZQ,SAFN;IAIArC,sBAAsB,CAACE,OAAvB,CAA+BoC,GAA/B;;IAEA,IAAIrD,CAAC,CAAC0C,KAAF,CAAQS,SAAR,CAAJ,EAAwB;MACpB;IACH;;IAEDZ,oBAAoB,CAACY,SAAD,CAApB;EACH,CAhBD;;EAkBA,MAAMG,wBAAwB,GAAG,MAAM1C,wBAAwB,CAACK,OAAhE;;EAEA,MAAMsC,0BAA0B,GAAG3D,QAAQ,CAACmC,EAAT,KAAgB,KAAhB,IAAyBR,OAA5D;EAEA,MAAMiC,KAAK,GAAGvD,iBAAiB,EAA/B;EACA,MAAMwD,mBAAmB,GAAGtD,GAAG,CAAC,CAC5B;IACI2B,eAAe,EAAEJ,mBADrB;IAEIgC,MAAM,EAAEF,KAAK,CAACG,GAFlB;IAGIC,IAAI,EAAE,CAHV;IAIIC,QAAQ,EAAE,UAJd;IAKIC,KAAK,EAAE,CALX;IAMIH,GAAG,EAAE,CANT;IAOII,MAAM,EAAE7C,KAAK,CAAC6C,MAAN,CAAaC;EAPzB,CAD4B,CAAD,CAA/B;EAYA,oBACI,oBAAC,QAAD;IAAU,KAAK,EAAE;MACbpC,kBADa;MAEbI,WAFa;MAGbG,SAHa;MAIbE,cAJa;MAKbU,SALa;MAMbG,QANa;MAObD,YAPa;MAQbK,wBARa;MASbX,mBATa;MAUbG;IAVa;EAAjB,GAYKS,0BAA0B,gBACvB,oBAAC,IAAD;IAAM,KAAK,EAAEE;EAAb,EADuB,GAEvB,IAdR,EAeK9C,QAfL,CADJ;AAmBH"}
|
|
@@ -163,7 +163,7 @@ export default function useUnstableCollapsibleAppBar() {
|
|
|
163
163
|
duration: ANIMATION_DURATION_MILLIS
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
}
|
|
166
|
+
});
|
|
167
167
|
const hasCollapsible = collapsibleToolbarHeight > 0;
|
|
168
168
|
const appBarStyle = [animatedStyle, {
|
|
169
169
|
paddingTop: safeAreaInsets.top
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useRef","Platform","useAnimatedScrollHandler","useAnimatedStyle","useDerivedValue","useSharedValue","withTiming","useSafeAreaInsets","useAppbarStyles","useElevationStyle","useHeight","defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","translateY","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","animatedStyle","transform","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","duration","savedOffsetY","scrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","deltaY","dy","min","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","floating","undefined","scrollContentInsets"],"sources":["useUnstableCollapsibleAppBar.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport {\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport useAppbarStyles from './useAppbarStyles';\nimport useElevationStyle from './useElevationStyle';\nimport useHeight from './useHeight';\n\ntype WebOnlyStyle = { boxShadow: any };\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n shouldTranslateYReset?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n vectorY: SharedValue<number>;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n shouldTranslateYReset: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\nfunction useLargerValueOfLastTwoValues(value: number) {\n const refLatestTwoValues = useRef([0, 0]);\n\n refLatestTwoValues.current.shift();\n refLatestTwoValues.current.push(value);\n\n return Math.max(...refLatestTwoValues.current);\n}\n\nexport default function useUnstableCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { shouldTranslateYReset }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight, [collapsibleToolbarHeight]);\n\n const translateY = useSharedValue<number>(0);\n const lastTranslateY = useSharedValue<number>(0);\n const lastOffsetY = useSharedValue<number>(0);\n const prevOffsetY = useSharedValue<number>(0);\n const overlapped = useSharedValue<boolean>(false);\n const vectorY = useSharedValue<number>(0);\n\n const elevationStyle = useElevationStyle(4);\n const animatedStyle = useAnimatedStyle(() => {\n const transform = [{ translateY: translateY.value }];\n\n if (Platform.OS === 'web') {\n return {\n transform,\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n };\n }\n if (Platform.OS === 'android') {\n return {\n transform,\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n };\n }\n if (Platform.OS === 'ios') {\n return {\n transform,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n };\n }\n return {};\n }, [\n /**\n * FIXME: Consider add `elevationStyle` to dependencies.\n */\n ]);\n\n const indexRef = useRef<number>(0);\n const offsetsRef = useRef<Array<number>>([]);\n\n const onScrollViewChanged = useCallback((nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n if (shouldTranslateYReset) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n offsetsRef.current = [];\n overlapped.value = false;\n }\n\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n }\n }, [appBarHeight]);\n\n const scrollHandler = useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n const deltaY = offsetY - prevOffsetY.value;\n vectorY.value = (vectorY.value * deltaY >= 0 && offsetY > 0) ? vectorY.value + deltaY : deltaY;\n prevOffsetY.value = offsetY;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n overlapped.value = offsetY > 0;\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n }, [appBarHeight]);\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n { paddingTop: safeAreaInsets.top },\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n vectorY,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarMaxHeight : 0 },\n };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,OAApC;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AAEA,SACIC,wBADJ,EAEIC,gBAFJ,EAGIC,eAHJ,EAIIC,cAJJ,EAKIC,UALJ,QAMO,yBANP;AAOA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,O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cAAc,GAAG1C,wBAAwB,GAAG,CAAlD;EAEA,MAAM2C,WAAW,GAAG,CAChBjC,aADgB,EAEhB;IAAEkC,UAAU,EAAEhD,cAAc,CAACiD;EAA7B,CAFgB,EAGhBH,cAAc,GAAG/C,MAAM,CAACmD,QAAV,GAAqBC,SAHnB,CAApB;EAMA,OAAO;IACHJ,WADG;IAEHnC,OAFG;IAGHV,cAHG;IAIHG,0BAJG;IAKH2B,QAAQ,EAAEH,aALP;IAMHL,mBANG;IAOH4B,mBAAmB,EAAE;MAAEH,GAAG,EAAEH,cAAc,GAAG3C,eAAH,GAAqB;IAA1C;EAPlB,CAAP;AASH;AAAA"}
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","Platform","useAnimatedScrollHandler","useAnimatedStyle","useDerivedValue","useSharedValue","withTiming","useSafeAreaInsets","useAppbarStyles","useElevationStyle","useHeight","defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","translateY","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","animatedStyle","transform","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","duration","savedOffsetY","scrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","deltaY","dy","min","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","floating","undefined","scrollContentInsets"],"sources":["useUnstableCollapsibleAppBar.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport {\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport useAppbarStyles from './useAppbarStyles';\nimport useElevationStyle from './useElevationStyle';\nimport useHeight from './useHeight';\n\ntype WebOnlyStyle = { boxShadow: any };\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n shouldTranslateYReset?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n vectorY: SharedValue<number>;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n shouldTranslateYReset: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\nfunction useLargerValueOfLastTwoValues(value: number) {\n const refLatestTwoValues = useRef([0, 0]);\n\n refLatestTwoValues.current.shift();\n refLatestTwoValues.current.push(value);\n\n return Math.max(...refLatestTwoValues.current);\n}\n\nexport default function useUnstableCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { shouldTranslateYReset }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight, [collapsibleToolbarHeight]);\n\n const translateY = useSharedValue<number>(0);\n const lastTranslateY = useSharedValue<number>(0);\n const lastOffsetY = useSharedValue<number>(0);\n const prevOffsetY = useSharedValue<number>(0);\n const overlapped = useSharedValue<boolean>(false);\n const vectorY = useSharedValue<number>(0);\n\n const elevationStyle = useElevationStyle(4);\n const animatedStyle = useAnimatedStyle(() => {\n const transform = [{ translateY: translateY.value }];\n\n if (Platform.OS === 'web') {\n return {\n transform,\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n };\n }\n if (Platform.OS === 'android') {\n return {\n transform,\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n };\n }\n if (Platform.OS === 'ios') {\n return {\n transform,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n };\n }\n return {};\n }, [\n /**\n * FIXME: Consider add `elevationStyle` to dependencies.\n */\n ]);\n\n const indexRef = useRef<number>(0);\n const offsetsRef = useRef<Array<number>>([]);\n\n const onScrollViewChanged = useCallback((nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n if (shouldTranslateYReset) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n offsetsRef.current = [];\n overlapped.value = false;\n }\n\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n }\n }, [appBarHeight]);\n\n const scrollHandler = useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n const deltaY = offsetY - prevOffsetY.value;\n vectorY.value = (vectorY.value * deltaY >= 0 && offsetY > 0) ? vectorY.value + deltaY : deltaY;\n prevOffsetY.value = offsetY;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n overlapped.value = offsetY > 0;\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n });\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n { paddingTop: safeAreaInsets.top },\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n vectorY,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarMaxHeight : 0 },\n };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,OAApC;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AAEA,SACIC,wBADJ,EAEIC,gBAFJ,EAGIC,eAHJ,EAIIC,cAJJ,EAKIC,UALJ,QAMO,yBANP;AAOA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,SAAP,MAAsB,aAAtB;AA+BA,MAAMC,cAAiC,GAAG;EACtCC,qBAAqB,EAAE;AADe,CAA1C;AAIA,MAAMC,yBAAyB,GAAG,GAAlC;AAEA,MAAMC,uBAAuB,GAAGb,QAAQ,CAACc,EAAT,KAAgB,KAAhD;;AAEA,SAASC,6BAAT,CAAuCC,KAAvC,EAAsD;EAClD,MAAMC,kBAAkB,GAAGlB,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,CAAjC;EAEAkB,kBAAkB,CAACC,OAAnB,CAA2BC,KAA3B;EACAF,kBAAkB,CAACC,OAAnB,CAA2BE,IAA3B,CAAgCJ,KAAhC;EAEA,OAAOK,IAAI,CAACC,GAAL,CAAS,GAAGL,kBAAkB,CAACC,OAA/B,CAAP;AACH;;AAED,eAAe,SAASK,4BAAT,GAAgG;EAAA,IAA1DC,WAA0D,uEAAnCd,cAAmC;EAC3G,MAAM;IAAEC;EAAF,IAA+C,EACjD,GAAGD,cAD8C;IAEjD,GAAGc;EAF8C,CAArD;EAKA,MAAMC,MAAM,GAAGlB,eAAe,EAA9B;EAEA,MAAMmB,cAAc,GAAGpB,iBAAiB,EAAxC;EAEA,MAAM,CAACqB,YAAD,EAAeC,cAAf,IAAiCnB,SAAS,EAAhD;EACA,MAAMoB,eAAe,GAA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GAAGN,KAAK,GAAG,GAA1B;MAEA,MAAMO,cAAc,GAAIR,EAAE,GAAGO,SAAL,IAAkBV,OAAO,GAAGjC,YAA7B,GAA6C,CAA7C,GAAiDqC,KAAxE;MAEA3B,UAAU,CAACrB,KAAX,GAAmB4C,OAAO,GAAGW,cAAV,GAA2B,CAA9C;MAEAtC,UAAU,CAACjB,KAAX,GAAmBX,UAAU,CAACkE,cAAD,EAAiB;QAC1ClB,QAAQ,EAAEzC;MADgC,CAAjB,CAA7B;IAGH;EApE0C,CAAD,CAA9C;EAuEA,MAAM4D,cAAc,GAAG1C,wBAAwB,GAAG,CAAlD;EAEA,MAAM2C,WAAW,GAAG,CAChBjC,aADgB,EAEhB;IAAEkC,UAAU,EAAEhD,cAAc,CAACiD;EAA7B,CAFgB,EAGhBH,cAAc,GAAG/C,MAAM,CAACmD,QAAV,GAAqBC,SAHnB,CAApB;EAMA,OAAO;IACHJ,WADG;IAEHnC,OAFG;IAGHV,cAHG;IAIHG,0BAJG;IAKH2B,QAAQ,EAAEH,aALP;IAMHL,mBANG;IAOH4B,mBAAmB,EAAE;MAAEH,GAAG,EAAEH,cAAc,GAAG3C,eAAH,GAAqB;IAA1C;EAPlB,CAAP;AASH;AAAA"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ComponentProps } from '@fountain-ui/core';
|
|
2
|
+
import type { ComponentProps, ExtendedStyle } from '@fountain-ui/core';
|
|
3
3
|
export default interface BottomSheetProps extends ComponentProps<{
|
|
4
4
|
/**
|
|
5
5
|
* Opacity for BackdropComponent
|
|
6
6
|
* @default 0.5
|
|
7
7
|
*/
|
|
8
8
|
backdropOpacity?: number;
|
|
9
|
+
/**
|
|
10
|
+
* View style to be applied to the background component. (only native)
|
|
11
|
+
*/
|
|
12
|
+
backgroundStyle?: ExtendedStyle | ExtendedStyle[];
|
|
9
13
|
/**
|
|
10
14
|
* Border radius for bottom sheet
|
|
11
15
|
*/
|
|
@@ -45,5 +49,9 @@ export default interface BottomSheetProps extends ComponentProps<{
|
|
|
45
49
|
* @default []
|
|
46
50
|
*/
|
|
47
51
|
snapPoints?: Array<number | string>;
|
|
52
|
+
/**
|
|
53
|
+
* View style to be applied to the content area.
|
|
54
|
+
*/
|
|
55
|
+
style?: ExtendedStyle | ExtendedStyle[];
|
|
48
56
|
}> {
|
|
49
57
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react-native-reanimated" />
|
|
2
|
+
import type BottomSheetProps from './BottomSheetProps';
|
|
3
|
+
export default function useDynamicSnapPoints(snapPoints: BottomSheetProps['snapPoints']): {
|
|
4
|
+
animatedSnapPoints: Readonly<{
|
|
5
|
+
value: (string | number)[];
|
|
6
|
+
}>;
|
|
7
|
+
animatedHandleHeight: import("react-native-reanimated").SharedValue<number>;
|
|
8
|
+
animatedContentHeight: import("react-native-reanimated").SharedValue<number>;
|
|
9
|
+
handleContentLayout: ({ nativeEvent: { layout: { height }, }, }: {
|
|
10
|
+
nativeEvent: {
|
|
11
|
+
layout: {
|
|
12
|
+
height: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}) => void;
|
|
16
|
+
} | {
|
|
17
|
+
animatedHandleHeight: undefined;
|
|
18
|
+
animatedSnapPoints: (string | number)[] | undefined;
|
|
19
|
+
animatedContentHeight: undefined;
|
|
20
|
+
handleContentLayout: undefined;
|
|
21
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type CarouselProps from './CarouselProps';
|
|
3
3
|
import type { CarouselInstance } from './types';
|
|
4
|
-
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<CarouselProps<any>, "style" | "data" | "autoplay" | "autoplayInterval" | "createItemStyle" | "createScrollAnimation" | "disableSmartAutoplay" | "initialIndex" | "itemHeight" | "itemWidth" | "loop" | "onIndexChange" | "renderItem" | "scrollEnabled" | "windowSize"> & React.RefAttributes<CarouselInstance>>>;
|
|
4
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<CarouselProps<any>, "style" | "data" | "autoplay" | "autoplayInterval" | "createItemStyle" | "createScrollAnimation" | "disableSmartAutoplay" | "initialIndex" | "itemHeight" | "itemWidth" | "loop" | "onIndexChange" | "renderItem" | "scrollEnabled" | "windowSize" | "needsOffscreenAlphaCompositingOnItem"> & React.RefAttributes<CarouselInstance>>>;
|
|
5
5
|
export default _default;
|
|
@@ -71,5 +71,12 @@ export default interface CarouselProps<ItemT = any> extends ComponentProps<{
|
|
|
71
71
|
* @default 5
|
|
72
72
|
*/
|
|
73
73
|
windowSize?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Whether item views need to be rendered offscreen and composited with an alpha
|
|
76
|
+
* in order to preserve 100% correct colors and blending behavior.
|
|
77
|
+
* Use this when items have opacity animations and multiple overlapping elements.
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
80
|
+
needsOffscreenAlphaCompositingOnItem?: boolean;
|
|
74
81
|
}> {
|
|
75
82
|
}
|
|
@@ -9,6 +9,7 @@ export interface InternalContextValue<ItemT> {
|
|
|
9
9
|
itemWidth: number;
|
|
10
10
|
itemVisibilityStore: ItemVisibilityStore;
|
|
11
11
|
loop: boolean;
|
|
12
|
+
needsOffscreenAlphaCompositingOnItem: boolean;
|
|
12
13
|
}
|
|
13
14
|
declare const InternalContext: import("react").Context<InternalContextValue<any>>;
|
|
14
15
|
export default InternalContext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fountain-ui/lab",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.20",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Fountain-UI Team",
|
|
6
6
|
"description": "Incubator for Fountain-UI React components.",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@emotion/react": "^11.10.0",
|
|
19
19
|
"@emotion/styled": "^11.10.0",
|
|
20
|
-
"@fountain-ui/icons": "3.0.0-alpha.
|
|
20
|
+
"@fountain-ui/icons": "3.0.0-alpha.12",
|
|
21
21
|
"@fountain-ui/utils": "^3.0.0-alpha.1",
|
|
22
22
|
"react-native-calendars": "1.1267.0"
|
|
23
23
|
},
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
30
30
|
"react-native": "^0.63.0",
|
|
31
31
|
"react-native-gesture-handler": "^2.0.0",
|
|
32
|
-
"react-native-pager-view": "^4.0.0"
|
|
32
|
+
"react-native-pager-view": "^4.0.0",
|
|
33
|
+
"react-native-safe-area-context": "^4.0.0"
|
|
33
34
|
},
|
|
34
35
|
"peerDependenciesMeta": {
|
|
35
36
|
"@gorhom/bottom-sheet": {
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"publishConfig": {
|
|
71
72
|
"access": "public"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "1791de45a37a8f9c9810cfaaa3b84908ba0bda83"
|
|
74
75
|
}
|