Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: onStoryHeaderPress #95

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export default YourComponent;
`avatarSource` | ImageProps['source'] | false
`renderAvatar` | () => ReactNode | false
`renderStoryHeader` | () => ReactNode | false
`onStoryHeaderPress` | () => void | false
`name` | string | false
`stories` | [StoryItemProps](#storyitemprops)[] | true

Expand Down
7 changes: 4 additions & 3 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC, memo } from 'react';
import {
View, Text, Image, TouchableOpacity,
Pressable,
} from 'react-native';
import { WIDTH } from '../../core/constants';
import HeaderStyles from './Header.styles';
Expand All @@ -9,7 +10,7 @@ import Close from '../Icon/close';

const StoryHeader: FC<StoryHeaderProps> = ( {
avatarSource, imgUrl, name, onClose, avatarSize, textStyle, closeColor, headerStyle,
headerContainerStyle, renderStoryHeader,
headerContainerStyle, renderStoryHeader, onStoryHeaderPress,
} ) => {

const styles = { width: avatarSize, height: avatarSize, borderRadius: avatarSize };
Expand All @@ -33,14 +34,14 @@ const StoryHeader: FC<StoryHeaderProps> = ( {
{ width }, headerContainerStyle,
]}
>
<View style={[ HeaderStyles.left, headerStyle ]}>
<Pressable style={[ HeaderStyles.left, headerStyle ]} onPress={() => onStoryHeaderPress?.()}>
{( Boolean( avatarSource ) || Boolean( imgUrl ) ) && (
<View style={[ HeaderStyles.avatar, { borderRadius: styles.borderRadius } ]}>
<Image source={avatarSource ?? { uri: imgUrl }} style={styles} />
</View>
)}
{Boolean( name ) && <Text style={textStyle}>{name}</Text>}
</View>
</Pressable>
<TouchableOpacity
onPress={onClose}
hitSlop={16}
Expand Down
1 change: 1 addition & 0 deletions src/core/dto/componentsDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export interface StoryHeaderProps {
headerContainerStyle?: ViewStyle;
onClose: () => void;
renderStoryHeader?: () => ReactNode;
onStoryHeaderPress?: () => void;
}

export interface IconProps {
Expand Down
1 change: 1 addition & 0 deletions src/core/dto/instagramStoriesDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface InstagramStoryProps {
avatarSource?: ImageProps['source'];
renderAvatar?: () => ReactNode;
renderStoryHeader?: () => ReactNode;
onStoryHeaderPress?: () => void;
name?: string;
stories: StoryItemProps[];
}
Expand Down
Loading