Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | /* Copyright (C) Click & Push Accessibility, Inc - All Rights Reserved * Unauthorized copying of this file, via any medium is strictly prohibited * Proprietary and confidential * Written and maintained by the Click & Push Development team * <dev@clicknpush.ca>, January 2022 */ import { useRef, useState } from "react"; import { UserLocation } from "./OutdoorMap"; import { Landmark } from "../../../hooks/useLandmarks"; import MapView from "react-native-maps"; export const useMapState = () => { /** * State that contains the new {@link Landmark} object which is passed down to the {@link AddLandmark} modal. */ const [newLandmark, setNewLandmark] = useState<Landmark>(undefined); /** * State that contains the selected {@link Landmark} object which is passed down to the {@link LandmarkDetails} modal. */ const [selectedLandmarkId, setSelectedLandmarkId] = useState<string>(''); /** * Holds the visibility state of the {@link AddLandmark} modal. */ const [lmAddVisible, toggleLmAdd] = useState<boolean>(false); /** * Holds the visibility state of the {@link LandmarkDetails} modal. */ const [lmDetailsVisible, toggleLmDetails] = useState<boolean>(false); /** * Flag that toggles whether or not editing is enabled in the {@link LandmarkDetails} modal. * The parent Map component has access to it so that it can disable closing the modal on backdrop press when it is enabled. */ const [lmDetailsEditing, toggleLmDetailsEditing] = useState<boolean>(false); /** * Holds the listening state of the {@link VoicePanel} modal. */ const [voiceActive, toggleVoiceActive] = useState<boolean>(false); /** * Flag that determines whether the filter options are shown */ const [filterVisible, toggleFilter] = useState<boolean>(false) /** * State of minumum landmark rating filter */ const [minLmRating, setMinLmRating] = useState<number>(0) /** * State of landmark types filter */ const [lmFilteredTypes, setLmTypeFilter] = useState<number[]>([]) /** * State of landmark "only show owned" filter */ const [onlyOwned, toggleOnlyOwned] = useState<boolean>(false) return { onlyOwned, toggleOnlyOwned, lmFilteredTypes, setLmTypeFilter, minLmRating, setMinLmRating, filterVisible, toggleFilter, lmDetailsVisible, toggleLmDetails, lmDetailsEditing, toggleLmDetailsEditing, selectedLandmarkId, setSelectedLandmarkId, newLandmark, setNewLandmark, lmAddVisible, toggleLmAdd, } } export const useOutdoorMapState = () => { /** * Holds the visibility state of the {@link AddLandmark} modal. */ const alertedLmVisibleState = false; const [nearbyLmPanelVisible, toggleNearbyLmPanel] = useState<boolean>(alertedLmVisibleState); /** * State that holds a {@link UserLocation} object retrieved from location services. */ const [userLocation, setUserLocation] = useState<UserLocation>(undefined); /** * Flag that determines whether the map should focus and follow the user's location. */ const [followUser, toggleFollowUser] = useState<boolean>(false); /** * State that contains the selected {@link Landmark} object which is passed down to the {@link LandmarkDetails} modal. */ const [landmarksNearUser, setLandmarksNearUser] = useState<Landmark[]>([]) /** * Flag that toggles whether or not foreground location permission has been granted. */ const [fgroundLocationPermission, toggleFgroundLocationPermission] = useState<boolean>(false); /** * Flag that toggles whether or not background location permission has been granted. */ const [bgroundLocationPermission, toggleBgroundLocationPermission] = useState<boolean>(false); /** * Flag that toggles whether or not voice recording permission has been granted. */ const [voicePermission, toggleVoicePermission] = useState<boolean>(false); /** * Holds the visibility state of the {@link VoicePanel} modal. */ const [voiceVisible, toggleVoiceVisible] = useState<boolean>(false); /** * Flag that toggles whether or not location is currently permitted (true if fground is granted is true and AppState is active, or if bground is active). */ const [locationPermitted, toggleLocationPermitted] = useState<boolean>(false); /** * Ref that holds the loaded [MapView]{@link https://github.com/react-native-maps/react-native-maps/blob/master/docs/mapview.md} instance. */ const mapRef = useRef<MapView>(); return { nearbyLmPanelVisible, toggleNearbyLmPanel, followUser, toggleFollowUser, userLocation, setUserLocation, landmarksNearUser, setLandmarksNearUser, mapRef, voicePermission, toggleVoicePermission, voiceVisible, toggleVoiceVisible, fgroundLocationPermission, toggleFgroundLocationPermission, bgroundLocationPermission, toggleBgroundLocationPermission, locationPermitted, toggleLocationPermitted, } } |