Skip to content

Commit

Permalink
Merge pull request #145 from oss-slu/MapStartingLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
yashb196 authored May 6, 2024
2 parents c240d34 + 6190150 commit 783701e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
24 changes: 24 additions & 0 deletions lib/screens/mapPage/ExploreLoadingScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ActivityIndicator, View, Text, StyleSheet } from 'react-native';
import { useTheme } from '../../components/ThemeProvider';

const ExploreLoadingScreen = () => {
const { theme, isDarkmode } = useTheme();

return (
<View style={styles.centered}>
<ActivityIndicator size="large" color="#0000ff" />
<View style={{padding: 5}}></View>
<Text style={{ color: theme.text }}>Loading your location...</Text>
</View>
);
}

const styles = StyleSheet.create({
centered: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}
});

export default ExploreLoadingScreen;
27 changes: 18 additions & 9 deletions lib/screens/mapPage/ExploreScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const ExploreScreen = () => {
const { theme, isDarkmode } = useTheme();
const [showMapTypeOptions, setShowMapTypeOptions] = useState(false);


const toggleMapTypeOptions = () => {
setShowMapTypeOptions(prevState => !prevState);
};
Expand Down Expand Up @@ -87,10 +86,18 @@ const ExploreScreen = () => {
globeIcon !== "earth",
"someUserId"
);

console.log("STEP 3: fetchedNotes from ApiService.fetchMessages:", fetchedNotes);
// console.log("Notes being used: ", fetchedNotes);


// console.log("STEP 3: fetchedNotes from ApiService.fetchMessages:", fetchedNotes);

// Write the count to the log file
await RNFS.appendFile(logFilePath, `Count of fetched notes: ${fetchedNotes.length}\n`, 'utf8')
.then(() => {
console.log('Logged count to file');
})
.catch(err => {
console.error('Error writing to log file:', err);
});

const fetchedMarkers = fetchedNotes.map((note) => {
let time;
if (note.time === undefined) {
Expand All @@ -101,7 +108,7 @@ const ExploreScreen = () => {
} else {
time = new Date(note.time);
}

return {
coordinate: {
latitude: parseFloat(note.latitude) || 0,
Expand All @@ -113,20 +120,22 @@ const ExploreScreen = () => {
description: note.BodyText || "",
images:
note.media.map((mediaItem) => ({ uri: mediaItem.uri })) ||
require("../../../assets/map_marker.png"), // need to replace with placeholder image
require("../../../assets/map_marker.png"), // Placeholder image replacement
time: formatToLocalDateString(time) || "",
tags: note.tags || [],
};
});

setState((prevState) => ({
...prevState,
markers: fetchedMarkers,
notesCount: fetchedNotes.length, // if you need to use this count in your state
}));
} catch (error) {
console.error("Error fetching messages:", error);
}
});


useEffect(() => {
fetchMessages();
Expand Down Expand Up @@ -491,7 +500,7 @@ const [state, setState] = useState({
<View style={styles.searchBox}>
<TouchableOpacity onPress={() => {
setGlobeIcon(prevIcon => (prevIcon === "earth-outline" ? "earth" : "earth-outline"));
setSearchResults(null);
setSearchResults(null);
}}>
<Ionicons
name={globeIcon}
Expand Down

0 comments on commit 783701e

Please sign in to comment.