-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
75 lines (69 loc) · 2.88 KB
/
App.tsx
File metadata and controls
75 lines (69 loc) · 2.88 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
import React, { useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { StatusBar } from 'react-native';
import RootNavigator from './src/navigation/RootNavigator';
import { useDailyReset } from './src/hooks/useDailyReset';
import { checkAchievements } from './src/services/achievementEngine';
import { useAppStore, useStatsStore, useTradeStore, useSettingsStore } from './src/stores';
import { appBlocker } from './src/services/blockingManager';
function AppInner() {
useDailyReset();
// Sync settings to native on app start
useEffect(() => {
const settings = useSettingsStore.getState();
const packages = settings.blockedApps.filter((a) => a.enabled).map((a) => a.packageName);
appBlocker.updateBlockedApps(packages).catch(() => {});
appBlocker.setDailyLimit(settings.dailyLimitMinutes).catch(() => {});
}, []);
// Run achievement checks whenever relevant state changes
const totalProfit = useAppStore((s) => s.totalProfit);
const currentStreak = useAppStore((s) => s.currentStreak);
const todayScreenTime = useAppStore((s) => s.todayScreenTime);
const unlockedAchievements = useAppStore((s) => s.unlockedAchievements);
const unlockAchievement = useAppStore((s) => s.unlockAchievement);
const totalUnlocks = useStatsStore((s) => s.totalUnlocks);
const totalBypasses = useStatsStore((s) => s.totalBypasses);
const trades = useTradeStore((s) => s.trades);
useEffect(() => {
const hasSolanaTrade = trades.some((t) => t.source === 'solana');
const results = checkAchievements(
{ totalProfit, currentStreak, totalUnlocks, totalBypasses, weekBypasses: totalBypasses, todayScreenTime, hasSolanaTrade },
new Set(unlockedAchievements),
);
results.forEach((a) => {
if (a.unlocked && !unlockedAchievements.includes(a.id)) {
unlockAchievement(a.id);
}
});
}, [totalProfit, currentStreak, todayScreenTime, totalUnlocks, totalBypasses, trades, unlockedAchievements, unlockAchievement]);
return <RootNavigator />;
}
export default function App() {
return (
<SafeAreaProvider>
<StatusBar barStyle="light-content" backgroundColor="#0A0A0F" />
<NavigationContainer
theme={{
dark: true,
colors: {
primary: '#4F8CFF',
background: '#0A0A0F',
card: '#131318',
text: '#e4e1e9',
border: 'rgba(255,255,255,0.08)',
notification: '#4F8CFF',
},
fonts: {
regular: { fontFamily: 'Inter', fontWeight: '400' },
medium: { fontFamily: 'Inter', fontWeight: '500' },
bold: { fontFamily: 'Inter', fontWeight: '700' },
heavy: { fontFamily: 'Inter', fontWeight: '800' },
},
}}
>
<AppInner />
</NavigationContainer>
</SafeAreaProvider>
);
}