@@ -62,7 +62,6 @@ import androidx.compose.ui.text.PlaceholderVerticalAlign
6262import androidx.compose.ui.text.SpanStyle
6363import androidx.compose.ui.text.buildAnnotatedString
6464import androidx.compose.ui.text.font.FontWeight
65- import androidx.compose.ui.text.style.TextAlign
6665import androidx.compose.ui.text.style.TextDecoration
6766import androidx.compose.ui.text.withStyle
6867import androidx.compose.ui.tooling.preview.Preview
@@ -80,6 +79,7 @@ import org.schabi.newpipe.ui.theme.AppTheme
8079import org.schabi.newpipe.ui.theme.customColors
8180import org.schabi.newpipe.util.Either
8281import org.schabi.newpipe.util.Localization
82+ import org.schabi.newpipe.util.text.FixedHeightCenteredText
8383import org.schabi.newpipe.util.text.fadedMarquee
8484import java.time.OffsetDateTime
8585
@@ -112,6 +112,8 @@ fun getLongPressMenuView(
112112 }
113113}
114114
115+ internal val MinButtonWidth = 86 .dp
116+
115117@Composable
116118fun LongPressMenu (
117119 longPressable : LongPressable ,
@@ -130,10 +132,9 @@ fun LongPressMenu(
130132 .fillMaxWidth()
131133 .padding(start = 6 .dp, end = 6 .dp, bottom = 16 .dp)
132134 ) {
133- val minButtonWidth = 86 .dp
134- val buttonHeight = 86 .dp
135+ val buttonHeight = MinButtonWidth // landscape aspect ratio, square in the limit
135136 val headerWidthInButtons = 5 // the header is 5 times as wide as the buttons
136- val buttonsPerRow = (this .maxWidth / minButtonWidth ).toInt()
137+ val buttonsPerRow = (this .maxWidth / MinButtonWidth ).toInt()
137138
138139 // the channel icon goes in the menu header, so do not show a button for it
139140 val actions = longPressActions.toMutableList()
@@ -498,22 +499,11 @@ fun LongPressMenuButton(
498499 contentDescription = null ,
499500 modifier = Modifier .size(32 .dp),
500501 )
501- Box {
502- // this allows making the box always the same height (i.e. the height of two text
503- // lines), while making the text appear centered if it is just a single line
504- Text (
505- text = " " ,
506- style = MaterialTheme .typography.bodySmall,
507- minLines = 2 ,
508- )
509- Text (
510- text = text,
511- style = MaterialTheme .typography.bodySmall,
512- maxLines = 2 ,
513- textAlign = TextAlign .Center ,
514- modifier = Modifier .align(Alignment .Center )
515- )
516- }
502+ FixedHeightCenteredText (
503+ text = text,
504+ lines = 2 ,
505+ style = MaterialTheme .typography.bodySmall,
506+ )
517507 }
518508 }
519509}
0 commit comments