diff --git a/iosApp/Configuration/Config.xcconfig b/iosApp/Configuration/Config.xcconfig index f391597..bfde983 100644 --- a/iosApp/Configuration/Config.xcconfig +++ b/iosApp/Configuration/Config.xcconfig @@ -1,3 +1,3 @@ -TEAM_ID= +TEAM_ID=X3U84U8A6F BUNDLE_ID=com.myapplication.MyApplication APP_NAME=My application diff --git a/shared/src/commonMain/kotlin/App.kt b/shared/src/commonMain/kotlin/App.kt index 0889bdd..fe8ebb0 100644 --- a/shared/src/commonMain/kotlin/App.kt +++ b/shared/src/commonMain/kotlin/App.kt @@ -1,38 +1,85 @@ -import androidx.compose.animation.AnimatedVisibility -import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.itemsIndexed import androidx.compose.material.Button import androidx.compose.material.MaterialTheme import androidx.compose.material.Text +import androidx.compose.material.TextButton import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import org.jetbrains.compose.resources.ExperimentalResourceApi -import org.jetbrains.compose.resources.painterResource +import androidx.compose.ui.unit.dp -@OptIn(ExperimentalResourceApi::class) @Composable fun App() { MaterialTheme { - var greetingText by remember { mutableStateOf("Hello, World!") } - var showImage by remember { mutableStateOf(false) } - Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) { - Button(onClick = { - greetingText = "Hello, ${getPlatformName()}" - showImage = !showImage - }) { - Text(greetingText) + val runGame = remember { mutableStateOf(false) } + + if (!runGame.value) { + Column { + Spacer(modifier = Modifier.size(50.dp)) + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center, + modifier = Modifier.fillMaxWidth() + ) { + Button(onClick = { runGame.value = true }) { + Text(text = "Start Game") + } + } } - AnimatedVisibility(showImage) { - Image( - painterResource("compose-multiplatform.xml"), - null - ) + } else { + + val fieldPos = remember { mutableStateListOf() } + val selectedPos = remember { mutableStateOf(0) } + val houses = remember { mutableStateOf(0) } + val population = remember { mutableStateOf(0) } + val maxPopulation = remember { mutableStateOf(0) } + + if (fieldPos.size != 100) { + for (i in 0..99) { + fieldPos.add(i, Field(text = "x")) + } + } + + Column { + Row { + Text( + text = "Einwohneranzahl ${population.value} / ${maxPopulation.value}" + ) + } + + LazyVerticalGrid( + columns = GridCells.Fixed(10) + ) { + itemsIndexed(fieldPos) { field, item: Field -> + TextButton(onClick = { + fieldPos[field] = fieldPos[field].copy(text = "o") + selectedPos.value = field + }) { + Text(text = item.text) + } + } + } + + Row { + Button(onClick = { + fieldPos[selectedPos.value] = fieldPos[selectedPos.value].copy(text = "H", isBuild = true) + houses.value++ + maxPopulation.value = houses.value * 5 + }) { + Text("Haus") + } + } } } } diff --git a/shared/src/commonMain/kotlin/Field.kt b/shared/src/commonMain/kotlin/Field.kt new file mode 100644 index 0000000..931fc0d --- /dev/null +++ b/shared/src/commonMain/kotlin/Field.kt @@ -0,0 +1 @@ +data class Field(var isBuild: Boolean = false, var text: String = "x") \ No newline at end of file