Compare commits

..

4 Commits

Author SHA1 Message Date
e1ddd22e4e 🚀 Launch 1.2.3+2 2024-09-23 23:34:40 +08:00
22b2ae32e9 Featured replies clickable 2024-09-23 23:34:25 +08:00
9d5c452eae 🐛 Fix overflow in content 2024-09-23 23:20:01 +08:00
0fdb1e4ead 💫 Improve loading image animation 2024-09-23 23:19:52 +08:00
3 changed files with 116 additions and 71 deletions

View File

@ -34,8 +34,17 @@ class AutoCacheImage extends StatelessWidget {
progressIndicatorBuilder: noProgressIndicator progressIndicatorBuilder: noProgressIndicator
? null ? null
: (context, url, downloadProgress) => Center( : (context, url, downloadProgress) => Center(
child: CircularProgressIndicator( child: TweenAnimationBuilder(
value: downloadProgress.progress, tween: Tween(
begin: 0,
end: downloadProgress.progress ?? 0,
),
duration: const Duration(milliseconds: 300),
builder: (context, value, _) => CircularProgressIndicator(
value: downloadProgress.progress != null
? value.toDouble()
: null,
),
), ),
), ),
errorWidget: noErrorWidget errorWidget: noErrorWidget
@ -74,11 +83,20 @@ class AutoCacheImage extends StatelessWidget {
ImageChunkEvent? loadingProgress) { ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child; if (loadingProgress == null) return child;
return Center( return Center(
child: CircularProgressIndicator( child: TweenAnimationBuilder(
value: loadingProgress.expectedTotalBytes != null tween: Tween(
? loadingProgress.cumulativeBytesLoaded / begin: 0,
loadingProgress.expectedTotalBytes! end: loadingProgress.expectedTotalBytes != null
: null, ? loadingProgress.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes!
: 0,
),
duration: const Duration(milliseconds: 300),
builder: (context, value, _) => CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null
? value.toDouble()
: null,
),
), ),
); );
}, },

View File

@ -101,11 +101,14 @@ class _PostItemState extends State<PostItem> {
onChange: (size) { onChange: (size) {
setState(() => _contentHeight = size.height); setState(() => _contentHeight = size.height);
}, },
child: MarkdownTextContent( child: SingleChildScrollView(
parentId: 'p${item.id}', physics: const NeverScrollableScrollPhysics(),
content: item.body['content'], child: MarkdownTextContent(
isAutoWarp: item.type == 'story', parentId: 'p${item.id}',
isSelectable: widget.isContentSelectable, content: item.body['content'],
isAutoWarp: item.type == 'story',
isSelectable: widget.isContentSelectable,
),
).paddingOnly( ).paddingOnly(
left: 16, left: 16,
right: 12, right: 12,
@ -209,14 +212,17 @@ class _PostItemState extends State<PostItem> {
onChange: (size) { onChange: (size) {
setState(() => _contentHeight = size.height); setState(() => _contentHeight = size.height);
}, },
child: MarkdownTextContent( child: SingleChildScrollView(
parentId: 'p${item.id}-embed', physics: const NeverScrollableScrollPhysics(),
content: item.body['content'], child: MarkdownTextContent(
isAutoWarp: item.type == 'story', parentId: 'p${item.id}-embed',
isSelectable: widget.isContentSelectable, content: item.body['content'],
isLargeText: item.type == 'article' && isAutoWarp: item.type == 'story',
widget.isFullContent, isSelectable: widget.isContentSelectable,
).paddingOnly(left: 12, right: 8), isLargeText: item.type == 'article' &&
widget.isFullContent,
).paddingOnly(left: 12, right: 8),
),
), ),
), ),
if (_contentHeight >= 320 && !widget.isFullContent) if (_contentHeight >= 320 && !widget.isFullContent)
@ -371,60 +377,81 @@ class _PostFeaturedReplyWidget extends StatelessWidget {
child: Column( child: Column(
children: snapshot.data! children: snapshot.data!
.map( .map(
(reply) => Row( (reply) => ClipRRect(
mainAxisAlignment: MainAxisAlignment.center, borderRadius: const BorderRadius.all(Radius.circular(8)),
crossAxisAlignment: CrossAxisAlignment.start, child: OpenContainer(
children: [ closedBuilder: (_, openContainer) => Row(
AccountAvatar(content: reply.author.avatar, radius: 10), mainAxisAlignment: MainAxisAlignment.center,
const Gap(6), crossAxisAlignment: CrossAxisAlignment.start,
Text( children: [
reply.author.nick, AccountAvatar(
style: const TextStyle(fontWeight: FontWeight.bold), content: reply.author.avatar,
), radius: 10,
const Gap(6), ),
Text( const Gap(6),
format( Text(
reply.publishedAt?.toLocal() ?? DateTime.now(), reply.author.nick,
locale: 'en_short', style:
), const TextStyle(fontWeight: FontWeight.bold),
).paddingOnly(top: 0.5), ),
const Gap(8), const Gap(6),
Expanded( Text(
child: Column( format(
crossAxisAlignment: CrossAxisAlignment.start, reply.publishedAt?.toLocal() ?? DateTime.now(),
children: [ locale: 'en_short',
MarkdownTextContent(
isAutoWarp: reply.type == 'story',
content: reply.body['content'],
parentId:
'p${item.id}-featured-reply${reply.id}',
), ),
if (reply.body['attachments'] is List && ).paddingOnly(top: 0.5),
reply.body['attachments'].isNotEmpty) const Gap(8),
Row( Expanded(
children: [ child: Column(
Icon( crossAxisAlignment: CrossAxisAlignment.start,
Icons.file_copy, children: [
size: 15, MarkdownTextContent(
color: unFocusColor, isAutoWarp: reply.type == 'story',
).paddingOnly(right: 5), content: reply.body['content'],
Text( parentId:
'attachmentHint'.trParams( 'p${item.id}-featured-reply${reply.id}',
{ ),
'count': reply if (reply.body['attachments'] is List &&
.body['attachments'].length reply.body['attachments'].isNotEmpty)
.toString(), Row(
}, children: [
), Icon(
style: TextStyle(color: unFocusColor), Icons.file_copy,
size: 15,
color: unFocusColor,
).paddingOnly(right: 5),
Text(
'attachmentHint'.trParams(
{
'count': reply
.body['attachments'].length
.toString(),
},
),
style: TextStyle(color: unFocusColor),
),
],
), ),
], ],
), ),
], ),
],
).paddingSymmetric(horizontal: 12, vertical: 8),
openBuilder: (_, __) => TitleShell(
title: 'postDetail'.tr,
child: PostDetailScreen(
id: reply.id.toString(),
post: reply,
), ),
), ),
], closedElevation: 0,
).paddingSymmetric(horizontal: 12, vertical: 8), openElevation: 0,
closedColor:
Theme.of(context).colorScheme.surfaceContainer,
openColor: Theme.of(context).colorScheme.surface,
),
),
) )
.toList(), .toList(),
), ),

View File

@ -2,7 +2,7 @@ name: solian
description: "The Solar Network App" description: "The Solar Network App"
publish_to: "none" publish_to: "none"
version: 1.2.3+1 version: 1.2.3+2
environment: environment:
sdk: ">=3.3.4 <4.0.0" sdk: ">=3.3.4 <4.0.0"