├── .github
└── workflows
│ ├── deploy.yml
│ └── release.yml
├── .gitignore
├── .idea
├── .gitignore
├── .name
├── artifacts
│ ├── app_jvm.xml
│ ├── app_jvm_1_0_0.xml
│ ├── app_jvm_1_0_1.xml
│ ├── app_jvm_1_0_2.xml
│ ├── app_wasm_js.xml
│ ├── easing_js.xml
│ ├── easing_jvm.xml
│ ├── easing_jvm_1_0_0.xml
│ ├── easing_jvm_1_0_1.xml
│ ├── easing_jvm_1_0_2.xml
│ ├── easing_wasm_js.xml
│ ├── easing_wasm_js_1_0_0.xml
│ ├── easing_wasm_js_1_0_1.xml
│ ├── easing_wasm_js_1_0_2.xml
│ ├── value_animator_jvm.xml
│ ├── value_animator_jvm_1_0_0.xml
│ ├── value_animator_jvm_1_0_1.xml
│ ├── value_animator_jvm_1_0_2.xml
│ ├── value_animator_wasm_js.xml
│ ├── value_animator_wasm_js_1_0_0.xml
│ ├── value_animator_wasm_js_1_0_1.xml
│ └── value_animator_wasm_js_1_0_2.xml
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── compiler.xml
├── gradle.xml
├── kotlinc.xml
├── misc.xml
└── vcs.xml
├── LICENSE.txt
├── README.md
├── app
├── .editorconfig
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ ├── androidMain
│ ├── AndroidManifest.xml
│ ├── kotlin
│ │ └── co
│ │ │ └── touchlab
│ │ │ └── composeanimations
│ │ │ └── animations
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── arrow_forward.xml
│ │ └── ic_launcher_background.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ ├── commonMain
│ ├── composeResources
│ │ └── values
│ │ │ └── strings.xml
│ └── kotlin
│ │ ├── androidx
│ │ └── compose
│ │ │ └── desktop
│ │ │ └── ui
│ │ │ └── tooling
│ │ │ └── preview
│ │ │ └── Preview.kt
│ │ └── co
│ │ └── touchlab
│ │ └── composeanimations
│ │ └── animations
│ │ ├── App.kt
│ │ ├── page
│ │ ├── Easings.kt
│ │ ├── Home.kt
│ │ └── ValueAnimatorDemo.kt
│ │ ├── screen
│ │ ├── EasingsScreen.kt
│ │ ├── HomeScreen.kt
│ │ └── ValueAnimatorScreen.kt
│ │ ├── shapes
│ │ ├── Ball.kt
│ │ └── Triangle.kt
│ │ ├── theme
│ │ ├── Color.kt
│ │ ├── Shape.kt
│ │ ├── Theme.kt
│ │ └── Type.kt
│ │ └── utils
│ │ └── size.kt
│ ├── iosMain
│ └── kotlin
│ │ └── co
│ │ └── touchlab
│ │ └── composeanimations
│ │ └── animations
│ │ └── vc
│ │ └── MainViewController.kt
│ └── jvmMain
│ └── kotlin
│ └── co
│ └── touchlab
│ └── composeanimations
│ └── animations
│ └── Main.kt
├── build.gradle.kts
├── easing
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── easing-demo.gif
├── proguard-rules.pro
└── src
│ ├── androidMain
│ └── AndroidManifest.xml
│ └── commonMain
│ └── kotlin
│ └── co
│ └── touchlab
│ └── composeanimations
│ └── easing
│ ├── Back.kt
│ ├── Bounce.kt
│ ├── Circ.kt
│ ├── Cubic.kt
│ ├── Elastic.kt
│ ├── Expo.kt
│ ├── Quad.kt
│ ├── Quart.kt
│ ├── Quint.kt
│ └── Sine.kt
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── iosApp
├── Configuration
│ └── Config.xcconfig
├── iosApp.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── faogustavo.xcuserdatad
│ │ │ ├── UserInterfaceState.xcuserstate
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ └── xcuserdata
│ │ └── faogustavo.xcuserdatad
│ │ └── xcschemes
│ │ ├── iosApp.xcscheme
│ │ └── xcschememanagement.plist
└── iosApp
│ ├── Assets.xcassets
│ ├── AccentColor.colorset
│ │ └── Contents.json
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ └── app-icon-1024.png
│ └── Contents.json
│ ├── ContentView.swift
│ ├── Info.plist
│ ├── Preview Content
│ └── Preview Assets.xcassets
│ │ └── Contents.json
│ └── iOSApp.swift
├── kotlin-js-store
└── yarn.lock
├── settings.gradle.kts
├── tl2.png
└── value-animator
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
├── src
├── androidMain
│ └── AndroidManifest.xml
└── commonMain
│ └── kotlin
│ └── co
│ └── touchlab
│ └── composeanimations
│ └── value
│ └── animator
│ ├── MultipleValuesAnimator.kt
│ ├── ValueAtFraction.kt
│ ├── animateAsState.kt
│ ├── animateTransitionValuesAsState.kt
│ ├── animateValuesAsState.kt
│ └── utils
│ ├── +intSize.kt
│ ├── +rect.kt
│ └── +size.kt
└── value-animator-demo.gif
/.github/workflows/deploy.yml:
--------------------------------------------------------------------------------
1 | name: deploy
2 | on: workflow_dispatch
3 |
4 | jobs:
5 | deploy:
6 | runs-on: macos-latest
7 | steps:
8 | - name: Checkout the repo
9 | uses: actions/checkout@v2
10 |
11 | - uses: actions/setup-java@v2
12 | with:
13 | distribution: "adopt"
14 | java-version: "17"
15 | - name: Validate Gradle Wrapper
16 | uses: gradle/wrapper-validation-action@v1
17 | - name: Cache gradle
18 | uses: actions/cache@v2
19 | with:
20 | path: ~/.gradle/caches
21 | key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
22 | restore-keys: |
23 | ${{ runner.os }}-gradle-
24 |
25 | - name: Cache konan
26 | uses: actions/cache@v2
27 | with:
28 | path: ~/.konan
29 | key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
30 | restore-keys: |
31 | ${{ runner.os }}-gradle-
32 |
33 | - name: Publish Artifacts
34 | run: ./gradlew publish --no-daemon --stacktrace --no-build-cache
35 | env:
36 | ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
37 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
38 | ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
39 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
40 | ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
41 | ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
42 |
43 | env:
44 | GRADLE_OPTS: -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=512m"
45 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: release
2 | on: workflow_dispatch
3 |
4 | jobs:
5 | release:
6 | runs-on: macos-latest
7 | steps:
8 | - name: Checkout the repo
9 | uses: actions/checkout@v2
10 |
11 | - uses: touchlab/read-property@0.1
12 | id: version-name
13 | with:
14 | file: ./gradle.properties
15 | property: VERSION_NAME
16 |
17 | - name: Echo Version
18 | run: echo "${{ steps.version-name.outputs.propVal }}"
19 |
20 | - uses: actions/setup-java@v2
21 | with:
22 | distribution: "adopt"
23 | java-version: "17"
24 | - name: Validate Gradle Wrapper
25 | uses: gradle/wrapper-validation-action@v1
26 | - name: Cache gradle
27 | uses: actions/cache@v2
28 | with:
29 | path: ~/.gradle/caches
30 | key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
31 | restore-keys: |
32 | ${{ runner.os }}-gradle-
33 |
34 | - name: Cache konan
35 | uses: actions/cache@v2
36 | with:
37 | path: ~/.konan
38 | key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
39 | restore-keys: |
40 | ${{ runner.os }}-gradle-
41 |
42 | - name: Finish Maven Central Release
43 | run: ./gradlew closeAndReleaseRepository --no-daemon --stacktrace --no-build-cache
44 | env:
45 | ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
46 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
47 | ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
48 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
49 | ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
50 | ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
51 |
52 | - name: Create Release
53 | if: ${{ contains(steps.version-match.outputs.group1, 'SNAPSHOT') == false }}
54 | uses: touchlab/release-action@v1.10.0
55 | with:
56 | tag: ${{ steps.version-name.outputs.propVal }}
57 |
58 | env:
59 | GRADLE_OPTS: -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=512m"
60 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | /.idea/deploymentTargetDropDown.xml
11 | /.idea/inspectionProfiles/Project_Default.xml
12 | .kotlin
13 | .DS_Store
14 | /build
15 | /captures
16 | .externalNativeBuild
17 | .cxx
18 | local.properties
19 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # GitHub Copilot persisted chat sessions
5 | /copilot/chatSessions
6 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | ComposeAnimations
--------------------------------------------------------------------------------
/.idea/artifacts/app_jvm.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/app/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/app_jvm_1_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/app/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/app_jvm_1_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/app/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/app_jvm_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/app/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/app_wasm_js.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/app/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/easing_js.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/easing/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/easing_jvm.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/easing/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/easing_jvm_1_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/easing/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/easing_jvm_1_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/easing/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/easing_jvm_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/easing/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/easing_wasm_js.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/easing/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/easing_wasm_js_1_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/easing/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/easing_wasm_js_1_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/easing/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/easing_wasm_js_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/easing/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/value_animator_jvm.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/value-animator/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/value_animator_jvm_1_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/value-animator/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/value_animator_jvm_1_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/value-animator/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/value_animator_jvm_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/value-animator/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/value_animator_wasm_js.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/value-animator/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/value_animator_wasm_js_1_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/value-animator/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/value_animator_wasm_js_1_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/value-animator/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/artifacts/value_animator_wasm_js_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/value-animator/build/libs
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | xmlns:android
15 |
16 | ^$
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | xmlns:.*
26 |
27 | ^$
28 |
29 |
30 | BY_NAME
31 |
32 |
33 |
34 |
35 |
36 |
37 | .*:id
38 |
39 | http://schemas.android.com/apk/res/android
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | .*:name
49 |
50 | http://schemas.android.com/apk/res/android
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | name
60 |
61 | ^$
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | style
71 |
72 | ^$
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | .*
82 |
83 | ^$
84 |
85 |
86 | BY_NAME
87 |
88 |
89 |
90 |
91 |
92 |
93 | .*
94 |
95 | http://schemas.android.com/apk/res/android
96 |
97 |
98 | ANDROID_ATTRIBUTE_ORDER
99 |
100 |
101 |
102 |
103 |
104 |
105 | .*
106 |
107 | .*
108 |
109 |
110 | BY_NAME
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2020 Touchlab
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Compose Animations
2 | > [!IMPORTANT]
3 | > Many of the things this library does are now also included in the official compose animation api's and this library is no longer being actively worked on. [See more here](https://touchlab.co/compose-animations-library)
4 |
5 | Group of libraries to help you build better animations with [Compose Multiplatform][compose]
6 |
7 | See docs at [Multiplatform Compose Animations](https://touchlab.co/composeanimations)
8 |
9 | License
10 | =======
11 |
12 | Copyright 2024 Touchlab, Inc.
13 |
14 | Licensed under the Apache License, Version 2.0 (the "License");
15 | you may not use this file except in compliance with the License.
16 | You may obtain a copy of the License at
17 |
18 | http://www.apache.org/licenses/LICENSE-2.0
19 |
20 | Unless required by applicable law or agreed to in writing, software
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | [compose]: https://www.jetbrains.com/lp/compose-multiplatform/
27 |
--------------------------------------------------------------------------------
/app/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*.{kt,kts}]
4 | ij_kotlin_continuation_indent_size = 4
5 | ij_kotlin_name_count_to_use_star_import = 500
6 | ij_kotlin_name_count_to_use_star_import_for_members = 500
7 | ij_kotlin_allow_trailing_comma = true
8 | ij_kotlin_allow_trailing_comma_on_call_site = true
9 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.androidApplication)
3 | alias(libs.plugins.kotlinMultiplatform)
4 | alias(libs.plugins.jetbrainsCompose)
5 | alias(libs.plugins.composeCompiler)
6 | }
7 |
8 | kotlin {
9 | jvm()
10 |
11 | listOf(
12 | iosX64(),
13 | iosArm64(),
14 | iosSimulatorArm64(),
15 | ).forEach { iosTarget ->
16 | iosTarget.binaries.framework {
17 | baseName = "ComposeAnimationsApp"
18 | isStatic = true
19 | }
20 | }
21 |
22 | androidTarget {
23 | compilations.all {
24 | kotlinOptions {
25 | jvmTarget = "1.8"
26 | }
27 | }
28 | }
29 |
30 | applyDefaultHierarchyTemplate()
31 |
32 | sourceSets {
33 | commonMain.dependencies {
34 | // Libs
35 | implementation(projects.easing)
36 | implementation(projects.valueAnimator)
37 |
38 | // Compose
39 | implementation(compose.ui)
40 | implementation(compose.runtime)
41 | implementation(compose.foundation)
42 | implementation(compose.animation)
43 | implementation(compose.material)
44 | implementation(compose.materialIconsExtended)
45 | implementation(compose.components.resources)
46 | implementation(compose.components.uiToolingPreview)
47 |
48 | implementation(libs.voyager.navigator)
49 | implementation(libs.voyager.transitions)
50 | }
51 |
52 | jvmMain.dependencies {
53 | implementation(compose.desktop.currentOs)
54 | }
55 |
56 | androidMain.dependencies {
57 | implementation(libs.androidx.coreKtx)
58 | implementation(libs.androidx.lifecycle)
59 | implementation(libs.androidx.activityCompose)
60 | implementation(libs.androidx.appCompat)
61 |
62 | implementation(libs.google.material)
63 |
64 | implementation(libs.compose.toolingPreview)
65 | }
66 | }
67 | }
68 |
69 | android {
70 | namespace = "co.touchlab.compose.animations"
71 | compileSdk = libs.versions.android.compileSdk.get().toInt()
72 |
73 | defaultConfig {
74 | minSdk = libs.versions.android.minSdk.get().toInt()
75 | targetSdk = libs.versions.android.targetSdk.get().toInt()
76 | versionCode = 1
77 | versionName = "1.0"
78 |
79 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
80 | vectorDrawables {
81 | useSupportLibrary = true
82 | }
83 | }
84 |
85 | buildTypes {
86 | release {
87 | isMinifyEnabled = false
88 | }
89 | }
90 |
91 | compileOptions {
92 | sourceCompatibility = JavaVersion.VERSION_1_8
93 | targetCompatibility = JavaVersion.VERSION_1_8
94 | }
95 |
96 | buildFeatures {
97 | compose = true
98 | }
99 |
100 | packaging {
101 | resources {
102 | excludes += "/META-INF/{AL2.0,LGPL2.1}"
103 | }
104 | }
105 | }
106 |
107 | dependencies {
108 | // External Libs
109 | androidTestImplementation(libs.androidx.androidJunit)
110 | androidTestImplementation(libs.androidx.espresso)
111 |
112 | testImplementation(libs.junit)
113 |
114 | androidTestImplementation(libs.compose.test)
115 | debugImplementation(libs.compose.tooling)
116 | }
117 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.kts.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidMain/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/androidMain/kotlin/co/touchlab/composeanimations/animations/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 |
7 | class MainActivity : ComponentActivity() {
8 | override fun onCreate(savedInstanceState: Bundle?) {
9 | super.onCreate(savedInstanceState)
10 | setContent {
11 | App()
12 | }
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/app/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/androidMain/res/drawable/arrow_forward.xml:
--------------------------------------------------------------------------------
1 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/androidMain/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/app/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/androidMain/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/androidMain/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 | #ddd
11 |
12 |
--------------------------------------------------------------------------------
/app/src/androidMain/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Compose Animations
3 |
--------------------------------------------------------------------------------
/app/src/androidMain/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/commonMain/composeResources/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/androidx/compose/desktop/ui/tooling/preview/Preview.kt:
--------------------------------------------------------------------------------
1 | package androidx.compose.desktop.ui.tooling.preview
2 |
3 | @OptIn(ExperimentalMultiplatform::class)
4 | @OptionalExpectation
5 | expect annotation class Preview()
6 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/App.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations
2 |
3 | import androidx.compose.material.MaterialTheme
4 | import androidx.compose.material.Surface
5 | import androidx.compose.runtime.Composable
6 | import cafe.adriel.voyager.navigator.Navigator
7 | import cafe.adriel.voyager.transitions.SlideTransition
8 | import co.touchlab.composeanimations.animations.screen.HomeScreen
9 | import co.touchlab.composeanimations.animations.theme.ComposeAnimationsTheme
10 |
11 | @Composable
12 | fun App() {
13 | ComposeAnimationsTheme {
14 | Surface(color = MaterialTheme.colors.background) {
15 | Navigator(HomeScreen) { navigator ->
16 | SlideTransition(navigator)
17 | }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/page/Easings.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.page
2 |
3 | import androidx.compose.animation.core.Easing
4 | import androidx.compose.animation.core.FastOutLinearInEasing
5 | import androidx.compose.animation.core.FastOutSlowInEasing
6 | import androidx.compose.animation.core.LinearEasing
7 | import androidx.compose.animation.core.LinearOutSlowInEasing
8 | import androidx.compose.animation.core.animateFloat
9 | import androidx.compose.animation.core.infiniteRepeatable
10 | import androidx.compose.animation.core.rememberInfiniteTransition
11 | import androidx.compose.animation.core.tween
12 | import androidx.compose.desktop.ui.tooling.preview.Preview
13 | import androidx.compose.foundation.Canvas
14 | import androidx.compose.foundation.layout.Box
15 | import androidx.compose.foundation.layout.Column
16 | import androidx.compose.foundation.layout.fillMaxWidth
17 | import androidx.compose.foundation.layout.height
18 | import androidx.compose.foundation.layout.padding
19 | import androidx.compose.foundation.lazy.LazyColumn
20 | import androidx.compose.foundation.lazy.items
21 | import androidx.compose.material.Icon
22 | import androidx.compose.material.IconButton
23 | import androidx.compose.material.Scaffold
24 | import androidx.compose.material.Text
25 | import androidx.compose.material.TopAppBar
26 | import androidx.compose.material.icons.Icons
27 | import androidx.compose.material.icons.automirrored.filled.ArrowBack
28 | import androidx.compose.runtime.Composable
29 | import androidx.compose.runtime.getValue
30 | import androidx.compose.ui.Alignment
31 | import androidx.compose.ui.Modifier
32 | import androidx.compose.ui.geometry.Offset
33 | import androidx.compose.ui.graphics.Color
34 | import androidx.compose.ui.text.font.FontWeight
35 | import androidx.compose.ui.unit.dp
36 | import co.touchlab.composeanimations.easing.EaseInBack
37 | import co.touchlab.composeanimations.easing.EaseInBounce
38 | import co.touchlab.composeanimations.easing.EaseInCirc
39 | import co.touchlab.composeanimations.easing.EaseInCubic
40 | import co.touchlab.composeanimations.easing.EaseInElastic
41 | import co.touchlab.composeanimations.easing.EaseInExpo
42 | import co.touchlab.composeanimations.easing.EaseInOutBack
43 | import co.touchlab.composeanimations.easing.EaseInOutBounce
44 | import co.touchlab.composeanimations.easing.EaseInOutCirc
45 | import co.touchlab.composeanimations.easing.EaseInOutCubic
46 | import co.touchlab.composeanimations.easing.EaseInOutElastic
47 | import co.touchlab.composeanimations.easing.EaseInOutExpo
48 | import co.touchlab.composeanimations.easing.EaseInOutQuad
49 | import co.touchlab.composeanimations.easing.EaseInOutQuart
50 | import co.touchlab.composeanimations.easing.EaseInOutQuint
51 | import co.touchlab.composeanimations.easing.EaseInOutSine
52 | import co.touchlab.composeanimations.easing.EaseInQuad
53 | import co.touchlab.composeanimations.easing.EaseInQuart
54 | import co.touchlab.composeanimations.easing.EaseInQuint
55 | import co.touchlab.composeanimations.easing.EaseInSine
56 | import co.touchlab.composeanimations.easing.EaseOutBack
57 | import co.touchlab.composeanimations.easing.EaseOutBounce
58 | import co.touchlab.composeanimations.easing.EaseOutCirc
59 | import co.touchlab.composeanimations.easing.EaseOutCubic
60 | import co.touchlab.composeanimations.easing.EaseOutElastic
61 | import co.touchlab.composeanimations.easing.EaseOutExpo
62 | import co.touchlab.composeanimations.easing.EaseOutQuad
63 | import co.touchlab.composeanimations.easing.EaseOutQuart
64 | import co.touchlab.composeanimations.easing.EaseOutQuint
65 | import co.touchlab.composeanimations.easing.EaseOutSine
66 |
67 | @Composable
68 | fun EasingDemo(goBack: () -> Unit) {
69 | Scaffold(
70 | topBar = {
71 | TopAppBar(
72 | title = { Text("Easing functions") },
73 | navigationIcon = {
74 | IconButton(onClick = goBack) {
75 | Icon(Icons.AutoMirrored.Filled.ArrowBack, null)
76 | }
77 | }
78 | )
79 | },
80 | ) {
81 | Box(modifier = Modifier.padding(it)) {
82 | EasingDemoContent()
83 | }
84 | }
85 | }
86 |
87 | @Composable
88 | private fun EasingDemoContent() {
89 | LazyColumn {
90 | items(ALL_EASIGNS.toList()) { (name, easing) ->
91 | Graph(
92 | name = name,
93 | easingFunction = easing
94 | )
95 | }
96 | }
97 | }
98 |
99 | @Composable
100 | private fun Graph(
101 | name: String,
102 | easingFunction: Easing,
103 | ) {
104 | val infiniteTransition = rememberInfiniteTransition()
105 | val time by infiniteTransition.animateFloat(
106 | initialValue = 0f,
107 | targetValue = 1f,
108 | animationSpec = infiniteRepeatable(
109 | animation = tween(
110 | durationMillis = 2500,
111 | easing = LinearEasing,
112 | )
113 | ),
114 | label = "${name}_time",
115 | )
116 | val value by infiniteTransition.animateFloat(
117 | initialValue = 0f,
118 | targetValue = 1f,
119 | animationSpec = infiniteRepeatable(
120 | animation = tween(
121 | durationMillis = 2500,
122 | easing = easingFunction,
123 | )
124 | ),
125 | label = "${name}_value",
126 | )
127 |
128 | Column(
129 | horizontalAlignment = Alignment.CenterHorizontally,
130 | modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
131 | ) {
132 | Text(
133 | text = name,
134 | fontWeight = FontWeight.Bold,
135 | modifier = Modifier.padding(bottom = 8.dp)
136 | )
137 | Canvas(
138 | modifier = Modifier
139 | .fillMaxWidth()
140 | .height(200.dp)
141 | .padding(vertical = 24.dp)
142 | ) {
143 | val canvasWidth = size.width
144 | val canvasHeight = size.height
145 |
146 | drawLine(
147 | color = Color.Blue,
148 | strokeWidth = 3f,
149 | start = Offset.Zero,
150 | end = Offset(0f, canvasHeight),
151 | )
152 |
153 | drawLine(
154 | color = Color.Blue,
155 | strokeWidth = 3f,
156 | start = Offset(canvasWidth, 0f),
157 | end = Offset(canvasWidth, canvasHeight),
158 | )
159 |
160 | drawLine(
161 | color = Color.Red,
162 | strokeWidth = 3f,
163 | start = Offset(0f, canvasHeight),
164 | end = Offset(canvasWidth, canvasHeight),
165 | )
166 |
167 | drawLine(
168 | color = Color.Red,
169 | strokeWidth = 3f,
170 | start = Offset(0f, 0f),
171 | end = Offset(canvasWidth, 0f),
172 | )
173 |
174 | val canvasSizeInt = canvasWidth.toInt()
175 | for (i in 1..canvasSizeInt) {
176 | val currentTime = (i + 1) / canvasSizeInt.toFloat()
177 | val previousTime = (i - 1) / canvasSizeInt.toFloat()
178 |
179 | drawLine(
180 | color = Color.LightGray,
181 | strokeWidth = 2f,
182 | start = Offset(
183 | x = canvasWidth * previousTime,
184 | y = canvasHeight * (1 - easingFunction.transform(previousTime))
185 | ),
186 | end = Offset(
187 | x = canvasWidth * currentTime,
188 | y = canvasHeight * (1 - easingFunction.transform(currentTime))
189 | ),
190 | )
191 | }
192 |
193 | drawCircle(
194 | color = Color.Black,
195 | radius = 10f,
196 | center = Offset(canvasWidth * time, canvasHeight * (1 - value))
197 | )
198 | }
199 | }
200 | }
201 |
202 | @Composable
203 | @Preview
204 | fun GraphPreview() {
205 | Graph(
206 | name = "Some function",
207 | easingFunction = LinearEasing
208 | )
209 | }
210 |
211 | private val ALL_EASIGNS = mapOf(
212 | "LinearEasing (Compose)" to LinearEasing,
213 | "FastOutSlowInEasing (Compose)" to FastOutSlowInEasing,
214 | "LinearOutSlowInEasing (Compose)" to LinearOutSlowInEasing,
215 | "FastOutLinearInEasing (Compose)" to FastOutLinearInEasing,
216 | "EaseInSine" to EaseInSine,
217 | "EaseOutSine" to EaseOutSine,
218 | "EaseInOutSine" to EaseInOutSine,
219 | "EaseInQuad" to EaseInQuad,
220 | "EaseOutQuad" to EaseOutQuad,
221 | "EaseInOutQuad" to EaseInOutQuad,
222 | "EaseInCubic" to EaseInCubic,
223 | "EaseOutCubic" to EaseOutCubic,
224 | "EaseInOutCubic" to EaseInOutCubic,
225 | "EaseInQuart" to EaseInQuart,
226 | "EaseOutQuart" to EaseOutQuart,
227 | "EaseInOutQuart" to EaseInOutQuart,
228 | "EaseInQuint" to EaseInQuint,
229 | "EaseOutQuint" to EaseOutQuint,
230 | "EaseInOutQuint" to EaseInOutQuint,
231 | "EaseInExpo" to EaseInExpo,
232 | "EaseOutExpo" to EaseOutExpo,
233 | "EaseInOutExpo" to EaseInOutExpo,
234 | "EaseInCirc" to EaseInCirc,
235 | "EaseOutCirc" to EaseOutCirc,
236 | "EaseInOutCirc" to EaseInOutCirc,
237 | "EaseInBack" to EaseInBack,
238 | "EaseOutBack" to EaseOutBack,
239 | "EaseInOutBack" to EaseInOutBack,
240 | "EaseInElastic" to EaseInElastic,
241 | "EaseOutElastic" to EaseOutElastic,
242 | "EaseInOutElastic" to EaseInOutElastic,
243 | "EaseInBounce" to EaseInBounce,
244 | "EaseOutBounce" to EaseOutBounce,
245 | "EaseInOutBounce" to EaseInOutBounce,
246 | )
247 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/page/Home.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.page
2 |
3 | import androidx.compose.desktop.ui.tooling.preview.Preview
4 | import androidx.compose.foundation.clickable
5 | import androidx.compose.foundation.layout.Arrangement
6 | import androidx.compose.foundation.layout.Box
7 | import androidx.compose.foundation.layout.Row
8 | import androidx.compose.foundation.layout.fillMaxWidth
9 | import androidx.compose.foundation.layout.padding
10 | import androidx.compose.foundation.lazy.LazyColumn
11 | import androidx.compose.foundation.lazy.items
12 | import androidx.compose.material.Icon
13 | import androidx.compose.material.Scaffold
14 | import androidx.compose.material.Text
15 | import androidx.compose.material.TopAppBar
16 | import androidx.compose.material.icons.Icons
17 | import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
18 | import androidx.compose.runtime.Composable
19 | import androidx.compose.ui.Alignment
20 | import androidx.compose.ui.Modifier
21 | import androidx.compose.ui.text.font.FontWeight
22 | import androidx.compose.ui.unit.dp
23 | import androidx.compose.ui.unit.sp
24 |
25 | @Composable
26 | fun Home(
27 | openEasingDemo: () -> Unit,
28 | openValueAnimatorDemo: () -> Unit,
29 | ) {
30 | Scaffold(
31 | topBar = {
32 | TopAppBar(
33 | title = { Text("Compose Animations Demo") },
34 | )
35 | },
36 | ) {
37 | Box(modifier = Modifier.padding(it)) {
38 | HomeContent(
39 | openEasingDemo = openEasingDemo,
40 | openValueAnimatorDemo = openValueAnimatorDemo,
41 | )
42 | }
43 | }
44 | }
45 |
46 | @Composable
47 | private fun HomeContent(
48 | openEasingDemo: () -> Unit,
49 | openValueAnimatorDemo: () -> Unit,
50 | ) {
51 | val allDemos = listOf(
52 | "Easing" to openEasingDemo,
53 | "Value Animator" to openValueAnimatorDemo,
54 | )
55 |
56 | LazyColumn {
57 | items(allDemos) { (name, callback) ->
58 | DemoLink(name = name, onClick = callback)
59 | }
60 | }
61 | }
62 |
63 | @Composable
64 | private fun DemoLink(
65 | name: String,
66 | onClick: () -> Unit,
67 | ) {
68 | Row(
69 | modifier = Modifier
70 | .clickable(onClick = onClick)
71 | .fillMaxWidth()
72 | .padding(vertical = 16.dp, horizontal = 8.dp),
73 | verticalAlignment = Alignment.CenterVertically,
74 | horizontalArrangement = Arrangement.SpaceBetween
75 | ) {
76 | Text(
77 | text = name,
78 | fontSize = 16.sp,
79 | fontWeight = FontWeight.Bold,
80 | )
81 | Icon(Icons.AutoMirrored.Filled.KeyboardArrowRight, null)
82 | }
83 | }
84 |
85 | @Composable
86 | @Preview
87 | fun DemoLinkPreview() {
88 | DemoLink("Hello World") {}
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/page/ValueAnimatorDemo.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.page
2 |
3 | import androidx.compose.animation.core.LinearEasing
4 | import androidx.compose.animation.core.RepeatMode
5 | import androidx.compose.animation.core.infiniteRepeatable
6 | import androidx.compose.animation.core.rememberInfiniteTransition
7 | import androidx.compose.animation.core.tween
8 | import androidx.compose.foundation.layout.Arrangement
9 | import androidx.compose.foundation.layout.Box
10 | import androidx.compose.foundation.layout.Column
11 | import androidx.compose.foundation.layout.Row
12 | import androidx.compose.foundation.layout.fillMaxSize
13 | import androidx.compose.foundation.layout.fillMaxWidth
14 | import androidx.compose.foundation.layout.offset
15 | import androidx.compose.foundation.layout.padding
16 | import androidx.compose.foundation.layout.width
17 | import androidx.compose.material.Button
18 | import androidx.compose.material.Icon
19 | import androidx.compose.material.IconButton
20 | import androidx.compose.material.Scaffold
21 | import androidx.compose.material.Text
22 | import androidx.compose.material.TopAppBar
23 | import androidx.compose.material.icons.Icons
24 | import androidx.compose.material.icons.automirrored.filled.ArrowBack
25 | import androidx.compose.runtime.Composable
26 | import androidx.compose.runtime.LaunchedEffect
27 | import androidx.compose.runtime.getValue
28 | import androidx.compose.runtime.mutableStateOf
29 | import androidx.compose.runtime.remember
30 | import androidx.compose.runtime.setValue
31 | import androidx.compose.ui.Alignment
32 | import androidx.compose.ui.Modifier
33 | import androidx.compose.ui.graphics.Color
34 | import androidx.compose.ui.graphics.graphicsLayer
35 | import androidx.compose.ui.text.font.FontWeight
36 | import androidx.compose.ui.unit.dp
37 | import androidx.compose.ui.unit.sp
38 | import co.touchlab.composeanimations.animations.shapes.Ball
39 | import co.touchlab.composeanimations.animations.shapes.Triangle
40 | import co.touchlab.composeanimations.animations.utils.size
41 | import co.touchlab.composeanimations.value.animator.animateColorValuesAsState
42 | import co.touchlab.composeanimations.value.animator.animateFloatValuesAsState
43 | import co.touchlab.composeanimations.value.animator.animateIntValues
44 | import kotlinx.coroutines.delay
45 |
46 | @Composable
47 | fun ValueAnimatorDemo(goBack: () -> Unit) {
48 | Scaffold(
49 | topBar = {
50 | TopAppBar(
51 | title = { Text("Value Animator") },
52 | navigationIcon = {
53 | IconButton(onClick = goBack) {
54 | Icon(Icons.AutoMirrored.Filled.ArrowBack, null)
55 | }
56 | }
57 | )
58 | },
59 | ) {
60 | Box(modifier = Modifier.padding(it)) {
61 | ValueAnimatorContent()
62 | }
63 | }
64 | }
65 |
66 | @Composable
67 | private fun ValueAnimatorContent() {
68 | Column(
69 | modifier = Modifier.fillMaxSize(),
70 | verticalArrangement = Arrangement.SpaceEvenly,
71 | horizontalAlignment = Alignment.CenterHorizontally,
72 | ) {
73 | Row(
74 | modifier = Modifier.fillMaxWidth(),
75 | horizontalArrangement = Arrangement.SpaceEvenly,
76 | ) {
77 | SpinningTriangle()
78 | ColorFadingTriangle()
79 | }
80 | Row(
81 | modifier = Modifier.fillMaxWidth(),
82 | horizontalArrangement = Arrangement.SpaceEvenly,
83 | ) {
84 | BouncingDots()
85 | LoadingButton()
86 | }
87 | }
88 | }
89 |
90 | @Composable
91 | private fun BouncingDots() {
92 | // Based on https://github.com/81813780/AVLoadingIndicatorView/blob/master/library/src/main/java/com/wang/avi/indicators/BallPulseSyncIndicator.java
93 | val ballsRange = (0..2)
94 | val ballSize = 12.dp
95 | val animators = ballsRange.map { index ->
96 | animateFloatValuesAsState(
97 | values = floatArrayOf(0f, ballSize.value, 0f),
98 | startDelay = (1 + index) * 70L,
99 | animationSpec = infiniteRepeatable(
100 | animation = tween(
101 | durationMillis = 200 * ballsRange.size,
102 | ),
103 | )
104 | )
105 | }
106 |
107 | Column(horizontalAlignment = Alignment.CenterHorizontally) {
108 | Text(
109 | text = "Float Animator",
110 | fontSize = 16.sp,
111 | fontWeight = FontWeight.Bold
112 | )
113 | Row(
114 | modifier = Modifier
115 | .padding(top = 8.dp)
116 | .width(ballSize * (ballsRange.size + 1)),
117 | horizontalArrangement = Arrangement.SpaceEvenly,
118 | ) {
119 | ballsRange.forEach { index ->
120 | Ball(
121 | modifier = Modifier
122 | .offset(y = animators[index].value.dp)
123 | )
124 | }
125 | }
126 | }
127 | }
128 |
129 | @Composable
130 | private fun LoadingButton() {
131 | var isLoading by remember { mutableStateOf(false) }
132 | if (isLoading) {
133 | LaunchedEffect(key1 = isLoading) {
134 | delay(1500)
135 | isLoading = false
136 | }
137 | }
138 | Column(horizontalAlignment = Alignment.CenterHorizontally) {
139 | Text(
140 | text = "Trigger animation",
141 | fontSize = 16.sp,
142 | fontWeight = FontWeight.Bold
143 | )
144 | Button(
145 | modifier = Modifier
146 | .width(150.dp)
147 | .padding(top = 4.dp),
148 | onClick = { if (!isLoading) isLoading = true },
149 | ) {
150 | if (isLoading) {
151 | val ballOffset by animateFloatValuesAsState(
152 | values = floatArrayOf(-35f, 35f),
153 | animationSpec = infiniteRepeatable(
154 | animation = tween(
155 | durationMillis = 175,
156 | ),
157 | repeatMode = RepeatMode.Reverse,
158 | )
159 | )
160 |
161 | Ball(
162 | modifier = Modifier.offset(x = ballOffset.dp)
163 | )
164 | } else {
165 | Text(text = "Login")
166 | }
167 | }
168 | }
169 | }
170 |
171 | @Composable
172 | fun SpinningTriangle() {
173 | val infiniteTransition = rememberInfiniteTransition("MyTriangle")
174 | val rotateXAnimation by infiniteTransition.animateIntValues(
175 | values = arrayOf(0, 180, 180, 0, 0),
176 | animationSpec = infiniteRepeatable(
177 | animation = tween(
178 | durationMillis = 2500,
179 | easing = LinearEasing
180 | ),
181 | )
182 | )
183 |
184 | val rotateYAnimation by infiniteTransition.animateIntValues(
185 | values = arrayOf(0, 0, 180, 180, 0),
186 | animationSpec = infiniteRepeatable(
187 | animation = tween(
188 | durationMillis = 2500,
189 | easing = LinearEasing
190 | ),
191 | )
192 | )
193 |
194 | Column(horizontalAlignment = Alignment.CenterHorizontally) {
195 | Text(
196 | text = "Int animator",
197 | fontSize = 16.sp,
198 | fontWeight = FontWeight.Bold
199 | )
200 | Triangle(
201 | modifier = Modifier
202 | .padding(top = 8.dp)
203 | .graphicsLayer(
204 | rotationX = rotateXAnimation.toFloat(),
205 | rotationY = rotateYAnimation.toFloat(),
206 | )
207 | )
208 | }
209 | }
210 |
211 | @Composable
212 | fun ColorFadingTriangle() {
213 | val colorAnimation by animateColorValuesAsState(
214 | values = arrayOf(Color.Red, Color.Green, Color.Blue),
215 | animationSpec = infiniteRepeatable(
216 | animation = tween(
217 | durationMillis = 2500,
218 | easing = LinearEasing,
219 | ),
220 | repeatMode = RepeatMode.Reverse,
221 | ),
222 | )
223 |
224 | Column(horizontalAlignment = Alignment.CenterHorizontally) {
225 | Text(
226 | text = "ARGB animator",
227 | fontSize = 16.sp,
228 | fontWeight = FontWeight.Bold
229 | )
230 | Triangle(
231 | modifier = Modifier.padding(top = 8.dp),
232 | backgroundColor = colorAnimation
233 | )
234 | }
235 | }
236 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/screen/EasingsScreen.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.screen
2 |
3 | import androidx.compose.runtime.Composable
4 | import cafe.adriel.voyager.core.screen.Screen
5 | import cafe.adriel.voyager.navigator.LocalNavigator
6 | import cafe.adriel.voyager.navigator.currentOrThrow
7 | import co.touchlab.composeanimations.animations.page.EasingDemo
8 |
9 | object EasingsScreen : Screen {
10 | @Composable
11 | override fun Content() {
12 | val navigator = LocalNavigator.currentOrThrow
13 | EasingDemo(goBack = { navigator.pop() })
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/screen/HomeScreen.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.screen
2 |
3 | import androidx.compose.runtime.Composable
4 | import cafe.adriel.voyager.core.screen.Screen
5 | import cafe.adriel.voyager.navigator.LocalNavigator
6 | import cafe.adriel.voyager.navigator.currentOrThrow
7 | import co.touchlab.composeanimations.animations.page.Home
8 |
9 | object HomeScreen : Screen {
10 | @Composable
11 | override fun Content() {
12 | val navigator = LocalNavigator.currentOrThrow
13 | Home(
14 | openEasingDemo = { navigator.push(EasingsScreen) },
15 | openValueAnimatorDemo = { navigator.push(ValueAnimatorScreen) },
16 | )
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/screen/ValueAnimatorScreen.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.screen
2 |
3 | import androidx.compose.runtime.Composable
4 | import cafe.adriel.voyager.core.screen.Screen
5 | import cafe.adriel.voyager.navigator.LocalNavigator
6 | import cafe.adriel.voyager.navigator.currentOrThrow
7 | import co.touchlab.composeanimations.animations.page.ValueAnimatorDemo
8 |
9 | object ValueAnimatorScreen : Screen {
10 | @Composable
11 | override fun Content() {
12 | val navigator = LocalNavigator.currentOrThrow
13 | ValueAnimatorDemo(goBack = { navigator.pop() })
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/shapes/Ball.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.shapes
2 |
3 | import androidx.compose.desktop.ui.tooling.preview.Preview
4 | import androidx.compose.foundation.background
5 | import androidx.compose.foundation.layout.Box
6 | import androidx.compose.foundation.layout.height
7 | import androidx.compose.foundation.layout.width
8 | import androidx.compose.foundation.shape.CircleShape
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.Modifier
11 | import androidx.compose.ui.draw.clipToBounds
12 | import androidx.compose.ui.graphics.Color
13 | import androidx.compose.ui.unit.Dp
14 | import androidx.compose.ui.unit.dp
15 |
16 | @Composable
17 | fun Ball(
18 | modifier: Modifier = Modifier,
19 | size: Dp = 12.dp,
20 | backgroundColor: Color = Color(0xFFDDDDDD),
21 | ) {
22 | Box(
23 | modifier = modifier
24 | .width(size)
25 | .height(size)
26 | .clipToBounds()
27 | .background(backgroundColor, CircleShape)
28 | )
29 | }
30 |
31 | @Preview
32 | @Composable
33 | fun BallPreview() {
34 | Ball(
35 | size = 32.dp,
36 | backgroundColor = Color(0xFF03DAC5),
37 | )
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/shapes/Triangle.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.shapes
2 |
3 | import androidx.compose.desktop.ui.tooling.preview.Preview
4 | import androidx.compose.foundation.background
5 | import androidx.compose.foundation.layout.Box
6 | import androidx.compose.foundation.layout.height
7 | import androidx.compose.foundation.layout.width
8 | import androidx.compose.foundation.shape.GenericShape
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.Modifier
11 | import androidx.compose.ui.draw.clipToBounds
12 | import androidx.compose.ui.graphics.Color
13 | import androidx.compose.ui.unit.Dp
14 | import androidx.compose.ui.unit.dp
15 |
16 | @Composable
17 | fun Triangle(
18 | modifier: Modifier = Modifier,
19 | size: Dp = 24.dp,
20 | backgroundColor: Color = Color(0xFFDDDDDD),
21 | ) {
22 |
23 | Box(
24 | modifier = modifier
25 | .width(size)
26 | .height(size)
27 | .clipToBounds()
28 | .background(backgroundColor, TriangleShape)
29 | )
30 | }
31 |
32 | private val TriangleShape = GenericShape { size, _ ->
33 | moveTo(size.width / 2f, 0f)
34 | lineTo(size.width, size.height)
35 | lineTo(0f, size.height)
36 | }
37 |
38 | @Composable
39 | @Preview
40 | fun TrianglePreview() {
41 | Triangle()
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
9 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
12 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun ComposeAnimationsTheme(
32 | darkTheme: Boolean = isSystemInDarkTheme(),
33 | content: @Composable() () -> Unit
34 | ) {
35 | val colors = if (darkTheme) {
36 | DarkColorPalette
37 | } else {
38 | LightColorPalette
39 | }
40 |
41 | MaterialTheme(
42 | colors = colors,
43 | typography = Typography,
44 | shapes = Shapes,
45 | content = content
46 | )
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
29 |
--------------------------------------------------------------------------------
/app/src/commonMain/kotlin/co/touchlab/composeanimations/animations/utils/size.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.utils
2 |
3 | val IntRange.size: Int
4 | get() = toList().size
5 |
--------------------------------------------------------------------------------
/app/src/iosMain/kotlin/co/touchlab/composeanimations/animations/vc/MainViewController.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations.vc
2 |
3 | import androidx.compose.ui.window.ComposeUIViewController
4 | import co.touchlab.composeanimations.animations.App
5 |
6 | fun MainViewController() = ComposeUIViewController { App() }
7 |
--------------------------------------------------------------------------------
/app/src/jvmMain/kotlin/co/touchlab/composeanimations/animations/Main.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.animations
2 |
3 | import androidx.compose.ui.unit.DpSize
4 | import androidx.compose.ui.unit.dp
5 | import androidx.compose.ui.window.Window
6 | import androidx.compose.ui.window.application
7 | import androidx.compose.ui.window.rememberWindowState
8 |
9 | fun main() {
10 | application {
11 | val windowState = rememberWindowState(
12 | size = DpSize(393.dp, 852.dp)
13 | )
14 |
15 | Window(
16 | onCloseRequest = ::exitApplication,
17 | state = windowState,
18 | resizable = false,
19 | title = "Compose Animations"
20 | ) {
21 | App()
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.maven.publish) apply false
3 | alias(libs.plugins.androidApplication) apply false
4 | alias(libs.plugins.androidLibrary) apply false
5 | alias(libs.plugins.kotlinMultiplatform) apply false
6 | alias(libs.plugins.jetbrainsCompose) apply false
7 | alias(libs.plugins.composeCompiler) apply false
8 | }
9 |
10 | val GROUP: String by project
11 | val VERSION_NAME: String by project
12 |
13 | allprojects {
14 | group = GROUP
15 | version = VERSION_NAME
16 |
17 | extensions.findByType()?.apply {
18 | sourceSets.all {
19 | languageSettings.optIn("kotlin.RequiresOptIn")
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/easing/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/easing/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.androidLibrary)
3 | alias(libs.plugins.kotlinMultiplatform)
4 | alias(libs.plugins.jetbrainsCompose)
5 | alias(libs.plugins.composeCompiler)
6 | alias(libs.plugins.maven.publish)
7 | }
8 |
9 | kotlin {
10 | jvm()
11 |
12 | iosX64()
13 | iosArm64()
14 | iosSimulatorArm64()
15 |
16 | wasmJs { browser() }
17 |
18 | androidTarget {
19 | publishAllLibraryVariants()
20 | compilations.all {
21 | kotlinOptions {
22 | jvmTarget = "1.8"
23 | }
24 | }
25 | }
26 |
27 | applyDefaultHierarchyTemplate()
28 |
29 | sourceSets {
30 | commonMain.dependencies {
31 | implementation(compose.runtime)
32 | implementation(compose.animation)
33 | }
34 | }
35 | }
36 |
37 | android {
38 | namespace = "co.touchlab.compose.easing"
39 | compileSdk = libs.versions.android.compileSdk.get().toInt()
40 |
41 | defaultConfig {
42 | minSdk = libs.versions.android.minSdk.get().toInt()
43 | targetSdk = libs.versions.android.targetSdk.get().toInt()
44 |
45 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
46 | proguardFile("consumer-rules.pro")
47 | }
48 |
49 | buildTypes {
50 | release {
51 | isMinifyEnabled = false
52 | }
53 | }
54 |
55 | compileOptions {
56 | sourceCompatibility = JavaVersion.VERSION_1_8
57 | targetCompatibility = JavaVersion.VERSION_1_8
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/easing/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/easing/consumer-rules.pro
--------------------------------------------------------------------------------
/easing/easing-demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/easing/easing-demo.gif
--------------------------------------------------------------------------------
/easing/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.kts.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/easing/src/androidMain/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Back.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.pow
5 |
6 | // https://easings.net/#easeInBack
7 | @Deprecated(
8 | "Use default implementations from Compose Multiplatform",
9 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInBack"),
10 | )
11 | object EaseInBack : Easing {
12 | override fun transform(fraction: Float): Float {
13 | val c1 = 1.70158f
14 | val c3 = c1 + 1
15 |
16 | return c3 * fraction.pow(3) - c1 * fraction.pow(2)
17 | }
18 | }
19 |
20 | // https://easings.net/#easeOutBack
21 | @Deprecated(
22 | "Use default implementations from Compose Multiplatform",
23 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutBack"),
24 | )
25 | object EaseOutBack : Easing {
26 | override fun transform(fraction: Float): Float {
27 | val c1 = 1.70158f
28 | val c3 = c1 + 1
29 |
30 | return 1 + c3 * (fraction - 1).pow(3) + c1 * (fraction - 1).pow(2)
31 | }
32 | }
33 |
34 | // https://easings.net/#easeInOutBack
35 | @Deprecated(
36 | "Use default implementations from Compose Multiplatform",
37 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutBack"),
38 | )
39 | object EaseInOutBack : Easing {
40 | override fun transform(fraction: Float): Float {
41 | val c1 = 1.70158f
42 | val c2 = c1 * 1.525f
43 |
44 | return if (fraction < 0.5f) {
45 | ((2 * fraction).pow(2) * ((c2 + 1) * 2 * fraction - c2)) / 2
46 | } else {
47 | ((2 * fraction - 2).pow(2) * ((c2 + 1) * (fraction * 2 - 2) + c2) + 2) / 2
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Bounce.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.pow
5 |
6 | // https://easings.net/#easeInBounce
7 | @Deprecated(
8 | "Use default implementations from Compose Multiplatform",
9 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInBounce"),
10 | )
11 | object EaseInBounce : Easing {
12 | override fun transform(fraction: Float): Float =
13 | 1 - EaseOutBounce.transform(1 - fraction)
14 | }
15 |
16 | // https://easings.net/#easeOutBounce
17 | @Deprecated(
18 | "Use default implementations from Compose Multiplatform",
19 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutBounce"),
20 | )
21 | object EaseOutBounce : Easing {
22 | override fun transform(fraction: Float): Float {
23 | val n1 = 7.5625f
24 | val d1 = 2.75f
25 |
26 | return when {
27 | fraction < (1f / d1) -> n1 * fraction.pow(2)
28 | fraction < (2f / d1) -> {
29 | val fractionSub = fraction - (1.5f / d1)
30 | n1 * fractionSub.pow(2) + 0.75f
31 | }
32 | fraction < (2.5f / d1) -> {
33 | val fractionSub = fraction - (2.25f / d1)
34 | n1 * fractionSub.pow(2) + 0.9375f
35 | }
36 | else -> {
37 | val fractionSub = fraction - (2.625f / d1)
38 | n1 * fractionSub.pow(2) + 0.984375f
39 | }
40 | }
41 | }
42 | }
43 |
44 | // https://easings.net/#easeInOutBounce
45 | @Deprecated(
46 | "Use default implementations from Compose Multiplatform",
47 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutBounce"),
48 | )
49 | object EaseInOutBounce : Easing {
50 | override fun transform(fraction: Float): Float = if (fraction < 0.5f) {
51 | (1 - EaseOutBounce.transform(1 - 2 * fraction)) / 2
52 | } else {
53 | (1 + EaseOutBounce.transform(2 * fraction - 1)) / 2
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Circ.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.pow
5 | import kotlin.math.sqrt
6 |
7 | // https://easings.net/#easeInCirc
8 | @Deprecated(
9 | "Use default implementations from Compose Multiplatform",
10 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInCirc"),
11 | )
12 | object EaseInCirc : Easing {
13 | override fun transform(fraction: Float): Float =
14 | 1 - sqrt(1 - fraction.pow(2))
15 | }
16 |
17 | // https://easings.net/#easeOutCirc
18 | @Deprecated(
19 | "Use default implementations from Compose Multiplatform",
20 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutCirc"),
21 | )
22 | object EaseOutCirc : Easing {
23 | override fun transform(fraction: Float): Float =
24 | sqrt(1 - (fraction - 1).pow(2))
25 | }
26 |
27 | // https://easings.net/#easeInOutCirc
28 | @Deprecated(
29 | "Use default implementations from Compose Multiplatform",
30 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutCirc"),
31 | )
32 | object EaseInOutCirc : Easing {
33 | override fun transform(fraction: Float): Float = if (fraction < 0.5f) {
34 | (1 - sqrt(1 - (2 * fraction).pow(2))) / 2
35 | } else {
36 | (sqrt(1 - (-2 * fraction + 2).pow(2)) + 1) / 2
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Cubic.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.pow
5 |
6 | // https://easings.net/#easeInCubic
7 | @Deprecated(
8 | "Use default implementations from Compose Multiplatform",
9 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInCubic"),
10 | )
11 | object EaseInCubic : Easing {
12 | override fun transform(fraction: Float): Float =
13 | fraction.pow(3)
14 | }
15 |
16 | // https://easings.net/#easeOutCubic
17 | @Deprecated(
18 | "Use default implementations from Compose Multiplatform",
19 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutCubic"),
20 | )
21 | object EaseOutCubic : Easing {
22 | override fun transform(fraction: Float): Float =
23 | 1 - (1 - fraction).pow(3)
24 | }
25 |
26 | // https://easings.net/#easeInOutCubic
27 | @Deprecated(
28 | "Use default implementations from Compose Multiplatform",
29 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutCubic"),
30 | )
31 | object EaseInOutCubic : Easing {
32 | override fun transform(fraction: Float): Float = if (fraction < 0.5f) {
33 | 4 * fraction.pow(3)
34 | } else {
35 | 1 - (-2 * fraction + 2).pow(3) / 2
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Elastic.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.PI
5 | import kotlin.math.pow
6 | import kotlin.math.sin
7 |
8 | // https://easings.net/#easeInElastic
9 | @Deprecated(
10 | "Use default implementations from Compose Multiplatform",
11 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInElastic"),
12 | )
13 | object EaseInElastic : Easing {
14 | override fun transform(fraction: Float): Float {
15 | val c4: Float = (2 * PI.toFloat()) / 3
16 |
17 | return if (fraction == 0f || fraction == 1f) {
18 | fraction
19 | } else {
20 | -(2f.pow(10 * fraction - 10)) * sin((fraction * 10 - 10.75f) * c4)
21 | }
22 | }
23 | }
24 |
25 | // https://easings.net/#easeOutElastic
26 | @Deprecated(
27 | "Use default implementations from Compose Multiplatform",
28 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutElastic"),
29 | )
30 | object EaseOutElastic : Easing {
31 | override fun transform(fraction: Float): Float {
32 | val c4: Float = (2 * PI.toFloat()) / 3
33 |
34 | return if (fraction == 0f || fraction == 1f) {
35 | fraction
36 | } else {
37 | 2f.pow(-10 * fraction) * sin((fraction * 10 - 0.75f) * c4) + 1
38 | }
39 | }
40 | }
41 |
42 | // https://easings.net/#easeInOutElastic
43 | @Deprecated(
44 | "Use default implementations from Compose Multiplatform",
45 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutElastic"),
46 | )
47 | object EaseInOutElastic : Easing {
48 | override fun transform(fraction: Float): Float {
49 | val c5: Float = (2 * PI.toFloat()) / 4.5f
50 |
51 | return when {
52 | fraction == 0f || fraction == 1f -> fraction
53 | fraction < 0.5f -> -(2f.pow(20 * fraction - 10) * sin((20 * fraction - 11.125f) * c5)) / 2
54 | else -> (2f.pow(-20 * fraction + 10) * sin((20 * fraction - 11.125f) * c5)) / 2 + 1
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Expo.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.pow
5 |
6 | // https://easings.net/#easeInExpo
7 | @Deprecated(
8 | "Use default implementations from Compose Multiplatform",
9 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInExpo"),
10 | )
11 | object EaseInExpo : Easing {
12 | override fun transform(fraction: Float): Float =
13 | if (fraction == 0f) fraction else 2f.pow(10 * fraction - 10)
14 | }
15 |
16 | // https://easings.net/#easeOutExpo
17 | @Deprecated(
18 | "Use default implementations from Compose Multiplatform",
19 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutExpo"),
20 | )
21 | object EaseOutExpo : Easing {
22 | override fun transform(fraction: Float): Float =
23 | if (fraction == 1f) fraction else (1 - 2f.pow(-10 * fraction))
24 | }
25 |
26 | // https://easings.net/#easeInOutExpo
27 | @Deprecated(
28 | "Use default implementations from Compose Multiplatform",
29 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutExpo"),
30 | )
31 | object EaseInOutExpo : Easing {
32 | override fun transform(fraction: Float): Float = when {
33 | fraction == 0f || fraction == 1f -> fraction
34 | fraction < 0.5f -> 2f.pow(20 * fraction - 10) / 2
35 | else -> (2 - 2f.pow(-20 * fraction + 10)) / 2
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Quad.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.pow
5 |
6 | // https://easings.net/#easeInQuad
7 | @Deprecated(
8 | "Use default implementations from Compose Multiplatform",
9 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInQuad"),
10 | )
11 | object EaseInQuad : Easing {
12 | override fun transform(fraction: Float): Float =
13 | fraction.pow(2)
14 | }
15 |
16 | // https://easings.net/#easeOutQuad
17 | @Deprecated(
18 | "Use default implementations from Compose Multiplatform",
19 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutQuad"),
20 | )
21 | object EaseOutQuad : Easing {
22 | override fun transform(fraction: Float): Float =
23 | 1 - (1 - fraction).pow(2)
24 | }
25 |
26 | // https://easings.net/#easeInOutQuad
27 | @Deprecated(
28 | "Use default implementations from Compose Multiplatform",
29 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutQuad"),
30 | )
31 | object EaseInOutQuad : Easing {
32 | override fun transform(fraction: Float): Float = if (fraction < 0.5f) {
33 | 2 * fraction.pow(2)
34 | } else {
35 | 1 - (-2 * fraction + 2).pow(2) / 2
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Quart.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.pow
5 |
6 | // https://easings.net/#easeInQuart
7 | @Deprecated(
8 | "Use default implementations from Compose Multiplatform",
9 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInQuart"),
10 | )
11 | object EaseInQuart : Easing {
12 | override fun transform(fraction: Float): Float =
13 | fraction.pow(4)
14 | }
15 |
16 | // https://easings.net/#easeOutQuart
17 | @Deprecated(
18 | "Use default implementations from Compose Multiplatform",
19 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutQuart"),
20 | )
21 | object EaseOutQuart : Easing {
22 | override fun transform(fraction: Float): Float =
23 | 1 - (1 - fraction).pow(4)
24 | }
25 |
26 | // https://easings.net/#easeInOutQuart
27 | @Deprecated(
28 | "Use default implementations from Compose Multiplatform",
29 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutQuart"),
30 | )
31 | object EaseInOutQuart : Easing {
32 | override fun transform(fraction: Float): Float = if (fraction < 0.5f) {
33 | 8 * fraction.pow(4)
34 | } else {
35 | 1 - (-2 * fraction + 2).pow(4) / 2
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Quint.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.pow
5 |
6 | // https://easings.net/#easeInQuint
7 | @Deprecated(
8 | "Use default implementations from Compose Multiplatform",
9 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInQuint"),
10 | )
11 | object EaseInQuint : Easing {
12 | override fun transform(fraction: Float): Float =
13 | 1 - (1 - fraction).pow(5)
14 | }
15 |
16 | // https://easings.net/#easeOutQuint
17 | @Deprecated(
18 | "Use default implementations from Compose Multiplatform",
19 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutQuint"),
20 | )
21 | object EaseOutQuint : Easing {
22 | override fun transform(fraction: Float): Float =
23 | 1 - (1 - fraction).pow(5)
24 | }
25 |
26 | // https://easings.net/#easeInOutQuint
27 | @Deprecated(
28 | "Use default implementations from Compose Multiplatform",
29 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutQuint"),
30 | )
31 | object EaseInOutQuint : Easing {
32 | override fun transform(fraction: Float): Float = if (fraction < 0.5f) {
33 | 16 * fraction.pow(5)
34 | } else {
35 | 1 - (-2 * fraction + 2).pow(5) / 2
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/easing/src/commonMain/kotlin/co/touchlab/composeanimations/easing/Sine.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.easing
2 |
3 | import androidx.compose.animation.core.Easing
4 | import kotlin.math.PI
5 | import kotlin.math.cos
6 | import kotlin.math.sin
7 |
8 | // https://easings.net/#easeInSine
9 | @Deprecated(
10 | "Use default implementations from Compose Multiplatform",
11 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInSine"),
12 | )
13 | object EaseInSine : Easing {
14 | override fun transform(fraction: Float): Float =
15 | 1 - cos((fraction * PI.toFloat()) / 2)
16 | }
17 |
18 | // https://easings.net/#easeOutSine
19 | @Deprecated(
20 | "Use default implementations from Compose Multiplatform",
21 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseOutSine"),
22 | )
23 | object EaseOutSine : Easing {
24 | override fun transform(fraction: Float): Float =
25 | sin((fraction * PI.toFloat()) / 2)
26 | }
27 |
28 | // https://easings.net/#easeInOutSine
29 | @Deprecated(
30 | "Use default implementations from Compose Multiplatform",
31 | replaceWith = ReplaceWith("androidx.compose.animation.core.EaseInOutSine"),
32 | )
33 | object EaseInOutSine : Easing {
34 | override fun transform(fraction: Float): Float =
35 | -(cos(fraction * PI.toFloat()) - 1) / 2
36 | }
37 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
23 | # Compose MP
24 | org.jetbrains.compose.experimental.jscanvas.enabled=true
25 | org.jetbrains.compose.experimental.macos.enabled=true
26 | org.jetbrains.compose.experimental.wasm.enabled=true
27 |
28 | SONATYPE_HOST=DEFAULT
29 | RELEASE_SIGNING_ENABLED=true
30 | GROUP=co.touchlab.composeanimations
31 | VERSION_NAME=1.0.2
32 |
33 | POM_NAME=ComposeAnimations
34 | POM_DESCRIPTION=Multiplatform Compose Animations
35 | POM_URL=https://github.com/touchlab/compose-animations
36 | POM_SCM_URL=https://github.com/touchlab/compose-animations
37 | POM_SCM_CONNECTION=scm:git:git://github.com/touchlab/compose-animations.git
38 | POM_SCM_DEV_CONNECTION=scm:git:git://github.com/touchlab/compose-animations.git
39 |
40 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
41 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
42 | POM_LICENCE_DIST=repo
43 |
44 | POM_DEVELOPER_ID=faogustavo
45 | POM_DEVELOPER_NAME=Gustavo Valvassori
46 | POM_DEVELOPER_ORG=Touchlab
47 | POM_DEVELOPER_URL=https://touchlab.co/
48 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | kotlin = "2.0.0"
3 | agp = "8.2.0"
4 |
5 | android-compileSdk = "34"
6 | android-minSdk = "21"
7 | android-targetSdk = "34"
8 |
9 | coreKtx = "1.13.0"
10 | lifecycle = "2.7.0"
11 | appCompat = "1.6.1"
12 | activityCompose = "1.9.0"
13 | androidJunit = "1.1.5"
14 | espresso = "3.5.1"
15 |
16 | googleMaterial = "1.11.0"
17 |
18 | compose = "1.6.6"
19 | compose-plugin = "1.6.10"
20 |
21 | voyager = "1.0.0"
22 |
23 | junit = "4.13.2"
24 |
25 | mavenPublish = "0.27.0"
26 |
27 | [libraries]
28 | androidx-coreKtx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
29 | androidx-lifecycle = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
30 | androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
31 | androidx-appCompat = { module = "androidx.appcompat:appcompat", version.ref = "appCompat" }
32 | androidx-androidJunit = { module = "androidx.test.ext:junit", version.ref = "androidJunit" }
33 | androidx-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
34 |
35 | google-material = { module = "com.google.android.material:material", version.ref = "googleMaterial" }
36 |
37 | compose-toolingPreview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
38 | compose-test = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
39 | compose-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
40 |
41 | junit = { module = "junit:junit", version.ref = "junit" }
42 |
43 | voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }
44 | voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyager" }
45 |
46 | [plugins]
47 | androidApplication = { id = "com.android.application", version.ref = "agp" }
48 | androidLibrary = { id = "com.android.library", version.ref = "agp" }
49 | kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
50 | jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
51 | composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
52 | maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }
53 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jul 28 18:28:15 BRT 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/iosApp/Configuration/Config.xcconfig:
--------------------------------------------------------------------------------
1 | TEAM_ID=
2 | BUNDLE_ID=co.touchlab.compose.animations
3 | APP_NAME=Compose Animations
4 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 54;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
11 | 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; };
12 | 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; };
13 | 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; };
14 | /* End PBXBuildFile section */
15 |
16 | /* Begin PBXFileReference section */
17 | 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
18 | 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; };
19 | 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; };
20 | 7555FF7B242A565900829871 /* Compose Animations.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Compose Animations.app"; sourceTree = BUILT_PRODUCTS_DIR; };
21 | 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; };
22 | 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
23 | AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; };
24 | /* End PBXFileReference section */
25 |
26 | /* Begin PBXFrameworksBuildPhase section */
27 | B92378962B6B1156000C7307 /* Frameworks */ = {
28 | isa = PBXFrameworksBuildPhase;
29 | buildActionMask = 2147483647;
30 | files = (
31 | );
32 | runOnlyForDeploymentPostprocessing = 0;
33 | };
34 | /* End PBXFrameworksBuildPhase section */
35 |
36 | /* Begin PBXGroup section */
37 | 058557D7273AAEEB004C7B11 /* Preview Content */ = {
38 | isa = PBXGroup;
39 | children = (
40 | 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */,
41 | );
42 | path = "Preview Content";
43 | sourceTree = "";
44 | };
45 | 42799AB246E5F90AF97AA0EF /* Frameworks */ = {
46 | isa = PBXGroup;
47 | children = (
48 | );
49 | name = Frameworks;
50 | sourceTree = "";
51 | };
52 | 7555FF72242A565900829871 = {
53 | isa = PBXGroup;
54 | children = (
55 | AB1DB47929225F7C00F7AF9C /* Configuration */,
56 | 7555FF7D242A565900829871 /* iosApp */,
57 | 7555FF7C242A565900829871 /* Products */,
58 | 42799AB246E5F90AF97AA0EF /* Frameworks */,
59 | );
60 | sourceTree = "";
61 | };
62 | 7555FF7C242A565900829871 /* Products */ = {
63 | isa = PBXGroup;
64 | children = (
65 | 7555FF7B242A565900829871 /* Compose Animations.app */,
66 | );
67 | name = Products;
68 | sourceTree = "";
69 | };
70 | 7555FF7D242A565900829871 /* iosApp */ = {
71 | isa = PBXGroup;
72 | children = (
73 | 058557BA273AAA24004C7B11 /* Assets.xcassets */,
74 | 7555FF82242A565900829871 /* ContentView.swift */,
75 | 7555FF8C242A565B00829871 /* Info.plist */,
76 | 2152FB032600AC8F00CF470E /* iOSApp.swift */,
77 | 058557D7273AAEEB004C7B11 /* Preview Content */,
78 | );
79 | path = iosApp;
80 | sourceTree = "";
81 | };
82 | AB1DB47929225F7C00F7AF9C /* Configuration */ = {
83 | isa = PBXGroup;
84 | children = (
85 | AB3632DC29227652001CCB65 /* Config.xcconfig */,
86 | );
87 | path = Configuration;
88 | sourceTree = "";
89 | };
90 | /* End PBXGroup section */
91 |
92 | /* Begin PBXNativeTarget section */
93 | 7555FF7A242A565900829871 /* iosApp */ = {
94 | isa = PBXNativeTarget;
95 | buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */;
96 | buildPhases = (
97 | F36B1CEB2AD83DDC00CB74D5 /* Compile Kotlin Framework */,
98 | 7555FF77242A565900829871 /* Sources */,
99 | B92378962B6B1156000C7307 /* Frameworks */,
100 | 7555FF79242A565900829871 /* Resources */,
101 | );
102 | buildRules = (
103 | );
104 | dependencies = (
105 | );
106 | name = iosApp;
107 | packageProductDependencies = (
108 | );
109 | productName = iosApp;
110 | productReference = 7555FF7B242A565900829871 /* Compose Animations.app */;
111 | productType = "com.apple.product-type.application";
112 | };
113 | /* End PBXNativeTarget section */
114 |
115 | /* Begin PBXProject section */
116 | 7555FF73242A565900829871 /* Project object */ = {
117 | isa = PBXProject;
118 | attributes = {
119 | LastSwiftUpdateCheck = 1130;
120 | LastUpgradeCheck = 1130;
121 | ORGANIZATIONNAME = orgName;
122 | TargetAttributes = {
123 | 7555FF7A242A565900829871 = {
124 | CreatedOnToolsVersion = 11.3.1;
125 | };
126 | };
127 | };
128 | buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */;
129 | compatibilityVersion = "Xcode 12.0";
130 | developmentRegion = en;
131 | hasScannedForEncodings = 0;
132 | knownRegions = (
133 | en,
134 | Base,
135 | );
136 | mainGroup = 7555FF72242A565900829871;
137 | packageReferences = (
138 | );
139 | productRefGroup = 7555FF7C242A565900829871 /* Products */;
140 | projectDirPath = "";
141 | projectRoot = "";
142 | targets = (
143 | 7555FF7A242A565900829871 /* iosApp */,
144 | );
145 | };
146 | /* End PBXProject section */
147 |
148 | /* Begin PBXResourcesBuildPhase section */
149 | 7555FF79242A565900829871 /* Resources */ = {
150 | isa = PBXResourcesBuildPhase;
151 | buildActionMask = 2147483647;
152 | files = (
153 | 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */,
154 | 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */,
155 | );
156 | runOnlyForDeploymentPostprocessing = 0;
157 | };
158 | /* End PBXResourcesBuildPhase section */
159 |
160 | /* Begin PBXShellScriptBuildPhase section */
161 | F36B1CEB2AD83DDC00CB74D5 /* Compile Kotlin Framework */ = {
162 | isa = PBXShellScriptBuildPhase;
163 | buildActionMask = 2147483647;
164 | files = (
165 | );
166 | inputFileListPaths = (
167 | );
168 | inputPaths = (
169 | );
170 | name = "Compile Kotlin Framework";
171 | outputFileListPaths = (
172 | );
173 | outputPaths = (
174 | );
175 | runOnlyForDeploymentPostprocessing = 0;
176 | shellPath = /bin/sh;
177 | shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\n./gradlew :app:embedAndSignAppleFrameworkForXcode\n";
178 | };
179 | /* End PBXShellScriptBuildPhase section */
180 |
181 | /* Begin PBXSourcesBuildPhase section */
182 | 7555FF77242A565900829871 /* Sources */ = {
183 | isa = PBXSourcesBuildPhase;
184 | buildActionMask = 2147483647;
185 | files = (
186 | 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
187 | 7555FF83242A565900829871 /* ContentView.swift in Sources */,
188 | );
189 | runOnlyForDeploymentPostprocessing = 0;
190 | };
191 | /* End PBXSourcesBuildPhase section */
192 |
193 | /* Begin XCBuildConfiguration section */
194 | 7555FFA3242A565B00829871 /* Debug */ = {
195 | isa = XCBuildConfiguration;
196 | baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;
197 | buildSettings = {
198 | ALWAYS_SEARCH_USER_PATHS = NO;
199 | CLANG_ANALYZER_NONNULL = YES;
200 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
201 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
202 | CLANG_CXX_LIBRARY = "libc++";
203 | CLANG_ENABLE_MODULES = YES;
204 | CLANG_ENABLE_OBJC_ARC = YES;
205 | CLANG_ENABLE_OBJC_WEAK = YES;
206 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
207 | CLANG_WARN_BOOL_CONVERSION = YES;
208 | CLANG_WARN_COMMA = YES;
209 | CLANG_WARN_CONSTANT_CONVERSION = YES;
210 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
211 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
212 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
213 | CLANG_WARN_EMPTY_BODY = YES;
214 | CLANG_WARN_ENUM_CONVERSION = YES;
215 | CLANG_WARN_INFINITE_RECURSION = YES;
216 | CLANG_WARN_INT_CONVERSION = YES;
217 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
218 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
219 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
220 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
221 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
222 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
223 | CLANG_WARN_STRICT_PROTOTYPES = YES;
224 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
225 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
226 | CLANG_WARN_UNREACHABLE_CODE = YES;
227 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
228 | COPY_PHASE_STRIP = NO;
229 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
230 | ENABLE_STRICT_OBJC_MSGSEND = YES;
231 | ENABLE_TESTABILITY = YES;
232 | GCC_C_LANGUAGE_STANDARD = gnu11;
233 | GCC_DYNAMIC_NO_PIC = NO;
234 | GCC_NO_COMMON_BLOCKS = YES;
235 | GCC_OPTIMIZATION_LEVEL = 0;
236 | GCC_PREPROCESSOR_DEFINITIONS = (
237 | "DEBUG=1",
238 | "$(inherited)",
239 | );
240 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
241 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
242 | GCC_WARN_UNDECLARED_SELECTOR = YES;
243 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
244 | GCC_WARN_UNUSED_FUNCTION = YES;
245 | GCC_WARN_UNUSED_VARIABLE = YES;
246 | IPHONEOS_DEPLOYMENT_TARGET = 15.4;
247 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
248 | MTL_FAST_MATH = YES;
249 | ONLY_ACTIVE_ARCH = YES;
250 | SDKROOT = iphoneos;
251 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
252 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
253 | };
254 | name = Debug;
255 | };
256 | 7555FFA4242A565B00829871 /* Release */ = {
257 | isa = XCBuildConfiguration;
258 | baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;
259 | buildSettings = {
260 | ALWAYS_SEARCH_USER_PATHS = NO;
261 | CLANG_ANALYZER_NONNULL = YES;
262 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
263 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
264 | CLANG_CXX_LIBRARY = "libc++";
265 | CLANG_ENABLE_MODULES = YES;
266 | CLANG_ENABLE_OBJC_ARC = YES;
267 | CLANG_ENABLE_OBJC_WEAK = YES;
268 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
269 | CLANG_WARN_BOOL_CONVERSION = YES;
270 | CLANG_WARN_COMMA = YES;
271 | CLANG_WARN_CONSTANT_CONVERSION = YES;
272 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
274 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
275 | CLANG_WARN_EMPTY_BODY = YES;
276 | CLANG_WARN_ENUM_CONVERSION = YES;
277 | CLANG_WARN_INFINITE_RECURSION = YES;
278 | CLANG_WARN_INT_CONVERSION = YES;
279 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
280 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
281 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
282 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
283 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
284 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
285 | CLANG_WARN_STRICT_PROTOTYPES = YES;
286 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
287 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
288 | CLANG_WARN_UNREACHABLE_CODE = YES;
289 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
290 | COPY_PHASE_STRIP = NO;
291 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
292 | ENABLE_NS_ASSERTIONS = NO;
293 | ENABLE_STRICT_OBJC_MSGSEND = YES;
294 | GCC_C_LANGUAGE_STANDARD = gnu11;
295 | GCC_NO_COMMON_BLOCKS = YES;
296 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
297 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
298 | GCC_WARN_UNDECLARED_SELECTOR = YES;
299 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
300 | GCC_WARN_UNUSED_FUNCTION = YES;
301 | GCC_WARN_UNUSED_VARIABLE = YES;
302 | IPHONEOS_DEPLOYMENT_TARGET = 15.4;
303 | MTL_ENABLE_DEBUG_INFO = NO;
304 | MTL_FAST_MATH = YES;
305 | SDKROOT = iphoneos;
306 | SWIFT_COMPILATION_MODE = wholemodule;
307 | SWIFT_OPTIMIZATION_LEVEL = "-O";
308 | VALIDATE_PRODUCT = YES;
309 | };
310 | name = Release;
311 | };
312 | 7555FFA6242A565B00829871 /* Debug */ = {
313 | isa = XCBuildConfiguration;
314 | buildSettings = {
315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
316 | CODE_SIGN_IDENTITY = "Apple Development";
317 | CODE_SIGN_STYLE = Automatic;
318 | CURRENT_PROJECT_VERSION = 1;
319 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
320 | DEVELOPMENT_TEAM = "${TEAM_ID}";
321 | ENABLE_PREVIEWS = YES;
322 | FRAMEWORK_SEARCH_PATHS = (
323 | "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
324 | "$(SRCROOT)/../app/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
325 | );
326 | INFOPLIST_FILE = iosApp/Info.plist;
327 | INFOPLIST_KEY_CFBundleDisplayName = "Compose Animations";
328 | IPHONEOS_DEPLOYMENT_TARGET = 15.4;
329 | LD_RUNPATH_SEARCH_PATHS = (
330 | "$(inherited)",
331 | "@executable_path/Frameworks",
332 | );
333 | MARKETING_VERSION = 1.0;
334 | OTHER_LDFLAGS = (
335 | "$(inherited)",
336 | "-framework",
337 | ComposeAnimationsApp,
338 | );
339 | PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
340 | PRODUCT_NAME = "${APP_NAME}";
341 | PROVISIONING_PROFILE_SPECIFIER = "";
342 | SWIFT_VERSION = 5.0;
343 | TARGETED_DEVICE_FAMILY = "1,2";
344 | };
345 | name = Debug;
346 | };
347 | 7555FFA7242A565B00829871 /* Release */ = {
348 | isa = XCBuildConfiguration;
349 | buildSettings = {
350 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
351 | CODE_SIGN_IDENTITY = "Apple Development";
352 | CODE_SIGN_STYLE = Automatic;
353 | CURRENT_PROJECT_VERSION = 1;
354 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
355 | DEVELOPMENT_TEAM = "${TEAM_ID}";
356 | ENABLE_PREVIEWS = YES;
357 | FRAMEWORK_SEARCH_PATHS = (
358 | "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../app/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
359 | );
360 | INFOPLIST_FILE = iosApp/Info.plist;
361 | INFOPLIST_KEY_CFBundleDisplayName = "Compose Animations";
362 | IPHONEOS_DEPLOYMENT_TARGET = 15.4;
363 | LD_RUNPATH_SEARCH_PATHS = (
364 | "$(inherited)",
365 | "@executable_path/Frameworks",
366 | );
367 | MARKETING_VERSION = 1.0;
368 | OTHER_LDFLAGS = (
369 | "$(inherited)",
370 | "-framework",
371 | ComposeAnimationsApp,
372 | );
373 | PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
374 | PRODUCT_NAME = "${APP_NAME}";
375 | PROVISIONING_PROFILE_SPECIFIER = "";
376 | SWIFT_VERSION = 5.0;
377 | TARGETED_DEVICE_FAMILY = "1,2";
378 | };
379 | name = Release;
380 | };
381 | /* End XCBuildConfiguration section */
382 |
383 | /* Begin XCConfigurationList section */
384 | 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = {
385 | isa = XCConfigurationList;
386 | buildConfigurations = (
387 | 7555FFA3242A565B00829871 /* Debug */,
388 | 7555FFA4242A565B00829871 /* Release */,
389 | );
390 | defaultConfigurationIsVisible = 0;
391 | defaultConfigurationName = Release;
392 | };
393 | 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = {
394 | isa = XCConfigurationList;
395 | buildConfigurations = (
396 | 7555FFA6242A565B00829871 /* Debug */,
397 | 7555FFA7242A565B00829871 /* Release */,
398 | );
399 | defaultConfigurationIsVisible = 0;
400 | defaultConfigurationName = Release;
401 | };
402 | /* End XCConfigurationList section */
403 | };
404 | rootObject = 7555FF73242A565900829871 /* Project object */;
405 | }
406 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/faogustavo.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/faogustavo.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/faogustavo.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/xcuserdata/faogustavo.xcuserdatad/xcschemes/iosApp.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
23 |
24 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/xcuserdata/faogustavo.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | iosApp.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 | iosApp.xcscheme
13 |
14 | orderHint
15 | 1
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "app-icon-1024.png",
5 | "idiom" : "universal",
6 | "platform" : "ios",
7 | "size" : "1024x1024"
8 | }
9 | ],
10 | "info" : {
11 | "author" : "xcode",
12 | "version" : 1
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
--------------------------------------------------------------------------------
/iosApp/iosApp/ContentView.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import SwiftUI
3 | import ComposeAnimationsApp
4 |
5 | struct ComposeView: UIViewControllerRepresentable {
6 | func makeUIViewController(context: Context) -> UIViewController {
7 | MainViewControllerKt.MainViewController()
8 | }
9 |
10 | func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
11 | }
12 |
13 | struct ContentView: View {
14 | var body: some View {
15 | ComposeView().ignoresSafeArea(.keyboard)
16 | }
17 | }
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CADisableMinimumFrameDurationOnPhone
6 |
7 | CFBundleDevelopmentRegion
8 | $(DEVELOPMENT_LANGUAGE)
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UIApplicationSceneManifest
26 |
27 | UIApplicationSupportsMultipleScenes
28 |
29 |
30 | UILaunchScreen
31 |
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
--------------------------------------------------------------------------------
/iosApp/iosApp/iOSApp.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | @main
4 | struct iOSApp: App {
5 | var body: some Scene {
6 | WindowGroup {
7 | ContentView()
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | // https://docs.gradle.org/current/userguide/declaring_dependencies.html
2 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
3 |
4 | pluginManagement {
5 | repositories {
6 | google()
7 | gradlePluginPortal()
8 | mavenCentral()
9 | }
10 | }
11 |
12 | dependencyResolutionManagement {
13 | repositories {
14 | google()
15 | mavenCentral()
16 | }
17 | }
18 |
19 | rootProject.name = "ComposeAnimations"
20 |
21 | // Modules
22 | include(":app")
23 | include(":easing")
24 | include(":value-animator")
25 |
--------------------------------------------------------------------------------
/tl2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/tl2.png
--------------------------------------------------------------------------------
/value-animator/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/value-animator/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.androidLibrary)
3 | alias(libs.plugins.kotlinMultiplatform)
4 | alias(libs.plugins.jetbrainsCompose)
5 | alias(libs.plugins.composeCompiler)
6 | alias(libs.plugins.maven.publish)
7 | }
8 |
9 | kotlin {
10 | jvm()
11 |
12 | iosX64()
13 | iosArm64()
14 | iosSimulatorArm64()
15 |
16 | wasmJs { browser() }
17 |
18 | androidTarget {
19 | publishAllLibraryVariants()
20 | compilations.all {
21 | kotlinOptions {
22 | jvmTarget = "1.8"
23 | }
24 | }
25 | }
26 |
27 | applyDefaultHierarchyTemplate()
28 |
29 | sourceSets {
30 | commonMain.dependencies {
31 | implementation(compose.runtime)
32 | implementation(compose.animation)
33 | }
34 | }
35 | }
36 |
37 | android {
38 | namespace = "co.touchlab.compose.value.animator"
39 | compileSdk = libs.versions.android.compileSdk.get().toInt()
40 |
41 | defaultConfig {
42 | minSdk = libs.versions.android.minSdk.get().toInt()
43 | targetSdk = libs.versions.android.targetSdk.get().toInt()
44 |
45 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
46 | proguardFile("consumer-rules.pro")
47 | }
48 |
49 | buildTypes {
50 | release {
51 | isMinifyEnabled = false
52 | }
53 | }
54 |
55 | compileOptions {
56 | sourceCompatibility = JavaVersion.VERSION_1_8
57 | targetCompatibility = JavaVersion.VERSION_1_8
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/value-animator/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/value-animator/consumer-rules.pro
--------------------------------------------------------------------------------
/value-animator/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.kts.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/value-animator/src/androidMain/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/value-animator/src/commonMain/kotlin/co/touchlab/composeanimations/value/animator/MultipleValuesAnimator.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.value.animator
2 |
3 | internal data class MultipleValuesAnimator(
4 | val values: List,
5 | ) {
6 | private val groups = values.zipWithNext()
7 |
8 | val initialAnimationValue: T = values.first()
9 | val targetAnimationValue: T = values.last()
10 |
11 | val initialFrameValue: Float = 0f
12 | val targetFrameValue: Float = groups.size.toFloat()
13 |
14 | fun animate(frame: Float, valueAtFraction: ValueAtFraction): T = when {
15 | groups.isEmpty() -> initialAnimationValue
16 | frame <= initialFrameValue -> initialAnimationValue
17 | frame >= targetFrameValue -> targetAnimationValue
18 | else -> {
19 | val integerPart = frame.toInt()
20 | val decimalPart = frame - integerPart
21 | val (initialValue, finalValue) = groups[frame.toInt()]
22 | valueAtFraction(decimalPart, initialValue, finalValue)
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/value-animator/src/commonMain/kotlin/co/touchlab/composeanimations/value/animator/ValueAtFraction.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.value.animator
2 |
3 | import androidx.compose.ui.geometry.Offset
4 | import androidx.compose.ui.geometry.Rect
5 | import androidx.compose.ui.geometry.Size
6 | import androidx.compose.ui.graphics.Color
7 | import androidx.compose.ui.graphics.colorspace.ColorSpaces
8 | import androidx.compose.ui.unit.Dp
9 | import androidx.compose.ui.unit.IntOffset
10 | import androidx.compose.ui.unit.IntSize
11 | import co.touchlab.composeanimations.value.animator.utils.minus
12 | import co.touchlab.composeanimations.value.animator.utils.plus
13 | import co.touchlab.composeanimations.value.animator.utils.times
14 | import kotlin.math.pow
15 |
16 | /**
17 | * This interface is responsible for converting the fraction value into one value of type T
18 | * between initialValue and finalValue
19 | */
20 | fun interface ValueAtFraction {
21 | companion object {
22 | val Float: ValueAtFraction get() = floatAtFraction
23 | val Int: ValueAtFraction get() = intAtFraction
24 | val Dp: ValueAtFraction get() = dpAtFraction
25 | val Size: ValueAtFraction get() = sizeAtFraction
26 | val Offset: ValueAtFraction get() = offsetAtFraction
27 | val Rect: ValueAtFraction get() = rectAtFraction
28 | val IntOffset: ValueAtFraction get() = intOffsetAtFraction
29 | val IntSize: ValueAtFraction get() = intSizeAtFraction
30 | val Color: ValueAtFraction get() = colorAtFraction
31 | }
32 |
33 | /**
34 | * @param fraction Float representing an animation progress. Always between 0f and 1f
35 | * @param initialValue The initial value from the range
36 | * @param finalValue The final value from the range
37 | */
38 | operator fun invoke(
39 | fraction: Float,
40 | initialValue: T,
41 | finalValue: T,
42 | ): T
43 | }
44 |
45 | private val floatAtFraction = ValueAtFraction { fraction, initialValue, finalValue ->
46 | initialValue + (finalValue - initialValue) * fraction
47 | }
48 |
49 | private val intAtFraction = ValueAtFraction { fraction, initialValue, finalValue ->
50 | initialValue + ((finalValue - initialValue) * fraction).toInt()
51 | }
52 |
53 | private val dpAtFraction = ValueAtFraction { fraction, initialValue, finalValue ->
54 | initialValue + (finalValue - initialValue) * fraction
55 | }
56 |
57 | private val sizeAtFraction = ValueAtFraction { fraction, initialValue, finalValue ->
58 | initialValue + (finalValue - initialValue) * fraction
59 | }
60 |
61 | private val offsetAtFraction = ValueAtFraction { fraction, initialValue, finalValue ->
62 | initialValue + (finalValue - initialValue) * fraction
63 | }
64 |
65 | private val rectAtFraction = ValueAtFraction { fraction, initialValue, finalValue ->
66 | initialValue + (finalValue - initialValue) * fraction
67 | }
68 |
69 | private val intOffsetAtFraction = ValueAtFraction { fraction, initialValue, finalValue ->
70 | initialValue + (finalValue - initialValue) * fraction
71 | }
72 |
73 | private val intSizeAtFraction = ValueAtFraction { fraction, initialValue, finalValue ->
74 | initialValue + (finalValue - initialValue) * fraction
75 | }
76 |
77 | private val colorAtFraction = ValueAtFraction { fraction, initialValue, finalValue ->
78 | val initialValueAsSRGB = initialValue.convert(ColorSpaces.Srgb)
79 | val finalValueAsSRGB = finalValue.convert(ColorSpaces.Srgb)
80 |
81 | val startA = initialValueAsSRGB.alpha
82 | val startR = initialValueAsSRGB.red.pow(2.2f)
83 | val startG = initialValueAsSRGB.green.pow(2.2f)
84 | val startB = initialValueAsSRGB.blue.pow(2.2f)
85 |
86 | val endA = finalValueAsSRGB.alpha
87 | val endR = finalValueAsSRGB.red.pow(2.2f)
88 | val endG = finalValueAsSRGB.green.pow(2.2f)
89 | val endB = finalValueAsSRGB.blue.pow(2.2f)
90 |
91 | Color(
92 | red = startR + fraction * (endR - startR),
93 | green = startG + fraction * (endG - startG),
94 | blue = startB + fraction * (endB - startB),
95 | alpha = startA + fraction * (endA - startA),
96 | colorSpace = ColorSpaces.Srgb
97 | )
98 | }
99 |
--------------------------------------------------------------------------------
/value-animator/src/commonMain/kotlin/co/touchlab/composeanimations/value/animator/animateAsState.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.value.animator
2 |
3 | import androidx.compose.animation.core.AnimationSpec
4 | import androidx.compose.animation.core.spring
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.runtime.State
7 | import androidx.compose.ui.geometry.Offset
8 | import androidx.compose.ui.geometry.Rect
9 | import androidx.compose.ui.geometry.Size
10 | import androidx.compose.ui.graphics.Color
11 | import androidx.compose.ui.unit.Dp
12 | import androidx.compose.ui.unit.IntOffset
13 | import androidx.compose.ui.unit.IntSize
14 |
15 | @Composable
16 | fun animateFloatAsState(
17 | initialValue: Float,
18 | targetValue: Float,
19 | startDelay: Long = 0,
20 | animationSpec: AnimationSpec = spring(),
21 | ) = animateFloatValuesAsState(
22 | values = floatArrayOf(initialValue, targetValue),
23 | startDelay = startDelay,
24 | animationSpec = animationSpec
25 | )
26 |
27 | @Composable
28 | fun animateIntAsState(
29 | initialValue: Int,
30 | targetValue: Int,
31 | startDelay: Long = 0,
32 | animationSpec: AnimationSpec = spring(),
33 | ) = animateIntValuesAsState(
34 | values = arrayOf(initialValue, targetValue),
35 | startDelay = startDelay,
36 | animationSpec = animationSpec
37 | )
38 |
39 | @Composable
40 | fun animateDpAsState(
41 | initialValue: Dp,
42 | targetValue: Dp,
43 | startDelay: Long = 0,
44 | animationSpec: AnimationSpec = spring(),
45 | ) = animateDpValuesAsState(
46 | values = arrayOf(initialValue, targetValue),
47 | startDelay = startDelay,
48 | animationSpec = animationSpec
49 | )
50 |
51 | @Composable
52 | fun animateSizeAsState(
53 | initialValue: Size,
54 | targetValue: Size,
55 | startDelay: Long = 0,
56 | animationSpec: AnimationSpec = spring(),
57 | ) = animateSizeValuesAsState(
58 | values = arrayOf(initialValue, targetValue),
59 | startDelay = startDelay,
60 | animationSpec = animationSpec
61 | )
62 |
63 | @Composable
64 | fun animateOffsetAsState(
65 | initialValue: Offset,
66 | targetValue: Offset,
67 | startDelay: Long = 0,
68 | animationSpec: AnimationSpec = spring(),
69 | ) = animateOffsetValuesAsState(
70 | values = arrayOf(initialValue, targetValue),
71 | startDelay = startDelay,
72 | animationSpec = animationSpec
73 | )
74 |
75 | @Composable
76 | fun animateRectAsState(
77 | initialValue: Rect,
78 | targetValue: Rect,
79 | startDelay: Long = 0,
80 | animationSpec: AnimationSpec = spring(),
81 | ) = animateRectValuesAsState(
82 | values = arrayOf(initialValue, targetValue),
83 | startDelay = startDelay,
84 | animationSpec = animationSpec
85 | )
86 |
87 | @Composable
88 | fun animateIntOffsetAsState(
89 | initialValue: IntOffset,
90 | targetValue: IntOffset,
91 | startDelay: Long = 0,
92 | animationSpec: AnimationSpec = spring(),
93 | ) = animateIntOffsetValuesAsState(
94 | values = arrayOf(initialValue, targetValue),
95 | startDelay = startDelay,
96 | animationSpec = animationSpec
97 | )
98 |
99 | @Composable
100 | fun animateIntSizeAsState(
101 | initialValue: IntSize,
102 | targetValue: IntSize,
103 | startDelay: Long = 0,
104 | animationSpec: AnimationSpec = spring(),
105 | ) = animateIntSizeValuesAsState(
106 | values = arrayOf(initialValue, targetValue),
107 | startDelay = startDelay,
108 | animationSpec = animationSpec
109 | )
110 |
111 | @Composable
112 | fun animateColorAsState(
113 | initialValue: Color,
114 | targetValue: Color,
115 | startDelay: Long = 0,
116 | animationSpec: AnimationSpec = spring(),
117 | ) = animateColorValuesAsState(
118 | values = arrayOf(initialValue, targetValue),
119 | startDelay = startDelay,
120 | animationSpec = animationSpec
121 | )
122 |
123 | @Composable
124 | inline fun animateAsState(
125 | initialValue: T,
126 | targetValue: T,
127 | getValueAtFraction: ValueAtFraction,
128 | startDelay: Long = 0,
129 | animationSpec: AnimationSpec = spring(),
130 | ): State = animateValuesAsState(
131 | values = arrayOf(initialValue, targetValue),
132 | getValueAtFraction = getValueAtFraction,
133 | startDelay = startDelay,
134 | animationSpec = animationSpec,
135 | )
136 |
--------------------------------------------------------------------------------
/value-animator/src/commonMain/kotlin/co/touchlab/composeanimations/value/animator/animateTransitionValuesAsState.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.value.animator
2 |
3 | import androidx.compose.animation.core.InfiniteRepeatableSpec
4 | import androidx.compose.animation.core.InfiniteTransition
5 | import androidx.compose.animation.core.animateFloat
6 | import androidx.compose.animation.core.infiniteRepeatable
7 | import androidx.compose.animation.core.tween
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.runtime.State
10 | import androidx.compose.runtime.derivedStateOf
11 | import androidx.compose.runtime.getValue
12 | import androidx.compose.runtime.remember
13 | import androidx.compose.runtime.rememberUpdatedState
14 | import androidx.compose.ui.geometry.Offset
15 | import androidx.compose.ui.geometry.Rect
16 | import androidx.compose.ui.geometry.Size
17 | import androidx.compose.ui.graphics.Color
18 | import androidx.compose.ui.unit.Dp
19 | import androidx.compose.ui.unit.IntOffset
20 | import androidx.compose.ui.unit.IntSize
21 |
22 | @Composable
23 | fun InfiniteTransition.animateFloatValues(
24 | vararg values: Float,
25 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
26 | label: String = "MultipleFloatAnimation",
27 | ): State = animateValues(
28 | values = values.toTypedArray(),
29 | getValueAtFraction = ValueAtFraction.Float,
30 | animationSpec = animationSpec,
31 | label = label,
32 | )
33 |
34 | @Composable
35 | fun InfiniteTransition.animateIntValues(
36 | values: Array,
37 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
38 | label: String = "MultipleIntAnimation",
39 | ): State = animateValues(
40 | values = values,
41 | getValueAtFraction = ValueAtFraction.Int,
42 | animationSpec = animationSpec,
43 | label = label,
44 | )
45 |
46 | @Composable
47 | fun InfiniteTransition.animateDpValues(
48 | values: Array,
49 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
50 | label: String = "MultipleDpAnimation",
51 | ): State = animateValues(
52 | values = values,
53 | getValueAtFraction = ValueAtFraction.Dp,
54 | animationSpec = animationSpec,
55 | label = label,
56 | )
57 |
58 | @Composable
59 | fun InfiniteTransition.animateSizeValues(
60 | values: Array,
61 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
62 | label: String = "MultipleSizeAnimation",
63 | ): State = animateValues(
64 | values = values,
65 | getValueAtFraction = ValueAtFraction.Size,
66 | animationSpec = animationSpec,
67 | label = label,
68 | )
69 |
70 | @Composable
71 | fun InfiniteTransition.animateOffsetValues(
72 | values: Array,
73 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
74 | label: String = "MultipleOffsetAnimation",
75 | ): State = animateValues(
76 | values = values,
77 | getValueAtFraction = ValueAtFraction.Offset,
78 | animationSpec = animationSpec,
79 | label = label,
80 | )
81 |
82 | @Composable
83 | fun InfiniteTransition.animateRectValues(
84 | values: Array,
85 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
86 | label: String = "MultipleRectAnimation",
87 | ): State = animateValues(
88 | values = values,
89 | getValueAtFraction = ValueAtFraction.Rect,
90 | animationSpec = animationSpec,
91 | label = label,
92 | )
93 |
94 | @Composable
95 | fun InfiniteTransition.animateIntOffsetValues(
96 | values: Array,
97 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
98 | label: String = "MultipleIntOffsetAnimation",
99 | ): State = animateValues(
100 | values = values,
101 | getValueAtFraction = ValueAtFraction.IntOffset,
102 | animationSpec = animationSpec,
103 | label = label,
104 | )
105 |
106 | @Composable
107 | fun InfiniteTransition.animateIntSizeValues(
108 | values: Array,
109 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
110 | label: String = "MultipleIntSizeAnimation",
111 | ): State = animateValues(
112 | values = values,
113 | getValueAtFraction = ValueAtFraction.IntSize,
114 | animationSpec = animationSpec,
115 | label = label,
116 | )
117 |
118 | @Composable
119 | fun InfiniteTransition.animateColorValues(
120 | values: Array,
121 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
122 | label: String = "MultipleColorAnimation",
123 | ): State = animateValues(
124 | values = values,
125 | getValueAtFraction = ValueAtFraction.Color,
126 | animationSpec = animationSpec,
127 | label = label,
128 | )
129 |
130 | @Composable
131 | inline fun InfiniteTransition.animateValues(
132 | initialValue: T,
133 | targetValue: T,
134 | getValueAtFraction: ValueAtFraction,
135 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
136 | label: String = "ValueAnimation",
137 | ): State = animateValues(
138 | values = arrayOf(initialValue, targetValue),
139 | getValueAtFraction = getValueAtFraction,
140 | animationSpec = animationSpec,
141 | label = label,
142 | )
143 |
144 | @Composable
145 | fun InfiniteTransition.animateValues(
146 | vararg values: T,
147 | getValueAtFraction: ValueAtFraction,
148 | animationSpec: InfiniteRepeatableSpec = infiniteRepeatable(animation = tween()),
149 | label: String = "MultipleValueAnimation",
150 | ): State {
151 | require(values.isNotEmpty()) {
152 | "You should provide at least one item to animate"
153 | }
154 |
155 | val valueAnimator by rememberUpdatedState(
156 | MultipleValuesAnimator(values.toList())
157 | )
158 |
159 | val animatedFrame by animateFloat(
160 | initialValue = valueAnimator.initialFrameValue,
161 | targetValue = valueAnimator.targetFrameValue,
162 | animationSpec = animationSpec,
163 | label = label,
164 | )
165 |
166 | return remember(valueAnimator) {
167 | derivedStateOf {
168 | valueAnimator.animate(animatedFrame, getValueAtFraction)
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/value-animator/src/commonMain/kotlin/co/touchlab/composeanimations/value/animator/animateValuesAsState.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.value.animator
2 |
3 | import androidx.compose.animation.core.AnimationSpec
4 | import androidx.compose.animation.core.animate
5 | import androidx.compose.animation.core.spring
6 | import androidx.compose.runtime.Composable
7 | import androidx.compose.runtime.LaunchedEffect
8 | import androidx.compose.runtime.State
9 | import androidx.compose.runtime.getValue
10 | import androidx.compose.runtime.mutableStateOf
11 | import androidx.compose.runtime.remember
12 | import androidx.compose.runtime.rememberUpdatedState
13 | import androidx.compose.ui.geometry.Offset
14 | import androidx.compose.ui.geometry.Rect
15 | import androidx.compose.ui.geometry.Size
16 | import androidx.compose.ui.graphics.Color
17 | import androidx.compose.ui.unit.Dp
18 | import androidx.compose.ui.unit.IntOffset
19 | import androidx.compose.ui.unit.IntSize
20 | import kotlinx.coroutines.delay
21 |
22 | @Composable
23 | fun animateFloatValuesAsState(
24 | vararg values: Float,
25 | startDelay: Long = 0,
26 | animationSpec: AnimationSpec = spring(),
27 | ): State = animateValuesAsState(
28 | values = values.toTypedArray(),
29 | getValueAtFraction = ValueAtFraction.Float,
30 | startDelay = startDelay,
31 | animationSpec = animationSpec,
32 | )
33 |
34 | @Composable
35 | fun animateIntValuesAsState(
36 | values: Array,
37 | startDelay: Long = 0,
38 | animationSpec: AnimationSpec = spring(),
39 | ): State = animateValuesAsState(
40 | values = values,
41 | getValueAtFraction = ValueAtFraction.Int,
42 | startDelay = startDelay,
43 | animationSpec = animationSpec,
44 | )
45 |
46 | @Composable
47 | fun animateDpValuesAsState(
48 | values: Array,
49 | startDelay: Long = 0,
50 | animationSpec: AnimationSpec = spring(),
51 | ): State = animateValuesAsState(
52 | values = values,
53 | getValueAtFraction = ValueAtFraction.Dp,
54 | startDelay = startDelay,
55 | animationSpec = animationSpec,
56 | )
57 |
58 | @Composable
59 | fun animateSizeValuesAsState(
60 | values: Array,
61 | startDelay: Long = 0,
62 | animationSpec: AnimationSpec = spring(),
63 | ): State = animateValuesAsState(
64 | values = values,
65 | getValueAtFraction = ValueAtFraction.Size,
66 | startDelay = startDelay,
67 | animationSpec = animationSpec,
68 | )
69 |
70 | @Composable
71 | fun animateOffsetValuesAsState(
72 | values: Array,
73 | startDelay: Long = 0,
74 | animationSpec: AnimationSpec = spring(),
75 | ): State = animateValuesAsState(
76 | values = values,
77 | getValueAtFraction = ValueAtFraction.Offset,
78 | startDelay = startDelay,
79 | animationSpec = animationSpec,
80 | )
81 |
82 | @Composable
83 | fun animateRectValuesAsState(
84 | values: Array,
85 | startDelay: Long = 0,
86 | animationSpec: AnimationSpec = spring(),
87 | ): State = animateValuesAsState(
88 | values = values,
89 | getValueAtFraction = ValueAtFraction.Rect,
90 | startDelay = startDelay,
91 | animationSpec = animationSpec,
92 | )
93 |
94 | @Composable
95 | fun animateIntOffsetValuesAsState(
96 | values: Array,
97 | startDelay: Long = 0,
98 | animationSpec: AnimationSpec = spring(),
99 | ): State = animateValuesAsState(
100 | values = values,
101 | getValueAtFraction = ValueAtFraction.IntOffset,
102 | startDelay = startDelay,
103 | animationSpec = animationSpec,
104 | )
105 |
106 | @Composable
107 | fun animateIntSizeValuesAsState(
108 | values: Array,
109 | startDelay: Long = 0,
110 | animationSpec: AnimationSpec = spring(),
111 | ): State = animateValuesAsState(
112 | values = values,
113 | getValueAtFraction = ValueAtFraction.IntSize,
114 | startDelay = startDelay,
115 | animationSpec = animationSpec,
116 | )
117 |
118 | @Composable
119 | fun animateColorValuesAsState(
120 | values: Array,
121 | startDelay: Long = 0,
122 | animationSpec: AnimationSpec = spring(),
123 | ): State = animateValuesAsState(
124 | values = values,
125 | getValueAtFraction = ValueAtFraction.Color,
126 | startDelay = startDelay,
127 | animationSpec = animationSpec,
128 | )
129 |
130 | @Composable
131 | fun animateValuesAsState(
132 | vararg values: T,
133 | getValueAtFraction: ValueAtFraction,
134 | startDelay: Long = 0,
135 | animationSpec: AnimationSpec = spring(),
136 | ): State {
137 | require(values.isNotEmpty()) {
138 | "You should provide at least one item to animate"
139 | }
140 |
141 | val valueAnimator by rememberUpdatedState(
142 | MultipleValuesAnimator(values.toList())
143 | )
144 |
145 | val animatedValue = remember(valueAnimator) {
146 | mutableStateOf(valueAnimator.initialAnimationValue)
147 | }
148 |
149 | LaunchedEffect(valueAnimator) {
150 | if (startDelay > 0) {
151 | delay(startDelay)
152 | }
153 |
154 | val (_, setValue) = animatedValue
155 | animate(
156 | initialValue = valueAnimator.initialFrameValue,
157 | targetValue = valueAnimator.targetFrameValue,
158 | animationSpec = animationSpec,
159 | ) { frame, _ -> setValue(valueAnimator.animate(frame, getValueAtFraction)) }
160 | }
161 |
162 | return animatedValue
163 | }
164 |
--------------------------------------------------------------------------------
/value-animator/src/commonMain/kotlin/co/touchlab/composeanimations/value/animator/utils/+intSize.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.value.animator.utils
2 |
3 | import androidx.compose.ui.unit.IntSize
4 | import kotlin.math.roundToInt
5 |
6 | operator fun IntSize.minus(other: IntSize): IntSize = IntSize(
7 | width = this.width - other.width,
8 | height = this.height - other.height
9 | )
10 |
11 | operator fun IntSize.plus(other: IntSize): IntSize = IntSize(
12 | width = this.width + other.width,
13 | height = this.height + other.height
14 | )
15 |
16 | operator fun IntSize.times(value: Float): IntSize = IntSize(
17 | width = (this.width * value).toInt(),
18 | height = (this.height * value).toInt()
19 | )
20 |
21 | operator fun IntSize.div(value: Float): IntSize = IntSize(
22 | width = (this.width / value).roundToInt(),
23 | height = (this.height / value).roundToInt()
24 | )
25 |
--------------------------------------------------------------------------------
/value-animator/src/commonMain/kotlin/co/touchlab/composeanimations/value/animator/utils/+rect.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.value.animator.utils
2 |
3 | import androidx.compose.ui.geometry.Rect
4 |
5 | operator fun Rect.minus(other: Rect): Rect = Rect(
6 | left = this.left - other.left,
7 | right = this.right - other.right,
8 | top = this.top - other.top,
9 | bottom = this.bottom - other.bottom,
10 | )
11 |
12 | operator fun Rect.plus(other: Rect): Rect = Rect(
13 | left = this.left + other.left,
14 | right = this.right + other.right,
15 | top = this.top + other.top,
16 | bottom = this.bottom + other.bottom,
17 | )
18 |
19 | operator fun Rect.times(value: Float): Rect = Rect(
20 | left = this.left * value,
21 | right = this.right * value,
22 | top = this.top * value,
23 | bottom = this.bottom * value,
24 | )
25 |
26 | operator fun Rect.div(value: Float): Rect = Rect(
27 | left = this.left / value,
28 | right = this.right / value,
29 | top = this.top / value,
30 | bottom = this.bottom / value,
31 | )
32 |
--------------------------------------------------------------------------------
/value-animator/src/commonMain/kotlin/co/touchlab/composeanimations/value/animator/utils/+size.kt:
--------------------------------------------------------------------------------
1 | package co.touchlab.composeanimations.value.animator.utils
2 |
3 | import androidx.compose.ui.geometry.Size
4 |
5 | operator fun Size.minus(other: Size): Size = Size(
6 | width = this.width - other.width,
7 | height = this.height - other.height
8 | )
9 |
10 | operator fun Size.plus(other: Size): Size = Size(
11 | width = this.width + other.width,
12 | height = this.height + other.height
13 | )
14 |
--------------------------------------------------------------------------------
/value-animator/value-animator-demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/touchlab/compose-animations/06e582c980543386a96751805a7635b3f8117f53/value-animator/value-animator-demo.gif
--------------------------------------------------------------------------------