Skip to content

Commit

Permalink
fix: name text dont fit
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFridmansky authored and Lipo11 committed Jun 24, 2024
1 parent 337997e commit 3a221d7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
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
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
2 changes: 2 additions & 0 deletions src/core/dto/instagramStoriesDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ImageStyle,
ScrollViewProps, TextStyle, ViewStyle,
} from 'react-native';
import { TextProps } from 'react-native-svg';

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

0 comments on commit 3a221d7

Please sign in to comment.