The desktop home screen showed the 53-module code at 132 dp, about two blurred pixels per module. It now takes up to 200 dp when the window is tall enough, and every QR code draws its modules in whole pixels so the edges stay sharp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e1a84f6b70
commit
ca87d53632
2 files changed
+10
-5
No files matched your search
@@ -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.",
|
||||
|
||||
@@ -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<String>, 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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user