Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map starting location #145

Merged
merged 6 commits into from
May 6, 2024
Merged
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
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
Loading