Skip to content

Commit

Permalink
App window is resizable (partially implements #18)
Browse files Browse the repository at this point in the history
Remains:
- min size
- responsive grid
- responsive alphabet
  • Loading branch information
opatry committed Jan 15, 2022
1 parent de22f21 commit 7c3adc3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -146,6 +147,7 @@ fun GameScreen(settings: Settings, viewModel: WordleViewModel) {
Column(
Modifier
.fillMaxWidth()
.padding(bottom = 8.dp)
.focusRequester(focusRequester)
.focusable(true)
.onKeyEvent { event ->
Expand Down Expand Up @@ -174,8 +176,13 @@ fun GameScreen(settings: Settings, viewModel: WordleViewModel) {
onSettingsClick = { showSettings = true }
)
Divider()

AnswerPlaceHolder(viewModel.answer, viewModel::restart)

WordleGrid(viewModel.grid)

Spacer(Modifier.weight(1f))

Alphabet(viewModel.alphabet, enabled = actionsEnabled) { key ->
handleKey(viewModel, key)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ package net.opatry.game.wordle.ui.compose
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.loadImageBitmap
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.useResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.WindowState
import androidx.compose.ui.window.singleWindowApplication
import net.opatry.game.wordle.ui.compose.theme.AppIcon
Expand Down Expand Up @@ -59,9 +61,18 @@ object DesktopIconProvider : IconProvider {
fun main() {
singleWindowApplication(
title = "Wordle Compose",
icon = BitmapPainter(useResource("/icon.png", ::loadImageBitmap)),
state = WindowState(width = 500.dp, height = 700.dp),
resizable = false,
// FIXME can't make iconFile work
// Icon in the titlebar of the window (for platforms which support this).
// On macOS individual windows can't have a separate icon.
// To change the icon in the Dock, set it via `iconFile` in `build.gradle`
icon = BitmapPainter(useResource("icon.png", ::loadImageBitmap)),
state = WindowState(
position = WindowPosition(Alignment.Center),
width = 500.dp,
height = 700.dp
),
// TODO how to restrict to a minimum width & height (500x700?)
resizable = true,
) {
CompositionLocalProvider(LocalIconProvider provides DesktopIconProvider) {
WordleApp()
Expand Down

0 comments on commit 7c3adc3

Please sign in to comment.