Homepage improvements

This commit is contained in:
Keannu Bernasol 2023-07-26 10:03:25 +08:00
parent 22707b8372
commit b43577870b
3 changed files with 38 additions and 16 deletions

View file

@ -12,7 +12,7 @@ import {
export let backendURL = "";
export let backendURLWebsocket = "";
let use_production = true;
if (__DEV__ || !use_production) {
if (__DEV__ && !use_production) {
backendURL = "http://10.0.10.8:8000";
backendURLWebsocket = "ws://10.0.10.8:8000";
} else {
@ -25,6 +25,8 @@ const instance = axios.create({
timeout: 1000,
});
console.log(backendURL);
// App APIs
// Token Handling

View file

@ -19,8 +19,8 @@ export default function Home() {
const ustpCoords = {
latitude: 8.4857,
longitude: 124.6565,
latitudeDelta: 0.000235,
longitudeDelta: 0.000067,
latitudeDelta: 0.4,
longitudeDelta: 0.4,
};
async function requestLocation() {
const { status } = await Location.requestForegroundPermissionsAsync();
@ -62,27 +62,19 @@ export default function Home() {
let dist = GetDistance(
location.coords.latitude,
location.coords.longitude,
8.4857, // LatitudeDelta
124.6565 // LongitudeDelta
0.4,
0.4
);
setDist(Math.round(dist));
}
function CustomMap() {
if (dist && location) {
if (dist <= 1.5) {
if (dist >= 2) {
// Just switch this condition for map debugging
return (
<AnimatedMapView
style={styles.map}
mapType="none"
initialRegion={ustpCoords}
scrollEnabled={false}
zoomEnabled={false}
rotateEnabled={false}
followsUserLocation={true}
minZoomLevel={18}
toolbarEnabled={false}
customMapStyle={[
{
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
urlTemplate={urlProvider}
@ -106,7 +114,17 @@ export default function Home() {
latitude: location.coords.latitude,
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>
);
} else {
@ -145,6 +163,7 @@ export default function Home() {
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
loadingBackgroundColor={colors.secondary_2}
>
<UrlTile
urlTemplate={urlProvider}
@ -163,6 +182,7 @@ export default function Home() {
>
<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>

View file

@ -94,7 +94,7 @@ export default function Login() {
}
console.log(JSON.stringify(user_info));
} else {
console.log("heh", ParseLoginError(JSON.stringify(result[1])));
console.log(ParseLoginError(JSON.stringify(result[1])));
setError(ParseLoginError(JSON.stringify(result[1])));
}
});