Better link expand layout on large screen

This commit is contained in:
LittleSheep 2024-08-19 20:13:08 +08:00
parent e45d9b39d5
commit 32e6658f3d
2 changed files with 87 additions and 72 deletions

View File

@ -32,9 +32,13 @@ class LinkExpansion extends StatelessWidget {
final LinkExpandController expandController = Get.find();
return Column(
return Wrap(
children: matches.map((x) {
return FutureBuilder(
return Container(
constraints: BoxConstraints(
maxWidth: matches.length == 1 ? 480 : 340,
),
child: FutureBuilder(
future: expandController.expandLink(x.group(0)!),
builder: (context, snapshot) {
if (!snapshot.hasData) {
@ -74,8 +78,9 @@ class LinkExpansion extends StatelessWidget {
),
],
).paddingOnly(
bottom:
(snapshot.data!.icon?.isNotEmpty ?? false) ? 8 : 4,
bottom: (snapshot.data!.icon?.isNotEmpty ?? false)
? 8
: 4,
),
if (snapshot.data!.image != null &&
(snapshot.data!.image?.startsWith('http') ?? false))
@ -93,7 +98,8 @@ class LinkExpansion extends StatelessWidget {
overflow: TextOverflow.fade,
style: Theme.of(context).textTheme.bodyLarge,
),
if (snapshot.data!.description != null && isRichDescription)
if (snapshot.data!.description != null &&
isRichDescription)
MarkdownBody(data: snapshot.data!.description!)
else if (snapshot.data!.description != null)
Text(
@ -109,6 +115,7 @@ class LinkExpansion extends StatelessWidget {
},
);
},
),
);
}).toList(),
);

View File

@ -447,9 +447,17 @@ class _PostItemState extends State<PostItem> {
],
),
if (widget.item.replyTo != null && widget.isShowEmbed)
_buildReply(context).paddingOnly(top: 4),
Container(
constraints: const BoxConstraints(maxWidth: 480),
padding: const EdgeInsets.only(top: 4),
child: _buildReply(context),
),
if (widget.item.repostTo != null && widget.isShowEmbed)
_buildRepost(context).paddingOnly(top: 4),
Container(
constraints: const BoxConstraints(maxWidth: 480),
padding: const EdgeInsets.only(top: 4),
child: _buildRepost(context),
),
_buildFooter().paddingOnly(left: 12),
LinkExpansion(content: item.body['content'])
.paddingOnly(top: 4),