fix(dae): alert navigation view

This commit is contained in:
devthejo 2026-03-08 18:09:41 +01:00
parent 9914bd5276
commit 93ba79bfa7
No known key found for this signature in database
GPG key ID: 00CCA7A92B1D5351
5 changed files with 43 additions and 17 deletions

View file

@ -17,9 +17,11 @@ const iconStyle = {
iconSize: 0.5, iconSize: 0.5,
}; };
const defibIconStyle = { const defibCircleStyle = {
...iconStyle, circleRadius: 8,
iconAllowOverlap: true, circleColor: ["get", "defibColor"],
circleStrokeColor: "#FFFFFF",
circleStrokeWidth: 2,
}; };
const useStyles = createStyles(({ theme: { colors } }) => ({ const useStyles = createStyles(({ theme: { colors } }) => ({
@ -64,12 +66,12 @@ export default function ShapePoints({ shape, children, ...shapeSourceProps }) {
/> />
{/* Defibrillators (DAE) separate layer (non-clustered) */} {/* Defibrillators (DAE) separate layer (non-clustered) */}
<Maplibre.SymbolLayer <Maplibre.CircleLayer
filter={["==", ["get", "isDefib"], true]} filter={["==", ["get", "isDefib"], true]}
key="points-defib" key="points-defib"
id="points-defib" id="points-defib"
aboveLayerID="points-origin" aboveLayerID="points-origin"
style={defibIconStyle} style={defibCircleStyle}
/> />
{children} {children}

View file

@ -20,8 +20,6 @@ export default function ControlButtons({
setZoomLevel, setZoomLevel,
detached, detached,
}) { }) {
// const styles = useStyles();
return ( return (
<> <>
<View <View

View file

@ -119,8 +119,10 @@ export default function useFeatures({
defib.horaires_std, defib.horaires_std,
defib.disponible_24h, defib.disponible_24h,
); );
const icon = // Only show available defibs on the alert navigation map
status === "open" ? "green" : status === "closed" ? "red" : "grey"; if (status !== "open") {
return;
}
const id = `defib:${defib.id}`; const id = `defib:${defib.id}`;
features.push({ features.push({
@ -128,7 +130,7 @@ export default function useFeatures({
id, id,
properties: { properties: {
id, id,
icon, defibColor: "#4CAF50",
defib, defib,
isDefib: true, isDefib: true,
}, },

View file

@ -13,6 +13,7 @@ import {
useSessionState, useSessionState,
alertActions, alertActions,
useAggregatedMessagesState, useAggregatedMessagesState,
useDefibsState,
defibsActions, defibsActions,
} from "~/stores"; } from "~/stores";
import { getCurrentLocation } from "~/location"; import { getCurrentLocation } from "~/location";
@ -84,9 +85,17 @@ export default withConnectivity(
const navigation = useNavigation(); const navigation = useNavigation();
const toast = useToast(); const toast = useToast();
const { showDefibsOnAlertMap: defibsEnabled } = useDefibsState([
"showDefibsOnAlertMap",
]);
const [loadingDaeCorridor, setLoadingDaeCorridor] = useState(false); const [loadingDaeCorridor, setLoadingDaeCorridor] = useState(false);
const showDefibsOnAlertMap = useCallback(async () => { const toggleDefibsOnAlertMap = useCallback(async () => {
if (defibsEnabled) {
defibsActions.setShowDefibsOnAlertMap(false);
return;
}
if (loadingDaeCorridor) { if (loadingDaeCorridor) {
return; return;
} }
@ -174,7 +183,7 @@ export default withConnectivity(
} finally { } finally {
setLoadingDaeCorridor(false); setLoadingDaeCorridor(false);
} }
}, [alert, loadingDaeCorridor, navigation, toast]); }, [alert, defibsEnabled, loadingDaeCorridor, navigation, toast]);
const [notifyAroundMutation] = useMutation(NOTIFY_AROUND_MUTATION); const [notifyAroundMutation] = useMutation(NOTIFY_AROUND_MUTATION);
const notifyAround = useCallback(async () => { const notifyAround = useCallback(async () => {
@ -501,21 +510,33 @@ export default withConnectivity(
> >
<Button <Button
mode="contained" mode="contained"
loading={loadingDaeCorridor}
disabled={loadingDaeCorridor} disabled={loadingDaeCorridor}
icon={() => ( icon={() => (
<MaterialCommunityIcons <MaterialCommunityIcons
name="heart-pulse" name={
loadingDaeCorridor
? "loading"
: defibsEnabled
? "heart-off"
: "heart-pulse"
}
style={[styles.actionIcon, styles.actionShowDefibsIcon]} style={[styles.actionIcon, styles.actionShowDefibsIcon]}
/> />
)} )}
style={[styles.actionButton, styles.actionShowDefibsButton]} style={[
onPress={showDefibsOnAlertMap} styles.actionButton,
defibsEnabled
? styles.actionShowDefibsButtonActive
: styles.actionShowDefibsButton,
]}
onPress={toggleDefibsOnAlertMap}
> >
<Text <Text
style={[styles.actionText, styles.actionShowDefibsText]} style={[styles.actionText, styles.actionShowDefibsText]}
> >
Afficher les défibrillateurs {defibsEnabled
? "Ne plus afficher les défibrillateurs"
: "Afficher les défibrillateurs"}
</Text> </Text>
</Button> </Button>
</View> </View>

View file

@ -73,6 +73,9 @@ export default createStyles(({ wp, hp, scaleText, theme: { colors } }) => ({
actionShowDefibsButton: { actionShowDefibsButton: {
backgroundColor: colors.blue, backgroundColor: colors.blue,
}, },
actionShowDefibsButtonActive: {
backgroundColor: colors.grey,
},
actionShowDefibsText: {}, actionShowDefibsText: {},
actionShowDefibsIcon: {}, actionShowDefibsIcon: {},
actionSmsButton: {}, actionSmsButton: {},