Skip to content

Commit 7d5906f

Browse files
committed
Update space between image and texts to be 12.dp and one between texts to 4.dp
1 parent ec138d7 commit 7d5906f

File tree

1 file changed

+20
-13
lines changed
  • samples/user-interface/appwidgets/src/main/java/com/example/platform/ui/appwidgets/glance/layout/text/layout

1 file changed

+20
-13
lines changed

samples/user-interface/appwidgets/src/main/java/com/example/platform/ui/appwidgets/glance/layout/text/layout/TextWithImageLayout.kt

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.example.platform.ui.appwidgets.glance.layout.collections.layout.NoDat
4040
import com.example.platform.ui.appwidgets.glance.layout.text.layout.TextWithImageLayoutDimensions.contentSize
4141
import com.example.platform.ui.appwidgets.glance.layout.text.layout.TextWithImageLayoutDimensions.contentSpacing
4242
import com.example.platform.ui.appwidgets.glance.layout.text.layout.TextWithImageLayoutDimensions.pictureRadius
43+
import com.example.platform.ui.appwidgets.glance.layout.text.layout.TextWithImageLayoutDimensions.verticalTextsSpacing
4344
import com.example.platform.ui.appwidgets.glance.layout.text.layout.TextWithImageLayoutDimensions.widgetPadding
4445
import com.example.platform.ui.appwidgets.glance.layout.text.layout.TextWithImageLayoutSize.HorizontalLarge
4546
import com.example.platform.ui.appwidgets.glance.layout.text.layout.TextWithImageLayoutSize.HorizontalSmall
@@ -178,7 +179,7 @@ private fun HorizontalContent(data: TextWithImageData, showImage: Boolean) {
178179
// Use 40% of available width for text area if showing image on side.
179180
width = (0.4 * contentWidth).takeIf { showImage } ?: contentWidth,
180181
// Use 80% of vertical space for text area.
181-
height = 0.80 * (contentSize.height - contentSpacing)
182+
height = 0.80 * (contentSize.height - (2 * verticalTextsSpacing))
182183
)
183184
)
184185
if (showImage) {
@@ -201,8 +202,8 @@ private fun VerticalContent(
201202
verticalAlignment = Alignment.Vertical.Bottom,
202203
modifier = GlanceModifier.fillMaxHeight()
203204
) {
204-
val contentWidth = contentSize.width - contentSpacing
205-
val contentHeight = contentSize.height - (2 * contentSpacing)
205+
val contentWidth = contentSize.width
206+
val contentHeight = contentSize.height - (2 * verticalTextsSpacing)
206207

207208
if (showImage) {
208209
Image(
@@ -216,8 +217,8 @@ private fun VerticalContent(
216217
showSecondaryText = showSecondaryText,
217218
modifier = GlanceModifier.fillMaxWidth(),
218219
availableSize = DpSize(
219-
// Use 90% of available width to leave some offset for word break differences.
220-
width = 0.9 * contentWidth,
220+
// Use 80% of available width to leave some offset for word break differences.
221+
width = 0.8 * contentWidth,
221222
// Use 40% vertical space for text area if showing image
222223
height = (0.4 * contentHeight).takeIf { showImage } ?: contentHeight
223224
)
@@ -248,7 +249,7 @@ private fun TextStack(
248249
style = TextWithImageLayoutTextStyles.caption,
249250
modifier = GlanceModifier.fillMaxWidth()
250251
)
251-
Spacer(modifier = GlanceModifier.height(contentSpacing / 2))
252+
Spacer(modifier = GlanceModifier.height(verticalTextsSpacing))
252253
Text(
253254
text = data.primary,
254255
maxLines = primaryTextMaxLines,
@@ -260,7 +261,7 @@ private fun TextStack(
260261
availableSize = availableSize
261262
)
262263

263-
Spacer(modifier = GlanceModifier.height(contentSpacing / 2))
264+
Spacer(modifier = GlanceModifier.height(verticalTextsSpacing))
264265
Text(
265266
text = data.secondary,
266267
maxLines = secondaryTextMaxLines,
@@ -372,7 +373,8 @@ private enum class TextWithImageLayoutSize {
372373
}
373374
}
374375

375-
fun showTitleBar() = this != HorizontalSmall && this != VerticalSmall
376+
@Composable
377+
fun showTitleBar() = LocalSize.current.height >= 180.dp
376378
}
377379

378380

@@ -436,11 +438,16 @@ private object TextWithImageLayoutDimensions {
436438
/** Corner radius to be applied to an image. */
437439
val pictureRadius = 16.dp
438440

439-
/**
440-
* Space between larger building blocks within the layout. e.g space between text stack and
441-
* the image.
442-
*/
443-
val contentSpacing = 4.dp
441+
/**
442+
* Space between larger building blocks within the layout. e.g space between text stack and
443+
* the image.
444+
*/
445+
val contentSpacing = 12.dp
446+
447+
/**
448+
* Vertical spacing between text items
449+
*/
450+
val verticalTextsSpacing = 4.dp
444451

445452
/** Height of the title bar. */
446453
private val titleBarHeight: Dp

0 commit comments

Comments
 (0)