Skip to content

Commit c01abd5

Browse files
committed
feat: packages/expo-app
1 parent c4510c3 commit c01abd5

File tree

14 files changed

+4858
-3359
lines changed

14 files changed

+4858
-3359
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,8 @@ coverage
123123
/plugin/build
124124

125125
.env
126-
.yarn
126+
.yarn
127+
128+
# Expo
129+
packages/expo-app/ios
130+
packages/expo-app/android

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
},
140140
"packageManager": "[email protected]",
141141
"workspaces": [
142+
"apps/*",
142143
"packages/*"
143144
]
144145
}

packages/examples/package.json

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,33 @@
1111
"!**/__tests__"
1212
],
1313
"peerDependencies": {
14-
"@maplibre/maplibre-react-native": "*",
15-
"react": "*",
16-
"react-native": "*"
14+
"@maplibre-react-native/examples": "*",
15+
"@maplibre/maplibre-react-native": "*"
16+
},
17+
"dependencies": {
18+
"@mapbox/geo-viewport": "^0.5.0",
19+
"@react-native-masked-view/masked-view": "^0.3.1",
20+
"@react-navigation/native": "^6.1.8",
21+
"@react-navigation/stack": "^6.3.25",
22+
"@turf/along": "^6.5.0",
23+
"@turf/bbox-polygon": "^6.5.0",
24+
"@turf/distance": "^6.5.0",
25+
"@turf/helpers": "^6.5.0",
26+
"@turf/length": "^6.5.0",
27+
"@turf/nearest-point-on-line": "6.5.0",
28+
"@types/geojson": "7946.0.14",
29+
"debounce": "^2.0.0",
30+
"fbjs": "^3.0.5",
31+
"moment": "^2.30.1",
32+
"prop-types": "^15.7.2",
33+
"react": "18.2.0",
34+
"react-native": "0.74.5",
35+
"react-native-elements": "^3.4.3",
36+
"react-native-gesture-handler": "~2.16.1",
37+
"react-native-reanimated": "~3.10.1",
38+
"react-native-safe-area-context": "4.10.5",
39+
"react-native-screens": "3.31.1",
40+
"react-native-svg": "15.2.0",
41+
"react-native-vector-icons": "10.0.0"
1742
}
1843
}

packages/expo-app/App.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from 'react';
2+
import MapLibreGL from '@maplibre/maplibre-react-native';
3+
import {StyleSheet, Text, View, LogBox, SafeAreaView} from 'react-native';
4+
import Icon from 'react-native-vector-icons/MaterialIcons';
5+
6+
import { sheet, colors } from '@maplibre-react-native/examples';
7+
import { default as Home } from '@maplibre-react-native/examples/src/scenes/Examples';
8+
import { IS_ANDROID } from '@maplibre-react-native/examples/src/utils';
9+
10+
LogBox.ignoreLogs([
11+
'Warning: isMounted(...) is deprecated',
12+
'Module RCTImageLoader',
13+
]);
14+
15+
const styles = StyleSheet.create({
16+
noPermissionsText: {
17+
fontSize: 18,
18+
fontWeight: 'bold',
19+
},
20+
});
21+
22+
MapLibreGL.setAccessToken(null);
23+
Icon.loadFont();
24+
25+
class App extends React.Component {
26+
constructor(props) {
27+
super(props);
28+
29+
this.state = {
30+
isFetchingAndroidPermission: IS_ANDROID,
31+
isAndroidPermissionGranted: false,
32+
activeExample: -1,
33+
};
34+
}
35+
36+
async componentDidMount() {
37+
if (IS_ANDROID) {
38+
const isGranted = await MapLibreGL.requestAndroidLocationPermissions();
39+
this.setState({
40+
isAndroidPermissionGranted: isGranted,
41+
isFetchingAndroidPermission: false,
42+
});
43+
}
44+
}
45+
46+
render() {
47+
if (IS_ANDROID && !this.state.isAndroidPermissionGranted) {
48+
if (this.state.isFetchingAndroidPermission) {
49+
return null;
50+
}
51+
return (
52+
<SafeAreaView
53+
style={[sheet.matchParent, {backgroundColor: colors.primary.blue}]}
54+
forceInset={{top: 'always'}}>
55+
<View style={sheet.matchParent}>
56+
<Text style={styles.noPermissionsText}>
57+
You need to accept location permissions in order to use this
58+
example applications
59+
</Text>
60+
</View>
61+
</SafeAreaView>
62+
);
63+
}
64+
65+
return <Home />;
66+
}
67+
}
68+
69+
export default App;

packages/expo-app/app.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"expo": {
3+
"name": "expo-app",
4+
"slug": "expo-app",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"icon": "./assets/icon.png",
8+
"userInterfaceStyle": "light",
9+
"splash": {
10+
"image": "./assets/splash.png",
11+
"resizeMode": "contain",
12+
"backgroundColor": "#ffffff"
13+
},
14+
"ios": {
15+
"supportsTablet": true,
16+
"bundleIdentifier": "org.maplibre.expoapp"
17+
},
18+
"android": {
19+
"adaptiveIcon": {
20+
"foregroundImage": "./assets/adaptive-icon.png",
21+
"backgroundColor": "#ffffff"
22+
},
23+
"package": "org.maplibre.react_native_expo_app"
24+
},
25+
"web": {
26+
"favicon": "./assets/favicon.png"
27+
},
28+
"plugins": [
29+
[
30+
"expo-dev-launcher",
31+
{
32+
"launchMode": "most-recent"
33+
}
34+
],
35+
"@maplibre/maplibre-react-native"
36+
]
37+
}
38+
}
17.1 KB
Loading

packages/expo-app/assets/favicon.png

1.43 KB
Loading

packages/expo-app/assets/icon.png

21.9 KB
Loading

packages/expo-app/assets/splash.png

46.2 KB
Loading

packages/expo-app/babel.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = function (api) {
2+
api.cache(false);
3+
return {
4+
presets: [
5+
[
6+
'babel-preset-expo',
7+
{
8+
jsxRuntime: 'automatic'
9+
},
10+
]
11+
]
12+
};
13+
};

packages/expo-app/metro.config.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Learn more https://docs.expo.io/guides/customizing-metro
2+
/** @type {import('expo/metro-config').MetroConfig} */
3+
4+
5+
const { getDefaultConfig } = require('expo/metro-config');
6+
const { FileStore } = require('metro-cache');
7+
const path = require('path');
8+
9+
const projectRoot = __dirname;
10+
const workspaceRoot = path.resolve(projectRoot, '../..');
11+
12+
require('@expo/env').load(workspaceRoot, { force: true });
13+
14+
const config = getDefaultConfig(__dirname);
15+
16+
function withAssets(config) {
17+
const { transformer, resolver } = config;
18+
config.transformer = {
19+
...transformer,
20+
//babelTransformerPath: require.resolve('react-native-svg-transformer'),
21+
};
22+
config.resolver = {
23+
...resolver,
24+
// assetExts: resolver.assetExts.filter((ext) => ext !== 'svg'),
25+
// sourceExts: [...resolver.sourceExts, 'mjs', 'cjs', 'svg'],
26+
};
27+
// Remove console logs
28+
config.transformer.minifierConfig.compress.drop_console = true;
29+
return config;
30+
}
31+
32+
/**
33+
* Add the monorepo paths to the Metro config.
34+
* This allows Metro to resolve modules from the monorepo.
35+
*
36+
* @see https://docs.expo.dev/guides/monorepos/#modify-the-metro-config
37+
* @param {import('expo/metro-config').MetroConfig} config
38+
* @returns {import('expo/metro-config').MetroConfig}
39+
*/
40+
function withMonorepoPaths(config) {
41+
// #1 - Watch all files in the monorepo
42+
config.watchFolders = [workspaceRoot];
43+
config.resolver.nodeModulesPaths = [
44+
path.resolve(projectRoot, 'node_modules'),
45+
path.resolve(workspaceRoot, 'node_modules'),
46+
];
47+
48+
// #3 - Force resolving nested modules to the folders below
49+
config.resolver.disableHierarchicalLookup = true;
50+
51+
return config;
52+
}
53+
54+
/**
55+
* Move the Metro cache to the `node_modules/.cache/metro` folder.
56+
* This repository configured Turborepo to use this cache location as well.
57+
* If you have any environment variables, you can configure Turborepo to invalidate it when needed.
58+
*
59+
* @see https://turbo.build/repo/docs/reference/configuration#env
60+
* @param {import('expo/metro-config').MetroConfig} config
61+
* @returns {import('expo/metro-config').MetroConfig}
62+
*/
63+
function withTurborepoManagedCache(config) {
64+
config.cacheStores = [new FileStore({ root: path.join(__dirname, 'node_modules/.cache/metro') })];
65+
return config;
66+
}
67+
68+
module.exports = withMonorepoPaths(
69+
withAssets(config)
70+
);

packages/expo-app/package.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "expo-app",
3+
"version": "1.0.0",
4+
"main": "expo/AppEntry.js",
5+
"scripts": {
6+
"build": "expo prebuild",
7+
"start": "expo start",
8+
"android": "expo run:android",
9+
"ios": "expo run:ios",
10+
"web": "expo start --web"
11+
},
12+
"dependencies": {
13+
"@mapbox/geo-viewport": "*",
14+
"@maplibre-react-native/examples": "*",
15+
"@maplibre/maplibre-react-native": "10.0.0-alpha.13",
16+
"@react-native-masked-view/masked-view": "*",
17+
"@react-navigation/native": "*",
18+
"@react-navigation/stack": "*",
19+
"@turf/along": "*",
20+
"@turf/bbox-polygon": "*",
21+
"@turf/distance": "*",
22+
"@turf/helpers": "*",
23+
"@turf/length": "*",
24+
"@turf/nearest-point-on-line": "*",
25+
"@types/geojson": "*",
26+
"debounce": "*",
27+
"expo": "~51.0.28",
28+
"expo-dev-client": "^4.0.26",
29+
"expo-status-bar": "~1.12.1",
30+
"fbjs": "*",
31+
"moment": "*",
32+
"prop-types": "*",
33+
"react": "*",
34+
"react-native": "*",
35+
"react-native-elements": "*",
36+
"react-native-gesture-handler": "*",
37+
"react-native-safe-area-context": "*",
38+
"react-native-screens": "*",
39+
"react-native-svg": "*",
40+
"react-native-vector-icons": "*"
41+
},
42+
"devDependencies": {
43+
"@babel/core": "^7.20.0"
44+
},
45+
"private": true
46+
}

packages/expo-app/tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "expo/tsconfig.base",
3+
"compilerOptions": {
4+
"strict": true,
5+
"jsx": "preserve",
6+
"paths": {
7+
"@/*": [
8+
"./src/*"
9+
],
10+
"@maplibre/maplibre-react-native": ["../../javascript"],
11+
}
12+
},
13+
"include": [
14+
"**/*.ts",
15+
"**/*.tsx"
16+
]
17+
}

0 commit comments

Comments
 (0)