-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📸 Improved header on screenshots for Play Store
- Loading branch information
1 parent
ea6a9be
commit 476ef9a
Showing
2 changed files
with
62 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/main/java/com/lorenzovainigli/foodexpirationdates/view/preview/ScreenshotHeader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.lorenzovainigli.foodexpirationdates.view.preview | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringArrayResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.lorenzovainigli.foodexpirationdates.R | ||
|
||
@Composable | ||
fun ScreenshotHeader(text: String) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(100.dp), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.Center | ||
) { | ||
val fontSize = text.length.let { | ||
when { | ||
it > 50 -> 26.sp | ||
it > 40 -> 32.sp | ||
else -> 36.sp | ||
} | ||
} | ||
Text( | ||
modifier = Modifier.padding(6.dp), | ||
text = text, | ||
style = MaterialTheme.typography.headlineLarge, | ||
fontSize = fontSize, | ||
fontWeight = FontWeight(200), | ||
color = MaterialTheme.colorScheme.onPrimaryContainer, | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@LanguagePreviews | ||
@Composable | ||
fun ScreenshotHeaderPreview() { | ||
Column { | ||
stringArrayResource(id = R.array.screenshot_titles).forEach { | ||
Text(text = "Length = ${it.length}") | ||
ScreenshotHeader( | ||
text = "$it." | ||
) | ||
} | ||
} | ||
} |