Skip to content

Commit

Permalink
Merge pull request #66 from oss-slu/deliverable-6
Browse files Browse the repository at this point in the history
Deliverable 6 merging changes
  • Loading branch information
yashb196 authored Aug 24, 2023
2 parents 2d266c4 + fec8ad0 commit facf7aa
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 23 deletions.
7 changes: 1 addition & 6 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"config": {
"googleMapsApiKey": ""
},
"buildVersion" : "3"
"buildNumber" : "5"
},
"android": {
"adaptiveIcon": {
Expand All @@ -35,11 +35,6 @@
},
"web": {
"favicon": "./assets/favicon.png"
},
"extra": {
"eas": {
"projectId": "622ba56f-88f9-440e-af87-280abce3b1e8"
}
}
}
}
22 changes: 15 additions & 7 deletions lib/navigation/AppNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { User } from "../models/user_class";
import OnboardingScreen from "../screens/OnboardingScreen";
import { getItem } from "../utils/async_storage";
import { HomeScreenProps, RootTabParamList, EditNoteProps } from "../../types";
import * as SplashScreen from 'expo-splash-screen';

SplashScreen.preventAutoHideAsync();

const user = User.getInstance();

Expand Down Expand Up @@ -48,28 +51,33 @@ const HomeStack = () => {
};

const AppNavigator: React.FC = () => {
const [navState, setNavState] = useState<"onboarding" | "login" | "home">("onboarding");
const [navState, setNavState] = useState<"loading" | "onboarding" | "login" | "home">("loading");

useEffect(() => {
const checkOnboarding = async () => {
const onboarded = await getItem("onboarded");
if (onboarded === "1") {
const userId = await user.getId();
setNavState(userId ? "home" : "login");
const userId = await user.getId();

if (onboarded === "1" && userId) {
setNavState("home");
} else if (onboarded === "1") {
setNavState("login");
} else {
setNavState("onboarding");
}
await SplashScreen.hideAsync();
};

checkOnboarding();
}, []);


useEffect(() => {
user.setLoginCallback((isLoggedIn) => {
setNavState(isLoggedIn ? "home" : "login");
});
}, []);



return (
<NavigationContainer>
{navState === "onboarding" && (
Expand Down Expand Up @@ -124,4 +132,4 @@ const AppNavigator: React.FC = () => {

};

export default AppNavigator;
export default AppNavigator;
1 change: 1 addition & 0 deletions lib/screens/AddNoteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ const AddNoteScreen: React.FC<AddNoteScreenProps> = ({ navigation, route }) => {
<RichEditor
ref={(r) => (richTextRef.current = r)}
style={styles.input}
autoCorrect={true}
placeholder="Write your note here"
onChange={(text) => setBodyText(text)}
initialContentHTML={bodyText}
Expand Down
1 change: 1 addition & 0 deletions lib/screens/EditNoteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ const EditNoteScreen: React.FC<EditNoteScreenProps> = ({
<RichEditor
ref={(r) => (richTextRef.current = r)}
style={styles.input}
autoCorrect={true}
placeholder="Write your note here"
onChange={(text) => setText(text)}
initialContentHTML={text}
Expand Down
File renamed without changes.
37 changes: 30 additions & 7 deletions lib/screens/mapPage/ExploreScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { mapDarkStyle, mapStandardStyle } from "./mapData";
import ApiService from "../../utils/api_calls";
import { useTheme } from "@react-navigation/native";
import Constants from 'expo-constants'
import { Keyboard } from 'react-native';


const { width, height } = Dimensions.get("window");
const CARD_HEIGHT = 220;
Expand All @@ -37,6 +39,12 @@ const ExploreScreen = () => {
setSelectedNote(note);
setModalVisible(true);
};
const handleSearch = () => {
Keyboard.dismiss();
searchForMessages();
};



const [searchResults, setSearchResults] = useState(null);

Expand Down Expand Up @@ -111,7 +119,7 @@ const ExploreScreen = () => {

useEffect(() => {
fetchMessages();
}, [fetchMessages]);
}, [state, globeIcon, searchResults]);

const [state, setState] = useState({
markers: [],
Expand Down Expand Up @@ -203,14 +211,27 @@ const [state, setState] = useState({

useEffect(() => {
let isMounted = true;

(async () => {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== "granted") {
alert("Permission to access location was denied");
return;
Alert.alert(
"Permission Denied",
"Permission to access location was denied. This is required on this page",
[
{
text: "Try Again",
onPress: () => {
(async () => {
await Location.requestForegroundPermissionsAsync();
})();
}
},
]
);
return; // Early return to avoid executing further code without permission
}

let location = await Location.getCurrentPositionAsync({});
const { latitude, longitude } = location.coords;
if (isMounted) {
Expand All @@ -225,9 +246,10 @@ const [state, setState] = useState({
}));
}
})();

return () => isMounted = false;
}, []);


const interpolations = state.markers.map((marker, index) => {
const inputRange = [
Expand Down Expand Up @@ -312,8 +334,9 @@ const [state, setState] = useState({
autoCapitalize="none"
style={{ flex: 1, padding: 0 }}
onChangeText={setSearchQuery}
onSubmitEditing={handleSearch}
/>
<Ionicons name="ios-search" size={25} onPress={searchForMessages} />
<Ionicons name="ios-search" size={25} onPress={handleSearch} />
</View>

{/* <ScrollView
Expand Down
6 changes: 3 additions & 3 deletions lib/screens/mapPage/NoteDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ const NoteDetailModal: React.FC<Props> = memo(({ isVisible, onClose, note }) =>
No images
</Text>
)}
<View style={{ height: 250 }}></View>
</ScrollView>
<View
style={[
Expand Down Expand Up @@ -249,10 +248,11 @@ const styles = StyleSheet.create({
width: "100%",
height: 360,
marginBottom: 2,
borderRadius: 10,
overflow: "hidden",
borderWidth: 1,
<<<<<<< HEAD
=======
borderColor: '#e0e0e0',
>>>>>>> 60ad3d1 (fixing changes related to spacing of the images)
},
image: {
width: "100%",
Expand Down

0 comments on commit facf7aa

Please sign in to comment.