浏览代码

start rewriting how grouped landmarks are created

Aidan Gironella 1 年之前
父节点
当前提交
c64cfe8a96

+ 1 - 1
android/app/src/main/AndroidManifest.xml

@@ -12,7 +12,7 @@
   <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
     <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyBySHHaoLya5257pTmLzMUkkOqPl7nGE1w"/>
     <meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
-    <meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="exposdk:43.0.0"/>
+    <meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="1.0.1"/>
     <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
     <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
     <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://u.expo.dev/082de7a5-d9b8-4c96-bd1b-5706cca20324"/>

+ 3 - 0
eas.json

@@ -18,6 +18,9 @@
     "production": {
       "android": {
         "image": "latest"
+      },
+      "ios": {
+        "image": "latest"
       }
     }
   },

+ 11 - 2
src/components/Map/Panels/AddLandmarkPanel.tsx

@@ -57,6 +57,7 @@ export interface AddLandmarkProps {
     setVisible: (state: boolean) => void;
     visible: boolean;
     setLandmark: (landmark: string) => void; 
+    landmarks: Landmark[]
 }
 
 /**
@@ -64,7 +65,7 @@ export interface AddLandmarkProps {
  * @component
  * @category Map
  */
-const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandmark, setVisible, visible, setLandmark }) => {
+const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandmark, setVisible, visible, landmarks }) => {
     const [photos, setPhotos] = useState<LMPhoto[]>([])
     const [photoSourceMenuOpened, togglePhotoSourceMenu] = useState<boolean>(false)
     const [keyboardOpened, setKeyboardOpened] = useState<boolean>(false);
@@ -185,7 +186,15 @@ const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandm
             }
         }
         else {
-            await addLandmarkMutation.mutateAsync({ landmarkValue: newLandmark, photos: photos })
+            if (newLandmark?.groupCount == -1 && newLandmark?.parent == undefined) {
+                let newGroup: Landmark = {"description": "Group of landmarks", "floor": newLandmark?.floor, "groupCount": 2, "landmark_type": 30, "latitude": newLandmark?.latitude, "longitude": newLandmark?.latitude, "title": "group (combine landmarks)", "voice": false}
+                let response = JSON.parse(await addLandmarkMutation.mutateAsync({ landmarkValue: newGroup }))
+                console.error(response)
+                let newGroupLm = landmarks?.filter(lm => lm && lm.landmark_type == 30 && lm.longitude == newGroup?.longitude && lm.latitude == newGroup.latitude && lm.user == response?.landmark?.user)
+                console.log(newGroupLm)
+            }
+            else
+                await addLandmarkMutation.mutateAsync({ landmarkValue: newLandmark, photos: photos })
             if (newLandmark?.landmark_type == 30) {
                 if (profile?.show_group_lm_tip) {
                     console.log('[Profile]: User has group tips configured, showing tips.')

+ 25 - 19
src/components/Map/Panels/LandmarkDetailsPanel/DetailsBody.tsx

@@ -191,26 +191,26 @@ export const DetailsBody: React.FC<DetailsBodyProps> = (props) => {
      */
     const EditingDisabledUpperView: React.FC = () => {
         if (!groupList) {
-        return (
-            <View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
-                <View style={{flex: 8, flexDirection: 'column', marginBottom: 20}}>
-                    {props.landmark?.groupCount == -1 ?
-                        <TouchableOpacity style={styles.groupReturnButton} onPress={() => {props.setLandmark(props.landmark?.parent); toggleGroupList(true)}}>
-                            <FontAwesome size={15} color="white" name="chevron-left"/>
-                            <Text style={{color: "white", marginLeft: 5}}>Return to group</Text>
-                        </TouchableOpacity>
-                        : null}
-                    <Text style={{color: 'white', marginBottom: 10, fontSize: 15}}>{lmTypes[props.landmark?.landmark_type]?.label.toUpperCase()}</Text>
-                    <ScrollView nestedScrollEnabled={true}>
-                        <Text style={{color: 'white', fontSize: 13}}>{props.landmark?.description}</Text>
-                        {props.landmark?.expiry_date ?
-                        <Text style={{color: 'white', fontSize: 13}}>Landmark expires on {props.landmark.expiry_date.toString().substring(0,10)}</Text> : null}
-                    </ScrollView>
+            return (
+                <View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
+                    <View style={{flex: 8, flexDirection: 'column', marginBottom: 20}}>
+                        {props.landmark?.groupCount == -1 ?
+                            <TouchableOpacity style={styles.groupReturnButton} onPress={() => {props.setLandmark(props.landmark?.parent); toggleGroupList(true)}}>
+                                <FontAwesome size={15} color="white" name="chevron-left"/>
+                                <Text style={{color: "white", marginLeft: 5}}>Return to group</Text>
+                            </TouchableOpacity>
+                            : null}
+                        <Text style={{color: 'white', marginBottom: 10, fontSize: 15}}>{lmTypes[props.landmark?.landmark_type]?.label.toUpperCase()}</Text>
+                        <ScrollView nestedScrollEnabled={true}>
+                            <Text style={{color: 'white', fontSize: 13}}>{props.landmark?.description}</Text>
+                            {props.landmark?.expiry_date ?
+                            <Text style={{color: 'white', fontSize: 13}}>Landmark expires on {props.landmark.expiry_date.toString().substring(0,10)}</Text> : null}
+                        </ScrollView>
+                    </View>
+                    {props.landmark?.landmark_type ? <Image source={lmTypes[props.landmark?.landmark_type]?.image} /> : null}
                 </View>
-                {props.landmark?.landmark_type ? <Image source={lmTypes[props.landmark?.landmark_type]?.image} /> : null}
-            </View>
-        )
-                        } else return null
+            )
+        } else return null
     }
 
     /**
@@ -349,6 +349,12 @@ export const DetailsBody: React.FC<DetailsBodyProps> = (props) => {
                 processingPhoto={props.processingPhoto}
                 setProcessingPhoto={props.setProcessingPhoto}/>
              : null}
+             {landmarkOwnedByUser(props.landmark) && !groupList ? 
+             <TouchableOpacity style={{marginTop: 30, justifyContent: 'center', alignItems: 'center', opacity: .7}}
+                 onPress={() => {props.promptAddLandmark(props.landmark?.longitude, props.landmark?.latitude, undefined, "newGroup", props.landmark?.id)}}>
+                 <Text style={{fontSize: 20, marginBottom: 10, color: 'white'}}>Add another landmark here</Text>
+                 <FontAwesome name="plus" size={30} color='white' />
+             </TouchableOpacity> : null }
             
         </ScrollView>
     )

+ 7 - 5
src/components/Map/Panels/LandmarkDetailsPanel/LandmarkDetails.tsx

@@ -230,8 +230,10 @@ const LandmarkDetails: React.FC<LandmarkDetailsProps> = ({markerWindowPosition,
                 Alert.alert(
                     'Are you sure?', 
                     "This will convert the landmark to an empty group and is irreversible.", 
-                    [{text: "Okay", onPress: async () => {await editLandmarkMutation.mutateAsync(updatedLandmark); setEditing(false);}},
-                    {text: 'Cancel', onPress: () => {return}}]
+                    [
+                        {text: 'Cancel', onPress: () => {return}},
+                        {text: "Okay", onPress: async () => {await editLandmarkMutation.mutateAsync(updatedLandmark); setEditing(false);}},
+                    ]
                 ) 
             }
             else {
@@ -355,12 +357,12 @@ const LandmarkDetails: React.FC<LandmarkDetailsProps> = ({markerWindowPosition,
         if (selectedImage > -1) 
             return Dimensions.get("window").height 
         else if (keyboardOpened || editingEnabled || (!landmarkOwnedByUser(landmarkQuery?.data?.landmark) && landmarkQuery?.data?.landmark?.photos?.length == 0)) {
-            return Dimensions.get("window").height * .9
+            return Dimensions.get("window").height * .7
         }
         else if (landmarkQuery?.data?.landmark?.photos?.length > 0) 
-            return Dimensions.get("window").height * .9 
+            return Dimensions.get("window").height * .9
         else
-            return Dimensions.get("window").height * .7
+            return Dimensions.get("window").height * .8
     }
 
     return (

+ 1 - 1
src/components/Map/Panels/LandmarkDetailsPanel/LandmarkPhotos.tsx

@@ -101,7 +101,7 @@ export const LandmarkPhotos: React.FC<LandmarkPhotosProps> = (props) => {
                 </> : 
                 <>
                 {landmarkOwnedByUser(props.landmark) ?
-                <TouchableOpacity style={{marginTop: 30, justifyContent: 'center', alignItems: 'center', opacity: .7}} onPress={() => {togglePhotoSourceMenu(true)}}>
+                <TouchableOpacity style={{borderBottomWidth: 1, borderColor: 'lightgray', paddingBottom: 20, marginTop: 30, justifyContent: 'center', alignItems: 'center', opacity: .7}} onPress={() => {togglePhotoSourceMenu(true)}}>
                     <Text style={{fontSize: 20, marginBottom: 10, color: 'white'}}>Add photo of landmark</Text>
                     <FontAwesome name="plus" size={30} color='white' />
                 </TouchableOpacity> : null}

+ 1 - 1
src/data/landmarks.ts

@@ -167,7 +167,7 @@ export const useAddLandmark = () => {
                 errorMessage: "Something went wrong when creating a landmark",
                 loggingCategory: "LANDMARKS"
             });   
-            return response?.data;
+            return response?.config?.data;
         }
         else {
             console.warn("[LandmarkData]: Can't create landmark. Given landmark value is null.")

+ 6 - 1
src/navigation/MapNavigator.tsx

@@ -136,6 +136,10 @@ const MapNavigator: React.FC = ({ }) => {
             mapState.setNewLandmark({ latitude: latitude, longitude: longitude, floor: floor, voice: false, parent: parent, groupCount: -1 });
             mapState.toggleLmAdd(true)
             mapState.toggleLmDetails(false)
+        } else if (lmCount == "newGroup") {  // Adding 2nd landmark to existing landmark, making a new group
+            mapState.setNewLandmark({ latitude: latitude, longitude: longitude, floor: floor, voice: false, parent: undefined, groupCount: -1 });
+            mapState.toggleLmAdd(true)
+            mapState.toggleLmDetails(false)
         } else if (lmCount == "group") {  // Landmark is the group itself
             mapState.setNewLandmark({ latitude: latitude, longitude: longitude, floor: floor, voice: false, landmark_type: 30 });
             mapState.toggleLmAdd(true)
@@ -295,7 +299,8 @@ const MapNavigator: React.FC = ({ }) => {
                 setVisible={mapState.toggleLmAdd}
                 newLandmark={mapState.newLandmark}
                 visible={mapState.lmAddVisible}
-                setLandmark={mapState.setSelectedLandmarkId} />
+                setLandmark={mapState.setSelectedLandmarkId}
+                landmarks={landmarksQuery?.data} />
             <LandmarkDetails
                 markerWindowPosition={markerWindowPosition}
                 authNavigation={authNavigation}

+ 2 - 2
src/utils/RequestUtils.ts

@@ -11,11 +11,11 @@
 //export const API_URL = 'http://192.168.3.81:8000'
 // export const API_URL = 'https://staging.clicknpush.ca'
 
-export const API_URL = 'https://app.clicknpush.ca'
+// export const API_URL = 'https://app.clicknpush.ca'
 // export const API_URL = 'http://192.168.1.106:8000' // Nathan
 //export const API_URL = 'http://192.168.1.64:8000'   // Chase
 //export const API_URL = 'http://192.168.0.22:8000'       // Eric
-// export const API_URL = 'http://192.168.1.131:8000'  // Aidan surface
+export const API_URL = 'http://192.168.1.131:8000'  // Aidan surface
 // export const API_URL = 'http://192.168.1.87:8000'  // Aidan home
 
 // export const API_URL = Config.API_URL