diff --git a/README.md b/README.md
index 4fdae62..4e8ae9b 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
- [@voicethread/nativescript-custom-rotors](packages/nativescript-custom-rotors/README.md)
- [@voicethread/nativescript-downloader](packages/nativescript-downloader/README.md)
- [@voicethread/nativescript-filepicker](packages/nativescript-filepicker/README.md)
+- [@voicethread/rive](packages/rive/README.md)
# How to use?
diff --git a/apps/demo-angular/nativescript.config.ts b/apps/demo-angular/nativescript.config.ts
index fc9f2dd..7c98626 100644
--- a/apps/demo-angular/nativescript.config.ts
+++ b/apps/demo-angular/nativescript.config.ts
@@ -7,6 +7,16 @@ export default {
v8Flags: '--expose_gc',
markingMode: 'none',
},
+ ios: {
+ SPMPackages: [
+ {
+ name: 'RiveRuntime',
+ libs: ['RiveRuntime'],
+ repositoryURL: 'https://github.com/rive-app/rive-ios.git',
+ version: '5.0.0',
+ },
+ ],
+ },
appPath: 'src',
cli: {
packageManager: 'npm',
diff --git a/apps/demo-angular/package.json b/apps/demo-angular/package.json
index b14c3ce..2fe4a22 100644
--- a/apps/demo-angular/package.json
+++ b/apps/demo-angular/package.json
@@ -6,7 +6,8 @@
"@voicethread/nativescript-filepicker": "file:../../dist/packages/nativescript-filepicker",
"@voicethread/nativescript-downloader": "file:../../dist/packages/nativescript-downloader",
"@voicethread/nativescript-audio-player": "file:../../dist/packages/nativescript-audio-player",
- "@voicethread/nativescript-audio-recorder": "file:../../dist/packages/nativescript-audio-recorder"
+ "@voicethread/nativescript-audio-recorder": "file:../../dist/packages/nativescript-audio-recorder",
+ "@voicethread/nativescript-rive": "file:../../dist/packages/nativescript-rive"
},
"devDependencies": {
"@nativescript/android": "~8.4.0",
diff --git a/apps/demo-angular/src/app-routing.module.ts b/apps/demo-angular/src/app-routing.module.ts
index f564993..df633d5 100644
--- a/apps/demo-angular/src/app-routing.module.ts
+++ b/apps/demo-angular/src/app-routing.module.ts
@@ -12,6 +12,7 @@ const routes: Routes = [
{ path: 'nativescript-custom-rotors', loadChildren: () => import('./plugin-demos/nativescript-custom-rotors.module').then(m => m.NativescriptCustomRotorsModule) },
{ path: 'nativescript-downloader', loadChildren: () => import('./plugin-demos/nativescript-downloader.module').then(m => m.NativescriptDownloaderModule) },
{ path: 'nativescript-filepicker', loadChildren: () => import('./plugin-demos/nativescript-filepicker.module').then(m => m.NativescriptFilepickerModule) },
+ { path: 'nativescript-rive', loadChildren: () => import('./plugin-demos/nativescript-rive.module').then(m => m.NativescriptRiveModule) },
];
@NgModule({
diff --git a/apps/demo-angular/src/home.component.ts b/apps/demo-angular/src/home.component.ts
index 225a6ab..01d66c5 100644
--- a/apps/demo-angular/src/home.component.ts
+++ b/apps/demo-angular/src/home.component.ts
@@ -21,5 +21,8 @@ export class HomeComponent {
{
name: 'nativescript-filepicker',
},
+ {
+ name: 'nativescript-rive',
+ },
];
}
diff --git a/apps/demo-angular/src/plugin-demos/nativescript-rive.component.html b/apps/demo-angular/src/plugin-demos/nativescript-rive.component.html
new file mode 100644
index 0000000..fc4e0e3
--- /dev/null
+++ b/apps/demo-angular/src/plugin-demos/nativescript-rive.component.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/apps/demo-angular/src/plugin-demos/nativescript-rive.component.ts b/apps/demo-angular/src/plugin-demos/nativescript-rive.component.ts
new file mode 100644
index 0000000..c4c66a7
--- /dev/null
+++ b/apps/demo-angular/src/plugin-demos/nativescript-rive.component.ts
@@ -0,0 +1,7 @@
+import { Component } from '@angular/core';
+
+@Component({
+ selector: 'demo-nativescript-rive',
+ templateUrl: 'nativescript-rive.component.html',
+})
+export class NativescriptRiveComponent {}
diff --git a/apps/demo-angular/src/plugin-demos/nativescript-rive.module.ts b/apps/demo-angular/src/plugin-demos/nativescript-rive.module.ts
new file mode 100644
index 0000000..b73e6a3
--- /dev/null
+++ b/apps/demo-angular/src/plugin-demos/nativescript-rive.module.ts
@@ -0,0 +1,10 @@
+import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
+import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';
+import { NativescriptRiveComponent } from './nativescript-rive.component';
+
+@NgModule({
+ imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild([{ path: '', component: NativescriptRiveComponent }])],
+ declarations: [NativescriptRiveComponent],
+ schemas: [NO_ERRORS_SCHEMA],
+})
+export class NativescriptRiveModule {}
diff --git a/apps/demo/nativescript.config.ts b/apps/demo/nativescript.config.ts
index 711cef6..164586f 100644
--- a/apps/demo/nativescript.config.ts
+++ b/apps/demo/nativescript.config.ts
@@ -7,6 +7,16 @@ export default {
v8Flags: '--expose_gc',
markingMode: 'none',
},
+ ios: {
+ SPMPackages: [
+ {
+ name: 'RiveRuntime',
+ libs: ['RiveRuntime'],
+ repositoryURL: 'https://github.com/rive-app/rive-ios.git',
+ version: '5.0.0',
+ },
+ ],
+ },
appPath: 'src',
cli: {
packageManager: 'npm',
diff --git a/apps/demo/package.json b/apps/demo/package.json
index 8732fe1..fce3b33 100644
--- a/apps/demo/package.json
+++ b/apps/demo/package.json
@@ -5,14 +5,16 @@
"repository": "",
"dependencies": {
"@nativescript-community/perms": "^2.3.0",
+ "@nativescript/animated-circle": "^1.2.0",
"@nativescript/core": "file:../../node_modules/@nativescript/core",
"@nstudio/nativescript-loading-indicator": "^4.2.0",
"@valor/nativescript-feedback": "^2.0.2",
+ "@voicethread/nativescript-audio-player": "file:../../packages/nativescript-audio-player",
+ "@voicethread/nativescript-audio-recorder": "file:../../packages/nativescript-audio-recorder",
"@voicethread/nativescript-custom-rotors": "file:../../packages/nativescript-custom-rotors",
"@voicethread/nativescript-downloader": "file:../../packages/nativescript-downloader",
"@voicethread/nativescript-filepicker": "file:../../packages/nativescript-filepicker",
- "@voicethread/nativescript-audio-player": "file:../../packages/nativescript-audio-player",
- "@voicethread/nativescript-audio-recorder": "file:../../packages/nativescript-audio-recorder"
+ "@voicethread/nativescript-rive": "file:../../packages/nativescript-rive"
},
"devDependencies": {
"@nativescript/android": "~8.4.0",
diff --git a/apps/demo/src/main-page.xml b/apps/demo/src/main-page.xml
index b2be8ec..672d666 100644
--- a/apps/demo/src/main-page.xml
+++ b/apps/demo/src/main-page.xml
@@ -1,4 +1,5 @@
-
+
diff --git a/apps/demo/src/main-view-model.ts b/apps/demo/src/main-view-model.ts
index 8158f8b..d1e8a76 100644
--- a/apps/demo/src/main-view-model.ts
+++ b/apps/demo/src/main-view-model.ts
@@ -29,4 +29,10 @@ export class MainViewModel extends Observable {
moduleName: 'plugin-demos/nativescript-audio-recorder',
});
}
+
+ viewRive() {
+ Frame.topmost().navigate({
+ moduleName: 'plugin-demos/nativescript-rive',
+ });
+ }
}
diff --git a/apps/demo/src/plugin-demos/nativescript-rive.ts b/apps/demo/src/plugin-demos/nativescript-rive.ts
new file mode 100644
index 0000000..11b38d1
--- /dev/null
+++ b/apps/demo/src/plugin-demos/nativescript-rive.ts
@@ -0,0 +1,15 @@
+import { Observable, EventData, Page } from '@nativescript/core';
+import { DemoSharedNativescriptRive } from '@demo/shared';
+import { RiveView } from '@voicethread/nativescript-rive';
+
+export function navigatingTo(args: EventData) {
+ const page = args.object;
+ page.bindingContext = new DemoModel();
+}
+
+export class DemoModel extends DemoSharedNativescriptRive {
+ constructor() {
+ super();
+ console.log('--- REIV', RiveView);
+ }
+}
diff --git a/apps/demo/src/plugin-demos/nativescript-rive.xml b/apps/demo/src/plugin-demos/nativescript-rive.xml
new file mode 100644
index 0000000..95f094b
--- /dev/null
+++ b/apps/demo/src/plugin-demos/nativescript-rive.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/demo/webpack.config.js b/apps/demo/webpack.config.js
index de62bf3..bc7ac62 100644
--- a/apps/demo/webpack.config.js
+++ b/apps/demo/webpack.config.js
@@ -22,5 +22,11 @@ module.exports = env => {
context: webpack.Utils.project.getProjectFilePath('node_modules'),
});
+ webpack.Utils.addCopyRule({
+ from: '../../../tools/assets/rive',
+ to: 'assets/rive',
+ context: webpack.Utils.project.getProjectFilePath('node_modules'),
+ });
+
return webpack.resolveConfig();
};
diff --git a/package.json b/package.json
index 32f579f..915a24c 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
},
"private": true,
"devDependencies": {
+ "@angular-devkit/build-angular": "^15.0.0",
"@angular/animations": "^15.0.0",
"@angular/common": "^15.0.0",
"@angular/compiler": "^15.0.0",
@@ -37,8 +38,7 @@
"ng-packagr": "^15.0.0",
"rxjs": "~7.5.0",
"typescript": "~4.8.0",
- "zone.js": "~0.11.1",
- "@angular-devkit/build-angular": "^15.0.0"
+ "zone.js": "~0.11.1"
},
"lint-staged": {
"**/*.{js,ts,scss,json,html}": [
diff --git a/packages/nativescript-rive/.eslintrc.json b/packages/nativescript-rive/.eslintrc.json
new file mode 100644
index 0000000..53c06c8
--- /dev/null
+++ b/packages/nativescript-rive/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../.eslintrc.json"],
+ "ignorePatterns": ["!**/*", "node_modules/**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/packages/nativescript-rive/README.md b/packages/nativescript-rive/README.md
new file mode 100644
index 0000000..a036ff0
--- /dev/null
+++ b/packages/nativescript-rive/README.md
@@ -0,0 +1,13 @@
+# @voicethread/nativescript-rive
+
+```javascript
+npm install @voicethread/nativescript-rive
+```
+
+## Usage
+
+// TODO
+
+## License
+
+Apache License Version 2.0
diff --git a/packages/nativescript-rive/common.ts b/packages/nativescript-rive/common.ts
new file mode 100644
index 0000000..089d334
--- /dev/null
+++ b/packages/nativescript-rive/common.ts
@@ -0,0 +1,239 @@
+import { Observable, Property, View, booleanConverter } from '@nativescript/core';
+
+export enum TypeRiveLoop {
+ ONESHOT,
+ LOOP,
+ PINGPONG,
+ AUTO,
+ NONE,
+}
+
+export enum TypeRiveDirection {
+ BACKWARDS,
+ FORWARDS,
+ AUTO,
+}
+
+export enum TypeRiveFit {
+ FILL,
+ CONTAIN,
+ COVER,
+ FIT_WIDTH,
+ FIT_HEIGHT,
+ NONE,
+ SCALE_DOWN,
+}
+
+export enum TypeRiveAlignment {
+ TOP_LEFT,
+ TOP_CENTER,
+ TOP_RIGHT,
+ CENTER_LEFT,
+ CENTER,
+ CENTER_RIGHT,
+ BOTTOM_LEFT,
+ BOTTOM_RIGHT,
+}
+
+export class RiveEvents {
+ static onPlayEvent = 'onPlayEvent';
+ static onPauseEvent = 'onPauseEvent';
+ static onLoopEndEvent = 'onLoopEndEvent';
+ static onStopEvent = 'onStopEvent';
+ static stateChangedEvent = 'stageChangedEvent';
+ static receivedInputEvent = 'receivedInputEvent';
+ static touchBeganEvent = 'touchBeganEvent';
+ static touchCancelledEvent = 'touchCancelledEvent';
+ static touchEndedEvent = 'touchEndedEvent';
+ static touchMovedEvent = 'touchMovedEvent';
+ constructor(public view: View) {}
+ notifyEvent(name: string, data: any) {
+ this.view.notify({ eventName: name, object: this.view, data });
+ }
+}
+
+export abstract class RiveViewBase extends View {
+ /*
+ * Android: file in folder raw of android or path of file
+ * Required
+ * */
+ public src: string;
+ /**
+ * Rive events
+ */
+ public events: RiveEvents;
+
+ /* autoplay (optional) - Opening a rive animation view or specifying new resourceName or url will make it automatically play, when it is ready.
+ * Default: true
+ * */
+ public autoPlay: boolean;
+ /* alignment. (optional) - Specifies how animation should be aligned inside rive animation view..
+ * Default: TypeRiveAlignment.NONE
+ * */
+ public alignment?: TypeRiveAlignment;
+ /*
+ * fit (optional) - Specifies how animation should be displayed inside rive animation view
+ * Default: TypeRiveFit.CONTAIN
+ * */
+ public fit?: TypeRiveFit;
+ /*
+ * artboard (optional) - Specifies which animation artboard should be displayed in rive animation view.
+ * Default: null
+ * */
+ public artboard?: string;
+ /*
+ * animation (optional) - Specifies which animation should be played when autoplay is set to true.
+ * Default: null
+ * */
+ public animation?: string;
+
+ /**
+ * input (optional) - Specifies which input should be used.
+ */
+ public input?: string;
+
+ /**
+ * inputValue (optional) - Specifies which input value should be used.
+ */
+ public inputValue?: boolean;
+
+ /*
+ * stateMachine (optional) - Specifies which stateMachine should be played when autoplay is set to true.
+ * Default: undefined
+ * */
+ public stateMachine?: string;
+ /*
+ * loop. (optional).
+ * Default: TypeRiveLoop.AUTO
+ * */
+ public loop?: TypeRiveLoop;
+
+ /**
+ * direction. (optional).
+ */
+ public direction?: TypeRiveDirection;
+
+ onPlay: (animation: string) => void;
+ onPause: (animation: string) => void;
+ onStop: (animation: string) => void;
+ onLoopEnd: (animation: string, loopMode: TypeRiveLoop) => void;
+
+ /*
+ * loop: default AUTO
+ * direction: default AUTO
+ * settleInitialState: default true
+ * */
+ public abstract play(loop?: TypeRiveLoop, direction?: TypeRiveDirection, settleInitialState?: true): void;
+
+ /*
+ * animations: default []
+ * loop: default AUTO
+ * direction: default AUTO
+ * areStateMachines: default false
+ * settleInitialState: default true
+ * */
+ public abstract playWithAnimations(animations?: string | string[], loop?: TypeRiveLoop, direction?: TypeRiveDirection, areStateMachines?: false, settleInitialState?: true): void;
+
+ /**
+ * Stops all.
+ */
+ public abstract stop(): void;
+
+ /**
+ * Stops any of the provided animations.
+ */
+ public abstract stopWithAnimations(animations: string | string[], areStateMachines?: false): void;
+
+ /**
+ * Pauses all playing animations.
+ */
+ public abstract pause(): void;
+
+ /*
+ * Pauses any of the provided animations.
+ * animations: default []
+ * areStateMachines: default false
+ * */
+ public abstract pauseWithAnimations(animations: string | string[], areStateMachines?: false): void;
+
+ /**
+ * Reset the view by resetting the current artboard, before any animations have been applied
+ *
+ * Note: this will respect [autoplay]
+ */
+ public abstract reset(): void;
+
+ /*
+ * Fire the Trigger input called inputName on all active matching state machines
+ * stateMachineName - Specifies state machine name which will be matched against all active state machines.
+ * inputName - Specifies the name of the trigger that should be fired.
+ * */
+ public abstract fireState(stateMachineName: string, inputName: string): void;
+
+ public abstract isPlaying(): boolean;
+
+ /**
+ * Get the currently loaded StateMachine.
+ */
+ public abstract getStateMachines();
+
+ /**
+ * * Get the currently playing StateMachine.
+ */
+ public abstract getPlayingStateMachines();
+
+ /**
+ * Get the currently loaded animations.
+ */
+ public abstract getAnimations();
+
+ /**
+ * Get the currently playing animations.
+ */
+ public abstract getPlayingAnimations();
+}
+
+export const autoPlayProperty = new Property({
+ name: 'autoPlay',
+ defaultValue: true,
+ valueConverter: booleanConverter,
+});
+autoPlayProperty.register(RiveViewBase);
+
+export const fitProperty = new Property({
+ name: 'fit',
+ defaultValue: TypeRiveFit.CONTAIN,
+});
+fitProperty.register(RiveViewBase);
+
+export const alignmentProperty = new Property({
+ name: 'alignment',
+ defaultValue: TypeRiveAlignment.CENTER,
+});
+alignmentProperty.register(RiveViewBase);
+
+export const artboardProperty = new Property({
+ name: 'artboard',
+ defaultValue: null,
+});
+artboardProperty.register(RiveViewBase);
+export const animationProperty = new Property({
+ name: 'animation',
+ defaultValue: null,
+});
+animationProperty.register(RiveViewBase);
+export const stateMachineProperty = new Property({
+ name: 'stateMachine',
+ defaultValue: null,
+});
+stateMachineProperty.register(RiveViewBase);
+export const inputValueProperty = new Property({
+ name: 'inputValue',
+ defaultValue: null,
+});
+inputValueProperty.register(RiveViewBase);
+
+export const srcProperty = new Property({
+ name: 'src',
+});
+srcProperty.register(RiveViewBase);
diff --git a/packages/nativescript-rive/index.android.ts b/packages/nativescript-rive/index.android.ts
new file mode 100644
index 0000000..7637eba
--- /dev/null
+++ b/packages/nativescript-rive/index.android.ts
@@ -0,0 +1,326 @@
+import { File, Folder, Http, knownFolders, Utils } from '@nativescript/core';
+import {
+ RiveViewBase,
+ TypeRiveAlignment,
+ TypeRiveDirection,
+ TypeRiveFit,
+ TypeRiveLoop,
+ autoPlayProperty,
+ srcProperty,
+ fitProperty,
+ alignmentProperty,
+ artboardProperty,
+ RiveEvents,
+ inputValueProperty,
+} from './common';
+export { TypeRiveAlignment, TypeRiveDirection, TypeRiveFit, TypeRiveLoop } from './common';
+
+function lazy(action: () => T): () => T {
+ let _value: T;
+
+ return () => _value || (_value = action());
+}
+
+@NativeClass()
+@Interfaces([app.rive.runtime.kotlin.RiveArtboardRenderer.Listener])
+class Listener extends java.lang.Object implements app.rive.runtime.kotlin.RiveArtboardRenderer.Listener {
+ owner: RiveView;
+
+ constructor(owner: RiveView) {
+ super();
+ this.owner = owner;
+ }
+
+ notifyPlay(animation: app.rive.runtime.kotlin.core.PlayableInstance): void {
+ this.owner.events.notifyEvent(RiveEvents.onPlayEvent, { name: animation.getName() });
+ }
+
+ notifyStop(animation: app.rive.runtime.kotlin.core.PlayableInstance): void {
+ this.owner.events.notifyEvent(RiveEvents.onStopEvent, { name: animation.getName() });
+ }
+
+ notifyPause(animation: app.rive.runtime.kotlin.core.PlayableInstance): void {
+ this.owner.events.notifyEvent(RiveEvents.onPauseEvent, { name: animation.getName() });
+ }
+
+ notifyLoop(animation: app.rive.runtime.kotlin.core.PlayableInstance): void {
+ this.owner.events.notifyEvent(RiveEvents.onLoopEndEvent, { name: animation.getName(), loop: this.owner.loop });
+ }
+
+ notifyStateChanged(stateMachine: string, stateName: string): void {
+ this.owner.events.notifyEvent(RiveEvents.stateChangedEvent, { stateMachine, stateName });
+ }
+}
+
+export class RiveView extends RiveViewBase {
+ bytes: any;
+ nativeViewProtected: app.rive.runtime.kotlin.RiveAnimationView;
+
+ listener: Listener;
+
+ constructor() {
+ super();
+ this.events = new RiveEvents(this);
+ }
+
+ public createNativeView() {
+ return new app.rive.runtime.kotlin.RiveAnimationView(this._context, null);
+ }
+
+ public initNativeView(): void {
+ this.addListener();
+ }
+
+ public disposeNativeView(): void {
+ super.disposeNativeView();
+ }
+
+ async [srcProperty.setNative](src: string) {
+ if (!src) {
+ console.log('No rive file specified');
+ } else if (src[0] === '~' || src[0] === '@') {
+ if (!/.(riv)$/.test(src)) {
+ src += '.riv';
+ }
+ const filename = src.replace(/^.*[\\\/]/, '');
+ const folder = knownFolders.currentApp().getFolder(src.substring(2).replace(filename, ''));
+ const file: File = folder.getFile(filename);
+ this.bytes = await file.read();
+ } else if (src.startsWith(Utils.RESOURCE_PREFIX)) {
+ const resName = src
+ .replace(Utils.RESOURCE_PREFIX + 'raw/', '')
+ .replace(Utils.RESOURCE_PREFIX, '')
+ .replace('.riv', '');
+ const context = Utils.android.getApplicationContext();
+ const resId = context.getResources().getIdentifier(resName, 'raw', context.getPackageName());
+ const inStream: java.io.InputStream = context.getResources().openRawResource(resId);
+ const buffer = Array.create('byte', inStream.available());
+ inStream.read(buffer);
+ this.bytes = buffer;
+ } else if (src.startsWith('http')) {
+ const file = await Http.getFile(src);
+ this.bytes = await file.read();
+ } else {
+ console.log('[ui-rive] File not supported');
+ }
+
+ if (this.bytes) {
+ this._init();
+ }
+ }
+
+ [autoPlayProperty.setNative](autoPlay: boolean) {
+ this.nativeViewProtected.setAutoplay(autoPlay);
+ }
+
+ [fitProperty.getDefault]() {
+ return TypeRiveFit.CONTAIN;
+ }
+
+ [fitProperty.setNative](value: TypeRiveFit) {
+ this.nativeViewProtected.setFit(this.getFit(value));
+ }
+
+ [alignmentProperty.getDefault]() {
+ return TypeRiveAlignment.CENTER;
+ }
+
+ [alignmentProperty.setNative](value: RiveAlignment) {
+ this.nativeViewProtected.setAlignment(value);
+ }
+
+ [inputValueProperty.setNative](value: string | boolean | number | null) {
+ this.setInputValue(value);
+ }
+
+ setInputValue(value: string | boolean | number | null) {
+ if (this.input) {
+ console.log('typeof value:', typeof value);
+ console.log('inputValue:', value);
+ if (Utils.isBoolean(value) || ['true', 'false'].includes(value as string)) {
+ this.nativeViewProtected.setBooleanState(this.stateMachine, this.input, value === true || value === 'true');
+ } else {
+ const number = Number(value);
+ if (!isNaN(number)) {
+ this.nativeViewProtected.setNumberState(this.stateMachine, this.input, number);
+ }
+ }
+ }
+ }
+
+ private _init() {
+ if (this.nativeViewProtected) {
+ this.nativeViewProtected.reset();
+ this.nativeViewProtected.setRiveBytes(
+ this.bytes,
+ this.artboard,
+ this.animation,
+ this.stateMachine,
+ this.autoPlay,
+ this.getFit(this.fit),
+ this.getAlignment(this.alignment),
+ this.getLoop(this.loop)
+ );
+ if (this.input) {
+ this.setInputValue(this.inputValue);
+ }
+ }
+ }
+
+ public isPlaying(): boolean {
+ return this.nativeViewProtected ? this.nativeViewProtected.isPlaying() : false;
+ }
+
+ public play(loop = TypeRiveLoop.AUTO, direction = TypeRiveDirection.AUTO, settleInitialState = true) {
+ this.nativeViewProtected.play(this.getLoop(loop), this.getDirection(direction), settleInitialState);
+ }
+
+ public playWithAnimations(animationNames: string | string[] = [], loop = TypeRiveLoop.AUTO, direction = TypeRiveDirection.AUTO, areStateMachines = false, settleInitialState = true) {
+ if (Array.isArray(animationNames)) {
+ this.nativeViewProtected.play(this.buildList(animationNames), this.getLoop(loop), this.getDirection(direction), areStateMachines, settleInitialState);
+ } else if (typeof animationNames === 'string') {
+ this.nativeViewProtected.play(animationNames, this.getLoop(loop), this.getDirection(direction), areStateMachines, settleInitialState);
+ }
+ }
+
+ public stop(): void {
+ if (this.nativeViewProtected) {
+ this.nativeViewProtected.stop();
+ }
+ }
+
+ public stopWithAnimations(animations: string[] = [], areStateMachines = false): void {
+ if (Array.isArray(animations)) {
+ this.nativeViewProtected.stop(this.buildList(animations), areStateMachines);
+ } else if (typeof animations === 'string') {
+ this.nativeViewProtected.stop(animations, areStateMachines);
+ }
+ }
+
+ public pause(): void {
+ if (this.nativeViewProtected) {
+ this.nativeViewProtected.pause();
+ }
+ }
+
+ public pauseWithAnimations(animations: string | string[] = [], areStateMachines = false): void {
+ if (Array.isArray(animations)) {
+ this.nativeViewProtected.pause(this.buildList(animations), areStateMachines);
+ } else if (typeof animations === 'string') {
+ this.nativeViewProtected.pause(animations, areStateMachines);
+ }
+ }
+
+ public reset(): void {
+ if (this.nativeViewProtected) {
+ this.nativeViewProtected.reset();
+ }
+ }
+
+ public fireState(stateMachineName: string, inputName: string): void {
+ if (this.nativeViewProtected) {
+ this.nativeViewProtected.fireState(stateMachineName, inputName);
+ }
+ }
+
+ public getStateMachines() {
+ if (this.nativeViewProtected) {
+ this.nativeViewProtected.getStateMachines();
+ }
+ }
+
+ public getPlayingStateMachines() {
+ if (this.nativeViewProtected) {
+ this.nativeViewProtected.getPlayingStateMachines();
+ }
+ }
+
+ public getAnimations() {
+ if (this.nativeViewProtected) {
+ this.nativeViewProtected.getAnimations();
+ }
+ }
+
+ public getPlayingAnimations() {
+ if (this.nativeViewProtected) {
+ this.nativeViewProtected.getPlayingAnimations();
+ }
+ }
+
+ private addListener() {
+ // if (!this.listener) {
+ // this.listener = new Listener(this);
+ // this.nativeViewProtected.registerListener(this.listener);
+ // }
+ }
+
+ private buildList(array: string[]): java.util.ArrayList {
+ const animations = new java.util.ArrayList();
+ array.forEach(item => animations.add(item));
+ return animations;
+ }
+
+ private getLoop(riveLoop: TypeRiveLoop): app.rive.runtime.kotlin.core.Loop {
+ switch (riveLoop) {
+ case TypeRiveLoop.ONESHOT:
+ return app.rive.runtime.kotlin.core.Loop.ONESHOT;
+ case TypeRiveLoop.LOOP:
+ return app.rive.runtime.kotlin.core.Loop.LOOP;
+ case TypeRiveLoop.PINGPONG:
+ return app.rive.runtime.kotlin.core.Loop.PINGPONG;
+ default:
+ return app.rive.runtime.kotlin.core.Loop.AUTO;
+ }
+ }
+
+ private getDirection(riveDirection: TypeRiveDirection): app.rive.runtime.kotlin.core.Direction {
+ switch (riveDirection) {
+ case TypeRiveDirection.BACKWARDS:
+ return app.rive.runtime.kotlin.core.Direction.BACKWARDS;
+ case TypeRiveDirection.FORWARDS:
+ return app.rive.runtime.kotlin.core.Direction.FORWARDS;
+ default:
+ return app.rive.runtime.kotlin.core.Direction.AUTO;
+ }
+ }
+
+ private getFit(riveFit: TypeRiveFit): app.rive.runtime.kotlin.core.Fit {
+ switch (riveFit) {
+ case TypeRiveFit.FILL:
+ return app.rive.runtime.kotlin.core.Fit.FILL;
+ case TypeRiveFit.CONTAIN:
+ return app.rive.runtime.kotlin.core.Fit.CONTAIN;
+ case TypeRiveFit.COVER:
+ return app.rive.runtime.kotlin.core.Fit.COVER;
+ case TypeRiveFit.FIT_WIDTH:
+ return app.rive.runtime.kotlin.core.Fit.FIT_WIDTH;
+ case TypeRiveFit.FIT_HEIGHT:
+ return app.rive.runtime.kotlin.core.Fit.FIT_HEIGHT;
+ case TypeRiveFit.SCALE_DOWN:
+ return app.rive.runtime.kotlin.core.Fit.SCALE_DOWN;
+ default:
+ return app.rive.runtime.kotlin.core.Fit.NONE;
+ }
+ }
+
+ private getAlignment(riveAlignment: TypeRiveAlignment): app.rive.runtime.kotlin.core.Alignment {
+ switch (riveAlignment) {
+ case TypeRiveAlignment.TOP_LEFT:
+ return app.rive.runtime.kotlin.core.Alignment.TOP_LEFT;
+ case TypeRiveAlignment.TOP_CENTER:
+ return app.rive.runtime.kotlin.core.Alignment.TOP_CENTER;
+ case TypeRiveAlignment.TOP_RIGHT:
+ return app.rive.runtime.kotlin.core.Alignment.TOP_RIGHT;
+ case TypeRiveAlignment.CENTER_LEFT:
+ return app.rive.runtime.kotlin.core.Alignment.CENTER_LEFT;
+ case TypeRiveAlignment.CENTER_RIGHT:
+ return app.rive.runtime.kotlin.core.Alignment.CENTER_RIGHT;
+ case TypeRiveAlignment.BOTTOM_LEFT:
+ return app.rive.runtime.kotlin.core.Alignment.BOTTOM_LEFT;
+ case TypeRiveAlignment.BOTTOM_RIGHT:
+ return app.rive.runtime.kotlin.core.Alignment.BOTTOM_RIGHT;
+ default:
+ return app.rive.runtime.kotlin.core.Alignment.CENTER;
+ }
+ }
+}
diff --git a/packages/nativescript-rive/index.d.ts b/packages/nativescript-rive/index.d.ts
new file mode 100644
index 0000000..729b20e
--- /dev/null
+++ b/packages/nativescript-rive/index.d.ts
@@ -0,0 +1,68 @@
+import { View } from '@nativescript/core';
+import { TypeRiveAlignment, TypeRiveDirection, TypeRiveFit, TypeRiveLoop } from './common';
+export { TypeRiveAlignment, TypeRiveDirection, TypeRiveFit, TypeRiveLoop } from './common';
+
+export declare class RiveView extends View {
+ /**
+ * app.rive.runtime.kotlin.RiveAnimationView
+ */
+ readonly android: any;
+
+ /**
+ * NSCRiveController
+ */
+ readonly ios: any;
+
+ constructor();
+
+ public src: string;
+ public autoPlay: boolean;
+ public alignment?: RiveAlignment;
+ public fit?: RiveFit;
+ public artboardName?: string;
+ public animationName?: string;
+ public stateMachineName?: string;
+
+ /*
+ * loop: default AUTO
+ * direction: default AUTO
+ * */
+ public play(loop?: TypeRiveLoop, direction?: TypeRiveDirection, settleInitialState?: true): void;
+
+ /*
+ * loop: default AUTO
+ * direction: default AUTO
+ * */
+ public playWithAnimations(animationNames: string[], loop?: TypeRiveLoop, direction?: TypeRiveDirection, areStateMachines?: false, settleInitialState?: true): void;
+
+ /*
+ * loop: default AUTO
+ * direction: default AUTO
+ * */
+ public playWithAnimation(animationName: string, loop?: TypeRiveLoop, direction?: TypeRiveDirection, areStateMachines?: false, settleInitialState?: true): void;
+
+ public stop(): void;
+
+ public stopWithAnimations(animationNames: string[], areStateMachines?: false): void;
+
+ public stopWithAnimation(animationName: String, isStateMachine?: false): void;
+
+ public pause(): void;
+
+ public pauseWithAnimation(animationName: string, areStateMachines?: false): void;
+
+ public pauseWithAnimations(animationNames: string[], areStateMachines?: false): void;
+
+ public reset(): void;
+
+ public fireState(stateMachineName: string, inputName: string): void;
+
+ public isPlaying(): boolean;
+
+ public getStateMachines();
+
+ public getAnimations();
+
+ triggerInput(name: string): void;
+ triggerInputValue(name: string, value: string | boolean | number | null): void;
+}
diff --git a/packages/nativescript-rive/index.ios.ts b/packages/nativescript-rive/index.ios.ts
new file mode 100644
index 0000000..9594273
--- /dev/null
+++ b/packages/nativescript-rive/index.ios.ts
@@ -0,0 +1,410 @@
+import { File, Folder, knownFolders, Utils } from '@nativescript/core';
+import { RiveEvents, RiveViewBase, TypeRiveAlignment, TypeRiveDirection, TypeRiveFit, TypeRiveLoop, alignmentProperty, fitProperty, inputValueProperty, srcProperty } from './common';
+export { TypeRiveAlignment, TypeRiveDirection, TypeRiveFit, TypeRiveLoop } from './common';
+declare var NSCRiveController;
+
+export class RiveView extends RiveViewBase {
+ riveFile: RiveFile;
+ ctrl: NSCRiveController;
+ nativeViewProtected: UIView;
+ fileName: string;
+ fit: TypeRiveFit;
+ autoPlay: boolean;
+ riveFileDelegate: RiveFileDelegateImpl;
+ riveStateMachineDelegate: RiveStateMachineDelegateImpl;
+
+ constructor() {
+ super();
+ this.events = new RiveEvents(this);
+ }
+
+ public createNativeView() {
+ this.ctrl = NSCRiveController.alloc().init();
+ return this.ctrl.view;
+ }
+
+ public disposeNativeView(): void {
+ super.disposeNativeView();
+ this.stop();
+ this.riveFileDelegate = null;
+ this.riveStateMachineDelegate = null;
+ this.ctrl = null;
+ this.riveFile = null;
+ }
+
+ async [srcProperty.setNative](src: string) {
+ if (!src) {
+ console.log('No rive file specified');
+ } else if (src[0] === '~' || src[0] === '@') {
+ if (!/.(riv)$/.test(src)) {
+ src += '.riv';
+ }
+ const app: Folder = knownFolders.currentApp();
+ const filename = src.replace(/^.*[\\\/]/, '');
+ const folder: Folder = app.getFolder(src.substring(2).replace(filename, ''));
+ const file: File = folder.getFile(filename);
+ // TODO: fix typings in 8.5.1 to includes these new file apis
+ // const bytes = await file.readBufferAsync();
+ const bytes = interop.bufferFromData(NSData.dataWithContentsOfFile(file.path));
+ this.riveFile = RiveFile.alloc().initWithBytesByteLengthError(bytes, bytes.byteLength);
+ this._init();
+ } else if (src.startsWith(Utils.RESOURCE_PREFIX)) {
+ this.fileName = src.replace(Utils.RESOURCE_PREFIX, '').replace('.riv', '');
+ this._init();
+ } else if (src.startsWith('http')) {
+ this.riveFileDelegate = RiveFileDelegateImpl.initWithOwner(new WeakRef(this));
+ this.riveFile = RiveFile.alloc().initWithHttpUrlWithDelegate(src, (this.riveFileDelegate));
+ } else {
+ console.log('[ui-rive] File not supported');
+ }
+ }
+
+ riveFileHttpSrcDidLoad(riveFile: RiveFile) {
+ this._init();
+ }
+
+ [fitProperty.getDefault]() {
+ return TypeRiveFit.CONTAIN;
+ }
+
+ [fitProperty.setNative](value: TypeRiveFit) {
+ this.fit = value;
+ // this.nativeViewProtected.setFit(value);
+ }
+
+ [alignmentProperty.getDefault]() {
+ return TypeRiveAlignment.CENTER;
+ }
+
+ [alignmentProperty.setNative](value: TypeRiveAlignment) {
+ // this.nativeViewProtected.setAlignment(value);
+ }
+
+ [inputValueProperty.setNative](value: string | boolean | number | null) {
+ this.setInputValue(value);
+ }
+
+ triggerInput(name: string) {
+ if (this.ctrl && name) {
+ this.ctrl.triggerInputWithName(name);
+ }
+ }
+
+ triggerInputValue(name: string, value: string | boolean | number | null) {
+ this._setInputValue(name, value);
+ }
+
+ setInputValue(value: string | boolean | number | null) {
+ this._setInputValue(this.input, value);
+ }
+
+ private _setInputValue(name: string, value: string | boolean | number | null) {
+ this.input = name;
+ if (this.input && this.ctrl) {
+ if (Utils.isBoolean(value) || ['true', 'false'].includes(value as string)) {
+ this.ctrl.setInputWithNameBinary(this.input, value === true || value === 'true');
+ } else {
+ const number = Number(value);
+ if (!isNaN(number)) {
+ this.ctrl.setInputWithNameNumber(this.input, number);
+ }
+ }
+ }
+ }
+
+ setTextRunValue(name: string, value) {
+ this.ctrl.setTextWithNameValueError(name, value);
+ }
+
+ private _init() {
+ // console.log('init autoPlay:', this.autoPlay);
+ // console.log('init this.fit:', this.fit);
+
+ if (this.riveFile) {
+ this.ctrl.setModelWithFileFit(this.riveFile, this.getFit(this.fit));
+ } else if (this.fileName) {
+ this.ctrl.setModelResourceWithNameFit(this.fileName, this.getFit(this.fit));
+ }
+ if (this.artboard || this.animation || this.stateMachine) {
+ this.ctrl.configureModelWithArtboardStateMachineAnimation(this.artboard, this.stateMachine, this.animation);
+ }
+ this.riveStateMachineDelegate = RiveStateMachineDelegateImpl.initWithOwner(new WeakRef(this));
+ this.ctrl.setDelegateWithDelegate(this.riveStateMachineDelegate);
+ if (this.input) {
+ if (this.inputValue) {
+ this.setInputValue(this.inputValue);
+ } else {
+ this.ctrl.triggerInputWithName(this.input);
+ }
+ }
+ if (this.autoPlay) {
+ this.play(this.loop, this.direction);
+ }
+ }
+
+ public isPlaying(): boolean {
+ if (this.ctrl) {
+ return this.ctrl.isPlaying();
+ }
+ return false;
+ }
+
+ public play(loop = TypeRiveLoop.AUTO, direction = TypeRiveDirection.AUTO, settleInitialState = true) {
+ if (this.ctrl) {
+ // console.log('looop:', loop)
+ this.ctrl.playWithDirectionLoopName(this.getDirection(direction), this.getLoop(loop), null);
+ }
+ }
+
+ public playWithAnimations(animationNames: string | string[] = [], loop = TypeRiveLoop.AUTO, direction = TypeRiveDirection.AUTO, areStateMachines = false, settleInitialState = true) {
+ // if (Array.isArray(animationNames)) {
+ // this.nativeViewProtected.play(this.buildList(animationNames), this.getLoop(loop), this.getDirection(direction), areStateMachines, settleInitialState)
+ // } else if (typeof animationNames === 'string') {
+ // this.nativeViewProtected.play(animationNames, this.getLoop(loop), this.getDirection(direction), areStateMachines, settleInitialState)
+ // }
+ }
+
+ public stop(): void {
+ if (this.ctrl) {
+ this.ctrl.stop();
+ }
+ }
+
+ public stopWithAnimations(animationNames: string[] = [], areStateMachines = false): void {
+ if (this.ctrl) {
+ this.ctrl.stop();
+ }
+ // if (Array.isArray(animationNames)) {
+ // this.nativeViewProtected.stop(this.buildList(animationNames), areStateMachines);
+ // } else if (typeof animationNames === 'string') {
+ // this.nativeViewProtected.stop(animationNames, areStateMachines);
+ // }
+ }
+
+ public pause(): void {
+ if (this.ctrl) {
+ this.ctrl.pause();
+ }
+ }
+
+ public pauseWithAnimations(animationNames: string | string[] = [], areStateMachines = false): void {
+ // if (Array.isArray(animationNames)) {
+ // this.nativeViewProtected.pause(this.buildList(animationNames), areStateMachines);
+ // } else if (typeof animationNames === 'string') {
+ // this.nativeViewProtected.pause(animationNames, areStateMachines);
+ // }
+ }
+
+ public reset(): void {
+ // if (this.nativeViewProtected) {
+ // this.nativeViewProtected.reset();
+ // }
+ }
+
+ public fireState(stateMachineName: string, inputName: string): void {
+ // if (this.nativeViewProtected) {
+ // this.nativeViewProtected.fireState(stateMachineName, inputName);
+ // }
+ }
+
+ public setBooleanState(stateMachineName: string, inputName: string, value): void {
+ // if (this.nativeViewProtected) {
+ // this.nativeViewProtected.setBooleanState(stateMachineName, inputName, value);
+ // }
+ }
+
+ public setNumberState(stateMachineName: string, inputName: string, value): void {
+ // if (this.nativeViewProtected) {
+ // this.nativeViewProtected.setNumberState(stateMachineName, inputName, value);
+ // }
+ }
+
+ public getStateMachines() {
+ // if (this.nativeViewProtected) {
+ // this.nativeViewProtected.getStateMachines();
+ // }
+ }
+
+ public getPlayingStateMachines() {
+ // if (this.nativeViewProtected) {
+ // this.nativeViewProtected.getPlayingStateMachines();
+ // }
+ }
+
+ public getAnimations() {
+ // if (this.nativeViewProtected) {
+ // this.nativeViewProtected.getAnimations();
+ // }
+ }
+
+ public getPlayingAnimations() {
+ // if (this.nativeViewProtected) {
+ // this.nativeViewProtected.getPlayingAnimations();
+ // }
+ }
+
+ private addListener() {
+ // if (!this.listener) {
+ // this.listener = new Listener(this);
+ // this.nativeViewProtected.registerListener(this.listener);
+ // }
+ }
+
+ private buildList(array: string[]): java.util.ArrayList {
+ const animations = new java.util.ArrayList();
+ array.forEach(item => animations.add(item));
+ return animations;
+ }
+
+ private getLoop(riveLoop: TypeRiveLoop): string {
+ switch (riveLoop) {
+ case TypeRiveLoop.ONESHOT:
+ return 'oneShot';
+ case TypeRiveLoop.LOOP:
+ return 'loop';
+ case TypeRiveLoop.PINGPONG:
+ return 'pingPong';
+ case TypeRiveLoop.NONE:
+ return 'none';
+ default:
+ return null;
+ }
+ }
+
+ private getDirection(riveDirection: TypeRiveDirection): number {
+ switch (riveDirection) {
+ case TypeRiveDirection.BACKWARDS:
+ return -1;
+ case TypeRiveDirection.FORWARDS:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ private getFit(riveFit: TypeRiveFit): RiveFit {
+ switch (riveFit) {
+ case TypeRiveFit.FILL:
+ return RiveFit.fill;
+ case TypeRiveFit.CONTAIN:
+ return RiveFit.contain;
+ case TypeRiveFit.COVER:
+ return RiveFit.cover;
+ case TypeRiveFit.FIT_WIDTH:
+ return RiveFit.fitWidth;
+ case TypeRiveFit.FIT_HEIGHT:
+ return RiveFit.fitHeight;
+ case TypeRiveFit.SCALE_DOWN:
+ return RiveFit.scaleDown;
+ default:
+ return RiveFit.noFit;
+ }
+ }
+
+ private getAlignment(riveAlignment: RiveAlignment) {
+ //: Alignment {
+ // switch (riveAlignment) {
+ // case RiveAlignment.TOP_LEFT:
+ // return Alignment.TOP_LEFT;
+ // case RiveAlignment.TOP_CENTER:
+ // return Alignment.TOP_CENTER;
+ // case RiveAlignment.TOP_RIGHT:
+ // return Alignment.TOP_RIGHT;
+ // case RiveAlignment.CENTER_LEFT:
+ // return Alignment.CENTER_LEFT;
+ // case RiveAlignment.CENTER_RIGHT:
+ // return Alignment.CENTER_RIGHT;
+ // case RiveAlignment.BOTTOM_LEFT:
+ // return Alignment.BOTTOM_LEFT;
+ // case RiveAlignment.BOTTOM_RIGHT:
+ // return Alignment.BOTTOM_RIGHT;
+ // default:
+ // return Alignment.CENTER;
+ // }
+ }
+}
+
+@NativeClass()
+class RiveFileDelegateImpl extends NSObject implements RiveFileDelegate {
+ static ObjCProtocols = [RiveFileDelegate];
+
+ private _owner: WeakRef;
+
+ static initWithOwner(owner: WeakRef): RiveFileDelegateImpl {
+ const delegate = RiveFileDelegateImpl.new();
+ delegate._owner = owner;
+ return delegate;
+ }
+
+ riveFileDidLoadError(riveFile: RiveFile) {
+ console.log('riveFileDidLoadError:', riveFile.isLoaded);
+ const owner = this._owner.deref();
+ if (owner) {
+ if (riveFile.isLoaded) {
+ owner.riveFileHttpSrcDidLoad(riveFile);
+ }
+ }
+ return riveFile.isLoaded;
+ }
+}
+
+@NativeClass()
+class RiveStateMachineDelegateImpl extends NSObject implements RiveStateMachineDelegate {
+ static ObjCProtocols = [RiveStateMachineDelegate];
+
+ private _owner: WeakRef;
+
+ static initWithOwner(owner: WeakRef): RiveStateMachineDelegateImpl {
+ const delegate = RiveStateMachineDelegateImpl.new();
+ delegate._owner = owner;
+ return delegate;
+ }
+
+ stateMachineDidChangeState?(stateMachine: RiveStateMachineInstance, stateName: string): void {
+ console.log('stateMachineDidChangeState:', stateName);
+ const owner = this._owner.deref();
+ if (owner) {
+ owner.events.notifyEvent(RiveEvents.stateChangedEvent, { stateMachine, stateName });
+ }
+ }
+
+ stateMachineReceivedInput?(stateMachine: RiveStateMachineInstance, input: StateMachineInput): void {
+ console.log('stateMachineReceivedInput:', input);
+ const owner = this._owner.deref();
+ if (owner) {
+ owner.events.notifyEvent(RiveEvents.receivedInputEvent, { stateMachine, input });
+ }
+ }
+
+ touchBeganOnArtboardAtLocation?(artboard: RiveArtboard, location: CGPoint): void {
+ console.log('touchBeganOnArtboardAtLocation:', location);
+ const owner = this._owner.deref();
+ if (owner) {
+ owner.events.notifyEvent(RiveEvents.touchBeganEvent, { artboard, location });
+ }
+ }
+
+ touchCancelledOnArtboardAtLocation?(artboard: RiveArtboard, location: CGPoint): void {
+ console.log('touchCancelledOnArtboardAtLocation:', location);
+ const owner = this._owner.deref();
+ if (owner) {
+ owner.events.notifyEvent(RiveEvents.touchCancelledEvent, { artboard, location });
+ }
+ }
+
+ touchEndedOnArtboardAtLocation?(artboard: RiveArtboard, location: CGPoint): void {
+ console.log('touchEndedOnArtboardAtLocation:', location);
+ const owner = this._owner.deref();
+ if (owner) {
+ owner.events.notifyEvent(RiveEvents.touchEndedEvent, { artboard, location });
+ }
+ }
+
+ touchMovedOnArtboardAtLocation?(artboard: RiveArtboard, location: CGPoint): void {
+ console.log('touchMovedOnArtboardAtLocation:', location);
+ const owner = this._owner.deref();
+ if (owner) {
+ owner.events.notifyEvent(RiveEvents.touchMovedEvent, { artboard, location });
+ }
+ }
+}
diff --git a/packages/nativescript-rive/package.json b/packages/nativescript-rive/package.json
new file mode 100644
index 0000000..fcf3159
--- /dev/null
+++ b/packages/nativescript-rive/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "@voicethread/nativescript-rive",
+ "version": "1.0.0",
+ "description": "Add a plugin description",
+ "main": "index",
+ "typings": "index.d.ts",
+ "nativescript": {
+ "platforms": {
+ "ios": "6.0.0",
+ "android": "6.0.0"
+ }
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/VoiceThread/nativescript-plugins.git"
+ },
+ "keywords": [
+ "NativeScript",
+ "JavaScript",
+ "TypeScript",
+ "iOS",
+ "Android"
+ ],
+ "author": {
+ "name": "VoiceThread",
+ "email": "oss@nativescript.org"
+ },
+ "bugs": {
+ "url": "https://github.com/VoiceThread/nativescript-plugins/issues"
+ },
+ "license": "Apache-2.0",
+ "homepage": "https://github.com/VoiceThread/nativescript-plugins",
+ "readmeFilename": "README.md",
+ "bootstrapper": "@nativescript/plugin-seed"
+}
diff --git a/packages/nativescript-rive/platforms/android/AndroidManifest.xml b/packages/nativescript-rive/platforms/android/AndroidManifest.xml
new file mode 100644
index 0000000..dab81b8
--- /dev/null
+++ b/packages/nativescript-rive/platforms/android/AndroidManifest.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/nativescript-rive/platforms/android/include.gradle b/packages/nativescript-rive/platforms/android/include.gradle
new file mode 100644
index 0000000..73fd8bc
--- /dev/null
+++ b/packages/nativescript-rive/platforms/android/include.gradle
@@ -0,0 +1,8 @@
+dependencies {
+ def androidXAppCompatVersion = project.hasProperty("androidXAppCompat") ? project.androidXAppCompat : "1.3.1"
+ implementation "androidx.appcompat:appcompat:$androidXAppCompatVersion"
+
+ def riveVersion = project.hasProperty("riveVersion") ? project.riveVersion : "8.1.+"
+ implementation "app.rive:rive-android:$riveVersion"
+ implementation "androidx.startup:startup-runtime:1.1.1"
+}
\ No newline at end of file
diff --git a/packages/nativescript-rive/platforms/android/nativescript_rive.aar b/packages/nativescript-rive/platforms/android/nativescript_rive.aar
new file mode 100644
index 0000000..b2c93af
Binary files /dev/null and b/packages/nativescript-rive/platforms/android/nativescript_rive.aar differ
diff --git a/packages/nativescript-rive/platforms/ios/src/NSCRiveController.swift b/packages/nativescript-rive/platforms/ios/src/NSCRiveController.swift
new file mode 100644
index 0000000..9372e0e
--- /dev/null
+++ b/packages/nativescript-rive/platforms/ios/src/NSCRiveController.swift
@@ -0,0 +1,138 @@
+import UIKit
+import RiveRuntime
+
+@objc public class NSCRiveController: UIViewController {
+ @objc public var riveViewModel: RiveViewModel?
+ @objc public var riveView: RiveView?
+
+ @objc public func setModelResource(name: String, fit: NSNumber) {
+ riveViewModel = RiveViewModel(fileName: name, autoPlay: false)
+ setFit(fit)
+ addRiveView()
+ }
+
+ @objc public func setModel(file: RiveFile, fit: NSNumber) {
+ riveViewModel = RiveViewModel(RiveModel(riveFile: file), autoPlay: false)
+ setFit(fit)
+ addRiveView()
+ }
+
+ @objc public func configureModel(artboard: String?, stateMachine: String?, animation: String?) {
+ if (riveViewModel != nil) {
+ try? riveViewModel?.configureModel(artboardName: artboard, stateMachineName: stateMachine, animationName: animation)
+ }
+ }
+
+ func addRiveView() {
+ if (riveView != nil) {
+ try? riveView?.setModel(riveViewModel!.riveModel!)
+ } else {
+ riveView = riveViewModel?.createRiveView()
+
+ riveView!.translatesAutoresizingMaskIntoConstraints = false
+ view.addSubview(riveView!)
+ NSLayoutConstraint.activate([
+ riveView!.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
+ riveView!.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
+ riveView!.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
+ riveView!.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
+ ])
+ }
+ }
+
+ @objc public func setDelegate(delegate: RiveStateMachineDelegate) {
+ riveView?.stateMachineDelegate = delegate
+ }
+
+ @objc public func setInput(name: String, binary: Bool) {
+ riveViewModel?.setInput(name, value: binary)
+ }
+
+ @objc public func setInput(name: String, number: NSNumber) {
+ if let numFloat = number as? Float {
+ riveViewModel?.setInput(name, value: numFloat)
+ } else if let numDouble = number as? Double {
+ riveViewModel?.setInput(name, value: numDouble)
+ }
+ }
+
+ @objc public func setText(name: String, value: String) throws {
+ try riveViewModel?.setTextRunValue(name, textValue: value)
+ }
+
+ @objc public func triggerInput(name: String) {
+ riveViewModel?.triggerInput(name)
+ }
+
+ @objc public func stop() {
+ riveViewModel?.stop()
+ }
+
+ @objc public func pause() {
+ riveViewModel?.pause()
+ }
+
+ @objc public func isPlaying() -> Bool {
+ return riveViewModel?.isPlaying ?? false
+ }
+
+ @objc public func play(direction: NSNumber?, loop: String?, name: String?) {
+ if (riveViewModel != nil) {
+ let dir: RiveDirection?
+ switch (direction) {
+ case -1:
+ dir = .backwards
+ case 1:
+ dir = .forwards
+ case 0:
+ dir = .none
+ default:
+ dir = .autoDirection
+ }
+ let riveLoop: RiveLoop?
+ switch (loop) {
+ case "loop":
+ riveLoop = .loop
+ case "oneShot":
+ riveLoop = .oneShot
+ case "pingPong":
+ riveLoop = .pingPong
+ default:
+ riveLoop = .autoLoop
+ }
+ riveViewModel?.play(animationName: name ?? nil, loop: riveLoop ?? .autoLoop, direction: dir ?? .autoDirection);
+ }
+ }
+
+ @objc public func setFit(_ fit: NSNumber) {
+ if (riveViewModel != nil) {
+ switch (fit) {
+ case 0:
+ riveViewModel?.fit = .fill
+ break;
+ case 1:
+ riveViewModel?.fit = .contain
+ break;
+ case 2:
+ riveViewModel?.fit = .cover
+ break;
+ case 3:
+ riveViewModel?.fit = .fitWidth
+ break;
+ case 4:
+ riveViewModel?.fit = .fitHeight
+ break;
+ case 5:
+ riveViewModel?.fit = .noFit
+ break;
+ case 6:
+ riveViewModel?.fit = .scaleDown
+ break;
+ default:
+ riveViewModel?.fit = .contain
+ break;
+ }
+
+ }
+ }
+}
diff --git a/packages/nativescript-rive/project.json b/packages/nativescript-rive/project.json
new file mode 100644
index 0000000..b164929
--- /dev/null
+++ b/packages/nativescript-rive/project.json
@@ -0,0 +1,73 @@
+{
+ "name": "nativescript-rive",
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
+ "projectType": "library",
+ "sourceRoot": "packages/nativescript-rive",
+ "targets": {
+ "build": {
+ "executor": "@nrwl/js:tsc",
+ "options": {
+ "outputPath": "dist/packages/nativescript-rive",
+ "tsConfig": "packages/nativescript-rive/tsconfig.json",
+ "packageJson": "packages/nativescript-rive/package.json",
+ "main": "packages/nativescript-rive/index.d.ts",
+ "assets": [
+ "packages/nativescript-rive/*.md",
+ "packages/nativescript-rive/index.d.ts",
+ "LICENSE",
+ {
+ "glob": "**/*",
+ "input": "packages/nativescript-rive/platforms/",
+ "output": "./platforms/"
+ }
+ ],
+ "dependsOn": [
+ {
+ "target": "build.all",
+ "projects": "dependencies"
+ }
+ ]
+ }
+ },
+ "build.all": {
+ "executor": "nx:run-commands",
+ "options": {
+ "commands": [
+ "node tools/scripts/build-finish.ts nativescript-rive"
+ ],
+ "parallel": false
+ },
+ "outputs": [
+ "dist/packages/nativescript-rive"
+ ],
+ "dependsOn": [
+ {
+ "target": "build.all",
+ "projects": "dependencies"
+ },
+ {
+ "target": "build",
+ "projects": "self"
+ }
+ ]
+ },
+ "focus": {
+ "executor": "nx:run-commands",
+ "options": {
+ "commands": [
+ "nx g @nativescript/plugin-tools:focus-packages nativescript-rive"
+ ],
+ "parallel": false
+ }
+ },
+ "lint": {
+ "executor": "@nrwl/linter:eslint",
+ "options": {
+ "lintFilePatterns": [
+ "packages/nativescript-rive/**/*.ts"
+ ]
+ }
+ }
+ },
+ "tags": []
+}
diff --git a/packages/nativescript-rive/references.d.ts b/packages/nativescript-rive/references.d.ts
new file mode 100644
index 0000000..22bac92
--- /dev/null
+++ b/packages/nativescript-rive/references.d.ts
@@ -0,0 +1 @@
+///
diff --git a/packages/nativescript-rive/tsconfig.json b/packages/nativescript-rive/tsconfig.json
new file mode 100644
index 0000000..aed7323
--- /dev/null
+++ b/packages/nativescript-rive/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "compilerOptions": {
+ "outDir": "../../dist/out-tsc",
+ "rootDir": "."
+ },
+ "exclude": ["**/*.spec.ts", "**/*.test.ts", "angular"],
+ "include": ["**/*.ts", "references.d.ts"]
+}
diff --git a/packages/nativescript-rive/typings/android.d.ts b/packages/nativescript-rive/typings/android.d.ts
new file mode 100644
index 0000000..c66c7c0
--- /dev/null
+++ b/packages/nativescript-rive/typings/android.d.ts
@@ -0,0 +1,1083 @@
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export class BuildConfig {
+ public static class: java.lang.Class;
+ public static DEBUG: boolean;
+ public static LIBRARY_PACKAGE_NAME: string;
+ public static BUILD_TYPE: string;
+ public constructor();
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export class DetachedRiveState {
+ public static class: java.lang.Class;
+ public constructor(param0: java.util.List, param1: java.util.List);
+ public getPlayingAnimationsNames(): java.util.List;
+ public getPlayingStateMachineNames(): java.util.List;
+ public equals(param0: any): boolean;
+ public toString(): string;
+ public component1(): java.util.List;
+ public component2(): java.util.List;
+ public hashCode(): number;
+ public copy(param0: java.util.List, param1: java.util.List): app.rive.runtime.kotlin;
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export class Observable extends java.lang.Object {
+ public static class: java.lang.Class;
+ /**
+ * Constructs a new instance of the app.rive.runtime.kotlin interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
+ */
+ public constructor(implementation: { registerListener(param0: ListenerType): void; unregisterListener(param0: ListenerType): void });
+ public constructor();
+ public registerListener(param0: ListenerType): void;
+ public unregisterListener(param0: ListenerType): void;
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export class PointerEvents {
+ public static class: java.lang.Class;
+ public static POINTER_DOWN: app.rive.runtime.kotlin;
+ public static POINTER_UP: app.rive.runtime.kotlin;
+ public static POINTER_MOVE: app.rive.runtime.kotlin;
+ public static valueOf(param0: string): app.rive.runtime.kotlin;
+ public static values(): androidNative.Array;
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export class RiveAnimationView extends app.rive.runtime.kotlin implements app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public static TAG: string;
+ public setFit(param0: app.rive.runtime.kotlin): void;
+ public setBooleanState(param0: string, param1: string, param2: boolean): void;
+ public getStateMachines(): java.util.List;
+ public setRiveBytes(
+ bytes: java.lang.Byte,
+ artboardName: string,
+ animationName: string,
+ stateMachineName: string,
+ autoplay: boolean,
+ fit: app.rive.runtime.kotlin.core.Fit,
+ alignment: app.rive.runtime.kotlin.core.Alignment,
+ loop: app.rive.runtime.kotlin.core.Loop
+ ): void;
+ public getFit(): app.rive.runtime.kotlin;
+ public setRiveResource(
+ resId: number,
+ artboardName: string,
+ animationName: string,
+ stateMachineName: string,
+ autoplay: boolean,
+ fit: app.rive.runtime.kotlin.core.Fit,
+ alignment: app.rive.runtime.kotlin.core.Alignment,
+ loop: app.rive.runtime.kotlin.core.Loop
+ ): void;
+ public unregisterListener(param0: any): void;
+ public setArtboardName(param0: string): void;
+ public getPlayingAnimations(): java.util.HashSet;
+ public stop(param0: string, param1: boolean): void;
+ public play(loop: app.rive.runtime.kotlin.core.Loop, direction: app.rive.runtime.kotlin.core.Direction, settleInitialState: boolean): void;
+ public setNumberState(param0: string, param1: string, param2: number): void;
+ public play(animationName: string, loop: app.rive.runtime.kotlin.core.Loop, direction: app.rive.runtime.kotlin.core.Direction, isStateMachine: boolean, settleInitialState: boolean): void;
+ public onAttachedToWindow(): void;
+ public constructor(param0: globalAndroid.content.Context, param1?: globalAndroid.util.AttributeSet);
+ public onSurfaceTextureAvailable(param0: globalAndroid.graphics.SurfaceTexture, param1: number, param2: number): void;
+ public unregisterListener(param0: app.rive.runtime.kotlin): void;
+ public pause(): void;
+ public isPlaying(): boolean;
+ public play(
+ animationNames: java.util.List,
+ loop: app.rive.runtime.kotlin.core.Loop,
+ direction: app.rive.runtime.kotlin.core.Direction,
+ areStateMachines: boolean,
+ settleInitialState: boolean
+ ): void;
+ public pause(param0: string, param1: boolean): void;
+ public getAutoplay(): boolean;
+ public onDetachedFromWindow(): void;
+ public onMeasure(param0: number, param1: number): void;
+ public registerListener(param0: app.rive.runtime.kotlin): void;
+ public reset(): void;
+ public getPlayingStateMachines(): java.util.HashSet;
+ public getRenderer(): app.rive.runtime.kotlin;
+ public stop(param0: java.util.List, param1: boolean): void;
+ public setAlignment(param0: app.rive.runtime.kotlin): void;
+ public getArtboardName(): string;
+ public fireState(param0: string, param1: string): void;
+ public makeRenderer(): app.rive.runtime.kotlin;
+ public getRenderer(): app.rive.runtime.kotlin;
+ public stop(): void;
+ public setAutoplay(param0: boolean): void;
+ public onTouchEvent(param0: globalAndroid.view.MotionEvent): boolean;
+ public getAlignment(): app.rive.runtime.kotlin;
+ public pause(animationNames: java.util.List, areStateMachines: boolean): void;
+ public getDefaultAutoplay(): boolean;
+ public registerListener(param0: any): void;
+ public getAnimations(): java.util.List;
+ public onSurfaceTextureSizeChanged(param0: globalAndroid.graphics.SurfaceTexture, param1: number, param2: number): void;
+ public getFile(): app.rive.runtime.kotlin;
+ }
+ export module RiveAnimationView {
+ export class Companion {
+ public static class: java.lang.Class;
+ }
+ export class RendererAttrs {
+ public static class: java.lang.Class;
+ public getLoopIndex(): number;
+ public hashCode(): number;
+ public equals(param0: any): boolean;
+ public constructor(param0: number, param1: number, param2: number, param3: boolean, param4: boolean, param5: string, param6: string, param7: string, param8: number, param9: string);
+ public getAnimationName(): string;
+ public getAutoplay(): boolean;
+ public component2(): number;
+ public component9(): number;
+ public getStateMachineName(): string;
+ public copy(
+ param0: number,
+ param1: number,
+ param2: number,
+ param3: boolean,
+ param4: boolean,
+ param5: string,
+ param6: string,
+ param7: string,
+ param8: number,
+ param9: string
+ ): app.rive.runtime.kotlin;
+ public getFit(): app.rive.runtime.kotlin;
+ public component10(): string;
+ public getRiveTraceAnimations(): boolean;
+ public component1(): number;
+ public component8(): string;
+ public component4(): boolean;
+ public component5(): boolean;
+ public getArtboardName(): string;
+ public component7(): string;
+ public getUrl(): string;
+ public getResourceId(): number;
+ public toString(): string;
+ public getAlignment(): app.rive.runtime.kotlin;
+ public getFitIndex(): number;
+ public getLoop(): app.rive.runtime.kotlin;
+ public getAlignmentIndex(): number;
+ public component6(): string;
+ public component3(): number;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export class RiveArtboardRenderer extends app.rive.runtime.kotlin implements app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public setFit(param0: app.rive.runtime.kotlin): void;
+ public getStateMachines(): java.util.List;
+ public setLoop(param0: app.rive.runtime.kotlin): void;
+ public getFit(): app.rive.runtime.kotlin;
+ public setArtboardName(param0: string): void;
+ public play(param0: app.rive.runtime.kotlin, param1: app.rive.runtime.kotlin, param2: boolean): void;
+ public setNumberState(param0: string, param1: string, param2: number): void;
+ public getLoop(): app.rive.runtime.kotlin;
+ public constructor();
+ public pause(): void;
+ public stopAnimations(): void;
+ public getAutoplay(): boolean;
+ public registerListener(param0: app.rive.runtime.kotlin): void;
+ public setAlignment(param0: app.rive.runtime.kotlin): void;
+ public stopAnimations(param0: java.util.List, param1: boolean): void;
+ public getAnimationName(): string;
+ public artboardBounds(): globalAndroid.graphics.RectF;
+ public setAnimationName(param0: string): void;
+ public setAutoplay(param0: boolean): void;
+ public setRiveFile(param0: app.rive.runtime.kotlin): void;
+ public pause(param0: java.util.List, param1: boolean): void;
+ public stopAnimations(param0: string, param1: boolean): void;
+ public getStateMachineName(): string;
+ public getAnimations(): java.util.List;
+ public getFile(): app.rive.runtime.kotlin;
+ public setBooleanState(param0: string, param1: string, param2: boolean): void;
+ public setTargetBounds(param0: globalAndroid.graphics.RectF): void;
+ public unregisterListener(param0: any): void;
+ public getPlayingAnimations(): java.util.HashSet;
+ public play(param0: string, param1: app.rive.runtime.kotlin, param2: app.rive.runtime.kotlin, param3: boolean, param4: boolean): void;
+ public constructor(
+ param0: app.rive.runtime.kotlin,
+ param1: app.rive.runtime.kotlin,
+ param2: app.rive.runtime.kotlin,
+ param3: string,
+ param4: string,
+ param5: string,
+ param6: boolean,
+ param7: boolean
+ );
+ public unregisterListener(param0: app.rive.runtime.kotlin): void;
+ public play(param0: java.util.List, param1: app.rive.runtime.kotlin, param2: app.rive.runtime.kotlin, param3: boolean, param4: boolean): void;
+ public clear(): void;
+ public pause(param0: string, param1: boolean): void;
+ public draw(): void;
+ public getTargetBounds(): globalAndroid.graphics.RectF;
+ public constructor(param0: number);
+ public reset(): void;
+ public advance(param0: number): void;
+ public getPlayingStateMachines(): java.util.HashSet;
+ public getArtboardName(): string;
+ public fireState(param0: string, param1: string): void;
+ public setArtboardByName(param0: string): void;
+ public constructor(param0: boolean);
+ public setStateMachineName(param0: string): void;
+ public pointerEvent(param0: app.rive.runtime.kotlin, param1: number, param2: number): void;
+ public getAlignment(): app.rive.runtime.kotlin;
+ public getActiveArtboard(): app.rive.runtime.kotlin;
+ public registerListener(param0: any): void;
+ }
+ export module RiveArtboardRenderer {
+ export class Listener {
+ public static class: java.lang.Class;
+ /**
+ * Constructs a new instance of the app.rive.runtime.kotlin$Listener interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
+ */
+ public constructor(implementation: {
+ notifyPlay(param0: app.rive.runtime.kotlin): void;
+ notifyPause(param0: app.rive.runtime.kotlin): void;
+ notifyStop(param0: app.rive.runtime.kotlin): void;
+ notifyLoop(param0: app.rive.runtime.kotlin): void;
+ notifyStateChanged(param0: string, param1: string): void;
+ });
+ public constructor();
+ public notifyLoop(param0: app.rive.runtime.kotlin): void;
+ public notifyStop(param0: app.rive.runtime.kotlin): void;
+ public notifyPause(param0: app.rive.runtime.kotlin): void;
+ public notifyPlay(param0: app.rive.runtime.kotlin): void;
+ public notifyStateChanged(param0: string, param1: string): void;
+ }
+ export class WhenMappings {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export class RiveFileRequest extends com.android.volley.Request {
+ public static class: java.lang.Class;
+ public constructor(param0: string, param1: com.android.volley.Response.Listener, param2: com.android.volley.Response.ErrorListener);
+ public parseNetworkResponse(param0: com.android.volley.NetworkResponse): com.android.volley.Response;
+ public deliverResponse(param0: app.rive.runtime.kotlin): void;
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export class RiveInitializer extends androidx.startup.Initializer {
+ public static class: java.lang.Class;
+ public create(param0: globalAndroid.content.Context): void;
+ public constructor();
+ public dependencies(): java.util.List>;
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export abstract class RiveTextureView {
+ public static class: java.lang.Class;
+ public static TAG: string;
+ public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet);
+ public onSurfaceTextureAvailable(param0: globalAndroid.graphics.SurfaceTexture, param1: number, param2: number): void;
+ public onDetachedFromWindow(): void;
+ public getRenderer(): app.rive.runtime.kotlin;
+ public onSurfaceTextureUpdated(param0: globalAndroid.graphics.SurfaceTexture): void;
+ public onSurfaceTextureDestroyed(param0: globalAndroid.graphics.SurfaceTexture): boolean;
+ public onAttachedToWindow(): void;
+ public onVisibilityChanged(param0: globalAndroid.view.View, param1: number): void;
+ public getActivity(): globalAndroid.app.Activity;
+ public onSurfaceTextureSizeChanged(param0: globalAndroid.graphics.SurfaceTexture, param1: number, param2: number): void;
+ }
+ export module RiveTextureView {
+ export class Companion {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module controllers {
+ export class LinearAnimationController extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public initialize(param0: any): boolean;
+ public constructor();
+ public initialize(param0: app.rive.runtime.kotlin): boolean;
+ public constructor(param0: string, param1: boolean, param2: number);
+ public setAnimationInstance(param0: app.rive.runtime.kotlin): void;
+ public apply(param0: number): void;
+ public getAnimationInstance(): app.rive.runtime.kotlin;
+ public getMix(): number;
+ public setMix(param0: number): void;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module controllers {
+ export abstract class RiveController extends java.lang.Object {
+ public static class: java.lang.Class;
+ public constructor();
+ public initialize(param0: T): boolean;
+ public onActivate(): void;
+ public setActive(param0: boolean): void;
+ public apply(param0: number): void;
+ public onDeactivate(): void;
+ public isActive(): boolean;
+ public dispose(): void;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class Alignment {
+ public static class: java.lang.Class;
+ public static TOP_LEFT: app.rive.runtime.kotlin;
+ public static TOP_CENTER: app.rive.runtime.kotlin;
+ public static TOP_RIGHT: app.rive.runtime.kotlin;
+ public static CENTER_LEFT: app.rive.runtime.kotlin;
+ public static CENTER: app.rive.runtime.kotlin;
+ public static CENTER_RIGHT: app.rive.runtime.kotlin;
+ public static BOTTOM_LEFT: app.rive.runtime.kotlin;
+ public static BOTTOM_CENTER: app.rive.runtime.kotlin;
+ public static BOTTOM_RIGHT: app.rive.runtime.kotlin;
+ public static values(): androidNative.Array;
+ public static valueOf(param0: string): app.rive.runtime.kotlin;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class AnimationState extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: number);
+ public getName(): string;
+ public toString(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class AnyState extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: number);
+ public toString(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class Artboard extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public animation(param0: number): app.rive.runtime.kotlin;
+ public animation(param0: string): app.rive.runtime.kotlin;
+ public drawSkia(param0: number): void;
+ public getAnimationNames(): java.util.List;
+ public getStateMachineNames(): java.util.List;
+ public stateMachine(param0: string): app.rive.runtime.kotlin;
+ public advance(param0: number): boolean;
+ public stateMachine(param0: number): app.rive.runtime.kotlin;
+ public getName(): string;
+ public getFirstStateMachine(): app.rive.runtime.kotlin;
+ public cppDelete(param0: number): void;
+ public getFirstAnimation(): app.rive.runtime.kotlin;
+ public constructor(param0: number);
+ public getAnimationCount(): number;
+ public getStateMachineCount(): number;
+ public drawSkia(param0: number, param1: app.rive.runtime.kotlin, param2: app.rive.runtime.kotlin): void;
+ public getBounds(): globalAndroid.graphics.RectF;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class BlendState extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: number);
+ public toString(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class Decoder {
+ public static class: java.lang.Class;
+ public constructor();
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class Direction {
+ public static class: java.lang.Class;
+ public static BACKWARDS: app.rive.runtime.kotlin;
+ public static FORWARDS: app.rive.runtime.kotlin;
+ public static AUTO: app.rive.runtime.kotlin;
+ public static valueOf(param0: string): app.rive.runtime.kotlin;
+ public static values(): androidNative.Array;
+ public getValue(): number;
+ }
+ export module Direction {
+ export class Companion {
+ public static class: java.lang.Class;
+ public fromInt(param0: number): app.rive.runtime.kotlin;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class EntryState extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: number);
+ public toString(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class ExitState extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: number);
+ public toString(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class File extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public getArtboardCount(): number;
+ public constructor(param0: androidNative.Array);
+ public getArtboardNames(): java.util.List;
+ public artboard(param0: number): app.rive.runtime.kotlin;
+ public cppDelete(param0: number): void;
+ public constructor(param0: number);
+ public getFirstArtboard(): app.rive.runtime.kotlin;
+ public artboard(param0: string): app.rive.runtime.kotlin;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class Fit {
+ public static class: java.lang.Class;
+ public static FILL: app.rive.runtime.kotlin;
+ public static CONTAIN: app.rive.runtime.kotlin;
+ public static COVER: app.rive.runtime.kotlin;
+ public static FIT_WIDTH: app.rive.runtime.kotlin;
+ public static FIT_HEIGHT: app.rive.runtime.kotlin;
+ public static NONE: app.rive.runtime.kotlin;
+ public static SCALE_DOWN: app.rive.runtime.kotlin;
+ public static valueOf(param0: string): app.rive.runtime.kotlin;
+ public static values(): androidNative.Array;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class Helpers {
+ public static class: java.lang.Class;
+ public static INSTANCE: app.rive.runtime.kotlin;
+ public convertToArtboardSpace(
+ param0: globalAndroid.graphics.RectF,
+ param1: globalAndroid.graphics.PointF,
+ param2: app.rive.runtime.kotlin,
+ param3: app.rive.runtime.kotlin,
+ param4: globalAndroid.graphics.RectF
+ ): globalAndroid.graphics.PointF;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class LayerState extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public isExitState(): boolean;
+ public isAnimationState(): boolean;
+ public constructor(param0: number);
+ public isBlendState(): boolean;
+ public isEntryState(): boolean;
+ public isBlendStateDirect(): boolean;
+ public isAnyState(): boolean;
+ public isBlendState1D(): boolean;
+ public toString(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class LinearAnimationInstance extends app.rive.runtime.kotlin implements app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public time(param0: number): void;
+ public getDuration(): number;
+ public apply(param0: number): boolean;
+ public getDirection(): app.rive.runtime.kotlin;
+ public getWorkStart(): number;
+ public getTime(): number;
+ public getName(): string;
+ public getWorkEnd(): number;
+ public getStartTime(): number;
+ public getEndTime(): number;
+ public apply(): void;
+ public getLoop(): app.rive.runtime.kotlin;
+ public cppDelete(param0: number): void;
+ public constructor(param0: number);
+ public getEffectiveDurationInSeconds(): number;
+ public advance(param0: number): app.rive.runtime.kotlin;
+ public setLoop(param0: app.rive.runtime.kotlin): void;
+ public setDirection(param0: app.rive.runtime.kotlin): void;
+ public getEffectiveDuration(): number;
+ public constructor(param0: number, param1: number);
+ public getFps(): number;
+ public getMix(): number;
+ public setMix(param0: number): void;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class Loop {
+ public static class: java.lang.Class;
+ public static ONESHOT: app.rive.runtime.kotlin;
+ public static LOOP: app.rive.runtime.kotlin;
+ public static PINGPONG: app.rive.runtime.kotlin;
+ public static AUTO: app.rive.runtime.kotlin;
+ public static valueOf(param0: string): app.rive.runtime.kotlin;
+ public getValue(): number;
+ public static values(): androidNative.Array;
+ }
+ export module Loop {
+ export class Companion {
+ public static class: java.lang.Class;
+ public fromInt(param0: number): app.rive.runtime.kotlin;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export abstract class NativeObject {
+ public static class: java.lang.Class;
+ public static NULL_POINTER: number;
+ public cppDelete(param0: number): void;
+ public constructor(param0: number);
+ public getHasCppObject(): boolean;
+ public getCppPointer(): number;
+ public getDependencies(): java.util.List;
+ public setCppPointer(param0: number): void;
+ public dispose(): void;
+ }
+ export module NativeObject {
+ export class Companion {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class PlayableInstance {
+ public static class: java.lang.Class;
+ /**
+ * Constructs a new instance of the app.rive.runtime.kotlin interface with the provided implementation. An empty constructor exists calling super() when extending the interface class.
+ */
+ public constructor(implementation: { getName(): string });
+ public constructor();
+ public getName(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class Rive {
+ public static class: java.lang.Class;
+ public static INSTANCE: app.rive.runtime.kotlin;
+ public initializeCppEnvironment(): void;
+ public init(param0: globalAndroid.content.Context): void;
+ public calculateRequiredBounds(
+ param0: app.rive.runtime.kotlin,
+ param1: app.rive.runtime.kotlin,
+ param2: globalAndroid.graphics.RectF,
+ param3: globalAndroid.graphics.RectF
+ ): globalAndroid.graphics.RectF;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class SMIBoolean extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public setValue(param0: boolean): void;
+ public constructor(param0: number);
+ public getValue(): boolean;
+ public toString(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class SMIInput extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public isTrigger(): boolean;
+ public constructor(param0: number);
+ public isBoolean(): boolean;
+ public isNumber(): boolean;
+ public getName(): string;
+ public toString(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class SMINumber extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: number);
+ public setValue(param0: number): void;
+ public toString(): string;
+ public getValue(): number;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class SMITrigger extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: number);
+ public fire(): void;
+ public toString(): string;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export class StateMachineInstance extends app.rive.runtime.kotlin implements app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public pointerUp(param0: number, param1: number): void;
+ public getInputCount(): number;
+ public input(param0: string): app.rive.runtime.kotlin;
+ public pointerMove(param0: number, param1: number): void;
+ public getInputNames(): java.util.List;
+ public advance(param0: number): boolean;
+ public getName(): string;
+ public getLayerCount(): number;
+ public getStatesChanged(): java.util.List;
+ public stateChanged(param0: number): app.rive.runtime.kotlin;
+ public cppDelete(param0: number): void;
+ public constructor(param0: number);
+ public getInputs(): java.util.List;
+ public pointerDown(param0: number, param1: number): void;
+ public input(param0: number): app.rive.runtime.kotlin;
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export module errors {
+ export class AnimationException extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: string);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export module errors {
+ export class ArtboardException extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: string);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export module errors {
+ export class MalformedFileException extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: string);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export module errors {
+ export class RiveException {
+ public static class: java.lang.Class;
+ public constructor(param0: string);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export module errors {
+ export class StateMachineException extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: string);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export module errors {
+ export class StateMachineInputException extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: string);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module core {
+ export module errors {
+ export class UnsupportedRuntimeVersionException extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public constructor(param0: string);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module renderers {
+ export class RendererMetrics {
+ public static class: java.lang.Class;
+ public static SAMPLES: number;
+ public constructor(param0: globalAndroid.app.Activity);
+ public onFrameMetricsAvailable(param0: globalAndroid.view.Window, param1: globalAndroid.view.FrameMetrics, param2: number): void;
+ }
+ export module RendererMetrics {
+ export class Companion {
+ public static class: java.lang.Class;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+declare module app {
+ export module rive {
+ export module runtime {
+ export module kotlin {
+ export module renderers {
+ export abstract class RendererSkia extends app.rive.runtime.kotlin {
+ public static class: java.lang.Class;
+ public scheduleFrame(): void;
+ public restore(): void;
+ public constructor();
+ public delete(): void;
+ public isPlaying(): boolean;
+ public disposeDependencies(): void;
+ public getHeight(): number;
+ public setSurface(param0: globalAndroid.view.Surface): void;
+ public stop(): void;
+ public advance(param0: number): void;
+ public doFrame(param0: number): void;
+ public getWidth(): number;
+ public make(): void;
+ public start(): void;
+ public getAverageFps(): number;
+ public cppDelete(param0: number): void;
+ public constructor(param0: number);
+ public stopThread$any_release(): void;
+ public constructor(param0: boolean);
+ public save(): void;
+ public draw(): void;
+ public align(param0: app.rive.runtime.kotlin, param1: app.rive.runtime.kotlin, param2: globalAndroid.graphics.RectF, param3: globalAndroid.graphics.RectF): void;
+ }
+ }
+ }
+ }
+ }
+}
+
+//Generics information:
+//app.rive.runtime.kotlin.Observable:1
+//app.rive.runtime.kotlin.controllers.RiveController:1
diff --git a/packages/nativescript-rive/typings/objc!NSCRiveController.d.ts b/packages/nativescript-rive/typings/objc!NSCRiveController.d.ts
new file mode 100644
index 0000000..d042ced
--- /dev/null
+++ b/packages/nativescript-rive/typings/objc!NSCRiveController.d.ts
@@ -0,0 +1,35 @@
+declare class NSCRiveController extends UIViewController {
+ static alloc(): NSCRiveController; // inherited from NSObject
+
+ static new(): NSCRiveController; // inherited from NSObject
+
+ riveView: RiveView;
+
+ riveViewModel: RiveViewModel;
+
+ configureModelWithArtboardStateMachineAnimation(artboard: string, stateMachine: string, animation: string): void;
+
+ isPlaying(): boolean;
+
+ pause(): void;
+
+ playWithDirectionLoopName(direction: number, loop: string, name: string): void;
+
+ setDelegateWithDelegate(delegate: RiveStateMachineDelegate): void;
+
+ setFit(fit: number): void;
+
+ setInputWithNameNumber(name: string, number: number): void;
+
+ setInputWithNameBinary(name: string, binary: boolean): void;
+
+ setModelResourceWithNameFit(name: string, fit: number): void;
+
+ setModelWithFileFit(file: RiveFile, fit: number): void;
+
+ setTextWithNameValueError(name: string, value: string): boolean;
+
+ stop(): void;
+
+ triggerInputWithName(name: string): void;
+}
diff --git a/packages/nativescript-rive/typings/objc!RiveRuntime.d.ts b/packages/nativescript-rive/typings/objc!RiveRuntime.d.ts
new file mode 100644
index 0000000..e0ad446
--- /dev/null
+++ b/packages/nativescript-rive/typings/objc!RiveRuntime.d.ts
@@ -0,0 +1,495 @@
+declare const enum RiveAlignment {
+ topLeft = 0,
+
+ topCenter = 1,
+
+ topRight = 2,
+
+ centerLeft = 3,
+
+ center = 4,
+
+ centerRight = 5,
+
+ bottomLeft = 6,
+
+ bottomCenter = 7,
+
+ bottomRight = 8,
+}
+
+declare class RiveAnimationState extends RiveLayerState {
+ static alloc(): RiveAnimationState; // inherited from NSObject
+
+ static new(): RiveAnimationState; // inherited from NSObject
+}
+
+declare class RiveAnyState extends RiveLayerState {
+ static alloc(): RiveAnyState; // inherited from NSObject
+
+ static new(): RiveAnyState; // inherited from NSObject
+}
+
+declare class RiveArtboard extends NSObject {
+ static alloc(): RiveArtboard; // inherited from NSObject
+
+ static new(): RiveArtboard; // inherited from NSObject
+
+ advanceBy(elapsedSeconds: number): void;
+
+ animationCount(): number;
+
+ animationFromIndexError(index: number): RiveLinearAnimationInstance;
+
+ animationFromNameError(name: string): RiveLinearAnimationInstance;
+
+ animationNames(): NSArray;
+
+ bounds(): CGRect;
+
+ defaultStateMachine(): RiveStateMachineInstance;
+
+ draw(renderer: RiveRenderer): void;
+
+ name(): string;
+
+ stateMachineCount(): number;
+
+ stateMachineFromIndexError(index: number): RiveStateMachineInstance;
+
+ stateMachineFromNameError(name: string): RiveStateMachineInstance;
+
+ stateMachineNames(): NSArray;
+
+ textRun(name: string): RiveTextValueRun;
+}
+
+declare const enum RiveDirection {
+ backwards = 0,
+
+ forwards = 1,
+
+ autoDirection = 2,
+}
+
+declare class RiveEntryState extends RiveLayerState {
+ static alloc(): RiveEntryState; // inherited from NSObject
+
+ static new(): RiveEntryState; // inherited from NSObject
+}
+
+declare const enum RiveErrorCode {
+ NoArtboardsFound = 100,
+
+ NoArtboardFound = 101,
+
+ NoAnimations = 200,
+
+ NoAnimationFound = 201,
+
+ NoStateMachines = 300,
+
+ NoStateMachineFound = 301,
+
+ NoStateMachineInputFound = 400,
+
+ UnknownStateMachineInput = 401,
+
+ NoStateChangeFound = 402,
+
+ UnsupportedVersion = 500,
+
+ MalformedFile = 600,
+
+ UnknownError = 700,
+}
+
+declare var RiveErrorDomain: string;
+
+declare class RiveExitState extends RiveLayerState {
+ static alloc(): RiveExitState; // inherited from NSObject
+
+ static new(): RiveExitState; // inherited from NSObject
+}
+
+declare class RiveFile extends NSObject {
+ static alloc(): RiveFile; // inherited from NSObject
+
+ static new(): RiveFile; // inherited from NSObject
+
+ delegate: any;
+
+ isLoaded: boolean;
+
+ static readonly majorVersion: number;
+
+ static readonly minorVersion: number;
+
+ constructor(o: { byteArray: NSArray | any[] });
+
+ constructor(o: { bytes: string | interop.Pointer | interop.Reference; byteLength: number });
+
+ constructor(o: { httpUrl: string; withDelegate: RiveFileDelegate });
+
+ constructor(o: { resource: string });
+
+ constructor(o: { resource: string; withExtension: string });
+
+ artboard(): RiveArtboard;
+
+ artboardCount(): number;
+
+ artboardFromIndexError(index: number): RiveArtboard;
+
+ artboardFromNameError(name: string): RiveArtboard;
+
+ artboardNames(): NSArray;
+
+ initWithByteArrayError(bytes: NSArray | any[]): this;
+
+ initWithBytesByteLengthError(bytes: string | interop.Pointer | interop.Reference, length: number): this;
+
+ initWithHttpUrlWithDelegate(url: string, delegate: RiveFileDelegate): this;
+
+ initWithResourceError(resourceName: string): this;
+
+ initWithResourceWithExtensionError(resourceName: string, extension: string): this;
+}
+
+interface RiveFileDelegate extends NSObjectProtocol {
+ riveFileDidLoadError(riveFile: RiveFile): boolean;
+}
+declare var RiveFileDelegate: {
+ prototype: RiveFileDelegate;
+};
+
+declare const enum RiveFit {
+ fill = 0,
+
+ contain = 1,
+
+ cover = 2,
+
+ fitHeight = 3,
+
+ fitWidth = 4,
+
+ scaleDown = 5,
+
+ noFit = 6,
+}
+
+declare class RiveLayerState extends NSObject {
+ static alloc(): RiveLayerState; // inherited from NSObject
+
+ static new(): RiveLayerState; // inherited from NSObject
+
+ isAnimationState(): boolean;
+
+ isAnyState(): boolean;
+
+ isEntryState(): boolean;
+
+ isExitState(): boolean;
+
+ name(): string;
+
+ rive_layer_state(): interop.Pointer | interop.Reference;
+}
+
+declare class RiveLinearAnimationInstance extends NSObject {
+ static alloc(): RiveLinearAnimationInstance; // inherited from NSObject
+
+ static new(): RiveLinearAnimationInstance; // inherited from NSObject
+
+ advanceBy(elapsedSeconds: number): boolean;
+
+ didLoop(): boolean;
+
+ direction(): number;
+
+ duration(): number;
+
+ effectiveDuration(): number;
+
+ effectiveDurationInSeconds(): number;
+
+ endTime(): number;
+
+ fps(): number;
+
+ hasEnded(): boolean;
+
+ loop(): number;
+
+ name(): string;
+
+ setTime(time: number): void;
+
+ time(): number;
+
+ workEnd(): number;
+
+ workStart(): number;
+}
+
+declare const enum RiveLoop {
+ oneShot = 0,
+
+ loop = 1,
+
+ pingPong = 2,
+
+ autoLoop = 3,
+}
+
+declare class RiveRenderer extends NSObject {
+ static alloc(): RiveRenderer; // inherited from NSObject
+
+ static new(): RiveRenderer; // inherited from NSObject
+
+ constructor(o: { context: any });
+
+ alignWithRectWithContentRectWithAlignmentWithFit(rect: CGRect, contentRect: CGRect, alignment: RiveAlignment, fit: RiveFit): void;
+
+ initWithContext(context: any): this;
+}
+
+declare class RiveRendererView extends MTKView {
+ static alloc(): RiveRendererView; // inherited from NSObject
+
+ static appearance(): RiveRendererView; // inherited from UIAppearance
+
+ static appearanceForTraitCollection(trait: UITraitCollection): RiveRendererView; // inherited from UIAppearance
+
+ static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): RiveRendererView; // inherited from UIAppearance
+
+ static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(trait: UITraitCollection, containerTypes: NSArray | (typeof NSObject)[]): RiveRendererView; // inherited from UIAppearance
+
+ static appearanceWhenContainedIn(ContainerClass: typeof NSObject): RiveRendererView; // inherited from UIAppearance
+
+ static appearanceWhenContainedInInstancesOfClasses(containerTypes: NSArray | (typeof NSObject)[]): RiveRendererView; // inherited from UIAppearance
+
+ static new(): RiveRendererView; // inherited from NSObject
+
+ alignWithRectContentRectAlignmentFit(rect: CGRect, contentRect: CGRect, alignment: RiveAlignment, fit: RiveFit): void;
+
+ artboardLocationFromTouchLocationInArtboardFitAlignment(touchLocation: CGPoint, artboardRect: CGRect, fit: RiveFit, alignment: RiveAlignment): CGPoint;
+
+ drawRiveSize(rect: CGRect, size: CGSize): void;
+
+ drawWithArtboard(artboard: RiveArtboard): void;
+
+ isPaused(): boolean;
+}
+
+declare var RiveRuntimeVersionNumber: number;
+
+declare var RiveRuntimeVersionString: interop.Reference;
+
+declare class RiveSMIBool extends RiveSMIInput {
+ static alloc(): RiveSMIBool; // inherited from NSObject
+
+ static new(): RiveSMIBool; // inherited from NSObject
+
+ setValue(newValue: boolean): void;
+
+ value(): boolean;
+}
+
+declare class RiveSMIInput extends NSObject {
+ static alloc(): RiveSMIInput; // inherited from NSObject
+
+ static new(): RiveSMIInput; // inherited from NSObject
+
+ isBoolean(): boolean;
+
+ isNumber(): boolean;
+
+ isTrigger(): boolean;
+
+ name(): string;
+}
+
+declare class RiveSMINumber extends RiveSMIInput {
+ static alloc(): RiveSMINumber; // inherited from NSObject
+
+ static new(): RiveSMINumber; // inherited from NSObject
+
+ setValue(newValue: number): void;
+
+ value(): number;
+}
+
+declare class RiveSMITrigger extends RiveSMIInput {
+ static alloc(): RiveSMITrigger; // inherited from NSObject
+
+ static new(): RiveSMITrigger; // inherited from NSObject
+
+ fire(): void;
+}
+
+interface RiveStateMachineDelegate {
+ stateMachineDidChangeState?(stateMachine: RiveStateMachineInstance, stateName: string): void;
+
+ stateMachineReceivedInput?(stateMachine: RiveStateMachineInstance, input: StateMachineInput): void;
+
+ touchBeganOnArtboardAtLocation?(artboard: RiveArtboard, location: CGPoint): void;
+
+ touchCancelledOnArtboardAtLocation?(artboard: RiveArtboard, location: CGPoint): void;
+
+ touchEndedOnArtboardAtLocation?(artboard: RiveArtboard, location: CGPoint): void;
+
+ touchMovedOnArtboardAtLocation?(artboard: RiveArtboard, location: CGPoint): void;
+}
+declare var RiveStateMachineDelegate: {
+ prototype: RiveStateMachineDelegate;
+};
+
+declare class RiveStateMachineInstance extends NSObject {
+ static alloc(): RiveStateMachineInstance; // inherited from NSObject
+
+ static new(): RiveStateMachineInstance; // inherited from NSObject
+
+ advanceBy(elapsedSeconds: number): boolean;
+
+ getBool(name: string): RiveSMIBool;
+
+ getNumber(name: string): RiveSMINumber;
+
+ getTrigger(name: string): RiveSMITrigger;
+
+ inputCount(): number;
+
+ inputFromIndexError(index: number): RiveSMIInput;
+
+ inputFromNameError(name: string): RiveSMIInput;
+
+ inputNames(): NSArray;
+
+ layerCount(): number;
+
+ name(): string;
+
+ stateChangedCount(): number;
+
+ stateChangedFromIndexError(index: number): RiveLayerState;
+
+ stateChanges(): NSArray;
+
+ touchBeganAtLocation(touchLocation: CGPoint): void;
+
+ touchCancelledAtLocation(touchLocation: CGPoint): void;
+
+ touchEndedAtLocation(touchLocation: CGPoint): void;
+
+ touchMovedAtLocation(touchLocation: CGPoint): void;
+}
+
+declare class RiveTextValueRun extends NSObject {
+ static alloc(): RiveTextValueRun; // inherited from NSObject
+
+ static new(): RiveTextValueRun; // inherited from NSObject
+
+ setText(newValue: string): void;
+
+ text(): string;
+}
+
+declare class RiveUnknownState extends RiveLayerState {
+ static alloc(): RiveUnknownState; // inherited from NSObject
+
+ static new(): RiveUnknownState; // inherited from NSObject
+}
+
+declare class RiveView extends RiveRendererView {
+ static alloc(): RiveView; // inherited from NSObject
+
+ static appearance(): RiveView; // inherited from UIAppearance
+
+ static appearanceForTraitCollection(trait: UITraitCollection): RiveView; // inherited from UIAppearance
+
+ static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): RiveView; // inherited from UIAppearance
+
+ static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(trait: UITraitCollection, containerTypes: NSArray | (typeof NSObject)[]): RiveView; // inherited from UIAppearance
+
+ static appearanceWhenContainedIn(ContainerClass: typeof NSObject): RiveView; // inherited from UIAppearance
+
+ static appearanceWhenContainedInInstancesOfClasses(containerTypes: NSArray | (typeof NSObject)[]): RiveView; // inherited from UIAppearance
+
+ static new(): RiveView; // inherited from NSObject
+
+ advanceWithDelta(delta: number): void;
+}
+
+declare class RiveViewModel extends NSObject implements RiveFileDelegate, RiveStateMachineDelegate {
+ static alloc(): RiveViewModel; // inherited from NSObject
+
+ static new(): RiveViewModel; // inherited from NSObject
+
+ readonly debugDescription: string; // inherited from NSObjectProtocol
+
+ readonly description: string; // inherited from NSObjectProtocol
+
+ readonly hash: number; // inherited from NSObjectProtocol
+
+ readonly isProxy: boolean; // inherited from NSObjectProtocol
+
+ readonly superclass: typeof NSObject; // inherited from NSObjectProtocol
+
+ readonly; // inherited from NSObjectProtocol
+
+ class(): typeof NSObject;
+
+ conformsToProtocol(aProtocol: any /* Protocol */): boolean;
+
+ isEqual(object: any): boolean;
+
+ isKindOfClass(aClass: typeof NSObject): boolean;
+
+ isMemberOfClass(aClass: typeof NSObject): boolean;
+
+ performSelector(aSelector: string): any;
+
+ performSelectorWithObject(aSelector: string, object: any): any;
+
+ performSelectorWithObjectWithObject(aSelector: string, object1: any, object2: any): any;
+
+ respondsToSelector(aSelector: string): boolean;
+
+ retainCount(): number;
+
+ riveFileDidLoadError(riveFile: RiveFile): boolean;
+
+ self(): this;
+
+ setView(view: RiveView): void;
+
+ stateMachineDidChangeState(stateMachine: RiveStateMachineInstance, stateName: string): void;
+
+ stateMachineReceivedInput(stateMachine: RiveStateMachineInstance, input: StateMachineInput): void;
+
+ touchBeganOnArtboardAtLocation(artboard: RiveArtboard, location: CGPoint): void;
+
+ touchCancelledOnArtboardAtLocation(artboard: RiveArtboard, location: CGPoint): void;
+
+ touchEndedOnArtboardAtLocation(artboard: RiveArtboard, location: CGPoint): void;
+
+ touchMovedOnArtboardAtLocation(artboard: RiveArtboard, location: CGPoint): void;
+
+ updateWithView(view: RiveView): void;
+}
+
+declare class StateMachineInput extends NSObject {
+ static alloc(): StateMachineInput; // inherited from NSObject
+
+ static new(): StateMachineInput; // inherited from NSObject
+}
+
+declare const enum StateMachineInputType {
+ Trigger = 0,
+
+ Number = 1,
+
+ Boolean = 2,
+}
diff --git a/tools/assets/App_Resources/Android/app.gradle b/tools/assets/App_Resources/Android/app.gradle
index 8a52011..8a5d091 100644
--- a/tools/assets/App_Resources/Android/app.gradle
+++ b/tools/assets/App_Resources/Android/app.gradle
@@ -6,13 +6,25 @@
//}
android {
- compileSdkVersion 32
+ compileSdkVersion 33
+ buildToolsVersion "33.0.0"
+
defaultConfig {
minSdkVersion 21
- targetSdkVersion 32
+ targetSdkVersion 33
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
}
+
+dependencies {
+ constraints {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.21"
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.21"
+ }
+}
\ No newline at end of file
diff --git a/tools/assets/App_Resources/Android/gradle.properties b/tools/assets/App_Resources/Android/gradle.properties
new file mode 100644
index 0000000..55c5b25
--- /dev/null
+++ b/tools/assets/App_Resources/Android/gradle.properties
@@ -0,0 +1 @@
+useKotlin=true
\ No newline at end of file
diff --git a/tools/assets/App_Resources/Android/src/main/AndroidManifest.xml b/tools/assets/App_Resources/Android/src/main/AndroidManifest.xml
index 7eb0a60..50cbad1 100644
--- a/tools/assets/App_Resources/Android/src/main/AndroidManifest.xml
+++ b/tools/assets/App_Resources/Android/src/main/AndroidManifest.xml
@@ -2,7 +2,8 @@
+ android:versionName="1.0"
+ xmlns:tools="http://schemas.android.com/tools">
+
+
+
+