Skip to content

Commit 8883579

Browse files
committed
Add OpenInNew icon next to channel name
1 parent 8b4be69 commit 8883579

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenu.kt

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import androidx.compose.foundation.layout.heightIn
2424
import androidx.compose.foundation.layout.padding
2525
import androidx.compose.foundation.layout.size
2626
import androidx.compose.foundation.layout.widthIn
27+
import androidx.compose.foundation.text.InlineTextContent
28+
import androidx.compose.foundation.text.appendInlineContent
2729
import androidx.compose.material.icons.Icons
30+
import androidx.compose.material.icons.automirrored.filled.OpenInNew
2831
import androidx.compose.material.icons.automirrored.filled.PlaylistPlay
2932
import androidx.compose.material.icons.filled.Tune
3033
import androidx.compose.material3.BottomSheetDefaults
@@ -54,6 +57,8 @@ import androidx.compose.ui.platform.ComposeView
5457
import androidx.compose.ui.platform.LocalContext
5558
import androidx.compose.ui.res.painterResource
5659
import androidx.compose.ui.res.stringResource
60+
import androidx.compose.ui.text.Placeholder
61+
import androidx.compose.ui.text.PlaceholderVerticalAlign
5762
import androidx.compose.ui.text.SpanStyle
5863
import androidx.compose.ui.text.buildAnnotatedString
5964
import androidx.compose.ui.text.font.FontWeight
@@ -379,13 +384,14 @@ fun LongPressMenuHeader(
379384
Text(
380385
text = subtitle,
381386
style = MaterialTheme.typography.bodyMedium,
387+
inlineContent = getSubtitleInlineContent(),
382388
modifier = if (onUploaderClick == null) {
383389
Modifier
384390
} else {
385391
Modifier.clickable(onClick = onUploaderClick)
386392
}
387393
.fillMaxWidth()
388-
.fadedMarquee(edgeWidth = 12.dp)
394+
.fadedMarquee(edgeWidth = 12.dp),
389395
)
390396
}
391397
}
@@ -413,6 +419,9 @@ fun getSubtitleAnnotatedString(
413419
} else {
414420
append(item.uploader)
415421
}
422+
append("")
423+
// see getSubtitleInlineContent()
424+
appendInlineContent("open_in_new", "")
416425
}
417426
shouldAddSeparator = true
418427
} else if (!item.uploader.isNullOrBlank()) {
@@ -441,6 +450,27 @@ fun getSubtitleAnnotatedString(
441450
}
442451
}
443452

453+
/**
454+
* [getSubtitleAnnotatedString] returns a string that might make use of the OpenInNew icon, and we
455+
* provide it to [Text] through its `inlineContent` parameter.
456+
*/
457+
@Composable
458+
fun getSubtitleInlineContent() = mapOf(
459+
"open_in_new" to InlineTextContent(
460+
placeholder = Placeholder(
461+
width = MaterialTheme.typography.bodyMedium.fontSize,
462+
height = MaterialTheme.typography.bodyMedium.fontSize,
463+
placeholderVerticalAlign = PlaceholderVerticalAlign.Center,
464+
)
465+
) {
466+
Icon(
467+
imageVector = Icons.AutoMirrored.Filled.OpenInNew,
468+
contentDescription = null,
469+
tint = MaterialTheme.customColors.onSurfaceVariantLink,
470+
)
471+
}
472+
)
473+
444474
@Composable
445475
fun LongPressMenuButton(
446476
icon: ImageVector,

0 commit comments

Comments
 (0)