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

fix: name text dont fit #86

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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export default YourComponent;
`videoAnimationMaxDuration`| number | | The max duration of the video story animations in ms. If is this property not provided, the whole video will be played.
`backgroundColor` | string | '#000000' | The background color of story container.
`showName` | boolean | false | Whether you want to show user name under avatar in avatar list.
`nameTextStyle` | TextStyle | | Additional styles for name text elements.
`nameTextStyle` | TextStyle | { width: `avatarSize` + 10 } | Additional styles for name text elements.
`nameTextProps` | TextProps | | Props to be passed to the name Text component.
`videoProps` | [react-native-video](https://www.npmjs.com/package/react-native-video?activeTab=readme#configurable-props)| | Additional props for video component. For more information, follow `react-native-video`.
`closeIconColor` | string | '#00000099' | The color of story close icon.
`progressColor` | string | '#00000099' | Background color of progress bar item in inactive state
Expand Down
10 changes: 9 additions & 1 deletion src/components/Avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const StoryAvatar: FC<StoryAvatarProps> = ( {
size,
showName,
nameTextStyle,
nameTextProps,
} ) => {

const loaded = useSharedValue( false );
Expand Down Expand Up @@ -62,7 +63,14 @@ const StoryAvatar: FC<StoryAvatarProps> = ( {
/>
</TouchableOpacity>
</View>
{Boolean( showName ) && <Text style={nameTextStyle}>{name}</Text>}
{Boolean( showName ) && (
<Text
{...nameTextProps}
style={[ { width: size + AVATAR_OFFSET * 2 }, nameTextStyle ]}
>
{name}
</Text>
)}
</View>
);

Expand Down
2 changes: 2 additions & 0 deletions src/components/InstagramStories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const InstagramStories = forwardRef<InstagramStoriesPublicMethods, InstagramStor
backgroundColor = BACKGROUND_COLOR,
showName = false,
nameTextStyle,
nameTextProps,
videoAnimationMaxDuration,
videoProps,
closeIconColor = CLOSE_COLOR,
Expand Down Expand Up @@ -238,6 +239,7 @@ const InstagramStories = forwardRef<InstagramStoriesPublicMethods, InstagramStor
size={avatarSize}
showName={showName}
nameTextStyle={nameTextStyle}
nameTextProps={nameTextProps}
key={`avatar${story.id}`}
/>
) ) )}
Expand Down
3 changes: 2 additions & 1 deletion src/core/dto/componentsDTO.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SharedValue } from 'react-native-reanimated';
import {
ImageProps, ImageStyle, TextStyle, ViewStyle,
ImageProps, ImageStyle, TextProps, TextStyle, ViewStyle,
} from 'react-native';
import { ReactNode } from 'react';
import { InstagramStoryProps, StoryItemProps } from './instagramStoriesDTO';
Expand All @@ -15,6 +15,7 @@ export interface StoryAvatarProps extends InstagramStoryProps {
size: number;
showName?: boolean;
nameTextStyle?: TextStyle;
nameTextProps?: TextProps;
}

export interface StoryLoaderProps {
Expand Down
3 changes: 2 additions & 1 deletion src/core/dto/instagramStoriesDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactNode } from 'react';
import {
ImageProps,
ImageStyle,
ScrollViewProps, TextStyle, ViewStyle,
ScrollViewProps, TextStyle, ViewStyle, TextProps,
} from 'react-native';

export interface StoryItemProps {
Expand Down Expand Up @@ -51,6 +51,7 @@ export interface InstagramStoriesProps {
backgroundColor?: string;
showName?: boolean;
nameTextStyle?: TextStyle;
nameTextProps?: TextProps;
videoProps?: any;
closeIconColor?: string;
progressActiveColor?: string;
Expand Down
Loading