Hello world

main
Odabasioglu Cemal 2023-11-07 08:29:32 +00:00
parent 7e6bff2e13
commit 72cb4943e2
2 changed files with 48 additions and 135 deletions

32
build.gradle Normal file
View File

@ -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"
}

View File

@ -1,146 +1,27 @@
import androidx.compose.desktop.ui.tooling.preview.Preview package example
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
@Composable import javafx.geometry.Pos
@Preview import tornadofx.*
fun App() {
MaterialTheme { class HelloWorld : View() {
val currentPage = remember { mutableStateOf("accueil") } override val root = hbox {
label("Hello world")
when (currentPage.value) {
"accueil" -> {
AccueilPage(
onAjouterMotClick = { currentPage.value = "formulaire" },
onImporterClick = { /* Action d'importation */ },
onExporterClick = { /* Action d'exportation */ }
)
}
"formulaire" -> {
FormulairePage(onAnnulerClick = { currentPage.value = "accueil" })
}
} }
} }
}
@Composable class HelloWorldStyle : Stylesheet() {
fun AccueilPage( init {
onAjouterMotClick: () -> Unit, root {
onImporterClick: () -> Unit, prefWidth = 400.px
onExporterClick: () -> Unit prefHeight = 400.px
) { alignment = Pos.CENTER
Column( fontSize = 50.px
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")
} }
} }
} }
@Composable class HelloWorldApp : App(HelloWorld::class, HelloWorldStyle::class)
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)
val mot = remember { mutableStateOf("") } fun main(args: Array<String>) {
TextField( launch<HelloWorldApp>()
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()
}
} }