Skip to content

Commit

Permalink
📸 Improved header on screenshots for Play Store
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzovngl committed Dec 26, 2023
1 parent ea6a9be commit 476ef9a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.absoluteOffset
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Alignment
Expand All @@ -24,8 +20,6 @@ import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
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.navigation.compose.rememberNavController
Expand Down Expand Up @@ -56,22 +50,7 @@ fun PlayStoreScreenshot(
)
)
) {
Column(
modifier = Modifier
.fillMaxWidth()
.height(100.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Text(
modifier = Modifier.padding(6.dp),
text = text,
style = MaterialTheme.typography.headlineLarge,
fontWeight = FontWeight(200),
color = MaterialTheme.colorScheme.onPrimaryContainer,
textAlign = TextAlign.Center
)
}
ScreenshotHeader(text = text)
Image(
modifier = Modifier
.padding(top = 100.dp, start = 6.dp, end = 6.dp, bottom = 6.dp)
Expand Down
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."
)
}
}
}

0 comments on commit 476ef9a

Please sign in to comment.