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

View File

@ -447,9 +447,17 @@ class _PostItemState extends State<PostItem> {
], ],
), ),
if (widget.item.replyTo != null && widget.isShowEmbed) 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) 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), _buildFooter().paddingOnly(left: 12),
LinkExpansion(content: item.body['content']) LinkExpansion(content: item.body['content'])
.paddingOnly(top: 4), .paddingOnly(top: 4),