Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
chmac committed Nov 21, 2024
2 parents 743dcb9 + 0c6db22 commit 4933d60
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Possible groups and communities:
- foodsharing.de, [circle](https://www.trustroots.org/circles/foodsharing)
- [acroyoga circle](https://www.trustroots.org/circles/acroyoga)
- [lindyhop circle](https://www.trustroots.org/circles/lindyhoppers)
- [1NITE TENT](https://1nitetent.com/)


### Timeline
Expand Down
32 changes: 31 additions & 1 deletion nr-app/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
coordinatesToPlusCode,
plusCodeToCoordinates,
} from "@/utils/map.utils";
import { StyleSheet, Text, View } from "react-native";
import { StyleSheet, Text, View, Switch } from "react-native";

import { useAppDispatch, useAppSelector } from "@/redux/hooks";
import {
Expand All @@ -17,6 +17,18 @@ import React, { useState } from "react";
import { Button, Modal, TextInput } from "react-native";
import { getFirstTagValueFromEvent } from "@/common/utils";

// todo: make it more typescriptsy
function extractLocationCode(data: any) {
for (const entry of data) {
if (Array.isArray(entry) && entry.length >= 3) {
if (entry[0] === "l" && entry[2] === "open-location-code") {
return entry[1];
}
}
}
return null;
}

const NoteMarker = ({ event }: { event: EventWithMetadata }) => {
const plusCode = getFirstTagValueFromEvent(event.event, "open-location-code");

Expand Down Expand Up @@ -66,6 +78,7 @@ export default function Map() {
const [modalVisible, setModalVisible] = useState(false);
const [note, setNote] = useState("");
const [selectedCoordinate, setSelectedCoordinate] = useState<LatLng>();
const [isHitchmapEnabled, setIsHitchmapEnabled] = useState(true);

return (
<View style={styles.mapContainer}>
Expand All @@ -89,6 +102,13 @@ export default function Map() {
<NoteMarker event={event} key={event.event.sig} />
))}
</MapView>
<View style={styles.toggleContainer}>
<Text>Hitchmap</Text>
<Switch
value={isHitchmapEnabled}
onValueChange={setIsHitchmapEnabled}
/>
</View>

<Modal
visible={modalVisible}
Expand Down Expand Up @@ -120,6 +140,16 @@ const styles = StyleSheet.create({
mapContainer: {
flex: 1,
},
toggleContainer: {
position: "absolute",
top: 10,
left: 10,
flexDirection: "row",
alignItems: "center",
padding: 10,
backgroundColor: "rgba(0, 0, 0, 0.3)",
zIndex: 1, // Ensure toggle is above the map
},
map: {
width: "100%",
height: "100%",
Expand Down

0 comments on commit 4933d60

Please sign in to comment.