💄 Line up attachments & expansion of link

This commit is contained in:
LittleSheep 2024-08-19 22:25:17 +08:00
parent a5ee5b7f09
commit 9170ae6be7
3 changed files with 16 additions and 30 deletions

View File

@ -8,6 +8,7 @@ import 'package:solian/widgets/account/account_profile_popup.dart';
import 'package:solian/widgets/attachments/attachment_list.dart'; import 'package:solian/widgets/attachments/attachment_list.dart';
import 'package:solian/widgets/chat/chat_event_action_log.dart'; import 'package:solian/widgets/chat/chat_event_action_log.dart';
import 'package:solian/widgets/chat/chat_event_message.dart'; import 'package:solian/widgets/chat/chat_event_message.dart';
import 'package:solian/widgets/link_expansion.dart';
import 'package:timeago/timeago.dart' show format; import 'package:timeago/timeago.dart' show format;
class ChatEvent extends StatelessWidget { class ChatEvent extends StatelessWidget {
@ -37,6 +38,11 @@ class ChatEvent extends StatelessWidget {
return '$negativeSign${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds'; return '$negativeSign${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds';
} }
Widget _buildLinkExpansion() {
if (item.body['text'] == null) return const SizedBox();
return LinkExpansion(content: item.body['text']);
}
Widget _buildAttachment(BuildContext context, {bool isMinimal = false}) { Widget _buildAttachment(BuildContext context, {bool isMinimal = false}) {
final attachments = item.body['attachments'] != null final attachments = item.body['attachments'] != null
? List<String>.from(item.body['attachments']?.whereType<String>()) ? List<String>.from(item.body['attachments']?.whereType<String>())
@ -188,8 +194,9 @@ class ChatEvent extends StatelessWidget {
), ),
], ],
).paddingOnly(right: 12), ).paddingOnly(right: 12),
_buildAttachment(context, isMinimal: isContentPreviewing) _buildAttachment(context, isMinimal: isContentPreviewing).paddingOnly(
.paddingOnly(left: isContentPreviewing ? 12 : 56), left: isContentPreviewing ? 12 : 56,
),
], ],
); );
} else if (isQuote) { } else if (isQuote) {
@ -210,7 +217,9 @@ class ChatEvent extends StatelessWidget {
Row( Row(
children: [ children: [
AccountAvatar( AccountAvatar(
content: item.sender.account.avatar, radius: 9), content: item.sender.account.avatar,
radius: 9,
),
const SizedBox(width: 5), const SizedBox(width: 5),
Text( Text(
item.sender.account.nick, item.sender.account.nick,
@ -283,6 +292,7 @@ class ChatEvent extends StatelessWidget {
), ),
], ],
).paddingSymmetric(horizontal: 12), ).paddingSymmetric(horizontal: 12),
_buildLinkExpansion().paddingOnly(left: 52),
_buildAttachment(context).paddingOnly(left: 56), _buildAttachment(context).paddingOnly(left: 56),
], ],
); );

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:solian/controllers/chat_events_controller.dart'; import 'package:solian/controllers/chat_events_controller.dart';
import 'package:solian/models/channel.dart'; import 'package:solian/models/channel.dart';
@ -83,12 +82,7 @@ class ChatEventList extends StatelessWidget {
), ),
); );
}, },
).animate(key: Key('m-animation${item.uuid}')).slideY( );
duration: 250.ms,
curve: Curves.fastEaseInToSlowEaseOut,
end: 0,
begin: 0.5,
);
}, },
); );
}), }),

View File

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:solian/models/event.dart'; import 'package:solian/models/event.dart';
import 'package:solian/widgets/link_expansion.dart';
import 'package:solian/widgets/markdown_text_content.dart'; import 'package:solian/widgets/markdown_text_content.dart';
class ChatEventMessage extends StatelessWidget { class ChatEventMessage extends StatelessWidget {
@ -54,28 +53,11 @@ class ChatEventMessage extends StatelessWidget {
); );
} }
Widget _buildLinkExpansion() {
final body = EventMessageBody.fromJson(item.body);
return LinkExpansion(content: body.text);
}
Widget _buildBody(BuildContext context) { Widget _buildBody(BuildContext context) {
if (isMerged) { if (isMerged) {
return Column( return _buildContent(context).paddingOnly(left: 52);
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildContent(context).paddingOnly(left: 4),
_buildLinkExpansion(),
],
).paddingOnly(left: 48);
} else { } else {
return Column( return _buildContent(context);
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildContent(context),
_buildLinkExpansion(),
],
);
} }
} }