Compare commits

..

No commits in common. "73982f48d6614fa687a6128135a34c2e45336fe5" and "dea743a30744161c1c170153b5d06beed1c1ecf8" have entirely different histories.

11 changed files with 50 additions and 113 deletions

View File

@ -363,7 +363,4 @@ const i18nEnglish = {
'stickerUploaderNameHint': 'stickerUploaderNameHint':
'A human-friendly name given to the user in the sticker selection interface.', 'A human-friendly name given to the user in the sticker selection interface.',
'readMore': 'Read more', 'readMore': 'Read more',
'attachmentUnload': 'Not Loaded',
'attachmentUnloadCaption':
'In order to save traffic, this attachment is not loaded automatically. Click it to start loading.',
}; };

View File

@ -331,6 +331,4 @@ const i18nSimplifiedChinese = {
'stickerUploaderName': '贴图名称', 'stickerUploaderName': '贴图名称',
'stickerUploaderNameHint': '在贴图选择界面提供给用户的人类友好名称。', 'stickerUploaderNameHint': '在贴图选择界面提供给用户的人类友好名称。',
'readMore': '阅读更多', 'readMore': '阅读更多',
'attachmentUnload': '附件未加载',
'attachmentUnloadCaption': '为了节省流量,本附件未自动加载,点一下来开始加载。',
}; };

View File

@ -7,7 +7,6 @@ import 'package:media_kit_video/media_kit_video.dart';
import 'package:solian/models/attachment.dart'; import 'package:solian/models/attachment.dart';
import 'package:solian/platform.dart'; import 'package:solian/platform.dart';
import 'package:solian/services.dart'; import 'package:solian/services.dart';
import 'package:solian/widgets/sized_container.dart';
import 'package:url_launcher/url_launcher_string.dart'; import 'package:url_launcher/url_launcher_string.dart';
class AttachmentItem extends StatefulWidget { class AttachmentItem extends StatefulWidget {
@ -214,12 +213,8 @@ class _AttachmentItemImage extends StatelessWidget {
class _AttachmentItemVideo extends StatefulWidget { class _AttachmentItemVideo extends StatefulWidget {
final Attachment item; final Attachment item;
final bool autoload;
const _AttachmentItemVideo({ const _AttachmentItemVideo({required this.item});
required this.item,
this.autoload = false,
});
@override @override
State<_AttachmentItemVideo> createState() => _AttachmentItemVideoState(); State<_AttachmentItemVideo> createState() => _AttachmentItemVideoState();
@ -231,64 +226,21 @@ class _AttachmentItemVideoState extends State<_AttachmentItemVideo> {
); );
late final _controller = VideoController(_player); late final _controller = VideoController(_player);
bool _showContent = false;
void _startLoad() {
_player.open(
Media(ServiceFinder.buildUrl('files', '/attachments/${widget.item.id}')),
play: false,
);
setState(() => _showContent = true);
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_player.open(
Media(
ServiceFinder.buildUrl('files', '/attachments/${widget.item.id}'),
),
play: false,
);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ratio = widget.item.metadata?['ratio'] ?? 16 / 9;
if (!_showContent) {
return GestureDetector(
child: AspectRatio(
aspectRatio: ratio,
child: CenteredContainer(
maxWidth: 280,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.not_started,
color: Colors.white,
size: 32,
),
const SizedBox(height: 8),
Text(
'attachmentUnload'.tr,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
Text(
'attachmentUnloadCaption'.tr,
style: const TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
],
),
),
),
onTap: () {
_startLoad();
},
);
}
return Video( return Video(
aspectRatio: ratio, aspectRatio: widget.item.metadata?['ratio'] ?? 16 / 9,
controller: _controller, controller: _controller,
); );
} }

View File

@ -10,7 +10,6 @@ import 'package:solian/models/attachment.dart';
import 'package:solian/widgets/attachments/attachment_item.dart'; import 'package:solian/widgets/attachments/attachment_item.dart';
import 'package:solian/providers/content/attachment.dart'; import 'package:solian/providers/content/attachment.dart';
import 'package:solian/widgets/attachments/attachment_fullscreen.dart'; import 'package:solian/widgets/attachments/attachment_fullscreen.dart';
import 'package:solian/widgets/sized_container.dart';
class AttachmentList extends StatefulWidget { class AttachmentList extends StatefulWidget {
final String parentId; final String parentId;
@ -273,33 +272,35 @@ class AttachmentListEntry extends StatelessWidget {
), ),
), ),
if (item!.isMature && !showMature) if (item!.isMature && !showMature)
CenteredContainer( Center(
maxWidth: 280, child: Container(
child: Column( constraints: const BoxConstraints(maxWidth: 280),
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: [ mainAxisAlignment: MainAxisAlignment.center,
const Icon( children: [
Icons.visibility_off, const Icon(
color: Colors.white, Icons.visibility_off,
size: 32, color: Colors.white,
), size: 32,
if (!isDense) const SizedBox(height: 8), ),
if (!isDense) if (!isDense) const SizedBox(height: 8),
Text( if (!isDense)
'matureContent'.tr, Text(
style: const TextStyle( 'matureContent'.tr,
color: Colors.white, style: const TextStyle(
fontWeight: FontWeight.bold, color: Colors.white,
fontSize: 16, fontWeight: FontWeight.bold,
fontSize: 16,
),
), ),
), if (!isDense)
if (!isDense) Text(
Text( 'matureContentCaption'.tr,
'matureContentCaption'.tr, style: const TextStyle(color: Colors.white),
style: const TextStyle(color: Colors.white), textAlign: TextAlign.center,
textAlign: TextAlign.center, ),
), ],
], ),
), ),
), ),
], ],

View File

@ -50,10 +50,10 @@ class ChatEvent extends StatelessWidget {
return Row( return Row(
children: [ children: [
Icon( Icon(
Icons.file_copy, Icons.attachment,
size: 15, size: 18,
color: unFocusColor, color: unFocusColor,
).paddingOnly(right: 5), ).paddingOnly(right: 6),
Text( Text(
'attachmentHint'.trParams( 'attachmentHint'.trParams(
{'count': attachments.length.toString()}, {'count': attachments.length.toString()},
@ -221,8 +221,6 @@ class ChatEvent extends StatelessWidget {
], ],
), ),
_buildContent().paddingOnly(left: 0.5), _buildContent().paddingOnly(left: 0.5),
_buildAttachment(context, isMinimal: true)
.paddingOnly(left: 0),
], ],
), ),
), ),

View File

@ -31,11 +31,7 @@ class ChatEventMessageActionLog extends StatelessWidget {
).paddingOnly( ).paddingOnly(
left: isQuote ? 0 : (isMerged ? 64 : 12), left: isQuote ? 0 : (isMerged ? 64 : 12),
top: 2, top: 2,
bottom: isQuote bottom: isHasMerged ? 2 : 0,
? 0
: isHasMerged
? 2
: 0,
), ),
); );
} }

View File

@ -67,9 +67,7 @@ class ChatEventMessage extends StatelessWidget {
left: isQuote ? 0 : 12, left: isQuote ? 0 : 12,
right: isQuote ? 0 : 12, right: isQuote ? 0 : 12,
top: body.quoteEvent == null ? 2 : 0, top: body.quoteEvent == null ? 2 : 0,
bottom: hasAttachment && !isContentPreviewing && !isQuote bottom: hasAttachment && !isContentPreviewing ? 4 : (isHasMerged ? 2 : 0),
? 4
: (isHasMerged ? 2 : 0),
); );
} }
} }

View File

@ -208,8 +208,6 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
final body = EventMessageBody.fromJson(widget.edit!.body); final body = EventMessageBody.fromJson(widget.edit!.body);
_editTo = widget.edit!; _editTo = widget.edit!;
_textController.text = body.text; _textController.text = body.text;
_attachments.addAll(
widget.edit!.body['attachments']?.cast<int>() ?? List.empty());
} }
if (widget.reply != null) { if (widget.reply != null) {
_replyTo = widget.reply!; _replyTo = widget.reply!;

View File

@ -335,10 +335,10 @@ class _PostItemState extends State<PostItem> {
Row( Row(
children: [ children: [
Icon( Icon(
Icons.file_copy, Icons.attachment,
size: 15, size: 18,
color: _unFocusColor, color: _unFocusColor,
).paddingOnly(right: 5), ).paddingOnly(right: 6),
Text( Text(
'attachmentHint'.trParams( 'attachmentHint'.trParams(
{'count': attachments.length.toString()}, {'count': attachments.length.toString()},
@ -440,7 +440,7 @@ class _PostItemState extends State<PostItem> {
attachmentsId: attachments, attachmentsId: attachments,
isGrid: attachments.length > 1, isGrid: attachments.length > 1,
), ),
if (widget.isShowReply || widget.isReactable) if (widget.isShowReply && widget.isReactable)
PostQuickAction( PostQuickAction(
isShowReply: widget.isShowReply, isShowReply: widget.isShowReply,
isReactable: widget.isReactable, isReactable: widget.isReactable,

View File

@ -16,9 +16,8 @@ class SizedContainer extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Align( return Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: LimitedBox( child: Container(
maxWidth: maxWidth, constraints: BoxConstraints(maxWidth: maxWidth, maxHeight: maxHeight),
maxHeight: maxHeight,
child: child, child: child,
), ),
); );
@ -38,8 +37,8 @@ class CenteredContainer extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Center( return Center(
child: LimitedBox( child: Container(
maxWidth: maxWidth, constraints: BoxConstraints(maxWidth: maxWidth),
child: child, child: child,
), ),
); );

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.1+8 version: 1.2.1+6
environment: environment:
sdk: ">=3.3.4 <4.0.0" sdk: ">=3.3.4 <4.0.0"