mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Homepage improvements
This commit is contained in:
parent
22707b8372
commit
b43577870b
3 changed files with 38 additions and 16 deletions
|
@ -12,7 +12,7 @@ import {
|
||||||
export let backendURL = "";
|
export let backendURL = "";
|
||||||
export let backendURLWebsocket = "";
|
export let backendURLWebsocket = "";
|
||||||
let use_production = true;
|
let use_production = true;
|
||||||
if (__DEV__ || !use_production) {
|
if (__DEV__ && !use_production) {
|
||||||
backendURL = "http://10.0.10.8:8000";
|
backendURL = "http://10.0.10.8:8000";
|
||||||
backendURLWebsocket = "ws://10.0.10.8:8000";
|
backendURLWebsocket = "ws://10.0.10.8:8000";
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,6 +25,8 @@ const instance = axios.create({
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(backendURL);
|
||||||
|
|
||||||
// App APIs
|
// App APIs
|
||||||
|
|
||||||
// Token Handling
|
// Token Handling
|
||||||
|
|
|
@ -19,8 +19,8 @@ export default function Home() {
|
||||||
const ustpCoords = {
|
const ustpCoords = {
|
||||||
latitude: 8.4857,
|
latitude: 8.4857,
|
||||||
longitude: 124.6565,
|
longitude: 124.6565,
|
||||||
latitudeDelta: 0.000235,
|
latitudeDelta: 0.4,
|
||||||
longitudeDelta: 0.000067,
|
longitudeDelta: 0.4,
|
||||||
};
|
};
|
||||||
async function requestLocation() {
|
async function requestLocation() {
|
||||||
const { status } = await Location.requestForegroundPermissionsAsync();
|
const { status } = await Location.requestForegroundPermissionsAsync();
|
||||||
|
@ -62,27 +62,19 @@ export default function Home() {
|
||||||
let dist = GetDistance(
|
let dist = GetDistance(
|
||||||
location.coords.latitude,
|
location.coords.latitude,
|
||||||
location.coords.longitude,
|
location.coords.longitude,
|
||||||
8.4857, // LatitudeDelta
|
0.4,
|
||||||
124.6565 // LongitudeDelta
|
0.4
|
||||||
);
|
);
|
||||||
setDist(Math.round(dist));
|
setDist(Math.round(dist));
|
||||||
}
|
}
|
||||||
|
|
||||||
function CustomMap() {
|
function CustomMap() {
|
||||||
if (dist && location) {
|
if (dist && location) {
|
||||||
if (dist <= 1.5) {
|
if (dist >= 2) {
|
||||||
// Just switch this condition for map debugging
|
// Just switch this condition for map debugging
|
||||||
return (
|
return (
|
||||||
<AnimatedMapView
|
<AnimatedMapView
|
||||||
style={styles.map}
|
style={styles.map}
|
||||||
mapType="none"
|
|
||||||
initialRegion={ustpCoords}
|
|
||||||
scrollEnabled={false}
|
|
||||||
zoomEnabled={false}
|
|
||||||
rotateEnabled={false}
|
|
||||||
followsUserLocation={true}
|
|
||||||
minZoomLevel={18}
|
|
||||||
toolbarEnabled={false}
|
|
||||||
customMapStyle={[
|
customMapStyle={[
|
||||||
{
|
{
|
||||||
featureType: "poi",
|
featureType: "poi",
|
||||||
|
@ -93,6 +85,22 @@ export default function Home() {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
mapType="none"
|
||||||
|
scrollEnabled={true}
|
||||||
|
zoomEnabled={true}
|
||||||
|
toolbarEnabled={false}
|
||||||
|
rotateEnabled={false}
|
||||||
|
zoomControlEnabled
|
||||||
|
minZoomLevel={18}
|
||||||
|
zoomTapEnabled
|
||||||
|
followsUserLocation={true}
|
||||||
|
initialRegion={{
|
||||||
|
latitude: location.coords.latitude,
|
||||||
|
longitude: location.coords.longitude,
|
||||||
|
latitudeDelta: 0.4,
|
||||||
|
longitudeDelta: 0.4,
|
||||||
|
}}
|
||||||
|
loadingBackgroundColor={colors.secondary_2}
|
||||||
>
|
>
|
||||||
<UrlTile
|
<UrlTile
|
||||||
urlTemplate={urlProvider}
|
urlTemplate={urlProvider}
|
||||||
|
@ -106,7 +114,17 @@ export default function Home() {
|
||||||
latitude: location.coords.latitude,
|
latitude: location.coords.latitude,
|
||||||
longitude: location.coords.longitude,
|
longitude: location.coords.longitude,
|
||||||
}}
|
}}
|
||||||
/>
|
onPress={() => console.log(location)}
|
||||||
|
pinColor={colors.primary_1}
|
||||||
|
>
|
||||||
|
<Callout>
|
||||||
|
<Text style={styles.text_black_tiny}>
|
||||||
|
You are here {"\n"}
|
||||||
|
X: {Math.round(location.coords.longitude) + "\n"}
|
||||||
|
Z: {Math.round(location.coords.latitude)}
|
||||||
|
</Text>
|
||||||
|
</Callout>
|
||||||
|
</Marker>
|
||||||
</AnimatedMapView>
|
</AnimatedMapView>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,6 +163,7 @@ export default function Home() {
|
||||||
latitudeDelta: 0.0922,
|
latitudeDelta: 0.0922,
|
||||||
longitudeDelta: 0.0421,
|
longitudeDelta: 0.0421,
|
||||||
}}
|
}}
|
||||||
|
loadingBackgroundColor={colors.secondary_2}
|
||||||
>
|
>
|
||||||
<UrlTile
|
<UrlTile
|
||||||
urlTemplate={urlProvider}
|
urlTemplate={urlProvider}
|
||||||
|
@ -163,6 +182,7 @@ export default function Home() {
|
||||||
>
|
>
|
||||||
<Callout>
|
<Callout>
|
||||||
<Text style={styles.text_black_tiny}>
|
<Text style={styles.text_black_tiny}>
|
||||||
|
You are here {"\n"}
|
||||||
X: {Math.round(location.coords.longitude) + "\n"}
|
X: {Math.round(location.coords.longitude) + "\n"}
|
||||||
Z: {Math.round(location.coords.latitude)}
|
Z: {Math.round(location.coords.latitude)}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
|
@ -94,7 +94,7 @@ export default function Login() {
|
||||||
}
|
}
|
||||||
console.log(JSON.stringify(user_info));
|
console.log(JSON.stringify(user_info));
|
||||||
} else {
|
} else {
|
||||||
console.log("heh", ParseLoginError(JSON.stringify(result[1])));
|
console.log(ParseLoginError(JSON.stringify(result[1])));
|
||||||
setError(ParseLoginError(JSON.stringify(result[1])));
|
setError(ParseLoginError(JSON.stringify(result[1])));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue