@one-am/react-native-simple-image-slider 0.16.1 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +616 -19
- package/lib/commonjs/constants/layout.js +11 -0
- package/lib/commonjs/constants/layout.js.map +1 -0
- package/lib/commonjs/context/slider-context.js +47 -0
- package/lib/commonjs/context/slider-context.js.map +1 -0
- package/lib/commonjs/{utils/renderProp.js → context/slider-full-screen-context.js} +15 -8
- package/lib/commonjs/context/slider-full-screen-context.js.map +1 -0
- package/lib/commonjs/hooks/index.js +13 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/slider-state/index.js +40 -0
- package/lib/commonjs/hooks/slider-state/index.js.map +1 -0
- package/lib/commonjs/hooks/slider-state/use-slider-callbacks.js +63 -0
- package/lib/commonjs/hooks/slider-state/use-slider-callbacks.js.map +1 -0
- package/lib/commonjs/hooks/slider-state/use-slider-full-screen.js +24 -0
- package/lib/commonjs/hooks/slider-state/use-slider-full-screen.js.map +1 -0
- package/lib/commonjs/hooks/slider-state/use-slider-navigation.js +29 -0
- package/lib/commonjs/hooks/slider-state/use-slider-navigation.js.map +1 -0
- package/lib/commonjs/hooks/use-image-aspect-ratio.js +68 -0
- package/lib/commonjs/hooks/use-image-aspect-ratio.js.map +1 -0
- package/lib/commonjs/hooks/use-registered-callback.js +29 -0
- package/lib/commonjs/hooks/use-registered-callback.js.map +1 -0
- package/lib/commonjs/hooks/use-slider-state.js +72 -0
- package/lib/commonjs/hooks/use-slider-state.js.map +1 -0
- package/lib/commonjs/icons/{IconX.js → icon-x.js} +20 -26
- package/lib/commonjs/icons/icon-x.js.map +1 -0
- package/lib/commonjs/index.js +18 -47
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/pinch-to-zoom.js +207 -0
- package/lib/commonjs/internal/pinch-to-zoom.js.map +1 -0
- package/lib/commonjs/primitives/index.js +62 -0
- package/lib/commonjs/primitives/index.js.map +1 -0
- package/lib/commonjs/primitives/slider-close-button.js +45 -0
- package/lib/commonjs/primitives/slider-close-button.js.map +1 -0
- package/lib/commonjs/primitives/slider-content.js +170 -0
- package/lib/commonjs/primitives/slider-content.js.map +1 -0
- package/lib/commonjs/{AbsoluteComponentContainer.js → primitives/slider-corner.js} +19 -19
- package/lib/commonjs/primitives/slider-corner.js.map +1 -0
- package/lib/commonjs/{PageCounter.js → primitives/slider-description.js} +22 -31
- package/lib/commonjs/primitives/slider-description.js.map +1 -0
- package/lib/commonjs/primitives/slider-empty.js +32 -0
- package/lib/commonjs/primitives/slider-empty.js.map +1 -0
- package/lib/commonjs/primitives/slider-full-screen.js +114 -0
- package/lib/commonjs/primitives/slider-full-screen.js.map +1 -0
- package/lib/commonjs/primitives/slider-page-counter.js +63 -0
- package/lib/commonjs/primitives/slider-page-counter.js.map +1 -0
- package/lib/commonjs/primitives/slider.js +31 -0
- package/lib/commonjs/primitives/slider.js.map +1 -0
- package/lib/{module/@types → commonjs/types}/common.js.map +1 -1
- package/lib/commonjs/{@types/slider.js → types/context.js} +1 -1
- package/lib/commonjs/{@types/slider.js.map → types/context.js.map} +1 -1
- package/lib/{module/@types → commonjs/types}/icons.js.map +1 -1
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/pinch-to-zoom.js.map +1 -0
- package/lib/commonjs/types/slider-state.js +6 -0
- package/lib/commonjs/types/slider-state.js.map +1 -0
- package/lib/commonjs/utils/capitalize.js +10 -0
- package/lib/commonjs/utils/capitalize.js.map +1 -0
- package/lib/commonjs/utils/clamp.js.map +1 -1
- package/lib/module/constants/layout.js +7 -0
- package/lib/module/constants/layout.js.map +1 -0
- package/lib/module/context/slider-context.js +40 -0
- package/lib/module/context/slider-context.js.map +1 -0
- package/lib/module/context/slider-full-screen-context.js +19 -0
- package/lib/module/context/slider-full-screen-context.js.map +1 -0
- package/lib/module/hooks/index.js +4 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/slider-state/index.js +7 -0
- package/lib/module/hooks/slider-state/index.js.map +1 -0
- package/lib/module/hooks/slider-state/use-slider-callbacks.js +60 -0
- package/lib/module/hooks/slider-state/use-slider-callbacks.js.map +1 -0
- package/lib/module/hooks/slider-state/use-slider-full-screen.js +21 -0
- package/lib/module/hooks/slider-state/use-slider-full-screen.js.map +1 -0
- package/lib/module/hooks/slider-state/use-slider-navigation.js +25 -0
- package/lib/module/hooks/slider-state/use-slider-navigation.js.map +1 -0
- package/lib/module/hooks/use-image-aspect-ratio.js +64 -0
- package/lib/module/hooks/use-image-aspect-ratio.js.map +1 -0
- package/lib/module/hooks/use-registered-callback.js +26 -0
- package/lib/module/hooks/use-registered-callback.js.map +1 -0
- package/lib/module/hooks/use-slider-state.js +68 -0
- package/lib/module/hooks/use-slider-state.js.map +1 -0
- package/lib/module/icons/icon-x.js +32 -0
- package/lib/module/icons/icon-x.js.map +1 -0
- package/lib/module/index.js +2 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/pinch-to-zoom.js +202 -0
- package/lib/module/internal/pinch-to-zoom.js.map +1 -0
- package/lib/module/primitives/index.js +11 -0
- package/lib/module/primitives/index.js.map +1 -0
- package/lib/module/primitives/slider-close-button.js +40 -0
- package/lib/module/primitives/slider-close-button.js.map +1 -0
- package/lib/module/primitives/slider-content.js +165 -0
- package/lib/module/primitives/slider-content.js.map +1 -0
- package/lib/module/{AbsoluteComponentContainer.js → primitives/slider-corner.js} +19 -18
- package/lib/module/primitives/slider-corner.js.map +1 -0
- package/lib/module/primitives/slider-description.js +31 -0
- package/lib/module/primitives/slider-description.js.map +1 -0
- package/lib/module/primitives/slider-empty.js +28 -0
- package/lib/module/primitives/slider-empty.js.map +1 -0
- package/lib/module/primitives/slider-full-screen.js +109 -0
- package/lib/module/primitives/slider-full-screen.js.map +1 -0
- package/lib/module/primitives/slider-page-counter.js +59 -0
- package/lib/module/primitives/slider-page-counter.js.map +1 -0
- package/lib/module/primitives/slider.js +27 -0
- package/lib/module/primitives/slider.js.map +1 -0
- package/lib/{commonjs/@types → module/types}/common.js.map +1 -1
- package/lib/module/types/context.js +4 -0
- package/lib/module/types/context.js.map +1 -0
- package/lib/{commonjs/@types → module/types}/icons.js.map +1 -1
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/pinch-to-zoom.js.map +1 -0
- package/lib/module/types/slider-state.js +4 -0
- package/lib/module/types/slider-state.js.map +1 -0
- package/lib/module/utils/capitalize.js +7 -0
- package/lib/module/utils/capitalize.js.map +1 -0
- package/lib/module/utils/clamp.js +2 -1
- package/lib/module/utils/clamp.js.map +1 -1
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/__tests__/index.test.d.ts +1 -0
- package/lib/typescript/commonjs/src/__tests__/index.test.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/constants/layout.d.ts +5 -0
- package/lib/typescript/commonjs/src/constants/layout.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/slider-context.d.ts +8 -0
- package/lib/typescript/commonjs/src/context/slider-context.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/slider-full-screen-context.d.ts +6 -0
- package/lib/typescript/commonjs/src/context/slider-full-screen-context.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/slider-state/index.d.ts +5 -0
- package/lib/typescript/commonjs/src/hooks/slider-state/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/slider-state/use-slider-callbacks.d.ts +6 -0
- package/lib/typescript/commonjs/src/hooks/slider-state/use-slider-callbacks.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/slider-state/use-slider-full-screen.d.ts +8 -0
- package/lib/typescript/commonjs/src/hooks/slider-state/use-slider-full-screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/slider-state/use-slider-navigation.d.ts +5 -0
- package/lib/typescript/commonjs/src/hooks/slider-state/use-slider-navigation.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/use-image-aspect-ratio.d.ts +6 -0
- package/lib/typescript/commonjs/src/hooks/use-image-aspect-ratio.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/use-registered-callback.d.ts +8 -0
- package/lib/typescript/commonjs/src/hooks/use-registered-callback.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/use-slider-state.d.ts +4 -0
- package/lib/typescript/commonjs/src/hooks/use-slider-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/icons/icon-x.d.ts +6 -0
- package/lib/typescript/commonjs/src/icons/icon-x.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/{src/PinchToZoom.d.ts → commonjs/src/internal/pinch-to-zoom.d.ts} +9 -6
- package/lib/typescript/commonjs/src/internal/pinch-to-zoom.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/primitives/index.d.ts +17 -0
- package/lib/typescript/commonjs/src/primitives/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/primitives/slider-close-button.d.ts +12 -0
- package/lib/typescript/commonjs/src/primitives/slider-close-button.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/primitives/slider-content.d.ts +15 -0
- package/lib/typescript/commonjs/src/primitives/slider-content.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/primitives/slider-corner.d.ts +12 -0
- package/lib/typescript/commonjs/src/primitives/slider-corner.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/primitives/slider-description.d.ts +10 -0
- package/lib/typescript/commonjs/src/primitives/slider-description.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/primitives/slider-empty.d.ts +10 -0
- package/lib/typescript/commonjs/src/primitives/slider-empty.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/primitives/slider-full-screen.d.ts +10 -0
- package/lib/typescript/commonjs/src/primitives/slider-full-screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/primitives/slider-page-counter.d.ts +14 -0
- package/lib/typescript/commonjs/src/primitives/slider-page-counter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/primitives/slider.d.ts +30 -0
- package/lib/typescript/commonjs/src/primitives/slider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/common.d.ts +15 -0
- package/lib/typescript/commonjs/src/types/common.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/context.d.ts +25 -0
- package/lib/typescript/commonjs/src/types/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/icons.d.ts +8 -0
- package/lib/typescript/commonjs/src/types/icons.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/index.d.ts +6 -0
- package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/pinch-to-zoom.d.ts +9 -0
- package/lib/typescript/commonjs/src/types/pinch-to-zoom.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/slider-state.d.ts +39 -0
- package/lib/typescript/commonjs/src/types/slider-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/capitalize.d.ts +3 -0
- package/lib/typescript/commonjs/src/utils/capitalize.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/clamp.d.ts +3 -0
- package/lib/typescript/commonjs/src/utils/clamp.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/__tests__/index.test.d.ts +1 -0
- package/lib/typescript/module/src/__tests__/index.test.d.ts.map +1 -0
- package/lib/typescript/module/src/constants/layout.d.ts +5 -0
- package/lib/typescript/module/src/constants/layout.d.ts.map +1 -0
- package/lib/typescript/module/src/context/slider-context.d.ts +8 -0
- package/lib/typescript/module/src/context/slider-context.d.ts.map +1 -0
- package/lib/typescript/module/src/context/slider-full-screen-context.d.ts +6 -0
- package/lib/typescript/module/src/context/slider-full-screen-context.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/index.d.ts +2 -0
- package/lib/typescript/module/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/slider-state/index.d.ts +5 -0
- package/lib/typescript/module/src/hooks/slider-state/index.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/slider-state/use-slider-callbacks.d.ts +6 -0
- package/lib/typescript/module/src/hooks/slider-state/use-slider-callbacks.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/slider-state/use-slider-full-screen.d.ts +8 -0
- package/lib/typescript/module/src/hooks/slider-state/use-slider-full-screen.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/slider-state/use-slider-navigation.d.ts +5 -0
- package/lib/typescript/module/src/hooks/slider-state/use-slider-navigation.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/use-image-aspect-ratio.d.ts +6 -0
- package/lib/typescript/module/src/hooks/use-image-aspect-ratio.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/use-registered-callback.d.ts +8 -0
- package/lib/typescript/module/src/hooks/use-registered-callback.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/use-slider-state.d.ts +4 -0
- package/lib/typescript/module/src/hooks/use-slider-state.d.ts.map +1 -0
- package/lib/typescript/module/src/icons/icon-x.d.ts +6 -0
- package/lib/typescript/module/src/icons/icon-x.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/pinch-to-zoom.d.ts +51 -0
- package/lib/typescript/module/src/internal/pinch-to-zoom.d.ts.map +1 -0
- package/lib/typescript/module/src/primitives/index.d.ts +17 -0
- package/lib/typescript/module/src/primitives/index.d.ts.map +1 -0
- package/lib/typescript/module/src/primitives/slider-close-button.d.ts +12 -0
- package/lib/typescript/module/src/primitives/slider-close-button.d.ts.map +1 -0
- package/lib/typescript/module/src/primitives/slider-content.d.ts +15 -0
- package/lib/typescript/module/src/primitives/slider-content.d.ts.map +1 -0
- package/lib/typescript/module/src/primitives/slider-corner.d.ts +12 -0
- package/lib/typescript/module/src/primitives/slider-corner.d.ts.map +1 -0
- package/lib/typescript/module/src/primitives/slider-description.d.ts +10 -0
- package/lib/typescript/module/src/primitives/slider-description.d.ts.map +1 -0
- package/lib/typescript/module/src/primitives/slider-empty.d.ts +10 -0
- package/lib/typescript/module/src/primitives/slider-empty.d.ts.map +1 -0
- package/lib/typescript/module/src/primitives/slider-full-screen.d.ts +10 -0
- package/lib/typescript/module/src/primitives/slider-full-screen.d.ts.map +1 -0
- package/lib/typescript/module/src/primitives/slider-page-counter.d.ts +14 -0
- package/lib/typescript/module/src/primitives/slider-page-counter.d.ts.map +1 -0
- package/lib/typescript/module/src/primitives/slider.d.ts +30 -0
- package/lib/typescript/module/src/primitives/slider.d.ts.map +1 -0
- package/lib/typescript/module/src/types/common.d.ts +15 -0
- package/lib/typescript/module/src/types/common.d.ts.map +1 -0
- package/lib/typescript/module/src/types/context.d.ts +25 -0
- package/lib/typescript/module/src/types/context.d.ts.map +1 -0
- package/lib/typescript/module/src/types/icons.d.ts +8 -0
- package/lib/typescript/module/src/types/icons.d.ts.map +1 -0
- package/lib/typescript/module/src/types/index.d.ts +6 -0
- package/lib/typescript/module/src/types/index.d.ts.map +1 -0
- package/lib/typescript/module/src/types/pinch-to-zoom.d.ts +9 -0
- package/lib/typescript/module/src/types/pinch-to-zoom.d.ts.map +1 -0
- package/lib/typescript/module/src/types/slider-state.d.ts +39 -0
- package/lib/typescript/module/src/types/slider-state.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/capitalize.d.ts +3 -0
- package/lib/typescript/module/src/utils/capitalize.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/clamp.d.ts +3 -0
- package/lib/typescript/module/src/utils/clamp.d.ts.map +1 -0
- package/package.json +79 -91
- package/lib/commonjs/@types/pinch-to-zoom.js.map +0 -1
- package/lib/commonjs/AbsoluteComponentContainer.js.map +0 -1
- package/lib/commonjs/BaseSimpleImageSlider.js +0 -209
- package/lib/commonjs/BaseSimpleImageSlider.js.map +0 -1
- package/lib/commonjs/FullScreenImageSlider.js +0 -132
- package/lib/commonjs/FullScreenImageSlider.js.map +0 -1
- package/lib/commonjs/PageCounter.js.map +0 -1
- package/lib/commonjs/PinchToZoom.js +0 -174
- package/lib/commonjs/PinchToZoom.js.map +0 -1
- package/lib/commonjs/SimpleImageSlider.js +0 -79
- package/lib/commonjs/SimpleImageSlider.js.map +0 -1
- package/lib/commonjs/SimpleImageSliderThemeProvider.js +0 -40
- package/lib/commonjs/SimpleImageSliderThemeProvider.js.map +0 -1
- package/lib/commonjs/icons/IconX.js.map +0 -1
- package/lib/commonjs/utils/renderProp.js.map +0 -1
- package/lib/module/@types/pinch-to-zoom.js.map +0 -1
- package/lib/module/@types/slider.js +0 -4
- package/lib/module/@types/slider.js.map +0 -1
- package/lib/module/AbsoluteComponentContainer.js.map +0 -1
- package/lib/module/BaseSimpleImageSlider.js +0 -202
- package/lib/module/BaseSimpleImageSlider.js.map +0 -1
- package/lib/module/FullScreenImageSlider.js +0 -125
- package/lib/module/FullScreenImageSlider.js.map +0 -1
- package/lib/module/PageCounter.js +0 -39
- package/lib/module/PageCounter.js.map +0 -1
- package/lib/module/PinchToZoom.js +0 -168
- package/lib/module/PinchToZoom.js.map +0 -1
- package/lib/module/SimpleImageSlider.js +0 -72
- package/lib/module/SimpleImageSlider.js.map +0 -1
- package/lib/module/SimpleImageSliderThemeProvider.js +0 -33
- package/lib/module/SimpleImageSliderThemeProvider.js.map +0 -1
- package/lib/module/icons/IconX.js +0 -37
- package/lib/module/icons/IconX.js.map +0 -1
- package/lib/module/utils/renderProp.js +0 -12
- package/lib/module/utils/renderProp.js.map +0 -1
- package/lib/typescript/src/@types/common.d.ts +0 -1
- package/lib/typescript/src/@types/common.d.ts.map +0 -1
- package/lib/typescript/src/@types/icons.d.ts +0 -6
- package/lib/typescript/src/@types/icons.d.ts.map +0 -1
- package/lib/typescript/src/@types/pinch-to-zoom.d.ts +0 -8
- package/lib/typescript/src/@types/pinch-to-zoom.d.ts.map +0 -1
- package/lib/typescript/src/@types/slider.d.ts +0 -5
- package/lib/typescript/src/@types/slider.d.ts.map +0 -1
- package/lib/typescript/src/AbsoluteComponentContainer.d.ts +0 -7
- package/lib/typescript/src/AbsoluteComponentContainer.d.ts.map +0 -1
- package/lib/typescript/src/BaseSimpleImageSlider.d.ts +0 -126
- package/lib/typescript/src/BaseSimpleImageSlider.d.ts.map +0 -1
- package/lib/typescript/src/FullScreenImageSlider.d.ts +0 -58
- package/lib/typescript/src/FullScreenImageSlider.d.ts.map +0 -1
- package/lib/typescript/src/PageCounter.d.ts +0 -22
- package/lib/typescript/src/PageCounter.d.ts.map +0 -1
- package/lib/typescript/src/PinchToZoom.d.ts.map +0 -1
- package/lib/typescript/src/SimpleImageSlider.d.ts +0 -52
- package/lib/typescript/src/SimpleImageSlider.d.ts.map +0 -1
- package/lib/typescript/src/SimpleImageSliderThemeProvider.d.ts +0 -17
- package/lib/typescript/src/SimpleImageSliderThemeProvider.d.ts.map +0 -1
- package/lib/typescript/src/icons/IconX.d.ts +0 -5
- package/lib/typescript/src/icons/IconX.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -9
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/utils/clamp.d.ts +0 -2
- package/lib/typescript/src/utils/clamp.d.ts.map +0 -1
- package/lib/typescript/src/utils/renderProp.d.ts +0 -4
- package/lib/typescript/src/utils/renderProp.d.ts.map +0 -1
- package/src/@types/common.ts +0 -0
- package/src/@types/icons.ts +0 -6
- package/src/@types/pinch-to-zoom.ts +0 -7
- package/src/@types/slider.ts +0 -5
- package/src/AbsoluteComponentContainer.tsx +0 -30
- package/src/BaseSimpleImageSlider.tsx +0 -384
- package/src/FullScreenImageSlider.tsx +0 -203
- package/src/PageCounter.tsx +0 -67
- package/src/PinchToZoom.tsx +0 -345
- package/src/SimpleImageSlider.tsx +0 -110
- package/src/SimpleImageSliderThemeProvider.tsx +0 -49
- package/src/icons/IconX.tsx +0 -24
- package/src/index.tsx +0 -29
- package/src/utils/clamp.ts +0 -4
- package/src/utils/renderProp.tsx +0 -22
- /package/lib/commonjs/{@types → types}/common.js +0 -0
- /package/lib/commonjs/{@types → types}/icons.js +0 -0
- /package/lib/commonjs/{@types → types}/pinch-to-zoom.js +0 -0
- /package/lib/module/{@types → types}/common.js +0 -0
- /package/lib/module/{@types → types}/icons.js +0 -0
- /package/lib/module/{@types → types}/pinch-to-zoom.js +0 -0
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef,
|
|
3
|
-
type ReactElement,
|
|
4
|
-
useCallback,
|
|
5
|
-
useEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from 'react';
|
|
10
|
-
import { FlashList, type ListRenderItemInfo } from '@shopify/flash-list';
|
|
11
|
-
import mergeRefs from 'merge-refs';
|
|
12
|
-
import { Image, type ImageStyle } from 'expo-image';
|
|
13
|
-
import {
|
|
14
|
-
type LayoutChangeEvent,
|
|
15
|
-
Platform,
|
|
16
|
-
Pressable,
|
|
17
|
-
type StyleProp,
|
|
18
|
-
StyleSheet,
|
|
19
|
-
type TextStyle,
|
|
20
|
-
type ViewStyle,
|
|
21
|
-
} from 'react-native';
|
|
22
|
-
import type ViewToken from '@shopify/flash-list/src/viewability/ViewToken';
|
|
23
|
-
import PageCounter, { type PageCounterProps } from './PageCounter';
|
|
24
|
-
import PinchToZoom, { type PinchToZoomProps } from './PinchToZoom';
|
|
25
|
-
import { GestureHandlerRootView, ScrollView } from 'react-native-gesture-handler';
|
|
26
|
-
import renderProp, { type RenderProp } from './utils/renderProp';
|
|
27
|
-
import type { SimpleImageSliderItem } from './@types/slider';
|
|
28
|
-
import type { PinchToZoomStatus } from './@types/pinch-to-zoom';
|
|
29
|
-
import Animated from 'react-native-reanimated';
|
|
30
|
-
import { AbsoluteComponentContainer } from './AbsoluteComponentContainer';
|
|
31
|
-
|
|
32
|
-
export type BaseSimpleImageSliderProps = {
|
|
33
|
-
/**
|
|
34
|
-
* @description The list of images to be displayed.
|
|
35
|
-
*/
|
|
36
|
-
data: SimpleImageSliderItem[];
|
|
37
|
-
/**
|
|
38
|
-
* @description The style of the container.
|
|
39
|
-
*/
|
|
40
|
-
style?: StyleProp<ViewStyle>;
|
|
41
|
-
/**
|
|
42
|
-
* @description The width of the images. If not provided, the image will take the full width of the container.
|
|
43
|
-
* Will be calculated automatically if `imageHeight` and `imageAspectRatio` are provided.
|
|
44
|
-
*/
|
|
45
|
-
imageWidth?: number;
|
|
46
|
-
/**
|
|
47
|
-
* @description The height of the images. If not provided, the image will take the full height of the container.
|
|
48
|
-
* Will be calculated automatically if `imageWidth` and `imageAspectRatio` are provided.
|
|
49
|
-
*/
|
|
50
|
-
imageHeight?: number;
|
|
51
|
-
/**
|
|
52
|
-
* @description The aspect ratio of the images. Will be ignored if `imageWidth` and `imageHeight` are provided.
|
|
53
|
-
* @default 4 / 3
|
|
54
|
-
*/
|
|
55
|
-
imageAspectRatio?: number;
|
|
56
|
-
/**
|
|
57
|
-
* @description Callback that is called when an item is pressed.
|
|
58
|
-
* @param item The item that was pressed.
|
|
59
|
-
* @param index The index of the item that was pressed.
|
|
60
|
-
*/
|
|
61
|
-
onItemPress?: (item: SimpleImageSliderItem, index: number) => void;
|
|
62
|
-
/**
|
|
63
|
-
* @description The maximum number of items to be displayed.
|
|
64
|
-
*/
|
|
65
|
-
maxItems?: number;
|
|
66
|
-
/**
|
|
67
|
-
* @description Whether the page counter should be displayed or not.
|
|
68
|
-
* @default true
|
|
69
|
-
*/
|
|
70
|
-
showPageCounter?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* @description The position of the page counter.
|
|
73
|
-
* @default 'bottom-left'
|
|
74
|
-
*/
|
|
75
|
-
pageCounterPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
76
|
-
/**
|
|
77
|
-
* @description The style of the page counter.
|
|
78
|
-
*/
|
|
79
|
-
pageCounterStyle?: StyleProp<ViewStyle>;
|
|
80
|
-
/**
|
|
81
|
-
* @description The style of the text of the page counter.
|
|
82
|
-
*/
|
|
83
|
-
pageCounterTextStyle?: StyleProp<TextStyle>;
|
|
84
|
-
/**
|
|
85
|
-
* @description A component to be displayed in place of the default page counter.
|
|
86
|
-
*/
|
|
87
|
-
PageCounterComponent?: React.FunctionComponent<PageCounterProps>;
|
|
88
|
-
/**
|
|
89
|
-
* @description Callback that renders the page counter. Overrides `PageCounterComponent` if provided.
|
|
90
|
-
* @param currentPage The current page number.
|
|
91
|
-
* @param totalPages The total number of pages.
|
|
92
|
-
*/
|
|
93
|
-
renderPageCounter?: (currentPage: number, totalPages: number) => ReactElement;
|
|
94
|
-
/**
|
|
95
|
-
* @description A component to be displayed in the top right corner.
|
|
96
|
-
*/
|
|
97
|
-
TopRightComponent?: RenderProp;
|
|
98
|
-
/**
|
|
99
|
-
* @description A component to be displayed in the top left corner.
|
|
100
|
-
*/
|
|
101
|
-
TopLeftComponent?: RenderProp;
|
|
102
|
-
/**
|
|
103
|
-
* @description A component to be displayed in the bottom right corner.
|
|
104
|
-
*/
|
|
105
|
-
BottomRightComponent?: RenderProp;
|
|
106
|
-
/**
|
|
107
|
-
* @description A component to be displayed in the bottom left corner.
|
|
108
|
-
*/
|
|
109
|
-
BottomLeftComponent?: RenderProp;
|
|
110
|
-
/**
|
|
111
|
-
* @description The index of the item to be displayed initially.
|
|
112
|
-
*/
|
|
113
|
-
indexOverride?: number;
|
|
114
|
-
/**
|
|
115
|
-
* @description Callback that is called when the viewable item changes.
|
|
116
|
-
* @param index The index of the new viewable item.
|
|
117
|
-
*/
|
|
118
|
-
onViewableItemChange?: (index: number) => void;
|
|
119
|
-
/**
|
|
120
|
-
* @description Whether the pinch to zoom feature is enabled or not.
|
|
121
|
-
* @default false
|
|
122
|
-
*/
|
|
123
|
-
enablePinchToZoom?: boolean;
|
|
124
|
-
/**
|
|
125
|
-
* @description Callback that is called when the pinch to zoom status changes.
|
|
126
|
-
* @param status The new status of the pinch to zoom.
|
|
127
|
-
*/
|
|
128
|
-
onPinchToZoomStatusChange?: PinchToZoomProps['onStatusChange'];
|
|
129
|
-
/**
|
|
130
|
-
* @description Callback that is called when gestures should lead to a dismissal.
|
|
131
|
-
*/
|
|
132
|
-
onPinchToZoomRequestClose?: PinchToZoomProps['onDismiss'];
|
|
133
|
-
/**
|
|
134
|
-
* @description The tag to be used for shared transitions. This is applied to the current image in the list.
|
|
135
|
-
*/
|
|
136
|
-
sharedTransitionTag?: string;
|
|
137
|
-
/**
|
|
138
|
-
* @description Style that will be applied to every image in the slider.
|
|
139
|
-
*/
|
|
140
|
-
imageStyle?: StyleProp<ImageStyle>;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const AnimatedImage = Animated.createAnimatedComponent(Image);
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @description A simple image slider that displays a list of images. This is the component
|
|
147
|
-
* that {@link SimpleImageSlider} and {@link FullScreenImageSlider}
|
|
148
|
-
* are built upon. You should normally use one of those two components instead of this one.
|
|
149
|
-
*/
|
|
150
|
-
const BaseSimpleImageSlider = forwardRef<
|
|
151
|
-
FlashList<SimpleImageSliderItem>,
|
|
152
|
-
BaseSimpleImageSliderProps
|
|
153
|
-
>(function BaseSimpleImageSlider(
|
|
154
|
-
{
|
|
155
|
-
data,
|
|
156
|
-
style,
|
|
157
|
-
imageWidth,
|
|
158
|
-
imageHeight,
|
|
159
|
-
imageAspectRatio = 4 / 3,
|
|
160
|
-
onItemPress,
|
|
161
|
-
maxItems,
|
|
162
|
-
showPageCounter = true,
|
|
163
|
-
pageCounterPosition = 'bottom-left',
|
|
164
|
-
pageCounterStyle,
|
|
165
|
-
pageCounterTextStyle,
|
|
166
|
-
PageCounterComponent = PageCounter,
|
|
167
|
-
renderPageCounter,
|
|
168
|
-
TopRightComponent,
|
|
169
|
-
TopLeftComponent,
|
|
170
|
-
BottomRightComponent,
|
|
171
|
-
BottomLeftComponent,
|
|
172
|
-
indexOverride,
|
|
173
|
-
onViewableItemChange,
|
|
174
|
-
enablePinchToZoom = false,
|
|
175
|
-
onPinchToZoomStatusChange,
|
|
176
|
-
onPinchToZoomRequestClose,
|
|
177
|
-
sharedTransitionTag,
|
|
178
|
-
imageStyle,
|
|
179
|
-
},
|
|
180
|
-
ref
|
|
181
|
-
) {
|
|
182
|
-
const listRef = useRef<FlashList<SimpleImageSliderItem>>(null);
|
|
183
|
-
|
|
184
|
-
const styles = useMemo(
|
|
185
|
-
() => makeStyles({ imageAspectRatio, imageWidth, imageHeight }),
|
|
186
|
-
[imageAspectRatio, imageHeight, imageWidth]
|
|
187
|
-
);
|
|
188
|
-
const slicedData = useMemo(
|
|
189
|
-
() => (maxItems !== undefined ? (data?.slice(0, maxItems) ?? []) : (data ?? [])),
|
|
190
|
-
[data, maxItems]
|
|
191
|
-
);
|
|
192
|
-
const estimatedItemSize = useMemo(() => {
|
|
193
|
-
return imageWidth ?? (imageHeight ? imageHeight * (imageAspectRatio ?? 4 / 3) : 350);
|
|
194
|
-
}, [imageAspectRatio, imageHeight, imageWidth]);
|
|
195
|
-
|
|
196
|
-
const [currentItem, setCurrentItem] = useState(0);
|
|
197
|
-
const [scrollEnabled, setScrollEnabled] = useState(true);
|
|
198
|
-
const [snapToInterval, setSnapToInterval] = useState<number | undefined>(undefined);
|
|
199
|
-
|
|
200
|
-
const handleScaleChange = useCallback(() => {
|
|
201
|
-
setScrollEnabled(false);
|
|
202
|
-
}, []);
|
|
203
|
-
|
|
204
|
-
const handleScaleReset = useCallback(() => {
|
|
205
|
-
setScrollEnabled(true);
|
|
206
|
-
}, []);
|
|
207
|
-
|
|
208
|
-
const handleViewableItemsChanged = useCallback(
|
|
209
|
-
({ viewableItems }: { viewableItems: ViewToken[]; changed: ViewToken[] }) => {
|
|
210
|
-
const newIndex = viewableItems[0]?.index;
|
|
211
|
-
if (newIndex !== undefined && newIndex !== null) {
|
|
212
|
-
setCurrentItem(newIndex);
|
|
213
|
-
onViewableItemChange?.(newIndex);
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
[onViewableItemChange]
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
const handlePinchToZoomStatusChange = useCallback(
|
|
220
|
-
(status: PinchToZoomStatus) => {
|
|
221
|
-
listRef.current?.recordInteraction();
|
|
222
|
-
onPinchToZoomStatusChange?.(status);
|
|
223
|
-
},
|
|
224
|
-
[onPinchToZoomStatusChange]
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
const renderItem = useCallback(
|
|
228
|
-
({ item, index }: ListRenderItemInfo<SimpleImageSliderItem>) => {
|
|
229
|
-
const ImageComponent =
|
|
230
|
-
sharedTransitionTag && index === currentItem ? AnimatedImage : Image;
|
|
231
|
-
|
|
232
|
-
return (
|
|
233
|
-
<Pressable
|
|
234
|
-
onPress={() => {
|
|
235
|
-
listRef.current?.recordInteraction();
|
|
236
|
-
onItemPress?.(item, index);
|
|
237
|
-
}}
|
|
238
|
-
>
|
|
239
|
-
<ImageComponent
|
|
240
|
-
sharedTransitionTag={sharedTransitionTag}
|
|
241
|
-
transition={200}
|
|
242
|
-
// https://github.com/expo/expo/issues/34810
|
|
243
|
-
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */
|
|
244
|
-
placeholder={item.placeholder}
|
|
245
|
-
placeholderContentFit={'cover'}
|
|
246
|
-
recyclingKey={item.key}
|
|
247
|
-
// https://github.com/expo/expo/issues/34810
|
|
248
|
-
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */
|
|
249
|
-
source={item.source}
|
|
250
|
-
contentFit={'cover'}
|
|
251
|
-
contentPosition={'center'}
|
|
252
|
-
style={[styles.image, imageStyle]}
|
|
253
|
-
/>
|
|
254
|
-
</Pressable>
|
|
255
|
-
);
|
|
256
|
-
},
|
|
257
|
-
[currentItem, imageStyle, onItemPress, sharedTransitionTag, styles.image]
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
const keyExtractor = useCallback((item: SimpleImageSliderItem) => item.key, []);
|
|
261
|
-
|
|
262
|
-
const handleListLayout = useCallback((event: LayoutChangeEvent) => {
|
|
263
|
-
if (Platform.OS === 'ios') {
|
|
264
|
-
// temporary workaround for iOS scrolling a bit more than expected
|
|
265
|
-
setSnapToInterval(event.nativeEvent.layout.width - 0.5);
|
|
266
|
-
}
|
|
267
|
-
}, []);
|
|
268
|
-
|
|
269
|
-
useEffect(() => {
|
|
270
|
-
setCurrentItem(indexOverride ?? 0);
|
|
271
|
-
|
|
272
|
-
listRef.current?.scrollToIndex({ index: indexOverride ?? 0, animated: false });
|
|
273
|
-
}, [indexOverride, slicedData]);
|
|
274
|
-
|
|
275
|
-
const list = (
|
|
276
|
-
<FlashList
|
|
277
|
-
renderScrollComponent={ScrollView}
|
|
278
|
-
scrollEnabled={scrollEnabled}
|
|
279
|
-
disableScrollViewPanResponder={enablePinchToZoom ? !scrollEnabled : false}
|
|
280
|
-
ref={mergeRefs(ref, listRef)}
|
|
281
|
-
initialScrollIndex={indexOverride ?? currentItem ?? 0}
|
|
282
|
-
onViewableItemsChanged={handleViewableItemsChanged}
|
|
283
|
-
viewabilityConfig={{
|
|
284
|
-
itemVisiblePercentThreshold: 55,
|
|
285
|
-
}}
|
|
286
|
-
decelerationRate={'fast'}
|
|
287
|
-
pagingEnabled={snapToInterval === undefined}
|
|
288
|
-
snapToInterval={snapToInterval}
|
|
289
|
-
showsHorizontalScrollIndicator={false}
|
|
290
|
-
showsVerticalScrollIndicator={false}
|
|
291
|
-
horizontal={true}
|
|
292
|
-
keyExtractor={keyExtractor}
|
|
293
|
-
renderItem={renderItem}
|
|
294
|
-
data={slicedData}
|
|
295
|
-
estimatedItemSize={estimatedItemSize}
|
|
296
|
-
estimatedListSize={{
|
|
297
|
-
width: estimatedItemSize,
|
|
298
|
-
height: imageHeight ?? estimatedItemSize / imageAspectRatio,
|
|
299
|
-
}}
|
|
300
|
-
onLayout={handleListLayout}
|
|
301
|
-
/>
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
return (
|
|
305
|
-
<GestureHandlerRootView style={[styles.container, style]}>
|
|
306
|
-
{enablePinchToZoom ? (
|
|
307
|
-
<PinchToZoom
|
|
308
|
-
style={styles.pinchToZoom}
|
|
309
|
-
onDismiss={onPinchToZoomRequestClose}
|
|
310
|
-
onStatusChange={handlePinchToZoomStatusChange}
|
|
311
|
-
onScaleChange={handleScaleChange}
|
|
312
|
-
onScaleReset={handleScaleReset}
|
|
313
|
-
maximumZoomScale={5}
|
|
314
|
-
minimumZoomScale={1}
|
|
315
|
-
>
|
|
316
|
-
{list}
|
|
317
|
-
</PinchToZoom>
|
|
318
|
-
) : (
|
|
319
|
-
list
|
|
320
|
-
)}
|
|
321
|
-
{showPageCounter ? (
|
|
322
|
-
renderPageCounter ? (
|
|
323
|
-
renderPageCounter(currentItem + 1, slicedData.length)
|
|
324
|
-
) : (
|
|
325
|
-
<AbsoluteComponentContainer position={pageCounterPosition}>
|
|
326
|
-
<PageCounterComponent
|
|
327
|
-
totalPages={slicedData.length}
|
|
328
|
-
currentPage={currentItem + 1}
|
|
329
|
-
style={pageCounterStyle}
|
|
330
|
-
textStyle={pageCounterTextStyle}
|
|
331
|
-
/>
|
|
332
|
-
</AbsoluteComponentContainer>
|
|
333
|
-
)
|
|
334
|
-
) : null}
|
|
335
|
-
{TopRightComponent ? (
|
|
336
|
-
<AbsoluteComponentContainer position={'top-right'}>
|
|
337
|
-
{renderProp(TopRightComponent)}
|
|
338
|
-
</AbsoluteComponentContainer>
|
|
339
|
-
) : null}
|
|
340
|
-
{TopLeftComponent ? (
|
|
341
|
-
<AbsoluteComponentContainer position={'top-left'}>
|
|
342
|
-
{renderProp(TopLeftComponent)}
|
|
343
|
-
</AbsoluteComponentContainer>
|
|
344
|
-
) : null}
|
|
345
|
-
{BottomRightComponent ? (
|
|
346
|
-
<AbsoluteComponentContainer position={'bottom-right'}>
|
|
347
|
-
{renderProp(BottomRightComponent)}
|
|
348
|
-
</AbsoluteComponentContainer>
|
|
349
|
-
) : null}
|
|
350
|
-
{BottomLeftComponent ? (
|
|
351
|
-
<AbsoluteComponentContainer position={'bottom-left'}>
|
|
352
|
-
{renderProp(BottomLeftComponent)}
|
|
353
|
-
</AbsoluteComponentContainer>
|
|
354
|
-
) : null}
|
|
355
|
-
</GestureHandlerRootView>
|
|
356
|
-
);
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
const makeStyles = ({
|
|
360
|
-
imageAspectRatio,
|
|
361
|
-
imageWidth,
|
|
362
|
-
imageHeight,
|
|
363
|
-
}: {
|
|
364
|
-
imageAspectRatio?: number;
|
|
365
|
-
imageWidth?: number;
|
|
366
|
-
imageHeight?: number;
|
|
367
|
-
}) => {
|
|
368
|
-
return StyleSheet.create({
|
|
369
|
-
container: {
|
|
370
|
-
width: '100%',
|
|
371
|
-
aspectRatio: imageAspectRatio ?? 4 / 3,
|
|
372
|
-
},
|
|
373
|
-
pinchToZoom: {
|
|
374
|
-
zIndex: 1000,
|
|
375
|
-
},
|
|
376
|
-
image: {
|
|
377
|
-
width: imageWidth ?? '100%',
|
|
378
|
-
height: imageHeight ?? '100%',
|
|
379
|
-
aspectRatio: imageAspectRatio ?? 4 / 3,
|
|
380
|
-
},
|
|
381
|
-
});
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
export default BaseSimpleImageSlider;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef,
|
|
3
|
-
type ReactNode,
|
|
4
|
-
useCallback,
|
|
5
|
-
useEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
useState,
|
|
8
|
-
} from 'react';
|
|
9
|
-
import {
|
|
10
|
-
Modal,
|
|
11
|
-
type ScaledSize,
|
|
12
|
-
StyleSheet,
|
|
13
|
-
TouchableOpacity,
|
|
14
|
-
useWindowDimensions,
|
|
15
|
-
View,
|
|
16
|
-
} from 'react-native';
|
|
17
|
-
import IconX from './icons/IconX';
|
|
18
|
-
import Animated, {
|
|
19
|
-
runOnJS,
|
|
20
|
-
useAnimatedStyle,
|
|
21
|
-
useSharedValue,
|
|
22
|
-
withTiming,
|
|
23
|
-
} from 'react-native-reanimated';
|
|
24
|
-
import { setStatusBarStyle } from 'expo-status-bar';
|
|
25
|
-
import { FlashList } from '@shopify/flash-list';
|
|
26
|
-
import BaseListImageSlider, { type BaseSimpleImageSliderProps } from './BaseSimpleImageSlider';
|
|
27
|
-
import { type EdgeInsets, useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
28
|
-
import type { PinchToZoomStatus } from './@types/pinch-to-zoom';
|
|
29
|
-
import type { SimpleImageSliderItem } from './@types/slider';
|
|
30
|
-
import renderProp, { type RenderProp } from './utils/renderProp';
|
|
31
|
-
import {
|
|
32
|
-
type SimpleImageSliderTheme,
|
|
33
|
-
useSimpleImageSliderTheme,
|
|
34
|
-
} from './SimpleImageSliderThemeProvider';
|
|
35
|
-
|
|
36
|
-
export type FullScreenImageSliderProps = Omit<BaseSimpleImageSliderProps, 'imageWidth'> & {
|
|
37
|
-
/**
|
|
38
|
-
* @description Whether the modal is open or not.
|
|
39
|
-
*/
|
|
40
|
-
open?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* @description Callback that is called when the modal is requested to be closed.
|
|
43
|
-
*/
|
|
44
|
-
onRequestClose?: () => void;
|
|
45
|
-
/**
|
|
46
|
-
* @description Callback that renders an element to be displayed as the description of the current image.
|
|
47
|
-
* @param item The current item being displayed.
|
|
48
|
-
* @param index The index of the current item being displayed.
|
|
49
|
-
*/
|
|
50
|
-
renderDescription?: (item: SimpleImageSliderItem, index: number) => ReactNode;
|
|
51
|
-
/**
|
|
52
|
-
* @description Item to be rendered in place of the default close button icon.
|
|
53
|
-
*/
|
|
54
|
-
CloseButtonIcon?: RenderProp;
|
|
55
|
-
/**
|
|
56
|
-
* @description Callback that is called when the modal begins to fade out.
|
|
57
|
-
*/
|
|
58
|
-
onFadeOut?: () => void;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @description A full screen image slider that displays images in a modal.
|
|
63
|
-
*/
|
|
64
|
-
const FullScreenImageSlider = forwardRef<
|
|
65
|
-
FlashList<SimpleImageSliderItem>,
|
|
66
|
-
FullScreenImageSliderProps
|
|
67
|
-
>(function FullScreenImageSlider(
|
|
68
|
-
{
|
|
69
|
-
CloseButtonIcon,
|
|
70
|
-
open,
|
|
71
|
-
onRequestClose,
|
|
72
|
-
renderDescription,
|
|
73
|
-
onViewableItemChange,
|
|
74
|
-
onFadeOut,
|
|
75
|
-
data,
|
|
76
|
-
...props
|
|
77
|
-
},
|
|
78
|
-
ref
|
|
79
|
-
) {
|
|
80
|
-
const windowDimensions = useWindowDimensions();
|
|
81
|
-
const theme = useSimpleImageSliderTheme();
|
|
82
|
-
const safeAreaInsets = useSafeAreaInsets();
|
|
83
|
-
const styles = useMemo(
|
|
84
|
-
() => makeStyles(safeAreaInsets, windowDimensions, theme),
|
|
85
|
-
[safeAreaInsets, windowDimensions, theme]
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const [internalIndex, setInternalIndex] = useState<number>(0);
|
|
89
|
-
|
|
90
|
-
const internalOnViewableItemChange = useCallback(
|
|
91
|
-
(index: number) => {
|
|
92
|
-
setInternalIndex(index);
|
|
93
|
-
onViewableItemChange?.(index);
|
|
94
|
-
},
|
|
95
|
-
[onViewableItemChange]
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
if (open) {
|
|
100
|
-
setStatusBarStyle('light');
|
|
101
|
-
} else {
|
|
102
|
-
setStatusBarStyle('dark');
|
|
103
|
-
}
|
|
104
|
-
}, [open]);
|
|
105
|
-
|
|
106
|
-
const backgroundOpacity = useSharedValue(0);
|
|
107
|
-
|
|
108
|
-
const modalContentStyle = useAnimatedStyle(() => {
|
|
109
|
-
return {
|
|
110
|
-
backgroundColor: `rgba(0, 0, 0, ${backgroundOpacity.value})`,
|
|
111
|
-
};
|
|
112
|
-
}, []);
|
|
113
|
-
|
|
114
|
-
const onPinchToZoomStatusChange = useCallback(
|
|
115
|
-
({ translation, scale }: PinchToZoomStatus) => {
|
|
116
|
-
if (scale <= 1) {
|
|
117
|
-
if (translation.x === 0 && translation.y === 0) {
|
|
118
|
-
runOnJS(setStatusBarStyle)('light');
|
|
119
|
-
backgroundOpacity.value = withTiming(1);
|
|
120
|
-
} else {
|
|
121
|
-
if (onFadeOut) {
|
|
122
|
-
runOnJS(onFadeOut)();
|
|
123
|
-
}
|
|
124
|
-
runOnJS(setStatusBarStyle)('dark');
|
|
125
|
-
backgroundOpacity.value = withTiming(0);
|
|
126
|
-
}
|
|
127
|
-
} else {
|
|
128
|
-
backgroundOpacity.value = 1;
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
[backgroundOpacity, onFadeOut]
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<Modal
|
|
136
|
-
animationType="fade"
|
|
137
|
-
onRequestClose={onRequestClose}
|
|
138
|
-
transparent={true}
|
|
139
|
-
visible={open}
|
|
140
|
-
>
|
|
141
|
-
<Animated.View style={[styles.modalContent, modalContentStyle]}>
|
|
142
|
-
<TouchableOpacity style={styles.closeButton} onPress={onRequestClose}>
|
|
143
|
-
{CloseButtonIcon ? (
|
|
144
|
-
renderProp(CloseButtonIcon)
|
|
145
|
-
) : (
|
|
146
|
-
<IconX color={theme.colors.fullScreenCloseButton} />
|
|
147
|
-
)}
|
|
148
|
-
</TouchableOpacity>
|
|
149
|
-
<BaseListImageSlider
|
|
150
|
-
data={data}
|
|
151
|
-
enablePinchToZoom={true}
|
|
152
|
-
onPinchToZoomStatusChange={onPinchToZoomStatusChange}
|
|
153
|
-
onPinchToZoomRequestClose={onRequestClose}
|
|
154
|
-
showPageCounter={false}
|
|
155
|
-
{...props}
|
|
156
|
-
onViewableItemChange={internalOnViewableItemChange}
|
|
157
|
-
imageWidth={windowDimensions.width}
|
|
158
|
-
ref={ref}
|
|
159
|
-
/>
|
|
160
|
-
|
|
161
|
-
{renderDescription && data[internalIndex] ? (
|
|
162
|
-
<View style={styles.descriptionContainer}>
|
|
163
|
-
{renderDescription(data[internalIndex], internalIndex)}
|
|
164
|
-
</View>
|
|
165
|
-
) : null}
|
|
166
|
-
</Animated.View>
|
|
167
|
-
</Modal>
|
|
168
|
-
);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
export default FullScreenImageSlider;
|
|
172
|
-
|
|
173
|
-
const makeStyles = (
|
|
174
|
-
safeAreaInsets: EdgeInsets,
|
|
175
|
-
windowDimensions: ScaledSize,
|
|
176
|
-
theme: SimpleImageSliderTheme
|
|
177
|
-
) => {
|
|
178
|
-
return StyleSheet.create({
|
|
179
|
-
closeButton: {
|
|
180
|
-
position: 'absolute',
|
|
181
|
-
zIndex: 1000,
|
|
182
|
-
top: safeAreaInsets.top,
|
|
183
|
-
right: safeAreaInsets.right + 20,
|
|
184
|
-
},
|
|
185
|
-
modalContent: {
|
|
186
|
-
alignItems: 'center',
|
|
187
|
-
justifyContent: 'center',
|
|
188
|
-
gap: 16,
|
|
189
|
-
height: windowDimensions.height,
|
|
190
|
-
width: windowDimensions.width,
|
|
191
|
-
},
|
|
192
|
-
descriptionContainer: {
|
|
193
|
-
position: 'absolute',
|
|
194
|
-
borderTopWidth: 1,
|
|
195
|
-
borderTopColor: theme.colors.descriptionContainerBorder,
|
|
196
|
-
width: '100%',
|
|
197
|
-
paddingTop: 20,
|
|
198
|
-
bottom: safeAreaInsets.bottom + 100,
|
|
199
|
-
paddingLeft: safeAreaInsets.left + 20,
|
|
200
|
-
paddingRight: safeAreaInsets.right + 20,
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
};
|
package/src/PageCounter.tsx
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
type StyleProp,
|
|
4
|
-
StyleSheet,
|
|
5
|
-
Text,
|
|
6
|
-
type TextStyle,
|
|
7
|
-
View,
|
|
8
|
-
type ViewStyle,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
import {
|
|
11
|
-
type SimpleImageSliderTheme,
|
|
12
|
-
useSimpleImageSliderTheme,
|
|
13
|
-
} from './SimpleImageSliderThemeProvider';
|
|
14
|
-
|
|
15
|
-
export type PageCounterProps = {
|
|
16
|
-
/**
|
|
17
|
-
* @description The current page number (**counting from 1**).
|
|
18
|
-
*/
|
|
19
|
-
currentPage: number;
|
|
20
|
-
/**
|
|
21
|
-
* @description The total number of pages.
|
|
22
|
-
*/
|
|
23
|
-
totalPages: number;
|
|
24
|
-
/**
|
|
25
|
-
* @description Additional styles or styles to override default style of the container View.
|
|
26
|
-
*/
|
|
27
|
-
style?: StyleProp<ViewStyle>;
|
|
28
|
-
/**
|
|
29
|
-
* @description Additional styles or styles to override default style of the Text component.
|
|
30
|
-
*/
|
|
31
|
-
textStyle?: StyleProp<TextStyle>;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default function PageCounter({
|
|
35
|
-
currentPage,
|
|
36
|
-
totalPages,
|
|
37
|
-
style,
|
|
38
|
-
textStyle,
|
|
39
|
-
}: PageCounterProps) {
|
|
40
|
-
const theme = useSimpleImageSliderTheme();
|
|
41
|
-
const styles = useMemo(() => makeStyles(theme), [theme]);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<View style={[styles.container, style]}>
|
|
45
|
-
<Text style={textStyle}>
|
|
46
|
-
{currentPage} / {totalPages}
|
|
47
|
-
</Text>
|
|
48
|
-
</View>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const makeStyles = (theme: SimpleImageSliderTheme) => {
|
|
53
|
-
return StyleSheet.create({
|
|
54
|
-
container: {
|
|
55
|
-
backgroundColor: theme.colors.pageCounterBackground,
|
|
56
|
-
borderWidth: 1,
|
|
57
|
-
borderColor: theme.colors.pageCounterBorder,
|
|
58
|
-
borderRadius: 8,
|
|
59
|
-
paddingVertical: 6,
|
|
60
|
-
paddingHorizontal: 5,
|
|
61
|
-
width: 75,
|
|
62
|
-
flexDirection: 'row',
|
|
63
|
-
alignItems: 'center',
|
|
64
|
-
justifyContent: 'center',
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
};
|