UNPKG

10.4 kBSource Map (JSON)View Raw
1{"version":3,"sources":["DrawerNavigatorItems.tsx"],"names":["React","View","Text","StyleSheet","SafeAreaView","ThemeContext","TouchableItem","DrawerNavigatorItems","Component","getActiveTintColor","activeTintColor","props","context","getInactiveTintColor","inactiveTintColor","getActiveBackgroundColor","activeBackgroundColor","getInactiveBackgroundColor","inactiveBackgroundColor","render","items","activeItemKey","getLabel","renderIcon","onItemPress","itemsContainerStyle","itemStyle","labelStyle","activeLabelStyle","inactiveLabelStyle","iconContainerStyle","drawerPosition","styles","container","map","route","index","focused","key","color","backgroundColor","scene","tintColor","icon","label","accessibilityLabel","undefined","extraLabelStyle","item","vertical","inactiveIcon","light","dark","create","paddingVertical","flexDirection","alignItems","marginHorizontal","width","opacity","margin","fontWeight"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,IAAf,EAAqBC,UAArB,QAAuC,cAAvC;AACA,SAASC,YAAT,EAAuBC,YAAvB,QAA2C,kBAA3C;AACA,OAAOC,aAAP,MAA0B,iBAA1B;;AAGA;;;AAGA,eAAe,MAAMC,oBAAN,SAAmCP,KAAK,CAACQ,SAAzC,CAEb;AAAA;AAAA;;AAAA;AAAA;;AAwBQC,EAAAA,kBAAR,GAA6B;AAC3B,QAAI;AAAEC,MAAAA;AAAF,QAAsB,KAAKC,KAA/B;;AACA,QAAI,CAACD,eAAL,EAAsB;AACpB;AACD,KAFD,MAEO,IAAI,OAAOA,eAAP,KAA2B,QAA/B,EAAyC;AAC9C,aAAOA,eAAP;AACD;;AAED,WAAOA,eAAe,CAAC,KAAKE,OAAN,CAAtB;AACD;;AAEOC,EAAAA,oBAAR,GAA+B;AAC7B,QAAI;AAAEC,MAAAA;AAAF,QAAwB,KAAKH,KAAjC;;AACA,QAAI,CAACG,iBAAL,EAAwB;AACtB;AACD,KAFD,MAEO,IAAI,OAAOA,iBAAP,KAA6B,QAAjC,EAA2C;AAChD,aAAOA,iBAA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B;AAoB/Bf,EAAAA,KAAK,EAAE;AACLgB,IAAAA,MAAM,EAAE,EADH;AAELC,IAAAA,UAAU,EAAE;AAFP;AApBwB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\nimport { SafeAreaView, ThemeContext } from 'react-navigation';\nimport TouchableItem from './TouchableItem';\nimport { DrawerNavigatorItemsProps } from '../types';\n\n/**\n * Component that renders the navigation list in the drawer.\n */\nexport default class DrawerNavigatorItems extends React.Component<\n DrawerNavigatorItemsProps\n> {\n /* Material design specs - https://material.io/guidelines/patterns/navigation-drawer.html#navigation-drawer-specs */\n static defaultProps = {\n activeTintColor: {\n light: '#2196f3',\n dark: '#fff',\n },\n activeBackgroundColor: {\n light: 'rgba(0, 0, 0, .04)',\n dark: 'rgba(255, 255, 255, .04)',\n },\n inactiveTintColor: {\n light: 'rgba(0, 0, 0, .87)',\n dark: 'rgba(255, 255, 255, .87)',\n },\n inactiveBackgroundColor: {\n light: 'transparent',\n dark: 'transparent',\n },\n };\n\n static contextType = ThemeContext;\n context!: React.ContextType<typeof ThemeContext>;\n\n private getActiveTintColor() {\n let { activeTintColor } = this.props;\n if (!activeTintColor) {\n return;\n } else if (typeof activeTintColor === 'string') {\n return activeTintColor;\n }\n\n return activeTintColor[this.context];\n }\n\n private getInactiveTintColor() {\n let { inactiveTintColor } = this.props;\n if (!inactiveTintColor) {\n return;\n } else if (typeof inactiveTintColor === 'string') {\n return inactiveTintColor;\n }\n\n return inactiveTintColor[this.context];\n }\n\n private getActiveBackgroundColor() {\n let { activeBackgroundColor } = this.props;\n if (!activeBackgroundColor) {\n return;\n } else if (typeof activeBackgroundColor === 'string') {\n return activeBackgroundColor;\n }\n\n return activeBackgroundColor[this.context];\n }\n\n private getInactiveBackgroundColor() {\n let { inactiveBackgroundColor } = this.props;\n if (!inactiveBackgroundColor) {\n return;\n } else if (typeof inactiveBackgroundColor === 'string') {\n return inactiveBackgroundColor;\n }\n\n return inactiveBackgroundColor[this.context];\n }\n\n render() {\n const {\n items,\n activeItemKey,\n getLabel,\n renderIcon,\n onItemPress,\n itemsContainerStyle,\n itemStyle,\n labelStyle,\n activeLabelStyle,\n inactiveLabelStyle,\n iconContainerStyle,\n drawerPosition,\n } = this.props;\n\n const activeTintColor = this.getActiveTintColor();\n const activeBackgroundColor = this.getActiveBackgroundColor();\n const inactiveTintColor = this.getInactiveTintColor();\n const inactiveBackgroundColor = this.getInactiveBackgroundColor();\n\n return (\n <View style={[styles.container, itemsContainerStyle]}>\n {items.map((route, index: number) => {\n const focused = activeItemKey === route.key;\n const color = focused ? activeTintColor : inactiveTintColor;\n const backgroundColor = focused\n ? activeBackgroundColor\n : inactiveBackgroundColor;\n const scene = { route, index, focused, tintColor: color };\n const icon = renderIcon(scene);\n const label = getLabel(scene);\n const accessibilityLabel =\n typeof label === 'string' ? label : undefined;\n const extraLabelStyle = focused\n ? activeLabelStyle\n : inactiveLabelStyle;\n return (\n <TouchableItem\n key={route.key}\n accessible\n accessibilityLabel={accessibilityLabel}\n onPress={() => {\n onItemPress({ route, focused });\n }}\n delayPressIn={0}\n >\n <SafeAreaView\n style={[{ backgroundColor }, styles.item, itemStyle]}\n forceInset={{\n [drawerPosition]: 'always',\n [drawerPosition === 'left' ? 'right' : 'left']: 'never',\n vertical: 'never',\n }}\n >\n {icon ? (\n <View\n style={[\n styles.icon,\n focused ? null : styles.inactiveIcon,\n iconContainerStyle,\n ]}\n >\n {icon}\n </View>\n ) : null}\n {typeof label === 'string' ? (\n <Text\n style={[\n styles.label,\n { color },\n labelStyle,\n extraLabelStyle,\n ]}\n >\n {label}\n </Text>\n ) : (\n label\n )}\n </SafeAreaView>\n </TouchableItem>\n );\n })}\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n paddingVertical: 4,\n },\n item: {\n flexDirection: 'row',\n alignItems: 'center',\n },\n icon: {\n marginHorizontal: 16,\n width: 24,\n alignItems: 'center',\n },\n inactiveIcon: {\n /*\n * Icons have 0.54 opacity according to guidelines\n * 100/87 * 54 ~= 62\n */\n opacity: 0.62,\n },\n label: {\n margin: 16,\n fontWeight: 'bold',\n },\n});\n"]}
\No newline at end of file