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 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
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 @@ -100,6 +101,7 @@ const BubbleTabBarItemComponent = ({
];
const contentContainerStyle = [
styles.contentContainer,
tabStyle,
{
flexDirection: isRTL ? 'row-reverse' : 'row',
paddingHorizontal: itemInnerHorizontalSpace,
Expand Down
13 changes: 10 additions & 3 deletions src/presets/bubble/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
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 {
/**
* description
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you replace description with a description of the prop

* @type {ViewStyle}
*/
tabStyle?: ViewStyle;
Stringsaeed marked this conversation as resolved.
Show resolved Hide resolved
}

export interface BubbleTabBarItemConfig {
export interface BubbleTabBarItemConfig
extends Pick<BubbleTabBarConfig, 'tabStyle'> {
/**
* Tab bar item label style.
* @type {TextStyle}
Expand Down