Skip to content

Commit

Permalink
start
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Green authored and Matt Green committed Jan 17, 2016
1 parent 6347e32 commit 9bdcf7f
Show file tree
Hide file tree
Showing 14 changed files with 276 additions and 37 deletions.
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

Expand All @@ -26,9 +20,13 @@ build/Release
# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules
app/**/*.js
app/**/*.map
platforms

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
*.tgz
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
"args": [],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
26 changes: 24 additions & 2 deletions app/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions app/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import frame = require("ui/frame");
import application = require("application");

if(application.android) {
application.onLaunch = function (intent) {
console.log("onLaunch");

application.android.onActivityStarted = function (activity) {
console.log("onStarted");
var window = activity.getWindow();
if (window) {
window.setBackgroundDrawable(null);
}
}
}
}

if (application.ios) {
application.on("launch", args => {
// TODO: It would be nice if this was ios-specific property on the action bar and static property on application.ios.
//UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.UIStatusBarStyleLightContent;
setTimeout(() => {
//UIApplication.sharedApplication().keyWindow.backgroundColor = UIColor.blackColor();
}, 1);
});
}

application.mainModule = "pages/startPage";
// application.mainModule = "profile-main";
application.start();
6 changes: 0 additions & 6 deletions app/main-page.js

This file was deleted.

21 changes: 0 additions & 21 deletions app/main-view-model.js

This file was deleted.

43 changes: 43 additions & 0 deletions app/pages/startPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {Observable} from "data/observable"
// var observable = require("data/observable");
// var HelloWorldModel = (function (_super) {
// __extends(HelloWorldModel, _super);
// function HelloWorldModel() {
// _super.call(this);
// this.counter = 42;
// this.set("message", this.counter + " taps left");
// }
// HelloWorldModel.prototype.tapAction = function () {
// this.counter--;
// if (this.counter <= 0) {
// this.set("message", "Hoorraaay! You unlocked the NativeScript clicker achievement!");
// }
// else {
// this.set("message", this.counter + " taps left");
// }
// };
// return HelloWorldModel;
// })(observable.Observable);
// exports.HelloWorldModel = HelloWorldModel;
// exports.mainViewModel = new HelloWorldModel();

export class MainPageViewModel extends Observable
{
constructor()
{
super();
}

public tapAction()
{
this.set
}
}

//var vmModule = require("./main-view-model");
function pageLoaded(args) {
var page = args.object;
var vm = new MainPageViewModel();
page.bindingContext =vm;
}
exports.pageLoaded = pageLoaded;
File renamed without changes.
137 changes: 137 additions & 0 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
var path = require("path");
var fs = require("fs");

module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-shell');

var nsDistPath = process.env.NSDIST || './deps/NativeScript/bin/dist';

var androidAvd = grunt.option('avd') || "nexus"
var genyDevice = grunt.option('geny') || "nexus7"
var iOSDevice = grunt.option('device') || "iPhone-6"
var androidPlatfrom = "platforms/android/";

var hasAndroidPlatform = false;
try {
hasAndroidPlatform = fs.statSync(androidPlatfrom) && fs.statSync(androidPlatfrom).isDirectory();
}
catch (e) {
// ...
}

grunt.initConfig({
ts: {
build: {
tsconfig: './app/tsconfig.json',
options: {
fast: "never",
compiler: "node_modules/typescript/bin/tsc"
},
},
},
copy: {
widgets: {
src: "widgets.jar",
dest: path.join(androidPlatfrom, "libs") + "/",
cwd: "deps/android-widgets",
expand: true
},
localInstallModules: {
src: "<%= nsPackagePath %>",
dest: "deps/tns-core-modules.tgz"
}
},
clean: {
app: {
cwd: 'app',
expand: true,
src: [
'**/*.js',
'**/*.map',
]
},
nodeModulesGz: {
// HACK: Work around a {N} CLI bug that prevents you from using
// NPM packages containing *.gz files.
// https://github.com/NativeScript/nativescript-cli/issues/393
expand: true,
cwd: './node_modules',
src: [
'**/*.gz',
]
},
},
shell: {
depNSInit: {
command: [
'npm install',
'grunt --no-runtslint',
].join('&&'),
options: {
execOptions: {
cwd: 'deps/NativeScript',
}
}
},
localInstallModules: {
command: "npm install 'deps/tns-core-modules.tgz'"
},
emulateGeny: {
command: "tns emulate android --geny '" + genyDevice + "'"
},
emulateAndroid: {
command: "tns emulate android --avd '" + androidAvd + "'"
},
emulateIOS: {
command: "tns emulate ios --device '" + iOSDevice + "'"
},
removeAndroid: {
command: "tns platform remove android"
},
addAndroid: {
command: "tns platform add android"
}
}
});

grunt.registerTask("updateModules", [
"getNSPackage",
"copy:localInstallModules",
"shell:localInstallModules",
]);

grunt.registerTask("getNSPackage", function () {
var packageFiles = grunt.file.expand({
cwd: nsDistPath
}, [
'tns-core-modules*.tgz'
]);
var nsPackagePath = path.join(nsDistPath, packageFiles[0]);
grunt.config('nsPackagePath', nsPackagePath);
});

grunt.registerTask("app", [
"ts:build",
]);

// Copy custom version of widgets.jar to be up to date
grunt.registerTask("fix-android-widgets", hasAndroidPlatform ? ["copy:widgets"] : [])
grunt.registerTask("prepare", [
"shell:depNSInit",
"updateModules",
"clean:nodeModulesGz",
"fix-android-widgets"
]);

grunt.registerTask("app-full", [
"clean:app",
"app",
]);

grunt.registerTask("refresh-android", ["shell:removeAndroid", "shell:addAndroid", "fix-android-widgets"])
grunt.registerTask("run-android", ["app", "shell:emulateAndroid"])
grunt.registerTask("run-ios", ["app", "shell:emulateIOS"])
}
1 change: 1 addition & 0 deletions hooks/before-prepare/nativescript-dev-typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("nativescript-dev-typescript/lib/before-prepare.js");
1 change: 1 addition & 0 deletions hooks/before-watch/nativescript-dev-typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("nativescript-dev-typescript/lib/watch.js");
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
},
"dependencies": {
"tns-core-modules": "1.5.1",
"nativescript-angular": "~0.0.20",
"nativescript-dev-typescript": "~0.2.3"
"nativescript-angular": "~0.0.20"
},
"devDependencies": {
"typescript": "^1.7.5",
"grunt": "0.4.5",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-copy": "0.8.0",
"grunt-shell": "1.1.2",
"grunt-ts": "5.0.0-beta.5",
"nativescript-dev-typescript": "~0.2.3",
"shelljs": "^0.5.3"
}
}
1 change: 1 addition & 0 deletions references.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" /> Needed for autocompletion and compilation.
13 changes: 13 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"inlineSourceMap": true,
"experimentalDecorators": true,
"noEmitHelpers": true
},
"exclude": [
"node_modules",
"platforms"
]
}

0 comments on commit 9bdcf7f

Please sign in to comment.