Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 36cd891

Browse files
committed
added github 404 anim.
1 parent b06c0a4 commit 36cd891

File tree

9 files changed

+228
-3
lines changed

9 files changed

+228
-3
lines changed

‎app/src/main/java/dev/baseio/composeplayground/MainActivity.kt‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class MainActivity : ComponentActivity() {
3232
clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
3333
addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
3434
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
35-
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
35+
decorView.systemUiVisibility =
36+
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
3637
}
3738
statusBarColor = Color.TRANSPARENT
3839
}
@@ -54,7 +55,7 @@ class MainActivity : ComponentActivity() {
5455
modifier = Modifier
5556
.weight(1f)
5657
.fillMaxWidth(),
57-
count = 10, state = pagerState,
58+
count = 11, state = pagerState,
5859
) { page ->
5960
// Our page content
6061
when (page) {
@@ -71,11 +72,16 @@ class MainActivity : ComponentActivity() {
7172
YahooWeatherAndSun(Modifier.align(Alignment.Center))
7273
}
7374
}
74-
0 -> {
75+
10 -> {
7576
Box(modifier = Modifier.fillMaxSize()) {
7677
IOSSleepSchedule()
7778
}
7879
}
80+
0 -> {
81+
Box(modifier = Modifier.fillMaxSize()) {
82+
Github404(Modifier)
83+
}
84+
}
7985
9 -> {
8086
Box(modifier = Modifier.fillMaxSize()) {
8187
ScalingRotatingLoader()
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
package dev.baseio.composeplayground.ui.animations
2+
3+
import androidx.compose.animation.core.*
4+
import androidx.compose.foundation.Image
5+
import androidx.compose.foundation.background
6+
import androidx.compose.foundation.layout.*
7+
import androidx.compose.material.MaterialTheme
8+
import androidx.compose.material.Surface
9+
import androidx.compose.runtime.Composable
10+
import androidx.compose.runtime.getValue
11+
import androidx.compose.runtime.remember
12+
import androidx.compose.ui.Alignment
13+
import androidx.compose.ui.Modifier
14+
import androidx.compose.ui.draw.scale
15+
import androidx.compose.ui.layout.ContentScale
16+
import androidx.compose.ui.platform.LocalConfiguration
17+
import androidx.compose.ui.platform.LocalDensity
18+
import androidx.compose.ui.unit.IntOffset
19+
import androidx.compose.ui.unit.dp
20+
import dev.baseio.composeplayground.R
21+
import dev.baseio.composeplayground.contributors.AnmolVerma
22+
23+
@Composable
24+
fun Github404(modifier: Modifier) {
25+
26+
val infiniteTransition = rememberInfiniteTransition()
27+
val yFactor by infiniteTransition.animateFloat(
28+
initialValue = 0f,
29+
targetValue = 30f,
30+
animationSpec = infiniteRepeatable(
31+
animation = tween(durationMillis = 2000, delayMillis = 0, easing = LinearEasing),
32+
repeatMode = RepeatMode.Reverse
33+
)
34+
)
35+
36+
val bgImageScaleFactor by infiniteTransition.animateFloat(
37+
initialValue = 1f,
38+
targetValue = 1.5f,
39+
animationSpec = infiniteRepeatable(
40+
animation = tween(durationMillis = 2000, delayMillis = 1000, easing = LinearEasing),
41+
repeatMode = RepeatMode.Reverse
42+
)
43+
)
44+
45+
46+
val width = with(LocalDensity.current) {
47+
LocalConfiguration.current.screenWidthDp.dp.toPx()
48+
}
49+
val height = with(LocalDensity.current) {
50+
LocalConfiguration.current.screenHeightDp.dp.toPx()
51+
}
52+
53+
val githubAvatarX = remember {
54+
Animatable(width.div(2))
55+
}
56+
57+
val githubAvatarY = remember {
58+
Animatable(height.div(2))
59+
}
60+
61+
62+
Surface(
63+
modifier
64+
.background(MaterialTheme.colors.background)
65+
) {
66+
67+
Box(Modifier.fillMaxSize()) {
68+
69+
Box {
70+
BackgroundImageGithub(bgImageScaleFactor)
71+
Looking404(githubAvatarX.value, githubAvatarY.value)
72+
HomeTwo(githubAvatarX.value.plus(480), githubAvatarY.value.minus(220))
73+
HomeOne(githubAvatarX.value.plus(80), githubAvatarY.value.minus(180))
74+
SpaceShip(githubAvatarX.value.plus(10), githubAvatarY.value.plus(30).minus(yFactor))
75+
AvatarShadow(githubAvatarX.value.minus(150), githubAvatarY.value.plus(210).minus(yFactor))
76+
GithubAvatar(githubAvatarX.value.minus(160), githubAvatarY.value.minus(yFactor))
77+
}
78+
79+
Box(
80+
modifier = Modifier
81+
.scale(0.6f)
82+
.align(Alignment.BottomEnd)
83+
.background(MaterialTheme.colors.background)
84+
) {
85+
AnmolVerma(Modifier.align(Alignment.Center))
86+
}
87+
}
88+
}
89+
}
90+
91+
@Composable
92+
private fun HomeTwo(
93+
githubAvatarX: Float,
94+
githubAvatarY: Float
95+
) {
96+
Image(
97+
painter = androidx.compose.ui.res.painterResource(id = R.drawable.deserthome1),
98+
contentDescription = null, modifier = Modifier
99+
.offset {
100+
IntOffset(
101+
githubAvatarX
102+
.toInt(),
103+
githubAvatarY
104+
.toInt()
105+
)
106+
}
107+
.scale(1.5f)
108+
)
109+
}
110+
111+
@Composable
112+
private fun HomeOne(
113+
githubAvatarX: Float,
114+
githubAvatarY: Float
115+
) {
116+
Image(
117+
painter = androidx.compose.ui.res.painterResource(id = R.drawable.deserthome1),
118+
contentDescription = null, modifier = Modifier
119+
.offset {
120+
IntOffset(
121+
githubAvatarX
122+
.toInt(),
123+
githubAvatarY
124+
.toInt()
125+
)
126+
}
127+
.scale(2.8f)
128+
)
129+
}
130+
131+
@Composable
132+
private fun SpaceShip(
133+
githubAvatarX: Float,
134+
githubAvatarY: Float
135+
) {
136+
Image(
137+
painter = androidx.compose.ui.res.painterResource(id = R.drawable.spaceship),
138+
contentDescription = null, modifier = Modifier
139+
.offset {
140+
IntOffset(
141+
githubAvatarX
142+
.toInt(),
143+
githubAvatarY
144+
.toInt()
145+
)
146+
}
147+
.scale(1.8f)
148+
)
149+
}
150+
151+
@Composable
152+
private fun Looking404(
153+
githubAvatarX: Float,
154+
githubAvatarY: Float
155+
) {
156+
Image(
157+
painter = androidx.compose.ui.res.painterResource(id = R.drawable.notfound),
158+
contentDescription = null, modifier = Modifier
159+
.offset {
160+
IntOffset(
161+
githubAvatarX
162+
.minus(480)
163+
.toInt(),
164+
githubAvatarY
165+
.toInt()
166+
.minus(130)
167+
)
168+
}
169+
.scale(1.8f)
170+
)
171+
}
172+
173+
@Composable
174+
private fun GithubAvatar(
175+
githubAvatarX: Float,
176+
githubAvatarY: Float
177+
) {
178+
Image(
179+
painter = androidx.compose.ui.res.painterResource(id = R.drawable.githubavatar),
180+
contentDescription = null, modifier = Modifier
181+
.offset {
182+
IntOffset(
183+
githubAvatarX
184+
.toInt(),
185+
githubAvatarY.toInt()
186+
)
187+
}
188+
.scale(1.8f)
189+
)
190+
}
191+
192+
@Composable
193+
private fun AvatarShadow(
194+
githubAvatarX: Float,
195+
githubAvatarY: Float
196+
) {
197+
Image(
198+
painter = androidx.compose.ui.res.painterResource(id = R.drawable.avatarshadow),
199+
contentDescription = null, modifier = Modifier
200+
.offset {
201+
IntOffset(
202+
githubAvatarX
203+
.toInt(),
204+
githubAvatarY.toInt()
205+
)
206+
}
207+
.scale(1.8f)
208+
)
209+
}
210+
211+
@Composable
212+
private fun BackgroundImageGithub(bgImageScaleFactor: Float) {
213+
Image(
214+
painter = androidx.compose.ui.res.painterResource(id = R.drawable.background),
215+
contentDescription = null,
216+
contentScale = ContentScale.Crop,
217+
modifier = Modifier.fillMaxSize().scale(bgImageScaleFactor)
218+
)
219+
}
7.46 KB
Loading[フレーム]
35.3 KB
Loading[フレーム]
5.82 KB
Loading[フレーム]
9.42 KB
Loading[フレーム]
10.3 KB
Loading[フレーム]
10.1 KB
Loading[フレーム]
2.74 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /