Compare commits

..

5 Commits

Author SHA1 Message Date
54dee9702b 🐛 Fix attachments max width 2024-08-07 14:34:41 +08:00
94385564bd 🐛 Fix dupe attachment notification 2024-08-07 14:27:23 +08:00
0b2309816f 🐛 Fix desktop panic when download things 2024-08-07 13:50:50 +08:00
8283272a3b 🗑️ Fix mis-import 2024-08-07 01:49:03 +08:00
eb02a47e9a 💄 Fixes and improvements 2024-08-07 01:47:53 +08:00
9 changed files with 37 additions and 27 deletions

View File

@@ -1,4 +1,3 @@
import 'package:get/get.dart';
import 'package:solian/models/account.dart';
import 'package:solian/models/attachment.dart';
import 'package:solian/services.dart';
@@ -32,7 +31,7 @@ class Sticker {
required this.account,
});
String get textPlaceholder => '${pack?.prefix}$alias'.camelCase!;
String get textPlaceholder => '${pack?.prefix}$alias';
String get textWarpedPlaceholder => ':$textPlaceholder:';
String get imageUrl => ServiceFinder.buildUrl(

View File

@@ -8,6 +8,9 @@ class StickerProvider extends GetxController {
final RxList<Sticker> availableStickers = RxList.empty(growable: true);
Future<void> refreshAvailableStickers() async {
availableStickers.clear();
aliasImageMapping.clear();
final client = ServiceFinder.configureClient('files');
final resp = await client.get(
'/stickers/manifest?take=100',
@@ -20,7 +23,7 @@ class StickerProvider extends GetxController {
for (final pack in out) {
for (final sticker in (pack.stickers ?? List<Sticker>.empty())) {
sticker.pack = pack;
aliasImageMapping['${pack.prefix}${sticker.alias}'.camelCase!] =
aliasImageMapping[sticker.textPlaceholder.toUpperCase()] =
sticker.imageUrl;
availableStickers.add(sticker);
}

View File

@@ -70,7 +70,7 @@ class _StickerScreenState extends State<StickerScreen> {
);
return ListTile(
title: Text(item.name),
subtitle: Text(':${'$prefix${item.alias}'.camelCase}:'),
subtitle: Text(item.textWarpedPlaceholder),
contentPadding: const EdgeInsets.only(left: 16, right: 14),
trailing: Row(
mainAxisSize: MainAxisSize.min,
@@ -174,9 +174,10 @@ class _StickerScreenState extends State<StickerScreen> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
children: item.stickers
?.map((x) => _buildEmoteEntry(x, item.prefix))
.toList() ??
children: item.stickers?.map((x) {
x.pack = item;
return _buildEmoteEntry(x, item.prefix);
}).toList() ??
List.empty(),
);
},

View File

@@ -70,7 +70,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
'/attachments/${widget.item.id}',
);
if (PlatformInfo.isWeb) {
if (PlatformInfo.isWeb || PlatformInfo.isDesktop) {
await launchUrlString(url);
return;
}

View File

@@ -244,6 +244,7 @@ class _AttachmentItemVideoState extends State<_AttachmentItemVideo> {
@override
void initState() {
super.initState();
_showContent = widget.autoload;
}
@override

View File

@@ -23,16 +23,19 @@ class ChatEventMessage extends StatelessWidget {
final body = EventMessageBody.fromJson(item.body);
final hasAttachment = body.attachments?.isNotEmpty ?? false;
if (body.text.isEmpty && hasAttachment) {
if (body.text.isEmpty &&
hasAttachment &&
!isContentPreviewing &&
!isQuote) {
final unFocusColor =
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
return Row(
children: [
Icon(
Icons.attachment,
size: 18,
Icons.file_copy,
size: 15,
color: unFocusColor,
).paddingOnly(right: 6),
).paddingOnly(right: 5),
Text(
'attachmentHint'.trParams(
{'count': body.attachments?.length.toString() ?? 0.toString()},

View File

@@ -239,7 +239,7 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
if (suggestion.type == 'emotes') {
insertText = suggestion.content;
startText = replaceText.replaceFirstMapped(
RegExp(r':(?:([a-z0-9_+-]+)~)?([a-z0-9_+-]+)$'),
RegExp(r':(?:([-\w]+)~)?([-\w]+)$'),
(Match m) => insertText,
);
}
@@ -247,7 +247,7 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
if (suggestion.type == 'users') {
insertText = suggestion.content;
startText = replaceText.replaceFirstMapped(
RegExp(r'(?:\s|^)@([a-z0-9_+-]+)$'),
RegExp(r'(?:\s|^)@([-\w]+)$'),
(Match m) => insertText,
);
}
@@ -349,15 +349,17 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
final searchText = _textController.text
.substring(0, _textController.selection.baseOffset);
final emojiMatch =
RegExp(r':(?:([a-z0-9_+-]+)~)?([a-z0-9_+-]+)$')
.firstMatch(searchText);
final emojiMatch = RegExp(r':(?:([-\w]+)~)?([-\w]+)$')
.firstMatch(searchText);
if (emojiMatch != null) {
final StickerProvider stickers = Get.find();
final emoteSearch = emojiMatch[2]!;
return stickers.availableStickers
.where((x) =>
x.textWarpedPlaceholder.contains(emoteSearch))
.where(
(x) => x.textWarpedPlaceholder
.toUpperCase()
.contains(emoteSearch.toUpperCase()),
)
.map(
(x) => ChatMessageSuggestion(
type: 'emotes',
@@ -379,8 +381,8 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
.toList();
}
final userMatch = RegExp(r'(?:\s|^)@([a-z0-9_+-]+)$')
.firstMatch(searchText);
final userMatch =
RegExp(r'(?:\s|^)@([-\w]+)$').firstMatch(searchText);
if (userMatch != null) {
final userSearch = userMatch[1]!.toLowerCase();
final AuthProvider auth = Get.find();

View File

@@ -24,9 +24,9 @@ class MarkdownTextContent extends StatelessWidget {
});
Widget _buildContent(BuildContext context) {
final emojiMatch = RegExp(r':([a-z0-9_+-]+):').allMatches(content);
final isOnlyEmoji =
content.replaceAll(RegExp(r':([a-z0-9_+-]+):'), '').trim().isEmpty;
final emojiRegex = RegExp(r':([-\w]+):');
final emojiMatch = emojiRegex.allMatches(content);
final isOnlyEmoji = content.replaceAll(emojiRegex, '').trim().isEmpty;
return Markdown(
shrinkWrap: true,
@@ -89,7 +89,7 @@ class MarkdownTextContent extends StatelessWidget {
switch (segments[0]) {
case 'stickers':
final StickerProvider sticker = Get.find();
url = sticker.aliasImageMapping[segments[1]]!;
url = sticker.aliasImageMapping[segments[1].toUpperCase()]!;
if (emojiMatch.length <= 1 && isOnlyEmoji) {
width = 112;
height = 112;
@@ -161,12 +161,12 @@ class _UserNameCardInlineSyntax extends InlineSyntax {
}
class _CustomEmoteInlineSyntax extends InlineSyntax {
_CustomEmoteInlineSyntax() : super(r':([a-z0-9_+-]+):');
_CustomEmoteInlineSyntax() : super(r':([-\w]+):');
@override
bool onMatch(markdown.InlineParser parser, Match match) {
final StickerProvider sticker = Get.find();
final alias = match[1]!;
final alias = match[1]!.toUpperCase();
if (sticker.aliasImageMapping[alias] == null) {
parser.advanceBy(1);
return false;

View File

@@ -436,6 +436,7 @@ class _PostItemState extends State<PostItem> {
left: 16,
),
AttachmentList(
flatMaxHeight: MediaQuery.of(context).size.width,
parentId: widget.item.id.toString(),
attachmentsId: attachments,
isGrid: attachments.length > 1,