POWR/app/(tabs)/_layout.tsx

100 lines
3.0 KiB
TypeScript
Raw Normal View History

2025-02-09 20:38:38 -05:00
// app/(tabs)/_layout.tsx
2025-02-25 15:03:45 -05:00
import React, { useEffect } from 'react';
import { Platform, View } from 'react-native';
import { Tabs, useNavigation } from 'expo-router';
2025-02-12 12:55:51 -05:00
import { useTheme } from '@react-navigation/native';
import { Dumbbell, Library, Users, History, User, Home } from 'lucide-react-native';
2025-02-15 14:03:42 -05:00
import type { CustomTheme } from '@/lib/theme';
2025-02-25 15:03:45 -05:00
import ActiveWorkoutBar from '@/components/workout/ActiveWorkoutBar';
import { useWorkoutStore } from '@/stores/workoutStore';
2025-02-09 20:38:38 -05:00
export default function TabLayout() {
2025-02-15 14:03:42 -05:00
const theme = useTheme() as CustomTheme;
2025-02-25 15:03:45 -05:00
const navigation = useNavigation();
const { isActive, isMinimized } = useWorkoutStore();
const { minimizeWorkout } = useWorkoutStore.getState();
// Auto-minimize workout when navigating between tabs
useEffect(() => {
const unsubscribe = navigation.addListener('state', (e) => {
// If workout is active but not minimized, minimize it when changing tabs
if (isActive && !isMinimized) {
minimizeWorkout();
}
});
return unsubscribe;
}, [navigation, isActive, isMinimized, minimizeWorkout]);
2025-02-09 20:38:38 -05:00
return (
2025-02-25 15:03:45 -05:00
<View style={{ flex: 1 }}>
<Tabs
screenOptions={{
headerShown: false,
tabBarStyle: {
backgroundColor: theme.colors.background,
borderTopColor: theme.colors.border,
borderTopWidth: Platform.OS === 'ios' ? 0.5 : 1,
elevation: 0,
shadowOpacity: 0,
},
2025-03-01 13:43:42 -05:00
tabBarActiveTintColor: theme.colors.primary,
2025-02-25 15:03:45 -05:00
tabBarInactiveTintColor: theme.colors.tabInactive,
tabBarShowLabel: true,
tabBarLabelStyle: {
fontSize: 12,
marginBottom: Platform.OS === 'ios' ? 0 : 4,
},
}}>
<Tabs.Screen
name="profile"
options={{
title: 'Profile',
tabBarIcon: ({ color, size }) => (
<Home size={size} color={color} />
2025-02-25 15:03:45 -05:00
),
}}
/>
<Tabs.Screen
name="library"
options={{
title: 'Library',
tabBarIcon: ({ color, size }) => (
<Library size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="index"
options={{
title: 'Workout',
tabBarIcon: ({ color, size }) => (
<Dumbbell size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="social"
options={{
title: 'Social',
tabBarIcon: ({ color, size }) => (
<Users size={size} color={color} />
),
}}
/>
<Tabs.Screen
name="history"
options={{
title: 'History',
2025-02-25 15:03:45 -05:00
tabBarIcon: ({ color, size }) => (
<History size={size} color={color} />
),
}}
/>
</Tabs>
{/* Render the ActiveWorkoutBar above the tab bar */}
<ActiveWorkoutBar />
</View>
2025-02-09 20:38:38 -05:00
);
}