@@ -9,6 +9,9 @@ import MapView, { Marker, Callout } from "react-native-maps";
9
9
import { eventsSelectors } from "@/redux/slices/events.slice" ;
10
10
import { useAppSelector } from "@/redux/hooks" ;
11
11
12
+ import React , { useState } from "react" ;
13
+ import { Modal , TextInput , Button } from "react-native" ;
14
+
12
15
const NoteMarker = ( { event } ) => {
13
16
if ( Array . isArray ( event . event . tags [ 1 ] ) && event . event . tags [ 1 ] [ 1 ] ) {
14
17
const coordinates = plusCodeToCoordinates ( event . event . tags [ 1 ] [ 1 ] ) ;
@@ -31,12 +34,28 @@ const NoteMarker = ({ event }) => {
31
34
export default function Map ( ) {
32
35
const events = useAppSelector ( eventsSelectors . selectAll ) ;
33
36
37
+ const handleAddNote = ( ) => {
38
+ // Logic to add the note to the event or state
39
+ console . log ( "Note added:" , note , "at" , selectedCoordinate ) ;
40
+ setModalVisible ( false ) ;
41
+ setNote ( "" ) ;
42
+ } ;
43
+
44
+ const [ modalVisible , setModalVisible ] = useState ( false ) ;
45
+ const [ note , setNote ] = useState ( "" ) ;
46
+ const [ selectedCoordinate , setSelectedCoordinate ] = useState ( null ) ;
47
+ const handleLongPress = ( event ) => {
48
+ setSelectedCoordinate ( event . nativeEvent . coordinate ) ;
49
+ setModalVisible ( true ) ;
50
+ } ;
51
+
34
52
return (
35
53
< View style = { styles . mapContainer } >
36
54
< MapView
37
55
style = { styles . map }
38
56
rotateEnabled = { false }
39
57
pitchEnabled = { false }
58
+ onLongPress = { handleLongPress }
40
59
onRegionChangeComplete = { ( region , details ) => {
41
60
console . log ( "#rIMmxg Map move completed" , region , details ) ;
42
61
const topRightCoordinates = {
@@ -62,6 +81,32 @@ export default function Map() {
62
81
< NoteMarker event = { event } />
63
82
) ) }
64
83
</ MapView >
84
+
85
+ < Modal
86
+ visible = { modalVisible }
87
+ transparent = { true }
88
+ animationType = "slide"
89
+ onRequestClose = { ( ) => setModalVisible ( false ) }
90
+ >
91
+ < View style = { styles . modalContainer } >
92
+ < TextInput
93
+ style = { styles . input }
94
+ placeholder = "Enter your note"
95
+ value = { note }
96
+ onChangeText = { setNote }
97
+ />
98
+ < Button
99
+ style = { styles . button }
100
+ title = "Add Note"
101
+ onPress = { handleAddNote }
102
+ />
103
+ < Button
104
+ style = { styles . button }
105
+ title = "Cancel"
106
+ onPress = { ( ) => setModalVisible ( false ) }
107
+ />
108
+ </ View >
109
+ </ Modal >
65
110
</ View >
66
111
) ;
67
112
}
@@ -74,4 +119,17 @@ const styles = StyleSheet.create({
74
119
width : "100%" ,
75
120
height : "100%" ,
76
121
} ,
122
+ modalContainer : {
123
+ flex : 1 ,
124
+ justifyContent : "center" ,
125
+ alignItems : "center" ,
126
+ backgroundColor : "rgba(0, 0, 0, 0.7)" ,
127
+ } ,
128
+ input : {
129
+ width : 200 ,
130
+ padding : 10 ,
131
+ backgroundColor : "white" ,
132
+ marginBottom : 10 ,
133
+ } ,
134
+ button : { } ,
77
135
} ) ;
0 commit comments