diff --git a/README.md b/README.md index a186fd8..399bee6 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ export default YourComponent; `hideOverlayOnLongPress` | `boolean` | The value of `hideElementOnLongPress` | Controls whether the image overlay hides when `hideElementOnLongPress` is set to `true`. If `true`, the overlay will hide along with other elements on long press. If `false`, only the other elements (e.g., header, progress bar) will hide, and the overlay will remain visible. `loopingStories` | `'none'` | `'onlyLast'` | `'all'` | `'none'` | A string indicating whether to continue stories after last story was shown. If set to `'none'` modal will be closed after all stories were played, if set to `'onlyLast'` stories will loop on last user only after all stories were played. If set to `'all'` stories will play from beginning after all stories were played. `statusBarTranslucent` | boolean | false | A property passed to React native Modal component + `loaderColor` | string | '#FFFFFF' | The color of the loading spinner. + `loaderBackgroundColor` | string | | Background color of the loading overlay. `footerComponent` | ReactNode | | A custom component, such as a floating element, that can be added to the modal. `imageOverlayView` | ReactNode | | Image overlay compontent `onShow` | ( id: string ) => void | | Callback when a story is shown. diff --git a/src/components/Image/Image.styles.ts b/src/components/Image/Image.styles.ts index d1bc8b1..452afaf 100644 --- a/src/components/Image/Image.styles.ts +++ b/src/components/Image/Image.styles.ts @@ -9,6 +9,7 @@ export default StyleSheet.create( { right: 0, alignItems: 'center', justifyContent: 'center', + zIndex: 2, }, image: { alignItems: 'center', diff --git a/src/components/Image/index.tsx b/src/components/Image/index.tsx index a6edfc2..f4c07a9 100644 --- a/src/components/Image/index.tsx +++ b/src/components/Image/index.tsx @@ -12,7 +12,8 @@ import { StoryItemProps } from '../../core/dto/instagramStoriesDTO'; const StoryImage: FC = ( { stories, activeStory, defaultStory, isDefaultVideo, paused, videoProps, isActive, - mediaContainerStyle, imageStyles, imageProps, videoDuration, onImageLayout, onLoad, + mediaContainerStyle, imageStyles, imageProps, videoDuration, loaderColor, + loaderBackgroundColor, onImageLayout, onLoad, } ) => { const [ data, setData ] = useState<{ data?: StoryItemProps, isVideo?: boolean }>( @@ -20,7 +21,7 @@ const StoryImage: FC = ( { ); const loading = useSharedValue( true ); - const color = useSharedValue( LOADER_COLORS ); + const color = useSharedValue( loaderColor ? [ loaderColor ] : LOADER_COLORS ); const duration = useSharedValue( undefined ); const isPaused = useDerivedValue( () => paused.value || !isActive.value ); @@ -28,6 +29,10 @@ const StoryImage: FC = ( { opacity: loading.value ? 1 : 0, } ) ); + const loaderBackgroundStyle = useAnimatedStyle( () => ( { + backgroundColor: loaderBackgroundColor || 'transparent', + } ) ); + const onImageChange = async () => { if ( !activeStory.value ) { @@ -98,7 +103,7 @@ const StoryImage: FC = ( { return ( <> - + diff --git a/src/components/InstagramStories/index.tsx b/src/components/InstagramStories/index.tsx index 86bfe7f..bb29e4c 100644 --- a/src/components/InstagramStories/index.tsx +++ b/src/components/InstagramStories/index.tsx @@ -34,6 +34,8 @@ const InstagramStories = forwardRef { @@ -257,6 +259,8 @@ const InstagramStories = forwardRef diff --git a/src/components/List/index.tsx b/src/components/List/index.tsx index 0e7e533..9fa47d8 100644 --- a/src/components/List/index.tsx +++ b/src/components/List/index.tsx @@ -16,7 +16,7 @@ const StoryList: FC = ( { id, stories, index, x, activeUser, activeStory, progress, seenStories, paused, onLoad, videoProps, progressColor, progressActiveColor, mediaContainerStyle, imageStyles, imageProps, progressContainerStyle, imageOverlayView, hideElements, hideOverlayViewOnLongPress, - videoDuration, ...props + videoDuration, loaderColor, loaderBackgroundColor, ...props } ) => { const imageHeight = useSharedValue( HEIGHT ); @@ -58,6 +58,8 @@ const StoryList: FC = ( { imageStyles={imageStyles} imageProps={imageProps} videoDuration={videoDuration} + loaderColor={loaderColor} + loaderBackgroundColor={loaderBackgroundColor} /> ( ( { stories, seenStories, duration, videoDuration, storyAvatarSize, textStyle, containerStyle, backgroundColor, videoProps, closeIconColor, modalAnimationDuration = STORY_ANIMATION_DURATION, storyAnimationDuration = STORY_ANIMATION_DURATION, hideElementsOnLongPress, loopingStories = 'none', - statusBarTranslucent, onLoad, onShow, onHide, + statusBarTranslucent, loaderColor, loaderBackgroundColor, onLoad, onShow, onHide, onSeenStoriesChange, onSwipeUp, onStoryStart, onStoryEnd, footerComponent, ...props }, ref ) => { @@ -499,6 +499,8 @@ const StoryModal = forwardRef( ( { closeColor={closeIconColor} hideElements={hideElements} videoDuration={videoDuration} + loaderColor={loaderColor} + loaderBackgroundColor={loaderBackgroundColor} key={story.id} {...props} /> diff --git a/src/components/Progress/Progress.styles.ts b/src/components/Progress/Progress.styles.ts index a265a10..97e6d34 100644 --- a/src/components/Progress/Progress.styles.ts +++ b/src/components/Progress/Progress.styles.ts @@ -8,6 +8,7 @@ export default StyleSheet.create( { height: 2, flexDirection: 'row', gap: 4, + zindex: 3, }, item: { height: 3, diff --git a/src/core/dto/componentsDTO.ts b/src/core/dto/componentsDTO.ts index 1a4eef6..c1a2ad0 100644 --- a/src/core/dto/componentsDTO.ts +++ b/src/core/dto/componentsDTO.ts @@ -64,6 +64,8 @@ export interface StoryModalProps { hideOverlayViewOnLongPress?: boolean; loopingStories?: 'none' | 'all' | 'onlyLast'; statusBarTranslucent?: boolean; + loaderColor?: string; + loaderBackgroundColor?: string; onLoad: () => void; onShow?: ( id: string ) => void; onHide?: ( id: string ) => void; @@ -112,6 +114,8 @@ export interface StoryImageProps { imageStyles?: ImageStyle; imageProps?: ImageProps; videoDuration?: number; + loaderColor?: string; + loaderBackgroundColor?: string; onImageLayout: ( height: number ) => void; onLoad: ( duration?: number ) => void; } @@ -173,6 +177,8 @@ export interface StoryListProps extends InstagramStoryProps, StoryHeaderProps { hideElements: SharedValue; hideOverlayViewOnLongPress?: boolean; videoDuration?: number; + loaderColor?: string; + loaderBackgroundColor?: string; onLoad: ( duration?: number ) => void; } diff --git a/src/core/dto/instagramStoriesDTO.ts b/src/core/dto/instagramStoriesDTO.ts index 00889f9..263c8ea 100644 --- a/src/core/dto/instagramStoriesDTO.ts +++ b/src/core/dto/instagramStoriesDTO.ts @@ -63,6 +63,8 @@ export interface InstagramStoriesProps { statusBarTranslucent?: boolean; footerComponent?: ReactNode; avatarBorderRadius?: number; + loaderColor?: string; + loaderBackgroundColor?: string; onShow?: ( id: string ) => void; onHide?: ( id: string ) => void; onSwipeUp?: ( userId?: string, storyId?: string ) => void;