-
-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathStart.kt
More file actions
92 lines (88 loc) · 3.4 KB
/
Start.kt
File metadata and controls
92 lines (88 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package processing.app.ui
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.*
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import processing.app.Base
/**
* Show a splash screen window. A rewrite of Splash.java
*/
class Start {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val duration = 200
val timeMargin = 50
application {
var starting by remember { mutableStateOf(true) }
Window(
visible = starting,
onCloseRequest = { },
undecorated = true,
transparent = true,
resizable = false,
state = rememberWindowState(
position = WindowPosition(Alignment.Center),
width = 578.dp,
height = 665.dp
)
) {
var visible by remember { mutableStateOf(false) }
val composition = rememberCoroutineScope()
LaunchedEffect(Unit) {
visible = true
composition.launch {
delay(duration.toLong() + timeMargin)
try {
Base.main(args)
} catch (e: Exception) {
throw InternalError("Failed to invoke main method", e)
}
composition.launch {
visible = false
delay(duration.toLong() + timeMargin)
starting = false
}
}
}
AnimatedVisibility(
visible = visible,
enter = fadeIn(
animationSpec = tween(
durationMillis = duration,
easing = LinearEasing
)
),
exit = fadeOut(
animationSpec = tween(
durationMillis = duration,
easing = LinearEasing
)
)
) {
Image(
painter = painterResource("about-processing.svg"),
contentDescription = "About",
modifier = Modifier
.fillMaxSize()
.clip(RoundedCornerShape(16.dp))
)
}
}
}
}
}
}