-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Xcode 8.3 and Swift 3.x support as well as Android!
closes #2
- Loading branch information
1 parent
08a2a13
commit fcd9874
Showing
173 changed files
with
3,618 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
demo/ | ||
demo-ng/ | ||
*.png | ||
*.log | ||
*.map | ||
*.ts | ||
!.d.ts | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.svn": true, | ||
"**/.hg": true, | ||
"**/CVS": true, | ||
"**/.DS_Store": true, | ||
// "**/*.js": { | ||
// "when": "$(basename).ts" | ||
// } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ContentView } from 'tns-core-modules/ui/content-view'; | ||
export interface IConfettiTypes { | ||
confetti: number; | ||
triangle: number; | ||
star: number; | ||
diamond: number; | ||
image: number; | ||
} | ||
export declare abstract class ConfettiViewBase extends ContentView { | ||
static Types: IConfettiTypes; | ||
startConfetti(): void; | ||
stopConfetti(): void; | ||
colors: Array<any>; | ||
intensity: number; | ||
fullScreen: boolean; | ||
readonly confetti: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ContentView } from 'tns-core-modules/ui/content-view'; | ||
|
||
export interface IConfettiTypes { | ||
confetti: number; | ||
triangle: number; | ||
star: number; | ||
diamond: number; | ||
image: number; | ||
} | ||
|
||
export abstract class ConfettiViewBase extends ContentView { | ||
public static Types: IConfettiTypes; | ||
|
||
public startConfetti() { } | ||
|
||
public stopConfetti() { } | ||
|
||
public set colors(value: Array<any>) { } | ||
|
||
public set intensity(value: number) { } | ||
|
||
public set fullScreen(value: boolean) { } | ||
|
||
public get fullScreen() { return false; } | ||
|
||
public get confetti() { return null; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { IConfettiTypes, ConfettiViewBase } from './common'; | ||
export declare class ConfettiView extends ConfettiViewBase { | ||
static Types: IConfettiTypes; | ||
private _confetti; | ||
private _container; | ||
private _intensity; | ||
private _active; | ||
private _autoStart; | ||
private _fullScreen; | ||
private _colors; | ||
constructor(); | ||
createNativeView(): any; | ||
initNativeView(): void; | ||
destroyNativeView(): void; | ||
startConfetti(): void; | ||
stopConfetti(): void; | ||
container: any; | ||
colors: Array<string>; | ||
intensity: number; | ||
fullScreen: boolean; | ||
readonly confetti: any; | ||
onLayout(left: number, top: number, right: number, bottom: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { topmost } from 'tns-core-modules/ui/frame'; | ||
import { ContentView } from 'tns-core-modules/ui/content-view'; | ||
import { StackLayout } from 'tns-core-modules/ui/layouts/stack-layout'; | ||
import { Color } from 'tns-core-modules/color'; | ||
import { setTimeout } from 'tns-core-modules/timer'; | ||
import { IConfettiTypes, ConfettiViewBase } from './common'; | ||
|
||
declare var com; | ||
const CommonConfetti = com.github.jinatonic.confetti.CommonConfetti; | ||
|
||
export class ConfettiView extends ConfettiViewBase { | ||
|
||
public static Types: IConfettiTypes; // not common! prob remove | ||
|
||
private _confetti: any; | ||
private _container: any; | ||
private _intensity: number = 0.5; | ||
private _active: boolean = false; | ||
private _autoStart: boolean = true; | ||
private _fullScreen: boolean = false; | ||
private _colors: Array<string> = ['#f9583c', '#dd355b']; | ||
|
||
initNativeView() { | ||
|
||
setTimeout(() => { | ||
// wait until measurements of container are ready | ||
// TODO: need new lifecycle hook for this on Android | ||
let intArray = Array.create('int', this._colors.length); | ||
for (let i = 0; i < this._colors.length; i++) { | ||
intArray[i] = new Color(this._colors[i]).android; | ||
} | ||
this._confetti = CommonConfetti.rainingConfetti(this.container, intArray); | ||
if (this._autoStart) { | ||
this.startConfetti(); | ||
} | ||
}, 1000); | ||
} | ||
|
||
destroyNativeView() { | ||
this.stopConfetti(); | ||
this._container = null; | ||
this._confetti = null; | ||
} | ||
|
||
public startConfetti() { | ||
if (this._confetti) { | ||
this._confetti.infinite(); | ||
} | ||
} | ||
|
||
public stopConfetti() { | ||
if (this._confetti) { | ||
this._confetti.getConfettiManager().terminate(); | ||
} | ||
} | ||
|
||
public set container(value: any) { | ||
this._container = value.android; | ||
} | ||
|
||
public get container() { | ||
// use android view parent as the default | ||
return this._container || this.parent.android; | ||
} | ||
|
||
public set colors(value: Array<string>) { | ||
this._colors = value; | ||
} | ||
|
||
public set intensity(value: number) { } | ||
|
||
public set fullScreen(value: boolean) { } | ||
|
||
public get fullScreen(): boolean { return false; } | ||
|
||
public get confetti(): any { return this._confetti; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
export declare class ConfettiView { | ||
private _confettiView; | ||
import { IConfettiTypes, ConfettiViewBase } from './common'; | ||
export declare class ConfettiView extends ConfettiViewBase { | ||
static Types: IConfettiTypes; | ||
private _colors; | ||
private _confetti; | ||
private _intensity; | ||
private _active; | ||
constructor(); | ||
private _autoStart; | ||
private _fullScreen; | ||
createNativeView(): any; | ||
initNativeView(): void; | ||
destroyNativeView(): void; | ||
startConfetti(): void; | ||
stopConfetti(): void; | ||
intensity(intensity: number): void; | ||
colors(colors: Array<any>): void; | ||
colors: Array<any>; | ||
intensity: number; | ||
fullScreen: boolean; | ||
readonly confetti: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,103 @@ | ||
import {topmost} from 'ui/frame'; | ||
import { topmost } from 'tns-core-modules/ui/frame'; | ||
import { ContentView } from 'tns-core-modules/ui/content-view'; | ||
import { IConfettiTypes, ConfettiViewBase } from './common'; | ||
|
||
declare var SAConfettiView: any; | ||
export class ConfettiView extends ConfettiViewBase { | ||
|
||
export class ConfettiView { | ||
|
||
private _confettiView: any; | ||
public static Types: IConfettiTypes = { | ||
confetti: ConfettiType.Confetti, | ||
triangle: ConfettiType.Triangle, | ||
star: ConfettiType.Star, | ||
diamond: ConfettiType.Diamond, | ||
image: ConfettiType.Image | ||
} | ||
|
||
private _colors:Array<UIColor> = [ | ||
private _colors: Array<UIColor> = [ | ||
UIColor.colorWithRedGreenBlueAlpha(0.95, 0.40, 0.27, 1.0), | ||
UIColor.colorWithRedGreenBlueAlpha(1.00, 0.78, 0.36, 1.0), | ||
UIColor.colorWithRedGreenBlueAlpha(0.48, 0.78, 0.64, 1.0), | ||
UIColor.colorWithRedGreenBlueAlpha(0.30, 0.76, 0.85, 1.0), | ||
UIColor.colorWithRedGreenBlueAlpha(0.58, 0.39, 0.55, 1.0) | ||
]; | ||
private _confetti: any; | ||
private _intensity: number = 0.5; | ||
private _active: boolean = false; | ||
private _autoStart: boolean = true; | ||
private _fullScreen: boolean = false; | ||
|
||
constructor() { | ||
this._confettiView = new SAConfettiView(topmost()); | ||
this._confettiView.colors = this._colors; | ||
this._confettiView.itensity = this._intensity; | ||
topmost().currentPage.ios.view.addSubview(this._confettiView); | ||
createNativeView() { | ||
const confetti = SAConfettiView.new(); | ||
if (this._fullScreen) { | ||
// use dummy view | ||
this.nativeView = UIView.alloc().init(); | ||
this._confetti = confetti; | ||
rootVC().view.addSubview(confetti); | ||
} else { | ||
this.nativeView = confetti; | ||
} | ||
return this.nativeView; | ||
} | ||
|
||
initNativeView() { | ||
const confetti = this._confetti || this.nativeView; | ||
confetti.colors = this._colors; | ||
confetti.itensity = this._intensity; | ||
if (this._autoStart) { | ||
this.startConfetti(); | ||
} | ||
} | ||
|
||
destroyNativeView() { | ||
if (this.confetti) { | ||
this.stopConfetti(); | ||
if (this._fullScreen) { | ||
this.confetti.removeFromSuperview(); | ||
} | ||
} | ||
} | ||
|
||
public startConfetti() { | ||
if(this._confettiView && !this._active) { | ||
this._confettiView.startConfetti(); | ||
if (this.confetti && !this._active) { | ||
this.confetti.startConfetti(); | ||
this._active = true; | ||
} | ||
} | ||
|
||
public stopConfetti() { | ||
if(this._confettiView && this._active) { | ||
this._confettiView.stopConfetti(); | ||
if (this.confetti && this._active) { | ||
this.confetti.stopConfetti(); | ||
this._active = false; | ||
} | ||
} | ||
|
||
public intensity(intensity: number) { | ||
if(this._confettiView) { | ||
this._confettiView.intensity = intensity; | ||
public set colors(value: Array<any>) { | ||
this._colors = value; | ||
if (this.confetti) { | ||
this.confetti.colors = value; | ||
} | ||
} | ||
|
||
public colors(colors: Array<any>) { | ||
if(this._confettiView) { | ||
this._confettiView.colors = colors; | ||
public set intensity(value: number) { | ||
this._intensity = value; | ||
if (this.confetti) { | ||
this.confetti.intensity = value; | ||
} | ||
} | ||
|
||
public set fullScreen(value: boolean) { | ||
this._fullScreen = value; | ||
} | ||
|
||
public get fullScreen() { | ||
return this._fullScreen; | ||
} | ||
|
||
public get confetti() { | ||
return this._confetti || this.nativeView; | ||
} | ||
} | ||
|
||
const rootVC = function() { | ||
let appWindow = UIApplication.sharedApplication.keyWindow; | ||
return appWindow.rootViewController; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="__PACKAGE__" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
|
||
<supports-screens | ||
android:smallScreens="true" | ||
android:normalScreens="true" | ||
android:largeScreens="true" | ||
android:xlargeScreens="true"/> | ||
|
||
<uses-sdk | ||
android:minSdkVersion="17" | ||
android:targetSdkVersion="__APILEVEL__"/> | ||
|
||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
|
||
<application | ||
android:name="com.tns.NativeScriptApplication" | ||
android:allowBackup="true" | ||
android:icon="@drawable/icon" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme"> | ||
|
||
<activity | ||
android:name="com.tns.NativeScriptActivity" | ||
android:label="@string/title_activity_kimera" | ||
android:configChanges="keyboardHidden|orientation|screenSize" | ||
android:theme="@style/LaunchScreenTheme"> | ||
|
||
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" /> | ||
|
||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name="com.tns.ErrorReportActivity"/> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Add your native dependencies here: | ||
|
||
// Uncomment to add recyclerview-v7 dependency | ||
//dependencies { | ||
// compile 'com.android.support:recyclerview-v7:+' | ||
//} | ||
|
||
android { | ||
defaultConfig { | ||
generatedDensities = [] | ||
applicationId = "__PACKAGE__" | ||
} | ||
aaptOptions { | ||
additionalParameters "--no-version-vectors" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.