Merge pull request #131 from ryg-git/issue_84
This commit is contained in:
commit
803852004a
|
@ -102,6 +102,7 @@ class PostWidget extends HookWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
void _openLink() => linkLauncher(
|
void _openLink() => linkLauncher(
|
||||||
context: context, url: post.post.url, instanceHost: instanceHost);
|
context: context, url: post.post.url, instanceHost: instanceHost);
|
||||||
|
|
||||||
|
@ -419,12 +420,63 @@ class PostWidget extends HookWidget {
|
||||||
postImage()
|
postImage()
|
||||||
else if (post.post.url != null && post.post.url.isNotEmpty)
|
else if (post.post.url != null && post.post.url.isNotEmpty)
|
||||||
linkPreview(),
|
linkPreview(),
|
||||||
if (post.post.body != null)
|
if (post.post.body != null && fullPost)
|
||||||
// TODO: trim content
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
child:
|
child:
|
||||||
MarkdownText(post.post.body, instanceHost: instanceHost)),
|
MarkdownText(post.post.body, instanceHost: instanceHost)),
|
||||||
|
if (post.post.body != null && !fullPost)
|
||||||
|
LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final span = TextSpan(
|
||||||
|
text: post.post.body,
|
||||||
|
);
|
||||||
|
final tp = TextPainter(
|
||||||
|
text: span,
|
||||||
|
maxLines: 10,
|
||||||
|
textDirection: Directionality.of(context),
|
||||||
|
)..layout(maxWidth: constraints.maxWidth - 20);
|
||||||
|
|
||||||
|
if (tp.didExceedMaxLines) {
|
||||||
|
return ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(maxHeight: tp.height),
|
||||||
|
child: Stack(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
children: [
|
||||||
|
ClipRect(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
heightFactor: 0.8,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: MarkdownText(post.post.body,
|
||||||
|
instanceHost: instanceHost)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: tp.preferredLineHeight * 2.5,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [
|
||||||
|
theme.cardColor.withAlpha(0),
|
||||||
|
theme.cardColor,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: MarkdownText(post.post.body,
|
||||||
|
instanceHost: instanceHost));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
actions(),
|
actions(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue