Hello world
parent
7e6bff2e13
commit
72cb4943e2
|
@ -0,0 +1,32 @@
|
|||
buildscript {
|
||||
ext.kotlin_version = '1.2.51'
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget= "1.8"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
compile 'no.tornado:tornadofx:1.7.16'
|
||||
testCompile "junit:junit:4.11"
|
||||
testCompile 'org.assertj:assertj-core:3.9.0'
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = "4.6"
|
||||
}
|
|
@ -1,146 +1,27 @@
|
|||
import androidx.compose.desktop.ui.tooling.preview.Preview
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.application
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.TextField
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
package example
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun App() {
|
||||
import javafx.geometry.Pos
|
||||
import tornadofx.*
|
||||
|
||||
MaterialTheme {
|
||||
val currentPage = remember { mutableStateOf("accueil") }
|
||||
|
||||
when (currentPage.value) {
|
||||
"accueil" -> {
|
||||
AccueilPage(
|
||||
onAjouterMotClick = { currentPage.value = "formulaire" },
|
||||
onImporterClick = { /* Action d'importation */ },
|
||||
onExporterClick = { /* Action d'exportation */ }
|
||||
)
|
||||
}
|
||||
"formulaire" -> {
|
||||
FormulairePage(onAnnulerClick = { currentPage.value = "accueil" })
|
||||
}
|
||||
}
|
||||
class HelloWorld : View() {
|
||||
override val root = hbox {
|
||||
label("Hello world")
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AccueilPage(
|
||||
onAjouterMotClick: () -> Unit,
|
||||
onImporterClick: () -> Unit,
|
||||
onExporterClick: () -> Unit
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize() // Fills the maximum available width
|
||||
.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
|
||||
) {
|
||||
Text(text = "Glossaire", style = MaterialTheme.typography.h5)
|
||||
|
||||
Button(onClick = onAjouterMotClick) {
|
||||
Text("Ajouter un mot")
|
||||
}
|
||||
|
||||
Button(onClick = onImporterClick) {
|
||||
Text("Importer un fichier CSV")
|
||||
}
|
||||
|
||||
Button(onClick = onExporterClick) {
|
||||
Text("Exporter un fichier CSV")
|
||||
class HelloWorldStyle : Stylesheet() {
|
||||
init {
|
||||
root {
|
||||
prefWidth = 400.px
|
||||
prefHeight = 400.px
|
||||
alignment = Pos.CENTER
|
||||
fontSize = 50.px
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun FormulairePage(onAnnulerClick: () -> Unit) {
|
||||
MaterialTheme {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(text = "Nouveau contexte métier", style = MaterialTheme.typography.h5)
|
||||
class HelloWorldApp : App(HelloWorld::class, HelloWorldStyle::class)
|
||||
|
||||
val mot = remember { mutableStateOf("") }
|
||||
TextField(
|
||||
value = mot.value,
|
||||
onValueChange = { mot.value = it },
|
||||
label = { Text("Mot") }
|
||||
)
|
||||
|
||||
val description = remember { mutableStateOf("") }
|
||||
TextField(
|
||||
value = description.value,
|
||||
onValueChange = { description.value = it },
|
||||
label = { Text("Description") }
|
||||
)
|
||||
|
||||
val contextePrincipal = remember { mutableStateOf("") }
|
||||
TextField(
|
||||
value = contextePrincipal.value,
|
||||
onValueChange = { contextePrincipal.value = it },
|
||||
label = { Text("Contexte principal") }
|
||||
)
|
||||
|
||||
val contexte2 = remember { mutableStateOf("") }
|
||||
TextField(
|
||||
value = contexte2.value,
|
||||
onValueChange = { contexte2.value = it },
|
||||
label = { Text("Contexte 2") }
|
||||
)
|
||||
|
||||
val lieA = remember { mutableStateOf("") }
|
||||
TextField(
|
||||
value = lieA.value,
|
||||
onValueChange = { lieA.value = it },
|
||||
label = { Text("Lié à") }
|
||||
)
|
||||
|
||||
val synonyme = remember { mutableStateOf("") }
|
||||
TextField(
|
||||
value = synonyme.value,
|
||||
onValueChange = { synonyme.value = it },
|
||||
label = { Text("Synonyme") }
|
||||
)
|
||||
|
||||
val antonyme = remember { mutableStateOf("") }
|
||||
TextField(
|
||||
value = antonyme.value,
|
||||
onValueChange = { antonyme.value = it },
|
||||
label = { Text("Antonyme") }
|
||||
)
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
Button(onClick = onAnnulerClick) {
|
||||
Text("Annuler")
|
||||
}
|
||||
Button(onClick = { /* Action de validation */ }) {
|
||||
Text("Valider")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main() = application {
|
||||
Window(onCloseRequest = ::exitApplication) {
|
||||
App()
|
||||
}
|
||||
fun main(args: Array<String>) {
|
||||
launch<HelloWorldApp>()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue