This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community.
Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it.
https://www.freifunk-altdorf.de
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.4 KiB
71 lines
2.4 KiB
import React, { Component } from 'react' |
|
import { View, Text, Switch, StyleSheet } from 'react-native' |
|
import { PermissionsAndroid } from 'react-native'; |
|
|
|
|
|
class SwichExample extends Component { |
|
constructor(props) { |
|
super(props); |
|
|
|
this.state = { |
|
latitude: null, |
|
longitude: null, |
|
error: null, |
|
}; |
|
} |
|
async requestLocationPermission() { |
|
const chckLocationPermission = PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION); |
|
if (chckLocationPermission === PermissionsAndroid.RESULTS.GRANTED) { |
|
alert("You've access for the location"); |
|
} else { |
|
try { |
|
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, |
|
{ |
|
'title': 'Cool Location App required Location permission', |
|
'message': 'We required Location permission in order to get device location ' + |
|
'Please grant us.' |
|
} |
|
) |
|
if (granted === PermissionsAndroid.RESULTS.GRANTED) { |
|
alert("You've access for the location"); |
|
} else { |
|
alert("You don't have access for the location"); |
|
} |
|
} catch (err) { |
|
alert(err) |
|
} |
|
} |
|
}; |
|
|
|
|
|
|
|
componentDidMount() { |
|
navigator.geolocation.getCurrentPosition( |
|
(position) => { |
|
this.setState({ |
|
latitude: position.coords.latitude, |
|
longitude: position.coords.longitude, |
|
error: null, |
|
}); |
|
}, |
|
(error) => this.setState({ error: error.message }), |
|
{ enableHighAccuracy: false, timeout: 20000, maximumAge: 1000 }, |
|
); |
|
} |
|
|
|
render() { |
|
|
|
return ( |
|
<View style={{ flexGrow: 1, alignItems: 'center', justifyContent: 'center' }}> |
|
<Text |
|
onPress={() => this.requestLocationPermission()}> |
|
Request Location Permission |
|
</Text> |
|
<Text>Latitude: {this.state.latitude}</Text> |
|
<Text style={{paddingBottom: 10}}>Longitude: {this.state.longitude}</Text> |
|
{this.state.error ? <Text>Error: {this.state.error}</Text> : null} |
|
</View> |
|
) |
|
} |
|
} |
|
export default SwichExample;
|
|
|