Advertisement
Artyom_Kopan

view/View.kt

May 30th, 2022
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.10 KB | None | 0 0
  1. package view
  2.  
  3. import Screen
  4. import ViewModel
  5. import androidx.compose.foundation.layout.Column
  6. import androidx.compose.material.MaterialTheme
  7. import androidx.compose.runtime.Composable
  8.  
  9. @Suppress("FunctionNaming")
  10. @Composable
  11. fun View(viewModel: ViewModel) {
  12.     val state = viewModel.state
  13.  
  14.     Column {
  15.         MaterialTheme {
  16.             when (state.screen) {
  17.                 Screen.START_GAME -> {
  18.                     StartGame(viewModel::onStartGame)
  19.                 }
  20.                 Screen.MODE_CHOICE -> {
  21.                     GameModeChoice(viewModel::onChoiceSingleMode, viewModel::onChoiceBotMode)
  22.                 }
  23.                 Screen.SIDE_CHOICE -> {
  24.                     SideChoice(viewModel::onChoiceCrosses, viewModel::onChoiceNoughts)
  25.                 }
  26.                 Screen.GAME_FIELD -> {
  27.                     ButtonsList(
  28.                         state,
  29.                         viewModel::onButtonSelect
  30.                     )
  31.                 }
  32.                 Screen.END_GAME -> {
  33.                     EndGame(state)
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement