2020-06-15 14:00:46 +00:00
|
|
|
import { StyleSheet } from 'react-native';
|
|
|
|
import { DefaultTheme, DarkTheme } from '@react-navigation/native';
|
|
|
|
|
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
|
|
|
|
export * from './animations';
|
|
|
|
|
|
|
|
export const defaultHeader = {
|
|
|
|
headerBackTitleVisible: false,
|
|
|
|
cardOverlayEnabled: true,
|
|
|
|
cardStyle: { backgroundColor: 'transparent' }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export const cardStyle = {
|
|
|
|
backgroundColor: 'rgba(0,0,0,0)'
|
|
|
|
};
|
|
|
|
|
|
|
|
export const borderBottom = theme => ({
|
|
|
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
|
|
borderBottomColor: themes[theme].headerBorder,
|
|
|
|
elevation: 0
|
|
|
|
});
|
|
|
|
|
|
|
|
export const themedHeader = theme => ({
|
|
|
|
headerStyle: {
|
|
|
|
...borderBottom(theme),
|
|
|
|
backgroundColor: themes[theme].headerBackground
|
|
|
|
},
|
|
|
|
headerTintColor: themes[theme].headerTintColor,
|
|
|
|
headerTitleStyle: { color: themes[theme].headerTitleColor }
|
|
|
|
});
|
|
|
|
|
|
|
|
export const navigationTheme = (theme) => {
|
|
|
|
const defaultNavTheme = theme === 'light' ? DefaultTheme : DarkTheme;
|
|
|
|
|
|
|
|
return {
|
|
|
|
...defaultNavTheme,
|
|
|
|
colors: {
|
|
|
|
...defaultNavTheme.colors,
|
|
|
|
background: themes[theme].backgroundColor,
|
|
|
|
border: themes[theme].borderColor
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Gets the current screen from navigation state
|
|
|
|
export const getActiveRoute = (state) => {
|
2020-07-08 17:00:23 +00:00
|
|
|
const route = state?.routes[state?.index];
|
2020-06-15 14:00:46 +00:00
|
|
|
|
2020-07-08 17:00:23 +00:00
|
|
|
if (route?.state) {
|
2020-06-15 14:00:46 +00:00
|
|
|
// Dive into nested navigators
|
|
|
|
return getActiveRoute(route.state);
|
|
|
|
}
|
|
|
|
|
|
|
|
return route;
|
|
|
|
};
|
|
|
|
|
2020-07-08 17:00:23 +00:00
|
|
|
export const getActiveRouteName = state => getActiveRoute(state)?.name;
|