Skip to content

Commit

Permalink
feat(android): Rive (#62)
Browse files Browse the repository at this point in the history
Rive support for Android
  • Loading branch information
m1ga committed Jan 15, 2023
1 parent f1424f0 commit 4723308
Show file tree
Hide file tree
Showing 10 changed files with 444 additions and 132 deletions.
40 changes: 31 additions & 9 deletions README.md
Expand Up @@ -46,7 +46,8 @@ or in Alloy:
Name | Parameter | Info | Platforms
--- | --- | --- | -- |
start() | | Starts an animation from the beginning | iOS, Android |
start(int from, int to) | Startframe, Endframe | Plays an animation from frame `from` to `to` | iOS, Android |
start(int from, int to) | Startframe, Endframe | Plays an animation from frame `from` to `to` | Android |
start({string animationName, bool loop}) | | Plays the rive animation | Android |
pause() | | Pause an animation | iOS, Android |
resume() | | Resumes an animation from the current point | iOS, Android |
stop() | | Stops an animation an resets it | iOS, Android |
Expand All @@ -56,14 +57,16 @@ setText(String layer, String text) | Layer, Text | Sets the text in the layer `l

## Properties

Name | Parameter | Info | Platforms
--- | --- | --- | --- |
progress | float | Get/set the current progress (in percentage) | iOS, Android |
loop | boolean | Get/set if the animation should loop | iOS, Android |
speed | float | Get/set the speed of the animation | iOS, Android |
duration | float | Get/set the duration of the animation | iOS, Android |
isPlaying | boolean | Get the animation status | iOS, Android |
newRenderingEngineEnabled | boolean | Use the core animation background rendering engine instead of the main thread | iOS |
Name | Parameter | Info | Framework | Platforms
--- | --- | --- | --- | --- |
progress | float | Get/set the current progress (in percentage) | Lottie | Android |
loop | boolean | Get/set if the animation should loop | Lottie | Android |
speed | float | Get/set the speed of the animation | Lottie | Android |
duration | float | Get/set the duration of the animation | Lottie | Android |
isPlaying | boolean | Get the animation status | Lottie | Android |
cache() | boolean | - | Lottie | iOS |
animationName | String or Array | Sets the Rive animation name | Rive | Android |
newRenderingEngineEnabled | boolean | Use the core animation background rendering engine instead of the main thread | Lottie | iOS |

creation (tss) only:

Expand All @@ -74,6 +77,7 @@ file | String | JSON file. Files go into app/assets/ (Alloy)<br/>Android: Suppor
jsonString | String | Pass a raw JSON string to the module | iOS |
loop | boolean | loop the animation | iOS, Android |
autoStart | boolean | automatically start the animation | iOS, Android |
animationType | int | One of the constants `ANIMATION_LOTTIE` or `ANIMATION_RIVE` | iOS, Android |


## Events
Expand All @@ -83,6 +87,24 @@ Name | Info | Properties | Platforms
complete | When the animation is done | Status:int, Loop:boolean | iOS, Android |
update | Fires during the animation | Frame:int, status:int (ANIMATION_START, ANIMATION_END, ANIMATION_CANCEL, ANIMATION_REPEAT, ANIMATION_RUNNING) | Android |

## Constants

Name | Platforms
--- | --- |
ANIMATION_RIVE | Android |
ANIMATION_LOTTIE | Android |

used in setValueDelegateForKeyPath.type (iOS):

Name | Platforms
--- | --- |
CALLBACK_COLOR_VALUE | iOS |
CALLBACK_NUMBER_VALUE | iOS |
CALLBACK_POINT_VALUE | iOS |
CALLBACK_SIZE_VALUE | iOS |
CALLBACK_PATH_VALUE | iOS |


## Example

```xml
Expand Down
2 changes: 2 additions & 0 deletions android/build.gradle
Expand Up @@ -3,5 +3,7 @@ repositories {
}

dependencies {
implementation "androidx.startup:startup-runtime:1.1.0"
implementation 'com.airbnb.android:lottie:5.2.0'
implementation 'app.rive:rive-android:4.2.2'
}
2 changes: 1 addition & 1 deletion android/manifest
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 4.3.0
version: 4.4.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: ti.animation
Expand Down
12 changes: 12 additions & 0 deletions android/platform/android/res/layout/layout_rive.xml
@@ -0,0 +1,12 @@
<LinearLayout android:background="#00ffffff"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<app.rive.runtime.kotlin.RiveAnimationView
android:id="@+id/animation_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>

0 comments on commit 4723308

Please sign in to comment.