Skip to content

Commit

Permalink
chore: tabs refactor and component outsource
Browse files Browse the repository at this point in the history
  • Loading branch information
berenteb committed Jan 14, 2024
1 parent 5ea887c commit 5f3425d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ yarn-error.*
android
ios

.idea

29 changes: 25 additions & 4 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Feather } from '@expo/vector-icons';
import { useFonts } from 'expo-font';
import { SplashScreen, Tabs } from 'expo-router';
import { useEffect } from 'react';
import { Platform, SafeAreaView, View } from 'react-native';
import { Platform, SafeAreaView } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

import { TabbarBackground } from '../components/tabbar/tabbar-background';
import { TabbarIcon } from '../components/tabbar/tabbar-icon';
import { TabbarLabel } from '../components/tabbar/tabbar-label';
import { colors } from '../theme/colors';

export default function MainLayout() {
Expand Down Expand Up @@ -38,11 +40,12 @@ export default function MainLayout() {
screenOptions={{
headerShown: false,
tabBarActiveTintColor: colors.primary['500'],
tabBarBackground: () => <View className='shadow-md shadow-slate-500/30 w-full h-full bg-white rounded-xl' />,
tabBarLabel: TabbarLabel,
tabBarBackground: TabbarBackground,
tabBarStyle: {
borderTopWidth: 0,
marginHorizontal: 10,
paddingBottom: 15,
paddingBottom: 10,
paddingTop: 10,
height: 70,
marginBottom: 10,
Expand Down Expand Up @@ -75,7 +78,3 @@ export default function MainLayout() {
</SafeAreaView>
);
}

function TabbarIcon({ focused, name }: { focused: boolean; name: React.ComponentProps<typeof Feather>['name'] }) {
return <Feather name={name} size={30} color={focused ? colors.primary['500'] : 'gray'} />;
}
5 changes: 5 additions & 0 deletions components/tabbar/tabbar-background.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { View } from 'react-native';

export function TabbarBackground() {
return <View className='shadow-md shadow-slate-500/30 w-full h-full bg-white rounded-xl' />;
}
13 changes: 13 additions & 0 deletions components/tabbar/tabbar-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Feather } from '@expo/vector-icons';

import { colors } from '../../theme/colors';

export function TabbarIcon({
focused,
name,
}: {
focused: boolean;
name: React.ComponentProps<typeof Feather>['name'];
}) {
return <Feather name={name} size={30} color={focused ? colors.primary['500'] : 'gray'} />;
}
20 changes: 20 additions & 0 deletions components/tabbar/tabbar-label.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { PropsWithChildren } from 'react';

import { StyledText } from '../base/text';

interface TabbarLabelProps extends PropsWithChildren {
color: string;
}

export function TabbarLabel({ color, children }: TabbarLabelProps) {
return (
<StyledText
className='text-xs'
style={{
color,
}}
>
{children}
</StyledText>
);
}

0 comments on commit 5f3425d

Please sign in to comment.