-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
82 lines (71 loc) · 2.62 KB
/
App.js
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
import React, { useEffect } from 'react';
import { NavigationContainer, useNavigationContainerRef,} from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { StyleSheet, Text, useColorScheme, LogBox, TouchableOpacity, Image} from 'react-native';
import Welcome from './src/screens/Welcome';
import List from './src/screens/List';
import AlarmCreator from './src/screens/AlarmCreator';
import { Database } from "./api/Database";
import * as Notifications from 'expo-notifications';
import { colors } from './api/ColorPallete';
import AsyncStorage from '@react-native-async-storage/async-storage';
const Stack = createNativeStackNavigator();
LogBox.ignoreAllLogs();
const App = () => {
useEffect(() => {
Database.createTable(); console.log('created database');
// handles the notification
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});
}, [])
const navigationRef = useNavigationContainerRef();
const handleSignOut = (navigate) => {
AsyncStorage.setItem('uid', '').then(() => {
navigate('main'); // Navigate to "Welcome" after sign out
});
}
return (
<NavigationContainer ref={navigationRef}>
<Stack.Navigator initialRouteName="main" screenOptions={{ navigationBarColor: themes.colors.white, textAlign: 'center' }}>
<Stack.Screen
name="main"
component={Welcome}
options={{ headerShown: false }}
/>
<Stack.Screen
name="list"
component={List}
options={{
title: 'アラームリスト',
headerStyle: { backgroundColor: colors.blue },
headerTintColor: 'white',
headerBackVisible: false,
headerRight: () => (
<TouchableOpacity onPress={() => handleSignOut(navigationRef.navigate)}>
<Image style={[themes.logout]} source={require('./assets/logout.png')} />
</TouchableOpacity>
)
}}
/>
<Stack.Screen
name="creator"
component={AlarmCreator}
options={{ title: 'ラームを追加',
headerStyle: { backgroundColor: colors.blue },
headerTintColor: 'white', }}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
const themes = StyleSheet.create({
container: { flex: 1, backgroundColor: '#121212' },
colors: { black: '#000', white: 'white' },
logout:{width:30, height:20, marginRight:10}
});
export default App;