2020-06-15 14:00:46 +00:00
|
|
|
import { StyleSheet } from 'react-native';
|
2021-09-13 20:41:05 +00:00
|
|
|
import { DarkTheme, DefaultTheme } from '@react-navigation/native';
|
2020-06-15 14:00:46 +00:00
|
|
|
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../../lib/constants';
|
2022-04-12 16:27:05 +00:00
|
|
|
import { TSupportedThemes } from '../../theme';
|
2020-06-15 14:00:46 +00:00
|
|
|
|
|
|
|
export * from './animations';
|
|
|
|
|
|
|
|
export const defaultHeader = {
|
|
|
|
headerBackTitleVisible: false,
|
|
|
|
cardOverlayEnabled: true,
|
|
|
|
cardStyle: { backgroundColor: 'transparent' }
|
|
|
|
};
|
|
|
|
|
|
|
|
export const cardStyle = {
|
|
|
|
backgroundColor: 'rgba(0,0,0,0)'
|
|
|
|
};
|
|
|
|
|
2022-04-12 16:27:05 +00:00
|
|
|
export const borderBottom: any = (theme: TSupportedThemes) => ({
|
2020-06-15 14:00:46 +00:00
|
|
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
|
|
borderBottomColor: themes[theme].headerBorder,
|
|
|
|
elevation: 0
|
|
|
|
});
|
|
|
|
|
2022-06-01 19:46:37 +00:00
|
|
|
export const drawerStyle = {
|
|
|
|
width: 320
|
|
|
|
};
|
|
|
|
|
2022-04-12 16:27:05 +00:00
|
|
|
export const themedHeader = (theme: TSupportedThemes) => ({
|
2020-06-15 14:00:46 +00:00
|
|
|
headerStyle: {
|
|
|
|
...borderBottom(theme),
|
|
|
|
backgroundColor: themes[theme].headerBackground
|
|
|
|
},
|
|
|
|
headerTintColor: themes[theme].headerTintColor,
|
|
|
|
headerTitleStyle: { color: themes[theme].headerTitleColor }
|
|
|
|
});
|
|
|
|
|
2022-04-12 16:27:05 +00:00
|
|
|
export const navigationTheme = (theme: TSupportedThemes) => {
|
2020-06-15 14:00:46 +00:00
|
|
|
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
|
2021-09-13 20:41:05 +00:00
|
|
|
export const getActiveRoute: any = (state: any) => {
|
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;
|
|
|
|
};
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
export const getActiveRouteName = (state: any) => getActiveRoute(state)?.name;
|