-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
172 lines (158 loc) · 5.78 KB
/
Copy pathApp.js
File metadata and controls
172 lines (158 loc) · 5.78 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import React, { useEffect, useRef } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { View, Text, TouchableOpacity, Dimensions } from 'react-native';
import { StatusBar } from 'expo-status-bar';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import * as Notifications from 'expo-notifications';
import DashboardScreen from './src/screens/DashboardScreen';
import BudgetScreen from './src/screens/BudgetScreen';
import PositionsScreen from './src/screens/PositionsScreen';
import ChatScreen from './src/screens/ChatScreen';
import HistoryScreen from './src/screens/HistoryScreen';
import { colors } from './src/theme';
import { registerForPushNotifications } from './src/services/notificationService';
const Tab = createBottomTabNavigator();
const SCREEN_WIDTH = Dimensions.get('window').width;
function DashIcon({ color }) {
return (
<View style={{ width: 16, height: 16, alignItems: 'center', justifyContent: 'center' }}>
<View style={{ width: 9, height: 9, borderWidth: 1.5, borderColor: color, transform: [{ rotate: '45deg' }] }} />
</View>
);
}
function BudgetIcon({ color }) {
return (
<View style={{ width: 16, height: 16, alignItems: 'center', justifyContent: 'center' }}>
<View style={{ width: 13, height: 13, borderRadius: 6.5, borderWidth: 1.5, borderColor: color }} />
</View>
);
}
function PozIcon({ color }) {
const s = { width: 4, height: 4, borderWidth: 1.5, borderColor: color };
return (
<View style={{ width: 16, height: 16, alignItems: 'center', justifyContent: 'center', gap: 2 }}>
<View style={{ flexDirection: 'row', gap: 2 }}>
<View style={s} /><View style={s} />
</View>
<View style={{ flexDirection: 'row', gap: 2 }}>
<View style={s} /><View style={s} />
</View>
</View>
);
}
function ChatIcon({ color }) {
return (
<View style={{ width: 16, height: 16, alignItems: 'center', justifyContent: 'center' }}>
<View style={{ width: 13, height: 13, borderRadius: 6.5, borderWidth: 1.5, borderColor: color, alignItems: 'center', justifyContent: 'center' }}>
<View style={{ width: 4, height: 4, borderRadius: 2, backgroundColor: color }} />
</View>
</View>
);
}
function HistoryIcon({ color }) {
return (
<View style={{ width: 16, height: 16, alignItems: 'center', justifyContent: 'center' }}>
<View style={{ width: 10, height: 13, borderWidth: 1.5, borderColor: color, borderRadius: 2 }} />
</View>
);
}
const TAB_CONFIG = [
{ name: 'Dashboard', Icon: DashIcon, label: 'BOARD' },
{ name: 'Budget', Icon: BudgetIcon, label: 'BÜTÇE' },
{ name: 'Positions', Icon: PozIcon, label: 'POZİSYON' },
{ name: 'Chat', Icon: ChatIcon, label: 'ATHENA' },
{ name: 'History', Icon: HistoryIcon, label: 'GEÇMİŞ' },
];
function CustomTabBar({ state, navigation }) {
const insets = useSafeAreaInsets();
const itemWidth = SCREEN_WIDTH / TAB_CONFIG.length;
return (
<View style={{
flexDirection: 'row',
backgroundColor: '#0A0A0A',
borderTopWidth: 1,
borderTopColor: colors.border,
paddingBottom: insets.bottom,
paddingTop: 8,
height: 52 + insets.bottom,
}}>
{TAB_CONFIG.map((tab, index) => {
const focused = state.index === index;
const color = focused ? colors.primary : colors.textSecondary;
const { Icon } = tab;
return (
<TouchableOpacity
key={tab.name}
onPress={() => navigation.navigate(tab.name)}
style={{
width: itemWidth,
alignItems: 'center',
justifyContent: 'center',
gap: 4,
}}
activeOpacity={0.7}
>
<Icon color={color} />
<Text
numberOfLines={1}
style={{
fontSize: 8,
fontWeight: focused ? '700' : '500',
color,
letterSpacing: 0.3,
textAlign: 'center',
width: itemWidth - 4,
}}
>
{tab.label}
</Text>
</TouchableOpacity>
);
})}
</View>
);
}
function AppNavigator() {
return (
<Tab.Navigator
tabBar={(props) => <CustomTabBar {...props} />}
screenOptions={{ headerShown: false }}
>
<Tab.Screen name="Dashboard" component={DashboardScreen} />
<Tab.Screen name="Budget" component={BudgetScreen} />
<Tab.Screen name="Positions" component={PositionsScreen} />
<Tab.Screen name="Chat" component={ChatScreen} />
<Tab.Screen name="History" component={HistoryScreen} />
</Tab.Navigator>
);
}
export default function App() {
const notificationListener = useRef();
const responseListener = useRef();
useEffect(() => {
// Push notification setup
registerForPushNotifications();
// Bildirim geldiğinde (uygulama açıkken)
notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
console.log('Bildirim alındı:', notification);
});
// Bildirime tıklandığında
responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
console.log('Bildirime tıklandı:', response);
});
return () => {
Notifications.removeNotificationSubscription(notificationListener.current);
Notifications.removeNotificationSubscription(responseListener.current);
};
}, []);
return (
<SafeAreaProvider>
<StatusBar style="light" backgroundColor="#000000" />
<NavigationContainer>
<AppNavigator />
</NavigationContainer>
</SafeAreaProvider>
);
}