@@ -31,14 +31,13 @@ import androidx.compose.material.icons.filled.OpenInBrowser
3131import androidx.compose.material.icons.filled.Person
3232import androidx.compose.material.icons.filled.PictureInPicture
3333import androidx.compose.material.icons.filled.PlayArrow
34- import androidx.compose.material.icons.filled.PlaylistAdd
3534import androidx.compose.material.icons.filled.QueuePlayNext
3635import androidx.compose.material.icons.filled.Share
3736import androidx.compose.material3.ExperimentalMaterial3Api
38- import androidx.compose.material3.FilledTonalButton
3937import androidx.compose.material3.Icon
4038import androidx.compose.material3.MaterialTheme
4139import androidx.compose.material3.ModalBottomSheet
40+ import androidx.compose.material3.OutlinedButton
4241import androidx.compose.material3.SheetState
4342import androidx.compose.material3.Surface
4443import androidx.compose.material3.Text
@@ -54,6 +53,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
5453import androidx.compose.ui.platform.LocalContext
5554import androidx.compose.ui.res.painterResource
5655import androidx.compose.ui.res.stringResource
56+ import androidx.compose.ui.text.style.TextAlign
5757import androidx.compose.ui.tooling.preview.Preview
5858import androidx.compose.ui.tooling.preview.PreviewParameter
5959import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
@@ -81,7 +81,8 @@ fun LongPressMenu(
8181 sheetState = sheetState,
8282 ) {
8383 BoxWithConstraints (
84- modifier = Modifier .fillMaxWidth()
84+ modifier = Modifier
85+ .fillMaxWidth()
8586 .padding(bottom = 16 .dp)
8687 ) {
8788 val maxContainerWidth = maxWidth
@@ -189,6 +190,7 @@ fun LongPressMenu(
189190 icon = Icons .Default .Person ,
190191 text = stringResource(R .string.show_channel_details),
191192 onClick = {},
193+ enabled = longPressable.uploaderUrl != null ,
192194 modifier = Modifier .size(buttonWidth, buttonHeight),
193195 )
194196
@@ -344,11 +346,12 @@ fun LongPressMenuButton(
344346 enabled : Boolean = true,
345347 modifier : Modifier = Modifier ,
346348) {
347- FilledTonalButton (
349+ OutlinedButton (
348350 onClick = onClick,
349351 enabled = enabled,
350352 shape = MaterialTheme .shapes.large,
351353 contentPadding = PaddingValues (4 .dp),
354+ border = null ,
352355 modifier = modifier,
353356 ) {
354357 Column (horizontalAlignment = Alignment .CenterHorizontally ) {
@@ -357,18 +360,22 @@ fun LongPressMenuButton(
357360 contentDescription = null ,
358361 modifier = Modifier .size(32 .dp),
359362 )
360- Text (
361- text = text,
362- style = MaterialTheme .typography.bodySmall,
363- maxLines = 1 ,
364- // make all text visible with marquee (so new users can learn about the button
365- // labels), but wait 3 seconds before making many parts of the UI move so that
366- // normal users are not distracted
367- modifier = Modifier .basicMarquee(
368- initialDelayMillis = 3000 ,
369- iterations = if (enabled) 2 else 0 ,
363+ Box {
364+ // this allows making the box always the same height (i.e. the height of two text
365+ // lines), while making the text appear centered if it is just a single line
366+ Text (
367+ text = " " ,
368+ style = MaterialTheme .typography.bodySmall,
369+ minLines = 2 ,
370370 )
371- )
371+ Text (
372+ text = text,
373+ style = MaterialTheme .typography.bodySmall,
374+ maxLines = 2 ,
375+ textAlign = TextAlign .Center ,
376+ modifier = Modifier .align(Alignment .Center )
377+ )
378+ }
372379 }
373380 }
374381}
@@ -463,7 +470,7 @@ private fun LongPressMenuPreview(
463470 }
464471 AppTheme {
465472 LongPressMenu (
466- longPressable = LongPressablePreviews ().values.first() ,
473+ longPressable = longPressable ,
467474 onDismissRequest = {},
468475 sheetState = rememberStandardBottomSheetState(), // makes it start out as open
469476 )
0 commit comments