Fix text styles and spacing now that includeFontPadding is false

Change-Id: I6894836a7cd3a6139511a5d1ac0a96702a265186
pull/1220/head
Don Turner 9 months ago
parent a507ff6d8e
commit 68c15a891c

@ -167,7 +167,7 @@ fun NiaNavigationRail(
@ThemePreviews
@Composable
fun NiaNavigationPreview() {
fun NiaNavigationBarPreview() {
val items = listOf("For you", "Saved", "Interests")
val icons = listOf(
NiaIcons.UpcomingBorder,
@ -205,6 +205,47 @@ fun NiaNavigationPreview() {
}
}
@ThemePreviews
@Composable
fun NiaNavigationRailPreview() {
val items = listOf("For you", "Saved", "Interests")
val icons = listOf(
NiaIcons.UpcomingBorder,
NiaIcons.BookmarksBorder,
NiaIcons.Grid3x3,
)
val selectedIcons = listOf(
NiaIcons.Upcoming,
NiaIcons.Bookmarks,
NiaIcons.Grid3x3,
)
NiaTheme {
NiaNavigationRail {
items.forEachIndexed { index, item ->
NiaNavigationRailItem(
icon = {
Icon(
imageVector = icons[index],
contentDescription = item,
)
},
selectedIcon = {
Icon(
imageVector = selectedIcons[index],
contentDescription = item,
)
},
label = { Text(item) },
selected = index == 0,
onClick = { },
)
}
}
}
}
/**
* Now in Android navigation default values.
*/

@ -34,6 +34,7 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@ -77,11 +78,13 @@ fun NiaTopAppBar(
@Preview("Top App Bar")
@Composable
private fun NiaTopAppBarPreview() {
NiaTopAppBar(
titleRes = android.R.string.untitled,
navigationIcon = NiaIcons.Search,
navigationIconContentDescription = "Navigation icon",
actionIcon = NiaIcons.MoreVert,
actionIconContentDescription = "Action icon",
)
NiaTheme {
NiaTopAppBar(
titleRes = android.R.string.untitled,
navigationIcon = NiaIcons.Search,
navigationIconContentDescription = "Navigation icon",
actionIcon = NiaIcons.MoreVert,
actionIconContentDescription = "Action icon",
)
}
}

@ -17,8 +17,14 @@
package com.google.samples.apps.nowinandroid.core.designsystem.theme
import androidx.compose.material3.Typography
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.LineHeightStyle
import androidx.compose.ui.text.style.LineHeightStyle.Alignment
import androidx.compose.ui.text.style.LineHeightStyle.Alignment.Companion
import androidx.compose.ui.text.style.LineHeightStyle.Trim
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.sp
/**
@ -60,12 +66,20 @@ internal val NiaTypography = Typography(
fontSize = 24.sp,
lineHeight = 32.sp,
letterSpacing = 0.sp,
lineHeightStyle = LineHeightStyle(
alignment = Alignment.Bottom,
trim = Trim.None
),
),
titleLarge = TextStyle(
fontWeight = FontWeight.Bold,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp,
lineHeightStyle = LineHeightStyle(
alignment = Alignment.Bottom,
trim = Trim.LastLineBottom
),
),
titleMedium = TextStyle(
fontWeight = FontWeight.Bold,
@ -84,6 +98,10 @@ internal val NiaTypography = Typography(
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp,
lineHeightStyle = LineHeightStyle(
alignment = Alignment.Bottom,
trim = Trim.Both
),
),
bodyMedium = TextStyle(
fontWeight = FontWeight.Normal,
@ -108,11 +126,19 @@ internal val NiaTypography = Typography(
fontSize = 12.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp,
lineHeightStyle = LineHeightStyle(
alignment = Alignment.Bottom,
trim = Trim.None
),
),
labelSmall = TextStyle(
fontWeight = FontWeight.Medium,
fontSize = 10.sp,
lineHeight = 16.sp,
lineHeight = 14.sp,
letterSpacing = 0.sp,
lineHeightStyle = LineHeightStyle(
alignment = Alignment.Bottom,
trim = Trim.Both
),
),
)

@ -25,6 +25,7 @@ import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.tooling.preview.Preview
import com.github.takahirom.roborazzi.captureRoboImage
import com.google.accompanist.testharness.TestHarness
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaNavigationBar
@ -83,25 +84,27 @@ class NavigationScreenshotTests() {
@Composable
private fun NiaNavigationBarExample(label: String = "Item") {
NiaNavigationBar {
(0..2).forEach { index ->
NiaNavigationBarItem(
icon = {
Icon(
imageVector = NiaIcons.UpcomingBorder,
contentDescription = "",
)
},
selectedIcon = {
Icon(
imageVector = NiaIcons.Upcoming,
contentDescription = "",
)
},
label = { Text(label) },
selected = index == 0,
onClick = { },
)
NiaTheme {
NiaNavigationBar {
(0..2).forEach { index ->
NiaNavigationBarItem(
icon = {
Icon(
imageVector = NiaIcons.UpcomingBorder,
contentDescription = "",
)
},
selectedIcon = {
Icon(
imageVector = NiaIcons.Upcoming,
contentDescription = "",
)
},
label = { Text(label) },
selected = index == 0,
onClick = { },
)
}
}
}
}

@ -121,7 +121,7 @@ fun NewsResourceCardExpanded(
Spacer(modifier = Modifier.weight(1f))
BookmarkButton(isBookmarked, onToggleBookmark)
}
Spacer(modifier = Modifier.height(12.dp))
Spacer(modifier = Modifier.height(14.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
if (!hasBeenViewed) {
NotificationDot(
@ -132,7 +132,7 @@ fun NewsResourceCardExpanded(
}
NewsResourceMetaData(userNewsResource.publishDate, userNewsResource.type)
}
Spacer(modifier = Modifier.height(12.dp))
Spacer(modifier = Modifier.height(14.dp))
NewsResourceShortDescription(userNewsResource.content)
Spacer(modifier = Modifier.height(12.dp))
NewsResourceTopics(

Loading…
Cancel
Save