Compare commits

...

3 Commits

6 changed files with 281 additions and 15 deletions

View File

@ -16,7 +16,23 @@
"foregroundImage": "./assets/images/adaptive-icon.png", "foregroundImage": "./assets/images/adaptive-icon.png",
"backgroundColor": "#ffffff" "backgroundColor": "#ffffff"
}, },
"package": "eu.luemy.traintrapemoi" "package": "eu.luemy.traintrapemoi",
"permissions": [
"android.permission.ACCESS_COARSE_LOCATION",
"android.permission.ACCESS_FINE_LOCATION",
"android.permission.ACCESS_BACKGROUND_LOCATION",
"android.permission.FOREGROUND_SERVICE",
"android.permission.FOREGROUND_SERVICE_LOCATION",
"android.permission.RECEIVE_BOOT_COMPLETED",
"android.permission.WAKE_LOCK",
"android.permission.ACCESS_COARSE_LOCATION",
"android.permission.ACCESS_FINE_LOCATION",
"android.permission.ACCESS_BACKGROUND_LOCATION",
"android.permission.FOREGROUND_SERVICE",
"android.permission.FOREGROUND_SERVICE_LOCATION",
"android.permission.RECEIVE_BOOT_COMPLETED",
"android.permission.WAKE_LOCK"
]
}, },
"web": { "web": {
"bundler": "metro", "bundler": "metro",
@ -24,7 +40,18 @@
"favicon": "./assets/images/favicon.png" "favicon": "./assets/images/favicon.png"
}, },
"plugins": [ "plugins": [
"expo-background-fetch",
[
"expo-location",
{
"isAndroidBackgroundLocationEnabled": true,
"isIosBackgroundLocationEnabled": true,
"locationAlwaysAndWhenInUsePermission": "Allow $(PRODUCT_NAME) to use your location."
}
],
"expo-notifications",
"expo-router", "expo-router",
"expo-secure-store",
[ [
"expo-splash-screen", "expo-splash-screen",
{ {
@ -34,17 +61,9 @@
"backgroundColor": "#ffffff" "backgroundColor": "#ffffff"
} }
], ],
"@maplibre/maplibre-react-native",
[
"expo-location",
{
"isAndroidBackgroundLocationEnabled": true,
"isIosBackgroundLocationEnabled": true,
"locationAlwaysAndWhenInUsePermission": "Allow $(PRODUCT_NAME) to use your location."
}
],
"expo-task-manager", "expo-task-manager",
"expo-secure-store" "expo-updates",
"@maplibre/maplibre-react-native"
], ],
"experiments": { "experiments": {
"typedRoutes": true "typedRoutes": true
@ -56,6 +75,12 @@
"eas": { "eas": {
"projectId": "1898a5de-1db1-41f7-b883-1b02885f750a" "projectId": "1898a5de-1db1-41f7-b883-1b02885f750a"
} }
},
"runtimeVersion": {
"policy": "appVersion"
},
"updates": {
"url": "https://u.expo.dev/1898a5de-1db1-41f7-b883-1b02885f750a"
} }
} }
} }

View File

@ -6,13 +6,14 @@ import { Provider as StoreProvider } from 'react-redux'
import { MD3DarkTheme, MD3LightTheme, PaperProvider } from 'react-native-paper' import { MD3DarkTheme, MD3LightTheme, PaperProvider } from 'react-native-paper'
import store from '@/utils/store' import store from '@/utils/store'
import * as SecureStore from '@/utils/SecureStore' import * as SecureStore from '@/utils/SecureStore'
import { useStartBackgroundFetchServiceEffect } from '@/utils/background'
import { useStartGeolocationServiceEffect } from '@/utils/geolocation' import { useStartGeolocationServiceEffect } from '@/utils/geolocation'
import { useEffect } from 'react' import { useEffect } from 'react'
import { useRouteInfo } from 'expo-router/build/hooks' import { useRouteInfo } from 'expo-router/build/hooks'
import TabsHeader from '@/components/ui/TabsHeader'
export default function RootLayout() { export default function RootLayout() {
useStartGeolocationServiceEffect() useStartGeolocationServiceEffect()
useStartBackgroundFetchServiceEffect()
const colorScheme = useColorScheme() const colorScheme = useColorScheme()
const router = useRouter() const router = useRouter()
const route = useRouteInfo() const route = useRouteInfo()

View File

@ -6,13 +6,16 @@
"build": { "build": {
"development": { "development": {
"developmentClient": true, "developmentClient": true,
"distribution": "internal" "distribution": "internal",
"channel": "development"
}, },
"preview": { "preview": {
"distribution": "internal" "distribution": "internal",
"channel": "preview"
}, },
"production": { "production": {
"autoIncrement": true "autoIncrement": true,
"channel": "production"
} }
}, },
"submit": { "submit": {

192
client/package-lock.json generated
View File

@ -16,6 +16,7 @@
"@reduxjs/toolkit": "^2.4.0", "@reduxjs/toolkit": "^2.4.0",
"@turf/circle": "^7.1.0", "@turf/circle": "^7.1.0",
"expo": "~52.0.11", "expo": "~52.0.11",
"expo-background-fetch": "~13.0.3",
"expo-blur": "~14.0.1", "expo-blur": "~14.0.1",
"expo-constants": "~17.0.3", "expo-constants": "~17.0.3",
"expo-dev-client": "~5.0.4", "expo-dev-client": "~5.0.4",
@ -23,6 +24,7 @@
"expo-haptics": "~14.0.0", "expo-haptics": "~14.0.0",
"expo-linking": "~7.0.3", "expo-linking": "~7.0.3",
"expo-location": "^18.0.2", "expo-location": "^18.0.2",
"expo-notifications": "~0.29.11",
"expo-router": "~4.0.9", "expo-router": "~4.0.9",
"expo-secure-store": "~14.0.0", "expo-secure-store": "~14.0.0",
"expo-splash-screen": "~0.29.13", "expo-splash-screen": "~0.29.13",
@ -30,6 +32,7 @@
"expo-symbols": "~0.2.0", "expo-symbols": "~0.2.0",
"expo-system-ui": "~4.0.4", "expo-system-ui": "~4.0.4",
"expo-task-manager": "^12.0.3", "expo-task-manager": "^12.0.3",
"expo-updates": "~0.26.10",
"expo-web-browser": "~14.0.1", "expo-web-browser": "~14.0.1",
"maplibre-gl": "^4.7.1", "maplibre-gl": "^4.7.1",
"maplibre-react-components": "^0.1.9", "maplibre-react-components": "^0.1.9",
@ -2977,6 +2980,12 @@
"js-yaml": "bin/js-yaml.js" "js-yaml": "bin/js-yaml.js"
} }
}, },
"node_modules/@ide/backoff": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@ide/backoff/-/backoff-1.0.0.tgz",
"integrity": "sha512-F0YfUDjvT+Mtt/R4xdl2X0EYCHMMiJqNLdxHD++jDT5ydEFIyqbCHh51Qx2E211dgZprPKhV7sHmnXKpLuvc5g==",
"license": "MIT"
},
"node_modules/@isaacs/cliui": { "node_modules/@isaacs/cliui": {
"version": "8.0.2", "version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
@ -5449,6 +5458,19 @@
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/assert": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/assert/-/assert-2.1.0.tgz",
"integrity": "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==",
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.2",
"is-nan": "^1.3.2",
"object-is": "^1.1.5",
"object.assign": "^4.1.4",
"util": "^0.12.5"
}
},
"node_modules/assign-symbols": { "node_modules/assign-symbols": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
@ -5800,6 +5822,12 @@
"@babel/core": "^7.0.0" "@babel/core": "^7.0.0"
} }
}, },
"node_modules/badgin": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/badgin/-/badgin-1.2.3.tgz",
"integrity": "sha512-NQGA7LcfCpSzIbGRbkgjgdWkjy7HI+Th5VLxTJfW5EeaAf3fnS+xWQaQOCYiny+q6QSvxqoSO04vCx+4u++EJw==",
"license": "MIT"
},
"node_modules/balanced-match": { "node_modules/balanced-match": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -6915,6 +6943,23 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/define-properties": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz",
"integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==",
"license": "MIT",
"dependencies": {
"define-data-property": "^1.0.1",
"has-property-descriptors": "^1.0.0",
"object-keys": "^1.1.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/del": { "node_modules/del": {
"version": "6.1.1", "version": "6.1.1",
"resolved": "https://registry.npmjs.org/del/-/del-6.1.1.tgz", "resolved": "https://registry.npmjs.org/del/-/del-6.1.1.tgz",
@ -7548,6 +7593,15 @@
} }
} }
}, },
"node_modules/expo-application": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/expo-application/-/expo-application-6.0.1.tgz",
"integrity": "sha512-w+1quSmKp8SYKT+GAFHSN5c6u+PqoVRIfpsLyRQrQdOnBA9dA8Hw6JT9sHNFmA30A2v1b/sdYZE3qKuRJFNSWQ==",
"license": "MIT",
"peerDependencies": {
"expo": "*"
}
},
"node_modules/expo-asset": { "node_modules/expo-asset": {
"version": "11.0.1", "version": "11.0.1",
"resolved": "https://registry.npmjs.org/expo-asset/-/expo-asset-11.0.1.tgz", "resolved": "https://registry.npmjs.org/expo-asset/-/expo-asset-11.0.1.tgz",
@ -7565,6 +7619,18 @@
"react-native": "*" "react-native": "*"
} }
}, },
"node_modules/expo-background-fetch": {
"version": "13.0.3",
"resolved": "https://registry.npmjs.org/expo-background-fetch/-/expo-background-fetch-13.0.3.tgz",
"integrity": "sha512-wayjvMima858mvEqsXo6camcoeBLusVJnvMPdG0GKi2d9hKuQXCNP90sShDpgXOEIVzjN0UzZ8PqULgQWbqdAg==",
"license": "MIT",
"dependencies": {
"expo-task-manager": "~12.0.0"
},
"peerDependencies": {
"expo": "*"
}
},
"node_modules/expo-blur": { "node_modules/expo-blur": {
"version": "14.0.1", "version": "14.0.1",
"resolved": "https://registry.npmjs.org/expo-blur/-/expo-blur-14.0.1.tgz", "resolved": "https://registry.npmjs.org/expo-blur/-/expo-blur-14.0.1.tgz",
@ -7658,6 +7724,12 @@
"expo": "*" "expo": "*"
} }
}, },
"node_modules/expo-eas-client": {
"version": "0.13.1",
"resolved": "https://registry.npmjs.org/expo-eas-client/-/expo-eas-client-0.13.1.tgz",
"integrity": "sha512-IyeDiM6YSJG0c45kbuEo0qt76z0KTEZtisEFEtle+b+vfn9I3N+r3jbPscaI4yS3P6gpuoDyHv81YDVC6Dmkhw==",
"license": "MIT"
},
"node_modules/expo-file-system": { "node_modules/expo-file-system": {
"version": "18.0.4", "version": "18.0.4",
"resolved": "https://registry.npmjs.org/expo-file-system/-/expo-file-system-18.0.4.tgz", "resolved": "https://registry.npmjs.org/expo-file-system/-/expo-file-system-18.0.4.tgz",
@ -7809,6 +7881,26 @@
"invariant": "^2.2.4" "invariant": "^2.2.4"
} }
}, },
"node_modules/expo-notifications": {
"version": "0.29.11",
"resolved": "https://registry.npmjs.org/expo-notifications/-/expo-notifications-0.29.11.tgz",
"integrity": "sha512-u/Csc3YNOPjjuyjAeyj5ne7XR/Z0ABYVquhSnyjEj2Fp8mSldOPCMvaEA01pTFj+8HTlkjX5RZDvQ7cR62ngOA==",
"license": "MIT",
"dependencies": {
"@expo/image-utils": "^0.6.0",
"@ide/backoff": "^1.0.0",
"abort-controller": "^3.0.0",
"assert": "^2.0.0",
"badgin": "^1.1.5",
"expo-application": "~6.0.0",
"expo-constants": "~17.0.0"
},
"peerDependencies": {
"expo": "*",
"react": "*",
"react-native": "*"
}
},
"node_modules/expo-router": { "node_modules/expo-router": {
"version": "4.0.9", "version": "4.0.9",
"resolved": "https://registry.npmjs.org/expo-router/-/expo-router-4.0.9.tgz", "resolved": "https://registry.npmjs.org/expo-router/-/expo-router-4.0.9.tgz",
@ -7893,6 +7985,12 @@
"react-native": "*" "react-native": "*"
} }
}, },
"node_modules/expo-structured-headers": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/expo-structured-headers/-/expo-structured-headers-4.0.0.tgz",
"integrity": "sha512-uPiwZjWq3AdFGgY52+I2nGPrNa6izxAglymPXHUZLekZW290GqIUOk7MBNDD4sg4JwUbSi3gdxEurpEvuq+FSg==",
"license": "MIT"
},
"node_modules/expo-symbols": { "node_modules/expo-symbols": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/expo-symbols/-/expo-symbols-0.2.0.tgz", "resolved": "https://registry.npmjs.org/expo-symbols/-/expo-symbols-0.2.0.tgz",
@ -7938,6 +8036,35 @@
"react-native": "*" "react-native": "*"
} }
}, },
"node_modules/expo-updates": {
"version": "0.26.10",
"resolved": "https://registry.npmjs.org/expo-updates/-/expo-updates-0.26.10.tgz",
"integrity": "sha512-ETGUaSZRL7x72RH6MbZWRpyU9GFzCixIPNUT0kf/hcD07ojyHlW5hcwgc5ve565THSvhgiumz3yImKLbKBv2JA==",
"license": "MIT",
"dependencies": {
"@expo/code-signing-certificates": "0.0.5",
"@expo/config": "~10.0.4",
"@expo/config-plugins": "~9.0.10",
"@expo/spawn-async": "^1.7.2",
"arg": "4.1.0",
"chalk": "^4.1.2",
"expo-eas-client": "~0.13.0",
"expo-manifests": "~0.15.0",
"expo-structured-headers": "~4.0.0",
"expo-updates-interface": "~1.0.0",
"fast-glob": "^3.3.2",
"fbemitter": "^3.0.0",
"ignore": "^5.3.1",
"resolve-from": "^5.0.0"
},
"bin": {
"expo-updates": "bin/cli.js"
},
"peerDependencies": {
"expo": "*",
"react": "*"
}
},
"node_modules/expo-updates-interface": { "node_modules/expo-updates-interface": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/expo-updates-interface/-/expo-updates-interface-1.0.0.tgz", "resolved": "https://registry.npmjs.org/expo-updates-interface/-/expo-updates-interface-1.0.0.tgz",
@ -7947,6 +8074,12 @@
"expo": "*" "expo": "*"
} }
}, },
"node_modules/expo-updates/node_modules/arg": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.0.tgz",
"integrity": "sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg==",
"license": "MIT"
},
"node_modules/expo-web-browser": { "node_modules/expo-web-browser": {
"version": "14.0.1", "version": "14.0.1",
"resolved": "https://registry.npmjs.org/expo-web-browser/-/expo-web-browser-14.0.1.tgz", "resolved": "https://registry.npmjs.org/expo-web-browser/-/expo-web-browser-14.0.1.tgz",
@ -9202,6 +9335,22 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/is-nan": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz",
"integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==",
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.0",
"define-properties": "^1.1.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-number": { "node_modules/is-number": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
@ -12057,6 +12206,49 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/object-is": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz",
"integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==",
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.7",
"define-properties": "^1.2.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/object.assign": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz",
"integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==",
"license": "MIT",
"dependencies": {
"call-bind": "^1.0.5",
"define-properties": "^1.2.1",
"has-symbols": "^1.0.3",
"object-keys": "^1.1.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": { "node_modules/on-finished": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",

View File

@ -22,6 +22,7 @@
"@reduxjs/toolkit": "^2.4.0", "@reduxjs/toolkit": "^2.4.0",
"@turf/circle": "^7.1.0", "@turf/circle": "^7.1.0",
"expo": "~52.0.11", "expo": "~52.0.11",
"expo-background-fetch": "~13.0.3",
"expo-blur": "~14.0.1", "expo-blur": "~14.0.1",
"expo-constants": "~17.0.3", "expo-constants": "~17.0.3",
"expo-dev-client": "~5.0.4", "expo-dev-client": "~5.0.4",
@ -29,6 +30,8 @@
"expo-haptics": "~14.0.0", "expo-haptics": "~14.0.0",
"expo-linking": "~7.0.3", "expo-linking": "~7.0.3",
"expo-location": "^18.0.2", "expo-location": "^18.0.2",
"expo-notifications": "~0.29.11",
"expo-updates": "~0.26.10",
"expo-router": "~4.0.9", "expo-router": "~4.0.9",
"expo-secure-store": "~14.0.0", "expo-secure-store": "~14.0.0",
"expo-splash-screen": "~0.29.13", "expo-splash-screen": "~0.29.13",

View File

@ -0,0 +1,42 @@
import * as BackgroundFetch from 'expo-background-fetch'
import * as TaskManager from 'expo-task-manager'
import { Platform } from 'react-native'
import { useEffect } from 'react'
const BACKGROUND_FETCH_TASK = "background-fetch"
const BACKGROUND_FETCH_INTERVAL = 20
async function backgroundUpdate() {
async () => {
const now = Date.now()
console.log(`Got background fetch call at date: ${new Date(now).toISOString()}`)
// Be sure to return the successful result type!
return BackgroundFetch.BackgroundFetchResult.NewData
}
}
TaskManager.defineTask(BACKGROUND_FETCH_TASK, backgroundUpdate)
export async function startBackgroundFetchService(): Promise<void | (() => void)> {
if (Platform.OS === "web") {
const interval = setInterval(backgroundUpdate, BACKGROUND_FETCH_INTERVAL)
return () => clearInterval(interval)
}
if (await TaskManager.isTaskRegisteredAsync(BACKGROUND_FETCH_TASK))
return async () => await BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK)
await BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, {
minimumInterval: BACKGROUND_FETCH_INTERVAL,
stopOnTerminate: false,
startOnBoot: true,
})
return async () => await BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK)
}
export const useStartBackgroundFetchServiceEffect = () => useEffect(() => {
let cleanup: void | (() => void) = () => {}
startBackgroundFetchService().then(result => cleanup = result)
return cleanup
}, [])