-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 91f9bb8
Showing
21 changed files
with
5,944 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"f9155ac790fd02fadcdeca367b02581c04a353aa6d5aa84409a59f6804c87acd": true, | ||
"89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true, | ||
"2a74234a88689f1b5e89be3bab52b8c895a195b49bf8a694f9729e0637eee599": true, | ||
"f765856d473f9ad66803df77ff7f7c7c1e78fa75f4b04428f7013d56fa5896be": true, | ||
"cab078b5104d3f5e24a10ed37037b7e6943271b93e0514110a181599931d6e7e": true, | ||
"442c347a87ad8048e3786f9dc8804380fb93e22357c51a9875b75991c20b1b1f": true, | ||
"4f4701853ff27341463ba57a0d614f237115bca2c69defa8efcc1abe3421f669": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
node_modules/**/* | ||
.expo/* | ||
npm-debug.* | ||
*.jks | ||
*.p12 | ||
*.key | ||
*.mobileprovision | ||
*.orig.* | ||
*.ai | ||
*.indd | ||
*.apk | ||
desktop.ini | ||
web-build/ | ||
web-report/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Begin: spaghetti code | ||
import React, { Component } from 'react'; | ||
import { StyleSheet, Text, View, Image, ImageBackground, Alert, TouchableOpacity } from 'react-native'; | ||
import * as Location from 'expo-location'; | ||
import * as Permissions from 'expo-permissions'; | ||
|
||
|
||
export default class App extends Component { | ||
|
||
// init states | ||
state = { | ||
locationLat: null, | ||
locationLon: null, | ||
errorMessage: null, | ||
flagImage: true, | ||
textColour: '#FA5695' | ||
}; | ||
|
||
|
||
// location functions | ||
|
||
_getLocationPerms = async () => { | ||
let { status } = await Permissions.askAsync(Permissions.LOCATION); | ||
if (status !== 'granted') { | ||
this.setState({ | ||
errorMessage: 'Permissions to access location was denied', | ||
}); | ||
} | ||
}; | ||
|
||
findCoordinates = async () => { | ||
navigator.geolocation.getCurrentPosition( | ||
position => { | ||
const locationLat = JSON.stringify(position.coords.latitude); | ||
const locationLon = JSON.stringify(position.coords.longitude); | ||
|
||
this.setState({ locationLat }); | ||
this.setState({ locationLon }); | ||
}, | ||
error => Alert.alert(error.message), | ||
{ enableHighAccuracy: false, maximumAge: 10 } | ||
); | ||
}; | ||
|
||
changeImage() { | ||
if (this.state.textColour === 'white') { | ||
var textColour = '#FA5695'; | ||
} else { | ||
var textColour = 'white'; | ||
} | ||
this.setState({ | ||
flagImage:!this.state.flagImage, | ||
textColour: textColour | ||
}); | ||
}; | ||
|
||
tekstiStyle = function(options) { | ||
return { | ||
fontFamily: 'sans-serif', // android default font | ||
fontSize: 30, | ||
textAlign: "center", | ||
margin: 10, | ||
color: this.state.textColour // muuhun #F80160 | ||
} | ||
}; | ||
|
||
render() { | ||
|
||
const haversine = require('haversine'); | ||
|
||
setTimeout(this._getLocationPerms, 1000); // 2s | ||
setTimeout(this.findCoordinates, 1000); | ||
|
||
let toripolliisiLocation = { | ||
latitude: 65.0126795, | ||
longitude: 25.4649844 | ||
}; | ||
|
||
let start = { | ||
latitude: this.state.locationLat, | ||
longitude: this.state.locationLon | ||
}; | ||
|
||
return ( | ||
<ImageBackground source={ this.state.flagImage === true ? | ||
require('./assets/backgroundWhite.png') : | ||
require('./assets/backgroundPink.png')} | ||
style={{flex: 1, width: '100%', height: '100%'}}> | ||
<View style={styles.container}> | ||
|
||
<TouchableOpacity onPress={ this.changeImage.bind(this) }> | ||
<Image source={ this.state.flagImage === true ? | ||
require('./assets/ToripolliisiPink.png') : | ||
require('./assets/ToripolliisiWhite.png')} | ||
style={{width: 400, height: 500, resizeMode: 'center'}} /> | ||
</TouchableOpacity> | ||
|
||
<Text style={this.tekstiStyle()}> | ||
{"\n"}Etäisyys Toripolliisiin on | ||
</Text> | ||
<Text style={styles.etaisyys}> | ||
{String(haversine(start, toripolliisiLocation)).substring(0,6)} km | ||
</Text> | ||
|
||
</View> | ||
</ImageBackground> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
// backgroundColor: '#fff', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
|
||
teksti: { | ||
fontFamily: 'sans-serif', // android default font | ||
fontSize: 30, | ||
textAlign: "center", | ||
margin: 10, | ||
color: '#FA5695' // muuhun #F80160 | ||
}, | ||
|
||
etaisyys: { | ||
fontFamily: 'sans-serif-medium', | ||
fontSize: 42, | ||
textAlign: "center", | ||
fontWeight: 'bold', | ||
color: 'black' | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# ToripolliisiApp | ||
|
||
Android app for showing the current distance to Toripolliisi in Oulu marketplace using React Native and GPS. | ||
|
||
## Prerequisities | ||
* Android 6.0+ | ||
* Location data | ||
|
||
## Setup | ||
* Download and install the .apk | ||
|
||
## Features to add | ||
* Better performance | ||
* About menu and settings | ||
|
||
## Screenshots | ||
<img src="https://i.imgur.com/QvNfOTT.png" alt="White Toripolliisi" width="50%" height="50%"/><img src="https://i.imgur.com/lbMHYD9.png" alt="Pink Toripolliisi" width="50%" height="50%"/> | ||
|
||
## Special thanks | ||
* Aalto University Guild of Physics (especially their coffee machine) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"expo": { | ||
"name": "Etäisyyspolliisi", | ||
"slug": "toripolliisiApp", | ||
"privacy": "public", | ||
"sdkVersion": "33.0.0", | ||
"platforms": [ | ||
"ios", | ||
"android", | ||
"web" | ||
], | ||
"android": { | ||
"package": "com.nikodg.toripolliisiapp" | ||
}, | ||
"version": "4.2.0", | ||
"orientation": "portrait", | ||
"icon": "./assets/icon2.png", | ||
"splash": { | ||
"image": "./assets/splash2.png", | ||
"resizeMode": "contain", | ||
"backgroundColor": "#F80160" | ||
}, | ||
"updates": { | ||
"fallbackToCacheTimeout": 0 | ||
}, | ||
"assetBundlePatterns": [ | ||
"**/*" | ||
], | ||
"ios": { | ||
"supportsTablet": true | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = function(api) { | ||
api.cache(true); | ||
return { | ||
presets: ['babel-preset-expo'], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"main": "node_modules/expo/AppEntry.js", | ||
"scripts": { | ||
"start": "expo start", | ||
"android": "expo start --android", | ||
"ios": "expo start --ios", | ||
"web": "expo start --web", | ||
"eject": "expo eject" | ||
}, | ||
"dependencies": { | ||
"expo": "^33.0.0", | ||
"haversine": "^1.1.1", | ||
"react": "16.8.3", | ||
"react-dom": "^16.8.6", | ||
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz", | ||
"react-native-material-menu": "^0.6.3", | ||
"react-native-web": "^0.11.4" | ||
}, | ||
"devDependencies": { | ||
"babel-preset-expo": "^5.1.1" | ||
}, | ||
"private": true | ||
} |
Oops, something went wrong.