forked from googlemaps/react-native-navigation-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
122 lines (113 loc) · 3.53 KB
/
App.tsx
File metadata and controls
122 lines (113 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import {
NavigationContainer,
useIsFocused,
useNavigation,
type NavigationProp,
} from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { View, Button, StyleSheet } from 'react-native';
import NavigationScreen from './screens/NavigationScreen';
import MultipleMapsScreen from './screens/MultipleMapsScreen';
import {
NavigationProvider,
TaskRemovedBehavior,
type TermsAndConditionsDialogOptions,
} from '@googlemaps/react-native-navigation-sdk';
import IntegrationTestsScreen from './screens/IntegrationTestsScreen';
export type ScreenNames = [
'Home',
'Navigation',
'Multiple maps',
'Integration tests',
];
export type RootStackParamList = Record<ScreenNames[number], undefined>;
export type StackNavigation = NavigationProp<RootStackParamList>;
const HomeScreen = () => {
const { navigate } = useNavigation<StackNavigation>();
const isFocused = useIsFocused();
return (
<View style={styles.container}>
{/* Spacer */}
<View style={styles.container} />
<View style={styles.buttonContainer}>
<Button
title="Navigation"
onPress={() => isFocused && navigate('Navigation')}
/>
</View>
<View style={styles.buttonContainer}>
<Button
title="Multiple Maps"
onPress={() => isFocused && navigate('Multiple maps')}
/>
</View>
{/* Spacer */}
<View style={styles.container} />
<View style={styles.buttonContainer}>
<Button
color="grey"
title="Integration Tests"
testID="integration_tests_button"
onPress={() => isFocused && navigate('Integration tests')}
/>
</View>
</View>
);
};
const termsAndConditionsDialogOptions: TermsAndConditionsDialogOptions = {
title: 'RN NavSDK Sample',
companyName: 'Sample Company',
showOnlyDisclaimer: true,
};
const Stack = createStackNavigator();
/**
* Root component of the application.
* @return {NavigationProvider} The NavigationProvider as a root component.
*/
export default function App() {
return (
<NavigationProvider
termsAndConditionsDialogOptions={termsAndConditionsDialogOptions}
taskRemovedBehavior={TaskRemovedBehavior.CONTINUE_SERVICE}
>
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Navigation" component={NavigationScreen} />
<Stack.Screen name="Multiple maps" component={MultipleMapsScreen} />
<Stack.Screen
name="Integration tests"
component={IntegrationTestsScreen}
/>
</Stack.Navigator>
</NavigationContainer>
</NavigationProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
buttonContainer: {
width: '80%',
marginVertical: 8,
},
});