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: add tabStyle to bubble preset #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 16 additions & 5 deletions example/src/screens/BubbleStyled.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, { useMemo } from 'react';
import { StyleProp, ViewStyle } from 'react-native';
import { ViewStyle } from 'react-native';
import { useSafeArea } from 'react-native-safe-area-context';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import {
createBottomTabNavigator,
BottomTabBarOptions,
} from '@react-navigation/bottom-tabs';
import AnimatedTabBar, {
TabsConfig,
BubbleTabBarItemConfig,
Expand Down Expand Up @@ -84,7 +87,7 @@ const BubbleStyledScreen = () => {
return 20 + bottom + 12 * 2 + 12 * 2 + 12;
}, [bottom]);

const tabBarStyle = useMemo<StyleProp<ViewStyle>>(
const tabBarStyle = useMemo<ViewStyle>(
() => ({
position: 'absolute',
left: 0,
Expand All @@ -108,14 +111,22 @@ const BubbleStyledScreen = () => {
[bottom]
);

const tabBarOptions = useMemo(
const tabStyle = useMemo<ViewStyle>(
() => ({
borderRadius: 8,
}),
[]
);

const tabBarOptions: BottomTabBarOptions = useMemo(
() => ({
safeAreaInsets: {
bottom: 0,
},
tabStyle,
style: tabBarStyle,
}),
[tabBarStyle]
[tabBarStyle, tabStyle]
);

// render
Expand Down
2 changes: 2 additions & 0 deletions src/presets/bubble/BubbleTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { styles } from './styles';
const BubbleTabBarComponent = ({
selectedIndex,
tabs,
tabStyle,
duration = DEFAULT_ITEM_ANIMATION_DURATION,
easing = DEFAULT_ITEM_ANIMATION_EASING,
itemInnerSpace = DEFAULT_ITEM_INNER_SPACE,
Expand Down Expand Up @@ -84,6 +85,7 @@ const BubbleTabBarComponent = ({
itemContainerWidth={itemContainerWidth}
iconSize={iconSize}
isRTL={isRTL}
tabStyle={tabStyle}
{...configs}
/>
</RawButton>
Expand Down
2 changes: 2 additions & 0 deletions src/presets/bubble/item/BubbleTabBarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const BubbleTabBarItemComponent = ({
itemOuterSpace,
iconSize,
isRTL,
tabStyle,
}: BubbleTabBarItemProps) => {
//#region extract props
const {
Expand Down Expand Up @@ -110,6 +111,7 @@ const BubbleTabBarItemComponent = ({
outputRange: [background.inactiveColor, background.activeColor],
}),
},
tabStyle,
Stringsaeed marked this conversation as resolved.
Show resolved Hide resolved
];
const labelContainerStyle = [
styles.labelContainer,
Expand Down
7 changes: 5 additions & 2 deletions src/presets/bubble/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { TextStyle } from 'react-native';
import type { TextStyle, ViewStyle } from 'react-native';
import type Animated from 'react-native-reanimated';
import type { TabBarItemProps } from '../../types';

export interface BubbleTabBarConfig {}
export interface BubbleTabBarConfig {
tabStyle?: ViewStyle;
Stringsaeed marked this conversation as resolved.
Show resolved Hide resolved
}

export interface BubbleTabBarItemConfig {
/**
Expand Down Expand Up @@ -52,6 +54,7 @@ export interface BubbleTabBarItemConfig {
*/
inactiveColor: string;
};
tabStyle?: ViewStyle;
Stringsaeed marked this conversation as resolved.
Show resolved Hide resolved
}

export type BubbleTabBarItemProps = TabBarItemProps & BubbleTabBarItemConfig;
Expand Down