Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions frontend/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import getLocalIPAddress from "./getLocalIPAddress.ts";
import { API_BASE_URL } from "./src/screens/RegisterUserScreen.tsx";

const ip = getLocalIPAddress();

export default {
name: "Snap Map",
slug: "snap-map",
Expand All @@ -18,8 +13,9 @@ export default {
bundleIdentifier: "com.snapmap.app",
infoPlist: {
NSCameraUsageDescription: "Allow Snap Map to access your camera.",
NSLocationWhenInUseUsageDescription: "Allow Snap Map to access your location while using the app."
}
NSLocationWhenInUseUsageDescription:
"Allow Snap Map to access your location while using the app.",
},
},

android: {
Expand All @@ -30,8 +26,8 @@ export default {
foregroundImage: "./src/assets/images/icon.png",
backgroundColor: "#E6F4FE",
backgroundImage: "./src/assets/images/android-icon-background.png",
monochromeImage: "./src/assets/images/android-icon-monochrome.png"
}
monochromeImage: "./src/assets/images/android-icon-monochrome.png",
},
},

plugins: [
Expand All @@ -42,17 +38,16 @@ export default {
imageWidth: 200,
resizeMode: "contain",
backgroundColor: "#ffffff",
dark: { backgroundColor: "#000000" }
}
]
dark: { backgroundColor: "#000000" },
},
],
],

experiments: {
reactCompiler: true
reactCompiler: true,
},

extra: {
// API_BASE_URL: `https://snapmap.onrender.com`
API_BASE_URL: `http://${ip}:5000`
}
API_BASE_URL: "https://snapmap.onrender.com"
},
};
22 changes: 17 additions & 5 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions frontend/src/apiConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Constants from "expo-constants";

export const API_BASE_URL = Constants.expoConfig?.extra?.API_BASE_URL;

if (!API_BASE_URL) {
console.warn("API_BASE_URL is not defined in the Expo configuration.");
}
24 changes: 13 additions & 11 deletions frontend/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
StatusBar,
Image,
} from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import {
SafeAreaView,
useSafeAreaInsets,
} from "react-native-safe-area-context";
import { Dimensions } from "react-native";
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
import MapView, { Marker, PROVIDER_GOOGLE } from "react-native-maps";
Expand All @@ -18,12 +21,11 @@ import { useUser } from "@clerk/clerk-expo";
import HomeStyle from "../styles/HomeStyle";
import BottomNavigation from "../navigation/BottomNavigation";
import Constants from "expo-constants";
import { API_BASE_URL } from "../apiConfig";
import { useProfile } from "../context/ProfileContext";

const styles = HomeStyle;

const API_BASE_URL =
Constants.expoConfig?.extra?.API_BASE_URL ?? "http://localhost:5000";
const DEFAULT_RADIUS_METERS = 300;

type Coordinates = {
Expand Down Expand Up @@ -58,7 +60,7 @@ const HomeScreen = ({ navigation }: ScreenProps<"HomeScreen">) => {
headers: {
"Content-Type": "application/json",
},
}
},
);

if (!response.ok) {
Expand Down Expand Up @@ -101,7 +103,7 @@ const HomeScreen = ({ navigation }: ScreenProps<"HomeScreen">) => {
};
} else {
console.warn(
"Location permission not granted, using default location for nearby photos"
"Location permission not granted, using default location for nearby photos",
);
}
} catch (error) {
Expand Down Expand Up @@ -153,7 +155,11 @@ const HomeScreen = ({ navigation }: ScreenProps<"HomeScreen">) => {
style={styles.profileImage}
/>
) : (
<Ionicons name="person-circle-outline" size={28} color="#f43f5e" />
<Ionicons
name="person-circle-outline"
size={28}
color="#f43f5e"
/>
)}
</TouchableOpacity>
</View>
Expand Down Expand Up @@ -225,11 +231,7 @@ const HomeScreen = ({ navigation }: ScreenProps<"HomeScreen">) => {
onPress={() => navigation.navigate("MapScreen")}
>
<View style={styles.fullMapIconContainer}>
<MaterialCommunityIcons
name="map"
size={24}
color="#FFFFFF"
/>
<MaterialCommunityIcons name="map" size={24} color="#FFFFFF" />
</View>
<View style={styles.fullMapTextContainer}>
<Text style={styles.fullMapSubtext}>Tap to explore</Text>
Expand Down
36 changes: 17 additions & 19 deletions frontend/src/screens/MapScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ import { SafeAreaView } from "react-native-safe-area-context";
import MapStyle from "../styles/MapStyle";
import BottomNavigation from "../navigation/BottomNavigation";
import Constants from "expo-constants";
import { API_BASE_URL } from "../apiConfig";
import { useProfile } from "../context/ProfileContext";
import { useUser } from "@clerk/clerk-expo";
import SnapScreen from "./SnapScreen";

const styles = MapStyle;

const API_BASE_URL =
Constants.expoConfig?.extra?.API_BASE_URL ?? "http://localhost:5000";
const DEFAULT_RADIUS_METERS = 300;

type Coordinates = {
Expand Down Expand Up @@ -73,7 +72,7 @@ const MapScreen = ({ navigation }: ScreenProps<"MapScreen">) => {
headers: {
"Content-Type": "application/json",
},
}
},
);

if (!response.ok) {
Expand Down Expand Up @@ -144,25 +143,24 @@ const MapScreen = ({ navigation }: ScreenProps<"MapScreen">) => {
showsMyLocationButton
>
{photos.map((photo, idx) => (
<View
key={idx}>
<View key={idx}>
<Marker
key={photo.id}
coordinate={{
latitude: photo.latitude,
longitude: photo.longitude,
}}
image={photo.imageURL.length === 1 ? singlePhoto : multiPhoto}
onPress={() => navigation.navigate("SnapScreen", {
imageURL: photo.imageURL,
caption: photo.caption,
latitude: photo.latitude,
longitude: photo.longitude,
})}

key={photo.id}
coordinate={{
latitude: photo.latitude,
longitude: photo.longitude,
}}
image={photo.imageURL.length === 1 ? singlePhoto : multiPhoto}
onPress={() =>
navigation.navigate("SnapScreen", {
imageURL: photo.imageURL,
caption: photo.caption,
latitude: photo.latitude,
longitude: photo.longitude,
})
}
/>
</View>

))}
</MapView>

Expand Down
Loading