Przeglądaj źródła

changed grouped landmarks, can add to an existing landmark to create a group instead of creating an empty group

aidan 1 rok temu
rodzic
commit
adc5a7fffc

+ 0 - 3
eas.json

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

+ 20 - 0
ios/Podfile

@@ -48,6 +48,26 @@ end
   post_install do |installer|
     react_native_post_install(installer)
 
+    installer.pods_project.targets.each do |target|
+      target.build_configurations.each do |config|
+        if Gem::Version.new('8.0') > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
+          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
+        end
+      end
+    end
+    # __apply_Xcode_12_5_M1_post_install_workaround(installer)
+
+    # This is necessary for Xcode 14, because it signs resource bundles by default
+    # when building for devices.
+    installer.target_installation_results.pod_target_installation_results
+      .each do |pod_name, target_installation_result|
+      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
+        resource_bundle_target.build_configurations.each do |config|
+          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
+        end
+      end
+    end
+
     # Workaround `Cycle inside FBReactNativeSpec` error for react-native 0.64
     # Reference: https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933
     installer.pods_project.targets.each do |target|

+ 3 - 3
src/components/Map/MainMapComponent/IndoorMap.tsx

@@ -37,7 +37,7 @@ const IndoorMap: React.FC<IndoorMapProps> = ({ landmarks, promptAddLandmark, foc
     if (!lmTypesIndoor[item.landmark_type]) {
       return null
     }
-    if (item.floor == floor && SVGdim[0] != 1 && SVGdim[1] != 1) {
+    if (item.floor == floor && item.groupCount != -1 && SVGdim[0] != 1 && SVGdim[1] != 1) {
       return (
         <View style={{position: "absolute"}}>
           <Svg>
@@ -52,14 +52,14 @@ const IndoorMap: React.FC<IndoorMapProps> = ({ landmarks, promptAddLandmark, foc
               width={imageDim}
               height={imageDim}
               href={lmTypesIndoor[item.landmark_type].image as ImageSourcePropType} />
-            <Text
+            {item.landmark_type == 30 && <Text
               x={item.longitude * SVGdim[0] + imageDim * .4}
               y={item.latitude * SVGdim[1] + imageDim * .5}
               fontFamily="sans-serif-medium"
               fontWeight="bold"
               fontSize="8"
               fill="black"
-              >{item.groupCount}</Text>
+              >{item.groupCount}</Text>}
           </Svg>
         </View>
       )

+ 14 - 13
src/components/Map/Panels/AddLandmarkPanel.tsx

@@ -56,8 +56,10 @@ export interface AddLandmarkProps {
      */
     setVisible: (state: boolean) => void;
     visible: boolean;
-    setLandmark: (landmark: string) => void; 
-    landmarks: Landmark[]
+    /**
+     * The currently selected {@link Landmark} object, used only when a landmark is added to an existing individual landmark. 
+     */
+    siblingID?: string | undefined
 }
 
 /**
@@ -65,7 +67,7 @@ export interface AddLandmarkProps {
  * @component
  * @category Map
  */
-const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandmark, setVisible, visible, landmarks }) => {
+const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandmark, setVisible, visible, siblingID }) => {
     const [photos, setPhotos] = useState<LMPhoto[]>([])
     const [photoSourceMenuOpened, togglePhotoSourceMenu] = useState<boolean>(false)
     const [keyboardOpened, setKeyboardOpened] = useState<boolean>(false);
@@ -170,6 +172,13 @@ const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandm
      * Calls {@link addLandmarkAsync} from {@link useLandmarks} to initate the process of adding a landmark, then closes the modal.
      */
     const submit = async () => {
+        let newGroupBool: boolean = false
+        if (newLandmark?.groupCount == -2) {
+            newGroupBool = true;
+        } else {
+            newGroupBool = false
+        }
+
         if (typeof newLandmark.floor === 'number') {
             try {
                 const uri = await captureRef(capture, {
@@ -178,7 +187,7 @@ const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandm
                     result: 'base64'
                 })
 
-                await addLandmarkMutation.mutateAsync({ landmarkValue: newLandmark, photos: photos, indoorLmLocImg: uri }); // pass it in here
+                await addLandmarkMutation.mutateAsync({ landmarkValue: newLandmark, photos: photos, indoorLmLocImg: uri, newGroup: {bool: newGroupBool, sibling: siblingID} }); // pass it in here
 
 
             } catch (error) {
@@ -186,15 +195,7 @@ const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({ newLandmark, setNewLandm
             }
         }
         else {
-            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 })
+            await addLandmarkMutation.mutateAsync({ landmarkValue: newLandmark, photos: photos, newGroup: {bool: newGroupBool, sibling: siblingID} })
             if (newLandmark?.landmark_type == 30) {
                 if (profile?.show_group_lm_tip) {
                     console.log('[Profile]: User has group tips configured, showing tips.')

+ 9 - 7
src/components/Map/Panels/LandmarkDetailsPanel/DetailsBody.tsx

@@ -241,7 +241,7 @@ export const DetailsBody: React.FC<DetailsBodyProps> = (props) => {
                     )}
                     {landmarkOwnedByUser(props.landmark) ? 
                     <TouchableOpacity style={{marginTop: 30, justifyContent: 'center', alignItems: 'center', opacity: .7}}
-                        onPress={() => {props.promptAddLandmark(props.landmark?.longitude, props.landmark?.latitude, undefined, "groupItem", props.landmark?.id)}}>
+                        onPress={() => {props.promptAddLandmark(props.landmark?.longitude, props.landmark?.latitude, props.landmark?.floor, "groupItem", props.landmark?.id)}}>
                         <Text style={{fontSize: 20, marginBottom: 10, color: 'white'}}>Add landmark to group</Text>
                         <FontAwesome name="plus" size={30} color='white' />
                     </TouchableOpacity> : null }
@@ -349,12 +349,14 @@ 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 }
+            {landmarkOwnedByUser(props.landmark) && !groupList && !props.landmark?.parent ? 
+                <View style={{borderTopWidth: 1, borderColor: 'lightgray'}}>
+                    <TouchableOpacity style={{paddingTop: 30, justifyContent: 'center', alignItems: 'center', opacity: .7}}
+                        onPress={() => {props.promptAddLandmark(props.landmark?.longitude, props.landmark?.latitude, props.landmark?.floor, "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>
+                </View> : null }
             
         </ScrollView>
     )

+ 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={{borderBottomWidth: 1, borderColor: 'lightgray', paddingBottom: 20, marginTop: 30, justifyContent: 'center', alignItems: 'center', opacity: .7}} onPress={() => {togglePhotoSourceMenu(true)}}>
+                <TouchableOpacity style={{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}

+ 5 - 3
src/data/landmarks.ts

@@ -56,7 +56,8 @@ export interface Landmark {
     /*** A Date object representing an optional expiry date that will automatically cull the landmark */
     expiry_date?: Date | null,
     /** A number for grouped landmarks. 0 means not part of a group, -1 means it is part of a group,
-     *  and anything else means that this is the actual group of landmarks, with the number representing
+     *  -2 is a temporary indicator that a new group is being formed when a landmark is added to an existing landmark,
+     *  and anything else means that this is a group of landmarks, with the number representing
      *  the number of landmarks in the group.
      */
     groupCount?: number | null,
@@ -141,7 +142,7 @@ export const useAddLandmark = () => {
     const {sendApiRequestAsync, userId, anonUserId} = useAuth()
     const queryClient = useQueryClient();
 
-    const createLandmark = async (data: {landmarkValue: Landmark | undefined, photos?: LMPhoto[], indoorLmLocImg?: string}): Promise<Landmark | undefined> => {
+    const createLandmark = async (data: {landmarkValue: Landmark | undefined, photos?: LMPhoto[], indoorLmLocImg?: string, newGroup?: {bool: boolean, sibling: string}}): Promise<Landmark | undefined> => {
         if (data.landmarkValue) {
             if (userId) {
                 data.landmarkValue.user = userId
@@ -160,7 +161,8 @@ export const useAddLandmark = () => {
                     data: {
                         landmark: data.landmarkValue,
                         photos: data.photos,
-                        indoorLmLocImg: data.indoorLmLocImg
+                        indoorLmLocImg: data.indoorLmLocImg,
+                        newGroup: data.newGroup,
                     },
                 },
                 authorized: true,

+ 10 - 15
src/navigation/MapNavigator.tsx

@@ -61,11 +61,11 @@ const MapNavigator: React.FC = ({ }) => {
     /**
      * Clear selected landmark when landmark details panel is closed
      */
-    useEffect(() => {
-        if (!mapState.lmDetailsVisible) {
-            mapState.setSelectedLandmarkId('')
-        }
-    }, [mapState.lmDetailsVisible])
+    // useEffect(() => {
+    //     if (!mapState.lmDetailsVisible) {
+    //         mapState.setSelectedLandmarkId('')
+    //     }
+    // }, [mapState.lmDetailsVisible])
 
     useEffect(() => {
         const refetchLandmarksOnFilterOptionsChange = async () => {
@@ -132,19 +132,15 @@ const MapNavigator: React.FC = ({ }) => {
  */
     const promptAddLandmark = async (longitude?: number, latitude?: number, floor?: number, lmCount?: string, parent?: string) => {
         console.log('[Map]: Opening add landmark panel...')
-        if (lmCount == "groupItem") {  // Landmark is part of a group
+        if (lmCount == "groupItem") {  // Adding landmark to an already established group
             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 });
+        } else if (lmCount == "newGroup") {  // Adding 2nd landmark to existing landmark, thus making a new group
+            mapState.setNewLandmark({ latitude: latitude, longitude: longitude, floor: floor, voice: false, parent: parent, groupCount: -2 });
             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)
-            mapState.toggleLmDetails(false)
-        } else {  // Regular individial landmark
+        } else {  // Adding a regular individial landmark
             mapState.setNewLandmark({ latitude: latitude, longitude: longitude, floor: floor, voice: false });
             mapState.toggleLmAdd(true)
             mapState.toggleLmDetails(false)
@@ -299,8 +295,7 @@ const MapNavigator: React.FC = ({ }) => {
                 setVisible={mapState.toggleLmAdd}
                 newLandmark={mapState.newLandmark}
                 visible={mapState.lmAddVisible}
-                setLandmark={mapState.setSelectedLandmarkId}
-                landmarks={landmarksQuery?.data} />
+                siblingID={mapState.selectedLandmarkId} />
             <LandmarkDetails
                 markerWindowPosition={markerWindowPosition}
                 authNavigation={authNavigation}

+ 1 - 1
src/utils/GlobalUtils.ts

@@ -25,7 +25,7 @@ export const catTypes: {[key: number]: {cat: string}} = {
     4: {cat: "accessible"},
     5: {cat: "unpleasant"},
     6: {cat: "not in list"},
-    7: {cat: "group (combine landmarks)"}
+    // 7: {cat: "group (combine landmarks)"}
 } // works for now, but better solution would be to take categories from lmTypes and remove duplicates
 
 // Set of category types used when adding a landmark inside a group, 'group' option removed to prevent group nesting

+ 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