altaga-expo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/app.json +54 -0
- package/eslint.config.js +10 -0
- package/package.json +52 -0
- package/src/app/(screens)/main.js +43 -0
- package/src/app/+html.js +20 -0
- package/src/app/+middleware.js +38 -0
- package/src/app/+not-found.js +6 -0
- package/src/app/_layout.js +58 -0
- package/src/app/api/helloNoSecure+api.js +7 -0
- package/src/app/api/helloSecure+api.js +9 -0
- package/src/app/index.js +35 -0
- package/src/assets/favicon.png +0 -0
- package/src/assets/frame.png +0 -0
- package/src/assets/logo.png +0 -0
- package/src/core/constants.js +3 -0
- package/src/core/error.js +28 -0
- package/src/core/polyfills.js +4 -0
- package/src/core/styles.js +112 -0
- package/src/hocs/useHOCS.js +33 -0
- package/src/providers/contextLoader.js +43 -0
- package/src/providers/contextModule.js +57 -0
- package/src/providers/smartProvider.js +131 -0
- package/src/utilsAPI/corsHelper.js +27 -0
- package/src/utilsAPI/withSecurity.js +21 -0
- package/src/utilsApp/utils.js +136 -0
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Welcome to your Expo app 👋
|
|
2
|
+
|
|
3
|
+
This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
|
|
4
|
+
|
|
5
|
+
## Get started
|
|
6
|
+
|
|
7
|
+
1. Install dependencies
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Start the app
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx expo start
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
In the output, you'll find options to open the app in a
|
|
20
|
+
|
|
21
|
+
- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
|
|
22
|
+
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
|
|
23
|
+
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
|
|
24
|
+
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
|
|
25
|
+
|
|
26
|
+
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
|
|
27
|
+
|
|
28
|
+
## Get a fresh project
|
|
29
|
+
|
|
30
|
+
When you're ready, run:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm run reset-project
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
|
|
37
|
+
|
|
38
|
+
## Learn more
|
|
39
|
+
|
|
40
|
+
To learn more about developing your project with Expo, look at the following resources:
|
|
41
|
+
|
|
42
|
+
- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
|
|
43
|
+
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
|
|
44
|
+
|
|
45
|
+
## Join the community
|
|
46
|
+
|
|
47
|
+
Join our community of developers creating universal apps.
|
|
48
|
+
|
|
49
|
+
- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
|
|
50
|
+
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
|
package/app.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"expo": {
|
|
3
|
+
"name": "altaga-expo",
|
|
4
|
+
"slug": "altaga-expo",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"orientation": "portrait",
|
|
7
|
+
"icon": "./src/assets/logo.png",
|
|
8
|
+
"scheme": "altagaexpo",
|
|
9
|
+
"userInterfaceStyle": "automatic",
|
|
10
|
+
"newArchEnabled": true,
|
|
11
|
+
"ios": {
|
|
12
|
+
"supportsTablet": true
|
|
13
|
+
},
|
|
14
|
+
"android": {
|
|
15
|
+
"adaptiveIcon": {
|
|
16
|
+
"backgroundColor": "#E6F4FE",
|
|
17
|
+
"foregroundImage": "./src/assets/logo.png",
|
|
18
|
+
"backgroundImage": "./src/assets/logo.png",
|
|
19
|
+
"monochromeImage": "./src/assets/logo.png"
|
|
20
|
+
},
|
|
21
|
+
"edgeToEdgeEnabled": true,
|
|
22
|
+
"predictiveBackGestureEnabled": false
|
|
23
|
+
},
|
|
24
|
+
"web": {
|
|
25
|
+
"output": "server",
|
|
26
|
+
"favicon": "./src/assets/favicon.png"
|
|
27
|
+
},
|
|
28
|
+
"plugins": [
|
|
29
|
+
[
|
|
30
|
+
"expo-router",
|
|
31
|
+
{
|
|
32
|
+
"unstable_useServerMiddleware": true
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
"expo-splash-screen",
|
|
37
|
+
{
|
|
38
|
+
"image": "./src/assets/logo.png",
|
|
39
|
+
"imageWidth": 200,
|
|
40
|
+
"resizeMode": "contain",
|
|
41
|
+
"backgroundColor": "#ffffff",
|
|
42
|
+
"dark": {
|
|
43
|
+
"backgroundColor": "#000000"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"expo-secure-store"
|
|
48
|
+
],
|
|
49
|
+
"experiments": {
|
|
50
|
+
"typedRoutes": true,
|
|
51
|
+
"reactCompiler": true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
package/eslint.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "altaga-expo",
|
|
3
|
+
"main": "expo-router/entry",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"start": "expo start",
|
|
7
|
+
"reset-project": "node ./scripts/reset-project.js",
|
|
8
|
+
"android": "expo start --android",
|
|
9
|
+
"ios": "expo start --ios",
|
|
10
|
+
"web": "expo start --web",
|
|
11
|
+
"lint": "expo lint"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@expo-google-fonts/exo-2": "^0.4.2",
|
|
15
|
+
"@expo/vector-icons": "^15.0.3",
|
|
16
|
+
"@react-native-async-storage/async-storage": "2.2.0",
|
|
17
|
+
"@react-navigation/bottom-tabs": "^7.4.0",
|
|
18
|
+
"@react-navigation/elements": "^2.6.3",
|
|
19
|
+
"@react-navigation/native": "^7.1.8",
|
|
20
|
+
"buffer": "^6.0.3",
|
|
21
|
+
"expo": "~54.0.33",
|
|
22
|
+
"expo-constants": "~18.0.13",
|
|
23
|
+
"expo-font": "~14.0.11",
|
|
24
|
+
"expo-haptics": "~15.0.8",
|
|
25
|
+
"expo-image": "~3.0.11",
|
|
26
|
+
"expo-linking": "~8.0.11",
|
|
27
|
+
"expo-router": "~6.0.23",
|
|
28
|
+
"expo-secure-store": "~15.0.8",
|
|
29
|
+
"expo-splash-screen": "~31.0.13",
|
|
30
|
+
"expo-status-bar": "~3.0.9",
|
|
31
|
+
"expo-symbols": "~1.0.8",
|
|
32
|
+
"expo-system-ui": "~6.0.9",
|
|
33
|
+
"expo-web-browser": "~15.0.10",
|
|
34
|
+
"react": "19.1.0",
|
|
35
|
+
"react-dom": "19.1.0",
|
|
36
|
+
"react-native": "0.81.5",
|
|
37
|
+
"react-native-gesture-handler": "~2.28.0",
|
|
38
|
+
"react-native-reanimated": "~4.1.1",
|
|
39
|
+
"react-native-safe-area-context": "~5.6.0",
|
|
40
|
+
"react-native-screens": "~4.16.0",
|
|
41
|
+
"react-native-web": "~0.21.0",
|
|
42
|
+
"react-native-worklets": "0.5.1",
|
|
43
|
+
"toastify-react-native": "^7.2.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/react": "~19.1.0",
|
|
47
|
+
"eslint": "^9.25.0",
|
|
48
|
+
"eslint-config-expo": "~10.0.0",
|
|
49
|
+
"typescript": "~5.9.2"
|
|
50
|
+
},
|
|
51
|
+
"private": false
|
|
52
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Pressable, Text, View } from "react-native";
|
|
2
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
3
|
+
import { createGlobalStyles } from "../../core/styles";
|
|
4
|
+
import { useSmartSize } from "../../providers/smartProvider";
|
|
5
|
+
|
|
6
|
+
export default function Main() {
|
|
7
|
+
const smartSize = useSmartSize();
|
|
8
|
+
const { normalize } = smartSize;
|
|
9
|
+
const GlobalStyles = createGlobalStyles(smartSize);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<SafeAreaView style={GlobalStyles.container}>
|
|
13
|
+
{/* ─── Minimal Header ─── */}
|
|
14
|
+
<View style={GlobalStyles.header}>
|
|
15
|
+
<Text style={GlobalStyles.heroTitle}>Template</Text>
|
|
16
|
+
<View style={{ width: normalize(12), height: normalize(12), borderRadius: 6, backgroundColor: "#D4AF37" }} />
|
|
17
|
+
</View>
|
|
18
|
+
|
|
19
|
+
{/* ─── Minimal Body ─── */}
|
|
20
|
+
<View style={[GlobalStyles.main, { padding: normalize(24), justifyContent: 'center' }]}>
|
|
21
|
+
<View style={{ gap: normalize(12) }}>
|
|
22
|
+
<Text style={GlobalStyles.sectionHeader}>Welcome</Text>
|
|
23
|
+
<Text style={[GlobalStyles.heroTitle, { fontSize: normalize(48), lineHeight: normalize(48) }]}>
|
|
24
|
+
Start{"\n"}Building.
|
|
25
|
+
</Text>
|
|
26
|
+
<Text style={GlobalStyles.bodyText}>
|
|
27
|
+
This is a clean, minimal starting point for your next project.
|
|
28
|
+
</Text>
|
|
29
|
+
</View>
|
|
30
|
+
</View>
|
|
31
|
+
|
|
32
|
+
{/* ─── Single Action ─── */}
|
|
33
|
+
<View style={{ padding: normalize(24), paddingBottom: normalize(40) }}>
|
|
34
|
+
<Pressable style={({ pressed }) => [
|
|
35
|
+
GlobalStyles.primaryButton,
|
|
36
|
+
pressed && { opacity: 0.9, transform: [{ scale: 0.98 }] }
|
|
37
|
+
]}>
|
|
38
|
+
<Text style={GlobalStyles.buttonText}>Get Started</Text>
|
|
39
|
+
</Pressable>
|
|
40
|
+
</View>
|
|
41
|
+
</SafeAreaView>
|
|
42
|
+
);
|
|
43
|
+
}
|
package/src/app/+html.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ScrollViewStyleReset } from "expo-router/html";
|
|
2
|
+
|
|
3
|
+
export default function Root({ children }) {
|
|
4
|
+
return (
|
|
5
|
+
<html lang="en" style={{ backgroundColor: "black" }}>
|
|
6
|
+
<head>
|
|
7
|
+
<meta charSet="utf-8" />
|
|
8
|
+
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
|
|
9
|
+
<meta
|
|
10
|
+
name="viewport"
|
|
11
|
+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
|
12
|
+
/>
|
|
13
|
+
<ScrollViewStyleReset />
|
|
14
|
+
</head>
|
|
15
|
+
<body style={{ backgroundColor: "black", margin: 0, padding: 0 }}>
|
|
16
|
+
{children}
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getCorsHeaders, isAllowedOrigin } from "../utilsAPI/corsHelper";
|
|
2
|
+
|
|
3
|
+
export const unstable_settings = {
|
|
4
|
+
matcher: {
|
|
5
|
+
patterns: [
|
|
6
|
+
"/api",
|
|
7
|
+
"/api/[...path]"
|
|
8
|
+
],
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default function middleware(request) {
|
|
13
|
+
if (request.method === "OPTIONS") {
|
|
14
|
+
return new Response(null, {
|
|
15
|
+
status: 204,
|
|
16
|
+
headers: getCorsHeaders(request),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!isAllowedOrigin(request)) {
|
|
21
|
+
console.warn(`🚫 CORS BLOCKED origin: ${request.headers.get("origin")}`);
|
|
22
|
+
return Response.json(
|
|
23
|
+
{ error: "CORS error: Origin not allowed" },
|
|
24
|
+
{ status: 403, headers: getCorsHeaders(request) }
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const userAgent = request.headers.get("user-agent")?.toLowerCase() || "";
|
|
29
|
+
const blockedAgents = ["postman", "curl", "node-fetch", "axios", "insomnia", "undici"];
|
|
30
|
+
|
|
31
|
+
if (blockedAgents.some(agent => userAgent.includes(agent))) {
|
|
32
|
+
console.warn(`🚫 Blocked automated tool: ${userAgent}`);
|
|
33
|
+
return Response.json(
|
|
34
|
+
{ error: "Automated requests and server tools are not allowed." },
|
|
35
|
+
{ status: 403, headers: getCorsHeaders(request) }
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import '../core/polyfills';
|
|
2
|
+
import { ContextProvider } from "../providers/contextModule";
|
|
3
|
+
import SmartProvider from "../providers/smartProvider";
|
|
4
|
+
import {
|
|
5
|
+
Exo2_400Regular,
|
|
6
|
+
Exo2_700Bold,
|
|
7
|
+
useFonts,
|
|
8
|
+
} from "@expo-google-fonts/exo-2";
|
|
9
|
+
import { Stack } from "expo-router";
|
|
10
|
+
import { StatusBar } from "expo-status-bar";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import "react-native-reanimated";
|
|
13
|
+
import "../core/error";
|
|
14
|
+
import ContextLoader from "../providers/contextLoader";
|
|
15
|
+
|
|
16
|
+
export default function RootLayout() {
|
|
17
|
+
useFonts({
|
|
18
|
+
Exo2_400Regular,
|
|
19
|
+
Exo2_700Bold,
|
|
20
|
+
});
|
|
21
|
+
return (
|
|
22
|
+
<React.Fragment>
|
|
23
|
+
{
|
|
24
|
+
// This provider put a phone frame around the app if the app is running on a desktop
|
|
25
|
+
}
|
|
26
|
+
<SmartProvider>
|
|
27
|
+
{
|
|
28
|
+
// This provider provides the context to the app
|
|
29
|
+
}
|
|
30
|
+
<ContextProvider>
|
|
31
|
+
{
|
|
32
|
+
// This provider provides metamask connectivity
|
|
33
|
+
}
|
|
34
|
+
<ContextLoader />
|
|
35
|
+
{
|
|
36
|
+
// Base App Analytics
|
|
37
|
+
}
|
|
38
|
+
<Stack
|
|
39
|
+
initialRouteName="index"
|
|
40
|
+
screenOptions={{
|
|
41
|
+
animation: "simple_push",
|
|
42
|
+
headerShown: false,
|
|
43
|
+
contentStyle: { backgroundColor: "black" },
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
{
|
|
47
|
+
// Splash Loading Screen
|
|
48
|
+
}
|
|
49
|
+
<Stack.Screen name="index" />
|
|
50
|
+
<Stack.Screen name="(screens)/main" />
|
|
51
|
+
<Stack.Screen name="+not-found" options={{ title: 'Oops!' }} />
|
|
52
|
+
</Stack>
|
|
53
|
+
<StatusBar style="auto" />
|
|
54
|
+
</ContextProvider>
|
|
55
|
+
</SmartProvider>
|
|
56
|
+
</React.Fragment>
|
|
57
|
+
);
|
|
58
|
+
}
|
package/src/app/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Basic Imports
|
|
2
|
+
import { Image } from "expo-image";
|
|
3
|
+
import { useNavigation } from "expo-router";
|
|
4
|
+
import { useContext, useEffect } from "react";
|
|
5
|
+
import { View } from "react-native";
|
|
6
|
+
import logoSplash from "../assets/logo.png";
|
|
7
|
+
import { createGlobalStyles } from "../core/styles";
|
|
8
|
+
import ContextModule from "../providers/contextModule";
|
|
9
|
+
import { useSmartSize } from "../providers/smartProvider";
|
|
10
|
+
|
|
11
|
+
export default function SplashLoading() {
|
|
12
|
+
const context = useContext(ContextModule);
|
|
13
|
+
const smartSize = useSmartSize();
|
|
14
|
+
const GlobalStyles = createGlobalStyles(smartSize);
|
|
15
|
+
const navigation = useNavigation();
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
context.value.starter && navigation.navigate("(screens)/main");
|
|
19
|
+
}, [context.value.starter, navigation]);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<View style={[GlobalStyles.container, { justifyContent: "center" }]}>
|
|
23
|
+
<Image
|
|
24
|
+
source={logoSplash}
|
|
25
|
+
alt="Main Logo"
|
|
26
|
+
contentFit="contain"
|
|
27
|
+
transition={200}
|
|
28
|
+
style={{
|
|
29
|
+
width: "70%",
|
|
30
|
+
aspectRatio: 1,
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
</View>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
if (typeof window !== "undefined") {
|
|
2
|
+
// Fill this with your own ignore patterns
|
|
3
|
+
const ignorePatterns = [
|
|
4
|
+
];
|
|
5
|
+
|
|
6
|
+
const shouldIgnore = (...args) => {
|
|
7
|
+
const msg = args.map(String).join(" ").toLowerCase();
|
|
8
|
+
return ignorePatterns.some((p) => msg.includes(p));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const originalError = console.error;
|
|
12
|
+
console.error = (...args) => {
|
|
13
|
+
if (shouldIgnore(...args)) return;
|
|
14
|
+
originalError.apply(console, args);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const originalWarn = console.warn;
|
|
18
|
+
console.warn = (...args) => {
|
|
19
|
+
if (shouldIgnore(...args)) return;
|
|
20
|
+
originalWarn.apply(console, args);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const originalLog = console.log;
|
|
24
|
+
console.log = (...args) => {
|
|
25
|
+
if (shouldIgnore(...args)) return;
|
|
26
|
+
originalLog.apply(console, args);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Dimensions, StatusBar, StyleSheet } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const screenHeight = Dimensions.get("screen").height;
|
|
4
|
+
export const windowHeight = Dimensions.get("window").height;
|
|
5
|
+
|
|
6
|
+
// ─── Luxury Dark Palette ──────────────────────────────────────────────────
|
|
7
|
+
export const backgroundColor = "#0A0A0A"; // Rich Black
|
|
8
|
+
export const cardColor = "#1C1C1E"; // Elevated surface
|
|
9
|
+
export const accentColor = "#D4AF37"; // Metallic Gold
|
|
10
|
+
export const whiteColor = "#FFFFFF";
|
|
11
|
+
export const textSecondary = "#8E8E93";
|
|
12
|
+
export const borderColor = "#2C2C2E";
|
|
13
|
+
|
|
14
|
+
export const headerHeight = 84;
|
|
15
|
+
export const footerHeight = 64;
|
|
16
|
+
export const ratio =
|
|
17
|
+
Dimensions.get("window").height / Dimensions.get("window").width;
|
|
18
|
+
export const mainHeight =
|
|
19
|
+
Dimensions.get("window").height -
|
|
20
|
+
(headerHeight + footerHeight + (ratio > 1.7 ? 0 : (StatusBar.currentHeight ?? 0)));
|
|
21
|
+
export const StatusBarHeight = StatusBar.currentHeight ?? 0;
|
|
22
|
+
|
|
23
|
+
export const createGlobalStyles = ({ normalize }) => {
|
|
24
|
+
const baseText = {
|
|
25
|
+
color: whiteColor,
|
|
26
|
+
fontFamily: "Exo2_400Regular"
|
|
27
|
+
};
|
|
28
|
+
const baseBoldText = {
|
|
29
|
+
...baseText,
|
|
30
|
+
fontFamily: "Exo2_700Bold"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return StyleSheet.create({
|
|
34
|
+
// ─── Core Layout ──────────────────────────────────────────────────────────
|
|
35
|
+
container: {
|
|
36
|
+
flex: 1,
|
|
37
|
+
backgroundColor,
|
|
38
|
+
},
|
|
39
|
+
header: {
|
|
40
|
+
height: normalize(headerHeight),
|
|
41
|
+
width: "100%",
|
|
42
|
+
flexDirection: "row",
|
|
43
|
+
justifyContent: "space-between",
|
|
44
|
+
alignItems: "center",
|
|
45
|
+
paddingHorizontal: normalize(24),
|
|
46
|
+
borderBottomWidth: 1,
|
|
47
|
+
borderBottomColor: borderColor,
|
|
48
|
+
},
|
|
49
|
+
main: {
|
|
50
|
+
flex: 1,
|
|
51
|
+
width: "100%",
|
|
52
|
+
},
|
|
53
|
+
footer: {
|
|
54
|
+
width: "100%",
|
|
55
|
+
height: normalize(footerHeight),
|
|
56
|
+
flexDirection: "row",
|
|
57
|
+
justifyContent: "space-around",
|
|
58
|
+
alignItems: "center",
|
|
59
|
+
borderTopWidth: 1,
|
|
60
|
+
borderTopColor: borderColor,
|
|
61
|
+
},
|
|
62
|
+
// ─── Typography (Luxury Minimalist) ───────────────────────────────────────
|
|
63
|
+
heroTitle: {
|
|
64
|
+
...baseBoldText,
|
|
65
|
+
fontSize: normalize(32),
|
|
66
|
+
letterSpacing: -1,
|
|
67
|
+
},
|
|
68
|
+
sectionHeader: {
|
|
69
|
+
...baseBoldText,
|
|
70
|
+
fontSize: normalize(18),
|
|
71
|
+
color: accentColor,
|
|
72
|
+
textTransform: "uppercase",
|
|
73
|
+
letterSpacing: 1.5,
|
|
74
|
+
},
|
|
75
|
+
bodyText: {
|
|
76
|
+
...baseText,
|
|
77
|
+
fontSize: normalize(16),
|
|
78
|
+
color: textSecondary,
|
|
79
|
+
},
|
|
80
|
+
labelSmall: {
|
|
81
|
+
...baseText,
|
|
82
|
+
fontSize: normalize(12),
|
|
83
|
+
color: textSecondary,
|
|
84
|
+
textTransform: "uppercase",
|
|
85
|
+
letterSpacing: 1,
|
|
86
|
+
},
|
|
87
|
+
// ─── Template Components ──────────────────────────────────────────────────
|
|
88
|
+
card: {
|
|
89
|
+
backgroundColor: cardColor,
|
|
90
|
+
borderRadius: normalize(16),
|
|
91
|
+
padding: normalize(20),
|
|
92
|
+
borderWidth: 1,
|
|
93
|
+
borderColor,
|
|
94
|
+
},
|
|
95
|
+
primaryButton: {
|
|
96
|
+
backgroundColor: accentColor,
|
|
97
|
+
borderRadius: normalize(12),
|
|
98
|
+
paddingVertical: normalize(16),
|
|
99
|
+
paddingHorizontal: normalize(32),
|
|
100
|
+
alignItems: "center",
|
|
101
|
+
justifyContent: "center",
|
|
102
|
+
},
|
|
103
|
+
buttonText: {
|
|
104
|
+
...baseBoldText,
|
|
105
|
+
color: backgroundColor,
|
|
106
|
+
fontSize: normalize(16),
|
|
107
|
+
},
|
|
108
|
+
// ─── Utility ──────────────────────────────────────────────────────────────
|
|
109
|
+
textAccent: { color: accentColor },
|
|
110
|
+
textWhite: { color: whiteColor },
|
|
111
|
+
});
|
|
112
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useGlobalSearchParams,
|
|
3
|
+
useLocalSearchParams,
|
|
4
|
+
useNavigation,
|
|
5
|
+
} from "expo-router";
|
|
6
|
+
|
|
7
|
+
export const useHOCS = (Component) => { // For Class Components to have access to hooks
|
|
8
|
+
const getCurrentRoute = (navigation) => {
|
|
9
|
+
const state = navigation.getState();
|
|
10
|
+
const currentRoute = state.routes[state.index].name;
|
|
11
|
+
return currentRoute;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const HOCSComponent = (props) => {
|
|
15
|
+
const navigation = useNavigation();
|
|
16
|
+
const route = getCurrentRoute(navigation);
|
|
17
|
+
const glob = useGlobalSearchParams();
|
|
18
|
+
const local = useLocalSearchParams();
|
|
19
|
+
return (
|
|
20
|
+
<Component
|
|
21
|
+
glob={glob}
|
|
22
|
+
local={local}
|
|
23
|
+
navigation={navigation}
|
|
24
|
+
route={route}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
HOCSComponent.displayName = "HOCSComponent";
|
|
31
|
+
|
|
32
|
+
return HOCSComponent;
|
|
33
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
2
|
+
import { Fragment, useCallback, useContext, useEffect } from "react";
|
|
3
|
+
import { getAsyncStorageValue } from "../utilsApp/utils";
|
|
4
|
+
import ContextModule from "./contextModule";
|
|
5
|
+
|
|
6
|
+
export default function ContextLoader() {
|
|
7
|
+
const context = useContext(ContextModule);
|
|
8
|
+
const checkStarter = useCallback(async () => {
|
|
9
|
+
//await nukeStorage(); // for testing
|
|
10
|
+
|
|
11
|
+
const nonSensitiveData = await getAsyncStorageValue("NONSENSITIVEDATA"); // Check if the app is started for the first time
|
|
12
|
+
|
|
13
|
+
if (nonSensitiveData === null) {
|
|
14
|
+
context.setValue({ starter: true });
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const schema = await AsyncStorage.getItem("General");
|
|
19
|
+
const isConsistent =
|
|
20
|
+
Object.keys(context.value).length ===
|
|
21
|
+
Object.keys(JSON.parse(schema)).length;
|
|
22
|
+
|
|
23
|
+
if (isConsistent) {
|
|
24
|
+
console.log("Schema Match, using stored data"); // Avoiding data loss
|
|
25
|
+
context.setValue({
|
|
26
|
+
nonSensitiveData,
|
|
27
|
+
starter: true,
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
console.log("Schema Mismatch, using default data");
|
|
31
|
+
context.setValue({
|
|
32
|
+
...context.value,
|
|
33
|
+
starter: true,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}, [context]);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
checkStarter();
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
return <Fragment />;
|
|
43
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
const ContextModule = React.createContext();
|
|
4
|
+
|
|
5
|
+
class ContextProvider extends React.Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.state = {
|
|
9
|
+
value: {
|
|
10
|
+
// Use Your own default values
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setValue = (value, then = () => {}) => {
|
|
16
|
+
this.setState(
|
|
17
|
+
{
|
|
18
|
+
value: {
|
|
19
|
+
...this.state.value,
|
|
20
|
+
...value,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
() => then(),
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
setValueAsync = async (value, then = () => {}) => {
|
|
28
|
+
await new Promise((resolve) =>
|
|
29
|
+
this.setState(
|
|
30
|
+
{
|
|
31
|
+
value: {
|
|
32
|
+
...this.state.value,
|
|
33
|
+
...value,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
() => resolve(),
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
then();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
render() {
|
|
43
|
+
const { children } = this.props;
|
|
44
|
+
const { value } = this.state;
|
|
45
|
+
const { setValue, setValueAsync } = this;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<ContextModule.Provider value={{ value, setValue, setValueAsync }}>
|
|
49
|
+
{children}
|
|
50
|
+
</ContextModule.Provider>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { ContextProvider };
|
|
56
|
+
export const ContextConsumer = ContextModule.Consumer;
|
|
57
|
+
export default ContextModule;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import frame from "../assets/frame.png";
|
|
2
|
+
import { Image } from "expo-image";
|
|
3
|
+
import React, {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { Dimensions, PixelRatio, Platform, View } from "react-native";
|
|
11
|
+
import ToastManager from "toastify-react-native";
|
|
12
|
+
|
|
13
|
+
// 1. Create the Context
|
|
14
|
+
const SmartSizeContext = createContext({
|
|
15
|
+
width: 0,
|
|
16
|
+
height: 0,
|
|
17
|
+
scale: 1,
|
|
18
|
+
normalize: (size) => size,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// 2. Export the Hook
|
|
22
|
+
export const useSmartSize = () => useContext(SmartSizeContext);
|
|
23
|
+
|
|
24
|
+
export default function SmartProvider({ children }) {
|
|
25
|
+
const [frameSize, setFrameSize] = useState({ width: 0, height: 0 });
|
|
26
|
+
const [windowDimensions, setWindowDimensions] = useState(
|
|
27
|
+
Dimensions.get("window"),
|
|
28
|
+
);
|
|
29
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setIsMounted(true);
|
|
33
|
+
const subscription = Dimensions.addEventListener("change", ({ window }) => {
|
|
34
|
+
setWindowDimensions(window);
|
|
35
|
+
});
|
|
36
|
+
return () => subscription?.remove();
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
const ratio = windowDimensions.height / windowDimensions.width;
|
|
40
|
+
// Ensure the frame is only added after the component has mounted on the client.
|
|
41
|
+
// This prevents hydration mismatches (React error #418) between the server and the first render.
|
|
42
|
+
const isWebMobileView = isMounted ? Platform.OS === "web" && ratio < 1 : false;
|
|
43
|
+
|
|
44
|
+
// 3. Calculate the internal "smartphone" dimensions
|
|
45
|
+
// These are the dimensions the children actually see
|
|
46
|
+
const internalSize = useMemo(() => {
|
|
47
|
+
let width, height;
|
|
48
|
+
if (!isWebMobileView) {
|
|
49
|
+
width = windowDimensions.width;
|
|
50
|
+
height = windowDimensions.height;
|
|
51
|
+
} else {
|
|
52
|
+
width = frameSize.height / 2.3179;
|
|
53
|
+
height = frameSize.height * 0.7668;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Scale primarily based on width to avoid height-distortion on vertical screens.
|
|
57
|
+
const baseScale = width / 375;
|
|
58
|
+
// Apply a moderation factor (0 = no scale, 1 = full linear scale) to prevent extreme sizes
|
|
59
|
+
const factor = 0.4; // Adjust this value (0 to 1) to fine-tune the moderation
|
|
60
|
+
const moderateScale = 1 + (baseScale - 1) * factor;
|
|
61
|
+
// Clamp the scale to a safe range to prevent undersizing on tiny screens or oversizing on tablets
|
|
62
|
+
const clampedScale = Math.max(0.85, Math.min(1.2, moderateScale));
|
|
63
|
+
const normalize = (size) => PixelRatio.roundToNearestPixel(size * clampedScale);
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
width,
|
|
67
|
+
height,
|
|
68
|
+
scale: clampedScale,
|
|
69
|
+
normalize,
|
|
70
|
+
};
|
|
71
|
+
}, [frameSize, windowDimensions, isWebMobileView]);
|
|
72
|
+
|
|
73
|
+
const handleLayout = (event) => {
|
|
74
|
+
const { width, height } = event.nativeEvent.layout;
|
|
75
|
+
// Optimization: Only update if the integer value changed (prevents loops)
|
|
76
|
+
setFrameSize((prev) => {
|
|
77
|
+
if (
|
|
78
|
+
Math.round(prev.width) === Math.round(width) &&
|
|
79
|
+
Math.round(prev.height) === Math.round(height)
|
|
80
|
+
) {
|
|
81
|
+
return prev;
|
|
82
|
+
}
|
|
83
|
+
return { width, height };
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<SmartSizeContext.Provider value={internalSize}>
|
|
89
|
+
{isWebMobileView ? (
|
|
90
|
+
<React.Fragment>
|
|
91
|
+
<Image
|
|
92
|
+
source={frame}
|
|
93
|
+
onLayout={handleLayout}
|
|
94
|
+
contentFit="contain"
|
|
95
|
+
style={{
|
|
96
|
+
width: "auto",
|
|
97
|
+
height: windowDimensions.height,
|
|
98
|
+
backgroundColor: "black",
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
<View
|
|
102
|
+
style={{
|
|
103
|
+
position: "absolute",
|
|
104
|
+
width: `100%`,
|
|
105
|
+
height: `100%`,
|
|
106
|
+
alignSelf: "center",
|
|
107
|
+
justifyContent: "center",
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
<View
|
|
111
|
+
style={{
|
|
112
|
+
width: internalSize.width,
|
|
113
|
+
height: "76.68%",
|
|
114
|
+
alignSelf: "center",
|
|
115
|
+
justifyContent: "center",
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
{children}
|
|
119
|
+
<ToastManager style={{ width: internalSize.width }} />
|
|
120
|
+
</View>
|
|
121
|
+
</View>
|
|
122
|
+
</React.Fragment>
|
|
123
|
+
) : (
|
|
124
|
+
<View style={{ flex: 1, backgroundColor: "black" }}>
|
|
125
|
+
{children}
|
|
126
|
+
<ToastManager />
|
|
127
|
+
</View>
|
|
128
|
+
)}
|
|
129
|
+
</SmartSizeContext.Provider>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const ALLOWED_ORIGINS = [
|
|
2
|
+
"https://YOUR_WEBSITE_URL.com",
|
|
3
|
+
"http://localhost:8081"
|
|
4
|
+
];
|
|
5
|
+
|
|
6
|
+
export function isAllowedOrigin(request) {
|
|
7
|
+
const origin = request.headers.get("origin");
|
|
8
|
+
|
|
9
|
+
if (!origin) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return ALLOWED_ORIGINS.includes(origin);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getCorsHeaders(request) {
|
|
17
|
+
const origin = request.headers.get("origin");
|
|
18
|
+
const allowedOrigin = ALLOWED_ORIGINS.includes(origin) ? origin : ALLOWED_ORIGINS[0];
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
"Access-Control-Allow-Origin": allowedOrigin,
|
|
22
|
+
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
23
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-API-Key, X-Timestamp, X-Signature",
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default function CorsHelper() { return null; }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getCorsHeaders } from "./corsHelper";
|
|
2
|
+
|
|
3
|
+
export function withSecurity(handler) {
|
|
4
|
+
return async (request) => {
|
|
5
|
+
try {
|
|
6
|
+
const response = await handler(request);
|
|
7
|
+
const cors = getCorsHeaders(request);
|
|
8
|
+
return new Response(response.body, {
|
|
9
|
+
...response,
|
|
10
|
+
headers: {
|
|
11
|
+
...Object.fromEntries(response.headers.entries()),
|
|
12
|
+
...cors,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
} catch (_err) {
|
|
16
|
+
return Response.json({ error: "Internal Error" }, { status: 500 });
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function WithSecurity() { return null; }
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
2
|
+
import * as EncryptedStorage from "expo-secure-store";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Dimensions, PixelRatio, Platform } from "react-native";
|
|
5
|
+
|
|
6
|
+
export async function getAsyncStorageValue(label, storage = "General") {
|
|
7
|
+
try {
|
|
8
|
+
const session = await AsyncStorage.getItem(storage);
|
|
9
|
+
if (label in JSON.parse(session)) {
|
|
10
|
+
return JSON.parse(session)[label];
|
|
11
|
+
} else {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function setAsyncStorageValue(value, storage = "General") {
|
|
20
|
+
const session = await AsyncStorage.getItem(storage);
|
|
21
|
+
await AsyncStorage.setItem(
|
|
22
|
+
storage,
|
|
23
|
+
JSON.stringify({
|
|
24
|
+
...JSON.parse(session),
|
|
25
|
+
...value,
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function getEncryptedStorageValue(label, storage = "General") {
|
|
31
|
+
try {
|
|
32
|
+
const session = await EncryptedStorage.getItem(storage);
|
|
33
|
+
if (label in JSON.parse(session)) {
|
|
34
|
+
return JSON.parse(session)[label];
|
|
35
|
+
} else {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
try {
|
|
40
|
+
const session = await AsyncStorage.getItem(storage + "Backup");
|
|
41
|
+
if (label in JSON.parse(session)) {
|
|
42
|
+
return JSON.parse(session)[label];
|
|
43
|
+
} else {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function setEncryptedStorageValue(value, storage = "General") {
|
|
53
|
+
try {
|
|
54
|
+
const session = await EncryptedStorage.getItem(storage);
|
|
55
|
+
await EncryptedStorage.setItem(
|
|
56
|
+
storage,
|
|
57
|
+
JSON.stringify({
|
|
58
|
+
...JSON.parse(session),
|
|
59
|
+
...value,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
} catch {
|
|
63
|
+
const session = await AsyncStorage.getItem(storage + "Backup");
|
|
64
|
+
await AsyncStorage.setItem(
|
|
65
|
+
storage + "Backup",
|
|
66
|
+
JSON.stringify({
|
|
67
|
+
...JSON.parse(session),
|
|
68
|
+
...value,
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function nukeStorage(storage = "General") {
|
|
75
|
+
try {
|
|
76
|
+
await AsyncStorage.clear();
|
|
77
|
+
await clearSecureStorage(storage);
|
|
78
|
+
} catch {
|
|
79
|
+
console.log("Failed to clear AsyncStorage");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function clearSecureStorage(storage) {
|
|
84
|
+
try {
|
|
85
|
+
await EncryptedStorage.deleteItemAsync(storage);
|
|
86
|
+
} catch {
|
|
87
|
+
console.log("Failed to clear EncryptedStorage");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function epsilonRound(num, zeros = 4) {
|
|
92
|
+
let temp = num;
|
|
93
|
+
if (typeof num === "string") {
|
|
94
|
+
temp = parseFloat(num);
|
|
95
|
+
}
|
|
96
|
+
return (
|
|
97
|
+
Math.round((temp + Number.EPSILON) * Math.pow(10, zeros)) /
|
|
98
|
+
Math.pow(10, zeros)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const normalizeFontSize = (size) => {
|
|
103
|
+
let { width, height } = Dimensions.get("window");
|
|
104
|
+
if (Platform.OS === "web" && height / width < 1) {
|
|
105
|
+
width /= 2.3179;
|
|
106
|
+
height *= 0.7668;
|
|
107
|
+
}
|
|
108
|
+
const scale = width / 375;
|
|
109
|
+
const factor = 0.4;
|
|
110
|
+
const moderateScale = 1 + (scale - 1) * factor;
|
|
111
|
+
// Clamp the scale between 0.85 (min) and 1.2 (max) to prevent overlapping layouts
|
|
112
|
+
const clampedScale = Math.max(0.85, Math.min(1.2, moderateScale));
|
|
113
|
+
return PixelRatio.roundToNearestPixel(size * clampedScale);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export function useStateAsync(initialValue) {
|
|
117
|
+
const [state, setState] = useState(initialValue);
|
|
118
|
+
const resolverRef = useRef(null);
|
|
119
|
+
|
|
120
|
+
const asyncSetState = useCallback((newValue) => {
|
|
121
|
+
setState(newValue);
|
|
122
|
+
return new Promise((resolve) => {
|
|
123
|
+
resolverRef.current = resolve;
|
|
124
|
+
});
|
|
125
|
+
}, []);
|
|
126
|
+
|
|
127
|
+
// Resolve the promise after state updates
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (resolverRef.current) {
|
|
130
|
+
resolverRef.current(state);
|
|
131
|
+
resolverRef.current = null;
|
|
132
|
+
}
|
|
133
|
+
}, [state]);
|
|
134
|
+
|
|
135
|
+
return [state, asyncSetState];
|
|
136
|
+
}
|