Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f902740c1 | ||
|
|
bae64cd8c2 | ||
|
|
5586fea6b3 | ||
|
|
d0419fdf80 |
@@ -10,7 +10,7 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/RarDog/Lunaris/releases"><img src="https://img.shields.io/badge/Version-3.0.1-8A2BE2?style=for-the-badge&logo=semver&logoColor=white" alt="Version 3.0.1" /></a>
|
||||
<a href="https://github.com/RarDog/Lunaris/releases"><img src="https://img.shields.io/badge/Version-3.0.5-8A2BE2?style=for-the-badge&logo=semver&logoColor=white" alt="Version 3.0.5" /></a>
|
||||
<img src="https://img.shields.io/badge/Flutter-3.47+-02569B?style=for-the-badge&logo=flutter&logoColor=white" alt="Flutter" />
|
||||
<img src="https://img.shields.io/badge/Platform-Android%20%7C%20Linux%20%7C%20Windows-00C853?style=for-the-badge" alt="Platforms" />
|
||||
<a href="https://github.com/RarDog/Lunaris/wiki"><img src="https://img.shields.io/badge/Wiki-Documentation-FF6F00?style=for-the-badge&logo=gitbook&logoColor=white" alt="Wiki" /></a>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
const appDisplayVersion = '3.0.2';
|
||||
const appBuildNumber = 53;
|
||||
const appDisplayVersion = '3.0.5';
|
||||
const appBuildNumber = 56;
|
||||
const appReleaseChannel = 'Stable';
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
const lunarisChangelog = [
|
||||
LunarisChange(
|
||||
version: '3.0.5',
|
||||
title: 'Интерактивные ссылки на соцсети и авторов в объявлениях и описаниях',
|
||||
bullets: [
|
||||
'Кликабельные ссылки в объявлениях автора и описании постов: все URL в тексте подсвечиваются и открываются во внешнем браузере по клику.',
|
||||
'Красивые бейджи соцсетей (CreatorLinkChips): автоматическое распознавание и стилизация ссылок на YouTube, X (Twitter), Instagram, TikTok, Discord, Patreon, Fanbox, Fantia, Boosty, Pixiv, Twitch, Telegram, Gumroad и другие платформы с фирменными иконками и цветами.',
|
||||
'Корректная очистка пунктуации: знаки препинания в конце URL (!, ?, :, ., ,, ;, >) больше не ломают ссылки.',
|
||||
],
|
||||
),
|
||||
LunarisChange(
|
||||
version: '3.0.0',
|
||||
title: 'Lunaris 3.0 — Глобальное обновление: Дизайн 2.0, Интеграция Pawchive и умная синхронизация',
|
||||
|
||||
@@ -8,6 +8,7 @@ export 'models/artist_tag.dart';
|
||||
export 'models/artist_link.dart';
|
||||
export 'models/artist_announcement.dart';
|
||||
export 'models/cloud_media_link.dart';
|
||||
export 'models/creator_link.dart';
|
||||
export 'models/download_task.dart';
|
||||
export 'models/downloaded_media.dart';
|
||||
export 'models/favorite.dart';
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum CreatorLinkType {
|
||||
youtube,
|
||||
twitter,
|
||||
instagram,
|
||||
tiktok,
|
||||
discord,
|
||||
pixiv,
|
||||
fanbox,
|
||||
patreon,
|
||||
fantia,
|
||||
boosty,
|
||||
twitch,
|
||||
telegram,
|
||||
gumroad,
|
||||
subscribestar,
|
||||
artstation,
|
||||
deviantart,
|
||||
linkhub,
|
||||
other,
|
||||
}
|
||||
|
||||
class CreatorLink {
|
||||
const CreatorLink({
|
||||
required this.url,
|
||||
required this.type,
|
||||
required this.title,
|
||||
this.customLabel,
|
||||
});
|
||||
|
||||
final String url;
|
||||
final CreatorLinkType type;
|
||||
final String title;
|
||||
final String? customLabel;
|
||||
|
||||
String get serviceName {
|
||||
switch (type) {
|
||||
case CreatorLinkType.youtube:
|
||||
return 'YouTube';
|
||||
case CreatorLinkType.twitter:
|
||||
return 'X (Twitter)';
|
||||
case CreatorLinkType.instagram:
|
||||
return 'Instagram';
|
||||
case CreatorLinkType.tiktok:
|
||||
return 'TikTok';
|
||||
case CreatorLinkType.discord:
|
||||
return 'Discord';
|
||||
case CreatorLinkType.pixiv:
|
||||
return 'Pixiv';
|
||||
case CreatorLinkType.fanbox:
|
||||
return 'Fanbox';
|
||||
case CreatorLinkType.patreon:
|
||||
return 'Patreon';
|
||||
case CreatorLinkType.fantia:
|
||||
return 'Fantia';
|
||||
case CreatorLinkType.boosty:
|
||||
return 'Boosty';
|
||||
case CreatorLinkType.twitch:
|
||||
return 'Twitch';
|
||||
case CreatorLinkType.telegram:
|
||||
return 'Telegram';
|
||||
case CreatorLinkType.gumroad:
|
||||
return 'Gumroad';
|
||||
case CreatorLinkType.subscribestar:
|
||||
return 'SubscribeStar';
|
||||
case CreatorLinkType.artstation:
|
||||
return 'ArtStation';
|
||||
case CreatorLinkType.deviantart:
|
||||
return 'DeviantArt';
|
||||
case CreatorLinkType.linkhub:
|
||||
return 'Links Hub';
|
||||
case CreatorLinkType.other:
|
||||
return title.isNotEmpty ? title : 'Web Link';
|
||||
}
|
||||
}
|
||||
|
||||
Color get brandColor {
|
||||
switch (type) {
|
||||
case CreatorLinkType.youtube:
|
||||
return const Color(0xFFFF0000); // YouTube Red
|
||||
case CreatorLinkType.twitter:
|
||||
return const Color(0xFF1D9BF0); // Twitter Blue
|
||||
case CreatorLinkType.instagram:
|
||||
return const Color(0xFFE1306C); // Instagram Gradient Magenta
|
||||
case CreatorLinkType.tiktok:
|
||||
return const Color(0xFF00F2FE); // TikTok Cyan
|
||||
case CreatorLinkType.discord:
|
||||
return const Color(0xFF5865F2); // Discord Blurple
|
||||
case CreatorLinkType.pixiv:
|
||||
return const Color(0xFF0096FA); // Pixiv Blue
|
||||
case CreatorLinkType.fanbox:
|
||||
return const Color(0xFFF1A12F); // Fanbox Orange
|
||||
case CreatorLinkType.patreon:
|
||||
return const Color(0xFFFF424D); // Patreon Coral
|
||||
case CreatorLinkType.fantia:
|
||||
return const Color(0xFFE0245E); // Fantia Pink
|
||||
case CreatorLinkType.boosty:
|
||||
return const Color(0xFFF15A24); // Boosty Orange
|
||||
case CreatorLinkType.twitch:
|
||||
return const Color(0xFF9146FF); // Twitch Purple
|
||||
case CreatorLinkType.telegram:
|
||||
return const Color(0xFF2AABEE); // Telegram Blue
|
||||
case CreatorLinkType.gumroad:
|
||||
return const Color(0xFFFF90E8); // Gumroad Pink
|
||||
case CreatorLinkType.subscribestar:
|
||||
return const Color(0xFF00ADB5); // SubscribeStar Teal
|
||||
case CreatorLinkType.artstation:
|
||||
return const Color(0xFF13AFF0); // ArtStation Blue
|
||||
case CreatorLinkType.deviantart:
|
||||
return const Color(0xFF05CC47); // DeviantArt Green
|
||||
case CreatorLinkType.linkhub:
|
||||
return const Color(0xFF43E660); // Linktree Green
|
||||
case CreatorLinkType.other:
|
||||
return const Color(0xFF5C6BC0); // Indigo
|
||||
}
|
||||
}
|
||||
|
||||
IconData get iconData {
|
||||
switch (type) {
|
||||
case CreatorLinkType.youtube:
|
||||
return Icons.smart_display_rounded;
|
||||
case CreatorLinkType.twitter:
|
||||
return Icons.alternate_email_rounded;
|
||||
case CreatorLinkType.instagram:
|
||||
return Icons.camera_alt_rounded;
|
||||
case CreatorLinkType.tiktok:
|
||||
return Icons.music_note_rounded;
|
||||
case CreatorLinkType.discord:
|
||||
return Icons.forum_rounded;
|
||||
case CreatorLinkType.pixiv:
|
||||
return Icons.palette_rounded;
|
||||
case CreatorLinkType.fanbox:
|
||||
return Icons.favorite_rounded;
|
||||
case CreatorLinkType.patreon:
|
||||
return Icons.volunteer_activism_rounded;
|
||||
case CreatorLinkType.fantia:
|
||||
return Icons.stars_rounded;
|
||||
case CreatorLinkType.boosty:
|
||||
return Icons.rocket_launch_rounded;
|
||||
case CreatorLinkType.twitch:
|
||||
return Icons.live_tv_rounded;
|
||||
case CreatorLinkType.telegram:
|
||||
return Icons.send_rounded;
|
||||
case CreatorLinkType.gumroad:
|
||||
return Icons.shopping_bag_rounded;
|
||||
case CreatorLinkType.subscribestar:
|
||||
return Icons.star_rounded;
|
||||
case CreatorLinkType.artstation:
|
||||
case CreatorLinkType.deviantart:
|
||||
return Icons.brush_rounded;
|
||||
case CreatorLinkType.linkhub:
|
||||
return Icons.link_rounded;
|
||||
case CreatorLinkType.other:
|
||||
return Icons.language_rounded;
|
||||
}
|
||||
}
|
||||
|
||||
static final _urlRegex = RegExp(
|
||||
r'''https?://[^\s<>"{}|\\^`\[\]]+''',
|
||||
caseSensitive: false,
|
||||
);
|
||||
|
||||
static final _htmlLinkRegex = RegExp(
|
||||
r"""<a\s+[^>]*href=["']([^"']+)["'][^>]*>(.*?)</a>""",
|
||||
caseSensitive: false,
|
||||
dotAll: true,
|
||||
);
|
||||
|
||||
static const _cloudDriveHosts = {
|
||||
'drive.google.com',
|
||||
'mega.nz',
|
||||
'mega.co.nz',
|
||||
'dropbox.com',
|
||||
'pixeldrain.com',
|
||||
'mediafire.com',
|
||||
'catbox.moe',
|
||||
'bunkr.',
|
||||
'gofile.io',
|
||||
'terabox.com',
|
||||
'1024tera.com',
|
||||
'dubox.com',
|
||||
};
|
||||
|
||||
/// Extracts all social media, creator profiles and external web links from text.
|
||||
static List<CreatorLink> extractLinks(
|
||||
String? text, {
|
||||
bool excludeCloudDrives = true,
|
||||
}) {
|
||||
if (text == null || text.trim().isEmpty) return const [];
|
||||
final results = <CreatorLink>[];
|
||||
final seenUrls = <String>{};
|
||||
|
||||
void processUrl(String rawUrl, {String? customTitle}) {
|
||||
var url = rawUrl.trim();
|
||||
while (url.isNotEmpty &&
|
||||
(url.endsWith(')') ||
|
||||
url.endsWith('.') ||
|
||||
url.endsWith(',') ||
|
||||
url.endsWith(';') ||
|
||||
url.endsWith('!') ||
|
||||
url.endsWith('?') ||
|
||||
url.endsWith(':') ||
|
||||
url.endsWith('>'))) {
|
||||
url = url.substring(0, url.length - 1);
|
||||
}
|
||||
final uri = Uri.tryParse(url);
|
||||
if (uri == null || !uri.hasScheme || !uri.scheme.startsWith('http')) {
|
||||
return;
|
||||
}
|
||||
if (seenUrls.contains(url)) return;
|
||||
seenUrls.add(url);
|
||||
|
||||
final host = uri.host.toLowerCase();
|
||||
if (excludeCloudDrives) {
|
||||
if (_cloudDriveHosts.any((ch) => host.contains(ch))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final (type, defaultTitle) = _classifyHost(uri);
|
||||
results.add(CreatorLink(
|
||||
url: url,
|
||||
type: type,
|
||||
title: (customTitle != null && customTitle.isNotEmpty && customTitle != url)
|
||||
? customTitle
|
||||
: defaultTitle,
|
||||
));
|
||||
}
|
||||
|
||||
// 1. Process HTML anchors
|
||||
if (text.contains('<a ')) {
|
||||
for (final match in _htmlLinkRegex.allMatches(text)) {
|
||||
final href = match.group(1);
|
||||
final rawTitle = match.group(2);
|
||||
final cleanTitle =
|
||||
rawTitle?.replaceAll(RegExp(r'<[^>]*>'), '').trim() ?? '';
|
||||
if (href != null && href.isNotEmpty) {
|
||||
processUrl(href, customTitle: cleanTitle.isNotEmpty ? cleanTitle : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Process all plain URLs
|
||||
for (final match in _urlRegex.allMatches(text)) {
|
||||
final url = match.group(0);
|
||||
if (url != null) processUrl(url);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
static (CreatorLinkType, String) _classifyHost(Uri uri) {
|
||||
final host = uri.host.toLowerCase();
|
||||
|
||||
// YouTube
|
||||
if (host.contains('youtube.com') || host.contains('youtu.be')) {
|
||||
return (CreatorLinkType.youtube, 'YouTube');
|
||||
}
|
||||
// X / Twitter
|
||||
if (host.contains('twitter.com') || host.contains('x.com') || host == 't.co') {
|
||||
return (CreatorLinkType.twitter, 'X (Twitter)');
|
||||
}
|
||||
// Instagram
|
||||
if (host.contains('instagram.com') || host.contains('instagr.am')) {
|
||||
return (CreatorLinkType.instagram, 'Instagram');
|
||||
}
|
||||
// TikTok
|
||||
if (host.contains('tiktok.com')) {
|
||||
return (CreatorLinkType.tiktok, 'TikTok');
|
||||
}
|
||||
// Discord
|
||||
if (host.contains('discord.gg') || host.contains('discord.com')) {
|
||||
return (CreatorLinkType.discord, 'Discord');
|
||||
}
|
||||
// Pixiv
|
||||
if (host.contains('pixiv.net')) {
|
||||
return (CreatorLinkType.pixiv, 'Pixiv');
|
||||
}
|
||||
// Fanbox
|
||||
if (host.contains('fanbox.cc')) {
|
||||
return (CreatorLinkType.fanbox, 'Fanbox');
|
||||
}
|
||||
// Patreon
|
||||
if (host.contains('patreon.com')) {
|
||||
return (CreatorLinkType.patreon, 'Patreon');
|
||||
}
|
||||
// Fantia
|
||||
if (host.contains('fantia.jp')) {
|
||||
return (CreatorLinkType.fantia, 'Fantia');
|
||||
}
|
||||
// Boosty
|
||||
if (host.contains('boosty.to')) {
|
||||
return (CreatorLinkType.boosty, 'Boosty');
|
||||
}
|
||||
// Twitch
|
||||
if (host.contains('twitch.tv')) {
|
||||
return (CreatorLinkType.twitch, 'Twitch');
|
||||
}
|
||||
// Telegram
|
||||
if (host.contains('t.me') || host.contains('telegram.me')) {
|
||||
return (CreatorLinkType.telegram, 'Telegram');
|
||||
}
|
||||
// Gumroad
|
||||
if (host.contains('gumroad.com')) {
|
||||
return (CreatorLinkType.gumroad, 'Gumroad');
|
||||
}
|
||||
// SubscribeStar
|
||||
if (host.contains('subscribestar.adult') || host.contains('subscribestar.com')) {
|
||||
return (CreatorLinkType.subscribestar, 'SubscribeStar');
|
||||
}
|
||||
// ArtStation
|
||||
if (host.contains('artstation.com')) {
|
||||
return (CreatorLinkType.artstation, 'ArtStation');
|
||||
}
|
||||
// DeviantArt
|
||||
if (host.contains('deviantart.com')) {
|
||||
return (CreatorLinkType.deviantart, 'DeviantArt');
|
||||
}
|
||||
// Link hubs
|
||||
if (host.contains('linktr.ee') || host.contains('carrd.co') || host.contains('lit.link')) {
|
||||
return (CreatorLinkType.linkhub, 'Links Hub');
|
||||
}
|
||||
|
||||
// Default clean host name
|
||||
var cleanHost = host.replaceFirst(RegExp(r'^www\.'), '');
|
||||
if (cleanHost.length > 25) {
|
||||
cleanHost = cleanHost.substring(0, 25);
|
||||
}
|
||||
return (CreatorLinkType.other, cleanHost.isNotEmpty ? cleanHost : 'Web Link');
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import '../../../core/utils/result.dart';
|
||||
import '../../../shared/widgets/adaptive_scaffold.dart';
|
||||
import '../../../shared/widgets/empty_view.dart';
|
||||
import '../../../shared/widgets/error_view.dart';
|
||||
import '../../../shared/widgets/formatted_content_text.dart';
|
||||
import '../../../shared/widgets/post_masonry_grid.dart';
|
||||
import '../../favorites/presentation/favorites_controller.dart';
|
||||
import '../../settings/presentation/settings_controller.dart';
|
||||
@@ -235,7 +236,8 @@ class _ArtistPostsScreenState extends ConsumerState<ArtistPostsScreen> {
|
||||
itemBuilder: (context, index) {
|
||||
final a = _announcements[index];
|
||||
final cleanContent = CloudLinkExtractor.cleanCommentary(a.content);
|
||||
final detectedLinks = CloudLinkExtractor.extractLinks(content: a.content);
|
||||
final detectedCloudLinks = CloudLinkExtractor.extractLinks(content: a.content);
|
||||
final creatorLinks = CreatorLink.extractLinks(a.content);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -250,18 +252,25 @@ class _ArtistPostsScreenState extends ConsumerState<ArtistPostsScreen> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
SelectableText(
|
||||
cleanContent.isNotEmpty ? cleanContent : a.content,
|
||||
FormattedContentText(
|
||||
text: cleanContent.isNotEmpty ? cleanContent : a.content,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
height: 1.45,
|
||||
),
|
||||
),
|
||||
if (detectedLinks.isNotEmpty) ...[
|
||||
if (creatorLinks.isNotEmpty) ...[
|
||||
const SizedBox(height: 10),
|
||||
CreatorLinkChips(
|
||||
links: creatorLinks,
|
||||
title: 'Ссылки автора',
|
||||
),
|
||||
],
|
||||
if (detectedCloudLinks.isNotEmpty) ...[
|
||||
const SizedBox(height: 10),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 6,
|
||||
children: detectedLinks.map((link) {
|
||||
children: detectedCloudLinks.map((link) {
|
||||
return ActionChip(
|
||||
avatar: Icon(
|
||||
link.iconData,
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../../../app/app_strings.dart';
|
||||
import '../../../../backend/models/cloud_media_link.dart';
|
||||
import '../../../../backend/models/creator_link.dart';
|
||||
import '../../../../shared/widgets/formatted_content_text.dart';
|
||||
|
||||
class CloudMirrorsCard extends StatelessWidget {
|
||||
const CloudMirrorsCard({
|
||||
@@ -186,13 +188,26 @@ class CloudMirrorsCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SelectableText(
|
||||
commentary!.trim(),
|
||||
FormattedContentText(
|
||||
text: commentary!.trim(),
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
height: 1.45,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final creatorLinks = CreatorLink.extractLinks(commentary);
|
||||
if (creatorLinks.isEmpty) return const SizedBox.shrink();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: CreatorLinkChips(
|
||||
links: creatorLinks,
|
||||
title: strings.ru ? 'Ссылки автора' : 'Author Links',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1005,13 +1005,13 @@ class _SettingsContentState extends ConsumerState<_SettingsContent> {
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Option 1: Gitea (Recommended for speed)
|
||||
// Option 1: GitHub (Recommended for speed)
|
||||
Material(
|
||||
color: theme.colorScheme.primaryContainer.withValues(alpha: 0.35),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () => Navigator.pop(sheetContext, UpdateSource.gitea),
|
||||
onTap: () => Navigator.pop(sheetContext, UpdateSource.github),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
@@ -1037,7 +1037,7 @@ class _SettingsContentState extends ConsumerState<_SettingsContent> {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'Gitea',
|
||||
'GitHub',
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -1087,13 +1087,13 @@ class _SettingsContentState extends ConsumerState<_SettingsContent> {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Option 2: GitHub (Muted / neutral grey)
|
||||
// Option 2: Gitea (Muted / neutral grey)
|
||||
Material(
|
||||
color: theme.colorScheme.surfaceContainerHighest.withValues(alpha: 0.25),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () => Navigator.pop(sheetContext, UpdateSource.github),
|
||||
onTap: () => Navigator.pop(sheetContext, UpdateSource.gitea),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
@@ -1106,7 +1106,7 @@ class _SettingsContentState extends ConsumerState<_SettingsContent> {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.code_rounded,
|
||||
Icons.dns_rounded,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
size: 22,
|
||||
),
|
||||
@@ -1117,7 +1117,7 @@ class _SettingsContentState extends ConsumerState<_SettingsContent> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'GitHub',
|
||||
'Gitea',
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
@@ -1126,8 +1126,8 @@ class _SettingsContentState extends ConsumerState<_SettingsContent> {
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
isRu
|
||||
? 'Глобальное зеркало релизов'
|
||||
: 'Global release mirror',
|
||||
? 'Сервер релизов'
|
||||
: 'Release server',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.7),
|
||||
),
|
||||
|
||||
@@ -192,23 +192,46 @@ class _TagInputSearchBarState extends State<TagInputSearchBar> {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final screenSize = MediaQuery.sizeOf(context);
|
||||
final renderBox =
|
||||
_fieldKey.currentContext?.findRenderObject() as RenderBox?;
|
||||
final width =
|
||||
final fieldWidth =
|
||||
renderBox?.hasSize == true ? renderBox!.size.width : 360.0;
|
||||
final height =
|
||||
final fieldHeight =
|
||||
renderBox?.hasSize == true ? renderBox!.size.height : 48.0;
|
||||
|
||||
final screenW = screenSize.width;
|
||||
// Substantially wider dropdown:
|
||||
// Mobile (< 600px): use full screen width minus comfortable 24px margins.
|
||||
// Desktop/Tablet (>= 600px): expand to 1.35x field width, up to 780px.
|
||||
final dropdownWidth = screenW < 600
|
||||
? (screenW - 24.0).clamp(fieldWidth, 580.0)
|
||||
: (fieldWidth * 1.35).clamp(fieldWidth, (screenW - 32.0).clamp(fieldWidth, 780.0));
|
||||
|
||||
// Ensure dropdown stays fully on screen and doesn't get clipped
|
||||
double dxOffset = 0.0;
|
||||
if (renderBox?.hasSize == true && renderBox?.attached == true) {
|
||||
final globalPos = renderBox!.localToGlobal(Offset.zero);
|
||||
final globalRight = globalPos.dx + dropdownWidth;
|
||||
final maxRight = screenW - 12.0;
|
||||
if (globalRight > maxRight) {
|
||||
dxOffset = maxRight - globalRight;
|
||||
}
|
||||
if (globalPos.dx + dxOffset < 12.0) {
|
||||
dxOffset = 12.0 - globalPos.dx;
|
||||
}
|
||||
}
|
||||
|
||||
return CompositedTransformFollower(
|
||||
link: _layerLink,
|
||||
showWhenUnlinked: false,
|
||||
offset: Offset(0, height + 6),
|
||||
offset: Offset(dxOffset, fieldHeight + 6),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: TapRegion(
|
||||
groupId: _fieldKey,
|
||||
child: SizedBox(
|
||||
width: width.clamp(280.0, 620.0),
|
||||
width: dropdownWidth,
|
||||
child: _TagSuggestionDropdown(
|
||||
suggestions: suggestions,
|
||||
query: token,
|
||||
@@ -565,7 +588,7 @@ class _TagSuggestionDropdown extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 620),
|
||||
constraints: const BoxConstraints(maxWidth: 820),
|
||||
child: Material(
|
||||
elevation: 8,
|
||||
shadowColor: Colors.black.withValues(alpha: 0.18),
|
||||
@@ -641,7 +664,7 @@ class _TagSuggestionDropdown extends StatelessWidget {
|
||||
if (cleanToken.isEmpty) {
|
||||
return Text(
|
||||
text,
|
||||
maxLines: 1,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: defaultStyle,
|
||||
);
|
||||
@@ -653,7 +676,7 @@ class _TagSuggestionDropdown extends StatelessWidget {
|
||||
if (matchIndex < 0) {
|
||||
return Text(
|
||||
text,
|
||||
maxLines: 1,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: defaultStyle,
|
||||
);
|
||||
@@ -678,7 +701,7 @@ class _TagSuggestionDropdown extends StatelessWidget {
|
||||
if (after.isNotEmpty) TextSpan(text: after),
|
||||
],
|
||||
),
|
||||
maxLines: 1,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../backend/models/creator_link.dart';
|
||||
|
||||
class FormattedContentText extends StatefulWidget {
|
||||
const FormattedContentText({
|
||||
super.key,
|
||||
required this.text,
|
||||
this.style,
|
||||
this.linkColor,
|
||||
this.selectable = true,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final TextStyle? style;
|
||||
final Color? linkColor;
|
||||
final bool selectable;
|
||||
|
||||
@override
|
||||
State<FormattedContentText> createState() => _FormattedContentTextState();
|
||||
}
|
||||
|
||||
class _FormattedContentTextState extends State<FormattedContentText> {
|
||||
final List<TapGestureRecognizer> _recognizers = [];
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (final r in _recognizers) {
|
||||
r.dispose();
|
||||
}
|
||||
_recognizers.clear();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _clearRecognizers() {
|
||||
for (final r in _recognizers) {
|
||||
r.dispose();
|
||||
}
|
||||
_recognizers.clear();
|
||||
}
|
||||
|
||||
Future<void> _launch(String url) async {
|
||||
final uri = Uri.tryParse(url);
|
||||
if (uri != null) {
|
||||
try {
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} catch (_) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Не удалось открыть ссылку: $url')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_clearRecognizers();
|
||||
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.colorScheme;
|
||||
final defaultStyle = widget.style ?? theme.textTheme.bodyMedium ?? const TextStyle();
|
||||
final linkStyle = defaultStyle.copyWith(
|
||||
color: widget.linkColor ?? scheme.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: (widget.linkColor ?? scheme.primary).withValues(alpha: 0.45),
|
||||
);
|
||||
|
||||
final text = widget.text;
|
||||
if (text.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
final urlRegex = RegExp(r'''https?://[^\s<>"{}|\\^`\[\]]+''', caseSensitive: false);
|
||||
final spans = <InlineSpan>[];
|
||||
var lastIndex = 0;
|
||||
|
||||
for (final match in urlRegex.allMatches(text)) {
|
||||
if (match.start > lastIndex) {
|
||||
spans.add(TextSpan(
|
||||
text: text.substring(lastIndex, match.start),
|
||||
style: defaultStyle,
|
||||
));
|
||||
}
|
||||
|
||||
var rawUrl = match.group(0)!;
|
||||
var cleanUrl = rawUrl;
|
||||
var trailing = '';
|
||||
while (cleanUrl.isNotEmpty &&
|
||||
(cleanUrl.endsWith(')') ||
|
||||
cleanUrl.endsWith('.') ||
|
||||
cleanUrl.endsWith(',') ||
|
||||
cleanUrl.endsWith(';') ||
|
||||
cleanUrl.endsWith('!') ||
|
||||
cleanUrl.endsWith('?') ||
|
||||
cleanUrl.endsWith(':') ||
|
||||
cleanUrl.endsWith('>'))) {
|
||||
trailing = cleanUrl[cleanUrl.length - 1] + trailing;
|
||||
cleanUrl = cleanUrl.substring(0, cleanUrl.length - 1);
|
||||
}
|
||||
|
||||
final recognizer = TapGestureRecognizer()
|
||||
..onTap = () => _launch(cleanUrl);
|
||||
_recognizers.add(recognizer);
|
||||
|
||||
spans.add(TextSpan(
|
||||
text: cleanUrl,
|
||||
style: linkStyle,
|
||||
recognizer: recognizer,
|
||||
));
|
||||
|
||||
if (trailing.isNotEmpty) {
|
||||
spans.add(TextSpan(
|
||||
text: trailing,
|
||||
style: defaultStyle,
|
||||
));
|
||||
}
|
||||
|
||||
lastIndex = match.end;
|
||||
}
|
||||
|
||||
if (lastIndex < text.length) {
|
||||
spans.add(TextSpan(
|
||||
text: text.substring(lastIndex),
|
||||
style: defaultStyle,
|
||||
));
|
||||
}
|
||||
|
||||
if (widget.selectable) {
|
||||
return SelectableText.rich(
|
||||
TextSpan(children: spans),
|
||||
style: defaultStyle,
|
||||
);
|
||||
}
|
||||
|
||||
return Text.rich(
|
||||
TextSpan(children: spans),
|
||||
style: defaultStyle,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CreatorLinkChips extends StatelessWidget {
|
||||
const CreatorLinkChips({
|
||||
super.key,
|
||||
required this.links,
|
||||
this.title,
|
||||
});
|
||||
|
||||
final List<CreatorLink> links;
|
||||
final String? title;
|
||||
|
||||
Future<void> _openLink(BuildContext context, String url) async {
|
||||
final uri = Uri.tryParse(url);
|
||||
if (uri != null) {
|
||||
try {
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} catch (_) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Не удалось открыть ссылку: $url')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (links.isEmpty) return const SizedBox.shrink();
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (title != null && title!.isNotEmpty) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.link_rounded,
|
||||
size: 15,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
title!,
|
||||
style: theme.textTheme.labelMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 6,
|
||||
children: links.map((link) {
|
||||
final brand = link.brandColor;
|
||||
final labelText = link.title.isNotEmpty ? link.title : link.serviceName;
|
||||
|
||||
return Material(
|
||||
color: brand.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
onTap: () => _openLink(context, link.url),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: brand.withValues(alpha: 0.35),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
link.iconData,
|
||||
size: 16,
|
||||
color: brand,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 240),
|
||||
child: Text(
|
||||
labelText,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.onSurface,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.arrow_outward_rounded,
|
||||
size: 12,
|
||||
color: brand.withValues(alpha: 0.75),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: gel_rule_app
|
||||
description: Local backend/core layer for a Flutter booru browser app.
|
||||
publish_to: "none"
|
||||
version: 3.0.2+53
|
||||
version: 3.0.5+56
|
||||
|
||||
environment:
|
||||
sdk: ">=3.3.0 <4.0.0"
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gel_rule_app/backend/models/creator_link.dart';
|
||||
|
||||
void main() {
|
||||
group('CreatorLink extractor and classification tests', () {
|
||||
test('extracts and classifies social and creator links accurately', () {
|
||||
const text = '''
|
||||
Check out my latest speedpaint on YouTube: https://youtu.be/dQw4w9WgXcQ
|
||||
Also follow my X account https://x.com/artist_handle and Instagram: https://instagram.com/p/C1234567/!
|
||||
Support me on Patreon: https://www.patreon.com/my_art or Fanbox: https://artist.fanbox.cc
|
||||
Join my Discord: https://discord.gg/invitelink
|
||||
Other links: https://carrd.co/myportfolio and https://example.com/blog.
|
||||
Cloud links like https://drive.google.com/file/d/123/view and https://mega.nz/file/abc should be excluded by default.
|
||||
''';
|
||||
|
||||
final links = CreatorLink.extractLinks(text);
|
||||
|
||||
expect(links.length, 8);
|
||||
|
||||
final yt = links.firstWhere((l) => l.type == CreatorLinkType.youtube);
|
||||
expect(yt.serviceName, 'YouTube');
|
||||
expect(yt.url, 'https://youtu.be/dQw4w9WgXcQ');
|
||||
|
||||
final twitter = links.firstWhere((l) => l.type == CreatorLinkType.twitter);
|
||||
expect(twitter.serviceName, 'X (Twitter)');
|
||||
expect(twitter.url, 'https://x.com/artist_handle');
|
||||
|
||||
final insta = links.firstWhere((l) => l.type == CreatorLinkType.instagram);
|
||||
expect(insta.serviceName, 'Instagram');
|
||||
expect(insta.url, 'https://instagram.com/p/C1234567/');
|
||||
|
||||
final patreon = links.firstWhere((l) => l.type == CreatorLinkType.patreon);
|
||||
expect(patreon.serviceName, 'Patreon');
|
||||
|
||||
final fanbox = links.firstWhere((l) => l.type == CreatorLinkType.fanbox);
|
||||
expect(fanbox.serviceName, 'Fanbox');
|
||||
|
||||
final discord = links.firstWhere((l) => l.type == CreatorLinkType.discord);
|
||||
expect(discord.serviceName, 'Discord');
|
||||
|
||||
final hub = links.firstWhere((l) => l.type == CreatorLinkType.linkhub);
|
||||
expect(hub.serviceName, 'Links Hub');
|
||||
|
||||
final web = links.firstWhere((l) => l.type == CreatorLinkType.other);
|
||||
expect(web.url, 'https://example.com/blog');
|
||||
|
||||
// Verify cloud storage was excluded
|
||||
expect(links.any((l) => l.url.contains('drive.google.com')), isFalse);
|
||||
expect(links.any((l) => l.url.contains('mega.nz')), isFalse);
|
||||
});
|
||||
|
||||
test('handles HTML anchor links with custom titles', () {
|
||||
const html = '''
|
||||
<p>Visit my <a href="https://twitter.com/draws">Twitter Profile</a> and watch on <a href="https://www.youtube.com/channel/123">YouTube Stream</a>!</p>
|
||||
''';
|
||||
|
||||
final links = CreatorLink.extractLinks(html);
|
||||
expect(links.length, 2);
|
||||
|
||||
final tw = links.firstWhere((l) => l.type == CreatorLinkType.twitter);
|
||||
expect(tw.title, 'Twitter Profile');
|
||||
|
||||
final yt = links.firstWhere((l) => l.type == CreatorLinkType.youtube);
|
||||
expect(yt.title, 'YouTube Stream');
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user