Skip to content

Commit f201c4a

Browse files
committed
Enable screen dimens from args
1 parent 7894de4 commit f201c4a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

desktop/src/main/kotlin/com/jdamcd/arrivals/desktop/ArrivalsView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private fun Data(state: ArrivalsState.Data, onClickRefresh: () -> Unit) {
6666
Column {
6767
Column(
6868
modifier = Modifier
69-
.padding(top = 32.dp, bottom = 20.dp, start = 32.dp, end = 32.dp)
69+
.padding(top = 20.dp, bottom = 8.dp, start = 32.dp, end = 32.dp)
7070
.weight(1f)
7171
.fillMaxWidth(),
7272
verticalArrangement = Arrangement.SpaceEvenly

desktop/src/main/kotlin/com/jdamcd/arrivals/desktop/Main.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package com.jdamcd.arrivals.desktop
22

33
import androidx.compose.runtime.collectAsState
44
import androidx.compose.runtime.getValue
5+
import androidx.compose.ui.Alignment
56
import androidx.compose.ui.input.key.Key
67
import androidx.compose.ui.input.key.key
78
import androidx.compose.ui.unit.DpSize
89
import androidx.compose.ui.unit.dp
910
import androidx.compose.ui.window.Window
10-
import androidx.compose.ui.window.WindowPlacement
11+
import androidx.compose.ui.window.WindowPosition
1112
import androidx.compose.ui.window.application
1213
import androidx.compose.ui.window.rememberWindowState
1314
import com.jdamcd.arrivals.Arrivals
@@ -18,10 +19,12 @@ private val koin = initKoin().koin
1819

1920
fun main(args: Array<String>) = application {
2021
val fixWindow = args.contains("-pi")
22+
val width = dimenFromArg(args, 1) ?: 1280
23+
val height = dimenFromArg(args, 2) ?: 400
2124

2225
val windowState = rememberWindowState(
23-
placement = if (fixWindow) WindowPlacement.Maximized else WindowPlacement.Floating,
24-
size = DpSize(1280.dp, 400.dp)
26+
position = WindowPosition(Alignment.Center),
27+
size = DpSize(width.dp, height.dp)
2528
)
2629

2730
val viewModel = ArrivalsViewModel(koin.get<Arrivals>())
@@ -43,3 +46,5 @@ fun main(args: Array<String>) = application {
4346
ArrivalsView(state, viewModel::refresh)
4447
}
4548
}
49+
50+
private fun dimenFromArg(args: Array<String>, index: Int): Int? = if (args.size > index) args[index].toIntOrNull() else null

0 commit comments

Comments
 (0)