Skip to content

Commit 8ed2d1b

Browse files
committed
Welcome Screen: WIP
1 parent 5c020dd commit 8ed2d1b

File tree

5 files changed

+92
-15
lines changed

5 files changed

+92
-15
lines changed
Lines changed: 3 additions & 0 deletions
Loading

app/src/processing/app/Preferences.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,18 @@ fun loadPreferences(): Properties{
2727
preferencesFile.createNewFile()
2828
}
2929
watchFile(preferencesFile)
30+
var update by remember { mutableStateOf(System.currentTimeMillis()) }
3031

31-
return Properties().apply {
32+
// TODO: Make observable when preferences change
33+
// TODO: Save to file when preferences change
34+
class ObservableProperties : Properties() {
35+
override fun setProperty(key: String, value: String): Any? {
36+
update = System.currentTimeMillis()
37+
return super.setProperty(key, value)
38+
}
39+
}
40+
41+
return ObservableProperties().apply {
3242
load(ClassLoader.getSystemResourceAsStream(DEFAULTS_FILE_NAME) ?: InputStream.nullInputStream())
3343
load(preferencesFile.inputStream())
3444
}

app/src/processing/app/ui/Welcome.kt

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ package processing.app.ui
22

33
import androidx.compose.foundation.Image
44
import androidx.compose.foundation.background
5+
import androidx.compose.foundation.border
56
import androidx.compose.foundation.layout.*
67
import androidx.compose.foundation.lazy.grid.GridCells
78
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
89
import androidx.compose.foundation.shape.RoundedCornerShape
10+
import androidx.compose.material.Checkbox
911
import androidx.compose.material.MaterialTheme
1012
import androidx.compose.material.MaterialTheme.colors
1113
import androidx.compose.material.MaterialTheme.typography
14+
import androidx.compose.material.RadioButton
1215
import androidx.compose.material.Text
1316
import androidx.compose.runtime.Composable
1417
import androidx.compose.ui.Alignment
@@ -20,6 +23,7 @@ import androidx.compose.ui.graphics.Color
2023
import androidx.compose.ui.res.painterResource
2124
import androidx.compose.ui.unit.dp
2225
import processing.app.Base
26+
import processing.app.LocalPreferences
2327
import processing.app.ui.theme.LocalLocale
2428
import processing.app.ui.theme.PDEButton
2529
import processing.app.ui.theme.PDEWindow
@@ -69,21 +73,42 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
6973
Column(
7074
verticalArrangement = Arrangement.spacedBy(16.dp)
7175
) {
72-
Text(
73-
text = locale["welcome.action.examples"],
74-
)
75-
Text(
76-
text = locale["welcome.action.tutorials"],
77-
)
76+
chip {
77+
Text(
78+
text = locale["welcome.action.examples"],
79+
)
80+
}
81+
chip {
82+
Text(
83+
text = locale["welcome.action.tutorials"],
84+
)
85+
}
7886
}
7987
Row(
8088
modifier = Modifier.fillMaxWidth(),
8189
horizontalArrangement = Arrangement.SpaceBetween,
82-
verticalAlignment = Alignment.CenterVertically
83-
){
84-
Text(
85-
text = locale["welcome.action.startup"],
86-
)
90+
verticalAlignment = Alignment.Bottom
91+
) {
92+
Row(
93+
horizontalArrangement = Arrangement.spacedBy(8.dp),
94+
verticalAlignment = Alignment.CenterVertically,
95+
modifier = Modifier
96+
.offset (-32.dp)
97+
98+
) {
99+
val preferences = LocalPreferences.current
100+
Checkbox(
101+
checked = preferences["welcome.four.show"]?.equals("true") ?: false,
102+
onCheckedChange = {
103+
preferences.setProperty("welcome.four.show",it.toString())
104+
},
105+
modifier = Modifier
106+
.size(24.dp)
107+
)
108+
Text(
109+
text = locale["welcome.action.startup"],
110+
)
111+
}
87112
PDEButton(onClick = { println("Open") }) {
88113
val locale = LocalLocale.current
89114
Text(locale["welcome.action.go"])
@@ -115,13 +140,19 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
115140
text = locale["welcome.intro.suggestion"],
116141
style = typography.body1,
117142
modifier = Modifier
118-
.padding(vertical = 16.dp)
143+
.padding(top = 16.dp)
119144
.clip(RoundedCornerShape(12.dp))
120145
.background(colors.primary)
121146
.padding(16.dp)
122147
.sizeIn(maxWidth = 200.dp)
123148

124149
)
150+
Image(
151+
painter = painterResource("welcome/intro/bubble.svg"),
152+
contentDescription = locale["welcome.intro.long"],
153+
modifier = Modifier
154+
.align{ _, space, _ -> space / 4 }
155+
)
125156
Row(
126157
modifier = Modifier
127158
.fillMaxWidth(),
@@ -165,6 +196,19 @@ class Welcome @Throws(IOException::class) constructor(base: Base) {
165196
}
166197
}
167198

199+
@Composable
200+
fun chip(content: @Composable () -> Unit){
201+
Box(
202+
modifier = Modifier
203+
.clip(RoundedCornerShape(12.dp))
204+
.background(colors.surface)
205+
.border(1.dp, colors.primary, RoundedCornerShape(12.dp))
206+
.padding(vertical = 4.dp, horizontal = 12.dp)
207+
){
208+
content()
209+
}
210+
}
211+
168212
@JvmStatic
169213
fun main(args: Array<String>) {
170214
pdeapplication("menu.help.welcome") {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package processing.app.ui.theme
2+
3+
import androidx.compose.material.Colors
4+
import androidx.compose.ui.graphics.Color
5+
6+
//val Colors = Colors(
7+
// primary = Color("#0F195A".toColorInt()),
8+
// primaryVariant = theme.getColor("toolbar.button.pressed.field"),
9+
// secondary = theme.getColor("editor.gradient.bottom"),
10+
// secondaryVariant = theme.getColor("editor.scrollbar.thumb.pressed.color"),
11+
// background = theme.getColor("editor.bgcolor"),
12+
// surface = theme.getColor("editor.bgcolor"),
13+
// error = theme.getColor("status.error.bgcolor"),
14+
// onPrimary = theme.getColor("toolbar.button.enabled.field"),
15+
// onSecondary = theme.getColor("toolbar.button.enabled.field"),
16+
// onBackground = theme.getColor("editor.fgcolor"),
17+
// onSurface = theme.getColor("editor.fgcolor"),
18+
// onError = theme.getColor("status.error.fgcolor"),
19+
// isLight = theme.getProperty("laf.mode").equals("light")
20+
//)

build/shared/lib/languages/PDE.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,8 @@ welcome.intro.message = A flexible software sketchbook and a language for learni
621621
welcome.intro.suggestion = Is it your first time using Processing? Try one of the examples on the right.
622622
welcome.action.examples = More examples
623623
welcome.action.tutorials = Tutorials
624-
welcome.action.startup = Startup
625-
welcome.action.go = "Let's go!"
624+
welcome.action.startup = Show this window at startup
625+
welcome.action.go = Let's go!
626626

627627
# ---------------------------------------
628628
# Beta

0 commit comments

Comments
 (0)