Skip to content

Commit

Permalink
Improved map rendering
Browse files Browse the repository at this point in the history
Allow to swipe sidebar over map
  • Loading branch information
AlixH committed Dec 7, 2021
1 parent bb4033e commit f422fdf
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,9 @@ function createAppDrawerNavigator(props: BaseProps) {
headerShown: false,
drawerType: 'front',
swipeEnabled: false,
swipeEdgeWidth: 20,
unmountOnBlur: false
swipeEdgeWidth: scale(50),
unmountOnBlur: false,

})}
backBehavior={'history'}
drawerPosition="left"
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/HeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default class HeaderComponent extends React.Component<Props, State> {
</View>
<View style={style.actionsContainer}>
{actions?.map((action, index) => (
<TouchableOpacity style={style.action} key={index} onPress={action.onPress}>
<TouchableOpacity delayPressIn={0} style={style.action} key={index} onPress={action.onPress}>
{action.renderAction?.()}
</TouchableOpacity>
))}
Expand Down
11 changes: 5 additions & 6 deletions src/components/map/ClusterMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class ClusterMap<T extends Localizable> extends React.Component<P
const style = computeStyleSheet();
return (
<View style={style.map}>
<View style={style.mapOverlay} />
{initialRegion && (
<MapView
customMapStyle={isDarkModeEnabled ? this.darkMapTheme : null}
Expand All @@ -56,7 +57,7 @@ export default class ClusterMap<T extends Localizable> extends React.Component<P
spiderLineColor={commonColors.textColor}
mapType={satelliteMap ? 'satellite' : 'standard'}
initialRegion={initialRegion}
onRegionChangeComplete={onMapRegionChangeComplete}
onRegionChangeComplete={(region) => onMapRegionChangeComplete(region)}
>
{items.map((item, index) => (
renderMarker?.(item, index)
Expand All @@ -68,11 +69,9 @@ export default class ClusterMap<T extends Localizable> extends React.Component<P
}

private computeRadius(latitudeDelta: number): number {
if(latitudeDelta <= 0.0005) {
return 5
} else if(latitudeDelta <= 0.001 ) {
return 20
if (latitudeDelta <= 0.0005) {
return 5;
}
return 30
return 30;
}
}
6 changes: 6 additions & 0 deletions src/components/map/ClusterMapStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export default function computeStyleSheet(): StyleSheet.NamedStyles<any> {
map: {
width: '100%',
height: '100%'
},
mapOverlay: {
width: '50@s',
position: 'absolute',
zIndex: 1,
height: '100%'
}
});
const portraitStyles = {};
Expand Down
12 changes: 8 additions & 4 deletions src/screens/charging-stations/list/ChargingStations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,11 @@ export default class ChargingStations extends BaseAutoRefreshScreen<Props, State
};

public onMapRegionChangeComplete = (region: Region) => {
this.currentRegion = region;
this.refresh();
if(region.latitude.toFixed(6) !== this.currentRegion.latitude.toFixed(6) ||
region.longitude.toFixed(6) !== this.currentRegion.longitude.toFixed(6)) {
this.currentRegion = region;
this.refresh();
}
}

public filterChanged(newFilters: ChargingStationsFiltersDef) {
Expand Down Expand Up @@ -410,8 +413,9 @@ export default class ChargingStations extends BaseAutoRefreshScreen<Props, State
</TouchableOpacity>
)}
<TouchableOpacity
delayPressIn={0}
style={fabStyles.fab}
onPress={() => this.setState({ showMap: ! showMap}, () => this.refresh(true)) }
onPress={() => this.setState({ showMap: !showMap}, () => this.refresh(true)) }
>
<Icon style={fabStyles.fabIcon} type={'MaterialCommunityIcons'} name={showMap ? 'format-list-bulleted' : 'map'} />
</TouchableOpacity>
Expand Down Expand Up @@ -485,7 +489,7 @@ export default class ChargingStations extends BaseAutoRefreshScreen<Props, State
</Marker>
)}
initialRegion={this.currentRegion}
onMapRegionChangeComplete={this.onMapRegionChangeComplete}
onMapRegionChangeComplete={(region) => this.onMapRegionChangeComplete(region)}
/>
</View>
)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/tenants/Tenants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class Tenants extends BaseScreen<Props, State> {
/>
) : (
<View style={style.container}>
<TouchableOpacity onPress={() => this.setState({ showAddTenantDialog: true })} style={[fabStyles.fab, fabStyles.placedFab]}>
<TouchableOpacity delayPressIn={0} onPress={() => this.setState({ showAddTenantDialog: true })} style={[fabStyles.fab, fabStyles.placedFab]}>
<Icon type={'MaterialCommunityIcons'} name={'plus'} style={fabStyles.fabIcon} />
</TouchableOpacity>
{showAddTenantManuallyDialog && (
Expand Down

0 comments on commit f422fdf

Please sign in to comment.