Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 0b98c29

Browse files
authored
Merge pull request #84 from android/yaraki/MotionCompose
MotionCompose
2 parents 05259b7 + 22dd460 commit 0b98c29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2785
-0
lines changed

MotionCompose/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

MotionCompose/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Android Compose Motion Sample
2+
=============================
3+
4+
A collection of demos for Material Design Motion implemented in
5+
[Jetpack Compose](https://developer.android.com/jetpack/compose).
6+
7+
[Material Design](https://material.io) provides a lot of examples about motion design. This sample
8+
shows how to implement them on Android.
9+
10+
- [Understanding motion](https://material.io/design/motion/understanding-motion.html)
11+
- [The motion system](https://material.io/design/motion/the-motion-system.html)
12+
- [Speed](https://material.io/design/motion/speed.html)
13+
- [Choreography](https://material.io/design/motion/choreography.html)
14+
- [Customization](https://material.io/design/motion/customization.html)
15+
16+
The [Animation](https://developer.android.com/jetpack/compose/animation) doc how to use various
17+
animation APIs in Jetpack Compose.
18+
19+
All the source codes for demos are in the
20+
[demo](app/src/main/java/com/example/android/compose/motion/demo)
21+
package.
22+
23+
### [Layout > Fade](app/src/main/java/com/example/android/compose/motion/demo/fade)
24+
25+
https://user-images.githubusercontent.com/1237536/142575353-8ed5cc04-34e3-45ea-9782-19408c8d2c37.mp4
26+
27+
### [Layout > Fade through](app/src/main/java/com/example/android/compose/motion/demo/fadethrough)
28+
29+
https://user-images.githubusercontent.com/1237536/142538271-480a5573-4231-414a-88cd-9fd9951fc792.mp4
30+
31+
### [Layout > Shared transform](app/src/main/java/com/example/android/compose/motion/demo/sharedtransform)
32+
33+
https://user-images.githubusercontent.com/1237536/144388012-03a82738-40ac-47fb-9bf2-b6730e673c90.mp4
34+
35+
### [Layout > Shared axis](app/src/main/java/com/example/android/compose/motion/demo/sharedaxis)
36+
37+
https://user-images.githubusercontent.com/1237536/143834134-bfb2cebd-2610-4207-b53e-720c9f1b6e62.mp4
38+
39+
### [List > Loading](app/src/main/java/com/example/android/compose/motion/demo/loading)
40+
41+
https://user-images.githubusercontent.com/1237536/143526001-7621d2db-1228-4011-ae84-1572909e7806.mp4

MotionCompose/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

MotionCompose/app/build.gradle

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (C) 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'com.android.application'
19+
id 'org.jetbrains.kotlin.android'
20+
}
21+
22+
android {
23+
compileSdk 31
24+
25+
defaultConfig {
26+
applicationId 'com.example.android.compose.motion'
27+
minSdk 21
28+
targetSdk 31
29+
versionCode 1
30+
versionName '1.0'
31+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
32+
}
33+
34+
buildTypes {
35+
release {
36+
minifyEnabled false
37+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
38+
}
39+
}
40+
compileOptions {
41+
sourceCompatibility JavaVersion.VERSION_1_8
42+
targetCompatibility JavaVersion.VERSION_1_8
43+
}
44+
kotlinOptions {
45+
freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
46+
freeCompilerArgs += '-Xopt-in=kotlin.Experimental'
47+
jvmTarget = '1.8'
48+
}
49+
buildFeatures {
50+
compose true
51+
}
52+
composeOptions {
53+
kotlinCompilerExtensionVersion compose_version
54+
}
55+
packagingOptions {
56+
resources {
57+
excludes += '/META-INF/{AL2.0,LGPL2.1}'
58+
}
59+
}
60+
}
61+
62+
dependencies {
63+
implementation 'androidx.core:core-ktx:1.7.0'
64+
implementation "androidx.compose.ui:ui:$compose_version"
65+
implementation 'androidx.compose.material3:material3:1.0.0-alpha02'
66+
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
67+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
68+
implementation 'androidx.activity:activity-compose:1.4.0'
69+
implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.0-rc02'
70+
71+
def accompanist_version = '0.22.0-rc'
72+
implementation "com.google.accompanist:accompanist-flowlayout:$accompanist_version"
73+
implementation "com.google.accompanist:accompanist-insets-ui:$accompanist_version"
74+
implementation "com.google.accompanist:accompanist-placeholder:$accompanist_version"
75+
76+
def lifecycle_version = '2.4.0'
77+
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
78+
79+
implementation "androidx.paging:paging-compose:1.0.0-alpha14"
80+
81+
testImplementation 'junit:junit:4.13.2'
82+
androidTestImplementation 'com.google.truth:truth:1.1.3'
83+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
84+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
85+
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
86+
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
87+
}

MotionCompose/app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.
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
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.android.compose.motion
18+
19+
import androidx.test.core.app.ActivityScenario
20+
import androidx.test.ext.junit.runners.AndroidJUnit4
21+
import com.google.common.truth.Truth.assertThat
22+
import org.junit.Test
23+
import org.junit.runner.RunWith
24+
25+
@RunWith(AndroidJUnit4::class)
26+
class MainActivityTest {
27+
28+
@Test
29+
fun launches() {
30+
val scenario = ActivityScenario.launch(MainActivity::class.java)
31+
scenario.onActivity { activity ->
32+
assertThat(activity.title).isEqualTo("Motion Compose")
33+
}
34+
}
35+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2021 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<manifest
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:tools="http://schemas.android.com/tools"
20+
package="com.example.android.compose.motion">
21+
22+
<application
23+
android:allowBackup="false"
24+
android:icon="@mipmap/ic_launcher"
25+
android:label="@string/app_name"
26+
android:roundIcon="@mipmap/ic_launcher_round"
27+
android:supportsRtl="true"
28+
android:theme="@style/Theme.MotionCompose">
29+
30+
<activity
31+
android:name=".MainActivity"
32+
android:exported="true"
33+
android:theme="@style/Theme.MotionCompose">
34+
<intent-filter>
35+
<action android:name="android.intent.action.MAIN" />
36+
<category android:name="android.intent.category.LAUNCHER" />
37+
</intent-filter>
38+
</activity>
39+
40+
</application>
41+
42+
</manifest>
31.9 KB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.android.compose.motion
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
import androidx.activity.compose.setContent
22+
import androidx.core.view.WindowCompat
23+
import com.example.android.compose.motion.ui.Main
24+
25+
class MainActivity : ComponentActivity() {
26+
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
super.onCreate(savedInstanceState)
29+
WindowCompat.setDecorFitsSystemWindows(window, false)
30+
setContent {
31+
Main()
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)