Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
extends: '@react-native',
};
7 changes: 5 additions & 2 deletions PROJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,12 @@ host it was made for (`admin-web`) is gone, and since B-52 the console mounts th
How the barrel runs on the web:

- **Web differences live in `.web.js` twins** inside this package (`Config`, `Localization`, `MapboxGLWrapper`,
`OptionPicker/OptionSheet`); a web bundler resolves them first.
`OptionPicker/OptionSheet`); a web bundler resolves them first. `MapboxGLWrapper/index.web.js` (0.8.0) is the
native surface on react-map-gl and loads the map (`MapboxGLWrapperMap.web.js`, with mapbox-gl and its stylesheet)
through `import()`, so the barrel does not put the map engine in a host's first page. `Geoposition/MapPicker`
has a web twin on that wrapper for the same reason: @rnmapbox/maps' web build imports mapbox-gl and its CSS.
- **Native modules a web bundle cannot load are the host's web stubs** (CustomerApp `web-stubs/`:
`react-native-config`, the map wrapper's override, `navigator.geolocation`), applied only on the web.
`react-native-config`, `navigator.geolocation`), applied only on the web.
- **`Config.web.js`**: on the web the host calls `configureComponents({ IMAGEKIT_URL, … })` once before
rendering. Native `Config.js` exports the same function (merge, no behaviour change).
- **Never import this package by its published name from inside it**, and import `../ScreenWrapper`
Expand Down
4 changes: 2 additions & 2 deletions packages/components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jmstechnologiesinc/react-native-components",
"version": "0.7.3",
"version": "0.8.0",
"description": "Biblioteca de componentes de interfaz compartida por las aplicaciones de Daxir.",
"author": "yerloveraaa <yerloveraaa@gmail.com>",
"homepage": "https://github.com/jmstechnologiesinc/react-native-components#readme",
Expand Down Expand Up @@ -53,6 +53,7 @@
"i18next": "^23.16.8",
"i18next-browser-languagedetector": "^8.2.1",
"lodash.memoize": "^4.1.2",
"mapbox-gl": "^3.5.0",
"react": "19.2.3",
"react-i18next": "^15.7.4",
"react-map-gl": "^8.1.2",
Expand Down
104 changes: 104 additions & 0 deletions packages/components/src/Geoposition/MapPicker/index.web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// The web twin of MapPicker (index.js): the same props and layout on the package's web map wrapper instead of
// @rnmapbox/maps. @rnmapbox's own web build imports mapbox-gl and its stylesheet; reached from the barrel through this
// component, it put the whole map engine in every page of the web hosts, a map or not. The wrapper loads it with
// import() the first time a map renders. index.js, the native picker, is unchanged.
import { View, Dimensions, StyleSheet } from 'react-native';
import React from 'react';
import { Appbar, IconButton, MD3LightTheme } from '@jmstechnologiesinc/react-native-paper';
import { moderateScale } from '@jmstechnologiesinc/react-native-size-matters';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import MapboxGLWrapper from '../../MapboxGLWrapper';
import AddressSelectionSheet from './AddressSelectionSheet';

const MapPicker = ({
mapRef,
cameraRef,
isLocationPermissionDenied,
isLoading,
setIsLoading,
onSaveLocation,
onRegionChangeComplete,
currentLocation,
currentMapAdress,
findUserLocation,
centerMapOnUserLocation,
onBackPress,
}) => {
const { height } = Dimensions.get('window');
const insets = useSafeAreaInsets();

return (
<>
<MapboxGLWrapper
ref={mapRef}
style={styles.map}
onRegionDidChange={onRegionChangeComplete}
onDidFinishLoadingMap={() => setIsLoading(false)}
onRegionIsChanging={() => setIsLoading(true)}
>
{currentLocation ? (
<MapboxGLWrapper.Camera
zoomLevel={15}
centerCoordinate={[currentLocation.longitude, currentLocation.latitude]}
animationDuration={1000}
ref={cameraRef}
/>
) : null}
<MapboxGLWrapper.FolowUserLocation />
</MapboxGLWrapper>

{currentLocation ? (
<View style={styles.iconLocation}>
<IconButton
icon="map-marker-outline"
size={MD3LightTheme.spacing.x12}
iconColor={MD3LightTheme.colors.primary}
/>
</View>
) : null}

{!isLocationPermissionDenied && (
<View style={[styles.centerButton, { bottom: height * 0.25 }]}>
<IconButton
icon="crosshairs-gps"
size={MD3LightTheme.spacing.x6}
mode="contained"
onPress={centerMapOnUserLocation}
/>
</View>
)}

<AddressSelectionSheet
currentMapAdress={currentMapAdress ? findUserLocation(currentMapAdress) : currentLocation}
onSaveLocation={onSaveLocation}
isLoading={isLoading}
/>

<View style={[styles.backAction, { top: moderateScale(insets.top) }]}>
<Appbar.BackAction mode="contained" onPress={onBackPress} />
</View>
</>
);
};

const styles = StyleSheet.create({
map: {
flex: 1,
},
centerButton: {
position: 'absolute',
right: MD3LightTheme.spacing.x2,
},
backAction: {
position: 'absolute',
},
iconLocation: {
position: 'absolute',
top: '50%',
left: '50%',
transform: [{ translateX: -41 }, { translateY: -56 }],
zIndex: 1,
},
});

export default MapPicker;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { StyleSheet, View } from 'react-native';

// The map's box on the web, shared by the map and by the placeholder index.web.js shows while the map's code loads,
// so the page keeps the same layout before and after. A `flex: 1` would beat the consumer's height: in CSS flex the
// 0 flex-basis wins over `height` and the map collapses to 0 (the order detail asks for 300). With an explicit
// height the box needs no flex.
const MapboxGLWrapperContainer = ({ style, children }) => {
const hasExplicitHeight = StyleSheet.flatten(style)?.height != null;

return <View style={[hasExplicitHeight ? null : styles.container, style]}>{children}</View>;
};

const styles = StyleSheet.create({
container: {
flex: 1,
},
});

export default MapboxGLWrapperContainer;
Loading
Loading