fix(media): resize media to fit visible window, never truncate text
- Remove maxLines/TextOverflow from RichTextContent so post text is never truncated - Media height = window height minus 200dp chrome, so each image/video fits in the visible area without scrolling - Use ContentScale.Fit for images to scale down while keeping aspect ratio instead of filling width and overflowing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+4
-9
@@ -45,7 +45,6 @@ import androidx.compose.ui.layout.ContentScale
|
|||||||
import androidx.compose.ui.text.SpanStyle
|
import androidx.compose.ui.text.SpanStyle
|
||||||
import androidx.compose.ui.text.buildAnnotatedString
|
import androidx.compose.ui.text.buildAnnotatedString
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
|
||||||
import androidx.compose.ui.text.withStyle
|
import androidx.compose.ui.text.withStyle
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import coil3.compose.AsyncImage
|
import coil3.compose.AsyncImage
|
||||||
@@ -130,9 +129,10 @@ fun NoteCard(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cap media height to 70% of window height so controls are never clipped
|
// Cap media height so each media item fits in the visible window
|
||||||
|
// Subtract ~200dp for card chrome (header, text preview, actions, padding)
|
||||||
val windowState = LocalWindowState.current
|
val windowState = LocalWindowState.current
|
||||||
val maxMediaHeight = if (windowState != null) windowState.size.height * 0.7f else 400.dp
|
val maxMediaHeight = if (windowState != null) (windowState.size.height - 200.dp) else 400.dp
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier.fillMaxWidth(),
|
modifier = modifier.fillMaxWidth(),
|
||||||
@@ -214,7 +214,7 @@ fun NoteCard(
|
|||||||
Modifier
|
Modifier
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
contentScale = ContentScale.FillWidth,
|
contentScale = ContentScale.Fit,
|
||||||
)
|
)
|
||||||
if (url != imageUrls.last()) {
|
if (url != imageUrls.last()) {
|
||||||
Spacer(Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
@@ -285,15 +285,12 @@ fun RichTextContent(
|
|||||||
content: String,
|
content: String,
|
||||||
urls: Urls,
|
urls: Urls,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
maxLines: Int = Int.MAX_VALUE,
|
|
||||||
) {
|
) {
|
||||||
if (urls.withScheme.isEmpty()) {
|
if (urls.withScheme.isEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
text = content,
|
text = content,
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
maxLines = maxLines,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -334,8 +331,6 @@ fun RichTextContent(
|
|||||||
text = annotatedText,
|
text = annotatedText,
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
maxLines = maxLines,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user