@@ -349,55 +349,25 @@ private fun TabBaselineLayout(
349
349
firstBaseline = firstBaseline!! ,
350
350
lastBaseline = lastBaseline!!
351
351
)
352
- textPlaceable != null -> placeText(
353
- density = this @Layout,
354
- textPlaceable = textPlaceable,
355
- tabHeight = tabHeight,
356
- firstBaseline = firstBaseline!! ,
357
- lastBaseline = lastBaseline!!
358
- )
359
- iconPlaceable != null -> placeIcon(iconPlaceable, tabHeight)
360
- else -> {}
352
+ textPlaceable != null -> placeTextOrIcon(textPlaceable, tabHeight)
353
+ iconPlaceable != null -> placeTextOrIcon(iconPlaceable, tabHeight)
354
+ else -> {
355
+ }
361
356
}
362
357
}
363
358
}
364
359
}
365
360
366
361
/* *
367
- * Places the provided [iconPlaceable] in the vertical center of the provided [tabHeight].
362
+ * Places the provided [textOrIconPlaceable] in the vertical center of the provided
363
+ * [tabHeight].
368
364
*/
369
- private fun Placeable.PlacementScope.placeIcon (
370
- iconPlaceable : Placeable ,
365
+ private fun Placeable.PlacementScope.placeTextOrIcon (
366
+ textOrIconPlaceable : Placeable ,
371
367
tabHeight : Int
372
368
) {
373
- val iconY = (tabHeight - iconPlaceable.height) / 2
374
- iconPlaceable.placeRelative(0 , iconY)
375
- }
376
-
377
- /* *
378
- * Places the provided [textPlaceable] offset from the bottom of the tab using the correct
379
- * baseline offset.
380
- */
381
- private fun Placeable.PlacementScope.placeText (
382
- density : Density ,
383
- textPlaceable : Placeable ,
384
- tabHeight : Int ,
385
- firstBaseline : Int ,
386
- lastBaseline : Int
387
- ) {
388
- val baselineOffset = if (firstBaseline == lastBaseline) {
389
- SingleLineTextBaseline
390
- } else {
391
- DoubleLineTextBaseline
392
- }
393
-
394
- // Total offset between the last text baseline and the bottom of the Tab layout
395
- val totalOffset = with (density) {
396
- baselineOffset.roundToPx() + TabRowDefaults .IndicatorHeight .roundToPx()
397
- }
398
-
399
- val textPlaceableY = tabHeight - lastBaseline - totalOffset
400
- textPlaceable.placeRelative(0 , textPlaceableY)
369
+ val contentY = (tabHeight - textOrIconPlaceable.height) / 2
370
+ textOrIconPlaceable.placeRelative(0 , contentY)
401
371
}
402
372
403
373
/* *
@@ -452,14 +422,10 @@ private const val TabFadeOutAnimationDuration = 100
452
422
// The horizontal padding on the left and right of text
453
423
private val HorizontalTextPadding = 16 .dp
454
424
455
- // Distance from the top of the indicator to the text baseline when there is one line of text
456
- private val SingleLineTextBaseline = 18 .dp
457
425
// Distance from the top of the indicator to the text baseline when there is one line of text and an
458
426
// icon
459
427
private val SingleLineTextBaselineWithIcon = 14 .dp
460
428
// Distance from the top of the indicator to the last text baseline when there are two lines of text
461
- private val DoubleLineTextBaseline = 10 .dp
462
- // Distance from the top of the indicator to the last text baseline when there are two lines of text
463
429
// and an icon
464
430
private val DoubleLineTextBaselineWithIcon = 6 .dp
465
431
// Distance from the first text baseline to the bottom of the icon in a combined tab
0 commit comments