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

Develop #11

Merged
merged 24 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
053e29a
MVP for home screen
ahardy42 Mar 23, 2020
36a30c0
map page is pretty weak but it works and markers are loaded when a po…
ahardy42 Mar 24, 2020
a7f4153
Merge pull request #1 from ahardy42/feature/map-page
ahardy42 Mar 24, 2020
1cb9764
added difficulty options and styled buttons
ahardy42 Mar 24, 2020
30ea207
Merge pull request #2 from ahardy42/feature/main-options
ahardy42 Mar 24, 2020
2b29105
added a start modal
ahardy42 Mar 24, 2020
3cead56
Merge pull request #3 from ahardy42/feature/start-modal
ahardy42 Mar 24, 2020
d1d5bde
updated marker
ahardy42 Mar 24, 2020
c98ef6a
snapping markers roughly to roads
ahardy42 Mar 25, 2020
2c0c5e1
Merge pull request #4 from ahardy42/feature/marker-fix
ahardy42 Mar 25, 2020
19d346f
updated bbox creation
ahardy42 Mar 25, 2020
adca8a7
added bbox creation screen to select polygon for play
ahardy42 Mar 25, 2020
9817376
Merge pull request #5 from ahardy42/feature/create-bbox
ahardy42 Mar 25, 2020
579e10a
difficulty settings means something now
ahardy42 Mar 25, 2020
dd5bf17
Merge pull request #6 from ahardy42/feature/difficulty
ahardy42 Mar 25, 2020
73bf265
create different lengths and a home button
ahardy42 Mar 26, 2020
9d2a8af
Merge pull request #7 from ahardy42/feature/length
ahardy42 Mar 26, 2020
201ede2
created a timer for the game
ahardy42 Mar 26, 2020
87baf5c
Merge pull request #8 from ahardy42/feature/timer
ahardy42 Mar 26, 2020
11ebfa6
made some styling changes
ahardy42 Mar 26, 2020
89cf829
created game over situation
ahardy42 Mar 26, 2020
54acc5e
Merge pull request #9 from ahardy42/feature/game-over
ahardy42 Mar 26, 2020
74a00ea
Merge pull request #10 from ahardy42/feature/stylin
ahardy42 Mar 26, 2020
7648868
updating some simple things
ahardy42 Mar 26, 2020
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
Prev Previous commit
Next Next commit
create different lengths and a home button
  • Loading branch information
ahardy42 committed Mar 26, 2020
commit 73bf265e877548454821af097a58b4f8d75b96cc
33 changes: 33 additions & 0 deletions components/HomeButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { View, StyleSheet } from 'react-native';
import { Icon } from 'react-native-elements';
import { useMarkerContext } from '../context/MarkerContext';

type HomeButtonProps = {
handlePress: () => void
}

export default function HomeButton({ handlePress }: HomeButtonProps) {

const [,markerDispatch] = useMarkerContext();

const _handlePress: () => void = () => {
markerDispatch({type: 'RESET_STATE'});
handlePress();
}

return (
<View style={styles.container}>
<Icon name='home' type='font-awesome' size={25} color='orange' reverse onPress={_handlePress}/>
</View>
);
};

const styles = StyleSheet.create({
container: {
position: 'absolute',
bottom: 100,
right: 15,
zIndex: 300
}
})
11 changes: 2 additions & 9 deletions components/MapButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
import { View, StyleSheet } from 'react-native';
import { useFormContext } from '../context/FormContext';
import { Icon } from 'react-native-elements'
import { Icon } from 'react-native-elements';

type MapButtonProps = {
handleCompass?: React.Dispatch<React.SetStateAction<boolean>>,
Expand Down Expand Up @@ -41,12 +41,5 @@ const styles = StyleSheet.create({
left: 15,
flexDirection: 'column',
zIndex: 300
},
button: {
width: 100,
height: 100,
borderRadius: 50,
justifyContent: 'center',
alignItems: 'center'
}
})
21 changes: 17 additions & 4 deletions screens/BboxCreateScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { StyleSheet, View, Dimensions } from 'react-native';
import { RootStackParamList } from '../App';
import { StackNavigationProp } from '@react-navigation/stack';
import { LocationData, Accuracy } from 'expo-location';
// utilties
import { useFormContext } from '../context/FormContext';
import { useMarkerContext } from '../context/MarkerContext';
Expand All @@ -12,8 +11,8 @@ import { usePolygonCreator, PolyBoundary } from '../components/PolyBoundary';
import PolyButton from '../components/PolyButton';
import MapView, { Region, LatLng } from 'react-native-maps';
import Instructions from '../components/Instructions';
import { StackActions } from '@react-navigation/native';
import { useRegionContext } from '../context/RegionContext';
import HomeButton from '../components/HomeButton';

type ProfileScreenNavigationProp = StackNavigationProp<
RootStackParamList,
Expand All @@ -40,19 +39,32 @@ export default function BboxCreateScreen({ navigation }: BboxCreateProps) {
const [isFollowingUser, setFollowing] = React.useState<boolean>(true);
const [finalRegion, setRegion] = useRegionContext();

const returnLen: () => number = () => {
switch (formState.distance) {
case 'short':
return 6;
case 'medium':
return 10;
case 'long':
return 14;
default:
return 6
}
}

React.useEffect(() => {
if (boundary.length) {
// init markers
if (formState.activity === 'on-road') {
initSnappedMarkerList(boundary, 10)
initSnappedMarkerList(boundary, returnLen())
.then(list => {
markerDispatch({type: 'SET_LIST', payload: list})
})
.catch(e => {
console.log(e);
})
} else {
let list = initMarkerList(boundary, 10);
let list = initMarkerList(boundary, returnLen());
console.log('list is', list)
markerDispatch({type: 'SET_LIST', payload: list})
}
Expand Down Expand Up @@ -83,6 +95,7 @@ export default function BboxCreateScreen({ navigation }: BboxCreateProps) {
</MapView>
<Instructions coordsLen={coords.length}/>
<PolyButton coordsLen={coords.length} coords={coords} setBoundary={setBoundary}/>
<HomeButton handlePress={() => navigation.navigate('Home')} />
</View>
);
}
Expand Down
2 changes: 2 additions & 0 deletions screens/MapScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import MarkerList from '../components/MarkerList';
import StartModal from '../components/StartModal';
import PointsTally from '../components/PointsTally';
import MapButtons from '../components/MapButtons';
import HomeButton from '../components/HomeButton';

type ProfileScreenNavigationProp = StackNavigationProp<
RootStackParamList,
Expand Down Expand Up @@ -126,6 +127,7 @@ export default function MapScreen({ navigation }: HomeScreenProps) {
<MarkerList markerList={markerState.markers} />
</MapView>
<MapButtons mapRef={mapRef} handleCompass={setIsHeading} handleLocation={setIsLocation} />
<HomeButton handlePress={() => navigation.navigate('Home')} />
</View>
);
}
Expand Down