diff --git a/shared/src/commonMain/kotlin/hr/bela/shared/ui/HomeScreen.kt b/shared/src/commonMain/kotlin/hr/bela/shared/ui/HomeScreen.kt index d6cfe81..ad4deb7 100644 --- a/shared/src/commonMain/kotlin/hr/bela/shared/ui/HomeScreen.kt +++ b/shared/src/commonMain/kotlin/hr/bela/shared/ui/HomeScreen.kt @@ -138,6 +138,8 @@ private fun WideHome( val platform = LocalPlatform.current BoxWithConstraints(Modifier.fillMaxSize().feltBackground().padding(horizontal = 56.dp, vertical = 32.dp)) { val logo = minOf(380.dp, maxHeight * 0.48f) + // As large as the window's height allows: a phone has to read it off a monitor. + val qr = (maxHeight - 462.dp).coerceIn(132.dp, 200.dp) Row( Modifier.align(Alignment.Center).widthIn(max = 1180.dp).fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, @@ -194,8 +196,8 @@ private fun WideHome( Rule() Spacer(Modifier.height(6.dp)) Row(verticalAlignment = Alignment.CenterVertically) { - QrCode(QrMatrix.LATEST_APK, Modifier.width(132.dp)) - Column(Modifier.padding(start = 18.dp)) { + QrCode(QrMatrix.LATEST_APK, Modifier.width(qr)) + Column(Modifier.padding(start = 16.dp)) { Overline("Android", color = Gold) Text( "Skeniraj kod mobitelom i igraj Belu i u aplikaciji.", diff --git a/shared/src/commonMain/kotlin/hr/bela/shared/ui/SettingsScreen.kt b/shared/src/commonMain/kotlin/hr/bela/shared/ui/SettingsScreen.kt index 3386317..0affad4 100644 --- a/shared/src/commonMain/kotlin/hr/bela/shared/ui/SettingsScreen.kt +++ b/shared/src/commonMain/kotlin/hr/bela/shared/ui/SettingsScreen.kt @@ -47,6 +47,7 @@ import hr.bela.shared.PlatformBackHandler import hr.bela.shared.res.Res import hr.bela.shared.res.logo import org.jetbrains.compose.resources.imageResource +import kotlin.math.floor /** * Settings: about the app, updating it ([updates]: the Android app's own section, none on the web) and a QR code @@ -220,12 +221,14 @@ fun QrCode(rows: List, modifier: Modifier = Modifier) { ) { Canvas(Modifier.fillMaxSize()) { val n = rows.size - val cell = size.width / n + // Whole pixels per module, so every module is sharp (a fractional size blurs the edges, which a phone + // camera reading a monitor struggles with). The few pixels left over widen the white margin. + val cell = floor(size.width / n).coerceAtLeast(1f) + val origin = floor((size.width - cell * n) / 2) for (y in 0 until n) { for (x in 0 until n) { if (rows[y][x] == '#') { - // Slight overlap so neighbouring modules join without hairline gaps. - drawRect(Color(0xFF14261C), topLeft = Offset(x * cell, y * cell), size = Size(cell + 0.6f, cell + 0.6f)) + drawRect(Color(0xFF14261C), topLeft = Offset(origin + x * cell, origin + y * cell), size = Size(cell, cell)) } } }