Browse Source

starting adding global alert for anon lms

chase 2 years ago
parent
commit
d703134e9a

+ 7 - 13
ios/Podfile.lock

@@ -281,6 +281,8 @@ PODS:
   - react-native-spokestack (6.1.4):
     - React
     - Spokestack-iOS (= 14.1.0)
+  - react-native-view-shot (3.1.2):
+    - React
   - React-perflogger (0.64.3)
   - React-RCTActionSheet (0.64.3):
     - React-Core/RCTActionSheetHeaders (= 0.64.3)
@@ -349,8 +351,6 @@ PODS:
     - React-Core
   - RNCPicker (2.3.0):
     - React-Core
-  - RNFS (2.19.0):
-    - React-Core
   - RNGestureHandler (1.10.3):
     - React-Core
   - RNPermissions (3.1.0):
@@ -387,8 +387,6 @@ PODS:
   - RNScreens (3.8.0):
     - React-Core
     - React-RCTImage
-  - RNSha256 (1.4.7):
-    - React
   - RNSVG (12.1.1):
     - React
   - Spokestack-iOS (14.1.0):
@@ -459,6 +457,7 @@ DEPENDENCIES:
   - "react-native-slider (from `../node_modules/@react-native-community/slider`)"
   - react-native-spinkit (from `../node_modules/react-native-spinkit`)
   - react-native-spokestack (from `../node_modules/react-native-spokestack`)
+  - react-native-view-shot (from `../node_modules/react-native-view-shot`)
   - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
   - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
   - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
@@ -473,12 +472,10 @@ DEPENDENCIES:
   - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
   - "RNCCheckbox (from `../node_modules/@react-native-community/checkbox`)"
   - "RNCPicker (from `../node_modules/@react-native-picker/picker`)"
-  - RNFS (from `../node_modules/react-native-fs`)
   - RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
   - RNPermissions (from `../node_modules/react-native-permissions`)
   - RNReanimated (from `../node_modules/react-native-reanimated`)
   - RNScreens (from `../node_modules/react-native-screens`)
-  - RNSha256 (from `../node_modules/react-native-sha256`)
   - RNSVG (from `../node_modules/react-native-svg`)
   - UMTaskManagerInterface (from `../node_modules/unimodules-task-manager-interface/ios`)
   - Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
@@ -594,6 +591,8 @@ EXTERNAL SOURCES:
     :path: "../node_modules/react-native-spinkit"
   react-native-spokestack:
     :path: "../node_modules/react-native-spokestack"
+  react-native-view-shot:
+    :path: "../node_modules/react-native-view-shot"
   React-perflogger:
     :path: "../node_modules/react-native/ReactCommon/reactperflogger"
   React-RCTActionSheet:
@@ -622,8 +621,6 @@ EXTERNAL SOURCES:
     :path: "../node_modules/@react-native-community/checkbox"
   RNCPicker:
     :path: "../node_modules/@react-native-picker/picker"
-  RNFS:
-    :path: "../node_modules/react-native-fs"
   RNGestureHandler:
     :path: "../node_modules/react-native-gesture-handler"
   RNPermissions:
@@ -632,8 +629,6 @@ EXTERNAL SOURCES:
     :path: "../node_modules/react-native-reanimated"
   RNScreens:
     :path: "../node_modules/react-native-screens"
-  RNSha256:
-    :path: "../node_modules/react-native-sha256"
   RNSVG:
     :path: "../node_modules/react-native-svg"
   UMTaskManagerInterface:
@@ -695,6 +690,7 @@ SPEC CHECKSUMS:
   react-native-slider: c98f8413776ec1218ec9cd4f8ed32bfd91d428fc
   react-native-spinkit: da294fd828216ad211fe36a5c14c1e09f09e62db
   react-native-spokestack: dc94170589d1b505f1d46824051888909a8eb039
+  react-native-view-shot: 4475fde003fe8a210053d1f98fb9e06c1d834e1c
   React-perflogger: cc76a4254d19640f1d8ad1c66fdee800414b805c
   React-RCTActionSheet: 7448f049318d8d7e8a9a1ebb742ada721757eea8
   React-RCTAnimation: fb9b3fa1a4a9f5e6ab01b3368693ce69860ba76a
@@ -709,12 +705,10 @@ SPEC CHECKSUMS:
   ReactCommon: 8fea6422328e2fc093e25c9fac67adbcf0f04fb4
   RNCCheckbox: 6bd119c26c6eb8264a29d59ff66cb70a14de3349
   RNCPicker: c796ddf16cd93e980a5a5642eebcee9eb9da1e76
-  RNFS: fc610f78fdf8bfc89a9e5cc2f898519f4dba1002
   RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
   RNPermissions: 4b54095940aea8c03fa3e6c92d4ac3647b31ed4e
   RNReanimated: 241c586663f44f19a53883c63375fdd041253960
   RNScreens: 6e1ea5787989f92b0671049b808aef64fa1ef98c
-  RNSha256: bf2c90a9e0cec6dcbcc4100e4e19715ae7feaa34
   RNSVG: 551acb6562324b1d52a4e0758f7ca0ec234e278f
   Spokestack-iOS: 090ed0e757276f2407beec82fa851ec3e408b5b9
   TensorFlowLiteC: 51f50caf5777f740a70e2c1a5dbdc149e7aeb50b
@@ -722,6 +716,6 @@ SPEC CHECKSUMS:
   UMTaskManagerInterface: 5654c50e68af11b19b9d05452bacf23d19b3f30f
   Yoga: e6ecf3fa25af9d4c87e94ad7d5d292eedef49749
 
-PODFILE CHECKSUM: 606a2c00ea818ac7e33d41f324d5f6f09027970a
+PODFILE CHECKSUM: 36a2eb9184cd7de694ef4e992701e848c207fffb
 
 COCOAPODS: 1.11.2

+ 2 - 4
ios/cnpmobile.xcodeproj/project.pbxproj

@@ -299,12 +299,10 @@
 				"${BUILT_PRODUCTS_DIR}/RCTTypeSafety/RCTTypeSafety.framework",
 				"${BUILT_PRODUCTS_DIR}/RNCCheckbox/RNCCheckbox.framework",
 				"${BUILT_PRODUCTS_DIR}/RNCPicker/RNCPicker.framework",
-				"${BUILT_PRODUCTS_DIR}/RNFS/RNFS.framework",
 				"${BUILT_PRODUCTS_DIR}/RNGestureHandler/RNGestureHandler.framework",
 				"${BUILT_PRODUCTS_DIR}/RNReanimated/RNReanimated.framework",
 				"${BUILT_PRODUCTS_DIR}/RNSVG/RNSVG.framework",
 				"${BUILT_PRODUCTS_DIR}/RNScreens/RNScreens.framework",
-				"${BUILT_PRODUCTS_DIR}/RNSha256/RNSha256.framework",
 				"${BUILT_PRODUCTS_DIR}/React-Core/React.framework",
 				"${BUILT_PRODUCTS_DIR}/React-CoreModules/CoreModules.framework",
 				"${BUILT_PRODUCTS_DIR}/React-RCTAnimation/RCTAnimation.framework",
@@ -329,6 +327,7 @@
 				"${BUILT_PRODUCTS_DIR}/react-native-safe-area-context/react_native_safe_area_context.framework",
 				"${BUILT_PRODUCTS_DIR}/react-native-slider/react_native_slider.framework",
 				"${BUILT_PRODUCTS_DIR}/react-native-spinkit/react_native_spinkit.framework",
+				"${BUILT_PRODUCTS_DIR}/react-native-view-shot/react_native_view_shot.framework",
 			);
 			name = "[CP] Embed Pods Frameworks";
 			outputPaths = (
@@ -338,12 +337,10 @@
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTTypeSafety.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNCCheckbox.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNCPicker.framework",
-				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNFS.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNGestureHandler.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNReanimated.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNSVG.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNScreens.framework",
-				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNSha256.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/React.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CoreModules.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTAnimation.framework",
@@ -368,6 +365,7 @@
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_safe_area_context.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_slider.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_spinkit.framework",
+				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/react_native_view_shot.framework",
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;

+ 6 - 1
src/components/Map/MainMapComponent/IndoorMap.tsx

@@ -134,7 +134,12 @@ const IndoorMap: React.FC<IndoorMapProps> = ({ navigation, landmarks, promptAddL
           <Picker
             placeholder={{}}
             value={floor}
-            style={{ inputAndroid: {color:"white"} , inputIOS: {color:"white"} }}
+            style={{ 
+              inputAndroid: {textAlign: 'center', color:"white", height: '100%', backgroundColor: 'black'} ,
+              inputIOS: {textAlign: 'center', height: '100%', width: '30%', backgroundColor: 'black', alignSelf: 'center'} ,
+              iconContainer: {backgroundColor: 'black', height: '100%', justifyContent: 'center',}
+            }}
+            Icon={() => <FontAwesome name="chevron-down"  color='white' size={20} />}
             onValueChange={(value) => {
               setFloor(value)
               setShowME(false)

+ 16 - 3
src/components/Map/MainMapComponent/Map.styles.tsx

@@ -9,10 +9,23 @@ import { StyleSheet } from "react-native";
 import { colors } from "../../../utils/GlobalUtils";
 import { AppState, Platform, ScrollView, View, Image, Dimensions, } from "react-native"
 
+const mapButtonShadow = StyleSheet.create({
+    mapButtonShadow: {
+        shadowColor: "grey",
+        shadowOffset: {
+            width: 0,
+            height: 0,
+        },
+        shadowRadius: 2,
+        shadowOpacity: 1,
+        elevation: 10, 
+    },
+})
+
 const mapStyles = StyleSheet.create({
     lowerMapButton: {
+        ...mapButtonShadow.mapButtonShadow,
         backgroundColor: colors.red, 
-        elevation: 10, 
         right: 20, 
         position: 'absolute', 
         height: 40, width: 40, 
@@ -21,7 +34,7 @@ const mapStyles = StyleSheet.create({
         alignItems: 'center'
     },
     filterButtonOutdoor: {
-        elevation: 10, 
+        ...mapButtonShadow.mapButtonShadow,
         height: 40, 
         width: 40, 
         borderRadius: 20, 
@@ -30,7 +43,7 @@ const mapStyles = StyleSheet.create({
         backgroundColor: 'white', 
     },
     filterButtonIndoor: {
-        elevation: 5, 
+        ...mapButtonShadow.mapButtonShadow,
         height: 30, 
         width:  30, 
         borderRadius: 20, 

+ 34 - 2
src/data/Auth/AuthContext.tsx

@@ -7,8 +7,8 @@ import { useQueryClient } from "react-query"
 import { API_URL, reportAxiosError } from "../../utils/RequestUtils"
 import { Landmark } from "../landmarks"
 import { queryKeys } from "../query-keys"
-import {sha256} from 'react-native-sha256'
 import {v4} from 'uuid'
+import { ErrorMessage } from "formik"
 
 export const SECURESTORE_ACCESSTOKEN = "access"
 export const SECURESTORE_REFRESHTOKEN = "refresh"
@@ -54,6 +54,12 @@ interface AuthenticationResult {
     errorMessage?: string
 }
 
+interface GlobalAlert {
+    message: string
+    type: 'success' | 'error'
+    callback: () => void
+}
+
 const setStorageItem = async (key: string, value: string) => {
     if (value) {
         await setItemAsync(key, value)
@@ -90,7 +96,7 @@ export const AuthContextProvider: React.FC = ({children}) => {
     const [userId, setUserId] = useState<string>()
     const [anonUserId, setAnonUserId] = useState<string>()
     const [loading, setLoading] = useState<boolean>(false)
-    const [error, setError] = useState<string>('')
+    const [message, setMessage] = useState<string>('')
 
     const queryClient = useQueryClient()
 
@@ -230,6 +236,10 @@ export const AuthContextProvider: React.FC = ({children}) => {
                 await setAccessTokenAsync(tokenResponse.access_token);
                 await setRefreshTokenAsync(tokenResponse.refresh_token);
                 await setUserIdAsync(idToken.sub)
+
+                // TODO: check for anonymous landmarks on the server, and display a notification if there are any asking the user to convert them
+                await checkForAnonymousLandmarks()
+
                 setAnonUserId('')
 
                 console.log('[Authentication]: Tokens successfully retrieved.')
@@ -310,6 +320,28 @@ export const AuthContextProvider: React.FC = ({children}) => {
         return owned
     }
 
+    const createGlobalAlert = (message: string) => {
+
+    const checkForAnonymousLandmarks = async () => {
+        try {
+            const response = await sendApiRequestAsync({
+                axiosConfig: {
+                    method: 'GET',
+                    url: `/api/landmarks/anon/${anonUserId}/`
+                },
+                authorized: true,
+                errorMessage: 'An error occured while checking for anonymous landmarks'
+            })
+    
+            if (response?.data?.has_landmark) {
+
+            }
+        } catch (error) {
+            reportAxiosError("[Authentication]: Error when checking for anonymous landmarks", error);
+            return false
+        }
+    }
+
     const authState = useMemo(() => ({
         accessToken,
         notificationToken,

+ 21 - 1
yarn.lock

@@ -4882,6 +4882,13 @@
   "resolved" "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz"
   "version" "2.2.0"
 
+"bindings@^1.5.0":
+  "integrity" "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ=="
+  "resolved" "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz"
+  "version" "1.5.0"
+  dependencies:
+    "file-uri-to-path" "1.0.0"
+
 "bl@^4.0.3", "bl@^4.1.0":
   "integrity" "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w=="
   "resolved" "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz"
@@ -8337,6 +8344,19 @@
   "resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
   "version" "1.0.0"
 
+"fsevents@^1.2.7":
+  "integrity" "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw=="
+  "resolved" "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz"
+  "version" "1.2.13"
+  dependencies:
+    "bindings" "^1.5.0"
+    "nan" "^2.12.1"
+
+"fsevents@^2.1.2", "fsevents@~2.3.2":
+  "integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="
+  "resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
+  "version" "2.3.2"
+
 "function-bind@^1.1.1":
   "integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
   "resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
@@ -11528,7 +11548,7 @@
     "object-assign" "^4.0.1"
     "thenify-all" "^1.0.0"
 
-"nan@^2.14.2":
+"nan@^2.12.1", "nan@^2.14.2":
   "integrity" "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
   "resolved" "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz"
   "version" "2.15.0"