Small changes
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 116 KiB |
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 193 KiB |
|
@ -4,3 +4,13 @@
|
||||||
left: 90%;
|
left: 90%;
|
||||||
top: 160%;
|
top: 160%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.font-awesome {
|
||||||
|
font-family: "fontawesome-webfont";
|
||||||
|
font-size: 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
.radioBefore {
|
||||||
|
font-family: "fontawesome-webfont";
|
||||||
|
font-size: 24;
|
||||||
|
}
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
<ActionBar title="Home" class="action-bar"></ActionBar>
|
<ActionBar title="Nightr" class="action-bar"></ActionBar>
|
||||||
|
|
||||||
<ScrollView class="page">
|
<ScrollView class="page">
|
||||||
<AbsoluteLayout>
|
<AbsoluteLayout>
|
||||||
<StackLayout class="float-btn-container">
|
<StackLayout class="float-btn-container">
|
||||||
<ns-my-button (tap)=onTap($event) text="Nightr"></ns-my-button>
|
<ns-my-button (tap)=onTap($event) text="Nightr"></ns-my-button>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<StackLayout>
|
|
||||||
<ns-locationButton></ns-locationButton>
|
|
||||||
<ns-camera-button></ns-camera-button>
|
|
||||||
<Button class="btn btn-primary" text="Result page" [nsRouterLink]="['/result-page']"></Button>
|
|
||||||
</StackLayout>
|
|
||||||
</AbsoluteLayout>
|
</AbsoluteLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import * as dialogs from "tns-core-modules/ui/dialogs";
|
import * as dialogs from "tns-core-modules/ui/dialogs";
|
||||||
import { RouterExtensions } from "nativescript-angular/router";
|
import { RouterExtensions } from "nativescript-angular/router";
|
||||||
import { TouchGestureEventData, GestureEventData } from 'tns-core-modules/ui/gestures'
|
import { TouchGestureEventData, GestureEventData } from 'tns-core-modules/ui/gestures';
|
||||||
import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, distance, clearWatch, Location } from "nativescript-geolocation";
|
import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, distance, clearWatch, Location } from "nativescript-geolocation";
|
||||||
|
import { MyHttpPostService } from '../services/my-http-post-service';
|
||||||
import { MyHttpPostService } from '../services/my-http-post-service'
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -22,6 +21,7 @@ export class HomePageComponent implements OnInit {
|
||||||
image: any;
|
image: any;
|
||||||
flat_earth: boolean;
|
flat_earth: boolean;
|
||||||
in_australia: boolean;
|
in_australia: boolean;
|
||||||
|
changeYes: boolean;
|
||||||
|
|
||||||
constructor(private routerExtensions: RouterExtensions,
|
constructor(private routerExtensions: RouterExtensions,
|
||||||
) { }
|
) { }
|
||||||
|
@ -29,6 +29,13 @@ export class HomePageComponent implements OnInit {
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public changeGenderMale(){
|
||||||
|
if(this.changeYes == true)
|
||||||
|
this.changeYes = false;
|
||||||
|
else
|
||||||
|
this.changeYes = true;
|
||||||
|
}
|
||||||
|
|
||||||
public onTap(args: GestureEventData): void {
|
public onTap(args: GestureEventData): void {
|
||||||
this.routerExtensions.navigateByUrl("/result-page");
|
this.routerExtensions.navigateByUrl("/result-page");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,26 @@
|
||||||
.title-container
|
.h2
|
||||||
{
|
{
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
font-size: 30px;
|
font-size: 35px;
|
||||||
padding: 5px;
|
|
||||||
color: white;
|
color: white;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
.h1
|
||||||
|
{
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 100px;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.h3
|
||||||
|
{
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 20px;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
background-color: lightskyblue;
|
background-color: lightskyblue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
<ActionBar title="Result" class="action-bar"></ActionBar>
|
<ActionBar title="Nightr" class="action-bar"></ActionBar>
|
||||||
|
|
||||||
<StackLayout class="page" height="100%">
|
<StackLayout class="page" height="100%">
|
||||||
<StackLayout height="20%" class="title-container">
|
<StackLayout height="45%" class="title-container">
|
||||||
<Label text="{{night}}"></Label>
|
<Label text="{{itis}}" class="h3"></Label>
|
||||||
<Label text="{{percentage}}" textWrap="true"></Label>
|
<Label text="{{night}}" class="h1"></Label>
|
||||||
|
<Label text="{{percentage}}" textWrap="true" class="h2"></Label>
|
||||||
|
<Label text="{{hereswhy}}" class="h3"></Label>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<ScrollView height='80%'>
|
<ScrollView height='55%'>
|
||||||
<ListView [items]="reasons" class="list-group">
|
<ListView [items]="reasons" class="list-group">
|
||||||
<ng-template let-reason="item" let-i="index" let-odd="odd" let-even="even">
|
<ng-template let-reason="item" let-i="index" let-odd="odd" let-even="even">
|
||||||
<StackLayout orientation="vertical" class="list-group-item">
|
<StackLayout orientation="vertical" class="list-group-item">
|
||||||
|
@ -16,3 +17,4 @@
|
||||||
</ListView>
|
</ListView>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
<ActivityIndicator #activityIndicator [busy]="isBusy" originX ="0.5" originY="0.5" width="100" height="100" class="activity-indicator"></ActivityIndicator>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { MyHttpPostService } from '../services/my-http-post-service'
|
import { MyHttpPostService } from '../services/my-http-post-service';
|
||||||
import { MyGeoLocationService} from '../services/my-geo-location.service';
|
import { MyGeoLocationService} from '../services/my-geo-location.service';
|
||||||
import { MyBatteryInfoService } from '../services/my-battery-info.service';
|
import { MyBatteryInfoService } from '../services/my-battery-info.service';
|
||||||
import { MyCameraService } from '../services/my-camera-service'
|
import { MyCameraService } from '../services/my-camera-service';
|
||||||
import { RouterExtensions } from 'nativescript-angular/router';
|
import { RouterExtensions } from 'nativescript-angular/router';
|
||||||
import { Location } from 'nativescript-geolocation';
|
import { Location } from 'nativescript-geolocation';
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ class Reason {
|
||||||
})
|
})
|
||||||
export class ResultPageComponent implements OnInit {
|
export class ResultPageComponent implements OnInit {
|
||||||
returnMessage: string = "";
|
returnMessage: string = "";
|
||||||
|
isBusy: boolean;
|
||||||
myReturnJSON: Object;
|
myReturnJSON: Object;
|
||||||
locationData: Location;
|
locationData: Location;
|
||||||
myPicture: String;
|
myPicture: String;
|
||||||
|
@ -28,9 +29,12 @@ export class ResultPageComponent implements OnInit {
|
||||||
flat_earth: boolean;
|
flat_earth: boolean;
|
||||||
in_australia: boolean;
|
in_australia: boolean;
|
||||||
night: string = "";
|
night: string = "";
|
||||||
percentage: string = "";
|
percentage: string = "Calculating...";
|
||||||
|
hereswhy: string = "";
|
||||||
|
itis: string = "";
|
||||||
|
reasons: Array<Reason>;
|
||||||
JSONObject;
|
JSONObject;
|
||||||
public reasons: Array<Reason>;
|
|
||||||
|
|
||||||
constructor(private myHttpPostSerivce: MyHttpPostService,
|
constructor(private myHttpPostSerivce: MyHttpPostService,
|
||||||
private routerExtensions: RouterExtensions,
|
private routerExtensions: RouterExtensions,
|
||||||
|
@ -39,6 +43,8 @@ export class ResultPageComponent implements OnInit {
|
||||||
private cameraService: MyCameraService,){ }
|
private cameraService: MyCameraService,){ }
|
||||||
|
|
||||||
ngOnInit(): Promise<void> {
|
ngOnInit(): Promise<void> {
|
||||||
|
this.isBusy = true;
|
||||||
|
this.reasons = new Array<Reason>();
|
||||||
return this.cameraService.takePicture().
|
return this.cameraService.takePicture().
|
||||||
then(picture => {
|
then(picture => {
|
||||||
this.image = JSON.stringify(picture);
|
this.image = JSON.stringify(picture);
|
||||||
|
@ -60,15 +66,38 @@ public submit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
private makePostRequest(): void {
|
private makePostRequest(): void {
|
||||||
|
this.isBusy = true;
|
||||||
this.myHttpPostSerivce
|
this.myHttpPostSerivce
|
||||||
.postData({ position: this.locationData, image: this.image, flat_earth: true, in_australia: true, })
|
.postData({ position: this.locationData, image: this.image, flat_earth: true, in_australia: true, })
|
||||||
.subscribe(res => {
|
.subscribe(res => {
|
||||||
//console.log('This is res', res);
|
console.log('This is res', res);
|
||||||
this.JSONObject = res;
|
this.JSONObject = res;
|
||||||
|
this.isBusy = false;
|
||||||
|
this.addToArray();
|
||||||
//console.log('THis is myreturnJSON', this.myReturnJSON);
|
//console.log('THis is myreturnJSON', this.myReturnJSON);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public addToArray(): void {
|
||||||
|
|
||||||
|
if (this.JSONObject.night) {
|
||||||
|
this.night = "NIGHT";
|
||||||
|
} else {
|
||||||
|
this.night = "DAY";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.percentage = "At least we are "+Math.floor(this.JSONObject.weighted_probabilities_mean*100)+"% sure"
|
||||||
|
for (let i = 0; i < this.JSONObject.predictions.length; i++) {
|
||||||
|
var causestring = ""
|
||||||
|
for (let j = 0; j < this.JSONObject.predictions[i].reasons.length; j++) {
|
||||||
|
causestring = causestring + " - " + this.JSONObject.predictions[i].reasons[j] + "\n";
|
||||||
|
}
|
||||||
|
this.itis = "It is"
|
||||||
|
this.hereswhy = "Here's why:"
|
||||||
|
this.reasons.push(new Reason(""+Math.round(this.JSONObject.predictions[i].contribution*100)+"% - " + this.JSONObject.predictions[i].name, causestring));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
goBack(): void {
|
goBack(): void {
|
||||||
this.routerExtensions.back();
|
this.routerExtensions.back();
|
||||||
}
|
}
|
||||||
|
|