|
| 1 | +import TabView, { SceneMap } from 'react-native-bottom-tabs'; |
| 2 | +import React from 'react'; |
| 3 | +import { Article } from '../Screens/Article'; |
| 4 | +import { Albums } from '../Screens/Albums'; |
| 5 | +import { Contacts } from '../Screens/Contacts'; |
| 6 | +import { Chat } from '../Screens/Chat'; |
| 7 | +import { I18nManager, type ColorValue } from 'react-native'; |
| 8 | +import type { LayoutDirection } from 'react-native-bottom-tabs'; |
| 9 | + |
| 10 | +interface Props { |
| 11 | + disablePageAnimations?: boolean; |
| 12 | + scrollEdgeAppearance?: 'default' | 'opaque' | 'transparent'; |
| 13 | + backgroundColor?: ColorValue; |
| 14 | + translucent?: boolean; |
| 15 | + hideOneTab?: boolean; |
| 16 | + rippleColor?: ColorValue; |
| 17 | + activeIndicatorColor?: ColorValue; |
| 18 | + layoutDirection?: LayoutDirection; |
| 19 | +} |
| 20 | + |
| 21 | +const renderScene = SceneMap({ |
| 22 | + article: Article, |
| 23 | + albums: Albums, |
| 24 | + contacts: Contacts, |
| 25 | + chat: Chat, |
| 26 | +}); |
| 27 | + |
| 28 | +export default function FourTabsRTL({ |
| 29 | + disablePageAnimations = false, |
| 30 | + scrollEdgeAppearance = 'default', |
| 31 | + backgroundColor, |
| 32 | + translucent = true, |
| 33 | + hideOneTab = false, |
| 34 | + rippleColor, |
| 35 | + activeIndicatorColor, |
| 36 | + layoutDirection = 'locale', |
| 37 | +}: Props) { |
| 38 | + React.useLayoutEffect(() => { |
| 39 | + if (layoutDirection === 'rtl') { |
| 40 | + I18nManager.allowRTL(true); |
| 41 | + I18nManager.forceRTL(true); |
| 42 | + } |
| 43 | + return () => { |
| 44 | + if (layoutDirection === 'rtl') { |
| 45 | + I18nManager.allowRTL(false); |
| 46 | + I18nManager.forceRTL(false); |
| 47 | + } |
| 48 | + }; |
| 49 | + }, [layoutDirection]); |
| 50 | + const [index, setIndex] = React.useState(0); |
| 51 | + const [routes] = React.useState([ |
| 52 | + { |
| 53 | + key: 'article', |
| 54 | + title: 'المقالات', |
| 55 | + focusedIcon: require('../../assets/icons/article_dark.png'), |
| 56 | + unfocusedIcon: require('../../assets/icons/chat_dark.png'), |
| 57 | + badge: '!', |
| 58 | + }, |
| 59 | + { |
| 60 | + key: 'albums', |
| 61 | + title: 'البومات', |
| 62 | + focusedIcon: require('../../assets/icons/grid_dark.png'), |
| 63 | + badge: '5', |
| 64 | + hidden: hideOneTab, |
| 65 | + }, |
| 66 | + { |
| 67 | + key: 'contacts', |
| 68 | + focusedIcon: require('../../assets/icons/person_dark.png'), |
| 69 | + title: 'المتراسلين', |
| 70 | + badge: ' ', |
| 71 | + }, |
| 72 | + { |
| 73 | + key: 'chat', |
| 74 | + focusedIcon: require('../../assets/icons/chat_dark.png'), |
| 75 | + title: 'المحادثات', |
| 76 | + role: 'search', |
| 77 | + }, |
| 78 | + ]); |
| 79 | + |
| 80 | + return ( |
| 81 | + <TabView |
| 82 | + sidebarAdaptable |
| 83 | + disablePageAnimations={disablePageAnimations} |
| 84 | + scrollEdgeAppearance={scrollEdgeAppearance} |
| 85 | + navigationState={{ index, routes }} |
| 86 | + onIndexChange={setIndex} |
| 87 | + renderScene={renderScene} |
| 88 | + tabBarStyle={{ backgroundColor }} |
| 89 | + translucent={translucent} |
| 90 | + rippleColor={rippleColor} |
| 91 | + activeIndicatorColor={activeIndicatorColor} |
| 92 | + layoutDirection={layoutDirection} |
| 93 | + /> |
| 94 | + ); |
| 95 | +} |
0 commit comments