Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.loloof64.compose_chess_experiment.ui.screens.game
- import androidx.compose.foundation.layout.Arrangement
- import androidx.compose.foundation.layout.Column
- import androidx.compose.foundation.layout.padding
- import androidx.compose.material3.*
- import androidx.compose.runtime.Composable
- import androidx.compose.runtime.collectAsState
- import androidx.compose.ui.Alignment
- import androidx.compose.ui.Modifier
- import androidx.compose.ui.res.stringResource
- import androidx.lifecycle.viewmodel.compose.viewModel
- import com.loloof64.compose_chess_experiment.R
- import com.loloof64.compose_chess_experiment.ui.components.chess_board.ChessBoard
- @OptIn(ExperimentalMaterial3Api::class)
- @Composable
- fun GameScreen(
- viewModel: ChessGameViewModel = viewModel()
- ) {
- val state = viewModel.uiState.collectAsState()
- Scaffold(
- topBar = {
- TopAppBar(
- title = { Text(stringResource(id = R.string.game_page)) }
- )
- }
- ) {
- Column(
- modifier = Modifier.padding(it),
- horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.Center
- ) {
- Button(onClick = {
- viewModel.newGame()
- }) {
- Text(text = "New game")
- }
- ChessBoard(
- position = state.value.currentPosition
- )
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement