swimtracker-app/components/ThemedStackNavigation.js

71 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-06-02 17:19:09 +02:00
import React from 'react';
import { LinearGradient } from 'expo-linear-gradient';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { BlurView } from 'expo-blur';
import { StyleSheet } from 'react-native';
import backgroundColors from './Themes';
// Own views
import LiveTrainingView from './LiveTrainingView';
import HomeView from './HomeView';
import { connect } from 'react-redux';
const Stack = createStackNavigator();
function ThemedStackNavigation(props) {
const screenOptions = {
cardStyle: {
backgroundColor: "transparent",
opacity: 1
},
headerTransparent: "true",
headerTitleStyle: {
color: 'white',
fontWeight: 'bold',
2020-06-02 22:43:48 +02:00
fontSize: 20,
2020-06-02 17:19:09 +02:00
},
headerTintColor: "white",
headerBackground: () => (
<BlurView
tint="dark"
intensity={30}
style={StyleSheet.absoluteFill}
/>
),
}
return (
<LinearGradient
colors={backgroundColors[props.themeName]}
start={[0, 0]}
end={[0.5, 1]}
style={{ flex: 1 }}
>
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen
name="Home"
component={HomeView}
options={{ ...screenOptions, headerTitle: "SwimTracker" }}
/>
<Stack.Screen
name="Training"
component={LiveTrainingView}
options={{ ...screenOptions, headerTitle: "Training" }}
/>
</Stack.Navigator>
</NavigationContainer>
</LinearGradient>
)
};
const mapStateToProps = (state) => {
return { themeName: state.settings.theme };
};
export default connect(mapStateToProps)(ThemedStackNavigation);