Chat attachments

This commit is contained in:
LittleSheep 2024-05-26 21:03:25 +08:00
parent 9cb2b9122e
commit c3bf0a19b8
5 changed files with 27 additions and 5 deletions

View File

@ -145,8 +145,6 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: !isMerged ? 8 : 0, top: !isMerged ? 8 : 0,
bottom: !hasMerged ? 8 : 0, bottom: !hasMerged ? 8 : 0,
left: 12,
right: 12,
), ),
child: ChatMessage( child: ChatMessage(
item: item, item: item,

View File

@ -45,7 +45,7 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
List<int> _attachments = List.empty(); List<int> _attachments = List.empty();
void showAttachments(BuildContext context) { void showAttachments() {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
builder: (context) => AttachmentPublishingPopup( builder: (context) => AttachmentPublishingPopup(
@ -258,7 +258,7 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
TextButton( TextButton(
style: TextButton.styleFrom(shape: const CircleBorder()), style: TextButton.styleFrom(shape: const CircleBorder()),
child: const Icon(Icons.camera_alt), child: const Icon(Icons.camera_alt),
onPressed: () => showAttachments(context), onPressed: () => showAttachments(),
) )
], ],
), ),

View File

@ -82,6 +82,8 @@ class _SocialScreenState extends State<SocialScreen> {
sliver: SliverAppBar( sliver: SliverAppBar(
title: Text('social'.tr), title: Text('social'.tr),
centerTitle: false, centerTitle: false,
floating: true,
snap: true,
titleSpacing: titleSpacing:
SolianTheme.isLargeScreen(context) ? null : 24, SolianTheme.isLargeScreen(context) ? null : 24,
forceElevated: innerBoxIsScrolled, forceElevated: innerBoxIsScrolled,

View File

@ -4,6 +4,7 @@ import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:solian/models/message.dart'; import 'package:solian/models/message.dart';
import 'package:solian/widgets/account/account_avatar.dart'; import 'package:solian/widgets/account/account_avatar.dart';
import 'package:solian/widgets/attachments/attachment_list.dart';
import 'package:timeago/timeago.dart' show format; import 'package:timeago/timeago.dart' show format;
import 'package:url_launcher/url_launcher_string.dart'; import 'package:url_launcher/url_launcher_string.dart';
@ -136,7 +137,11 @@ class ChatMessage extends StatelessWidget {
), ),
), ),
], ],
), ).paddingSymmetric(horizontal: 12),
AttachmentList(
parentId: item.uuid,
attachmentsId: item.attachments ?? List.empty(),
).paddingSymmetric(vertical: 4),
], ],
); );
} }

View File

@ -6,6 +6,7 @@ import 'package:solian/models/channel.dart';
import 'package:solian/models/message.dart'; import 'package:solian/models/message.dart';
import 'package:solian/providers/auth.dart'; import 'package:solian/providers/auth.dart';
import 'package:solian/services.dart'; import 'package:solian/services.dart';
import 'package:solian/widgets/attachments/attachment_publish.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
class ChatMessageInput extends StatefulWidget { class ChatMessageInput extends StatefulWidget {
@ -34,6 +35,17 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
List<int> _attachments = List.empty(growable: true); List<int> _attachments = List.empty(growable: true);
void showAttachments() {
showModalBottomSheet(
context: context,
builder: (context) => AttachmentPublishingPopup(
usage: 'm.attachment',
current: _attachments,
onUpdate: (value) => _attachments = value,
),
);
}
Map<String, dynamic> encodeMessage(String content) { Map<String, dynamic> encodeMessage(String content) {
// TODO Impl E2EE // TODO Impl E2EE
@ -144,6 +156,11 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
FocusManager.instance.primaryFocus?.unfocus(), FocusManager.instance.primaryFocus?.unfocus(),
), ),
), ),
IconButton(
icon: const Icon(Icons.attach_file),
color: Colors.teal,
onPressed: () => showAttachments(),
),
IconButton( IconButton(
icon: const Icon(Icons.send), icon: const Icon(Icons.send),
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,