_layout.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React from 'react';
  2. import { Tabs } from 'expo-router';
  3. import { Dimensions, Platform } from 'react-native';
  4. import {
  5. TabAccountIcon,
  6. TabChargingIcon,
  7. TabHomeIcon
  8. } from '../../../component/global/SVG';
  9. export default function TabLayout() {
  10. const { height } = Dimensions.get('window');
  11. // Calculate marginBottom based on screen height
  12. const calculateMarginBottom = () => {
  13. if (Platform.OS === 'ios') return 0;
  14. if (height < 600) return 0;
  15. return 15;
  16. };
  17. return (
  18. <Tabs
  19. screenOptions={{
  20. headerShown: false,
  21. tabBarLabelStyle: {
  22. fontSize: 16,
  23. marginBottom: calculateMarginBottom()
  24. },
  25. tabBarStyle: {
  26. height: height * 0.105
  27. },
  28. tabBarIconStyle: {
  29. width: 10,
  30. height: 10
  31. }
  32. }}
  33. >
  34. <Tabs.Screen
  35. name="(home)"
  36. options={{
  37. title: '主頁',
  38. tabBarHideOnKeyboard: true,
  39. tabBarIcon: ({ focused }) => (
  40. <TabHomeIcon color={focused ? '#02677D' : '#BBBBBB'} />
  41. )
  42. }}
  43. />
  44. <Tabs.Screen
  45. name="(charging)/index"
  46. options={{
  47. title: '充電',
  48. tabBarHideOnKeyboard: true,
  49. tabBarIcon: ({ focused }) => (
  50. <TabChargingIcon
  51. color={focused ? '#02677D' : '#BBBBBB'}
  52. />
  53. )
  54. }}
  55. />
  56. <Tabs.Screen
  57. name="(account)"
  58. options={{
  59. title: '帳戶',
  60. tabBarHideOnKeyboard: true,
  61. tabBarIcon: ({ focused, color }) => (
  62. <TabAccountIcon
  63. color={focused ? '#02677D' : '#BBBBBB'}
  64. />
  65. )
  66. }}
  67. />
  68. </Tabs>
  69. );
  70. }