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

Minor changes to Search Screen #11

Merged
merged 1 commit into from Sep 4, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/.expo/packager-info.json
Expand Up @@ -2,7 +2,7 @@
"devToolsPort": 19002,
"expoServerPort": 19000,
"packagerPort": 19001,
"packagerPid": 32764,
"packagerPid": 13440,
"expoServerNgrokUrl": null,
"packagerNgrokUrl": null,
"ngrokPid": null,
Expand Down
8 changes: 4 additions & 4 deletions client/App.js
Expand Up @@ -49,10 +49,10 @@ const navigator = createSwitchNavigator(
{
//LoadingScreen checks for token and id in local storage
// Loading: LoadingScreen,
// loginFlow: createStackNavigator({
// Signin: SigninScreen,
// Signup: SignupScreen
// }),
loginFlow: createStackNavigator({
Signin: SigninScreen,
Signup: SignupScreen
}),
mainFlow: createBottomTabNavigator({
homeFlow: homeFlow,
Account: AccountScreen
Expand Down
2 changes: 1 addition & 1 deletion client/app/api/apiServer.js
Expand Up @@ -2,7 +2,7 @@ import axios from "axios";
import {AsyncStorage} from 'react-native';

const instance = axios.create({
baseURL: "http://9a009627dea8.ngrok.io"
baseURL: "https://ascentbackend.herokuapp.com/"
})

instance.interceptors.request.use(
Expand Down
48 changes: 48 additions & 0 deletions client/app/components/AreaSearchResultsList.js
@@ -0,0 +1,48 @@
import React from 'react';
import {View, StyleSheet, ScrollView, FlatList, SectionList, TouchableOpacity, Image, SafeAreaView} from 'react-native';
import {Text} from 'react-native-elements'

const AreaSearchResultsList = ({navigation,areaSearchResults}) => {
return (
<FlatList
data={areaSearchResults}
keyExtractor={(result)=> result.id.toString()}
renderItem={({item})=>{
return(
<TouchableOpacity style={{borderBottomWidth:1, backgroundColor:"#bdc6cf"}} onPress={()=> navigation.navigate('AreaDetail',{id:item.id, title: item.name})}>
<View style={{ height:60, flexDirection:"row", }}>
{item.image_url ? <Image style={styles.image} source={{uri: item.image_url}}/> : <Image style={styles.image} source={require('../images/placeholderImage.jpeg')}/>}
<View >
<View style={{paddingTop:5}}>
<Text style={{ fontSize:16,fontWeight:"bold",}}>
{/* width:140 */}
{item.name}
</Text>
</View>
<View>
<Text style={{fontSize:12}}>
Created by: {item.User.username}
</Text>
<Text>
{item.Routes.length} Routes
</Text>
</View>
</View>
<View style={{ paddingLeft: 4, paddingTop:10}}>

</View>
</View>
</TouchableOpacity>
)
}}
/>
);
}
const styles = StyleSheet.create({
image:{
width:80,
height:60
}
})

export default AreaSearchResultsList;
2 changes: 2 additions & 0 deletions client/app/components/RouteForm.js
Expand Up @@ -93,6 +93,7 @@ console.log(selectedArea)
inputContainerStyle={{borderWidth: 1,borderColor:"white", width:100}}
inputStyle={styles.input}
labelStyle={styles.label}
selectionColor={"white"}
/>
</View>
<View style={{marginLeft:20}}>
Expand All @@ -105,6 +106,7 @@ console.log(selectedArea)
inputContainerStyle={{borderWidth: 1,borderColor:"white", width:100}}
inputStyle={{color:"white"}}
labelStyle={styles.label}
selectionColor={"white"}
/>
</View>
</View>
Expand Down
51 changes: 51 additions & 0 deletions client/app/components/RouteSearchResultsList.js
@@ -0,0 +1,51 @@
import React from 'react';
import {View, StyleSheet, ScrollView, FlatList, SectionList, TouchableOpacity, Image, SafeAreaView} from 'react-native';
import {Text} from 'react-native-elements'

const RouteSearchResultsList = ({navigation,routeSearchResults}) => {
return (
<FlatList
data={routeSearchResults}
keyExtractor={(result)=> result.id.toString()}
renderItem={({item})=>{
return(
<TouchableOpacity style={{borderBottomWidth:1, backgroundColor:"#bdc6cf"}} onPress={()=> navigation.navigate('RouteDetail', {id:item.id, title:item.name})}>
<View style={{ height:60, flexDirection:"row", justifyContent:"space-between"}}>
{item.image_url ? <Image style={styles.image} source={{uri: item.image_url}}/> : <Image style={styles.image} source={require('../images/placeholderImage.jpeg')}/>}
<View >
<View style={{ paddingTop:5}}>
<Text style={{ fontSize:16,fontWeight:"bold", marginRight:150, width:125}}>
{item.name}
</Text>
<Text style={{fontSize:10}}>
{item.Area.name}
</Text>
</View>
<View style={{}} >
<Text style={{fontSize:12,marginTop:7}}>
Created by: {item.User.username}
</Text>
</View>
</View>
<View style={{ alignItems:"flex-end", width:55,}}>
<Text >
{item.type}
</Text>
<Text style={{marginTop:5}}>
{item.grade}
</Text>
</View>
</View>
</TouchableOpacity>
)
}}
/>
);
}
const styles = StyleSheet.create({
image:{
width:80,
height:60
}
})
export default RouteSearchResultsList;
14 changes: 7 additions & 7 deletions client/app/screens/MapScreen.js
Expand Up @@ -18,13 +18,13 @@ const Map = ({navigation}) => {
const askPermission = async()=>{
try{
await requestPermissionsAsync();
await watchPositionAsync({
accuracy: Accuracy.BestForNavigation,
timeInterval:1000,
distanceInterval: 10
}, (location)=>{
setCurrentLocation(location)
})
// await watchPositionAsync({
// accuracy: Accuracy.BestForNavigation,
// timeInterval:1000,
// distanceInterval: 10
// }, (location)=>{
// setCurrentLocation(location)
// })
}catch(err){
setErr(err)
}
Expand Down
19 changes: 10 additions & 9 deletions client/app/screens/SearchScreen.js
Expand Up @@ -8,7 +8,8 @@ import {SearchBar} from 'react-native-elements'
import { set } from 'react-native-reanimated';
import {Context as routeContext} from '../context/RouteContext'
import {Context as areaContext} from '../context/AreaContext'

import AreaSearchResultsList from '../components/AreaSearchResultsList'
import RouteSearchResultsList from '../components/RouteSearchResultsList'

const SearchScreen = ({navigation}) => {
// const [searchTerm, setSearchTerm] = useState('')
Expand Down Expand Up @@ -81,8 +82,8 @@ const SearchScreen = ({navigation}) => {


return (
<SafeAreaView>
<ScrollView nestedScrollEnabled={true} showsHorizontalScrollIndicator={false}>
<SafeAreaView showsVerticalScrollIndicator={false}>
<ScrollView nestedScrollEnabled={true} showsVerticalScrollIndicator={false}>
{/* <SearchBar
// setSearchTerm={setSearchTerm}
// searchTerm={searchTerm}
Expand Down Expand Up @@ -114,7 +115,7 @@ const SearchScreen = ({navigation}) => {
<View >
<View style={{paddingTop:5}}>
<Text style={{ fontSize:16,fontWeight:"bold",}}>
{/* width:140 */}

{item.name}
</Text>
</View>
Expand Down Expand Up @@ -148,22 +149,22 @@ const SearchScreen = ({navigation}) => {
<View style={{ height:60, flexDirection:"row", justifyContent:"space-between"}}>
{item.image_url ? <Image style={styles.image} source={{uri: item.image_url}}/> : <Image style={styles.image} source={require('../images/placeholderImage.jpeg')}/>}
<View >
<View style={{paddingTop:5}}>
<Text style={{ fontSize:16,fontWeight:"bold", marginRight:150, width:140}}>
<View style={{ paddingTop:5}}>
<Text style={{ fontSize:16,fontWeight:"bold", marginRight:150, width:125}}>
{item.name}
</Text>
<Text style={{fontSize:10}}>
{item.Area.name}
</Text>
</View>
<View>
<View style={{}} >
<Text style={{fontSize:12,marginTop:7}}>
Created by: {item.User.username}
</Text>
</View>
</View>
<View style={{alignItems:"flex-end"}}>
<Text>
<View style={{ alignItems:"flex-end", width:55,}}>
<Text >
{item.type}
</Text>
<Text style={{marginTop:5}}>
Expand Down
12 changes: 8 additions & 4 deletions client/app/screens/SigninScreen.js
@@ -1,6 +1,6 @@
import React,{useState, useContext} from 'react';
import {View, StyleSheet, SafeAreaView,ImageBackground,Image,TouchableOpacity, Button} from 'react-native';
import {Text, Input, Button as SignInButton} from 'react-native-elements'
import {View, StyleSheet, SafeAreaView,ImageBackground,Image,TouchableOpacity} from 'react-native';
import {Text, Input, Button} from 'react-native-elements'
import {Context as UserContext} from '../context/UserContext';
import Spacer from '../components/Spacer'
import { MaterialIcons } from '@expo/vector-icons';
Expand Down Expand Up @@ -56,7 +56,7 @@ const SigninScreen = ({navigation}) => {
/>
{state.errorMessage ? <Text style={styles.errorMessage}>{state.errorMessage}</Text>: null}
<Spacer>
<SignInButton buttonStyle={{backgroundColor:"#1359c4"}}title={"Sign In"} onPress={()=> signin({email,password})} />
<Button buttonStyle={{backgroundColor:"#1359c4"}} title={"Sign In"} onPress={()=> signin({email,password})} />
</Spacer>
<NavigationEvents
// onWillFocus={()=>{}} Right before navigating to screen
Expand All @@ -70,8 +70,12 @@ const SigninScreen = ({navigation}) => {
</Spacer>
</TouchableOpacity>
<Spacer/>
<Button title={"Demo User"} onPress={()=> signin({email:'demo@email.com',password:'password'})}>

</Button>
</View>
<SignInButton buttonStyle={{backgroundColor:"transparent"}}style={styles.modal} titleStyle={{color:"white"}}title="About Us" onPress={toggleModal}/>
<Button buttonStyle={{backgroundColor:"transparent"}}style={styles.modal} titleStyle={{color:"white"}}title="About Us" onPress={toggleModal}/>

<AboutUs toggleModal={toggleModal} isModalVisable={isModalVisable}/>
</SafeAreaView>
</ImageBackground>
Expand Down
2 changes: 1 addition & 1 deletion client/app/screens/SignupScreen.js
Expand Up @@ -61,7 +61,7 @@ const SignupScreen = ({navigation}) => {
/>
{state.errorMessage ? <Text style={styles.errorMessage}>{state.errorMessage}</Text>: null}
<Spacer>
<Button title={"Create Account"} onPress={()=> signup({username,email,password})} />
<Button title={"Create Account"} buttonStyle={{backgroundColor:"#1359c4"}} onPress={ ()=> signup({username,email,password})} />
</Spacer>
<NavigationEvents
// onWillFocus={()=>{}} Right before navigating to screen
Expand Down
2 changes: 1 addition & 1 deletion client/app/screens/crudRoute/RouteDetailScreen.js
Expand Up @@ -55,7 +55,7 @@ const RouteDetailPage = ({navigation}) => {
</TouchableOpacity>
<Spacer/>
<TouchableOpacity onPress={()=> Alert.alert("Delete", "Are you sure you want to delete?", [
{text: "Yes", onPress: ()=> deleteRoute(route.id, ()=> navigation.navigate('YourRoute'), ()=>{alert("Route deleted!")})},
{text: "Yes", onPress: ()=> deleteRoute(route.id, ()=> navigation.navigate('Home'), ()=>{alert("Route deleted!")})},
{text: "No", onPress: ()=> null}
])}>
<FontAwesome5 name="trash" size={24} color="white" />
Expand Down