Skip to content

Commit

Permalink
refactor: lint test apps
Browse files Browse the repository at this point in the history
  • Loading branch information
sis0k0 committed Mar 22, 2017
1 parent 150c1ce commit c7837ed
Show file tree
Hide file tree
Showing 62 changed files with 788 additions and 446 deletions.
25 changes: 10 additions & 15 deletions ng-sample/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
//import "globals";
// import "./modules";
//global.registerModule("./main-page", function () { return require("./main-page"); });
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { NativeScriptAnimationsModule } from "nativescript-angular/animations";

//import * as profiling from "./profiling";
//profiling.start("application-start");

// "nativescript-angular/application" import should be first in order to load some required settings (like globals and reflect-metadata)
import { NativeScriptModule, platformNativeScriptDynamic } from "nativescript-angular/platform";
import { onAfterLivesync, onBeforeLivesync } from "nativescript-angular/platform-common";
import { NgModule } from "@angular/core";
import { Router } from "@angular/router";
Expand Down Expand Up @@ -69,9 +64,9 @@ import { AnimationStatesTest } from "./examples/animation/animation-states-test"
class ExampleModule { }

function makeExampleModule(componentType) {
let imports: any[] = [ExampleModule];
let imports: any[] = [ExampleModule, NativeScriptAnimationsModule];
if (componentType.routes) {
imports.push(NativeScriptRouterModule.forRoot(componentType.routes))
imports.push(NativeScriptRouterModule.forRoot(componentType.routes));
}
let exports: any[] = [];
if (componentType.exports) {
Expand Down Expand Up @@ -111,7 +106,7 @@ const customPageFactoryProvider = {
}
};

platformNativeScriptDynamic().bootstrapModule(makeExampleModule(RendererTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(RendererTest));
// platformNativeScriptDynamic(undefined, [customPageFactoryProvider]).bootstrapModule(makeExampleModule(RendererTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(TabViewTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(Benchmark));
Expand All @@ -135,10 +130,10 @@ platformNativeScriptDynamic().bootstrapModule(makeExampleModule(RendererTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationStatesTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationNgClassTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationKeyframesTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));

//Livesync test
var cachedUrl: string;
// Livesync test
let cachedUrl: string;
onBeforeLivesync.subscribe((moduleRef) => {
console.log("------- onBeforeLivesync");
if (moduleRef) {
Expand All @@ -157,5 +152,5 @@ onAfterLivesync.subscribe((moduleRef) => {
}
});

//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LivesyncApp));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LivesyncApp));
console.log("APP RESTART");
17 changes: 7 additions & 10 deletions ng-sample/app/examples/action-bar/action-bar-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { Page} from "ui/page";
import { Component } from "@angular/core";
import { Page } from "ui/page";

@Component({
selector: "first",
Expand Down Expand Up @@ -29,7 +29,6 @@ class FirstComponent {
@Component({
selector: "nested-component",
template: `
<ActionBarExtension>
<ActionItem *ngIf="show" (tap)="onTap()">
<Button text="CUSTOM"></Button>
Expand Down Expand Up @@ -70,7 +69,7 @@ class SecondComponent {
}

@Component({
selector: 'action-bar-test',
selector: "action-bar-test",
template: `
<GridLayout>
<page-router-outlet></page-router-outlet>
Expand All @@ -79,14 +78,12 @@ class SecondComponent {
})
export class ActionBarTest {
static routes = [
{ path: '', component: FirstComponent },
{ path: 'second', component: SecondComponent },
]
{ path: "", component: FirstComponent },
{ path: "second", component: SecondComponent },
];

static entries = [
FirstComponent,
SecondComponent,
]
];
}


30 changes: 15 additions & 15 deletions ng-sample/app/examples/animation/animation-enter-leave-test.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import {Component, trigger, style, animate, state, transition } from '@angular/core';
import {Component, trigger, style, animate, state, transition } from "@angular/core";

@Component({
selector: 'animation-enter-leave',
templateUrl: './examples/animation/animation-enter-leave-test.html',
styleUrls: [ './examples/animation/animation-enter-leave-test.css' ],
selector: "animation-enter-leave",
templateUrl: "./examples/animation/animation-enter-leave-test.html",
styleUrls: [ "./examples/animation/animation-enter-leave-test.css" ],
animations: [
trigger('state', [
state('in', style({ 'background-color': 'red', 'opacity': 1 })),
state('void', style({ 'background-color': 'white', 'opacity': 0 })),
transition('void => *', [ animate('600ms ease-out') ]),
transition('* => void', [ animate('600ms ease-out')])
trigger("state", [
state("in", style({ "background-color": "red", "opacity": 1 })),
state("void", style({ "background-color": "white", "opacity": 0 })),
transition("void => *", [ animate("600ms ease-out") ]),
transition("* => void", [ animate("600ms ease-out")])
])
]
})
export class AnimationEnterLeaveTest {

public items: Array<string>;

constructor() {
this.items = [];
for (var i = 0; i < 3; i++) {
for (let i = 0; i < 3; i++) {
this.items.push("Item " + i);
}
}

onAddTap() {
this.items.push("Item " + (this.items.length + 1));
}

onRemoveAllTap() {
this.items = [];
}

onItemTap(event) {
var index = this.items.indexOf(event.object.text);
let index = this.items.indexOf(event.object.text);
this.items.splice(index, 1);
}
}
Expand Down
30 changes: 15 additions & 15 deletions ng-sample/app/examples/animation/animation-keyframes-test.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { Component } from '@angular/core';
import { trigger, style, animate, state, transition, keyframes } from '@angular/animations';
import { Component } from "@angular/core";
import { trigger, style, animate, state, transition, keyframes } from "@angular/animations";

@Component({
selector: 'animation-states',
selector: "animation-states",
template: `
<StackLayout>
<Button text="Touch me!" [@state]=" isOn ? 'active' : 'inactive' " (tap)="onTap()"></Button>
</StackLayout>`,
animations: [
trigger('state', [
state('active', style({ opacity: 1 })),
state('inactive', style({ opacity: 0.2 })),
transition('inactive => active', [
trigger("state", [
state("active", style({ opacity: 1 })),
state("inactive", style({ opacity: 0.2 })),
transition("inactive => active", [
animate(300, keyframes([
style({opacity: 0.2, transform: 'translateX(-100)', offset: 0}),
style({opacity: 1, transform: 'translateX(15)', offset: 0.3}),
style({opacity: 1, transform: 'translateX(0)', offset: 1.0})
style({opacity: 0.2, transform: "translateX(-100),translateY(100)", offset: 0}),
style({opacity: 1, transform: "translateX(15)", offset: 0.3}),
style({opacity: 1, transform: "translateX(0)", offset: 1.0})
]))
]),
transition('active => inactive', [
transition("active => inactive", [
animate(300, keyframes([
style({opacity: 1, transform: 'translateX(0)', offset: 0}),
style({opacity: 1, transform: 'translateX(-15)', offset: 0.7}),
style({opacity: 0.2, transform: 'translateX(100)', offset: 1.0})
style({opacity: 1, transform: "translateX(0)", offset: 0}),
style({opacity: 1, transform: "translateX(-15)", offset: 0.7}),
style({opacity: 0.2, transform: "translateX(100)", offset: 1.0})
]))
])
])
]
})
export class AnimationKeyframesTest {

isOn = false;

onTap() {
Expand Down
7 changes: 1 addition & 6 deletions ng-sample/app/examples/animation/animation-ngclass-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ export class AnimationNgClassTest {

onTap() {
this.isOn = !this.isOn;
if (this.isOn) {
this.text = "Toggled";
}
else {
this.text = "Normal";
}
this.text = this.isOn ? "Toggled" : "Normal";
}
}
16 changes: 8 additions & 8 deletions ng-sample/app/examples/animation/animation-states-test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {Component, trigger, style, animate, state, transition } from '@angular/core';
import {Component, trigger, style, animate, state, transition } from "@angular/core";

@Component({
selector: 'animation-states',
selector: "animation-states",
template: `
<StackLayout>
<Button text="Touch me!" [@state]=" isOn ? 'active' : 'inactive' " (tap)="onTap()"></Button>
</StackLayout>`,
animations: [
trigger('state', [
state('inactive', style({ 'background-color': 'red' })),
state('active', style({ 'background-color': 'green' })),
transition('inactive => active', [ animate('600ms ease-out') ]),
transition('active => inactive', [ animate('600ms ease-out') ]),
trigger("state", [
state("inactive", style({ "background-color": "red" })),
state("active", style({ "background-color": "green" })),
transition("inactive => active", [ animate("600ms ease-out") ]),
transition("active => inactive", [ animate("600ms ease-out") ]),
])
]
})
export class AnimationStatesTest {

isOn = false;

onTap() {
Expand Down
20 changes: 11 additions & 9 deletions ng-sample/app/examples/http/http-test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import {Component} from '@angular/core';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';
import {Component} from "@angular/core";
import {Http} from "@angular/http";
import "rxjs/add/operator/map";

/* IMPORTANT
In order to test out the full image example, to fix the App Transport Security error in iOS 9, you will need to follow this after adding the iOS platform:
In order to test out the full image example,
to fix the App Transport Security error in iOS 9,
you will need to follow this after adding the iOS platform:
https://blog.nraboy.com/2015/12/fix-ios-9-app-transport-security-issues-in-nativescript/
*/

@Component({
selector: 'http-test',
selector: "http-test",
template: `
<StackLayout horizontalAlignment="center">
<Button text="Load Local File with Http" (tap)='loadLocal()' cssClass="btn-primary"></Button>
Expand All @@ -28,12 +30,12 @@ export class HttpTest {
public title: string;
public description: string;

constructor(private http: Http) {
constructor(private http: Http) {

}

public loadLocal() {
this.http.get('~/examples/http/data.json').map(res => res.json()).subscribe((response: any) => {
this.http.get("~/examples/http/data.json").map(res => res.json()).subscribe((response: any) => {
let user = response.results[0];
this.title = user.title;
this.description = user.description;
Expand Down
26 changes: 14 additions & 12 deletions ng-sample/app/examples/image/image-test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {Component} from '@angular/core';
import { Component } from "@angular/core";

/* IMPORTANT
In order to test out the full image example, to fix the App Transport Security error in iOS 9, you will need to follow this after adding the iOS platform:
In order to test out the full image example,
to fix the App Transport Security error in iOS 9,
you will need to follow this after adding the iOS platform:
https://blog.nraboy.com/2015/12/fix-ios-9-app-transport-security-issues-in-nativescript/
*/

@Component({
selector: 'image-test',
selector: "image-test",
template: `
<StackLayout horizontalAlignment="center">
<Image [src]="currentImage" width="300" height="300"></Image>
Expand All @@ -22,19 +24,19 @@ https://blog.nraboy.com/2015/12/fix-ios-9-app-transport-security-issues-in-nativ
`
})
export class ImageTest {

public currentImage: string;
private images: Array<string> = [
'res://300x300.jpg',
'~/examples/image/img/Default.png',
'http://www.codeproject.com/KB/mobile/883465/NativeScript.png'
"res://300x300.jpg",
"~/examples/image/img/Default.png",
"http://www.codeproject.com/KB/mobile/883465/NativeScript.png"
];
private cnt: number = 0;

constructor() {
constructor() {
this.currentImage = this.images[this.cnt];
}

changeImage(direction: number) {
if (direction > 0) {
this.cnt++;
Expand All @@ -50,12 +52,12 @@ export class ImageTest {
}
this.currentImage = this.images[this.cnt];
}

addImage(e: any, name: string): void {
if (name.indexOf('http') === -1) {
if (name.indexOf("http") === -1) {
alert(`Must be a valid url to an image starting with 'http'!`);
} else {
this.images.push(name);
this.images.push(name);
this.currentImage = this.images[this.images.length - 1];
}
}
Expand Down
11 changes: 6 additions & 5 deletions ng-sample/app/examples/list/data.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable } from "@angular/core";
import { BehaviorSubject } from "rxjs/BehaviorSubject";

export class DataItem {
Expand All @@ -10,13 +10,13 @@ export class DataService {
private _intervalId;
private _counter = 0;
private _currentItems: Array<DataItem>;

public items$: BehaviorSubject<Array<DataItem>>;

constructor() {
this._currentItems = [];
for (var i = 0; i < 3; i++) {
this.appendItem()
for (let i = 0; i < 3; i++) {
this.appendItem();
}

this.items$ = new BehaviorSubject(this._currentItems);
Expand Down Expand Up @@ -51,4 +51,5 @@ export class DataService {
this._currentItems.push(new DataItem(this._counter, "data item " + this._counter));
this._counter++;
}
}
}

Loading

0 comments on commit c7837ed

Please sign in to comment.