added sliders on frontpage

This commit is contained in:
Viktor Søndergaard 2019-04-07 04:33:31 +02:00
parent 02d306f1c5
commit ca4c0fe1d9
5 changed files with 58 additions and 30 deletions

View File

@ -3784,6 +3784,11 @@
"nativescript-permissions": "^1.2.3"
}
},
"nativescript-checkbox": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/nativescript-checkbox/-/nativescript-checkbox-3.0.3.tgz",
"integrity": "sha1-H5oC4BvPi9fSd79IW8CvMa3jdcs="
},
"nativescript-dev-typescript": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/nativescript-dev-typescript/-/nativescript-dev-typescript-0.9.0.tgz",

View File

@ -23,6 +23,7 @@
"@angular/router": "~7.2.0",
"nativescript-angular": "~7.2.0",
"nativescript-camera": "^4.4.0",
"nativescript-checkbox": "^3.0.3",
"nativescript-geolocation": "^5.0.0",
"nativescript-powerinfo": "^1.0.7",
"nativescript-theme-core": "~1.0.4",

View File

@ -2,13 +2,14 @@
<ScrollView class="page">
<AbsoluteLayout>
<GridLayout rows="auto auto" columns="* *" class="m-5">
<Label class="h3 m-15" text="Is the Earth flat?" textWrap="true" row="0" col="0"></Label>
<Switch class="m-15" checked="false" (checkedChange)="toggleFlatEarth($event)" row="0" col="1"></Switch>
<Label class="h3 m-15" text="Are you in Australia?" textWrap="true" row="1" col="0"></Label>
<Switch class="m-15" checked="false" (checkedChange)="toggleIsAustralia($event)" row="1" col="1"></Switch>
</GridLayout>
<StackLayout class="float-btn-container">
<ns-my-button (tap)=onTap($event) text="Nightr"></ns-my-button>
</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>
</ScrollView>

View File

@ -1,12 +1,11 @@
import { Component, OnInit } from "@angular/core";
import * as dialogs from "tns-core-modules/ui/dialogs";
import { RouterExtensions } from "nativescript-angular/router";
import { TouchGestureEventData, GestureEventData } from 'tns-core-modules/ui/gestures'
import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, distance, clearWatch, Location } from "nativescript-geolocation";
import { GestureEventData } from 'tns-core-modules/ui/gestures'
import { Switch } from "tns-core-modules/ui/switch";
import * as appSettings from "tns-core-modules/application-settings";
import { MyHttpPostService } from '../services/my-http-post-service';
@Component({
selector: "home-page",
moduleId: module.id,
@ -15,29 +14,47 @@ import { MyHttpPostService } from '../services/my-http-post-service';
providers: [MyHttpPostService]
})
export class HomePageComponent implements OnInit {
returnMessage: string = "";
myReturnJSON: Object;
locationData: Location;
myPicture: String;
image: any;
flat_earth: boolean;
in_australia: boolean;
changeYes: boolean;
public toggleFlatEarthState = "Is the earth flat?";
public toggleIsAustraliaState = "Are you in Australia?";
isEarthFlat: boolean;
inAustralia: boolean;
constructor(private routerExtensions: RouterExtensions,
) { }
ngOnInit(): void {
}
public changeGenderMale(){
if(this.changeYes == true)
this.changeYes = false;
else
this.changeYes = true;
public toggleFlatEarth(args) {
console.log('Reached toggleFlatearch');
let firstSwitch = <Switch>args.object;
if (firstSwitch.checked) {
this.isEarthFlat = true;
appSettings.setBoolean("applicationIsEarthFlat", true);
} else {
this.isEarthFlat = false;
appSettings.setBoolean("applicationIsEarthFlat", false);
}
}
public toggleIsAustralia(args) {
let secondSwitch = <Switch>args.object;
if (secondSwitch.checked) {
this.inAustralia = true;
appSettings.setBoolean("applicationinAustralia", true);
} else {
this.inAustralia = false;
appSettings.setBoolean("applicationinAustralia", false);
console.log('isEarthflat', this.isEarthFlat);
}
}
public onTap(args: GestureEventData): void {
this.routerExtensions.navigateByUrl("/result-page");
let navigationExtras = {
queryParams: {
isEarthFlat: this.isEarthFlat,
inAustralia: this.inAustralia }
}
//console.log('this is inAustralia', this.inAustralia, 'This is isEarthFlat', this.isEarthFlat);
this.routerExtensions.navigateByUrl("/result-page"), navigationExtras;
}
}

View File

@ -6,6 +6,7 @@ import { MyBatteryInfoService } from '../services/my-battery-info.service';
import { MyCameraService } from '../services/my-camera-service'
import { RouterExtensions } from 'nativescript-angular/router';
import { Location } from 'nativescript-geolocation';
import * as appSettings from "tns-core-modules/application-settings";
class Reason {
constructor(public str: string, public causestring: string) {
@ -18,6 +19,7 @@ class Reason {
templateUrl: './result-page.component.html',
styleUrls: ['./result-page.component.css'],
moduleId: module.id,
providers: [MyHttpPostService]
})
export class ResultPageComponent implements OnInit {
returnMessage: string = "";
@ -61,7 +63,9 @@ public submit(): void {
private makePostRequest(): void {
this.myHttpPostSerivce
.postData({ position: this.locationData, image: this.image, flat_earth: true, in_australia: true, })
.postData({ position: this.locationData, image: this.image,
flat_earth: appSettings.getBoolean("applicationIsEarthFlat", false),
in_australia: appSettings.getBoolean("applicationinAustralia", false), })
.subscribe(res => {
//console.log('This is res', res);
this.JSONObject = res;