From c9c97c3a60e628ccd725d97c14b5cb86ce2a9dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20G=C3=B6r=C3=B6mbey?= Date: Sat, 14 Mar 2026 11:05:17 +0000 Subject: [PATCH 01/11] Navigation --- .../hu/mokegyesulet/it/dunestrat/navigation/NavGraph.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/navigation/NavGraph.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/navigation/NavGraph.kt index 3a2ba64..75dca91 100644 --- a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/navigation/NavGraph.kt +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/navigation/NavGraph.kt @@ -1,18 +1,21 @@ package hu.mokegyesulet.it.dunestrat.navigation import androidx.compose.runtime.Composable +import androidx.navigation.NavBackStackEntry import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController -import androidx.navigation.toRoute import hu.mokegyesulet.it.dunestrat.feature.init.InitScreen import hu.mokegyesulet.it.dunestrat.feature.mainmenu.MainMenu import hu.mokegyesulet.it.dunestrat.feature.playerstep.PlayerStepInputScreen import hu.mokegyesulet.it.dunestrat.feature.testdata.TestDataScreen @Composable -fun NavGraph(navController: NavHostController = rememberNavController()) { +fun NavGraph( + navController: NavHostController = rememberNavController(), + toRoute: NavBackStackEntry.() -> Screen.PlayerStepInput, +) { NavHost( navController = navController, startDestination = Screen.MainMenu, From a309dcb957a6aae870e6482d5c7745c7f1305893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1si=20M=C3=A1t=C3=A9?= Date: Fri, 23 Jan 2026 13:49:32 +0100 Subject: [PATCH 02/11] Basic UI and state dataclass for step creation --- .../entersteps/admin/EnterStepsAdminScreen.kt | 23 +++++++ .../admin/EnterStepsAdminViewModel.kt | 45 ++++++++++++++ .../it/dunestrat/ui/step/EnterStepsCard.kt | 61 +++++++++++++++++++ .../it/dunestrat/ui/step/StepCardState.kt | 22 +++++++ 4 files changed, 151 insertions(+) create mode 100644 composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/entersteps/admin/EnterStepsAdminScreen.kt create mode 100644 composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/entersteps/admin/EnterStepsAdminViewModel.kt create mode 100644 composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/ui/step/EnterStepsCard.kt create mode 100644 composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/ui/step/StepCardState.kt diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/entersteps/admin/EnterStepsAdminScreen.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/entersteps/admin/EnterStepsAdminScreen.kt new file mode 100644 index 0000000..a4f0bb1 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/entersteps/admin/EnterStepsAdminScreen.kt @@ -0,0 +1,23 @@ +package hu.mokegyesulet.it.dunestrat.feature.entersteps.admin + +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.lifecycle.viewmodel.compose.viewModel +import hu.mokegyesulet.it.dunestrat.model.Player +import hu.mokegyesulet.it.dunestrat.ui.step.EnterStepsCard + +@Composable +fun EnterStepsAdminScreen(players: List) { + val viewModel = viewModel { EnterStepsAdminViewModel(players) } + val steps = viewModel.stepStates.value + LazyColumn( + modifier = Modifier.fillMaxWidth(1f), + ) { + itemsIndexed(steps) { index, step -> + EnterStepsCard(step, viewModel.onStepCardStateChanged(index)) + } + } +} diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/entersteps/admin/EnterStepsAdminViewModel.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/entersteps/admin/EnterStepsAdminViewModel.kt new file mode 100644 index 0000000..e16a529 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/entersteps/admin/EnterStepsAdminViewModel.kt @@ -0,0 +1,45 @@ +package hu.mokegyesulet.it.dunestrat.feature.entersteps.admin + +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.mutableStateOf +import androidx.lifecycle.ViewModel +import hu.mokegyesulet.it.dunestrat.model.Player +import hu.mokegyesulet.it.dunestrat.ui.step.StepCardEvent +import hu.mokegyesulet.it.dunestrat.ui.step.StepCardState + +class EnterStepsAdminViewModel(players: List) : ViewModel() { + private val _stepStates: MutableList = ArrayList() + init { + for (p in players) { + _stepStates.add(StepCardState(p.id)) + } + } + val stepStates: MutableState> + get() = mutableStateOf(_stepStates) + + private fun onStepCardStateChanged( + event: StepCardEvent, + playerIndex: Int, + ) { + when (event) { + is StepCardEvent.EnterFieldsChanged -> _stepStates[playerIndex] = + _stepStates[playerIndex].copy(enterFields = event.enterFields) + + is StepCardEvent.LeaveFieldsChanged -> _stepStates[playerIndex] = + _stepStates[playerIndex].copy(leaveFields = event.leaveFields) + + is StepCardEvent.BuildHarvestersChanged -> _stepStates[playerIndex] = + _stepStates[playerIndex].copy(buildHarvesters = event.buildHarvesters) + + is StepCardEvent.PurchaseWeaponsChanged -> { + val x = _stepStates[playerIndex].purchaseWeapons.toMutableMap() + x[event.weaponType] = event.amount + _stepStates[playerIndex] = _stepStates[playerIndex].copy(purchaseWeapons = x) + } + } + } + + fun onStepCardStateChanged(playerIndex: Int): (StepCardEvent) -> Unit = { e -> + onStepCardStateChanged(e, playerIndex) + } +} diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/ui/step/EnterStepsCard.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/ui/step/EnterStepsCard.kt new file mode 100644 index 0000000..49a1ae5 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/ui/step/EnterStepsCard.kt @@ -0,0 +1,61 @@ +package hu.mokegyesulet.it.dunestrat.ui.step + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.material3.Card +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.runtime.Composable +import hu.mokegyesulet.it.dunestrat.model.Weapon + +@Composable +fun EnterStepsCard( + stepCardState: StepCardState, + onStepCardStateChanged: (StepCardEvent) -> Unit, +) { + Card { + Column { + Text("Player: ${stepCardState.playerId}") + Row { + Text("Lelép:") + TextField( + value = stepCardState.leaveFields, + onValueChange = { + onStepCardStateChanged(StepCardEvent.LeaveFieldsChanged(it)) + }, + ) + } + Row { + Text("Rálép:") + TextField( + value = stepCardState.enterFields, + onValueChange = { + onStepCardStateChanged(StepCardEvent.EnterFieldsChanged(it)) + }, + ) + } + Row { + Text("Fegyver:") + for (w in Weapon.entries) { + TextField( + value = stepCardState.purchaseWeapons[w].toString(), + onValueChange = { + onStepCardStateChanged( + StepCardEvent.PurchaseWeaponsChanged(w, it.toInt()), + ) + }, + ) + } + } + Row { + Text("Harvester:") + TextField( + value = stepCardState.buildHarvesters, + onValueChange = { + onStepCardStateChanged(StepCardEvent.BuildHarvestersChanged(it)) + }, + ) + } + } + } +} diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/ui/step/StepCardState.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/ui/step/StepCardState.kt new file mode 100644 index 0000000..cd26703 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/ui/step/StepCardState.kt @@ -0,0 +1,22 @@ +package hu.mokegyesulet.it.dunestrat.ui.step + +import hu.mokegyesulet.it.dunestrat.model.Weapon + +data class StepCardState( + val playerId: String, + val leaveFields: String = "", + val enterFields: String = "", + val purchaseWeapons: Map = mapOf( + Weapon.LASGUN to 0, + Weapon.PISTOL to 0, + Weapon.CRYSKNIFE to 0, + Weapon.LEGION to 0, + ), + val buildHarvesters: String = "", +) +sealed class StepCardEvent { + class LeaveFieldsChanged(val leaveFields: String) : StepCardEvent() + class EnterFieldsChanged(val enterFields: String) : StepCardEvent() + class PurchaseWeaponsChanged(val weaponType: Weapon, val amount: Int) : StepCardEvent() + class BuildHarvestersChanged(val buildHarvesters: String) : StepCardEvent() +} From 3cd7a4b497948179513f125319e7668c186377e7 Mon Sep 17 00:00:00 2001 From: cstomi74 Date: Wed, 25 Feb 2026 19:13:50 +0100 Subject: [PATCH 03/11] =?UTF-8?q?A=20main=20menu=20alapvet=C5=91en=20szeri?= =?UTF-8?q?ntem=20el=20van=20rendezve,=20mag=C3=A1n=20a=20kin=C3=A9zet?= =?UTF-8?q?=C3=A9n=20kell=20m=C3=A9g=20csiszolni=20b=C5=91ven,=20illetve?= =?UTF-8?q?=20a=20grid=20a=20k=C3=B6zep=C3=A9n=20csak=20egy=20placeholder,?= =?UTF-8?q?=20oda=20m=C3=A9g=20be=20kell=20=C3=BCgyeskedni=20az=20aktu?= =?UTF-8?q?=C3=A1lis=20game=20statet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/artifacts/composeApp_js.xml | 8 + .idea/artifacts/composeApp_jvm.xml | 8 + .idea/artifacts/composeApp_wasm_js.xml | 8 + .idea/gradle.xml | 18 ++ .../it/dunestrat/feature/mainmenu/MainMenu.kt | 156 +++++++++++++----- .../feature/mainmenu/MainMenuViewModel.kt | 12 ++ .../it/dunestrat/navigation/NavGraph.kt | 5 +- 7 files changed, 175 insertions(+), 40 deletions(-) create mode 100644 .idea/artifacts/composeApp_js.xml create mode 100644 .idea/artifacts/composeApp_jvm.xml create mode 100644 .idea/artifacts/composeApp_wasm_js.xml create mode 100644 .idea/gradle.xml diff --git a/.idea/artifacts/composeApp_js.xml b/.idea/artifacts/composeApp_js.xml new file mode 100644 index 0000000..e52ad0e --- /dev/null +++ b/.idea/artifacts/composeApp_js.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/composeApp/build/libs + + + + + \ No newline at end of file diff --git a/.idea/artifacts/composeApp_jvm.xml b/.idea/artifacts/composeApp_jvm.xml new file mode 100644 index 0000000..96d842a --- /dev/null +++ b/.idea/artifacts/composeApp_jvm.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/composeApp/build/libs + + + + + \ No newline at end of file diff --git a/.idea/artifacts/composeApp_wasm_js.xml b/.idea/artifacts/composeApp_wasm_js.xml new file mode 100644 index 0000000..e3c9c59 --- /dev/null +++ b/.idea/artifacts/composeApp_wasm_js.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/composeApp/build/libs + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..2fa8368 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt index 0787087..c02a101 100644 --- a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt @@ -1,66 +1,148 @@ package hu.mokegyesulet.it.dunestrat.feature.mainmenu -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material3.Button -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.material3.* +import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel +import dune_strat.composeapp.generated.resources.Res +import dune_strat.composeapp.generated.resources.grid +import org.jetbrains.compose.resources.painterResource +@OptIn(ExperimentalMaterial3Api::class) @Composable fun MainMenu( - onPlayerStepInput: () -> Unit, - onPlaceholder2: () -> Unit, - onTestData: () -> Unit, + onInputMoves: () -> Unit, + onStat: () -> Unit, ) { - val viewModel: MainMenuViewModel = viewModel { MainMenuViewModel() } - val loggedIn by viewModel.isLoggedIn.collectAsState(initial = false) - val deserts by viewModel.deserts.collectAsState(initial = emptyList()) - if (loggedIn) { + val viewModel = viewModel { MainMenuViewModel() } + val gameCount by viewModel.gameCount + val games by viewModel.games.collectAsState(emptyList()) + var showMenu by remember { mutableStateOf(false) } + var isExpanded by remember { mutableStateOf(false) } + var gameOpened by remember { mutableStateOf("") } + Row { Column( - modifier = Modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.SpaceEvenly, + Modifier.padding(10.dp), ) { Button( - onClick = onPlayerStepInput, - ) { - Text(text = "Player step input") - } + onClick = { viewModel.onEvent(MainMenuViewModel.Event.CreateGame) }, + modifier = Modifier.width(240.dp) + .height(60.dp), - Button( - onClick = {}, ) { - Text(text = "Placeholder 2") + Text(text = "Új játék") } + Text(text = "Létrehozott játékok száma: $gameCount") + // Text(text = "Adatok: ${SupabaseRepository.getGames()}") - Button( - onClick = onTestData, + ExposedDropdownMenuBox( + expanded = isExpanded, + onExpandedChange = { isExpanded = it }, ) { - Text(text = "Test data") + TextField( + label = { Text("Játék kiválasztása") }, + value = gameOpened, + onValueChange = {}, + readOnly = true, + trailingIcon = { + ExposedDropdownMenuDefaults.TrailingIcon(expanded = isExpanded) + }, + colors = ExposedDropdownMenuDefaults.textFieldColors(), + modifier = Modifier.menuAnchor(), + + ) + ExposedDropdownMenu( + expanded = isExpanded, + onDismissRequest = { isExpanded = false }, + + ) { + DropdownMenuItem( + text = { Text(text = "Játék 1") }, + onClick = { + isExpanded = false + gameOpened = "Játék 1" + }, + ) + DropdownMenuItem( + text = { Text(text = "Játék 2") }, + onClick = { + isExpanded = false + gameOpened = "Játék 2" + }, + ) + DropdownMenuItem( + text = { Text(text = "Játék 3") }, + onClick = { + isExpanded = false + gameOpened = "Játék 3" + }, + ) + } } + } - Button( - onClick = viewModel::onLogout, + Column( + Modifier.weight(1f) + .fillMaxSize() + .padding(5.dp), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Bottom, + + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center, ) { - Text(text = "Log out") + Image( + painter = painterResource(Res.drawable.grid), + contentDescription = null, + modifier = Modifier.background(Color.Yellow) + .size(width = 600.dp, height = 600.dp), + + ) } } - } else { + Column( - modifier = Modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center, + modifier = Modifier + .wrapContentWidth() + .fillMaxHeight(), + verticalArrangement = Arrangement.Top, + horizontalAlignment = Alignment.End, + ) { Button( - onClick = viewModel::onLogin, + onClick = onInputMoves, + modifier = Modifier.padding(10.dp) + .width(200.dp) + .height(50.dp), + ) { + Text(text = "Lépések felvétele") + } + Text( + text = "Statisztikák: ", + textAlign = TextAlign.Left, + modifier = Modifier.width(200.dp), + + ) + + Spacer( + modifier = Modifier.height(8.dp) + .weight(10f), + ) + + Button( + onClick = onStat, + modifier = Modifier.padding(10.dp), ) { - Text(text = "Log in") + Text(text = "STAT") } } } diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenuViewModel.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenuViewModel.kt index 242159e..fe6648f 100644 --- a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenuViewModel.kt +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenuViewModel.kt @@ -1,5 +1,6 @@ package hu.mokegyesulet.it.dunestrat.feature.mainmenu +import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import hu.mokegyesulet.it.dunestrat.backend.AuthStatus @@ -29,4 +30,15 @@ class MainMenuViewModel : ViewModel() { get() = SupabaseAuth.authStatus.map { it is AuthStatus.Authenticated } + + val gameCount = mutableStateOf(0) + val games = SupabaseRepository.getGames() + sealed class Event() { + data object CreateGame : Event() + } + fun onEvent(event: Event) { + when (event) { + is Event.CreateGame -> gameCount.value += 1 + } + } } diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/navigation/NavGraph.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/navigation/NavGraph.kt index 75dca91..de6a47f 100644 --- a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/navigation/NavGraph.kt +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/navigation/NavGraph.kt @@ -22,9 +22,8 @@ fun NavGraph( ) { composable { MainMenu( - onPlayerStepInput = { navController.navigate(Screen.PlayerStepInput(32)) }, - onPlaceholder2 = {}, - onTestData = { navController.navigate(Screen.TestData) }, + onInputMoves = {}, + onStat = {}, ) } From d66ce8eb3070d948b2ebb7c70f8aef09b8d00cf6 Mon Sep 17 00:00:00 2001 From: cstomi74 Date: Sun, 1 Mar 2026 16:44:00 +0100 Subject: [PATCH 04/11] =?UTF-8?q?A=20statisztik=C3=A1kon=20k=C3=ADv=C3=BCl?= =?UTF-8?q?=20minden=20el=20van=20rendezve=20a=20k=C3=A9perny=C5=91n,=20?= =?UTF-8?q?=C3=A9s=20ebben=20az=20=C3=A1llapotban=20nem=20vinnyog=20semmi?= =?UTF-8?q?=C3=A9rt=20az=20IntelliJ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt index c02a101..b9e5584 100644 --- a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt @@ -40,7 +40,6 @@ fun MainMenu( Text(text = "Új játék") } Text(text = "Létrehozott játékok száma: $gameCount") - // Text(text = "Adatok: ${SupabaseRepository.getGames()}") ExposedDropdownMenuBox( expanded = isExpanded, @@ -55,7 +54,10 @@ fun MainMenu( ExposedDropdownMenuDefaults.TrailingIcon(expanded = isExpanded) }, colors = ExposedDropdownMenuDefaults.textFieldColors(), - modifier = Modifier.menuAnchor(), + // modifier = Modifier.menuAnchor(), + modifier = Modifier.menuAnchor( + ExposedDropdownMenuAnchorType.PrimaryNotEditable, + ), ) ExposedDropdownMenu( From 9bcfff5582b1cc52f2fcf9192bdd99a2e71420da Mon Sep 17 00:00:00 2001 From: cstomi74 Date: Sun, 8 Mar 2026 16:51:07 +0100 Subject: [PATCH 05/11] =?UTF-8?q?Mam=C3=A1si=20machin=C3=A1ci=C3=B3=20ut?= =?UTF-8?q?=C3=A1n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../it/dunestrat/feature/mainmenu/MainMenu.kt | 33 ++++++------------- .../feature/mainmenu/MainMenuViewModel.kt | 25 +++++++++++++- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt index b9e5584..dfbda7c 100644 --- a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenu.kt @@ -54,7 +54,6 @@ fun MainMenu( ExposedDropdownMenuDefaults.TrailingIcon(expanded = isExpanded) }, colors = ExposedDropdownMenuDefaults.textFieldColors(), - // modifier = Modifier.menuAnchor(), modifier = Modifier.menuAnchor( ExposedDropdownMenuAnchorType.PrimaryNotEditable, ), @@ -62,30 +61,18 @@ fun MainMenu( ) ExposedDropdownMenu( expanded = isExpanded, - onDismissRequest = { isExpanded = false }, + onDismissRequest = { viewModel.onEvent(MainMenuViewModel.Event.ExpandMenu) }, ) { - DropdownMenuItem( - text = { Text(text = "Játék 1") }, - onClick = { - isExpanded = false - gameOpened = "Játék 1" - }, - ) - DropdownMenuItem( - text = { Text(text = "Játék 2") }, - onClick = { - isExpanded = false - gameOpened = "Játék 2" - }, - ) - DropdownMenuItem( - text = { Text(text = "Játék 3") }, - onClick = { - isExpanded = false - gameOpened = "Játék 3" - }, - ) + for (g in games) { + DropdownMenuItem( + text = { Text(text = g.name) }, + onClick = { + viewModel.onEvent(MainMenuViewModel.Event.ExpandMenu) + viewModel.onEvent(MainMenuViewModel.Event.SelectGame(g)) + }, + ) + } } } } diff --git a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenuViewModel.kt b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenuViewModel.kt index fe6648f..10c24ff 100644 --- a/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenuViewModel.kt +++ b/composeApp/src/commonMain/kotlin/hu/mokegyesulet/it/dunestrat/feature/mainmenu/MainMenuViewModel.kt @@ -6,8 +6,15 @@ import androidx.lifecycle.viewModelScope import hu.mokegyesulet.it.dunestrat.backend.AuthStatus import hu.mokegyesulet.it.dunestrat.backend.SupabaseAuth import hu.mokegyesulet.it.dunestrat.backend.SupabaseRepository +import hu.mokegyesulet.it.dunestrat.backend.SupabaseRepository.supabase +import hu.mokegyesulet.it.dunestrat.backend.entities.GameStateDatabaseEntity +import hu.mokegyesulet.it.dunestrat.model.Game +import io.github.jan.supabase.postgrest.from +import io.github.jan.supabase.realtime.selectAsFlow import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch class MainMenuViewModel : ViewModel() { @@ -32,13 +39,29 @@ class MainMenuViewModel : ViewModel() { } val gameCount = mutableStateOf(0) - val games = SupabaseRepository.getGames() + val games = SupabaseRepository.getGames().stateIn( + viewModelScope, + SharingStarted.Eagerly, + emptyList(), + ) + val isExpanded = mutableStateOf(false) + + val waterAmount = SupabaseRepository.getLatestGameStateByGameId().stateIn( + viewModelScope, + SharingStarted.Eagerly, + initialValue = emptyList(), + ) + sealed class Event() { data object CreateGame : Event() + data object ExpandMenu : Event() + data class SelectGame(val game: Game) : Event() } fun onEvent(event: Event) { when (event) { is Event.CreateGame -> gameCount.value += 1 + is Event.ExpandMenu -> TODO() + is Event.SelectGame -> TODO() } } } From 1e4bf9b54db9246f480b129355cfe21a0314840f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20G=C3=B6r=C3=B6mbey?= Date: Sun, 14 Jun 2026 17:53:43 +0200 Subject: [PATCH 06/11] =?UTF-8?q?Laci=20machin=C3=A1ci=C3=B3i?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/gradle.xml | 2 +- .../it/dunestrat/feature/mainmenu/MainMenu.kt | 16 +++++++++------- .../feature/mainmenu/MainMenuViewModel.kt | 14 +++++--------- .../it/dunestrat/navigation/NavGraph.kt | 7 ++----- .../it/dunestrat/ui/step/StepCardState.kt | 2 +- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 2fa8368..cebe225 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -5,7 +5,7 @@