Compare commits

...
6 Commits
Author SHA1 Message Date
RarDog 8ad36e2f6b fix: eliminate video player blue screen on desktop with software rendering default and decoder toggle (v3.6.4)
Build and Release / Build Windows x64 (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
2026-09-05 18:48:33 +03:00
RarDog 4aedde9b3f feat: desktop horizontal mouse-wheel scroll & fix PC video player blue screen (v3.6.3)
Build and Release / Build Windows x64 (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
2026-09-05 18:32:45 +03:00
RarDog 5b2c8eb53e fix(perf): memory optimization, prevent OOM on mobile, and completely disable mouse wheel zoom
Build and Release / Build Windows x64 (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
2026-09-05 18:09:58 +03:00
RarDog d7d9cad423 fix(desktop): smooth sidebar hover animation without text jitter and remove mouse wheel zoom
Build and Release / Build Windows x64 (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
2026-09-05 17:58:49 +03:00
RarDog 7d3c4f964a feat: desktop UI redesign and comprehensive PC hotkeys (v3.6.0)
Build and Release / Build Windows x64 (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
2026-09-05 17:44:53 +03:00
RarDog 877a044ff3 feat(linux): add build_linux_appimage.sh script for AppImage packaging 2026-09-05 17:15:21 +03:00
18 changed files with 2238 additions and 587 deletions
+2 -1
View File
@@ -5,7 +5,8 @@
<application <application
android:label="Prisma" android:label="Prisma"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher"
android:largeHeap="true">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
+92
View File
@@ -0,0 +1,92 @@
#!/usr/bin/env bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "${ROOT_DIR}"
VERSION=$(grep 'version:' pubspec.yaml | head -n 1 | awk '{print $2}' | cut -d'+' -f1)
if [ -z "$VERSION" ]; then
VERSION="3.5.5"
fi
echo "Building AppImage for Prisma v${VERSION}..."
BUNDLE_DIR="${ROOT_DIR}/build/linux/x64/release/bundle"
if [ ! -f "${BUNDLE_DIR}/gel_rule_app" ]; then
echo "Release bundle not found. Running 'flutter build linux --release'..."
flutter build linux --release
fi
APP_DIR="${ROOT_DIR}/build/AppDir"
OUTPUT_DIR="${ROOT_DIR}/build"
APPIMAGE_NAME="Prisma-v${VERSION}-linux-x86_64.AppImage"
OUTPUT_APPIMAGE="${OUTPUT_DIR}/${APPIMAGE_NAME}"
# Ensure appimagetool is available
APPIMAGETOOL=""
if command -v appimagetool >/dev/null 2>&1; then
APPIMAGETOOL="appimagetool"
elif [ -f "${ROOT_DIR}/build/tools/appimagetool" ]; then
APPIMAGETOOL="${ROOT_DIR}/build/tools/appimagetool"
else
echo "Downloading appimagetool..."
mkdir -p "${ROOT_DIR}/build/tools"
curl -fsSL https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -o "${ROOT_DIR}/build/tools/appimagetool"
chmod +x "${ROOT_DIR}/build/tools/appimagetool"
APPIMAGETOOL="${ROOT_DIR}/build/tools/appimagetool"
fi
echo "Preparing AppDir at ${APP_DIR}..."
rm -rf "${APP_DIR}"
mkdir -p "${APP_DIR}"
# Copy bundle contents
cp -r "${BUNDLE_DIR}"/* "${APP_DIR}/"
# AppRun script
cat << 'EOF' > "${APP_DIR}/AppRun"
#!/bin/sh
HERE="$(dirname "$(readlink -f "${0}")")"
export PATH="${HERE}/usr/bin:${PATH}"
export LD_LIBRARY_PATH="${HERE}/lib:${HERE}/usr/lib:${LD_LIBRARY_PATH}"
exec "${HERE}/gel_rule_app" "$@"
EOF
chmod +x "${APP_DIR}/AppRun"
# Desktop file
cat << 'EOF' > "${APP_DIR}/prisma.desktop"
[Desktop Entry]
Name=Prisma
GenericName=Booru Client
Comment=Prisma - Modern Booru & Art Client
Exec=gel_rule_app %u
Icon=prisma
Terminal=false
Type=Application
Categories=Network;Graphics;
StartupWMClass=com.example.gel_rule_app
EOF
mkdir -p "${APP_DIR}/usr/share/applications"
cp "${APP_DIR}/prisma.desktop" "${APP_DIR}/usr/share/applications/prisma.desktop"
# Icons
ICON_SRC="${ROOT_DIR}/macos/Runner/Assets.xcassets/AppIcon.appiconset"
if [ -d "${ICON_SRC}" ]; then
for size in 16 32 64 128 256 512 1024; do
if [ -f "${ICON_SRC}/app_icon_${size}.png" ]; then
mkdir -p "${APP_DIR}/usr/share/icons/hicolor/${size}x${size}/apps"
cp "${ICON_SRC}/app_icon_${size}.png" "${APP_DIR}/usr/share/icons/hicolor/${size}x${size}/apps/prisma.png"
fi
done
cp "${ICON_SRC}/app_icon_512.png" "${APP_DIR}/prisma.png"
fi
# Build AppImage
echo "Generating AppImage with ${APPIMAGETOOL}..."
ARCH=x86_64 "${APPIMAGETOOL}" -n "${APP_DIR}" "${OUTPUT_APPIMAGE}"
echo "AppImage created successfully: ${OUTPUT_APPIMAGE}"
ls -lh "${OUTPUT_APPIMAGE}"
+50
View File
@@ -1,4 +1,54 @@
const prismaChangelog = [ const prismaChangelog = [
PrismaChange(
version: '3.6.4',
title: 'Полное исправление воспроизведения видео на ПК (устранение синего экрана)',
bullets: [
'Программный рендеринг (S/W) по умолчанию для ПК: на десктопных платформах отключен проблемный OpenGL FBO мост аппаратного ускорения, вызывавший синий экран из-за отсутствия или конфликтов драйверов VAAPI/VDPAU в Linux/AppImage.',
'Переключатель декодера H/W / S/W в плеере: на верхней панели управления видеоплеером добавлена кнопка быстрого переключения между аппаратным (H/W) и программным (S/W) декодированием на лету.',
'Отображение постера-превью: под видеоплеером теперь отображается превью-постер на время буферизации, исключая появление пустых областей.',
'Безопасное превью в ленте: предпросмотр видео в карточках постов на ПК также переведен на надежный программный рендерер.',
],
),
PrismaChange(
version: '3.6.3',
title: 'Горизонтальный скролл колесиком мыши на ПК и исправление синего экрана в видеоплеере',
bullets: [
'Горизонтальная прокрутка колесиком мыши в настройках: верхняя панель категорий настроек теперь плавно прокручивается колесиком мыши строго при наведении курсора.',
'Горизонтальная прокрутка колесиком мыши в авторах: полоса любимых авторов и лента их медиа теперь поддерживают быструю прокрутку колесиком мыши при наведении курсора.',
'Устранение «синего экрана» в видеоплеере на ПК: исправлена нативная инициализация MediaKit перед запуском Flutter-движка и настроен оптимальный режим аппаратного ускорения для десктопных платформ.',
],
),
PrismaChange(
version: '3.6.2',
title: 'Комплексная оптимизация памяти на телефоне и ПК, полное отключение зума колесиком',
bullets: [
'Полное отключение масштабирования колесиком мыши: перехвачен внутренний обработчик PointerScrollEvent в интерактивном вьюере, что навсегда исключило нежелательный зум при прокрутке.',
'Предотвращение вылетов на смартфонах (OOM): включен флаг android:largeHeap="true", расширяющий доступный лимит оперативной памяти процесса до 512–1024 МБ.',
'Ограничение аппетита кэша изображений: глобальный ImageCache в Flutter ограничен безопасным лимитом в 180 МБ и 120 изображений (вместо неограниченного роста до 1 ГБ+), неактивные растры своевременно выгружаются сборщиком мусора.',
'Оптимизация декодирования тяжелых артов: полноразмерные изображения с экстремальным разрешением (до 10K+) теперь безопасно декодируются с ограничением memCacheWidth под экран устройства, снижая расход RAM на 80–90%.',
'Оптимизация сетки и миниатюр: карточки ленты изолированы в RepaintBoundary для гладкого 120 FPS скролла без паразитных перерисовок, а всем каруселям, аватаркам и мозаикам заданы строгие границы кэширования.',
],
),
PrismaChange(
version: '3.6.1',
title: 'Плавная боковая панель без лагов и отключение зума колесиком',
bullets: [
'Устранение лагов боковой панели: полностью переработана анимация наведения на боковую панель на ПК. Убран тяжелый шейдерный блюр при изменении ширины и зафиксирована верстка элементов — текст больше не сжимается, не дергается и раскрывается на 120 FPS максимально плавно.',
'Отключение зума фото по колесику мыши: исключено случайное и резкое масштабирование изображений при прокрутке колесиком мыши. Масштабирование фото доступно через горячие клавиши (+, -, 0, F) или двойной клик.',
],
),
PrismaChange(
version: '3.6.0',
title: 'Редизайн интерфейса для ПК и система горячих клавиш (хоткеи)',
bullets: [
'Горячие клавиши для всех вкладок: переключение разделов по Ctrl+1..8 (и Alt+1..8), циклический переход Ctrl+Tab / Ctrl+Shift+Tab, поиск Ctrl+F, обновление Ctrl+R / F5.',
'Хоткеи видеоплеера: пауза/воспроизведение (Space, K), плавная перемотка на 5с (←/→, J/L) и 15с (Shift+←/→) с визуальными индикаторами, регулировка громкости ↑/↓, выключение звука M, полный экран F.',
'Хоткеи просмотра фото и галереи: масштабирование клавишами + / - / 0 (сброс в 100%), переключение страниц и фото в постах стрелками ← / →, быстрое сохранение Ctrl+S.',
'Окно-шпаргалка горячих клавиш: интерактивное модальное окно со всеми клавиатурными комбинациями по нажатию ? или F1, а также из меню панели.',
'Редизайн боковой панели ПК: боковое меню в стиле Liquid Glass с эффектом матового стекла, логотипом Lunaris, бейджами хоткеев, закреплением панели и быстрыми действиями.',
'Редизайн вкладок ленты: стильный сегментированный бар выбора периодов (Все время, 24ч, Неделя, Месяц, Год) с анимированными иконками и неоновые чипы источников.',
],
),
PrismaChange( PrismaChange(
version: '3.5.5', version: '3.5.5',
title: 'Сохранение последней вкладки и состояния навигации между разделами', title: 'Сохранение последней вкладки и состояния навигации между разделами',
@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:ui'; import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
@@ -1328,7 +1329,7 @@ class _FavoriteArtistsModalState extends State<_FavoriteArtistsModal> {
} }
} }
class _FavoriteArtistsSection extends ConsumerWidget { class _FavoriteArtistsSection extends StatefulWidget {
const _FavoriteArtistsSection({ const _FavoriteArtistsSection({
required this.favorites, required this.favorites,
required this.selectedKey, required this.selectedKey,
@@ -1344,8 +1345,23 @@ class _FavoriteArtistsSection extends ConsumerWidget {
final ValueChanged<FavoriteArtistItem> onRemoveFavorite; final ValueChanged<FavoriteArtistItem> onRemoveFavorite;
@override @override
Widget build(BuildContext context, WidgetRef ref) { State<_FavoriteArtistsSection> createState() =>
if (favorites.isEmpty) { _FavoriteArtistsSectionState();
}
class _FavoriteArtistsSectionState extends State<_FavoriteArtistsSection> {
final ScrollController _scrollController = ScrollController();
bool _isHovered = false;
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (widget.favorites.isEmpty) {
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB(16, 4, 16, 8), padding: const EdgeInsets.fromLTRB(16, 4, 16, 8),
child: _ArtistsLiquidCard( child: _ArtistsLiquidCard(
@@ -1368,9 +1384,9 @@ class _FavoriteArtistsSection extends ConsumerWidget {
); );
} }
final selected = favorites.firstWhere( final selected = widget.favorites.firstWhere(
(f) => f.key == selectedKey, (f) => f.key == widget.selectedKey,
orElse: () => favorites.first, orElse: () => widget.favorites.first,
); );
return Padding( return Padding(
@@ -1385,14 +1401,14 @@ class _FavoriteArtistsSection extends ConsumerWidget {
const Icon(Icons.star_rounded, color: Colors.amber, size: 20), const Icon(Icons.star_rounded, color: Colors.amber, size: 20),
const SizedBox(width: 6), const SizedBox(width: 6),
Text( Text(
'Любимые авторы (${favorites.length})', 'Любимые авторы (${widget.favorites.length})',
style: Theme.of(context).textTheme.titleSmall?.copyWith( style: Theme.of(context).textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
const Spacer(), const Spacer(),
TextButton( TextButton(
onPressed: () => onOpenArtist(selected), onPressed: () => widget.onOpenArtist(selected),
style: TextButton.styleFrom( style: TextButton.styleFrom(
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
padding: const EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric(horizontal: 8),
@@ -1409,111 +1425,136 @@ class _FavoriteArtistsSection extends ConsumerWidget {
], ],
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
SizedBox( MouseRegion(
height: 88, onEnter: (_) => _isHovered = true,
child: ListView.separated( onExit: (_) => _isHovered = false,
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4), child: Listener(
scrollDirection: Axis.horizontal, onPointerSignal: (event) {
itemCount: favorites.length, if (!_isHovered ||
separatorBuilder: (_, __) => const SizedBox(width: 10), event is! PointerScrollEvent ||
itemBuilder: (context, index) { !_scrollController.hasClients) {
final fav = favorites[index]; return;
final isSelected = fav.key == selected.key; }
final sColor = _serviceColor(fav.service); final delta = event.scrollDelta.dy != 0
? event.scrollDelta.dy
return InkWell( : event.scrollDelta.dx;
borderRadius: BorderRadius.circular(16), if (delta == 0) return;
onTap: () => onSelect(fav), final target = (_scrollController.offset + delta * 1.5).clamp(
child: AnimatedContainer( 0.0,
duration: const Duration(milliseconds: 200), _scrollController.position.maxScrollExtent,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
decoration: BoxDecoration(
color: isSelected
? Theme.of(context)
.colorScheme
.primaryContainer
.withValues(alpha: 0.45)
: Colors.transparent,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: isSelected
? Theme.of(context).colorScheme.primary
: Colors.transparent,
width: 1.5,
),
boxShadow: isSelected
? [
BoxShadow(
color: Theme.of(context)
.colorScheme
.primary
.withValues(alpha: 0.25),
blurRadius: 8,
),
]
: null,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: isSelected
? Theme.of(context).colorScheme.primary
: sColor.withValues(alpha: 0.4),
width: 1.2,
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(13),
child: fav.avatarUrl != null &&
fav.avatarUrl!.isNotEmpty
? CachedNetworkImage(
imageUrl: fav.avatarUrl!,
fit: BoxFit.cover,
placeholder: (_, __) => const Icon(
Icons.person_rounded,
size: 20),
errorWidget: (_, __, ___) => const Icon(
Icons.person_rounded,
size: 20),
)
: Center(
child: Text(
fav.name.isNotEmpty
? fav.name[0].toUpperCase()
: '?',
style: const TextStyle(
fontWeight: FontWeight.bold),
),
),
),
),
const SizedBox(height: 4),
SizedBox(
width: 68,
child: Text(
fav.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
fontWeight: isSelected
? FontWeight.bold
: FontWeight.normal,
),
),
),
],
),
),
); );
_scrollController.jumpTo(target);
}, },
child: SizedBox(
height: 88,
child: ListView.separated(
controller: _scrollController,
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
scrollDirection: Axis.horizontal,
itemCount: widget.favorites.length,
separatorBuilder: (_, __) => const SizedBox(width: 10),
itemBuilder: (context, index) {
final fav = widget.favorites[index];
final isSelected = fav.key == selected.key;
final sColor = _serviceColor(fav.service);
return InkWell(
borderRadius: BorderRadius.circular(16),
onTap: () => widget.onSelect(fav),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
decoration: BoxDecoration(
color: isSelected
? Theme.of(context)
.colorScheme
.primaryContainer
.withValues(alpha: 0.45)
: Colors.transparent,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: isSelected
? Theme.of(context).colorScheme.primary
: Colors.transparent,
width: 1.5,
),
boxShadow: isSelected
? [
BoxShadow(
color: Theme.of(context)
.colorScheme
.primary
.withValues(alpha: 0.25),
blurRadius: 8,
),
]
: null,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: isSelected
? Theme.of(context).colorScheme.primary
: sColor.withValues(alpha: 0.4),
width: 1.2,
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(13),
child: fav.avatarUrl != null &&
fav.avatarUrl!.isNotEmpty
? CachedNetworkImage(
imageUrl: fav.avatarUrl!,
memCacheWidth: 120,
memCacheHeight: 120,
fit: BoxFit.cover,
placeholder: (_, __) => const Icon(
Icons.person_rounded,
size: 20),
errorWidget: (_, __, ___) => const Icon(
Icons.person_rounded,
size: 20),
)
: Center(
child: Text(
fav.name.isNotEmpty
? fav.name[0].toUpperCase()
: '?',
style: const TextStyle(
fontWeight: FontWeight.bold),
),
),
),
),
const SizedBox(height: 4),
SizedBox(
width: 68,
child: Text(
fav.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
fontWeight: isSelected
? FontWeight.bold
: FontWeight.normal,
),
),
),
],
),
),
);
},
),
),
), ),
), ),
const SizedBox(height: 6), const SizedBox(height: 6),
@@ -1525,18 +1566,34 @@ class _FavoriteArtistsSection extends ConsumerWidget {
} }
} }
class _FavoriteArtistMediaStrip extends ConsumerWidget { class _FavoriteArtistMediaStrip extends ConsumerStatefulWidget {
const _FavoriteArtistMediaStrip({required this.artist}); const _FavoriteArtistMediaStrip({required this.artist});
final FavoriteArtistItem artist; final FavoriteArtistItem artist;
@override @override
Widget build(BuildContext context, WidgetRef ref) { ConsumerState<_FavoriteArtistMediaStrip> createState() =>
_FavoriteArtistMediaStripState();
}
class _FavoriteArtistMediaStripState
extends ConsumerState<_FavoriteArtistMediaStrip> {
final ScrollController _scrollController = ScrollController();
bool _isHovered = false;
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final query = ArtistWorkQuery( final query = ArtistWorkQuery(
providerId: artist.providerId, providerId: widget.artist.providerId,
service: artist.service, service: widget.artist.service,
artistId: artist.id, artistId: widget.artist.id,
artistName: artist.name, artistName: widget.artist.name,
); );
final asyncPosts = ref.watch(artistPostsProvider(query)); final asyncPosts = ref.watch(artistPostsProvider(query));
@@ -1564,76 +1621,101 @@ class _FavoriteArtistMediaStrip extends ConsumerWidget {
), ),
); );
} }
return SizedBox( return MouseRegion(
height: 96, onEnter: (_) => _isHovered = true,
child: ListView.separated( onExit: (_) => _isHovered = false,
scrollDirection: Axis.horizontal, child: Listener(
itemCount: posts.length.clamp(0, 15), onPointerSignal: (event) {
separatorBuilder: (_, __) => const SizedBox(width: 8), if (!_isHovered ||
itemBuilder: (context, index) { event is! PointerScrollEvent ||
final post = posts[index]; !_scrollController.hasClients) {
final isVideo = MediaUrlSelector.isVideo(post); return;
return InkWell( }
borderRadius: BorderRadius.circular(14), final delta = event.scrollDelta.dy != 0
onTap: () => AppNavigator.openPost( ? event.scrollDelta.dy
context, : event.scrollDelta.dx;
post: post, if (delta == 0) return;
postsList: posts, final target = (_scrollController.offset + delta * 1.5).clamp(
), 0.0,
child: Container( _scrollController.position.maxScrollExtent,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: Colors.white.withValues(alpha: 0.15),
width: 1.0,
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(13),
child: Stack(
children: [
SizedBox(
width: 96,
height: 96,
child: CachedNetworkImage(
imageUrl: post.previewUrl.isNotEmpty
? post.previewUrl
: post.sampleUrl,
fit: BoxFit.cover,
placeholder: (_, __) => ColoredBox(
color: Theme.of(context)
.colorScheme
.surfaceContainerHighest,
),
errorWidget: (_, __, ___) => ColoredBox(
color: Theme.of(context)
.colorScheme
.surfaceContainerHighest,
child: const Icon(Icons.broken_image_rounded,
size: 24),
),
),
),
if (isVideo)
Positioned(
bottom: 6,
right: 6,
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.7),
shape: BoxShape.circle,
),
child: const Icon(Icons.play_arrow_rounded,
color: Colors.white, size: 14),
),
),
],
),
),
),
); );
_scrollController.jumpTo(target);
}, },
child: SizedBox(
height: 96,
child: ListView.separated(
controller: _scrollController,
scrollDirection: Axis.horizontal,
itemCount: posts.length.clamp(0, 15),
separatorBuilder: (_, __) => const SizedBox(width: 8),
itemBuilder: (context, index) {
final post = posts[index];
final isVideo = MediaUrlSelector.isVideo(post);
return InkWell(
borderRadius: BorderRadius.circular(14),
onTap: () => AppNavigator.openPost(
context,
post: post,
postsList: posts,
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: Colors.white.withValues(alpha: 0.15),
width: 1.0,
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(13),
child: Stack(
children: [
SizedBox(
width: 96,
height: 96,
child: CachedNetworkImage(
imageUrl: post.previewUrl.isNotEmpty
? post.previewUrl
: post.sampleUrl,
memCacheWidth: 200,
memCacheHeight: 200,
fit: BoxFit.cover,
placeholder: (_, __) => ColoredBox(
color: Theme.of(context)
.colorScheme
.surfaceContainerHighest,
),
errorWidget: (_, __, ___) => ColoredBox(
color: Theme.of(context)
.colorScheme
.surfaceContainerHighest,
child: const Icon(Icons.broken_image_rounded,
size: 24),
),
),
),
if (isVideo)
Positioned(
bottom: 6,
right: 6,
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.7),
shape: BoxShape.circle,
),
child: const Icon(Icons.play_arrow_rounded,
color: Colors.white, size: 14),
),
),
],
),
),
),
);
},
),
),
), ),
); );
}, },
@@ -1706,6 +1788,8 @@ class _ArtistAvatar extends StatelessWidget {
? fallback ? fallback
: CachedNetworkImage( : CachedNetworkImage(
imageUrl: artist.avatarUrl!, imageUrl: artist.avatarUrl!,
memCacheWidth: 140,
memCacheHeight: 140,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => fallback, placeholder: (_, __) => fallback,
errorWidget: (_, __, ___) => fallback, errorWidget: (_, __, ___) => fallback,
@@ -314,6 +314,8 @@ class _CollectionCard extends ConsumerWidget {
if (urls.length == 1) { if (urls.length == 1) {
return CachedNetworkImage( return CachedNetworkImage(
imageUrl: urls[0], imageUrl: urls[0],
memCacheWidth: 260,
memCacheHeight: 260,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => Container(color: scheme.surfaceContainerHighest), placeholder: (_, __) => Container(color: scheme.surfaceContainerHighest),
errorWidget: (_, __, ___) => Container( errorWidget: (_, __, ___) => Container(
@@ -333,6 +335,8 @@ class _CollectionCard extends ConsumerWidget {
if (i < urls.length) if (i < urls.length)
CachedNetworkImage( CachedNetworkImage(
imageUrl: urls[i], imageUrl: urls[i],
memCacheWidth: 200,
memCacheHeight: 200,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => placeholder: (_, __) =>
Container(color: scheme.surfaceContainerHighest), Container(color: scheme.surfaceContainerHighest),
@@ -1225,6 +1225,8 @@ class _ArtistCard extends StatelessWidget {
), ),
child: CachedNetworkImage( child: CachedNetworkImage(
imageUrl: url, imageUrl: url,
memCacheWidth: 128,
memCacheHeight: 128,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => Container( placeholder: (_, __) => Container(
color: scheme.surfaceContainerHighest, color: scheme.surfaceContainerHighest,
@@ -144,7 +144,11 @@ class _FeedScreenState extends ConsumerState<FeedScreen>
return Shortcuts( return Shortcuts(
shortcuts: { shortcuts: {
LogicalKeySet(LogicalKeyboardKey.keyR): const _RefreshIntent(), LogicalKeySet(LogicalKeyboardKey.keyR): const _RandomPostIntent(),
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyR):
const _RefreshIntent(),
LogicalKeySet(LogicalKeyboardKey.f5): const _RefreshIntent(),
LogicalKeySet(LogicalKeyboardKey.keyV): const _ToggleSelectionIntent(),
LogicalKeySet(LogicalKeyboardKey.escape): const _ClearSelectionIntent(), LogicalKeySet(LogicalKeyboardKey.escape): const _ClearSelectionIntent(),
LogicalKeySet(LogicalKeyboardKey.delete): const _ClearSelectionIntent(), LogicalKeySet(LogicalKeyboardKey.delete): const _ClearSelectionIntent(),
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyA): LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyA):
@@ -158,6 +162,24 @@ class _FeedScreenState extends ConsumerState<FeedScreen>
return null; return null;
}, },
), ),
_RandomPostIntent: CallbackAction<_RandomPostIntent>(
onInvoke: (_) {
final posts = feed.value?.posts;
if (posts != null && posts.isNotEmpty) {
_openRandom(posts);
}
return null;
},
),
_ToggleSelectionIntent: CallbackAction<_ToggleSelectionIntent>(
onInvoke: (_) {
setState(() {
_selectionMode = !_selectionMode;
if (!_selectionMode) _selectedKeys.clear();
});
return null;
},
),
_ClearSelectionIntent: CallbackAction<_ClearSelectionIntent>( _ClearSelectionIntent: CallbackAction<_ClearSelectionIntent>(
onInvoke: (_) { onInvoke: (_) {
_clearSelection(); _clearSelection();
@@ -682,6 +704,14 @@ class _SelectVisibleIntent extends Intent {
const _SelectVisibleIntent(); const _SelectVisibleIntent();
} }
class _RandomPostIntent extends Intent {
const _RandomPostIntent();
}
class _ToggleSelectionIntent extends Intent {
const _ToggleSelectionIntent();
}
class _BatchActionBar extends StatelessWidget { class _BatchActionBar extends StatelessWidget {
const _BatchActionBar({ const _BatchActionBar({
required this.count, required this.count,
@@ -110,7 +110,7 @@ class _FeedToolbarState extends State<FeedToolbar> {
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
IconButton.filledTonal( IconButton.filledTonal(
tooltip: widget.selectionMode ? 'Выйти из выбора' : 'Выбрать посты', tooltip: widget.selectionMode ? 'Выйти из выбора (Esc)' : 'Выбрать посты (V)',
onPressed: widget.onToggleSelectionMode, onPressed: widget.onToggleSelectionMode,
icon: Icon(widget.selectionMode icon: Icon(widget.selectionMode
? Icons.check_box_rounded ? Icons.check_box_rounded
@@ -139,13 +139,13 @@ class _FeedToolbarState extends State<FeedToolbar> {
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
IconButton( IconButton(
tooltip: 'Обновить', tooltip: 'Обновить (Ctrl+R / F5)',
onPressed: widget.onRefresh, onPressed: widget.onRefresh,
icon: const Icon(Icons.refresh_rounded), icon: const Icon(Icons.refresh_rounded),
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
IconButton.filledTonal( IconButton.filledTonal(
tooltip: 'Случайный пост', tooltip: 'Случайный пост (R)',
onPressed: widget.onRandom, onPressed: widget.onRandom,
icon: const Icon(Icons.casino_rounded), icon: const Icon(Icons.casino_rounded),
), ),
@@ -163,41 +163,36 @@ class _FeedToolbarState extends State<FeedToolbar> {
const SizedBox(height: 8), const SizedBox(height: 8),
], ],
_HorizontalWheelScroller( _HorizontalWheelScroller(
height: 36, height: 38,
builder: (controller) => ListView( builder: (controller) => ListView(
controller: controller, controller: controller,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
primary: false, primary: false,
children: [ children: [
_LiquidPeriodTabs(
selectedPeriod: widget.topPeriodFilter,
onChanged: widget.onTopPeriodChanged,
),
const SizedBox(width: 8),
const _ToolbarDivider(),
const SizedBox(width: 8),
if (widget.providers.isNotEmpty) ...[ if (widget.providers.isNotEmpty) ...[
FilterChip( _LiquidProviderPill(
selected: widget.selectedProviderIds.isEmpty, label: 'Все источники',
label: const Text('Все источники'), isSelected: widget.selectedProviderIds.isEmpty,
onSelected: (_) => widget.onQuickProviderToggle('__all__'), icon: Icons.all_inclusive_rounded,
onTap: () => widget.onQuickProviderToggle('__all__'),
), ),
const SizedBox(width: 8), const SizedBox(width: 6),
for (final provider in widget.providers) ...[ for (final provider in widget.providers) ...[
FilterChip( _LiquidProviderPill(
selected: label: provider.name,
widget.selectedProviderIds.contains(provider.id), isSelected: widget.selectedProviderIds.contains(provider.id),
avatar: const Icon(Icons.hub_rounded, size: 15), icon: Icons.hub_rounded,
label: Text(provider.name), onTap: () => widget.onQuickProviderToggle(provider.id),
onSelected: (_) =>
widget.onQuickProviderToggle(provider.id),
), ),
const SizedBox(width: 8), const SizedBox(width: 6),
], ],
const SizedBox(width: 4),
const _ToolbarDivider(),
const SizedBox(width: 10),
],
for (final period in TopPeriodFilter.values) ...[
ChoiceChip(
selected: widget.topPeriodFilter == period,
label: Text(period.label),
onSelected: (_) => widget.onTopPeriodChanged(period),
),
const SizedBox(width: 8),
], ],
], ],
), ),
@@ -289,64 +284,56 @@ class _FeedToolbarState extends State<FeedToolbar> {
primary: false, primary: false,
children: [ children: [
if (hasActiveFilters || widget.selectedTags.isNotEmpty) ...[ if (hasActiveFilters || widget.selectedTags.isNotEmpty) ...[
ActionChip( _LiquidProviderPill(
visualDensity: VisualDensity.compact, label: 'Сбросить',
avatar: const Icon(Icons.filter_alt_off_rounded, size: 15), isSelected: false,
label: const Text('Сбросить'), icon: Icons.filter_alt_off_rounded,
onPressed: widget.onClearFilters, onTap: widget.onClearFilters,
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
], ],
ActionChip( _LiquidProviderPill(
visualDensity: VisualDensity.compact, label: 'Обновить',
avatar: const Icon(Icons.refresh_rounded, size: 15), isSelected: false,
label: const Text('Обновить'), icon: Icons.refresh_rounded,
onPressed: widget.onRefresh, onTap: widget.onRefresh,
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
const _ToolbarDivider(), const _ToolbarDivider(),
const SizedBox(width: 6), const SizedBox(width: 6),
FilterChip( _LiquidProviderPill(
visualDensity: VisualDensity.compact, label: widget.rating ?? 'Рейтинг',
selected: widget.rating != null, isSelected: widget.rating != null,
avatar: const Icon(Icons.shield_outlined, size: 15), icon: Icons.shield_outlined,
label: Text(widget.rating ?? 'Рейтинг'), onTap: widget.onRatingFilter,
onSelected: (_) => widget.onRatingFilter(),
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
const _ToolbarDivider(), const _ToolbarDivider(),
const SizedBox(width: 6), const SizedBox(width: 6),
_LiquidPeriodTabs(
selectedPeriod: widget.topPeriodFilter,
onChanged: widget.onTopPeriodChanged,
),
if (widget.providers.isNotEmpty) ...[ if (widget.providers.isNotEmpty) ...[
FilterChip( const SizedBox(width: 6),
visualDensity: VisualDensity.compact, const _ToolbarDivider(),
selected: widget.selectedProviderIds.isEmpty, const SizedBox(width: 6),
label: const Text('Все'), _LiquidProviderPill(
onSelected: (_) => widget.onQuickProviderToggle('__all__'), label: 'Все',
isSelected: widget.selectedProviderIds.isEmpty,
icon: Icons.all_inclusive_rounded,
onTap: () => widget.onQuickProviderToggle('__all__'),
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
for (final provider in widget.providers) ...[ for (final provider in widget.providers) ...[
FilterChip( _LiquidProviderPill(
visualDensity: VisualDensity.compact, label: provider.name,
selected: isSelected: widget.selectedProviderIds.contains(provider.id),
widget.selectedProviderIds.contains(provider.id), icon: Icons.hub_rounded,
label: Text(provider.name), onTap: () => widget.onQuickProviderToggle(provider.id),
onSelected: (_) =>
widget.onQuickProviderToggle(provider.id),
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
], ],
const SizedBox(width: 2),
const _ToolbarDivider(),
const SizedBox(width: 6),
],
for (final period in TopPeriodFilter.values) ...[
ChoiceChip(
visualDensity: VisualDensity.compact,
selected: widget.topPeriodFilter == period,
label: Text(period.label),
onSelected: (_) => widget.onTopPeriodChanged(period),
),
const SizedBox(width: 6),
], ],
], ],
), ),
@@ -371,6 +358,227 @@ class _ToolbarDivider extends StatelessWidget {
} }
} }
class _LiquidPeriodTabs extends StatelessWidget {
const _LiquidPeriodTabs({
required this.selectedPeriod,
required this.onChanged,
});
final TopPeriodFilter selectedPeriod;
final ValueChanged<TopPeriodFilter> onChanged;
IconData _iconFor(TopPeriodFilter period) {
return switch (period) {
TopPeriodFilter.none => Icons.auto_awesome_rounded,
TopPeriodFilter.month => Icons.calendar_month_rounded,
TopPeriodFilter.year => Icons.calendar_today_rounded,
TopPeriodFilter.allTime => Icons.workspace_premium_rounded,
};
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final isDark = theme.brightness == Brightness.dark;
return Container(
padding: const EdgeInsets.all(2.5),
decoration: BoxDecoration(
color: isDark
? scheme.surfaceContainerHigh.withValues(alpha: 0.55)
: scheme.surfaceContainerHighest.withValues(alpha: 0.45),
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: isDark
? Colors.white.withValues(alpha: 0.1)
: Colors.black.withValues(alpha: 0.06),
width: 1,
),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
for (final period in TopPeriodFilter.values) ...[
_LiquidPeriodTabItem(
period: period,
icon: _iconFor(period),
isSelected: selectedPeriod == period,
onTap: () => onChanged(period),
),
if (period != TopPeriodFilter.values.last) const SizedBox(width: 3),
],
],
),
);
}
}
class _LiquidPeriodTabItem extends StatelessWidget {
const _LiquidPeriodTabItem({
required this.period,
required this.icon,
required this.isSelected,
required this.onTap,
});
final TopPeriodFilter period;
final IconData icon;
final bool isSelected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final isDark = theme.brightness == Brightness.dark;
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(13),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeOutCubic,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: isSelected
? (isDark
? scheme.primary.withValues(alpha: 0.28)
: scheme.primaryContainer.withValues(alpha: 0.85))
: Colors.transparent,
borderRadius: BorderRadius.circular(13),
border: isSelected
? Border.all(
color: scheme.primary.withValues(alpha: isDark ? 0.45 : 0.3),
width: 1,
)
: null,
boxShadow: isSelected
? [
BoxShadow(
color: scheme.primary.withValues(alpha: isDark ? 0.25 : 0.12),
blurRadius: 8,
offset: const Offset(0, 2),
),
]
: null,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
icon,
size: 14,
color: isSelected
? (isDark ? scheme.primary : scheme.onPrimaryContainer)
: scheme.onSurfaceVariant.withValues(alpha: 0.85),
),
const SizedBox(width: 6),
Text(
period.label,
style: TextStyle(
fontSize: 12,
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500,
color: isSelected
? (isDark ? scheme.primary : scheme.onPrimaryContainer)
: scheme.onSurfaceVariant,
),
),
],
),
),
),
);
}
}
class _LiquidProviderPill extends StatelessWidget {
const _LiquidProviderPill({
required this.label,
required this.isSelected,
required this.onTap,
this.icon,
});
final String label;
final bool isSelected;
final VoidCallback onTap;
final IconData? icon;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final isDark = theme.brightness == Brightness.dark;
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(14),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeOutCubic,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: isSelected
? (isDark
? scheme.secondaryContainer.withValues(alpha: 0.35)
: scheme.secondaryContainer.withValues(alpha: 0.7))
: (isDark
? scheme.surfaceContainerHigh.withValues(alpha: 0.4)
: scheme.surfaceContainerHighest.withValues(alpha: 0.35)),
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: isSelected
? scheme.secondary.withValues(alpha: isDark ? 0.6 : 0.4)
: (isDark
? Colors.white.withValues(alpha: 0.08)
: Colors.black.withValues(alpha: 0.05)),
width: 1,
),
boxShadow: isSelected
? [
BoxShadow(
color: scheme.secondary.withValues(alpha: isDark ? 0.2 : 0.08),
blurRadius: 6,
),
]
: null,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (icon != null) ...[
Icon(
icon,
size: 14,
color: isSelected
? (isDark ? scheme.secondary : scheme.onSecondaryContainer)
: scheme.onSurfaceVariant.withValues(alpha: 0.8),
),
const SizedBox(width: 5),
],
Text(
label,
style: TextStyle(
fontSize: 12,
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500,
color: isSelected
? (isDark ? scheme.secondary : scheme.onSecondaryContainer)
: scheme.onSurfaceVariant,
),
),
],
),
),
),
);
}
}
class _HorizontalWheelScroller extends StatefulWidget { class _HorizontalWheelScroller extends StatefulWidget {
const _HorizontalWheelScroller({ const _HorizontalWheelScroller({
required this.builder, required this.builder,
@@ -172,6 +172,8 @@ class PostDetailsScreen extends ConsumerWidget {
LogicalKeySet(LogicalKeyboardKey.keyC): LogicalKeySet(LogicalKeyboardKey.keyC):
const _AddCollectionIntent(), const _AddCollectionIntent(),
LogicalKeySet(LogicalKeyboardKey.keyS): const _DownloadIntent(), LogicalKeySet(LogicalKeyboardKey.keyS): const _DownloadIntent(),
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyS):
const _DownloadIntent(),
LogicalKeySet(LogicalKeyboardKey.escape): const _CloseIntent(), LogicalKeySet(LogicalKeyboardKey.escape): const _CloseIntent(),
}, },
child: Actions( child: Actions(
@@ -1153,6 +1155,8 @@ class _NeighborStrip extends StatelessWidget {
imageUrl: post.previewUrl.isNotEmpty imageUrl: post.previewUrl.isNotEmpty
? post.previewUrl ? post.previewUrl
: post.sampleUrl, : post.sampleUrl,
memCacheWidth: 160,
memCacheHeight: 160,
fit: BoxFit.cover, fit: BoxFit.cover,
errorWidget: (_, __, ___) => errorWidget: (_, __, ___) =>
const Center(child: Icon(Icons.broken_image_rounded)), const Center(child: Icon(Icons.broken_image_rounded)),
@@ -78,6 +78,8 @@ class _PostMediaViewerState extends State<PostMediaViewer>
String? _videoError; String? _videoError;
bool _retriedFormatError = false; bool _retriedFormatError = false;
bool _softwareDecodingFallback = false; bool _softwareDecodingFallback = false;
late bool _useSoftwareDecoding =
Platform.isLinux || Platform.isWindows || Platform.isMacOS;
Timer? _hideTimer; Timer? _hideTimer;
StreamSubscription<String>? _errorSubscription; StreamSubscription<String>? _errorSubscription;
StreamSubscription<Duration>? _positionSubscription; StreamSubscription<Duration>? _positionSubscription;
@@ -109,6 +111,8 @@ class _PostMediaViewerState extends State<PostMediaViewer>
_videoError = null; _videoError = null;
_retriedFormatError = false; _retriedFormatError = false;
_softwareDecodingFallback = false; _softwareDecodingFallback = false;
_useSoftwareDecoding =
Platform.isLinux || Platform.isWindows || Platform.isMacOS;
_imageUrls = _buildImageUrls(widget.post); _imageUrls = _buildImageUrls(widget.post);
_videoUrls = _buildVideoUrls(widget.post); _videoUrls = _buildVideoUrls(widget.post);
if (_isPlayableMedia(widget.post) && _videoUrls.isNotEmpty) { if (_isPlayableMedia(widget.post) && _videoUrls.isNotEmpty) {
@@ -226,6 +230,11 @@ class _PostMediaViewerState extends State<PostMediaViewer>
aspectRatio: widget.post.width > 0 && widget.post.height > 0 aspectRatio: widget.post.width > 0 && widget.post.height > 0
? widget.post.width / widget.post.height ? widget.post.width / widget.post.height
: 16 / 9, : 16 / 9,
previewUrl: widget.post.previewUrl.isNotEmpty
? widget.post.previewUrl
: widget.post.sampleUrl,
isSoftwareDecoding: _useSoftwareDecoding,
onToggleDecoder: _toggleDecoderMode,
controlsVisible: _controlsVisible, controlsVisible: _controlsVisible,
coverVideo: _coverVideo, coverVideo: _coverVideo,
muted: _muted, muted: _muted,
@@ -317,10 +326,16 @@ class _PostMediaViewerState extends State<PostMediaViewer>
), ),
); );
} else { } else {
final mq = MediaQuery.maybeOf(context);
final dpr = mq?.devicePixelRatio ?? 1.5;
final screenWidth = mq?.size.width ?? 1280;
final maxCacheWidth =
(screenWidth * dpr * 1.5).round().clamp(1080, 2560);
image = CachedNetworkImage( image = CachedNetworkImage(
key: ValueKey(url), key: ValueKey(url),
imageUrl: url, imageUrl: url,
httpHeaders: headers, httpHeaders: headers,
memCacheWidth: maxCacheWidth,
fit: BoxFit.contain, fit: BoxFit.contain,
placeholder: (context, url) => placeholder: (context, url) =>
const Center(child: CircularProgressIndicator()), const Center(child: CircularProgressIndicator()),
@@ -383,16 +398,54 @@ class _PostMediaViewerState extends State<PostMediaViewer>
), ),
], ],
); );
final interactiveChild = _imageUrls.length > 1
? Shortcuts(
shortcuts: {
LogicalKeySet(LogicalKeyboardKey.arrowLeft):
const _PrevImageIntent(),
LogicalKeySet(LogicalKeyboardKey.keyA): const _PrevImageIntent(),
LogicalKeySet(LogicalKeyboardKey.arrowRight):
const _NextImageIntent(),
LogicalKeySet(LogicalKeyboardKey.keyD): const _NextImageIntent(),
},
child: Actions(
actions: {
_PrevImageIntent: CallbackAction<_PrevImageIntent>(
onInvoke: (_) {
if (_imageIndex > 0) {
setState(() => _imageIndex--);
}
return null;
},
),
_NextImageIntent: CallbackAction<_NextImageIntent>(
onInvoke: (_) {
if (_imageIndex < _imageUrls.length - 1) {
setState(() => _imageIndex++);
}
return null;
},
),
},
child: Focus(
autofocus: true,
child: child,
),
),
)
: child;
return LayoutBuilder( return LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
if (constraints.hasBoundedWidth && constraints.hasBoundedHeight) { if (constraints.hasBoundedWidth && constraints.hasBoundedHeight) {
return SizedBox( return SizedBox(
width: constraints.maxWidth, width: constraints.maxWidth,
height: constraints.maxHeight, height: constraints.maxHeight,
child: child, child: interactiveChild,
); );
} }
return child; return interactiveChild;
}, },
); );
} }
@@ -400,11 +453,12 @@ class _PostMediaViewerState extends State<PostMediaViewer>
void _initializeVideo() { void _initializeVideo() {
MediaKit.ensureInitialized(); MediaKit.ensureInitialized();
_player = Player(); _player = Player();
final bool enableHw = !_useSoftwareDecoding && !_softwareDecodingFallback;
_controller = VideoController( _controller = VideoController(
_player!, _player!,
configuration: VideoControllerConfiguration( configuration: VideoControllerConfiguration(
enableHardwareAcceleration: !_softwareDecodingFallback, enableHardwareAcceleration: enableHw,
hwdec: _softwareDecodingFallback ? 'no' : 'auto-safe', hwdec: enableHw ? (Platform.isAndroid ? 'auto-safe' : 'auto') : 'no',
), ),
); );
_applyVolume(); _applyVolume();
@@ -479,6 +533,7 @@ class _PostMediaViewerState extends State<PostMediaViewer>
lower.contains('failed to recognize file format'))) { lower.contains('failed to recognize file format'))) {
_retriedFormatError = true; _retriedFormatError = true;
_softwareDecodingFallback = true; _softwareDecodingFallback = true;
_useSoftwareDecoding = true;
_disposeVideo(); _disposeVideo();
await Future<void>.delayed(const Duration(milliseconds: 250)); await Future<void>.delayed(const Duration(milliseconds: 250));
if (mounted) { if (mounted) {
@@ -496,6 +551,7 @@ class _PostMediaViewerState extends State<PostMediaViewer>
_videoIndex = 0; _videoIndex = 0;
_retriedFormatError = false; _retriedFormatError = false;
_softwareDecodingFallback = true; _softwareDecodingFallback = true;
_useSoftwareDecoding = true;
_disposeVideo(); _disposeVideo();
await Future<void>.delayed(const Duration(milliseconds: 150)); await Future<void>.delayed(const Duration(milliseconds: 150));
if (mounted) { if (mounted) {
@@ -503,6 +559,26 @@ class _PostMediaViewerState extends State<PostMediaViewer>
} }
} }
void _toggleDecoderMode() {
setState(() {
_useSoftwareDecoding = !_useSoftwareDecoding;
_softwareDecodingFallback = false;
_retriedFormatError = false;
});
_disposeVideo();
_initializeVideo();
ScaffoldMessenger.maybeOf(context)?.showSnackBar(
SnackBar(
content: Text(
_useSoftwareDecoding
? 'Включено программное декодирование (S/W)'
: 'Включено аппаратное декодирование (H/W)',
),
duration: const Duration(seconds: 2),
),
);
}
void _disposeVideo() { void _disposeVideo() {
_hideTimer?.cancel(); _hideTimer?.cancel();
_errorSubscription?.cancel(); _errorSubscription?.cancel();
@@ -644,6 +720,11 @@ class _PostMediaViewerState extends State<PostMediaViewer>
halfVolume: _halfVolume, halfVolume: _halfVolume,
coverVideo: _coverVideo, coverVideo: _coverVideo,
initialVolume: _currentVolume, initialVolume: _currentVolume,
previewUrl: widget.post.previewUrl.isNotEmpty
? widget.post.previewUrl
: widget.post.sampleUrl,
isSoftwareDecoding: _useSoftwareDecoding,
onToggleDecoder: _toggleDecoderMode,
errorMessage: _videoError, errorMessage: _videoError,
onRetry: _retryVideo, onRetry: _retryVideo,
onChanged: (snapshot) { onChanged: (snapshot) {
@@ -739,6 +820,48 @@ class _TogglePlayIntent extends Intent {
const _TogglePlayIntent(); const _TogglePlayIntent();
} }
class _SeekVideoIntent extends Intent {
const _SeekVideoIntent(this.seconds);
final int seconds;
}
class _VolumeVideoIntent extends Intent {
const _VolumeVideoIntent(this.deltaY);
final double deltaY;
}
class _MuteVideoIntent extends Intent {
const _MuteVideoIntent();
}
class _FullscreenVideoIntent extends Intent {
const _FullscreenVideoIntent();
}
class _LoopVideoIntent extends Intent {
const _LoopVideoIntent();
}
class _ZoomInIntent extends Intent {
const _ZoomInIntent();
}
class _ZoomOutIntent extends Intent {
const _ZoomOutIntent();
}
class _ResetZoomIntent extends Intent {
const _ResetZoomIntent();
}
class _PrevImageIntent extends Intent {
const _PrevImageIntent();
}
class _NextImageIntent extends Intent {
const _NextImageIntent();
}
class _UnsupportedSwfPanel extends StatelessWidget { class _UnsupportedSwfPanel extends StatelessWidget {
const _UnsupportedSwfPanel(); const _UnsupportedSwfPanel();
@@ -798,6 +921,9 @@ class _FullscreenVideoPage extends StatefulWidget {
required this.halfVolume, required this.halfVolume,
required this.coverVideo, required this.coverVideo,
this.initialVolume = 100.0, this.initialVolume = 100.0,
this.previewUrl,
required this.isSoftwareDecoding,
required this.onToggleDecoder,
required this.errorMessage, required this.errorMessage,
required this.onRetry, required this.onRetry,
required this.onChanged, required this.onChanged,
@@ -812,6 +938,9 @@ class _FullscreenVideoPage extends StatefulWidget {
final bool halfVolume; final bool halfVolume;
final bool coverVideo; final bool coverVideo;
final double initialVolume; final double initialVolume;
final String? previewUrl;
final bool isSoftwareDecoding;
final VoidCallback onToggleDecoder;
final String? errorMessage; final String? errorMessage;
final VoidCallback onRetry; final VoidCallback onRetry;
final ValueChanged<VideoPlaybackSnapshot> onChanged; final ValueChanged<VideoPlaybackSnapshot> onChanged;
@@ -911,6 +1040,8 @@ class _FullscreenVideoPageState extends State<_FullscreenVideoPage> {
shortcuts: { shortcuts: {
LogicalKeySet(LogicalKeyboardKey.escape): const _CloseVideoIntent(), LogicalKeySet(LogicalKeyboardKey.escape): const _CloseVideoIntent(),
LogicalKeySet(LogicalKeyboardKey.space): const _TogglePlayIntent(), LogicalKeySet(LogicalKeyboardKey.space): const _TogglePlayIntent(),
LogicalKeySet(LogicalKeyboardKey.keyK): const _TogglePlayIntent(),
LogicalKeySet(LogicalKeyboardKey.keyF): const _CloseVideoIntent(),
}, },
child: Actions( child: Actions(
actions: { actions: {
@@ -934,6 +1065,9 @@ class _FullscreenVideoPageState extends State<_FullscreenVideoPage> {
player: widget.player, player: widget.player,
controller: widget.controller, controller: widget.controller,
aspectRatio: widget.aspectRatio, aspectRatio: widget.aspectRatio,
previewUrl: widget.previewUrl,
isSoftwareDecoding: widget.isSoftwareDecoding,
onToggleDecoder: widget.onToggleDecoder,
controlsVisible: _controlsVisible, controlsVisible: _controlsVisible,
coverVideo: _coverVideo, coverVideo: _coverVideo,
muted: _muted, muted: _muted,
@@ -1485,6 +1619,9 @@ class _VideoSurface extends StatefulWidget {
required this.player, required this.player,
required this.controller, required this.controller,
required this.aspectRatio, required this.aspectRatio,
this.previewUrl,
required this.isSoftwareDecoding,
required this.onToggleDecoder,
required this.controlsVisible, required this.controlsVisible,
required this.coverVideo, required this.coverVideo,
required this.muted, required this.muted,
@@ -1509,6 +1646,9 @@ class _VideoSurface extends StatefulWidget {
final Player player; final Player player;
final VideoController controller; final VideoController controller;
final double aspectRatio; final double aspectRatio;
final String? previewUrl;
final bool isSoftwareDecoding;
final VoidCallback onToggleDecoder;
final bool controlsVisible; final bool controlsVisible;
final bool coverVideo; final bool coverVideo;
final bool muted; final bool muted;
@@ -1667,15 +1807,22 @@ class _VideoSurfaceState extends State<_VideoSurface> {
return Stack( return Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
ColoredBox( if (widget.previewUrl != null && widget.previewUrl!.isNotEmpty)
color: Colors.black, Positioned.fill(
child: Video( child: CachedNetworkImage(
controller: widget.controller, imageUrl: widget.previewUrl!,
fit: widget.coverVideo ? BoxFit.cover : BoxFit.contain, fit: widget.coverVideo ? BoxFit.cover : BoxFit.contain,
controls: null, memCacheWidth: 1920,
pauseUponEnteringBackgroundMode: false, memCacheHeight: 1080,
resumeUponEnteringForegroundMode: false, ),
), ),
Video(
controller: widget.controller,
fit: widget.coverVideo ? BoxFit.cover : BoxFit.contain,
fill: Colors.transparent,
controls: null,
pauseUponEnteringBackgroundMode: false,
resumeUponEnteringForegroundMode: false,
), ),
if (_currentBrightness < 0.99) if (_currentBrightness < 0.99)
Positioned.fill( Positioned.fill(
@@ -1754,6 +1901,8 @@ class _VideoSurfaceState extends State<_VideoSurface> {
fullscreen: widget.fullscreen, fullscreen: widget.fullscreen,
isLocked: _isLocked, isLocked: _isLocked,
isLandscape: widget.isLandscape, isLandscape: widget.isLandscape,
isSoftwareDecoding: widget.isSoftwareDecoding,
onToggleDecoder: widget.onToggleDecoder,
onToggleOrientation: widget.onToggleOrientation, onToggleOrientation: widget.onToggleOrientation,
onToggleLock: () => setState(() => _isLocked = !_isLocked), onToggleLock: () => setState(() => _isLocked = !_isLocked),
onToggleFit: widget.onToggleFit, onToggleFit: widget.onToggleFit,
@@ -1771,16 +1920,87 @@ class _VideoSurfaceState extends State<_VideoSurface> {
}, },
); );
return MouseRegion( return Shortcuts(
onHover: (_) => widget.onInteract(), shortcuts: {
child: ClipRRect( LogicalKeySet(LogicalKeyboardKey.space): const _TogglePlayIntent(),
borderRadius: BorderRadius.circular(widget.fullscreen ? 0 : 10), LogicalKeySet(LogicalKeyboardKey.keyK): const _TogglePlayIntent(),
child: widget.fullscreen LogicalKeySet(LogicalKeyboardKey.arrowLeft): const _SeekVideoIntent(-5),
? SizedBox.expand(child: child) LogicalKeySet(LogicalKeyboardKey.keyJ): const _SeekVideoIntent(-5),
: AspectRatio( LogicalKeySet(LogicalKeyboardKey.arrowRight): const _SeekVideoIntent(5),
aspectRatio: widget.aspectRatio.clamp(0.35, 2.4), LogicalKeySet(LogicalKeyboardKey.keyL): const _SeekVideoIntent(5),
child: child, LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.arrowLeft):
), const _SeekVideoIntent(-15),
LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.arrowRight):
const _SeekVideoIntent(15),
LogicalKeySet(LogicalKeyboardKey.arrowUp): const _VolumeVideoIntent(-10),
LogicalKeySet(LogicalKeyboardKey.arrowDown): const _VolumeVideoIntent(10),
LogicalKeySet(LogicalKeyboardKey.keyM): const _MuteVideoIntent(),
LogicalKeySet(LogicalKeyboardKey.keyF): const _FullscreenVideoIntent(),
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyL):
const _LoopVideoIntent(),
},
child: Actions(
actions: {
_TogglePlayIntent: CallbackAction<_TogglePlayIntent>(
onInvoke: (_) {
if (widget.player.state.playing) {
widget.player.pause();
} else {
if (widget.player.state.completed) {
widget.player.seek(Duration.zero);
}
widget.player.play();
}
widget.onInteract();
return null;
},
),
_SeekVideoIntent: CallbackAction<_SeekVideoIntent>(
onInvoke: (intent) {
_seekBy(Duration(seconds: intent.seconds));
return null;
},
),
_VolumeVideoIntent: CallbackAction<_VolumeVideoIntent>(
onInvoke: (intent) {
_adjustVolume(intent.deltaY);
return null;
},
),
_MuteVideoIntent: CallbackAction<_MuteVideoIntent>(
onInvoke: (_) {
widget.onToggleMute();
return null;
},
),
_FullscreenVideoIntent: CallbackAction<_FullscreenVideoIntent>(
onInvoke: (_) {
widget.onFullscreen();
return null;
},
),
_LoopVideoIntent: CallbackAction<_LoopVideoIntent>(
onInvoke: (_) {
widget.onToggleLoop();
return null;
},
),
},
child: Focus(
autofocus: true,
child: MouseRegion(
onHover: (_) => widget.onInteract(),
child: ClipRRect(
borderRadius: BorderRadius.circular(widget.fullscreen ? 0 : 10),
child: widget.fullscreen
? SizedBox.expand(child: child)
: AspectRatio(
aspectRatio: widget.aspectRatio.clamp(0.35, 2.4),
child: child,
),
),
),
),
), ),
); );
} }
@@ -1959,80 +2179,133 @@ class _ZoomableImageState extends State<_ZoomableImage> {
super.dispose(); super.dispose();
} }
void _zoomIn() {
final currentScale = _controller.value.getMaxScaleOnAxis();
final newScale = (currentScale * 1.35).clamp(1.0, 6.0);
_controller.value = Matrix4.identity()..scaleByDouble(newScale, newScale, 1, 1);
if (mounted) setState(() => _zoomed = newScale > 1.02);
_setLocked(_zoomed);
}
void _zoomOut() {
final currentScale = _controller.value.getMaxScaleOnAxis();
final newScale = (currentScale / 1.35).clamp(1.0, 6.0);
if (newScale <= 1.02) {
_controller.value = Matrix4.identity();
if (mounted) setState(() => _zoomed = false);
_setLocked(false);
} else {
_controller.value = Matrix4.identity()..scaleByDouble(newScale, newScale, 1, 1);
if (mounted) setState(() => _zoomed = true);
_setLocked(true);
}
}
void _resetZoom() {
_controller.value = Matrix4.identity();
if (mounted) setState(() => _zoomed = false);
_setLocked(false);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return LayoutBuilder( return Shortcuts(
builder: (context, constraints) { shortcuts: {
final hasFrame = LogicalKeySet(LogicalKeyboardKey.equal): const _ZoomInIntent(),
constraints.hasBoundedWidth && constraints.hasBoundedHeight; LogicalKeySet(LogicalKeyboardKey.add): const _ZoomInIntent(),
final child = hasFrame LogicalKeySet(LogicalKeyboardKey.numpadAdd): const _ZoomInIntent(),
? SizedBox( LogicalKeySet(LogicalKeyboardKey.minus): const _ZoomOutIntent(),
width: constraints.maxWidth, LogicalKeySet(LogicalKeyboardKey.numpadSubtract): const _ZoomOutIntent(),
height: constraints.maxHeight, LogicalKeySet(LogicalKeyboardKey.digit0): const _ResetZoomIntent(),
child: widget.child, LogicalKeySet(LogicalKeyboardKey.numpad0): const _ResetZoomIntent(),
) LogicalKeySet(LogicalKeyboardKey.escape): const _ResetZoomIntent(),
: widget.child;
return Listener(
onPointerSignal: (signal) {
if (signal is PointerScrollEvent) {
final scaleDelta = signal.scrollDelta.dy < 0 ? 1.15 : 0.85;
final currentScale = _controller.value.getMaxScaleOnAxis();
final newScale = (currentScale * scaleDelta).clamp(1.0, 6.0);
if (newScale <= 1.02) {
_controller.value = Matrix4.identity();
if (mounted) setState(() => _zoomed = false);
_setLocked(false);
} else {
final focalPoint = signal.localPosition;
_controller.value = Matrix4.identity()
..translateByDouble(
-focalPoint.dx * (newScale - 1),
-focalPoint.dy * (newScale - 1),
0,
1)
..scaleByDouble(newScale, newScale, 1, 1);
if (mounted) setState(() => _zoomed = true);
_setLocked(true);
}
}
},
onPointerDown: (_) {
_pointerCount++;
if (_pointerCount >= 2 || _zoomed) {
_setLocked(true);
}
},
onPointerUp: (_) => _releasePointer(),
onPointerCancel: (_) => _releasePointer(),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onDoubleTapDown: (details) => _doubleTapDetails = details,
onDoubleTap: _toggleZoom,
child: InteractiveViewer(
transformationController: _controller,
minScale: 1,
maxScale: 6,
boundaryMargin: const EdgeInsets.all(160),
panEnabled: _zoomed,
scaleEnabled: true,
clipBehavior: Clip.none,
onInteractionStart: (_) {
if (_pointerCount >= 2 || _zoomed) _setLocked(true);
},
onInteractionEnd: (_) {
final scale = _controller.value.getMaxScaleOnAxis();
final nextZoomed = scale > 1.03;
if (!nextZoomed) {
_controller.value = Matrix4.identity();
}
if (mounted) setState(() => _zoomed = nextZoomed);
_setLocked(nextZoomed || _pointerCount >= 2);
},
child: child,
),
),
);
}, },
child: Actions(
actions: {
_ZoomInIntent: CallbackAction<_ZoomInIntent>(
onInvoke: (_) {
_zoomIn();
return null;
},
),
_ZoomOutIntent: CallbackAction<_ZoomOutIntent>(
onInvoke: (_) {
_zoomOut();
return null;
},
),
_ResetZoomIntent: CallbackAction<_ResetZoomIntent>(
onInvoke: (_) {
if (_zoomed) {
_resetZoom();
}
return null;
},
),
},
child: Focus(
autofocus: true,
child: LayoutBuilder(
builder: (context, constraints) {
final hasFrame =
constraints.hasBoundedWidth && constraints.hasBoundedHeight;
final child = hasFrame
? SizedBox(
width: constraints.maxWidth,
height: constraints.maxHeight,
child: widget.child,
)
: widget.child;
return Listener(
onPointerDown: (_) {
_pointerCount++;
if (_pointerCount >= 2 || _zoomed) {
_setLocked(true);
}
},
onPointerUp: (_) => _releasePointer(),
onPointerCancel: (_) => _releasePointer(),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onDoubleTapDown: (details) => _doubleTapDetails = details,
onDoubleTap: _toggleZoom,
child: InteractiveViewer(
transformationController: _controller,
minScale: 1,
maxScale: 6,
scaleFactor: 1000000.0,
boundaryMargin: const EdgeInsets.all(160),
panEnabled: _zoomed,
scaleEnabled: true,
clipBehavior: Clip.none,
onInteractionStart: (_) {
if (_pointerCount >= 2 || _zoomed) _setLocked(true);
},
onInteractionEnd: (_) {
final scale = _controller.value.getMaxScaleOnAxis();
final nextZoomed = scale > 1.03;
if (!nextZoomed) {
_controller.value = Matrix4.identity();
}
if (mounted) setState(() => _zoomed = nextZoomed);
_setLocked(nextZoomed || _pointerCount >= 2);
},
child: Listener(
onPointerSignal: (event) {
if (event is PointerScrollEvent) {
GestureBinding.instance.pointerSignalResolver
.register(event, (_) {});
}
},
child: child,
),
),
),
);
},
),
),
),
); );
} }
@@ -2441,6 +2714,8 @@ class _VideoControls extends StatefulWidget {
required this.fullscreen, required this.fullscreen,
required this.isLocked, required this.isLocked,
this.isLandscape, this.isLandscape,
required this.isSoftwareDecoding,
required this.onToggleDecoder,
this.onToggleOrientation, this.onToggleOrientation,
required this.onToggleLock, required this.onToggleLock,
required this.onToggleFit, required this.onToggleFit,
@@ -2460,6 +2735,8 @@ class _VideoControls extends StatefulWidget {
final bool fullscreen; final bool fullscreen;
final bool isLocked; final bool isLocked;
final bool? isLandscape; final bool? isLandscape;
final bool isSoftwareDecoding;
final VoidCallback onToggleDecoder;
final VoidCallback? onToggleOrientation; final VoidCallback? onToggleOrientation;
final VoidCallback onToggleLock; final VoidCallback onToggleLock;
final VoidCallback onToggleFit; final VoidCallback onToggleFit;
@@ -2559,6 +2836,17 @@ class _VideoControlsState extends State<_VideoControls> {
onPressed: widget.onToggleLock, onPressed: widget.onToggleLock,
), ),
const Spacer(), const Spacer(),
_RoundControlButton(
tooltip: widget.isSoftwareDecoding
? 'Декодер: S/W (программный). Нажмите для переключения на H/W'
: 'Декодер: H/W (аппаратный). Нажмите для переключения на S/W',
selected: !widget.isSoftwareDecoding,
icon: widget.isSoftwareDecoding
? Icons.memory_rounded
: Icons.speed_rounded,
onPressed: widget.onToggleDecoder,
),
const SizedBox(width: 8),
_SpeedBadgeButton( _SpeedBadgeButton(
currentRate: currentRate, currentRate: currentRate,
onSelected: (newRate) => widget.player.setRate(newRate), onSelected: (newRate) => widget.player.setRate(newRate),
@@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart' hide appBuildNumber; import 'package:flutter/services.dart' hide appBuildNumber;
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -1439,7 +1440,7 @@ class _SettingsIconBadge extends StatelessWidget {
} }
} }
class _CategoryQuickNav extends StatelessWidget { class _CategoryQuickNav extends StatefulWidget {
const _CategoryQuickNav({ const _CategoryQuickNav({
required this.categories, required this.categories,
required this.onSelect, required this.onSelect,
@@ -1449,103 +1450,143 @@ class _CategoryQuickNav extends StatelessWidget {
categories; categories;
final ValueChanged<GlobalKey> onSelect; final ValueChanged<GlobalKey> onSelect;
@override
State<_CategoryQuickNav> createState() => _CategoryQuickNavState();
}
class _CategoryQuickNavState extends State<_CategoryQuickNav> {
final ScrollController _scrollController = ScrollController();
bool _isHovered = false;
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark; final isDark = theme.brightness == Brightness.dark;
return SizedBox( return MouseRegion(
height: 44, onEnter: (_) => _isHovered = true,
child: ListView.separated( onExit: (_) => _isHovered = false,
padding: const EdgeInsets.symmetric(horizontal: 16), child: Listener(
scrollDirection: Axis.horizontal, onPointerSignal: (event) {
itemCount: categories.length, if (!_isHovered ||
separatorBuilder: (_, __) => const SizedBox(width: 8), event is! PointerScrollEvent ||
itemBuilder: (context, index) { !_scrollController.hasClients) {
final cat = categories[index]; return;
return Container( }
decoration: BoxDecoration( final delta = event.scrollDelta.dy != 0
borderRadius: BorderRadius.circular(22), ? event.scrollDelta.dy
boxShadow: [ : event.scrollDelta.dx;
BoxShadow( if (delta == 0) return;
color: isDark final target = (_scrollController.offset + delta * 1.5).clamp(
? Colors.black.withValues(alpha: 0.25) 0.0,
: cat.color.withValues(alpha: 0.12), _scrollController.position.maxScrollExtent,
blurRadius: 8, );
offset: const Offset(0, 2.5), _scrollController.jumpTo(target);
},
child: SizedBox(
height: 44,
child: ListView.separated(
controller: _scrollController,
padding: const EdgeInsets.symmetric(horizontal: 16),
scrollDirection: Axis.horizontal,
itemCount: widget.categories.length,
separatorBuilder: (_, __) => const SizedBox(width: 8),
itemBuilder: (context, index) {
final cat = widget.categories[index];
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22),
boxShadow: [
BoxShadow(
color: isDark
? Colors.black.withValues(alpha: 0.25)
: cat.color.withValues(alpha: 0.12),
blurRadius: 8,
offset: const Offset(0, 2.5),
),
],
), ),
], child: ClipRRect(
), borderRadius: BorderRadius.circular(22),
child: ClipRRect( child: BackdropFilter(
borderRadius: BorderRadius.circular(22), filter: ImageFilter.blur(sigmaX: 16, sigmaY: 16),
child: BackdropFilter( child: Material(
filter: ImageFilter.blur(sigmaX: 16, sigmaY: 16), color: isDark
child: Material( ? theme.colorScheme.surfaceContainerHigh
color: isDark .withValues(alpha: 0.60)
? theme.colorScheme.surfaceContainerHigh.withValues(alpha: 0.60) : Colors.white.withValues(alpha: 0.82),
: Colors.white.withValues(alpha: 0.82), child: InkWell(
child: InkWell(
borderRadius: BorderRadius.circular(22),
onTap: () {
HapticFeedback.selectionClick();
onSelect(cat.key);
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 7),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22), borderRadius: BorderRadius.circular(22),
border: Border.all( onTap: () {
color: isDark HapticFeedback.selectionClick();
? Colors.white.withValues(alpha: 0.18) widget.onSelect(cat.key);
: Colors.white.withValues(alpha: 0.85), },
width: 1.1, child: Container(
), padding: const EdgeInsets.symmetric(
), horizontal: 12, vertical: 7),
child: Row( decoration: BoxDecoration(
mainAxisSize: MainAxisSize.min, borderRadius: BorderRadius.circular(22),
children: [ border: Border.all(
Container( color: isDark
width: 24, ? Colors.white.withValues(alpha: 0.18)
height: 24, : Colors.white.withValues(alpha: 0.85),
decoration: BoxDecoration( width: 1.1,
gradient: LinearGradient( ),
begin: Alignment.topLeft, ),
end: Alignment.bottomRight, child: Row(
colors: [ mainAxisSize: MainAxisSize.min,
cat.color, children: [
cat.color.withValues(alpha: 0.82), Container(
], width: 24,
), height: 24,
borderRadius: BorderRadius.circular(7), decoration: BoxDecoration(
boxShadow: [ gradient: LinearGradient(
BoxShadow( begin: Alignment.topLeft,
color: cat.color.withValues(alpha: 0.35), end: Alignment.bottomRight,
blurRadius: 5, colors: [
offset: const Offset(0, 1.5), cat.color,
cat.color.withValues(alpha: 0.82),
],
),
borderRadius: BorderRadius.circular(7),
boxShadow: [
BoxShadow(
color: cat.color.withValues(alpha: 0.35),
blurRadius: 5,
offset: const Offset(0, 1.5),
),
],
), ),
], child: Center(
), child: Icon(cat.icon,
child: Center( size: 14, color: Colors.white),
child: Icon(cat.icon, size: 14, color: Colors.white), ),
), ),
const SizedBox(width: 8),
Text(
cat.label,
style: theme.textTheme.labelLarge?.copyWith(
fontWeight: FontWeight.w600,
letterSpacing: -0.2,
),
),
],
), ),
const SizedBox(width: 8), ),
Text(
cat.label,
style: theme.textTheme.labelLarge?.copyWith(
fontWeight: FontWeight.w600,
letterSpacing: -0.2,
),
),
],
), ),
), ),
), ),
), ),
), );
), },
); ),
}, ),
), ),
); );
} }
@@ -427,6 +427,8 @@ class _ViewedPostTile extends StatelessWidget {
) )
: CachedNetworkImage( : CachedNetworkImage(
imageUrl: image, imageUrl: image,
memCacheWidth: 320,
memCacheHeight: 320,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => Container( placeholder: (_, __) => Container(
color: scheme.surfaceContainerHighest, color: scheme.surfaceContainerHighest,
+5
View File
@@ -1,9 +1,14 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:media_kit/media_kit.dart';
import 'app/app.dart'; import 'app/app.dart';
void main() { void main() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
MediaKit.ensureInitialized();
// Optimize image cache to prevent memory bloat and OOM crashes
PaintingBinding.instance.imageCache.maximumSizeBytes = 180 * 1024 * 1024; // 180 MB
PaintingBinding.instance.imageCache.maximumSize = 120; // 120 images
runApp(const ProviderScope(child: GelRuleApp())); runApp(const ProviderScope(child: GelRuleApp()));
} }
+597 -87
View File
@@ -5,11 +5,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import '../../app/app.dart'; import '../../app/app.dart';
import '../../app/motion.dart';
import '../../app/responsive.dart'; import '../../app/responsive.dart';
import '../../app/router.dart'; import '../../app/router.dart';
import '../../backend/backend.dart'; import '../../backend/backend.dart';
import '../../core/utils/result.dart'; import '../../core/utils/result.dart';
import '../../features/feed/presentation/feed_controller.dart';
import 'desktop_shortcuts_dialog.dart';
class AppShell extends ConsumerStatefulWidget { class AppShell extends ConsumerStatefulWidget {
const AppShell({ const AppShell({
@@ -249,21 +250,54 @@ class _AppShellState extends ConsumerState<AppShell> {
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyF): LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyF):
const _NavigateIntent('/search'), const _NavigateIntent('/search'),
LogicalKeySet(LogicalKeyboardKey.escape): const _BackIntent(), LogicalKeySet(LogicalKeyboardKey.escape): const _BackIntent(),
LogicalKeySet(LogicalKeyboardKey.digit1): const _NavigateIntent('/'), // Ctrl + 1..8
LogicalKeySet(LogicalKeyboardKey.digit2): LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit1):
const _NavigateIntent('/'),
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit2):
const _NavigateIntent('/search'), const _NavigateIntent('/search'),
LogicalKeySet(LogicalKeyboardKey.digit3): LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit3):
const _NavigateIntent('/favorites'), const _NavigateIntent('/favorites'),
LogicalKeySet(LogicalKeyboardKey.digit4): LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit4):
const _NavigateIntent('/viewed'), const _NavigateIntent('/viewed'),
LogicalKeySet(LogicalKeyboardKey.digit5): LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit5):
const _NavigateIntent('/collections'), const _NavigateIntent('/collections'),
LogicalKeySet(LogicalKeyboardKey.digit6): LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit6):
const _NavigateIntent('/artists'), const _NavigateIntent('/artists'),
LogicalKeySet(LogicalKeyboardKey.digit7): LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit7):
const _NavigateIntent('/providers'), const _NavigateIntent('/providers'),
LogicalKeySet(LogicalKeyboardKey.digit8): LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.digit8):
const _NavigateIntent('/settings'), const _NavigateIntent('/settings'),
// Alt + 1..8
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.digit1):
const _NavigateIntent('/'),
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.digit2):
const _NavigateIntent('/search'),
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.digit3):
const _NavigateIntent('/favorites'),
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.digit4):
const _NavigateIntent('/viewed'),
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.digit5):
const _NavigateIntent('/collections'),
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.digit6):
const _NavigateIntent('/artists'),
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.digit7):
const _NavigateIntent('/providers'),
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.digit8):
const _NavigateIntent('/settings'),
// Tab cycling
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.tab):
const _CycleTabIntent(forward: true),
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.shift, LogicalKeyboardKey.tab):
const _CycleTabIntent(forward: false),
// Refresh
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyR):
const _RefreshIntent(),
LogicalKeySet(LogicalKeyboardKey.f5): const _RefreshIntent(),
// Shortcuts help cheat sheet
LogicalKeySet(LogicalKeyboardKey.question): const _HelpIntent(),
LogicalKeySet(LogicalKeyboardKey.f1): const _HelpIntent(),
LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.slash):
const _HelpIntent(),
}, },
child: Actions( child: Actions(
actions: { actions: {
@@ -279,6 +313,33 @@ class _AppShellState extends ConsumerState<AppShell> {
return null; return null;
}, },
), ),
_CycleTabIntent: CallbackAction<_CycleTabIntent>(
onInvoke: (intent) {
if (destinations.isEmpty) return null;
final currentBranch = widget.navigationShell?.currentIndex ?? 0;
final currentIdx = destinations.indexWhere(
(d) => AppShell.branchIndexForLocation(d.location) == currentBranch,
);
final safeIdx = currentIdx < 0 ? 0 : currentIdx;
final nextIdx = intent.forward
? ((safeIdx + 1) % destinations.length)
: ((safeIdx - 1 + destinations.length) % destinations.length);
_onNavigate(destinations[nextIdx].location);
return null;
},
),
_RefreshIntent: CallbackAction<_RefreshIntent>(
onInvoke: (_) {
ref.read(feedControllerProvider.notifier).refresh();
return null;
},
),
_HelpIntent: CallbackAction<_HelpIntent>(
onInvoke: (_) {
DesktopShortcutsDialog.show(context);
return null;
},
),
}, },
child: Focus( child: Focus(
autofocus: true, autofocus: true,
@@ -312,6 +373,7 @@ class _DesktopShell extends StatefulWidget {
required this.onNavigate, required this.onNavigate,
this.currentBranchIndex, this.currentBranchIndex,
}); });
final Widget child; final Widget child;
final List<_Destination> destinations; final List<_Destination> destinations;
final bool ru; final bool ru;
@@ -322,54 +384,416 @@ class _DesktopShell extends StatefulWidget {
State<_DesktopShell> createState() => _DesktopShellState(); State<_DesktopShell> createState() => _DesktopShellState();
} }
class _DesktopShellState extends State<_DesktopShell> { class _DesktopShellState extends State<_DesktopShell>
with SingleTickerProviderStateMixin {
late final AnimationController _controller;
late final Animation<double> _animation;
bool _hovered = false; bool _hovered = false;
bool _pinned = false;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 220),
);
_animation = CurvedAnimation(
parent: _controller,
curve: Curves.easeOutCubic,
reverseCurve: Curves.easeInCubic,
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
void _handleHover(bool hovered) {
if (_hovered == hovered) return;
setState(() => _hovered = hovered);
if (_pinned) return;
if (hovered) {
_controller.forward();
} else {
_controller.reverse();
}
}
void _togglePinned() {
setState(() {
_pinned = !_pinned;
if (_pinned) {
_controller.forward();
} else if (!_hovered) {
_controller.reverse();
}
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final isDark = theme.brightness == Brightness.dark;
final location = GoRouterState.of(context).uri.path; final location = GoRouterState.of(context).uri.path;
final activeBranch = widget.currentBranchIndex ?? final activeBranch = widget.currentBranchIndex ??
AppShell.branchIndexForLocation(location); AppShell.branchIndexForLocation(location);
final selected = widget.destinations.indexWhere( final selected = widget.destinations.indexWhere(
(item) => AppShell.branchIndexForLocation(item.location) == activeBranch, (item) => AppShell.branchIndexForLocation(item.location) == activeBranch,
); );
return Scaffold( return Scaffold(
body: Row( body: Row(
children: [ children: [
MouseRegion( MouseRegion(
onEnter: (_) => setState(() => _hovered = true), onEnter: (_) => _handleHover(true),
onExit: (_) => setState(() => _hovered = false), onExit: (_) => _handleHover(false),
child: AnimatedContainer( child: AnimatedBuilder(
duration: AppMotion.duration(context, 180), animation: _animation,
curve: Curves.easeOutCubic, builder: (context, _) {
width: _hovered ? 256 : 72, final progress = _animation.value;
color: Theme.of(context).navigationRailTheme.backgroundColor, final width = lerpDouble(74.0, 260.0, progress)!;
child: SafeArea( final contentOpacity =
child: Padding( (progress - 0.25).clamp(0.0, 0.75) / 0.75;
padding: final isFullyExpanded = progress > 0.85;
const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
child: Column( return Container(
children: [ width: width,
for (var index = 0; decoration: BoxDecoration(
index < widget.destinations.length; color: isDark
index++) ? scheme.surfaceContainerHigh
_RailButton( : scheme.surface,
destination: widget.destinations[index], border: Border(
ru: widget.ru, right: BorderSide(
selected: (selected < 0 ? 0 : selected) == index, color: isDark
expanded: _hovered, ? Colors.white.withValues(alpha: 0.1)
onTap: () { : scheme.outlineVariant.withValues(alpha: 0.35),
widget.onNavigate(widget.destinations[index].location); width: 1,
}, ),
), ),
const Spacer(), boxShadow: [
BoxShadow(
color:
Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
blurRadius: 16,
offset: const Offset(3, 0),
),
], ],
), ),
), child: ClipRect(
), child: OverflowBox(
minWidth: 260,
maxWidth: 260,
alignment: Alignment.topLeft,
child: SizedBox(
width: 260,
child: SafeArea(
child: Column(
children: [
// App Brand Header
Padding(
padding:
const EdgeInsets.fromLTRB(15, 16, 12, 14),
child: SizedBox(
height: 44,
child: Row(
children: [
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
scheme.primary,
scheme.tertiary,
],
),
borderRadius:
BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: scheme.primary
.withValues(alpha: 0.35),
blurRadius: 12,
offset: const Offset(0, 3),
),
],
),
child: const Center(
child: Icon(
Icons.auto_awesome_rounded,
color: Colors.white,
size: 24,
),
),
),
const SizedBox(width: 12),
Expanded(
child: Opacity(
opacity: contentOpacity,
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text(
'Lunaris',
maxLines: 1,
softWrap: false,
style: theme
.textTheme
.titleMedium
?.copyWith(
fontWeight:
FontWeight.w800,
letterSpacing: 0.2,
),
),
const SizedBox(height: 2),
Container(
padding: const EdgeInsets
.symmetric(
horizontal: 6,
vertical: 1.5,
),
decoration: BoxDecoration(
color: scheme.primary
.withValues(
alpha: 0.15),
borderRadius:
BorderRadius
.circular(6),
border: Border.all(
color: scheme.primary
.withValues(
alpha: 0.3),
width: 0.8,
),
),
child: Text(
'v3.6.4',
style: TextStyle(
fontSize: 10,
fontWeight:
FontWeight.bold,
color: scheme.primary,
letterSpacing: 0.4,
),
),
),
],
),
),
IconButton(
visualDensity:
VisualDensity.compact,
tooltip: _pinned
? (widget.ru
? 'Открепить панель'
: 'Unpin panel')
: (widget.ru
? 'Закрепить панель'
: 'Pin panel'),
onPressed: _togglePinned,
icon: Icon(
_pinned
? Icons.push_pin_rounded
: Icons.push_pin_outlined,
size: 19,
color: _pinned
? scheme.primary
: scheme
.onSurfaceVariant,
),
),
],
),
),
),
],
),
),
),
const Divider(height: 1),
const SizedBox(height: 8),
// Destinations List
Expanded(
child: ListView(
padding:
const EdgeInsets.symmetric(horizontal: 8),
children: [
for (var index = 0;
index < widget.destinations.length;
index++)
_RailButton(
destination: widget.destinations[index],
ru: widget.ru,
selected: (selected < 0 ? 0 : selected) ==
index,
contentOpacity: contentOpacity,
isFullyExpanded: isFullyExpanded,
shortcutKey: 'Ctrl+${index + 1}',
onTap: () {
widget.onNavigate(
widget.destinations[index]
.location);
},
),
],
),
),
// Bottom Actions
const Divider(height: 1),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 8),
child: SizedBox(
width: 244,
child: Row(
children: [
Expanded(
child: Tooltip(
message: isFullyExpanded
? ''
: (widget.ru
? 'Горячие клавиши (F1 / ?)'
: 'Keyboard Shortcuts (F1 / ?)'),
waitDuration: const Duration(
milliseconds: 350),
child: Material(
color: Colors.transparent,
borderRadius:
BorderRadius.circular(14),
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () =>
DesktopShortcutsDialog.show(
context),
child: SizedBox(
height: 44,
child: Row(
children: [
SizedBox(
width: 58,
child: Icon(
Icons.keyboard_rounded,
size: 22,
color: scheme
.onSurfaceVariant,
),
),
Expanded(
child: Opacity(
opacity: contentOpacity,
child: Row(
children: [
Expanded(
child: Text(
widget.ru
? 'Горячие клавиши'
: 'Shortcuts',
maxLines: 1,
softWrap: false,
overflow:
TextOverflow
.ellipsis,
style:
TextStyle(
fontWeight:
FontWeight
.w600,
fontSize: 13,
color: scheme
.onSurface,
),
),
),
Container(
padding:
const EdgeInsets
.symmetric(
horizontal: 6,
vertical: 2,
),
decoration:
BoxDecoration(
color: isDark
? Colors
.white
.withValues(
alpha:
0.1)
: Colors
.black
.withValues(
alpha:
0.06),
borderRadius:
BorderRadius
.circular(
6),
),
child: const Text(
'?',
style:
TextStyle(
fontSize: 11,
fontWeight:
FontWeight
.bold,
fontFamily:
'monospace',
),
),
),
const SizedBox(
width: 8),
],
),
),
),
],
),
),
),
),
),
),
if (!_pinned && progress < 0.4)
IconButton(
tooltip: widget.ru
? 'Закрепить панель'
: 'Pin sidebar',
onPressed: _togglePinned,
icon: const Icon(
Icons.chevron_right_rounded,
size: 20),
),
],
),
),
),
],
),
),
),
),
),
);
},
), ),
), ),
const VerticalDivider(width: 1),
Expanded(child: widget.child), Expanded(child: widget.child),
], ],
), ),
@@ -381,75 +805,148 @@ class _RailButton extends StatelessWidget {
const _RailButton({ const _RailButton({
required this.destination, required this.destination,
required this.selected, required this.selected,
required this.expanded, required this.contentOpacity,
required this.isFullyExpanded,
required this.ru, required this.ru,
required this.shortcutKey,
required this.onTap, required this.onTap,
}); });
final _Destination destination; final _Destination destination;
final bool selected; final bool selected;
final bool expanded; final double contentOpacity;
final bool isFullyExpanded;
final bool ru; final bool ru;
final String shortcutKey;
final VoidCallback onTap; final VoidCallback onTap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme; final theme = Theme.of(context);
final scheme = theme.colorScheme;
final isDark = theme.brightness == Brightness.dark;
final label = destination.labelFor(ru);
return Padding( return Padding(
padding: const EdgeInsets.only(bottom: 8), padding: const EdgeInsets.symmetric(vertical: 2),
child: Tooltip( child: Tooltip(
message: expanded ? '' : destination.labelFor(ru), message: isFullyExpanded ? '' : '$label ($shortcutKey)',
waitDuration: const Duration(milliseconds: 450), waitDuration: const Duration(milliseconds: 350),
child: Material( child: Material(
color: selected ? colors.primaryContainer : Colors.transparent, color: selected
borderRadius: BorderRadius.circular(28), ? scheme.primary.withValues(alpha: isDark ? 0.22 : 0.12)
: Colors.transparent,
borderRadius: BorderRadius.circular(14),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: InkWell( child: InkWell(
onTap: onTap, onTap: onTap,
child: SizedBox( child: SizedBox(
height: 48, width: 244,
child: Row( height: 46,
children: [ child: DecoratedBox(
SizedBox( decoration: BoxDecoration(
width: 56, borderRadius: BorderRadius.circular(14),
child: Icon( border: selected
destination.icon, ? Border.all(
color: selected color: scheme.primary
? colors.onPrimaryContainer .withValues(alpha: isDark ? 0.45 : 0.28),
: colors.onSurfaceVariant, width: 1.1,
)
: null,
),
child: Row(
children: [
// Active left indicator bar
Container(
width: 3.5,
height: 22,
decoration: BoxDecoration(
color: selected ? scheme.primary : Colors.transparent,
borderRadius: BorderRadius.circular(2),
boxShadow: selected
? [
BoxShadow(
color: scheme.primary.withValues(alpha: 0.6),
blurRadius: 6,
),
]
: null,
),
), ),
), SizedBox(
if (expanded) width: 54.5,
Expanded( child: Center(
child: ClipRect( child: Icon(
child: AnimatedOpacity( destination.icon,
opacity: 1, size: 22,
duration: AppMotion.duration(context, 120), color: selected
curve: Curves.easeOut, ? scheme.primary
child: Align( : (isDark
alignment: Alignment.centerLeft, ? scheme.onSurfaceVariant
child: Text( .withValues(alpha: 0.85)
destination.labelFor(ru), : scheme.onSurfaceVariant),
maxLines: 1,
overflow: TextOverflow.clip,
softWrap: false,
style: TextStyle(
fontWeight: selected
? FontWeight.w700
: FontWeight.w600,
color: selected
? colors.onPrimaryContainer
: colors.onSurface,
),
),
),
), ),
), ),
) ),
else Expanded(
const SizedBox.shrink(), child: Opacity(
if (expanded) const SizedBox(width: 12), opacity: contentOpacity,
], child: Row(
children: [
Expanded(
child: Text(
label,
maxLines: 1,
softWrap: false,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13.5,
fontWeight: selected
? FontWeight.w700
: FontWeight.w500,
color: selected
? scheme.primary
: scheme.onSurface,
),
),
),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 5.5,
vertical: 2,
),
decoration: BoxDecoration(
color: isDark
? Colors.white.withValues(alpha: 0.08)
: Colors.black.withValues(alpha: 0.05),
borderRadius: BorderRadius.circular(6),
border: Border.all(
color: isDark
? Colors.white.withValues(alpha: 0.12)
: Colors.black.withValues(alpha: 0.08),
width: 0.8,
),
),
child: Text(
shortcutKey,
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.bold,
fontFamily: 'monospace',
color: selected
? scheme.primary
: scheme.onSurfaceVariant
.withValues(alpha: 0.8),
),
),
),
const SizedBox(width: 8),
],
),
),
),
],
),
), ),
), ),
), ),
@@ -945,3 +1442,16 @@ class _NavigateIntent extends Intent {
class _BackIntent extends Intent { class _BackIntent extends Intent {
const _BackIntent(); const _BackIntent();
} }
class _CycleTabIntent extends Intent {
const _CycleTabIntent({required this.forward});
final bool forward;
}
class _RefreshIntent extends Intent {
const _RefreshIntent();
}
class _HelpIntent extends Intent {
const _HelpIntent();
}
@@ -0,0 +1,321 @@
import 'dart:ui';
import 'package:flutter/material.dart';
class DesktopShortcutsDialog extends StatelessWidget {
const DesktopShortcutsDialog({super.key});
static Future<void> show(BuildContext context) {
return showDialog(
context: context,
barrierColor: Colors.black54,
builder: (_) => const DesktopShortcutsDialog(),
);
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final isDark = theme.brightness == Brightness.dark;
return Dialog(
backgroundColor: Colors.transparent,
insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 720, maxHeight: 680),
child: ClipRRect(
borderRadius: BorderRadius.circular(24),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
child: Container(
decoration: BoxDecoration(
color: isDark
? scheme.surfaceContainerHigh.withValues(alpha: 0.88)
: Colors.white.withValues(alpha: 0.94),
borderRadius: BorderRadius.circular(24),
border: Border.all(
color: isDark
? Colors.white.withValues(alpha: 0.16)
: scheme.outlineVariant.withValues(alpha: 0.4),
width: 1.2,
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: isDark ? 0.45 : 0.12),
blurRadius: 32,
offset: const Offset(0, 12),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Header
Padding(
padding: const EdgeInsets.fromLTRB(24, 20, 16, 16),
child: Row(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: scheme.primaryContainer.withValues(alpha: 0.7),
borderRadius: BorderRadius.circular(14),
),
child: Icon(
Icons.keyboard_rounded,
color: scheme.primary,
size: 24,
),
),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Горячие клавиши',
style: theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 2),
Text(
'Быстрое управление с клавиатуры для ПК',
style: theme.textTheme.bodyMedium?.copyWith(
color: scheme.onSurfaceVariant,
),
),
],
),
),
IconButton(
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Icons.close_rounded),
tooltip: 'Закрыть (Esc)',
),
],
),
),
const Divider(height: 1),
// Shortcuts list
Flexible(
child: ListView(
padding: const EdgeInsets.fromLTRB(24, 16, 24, 24),
children: const [
_ShortcutSection(
icon: Icons.navigation_rounded,
title: 'Общие и навигация',
items: [
_ShortcutRow(['Ctrl', '1…8'], 'Переключение между вкладками'),
_ShortcutRow(['Ctrl', 'Tab'], 'Следующая вкладка'),
_ShortcutRow(['Ctrl', 'Shift', 'Tab'], 'Предыдущая вкладка'),
_ShortcutRow(['Ctrl', 'F'], 'Перейти к поиску / строка поиска'),
_ShortcutRow(['Ctrl', 'R'], 'Обновить ленту / страницу'),
_ShortcutRow(['F5'], 'Обновить страницу'),
_ShortcutRow(['Esc'], 'Закрыть окно / назад / сбросить выбор'),
_ShortcutRow(['?'], 'Открыть это окно горячих клавиш'),
],
),
SizedBox(height: 20),
_ShortcutSection(
icon: Icons.smart_display_rounded,
title: 'Видеоплеер',
items: [
_ShortcutRow(['Пробел'], 'Воспроизведение / Пауза'),
_ShortcutRow(['←', '→'], 'Перемотка на 5 секунд назад / вперед'),
_ShortcutRow(['Shift', '← / →'], 'Перемотка на 15 секунд'),
_ShortcutRow(['↑', '↓'], 'Регулировка громкости (±5%)'),
_ShortcutRow(['M'], 'Включить / выключить звук'),
_ShortcutRow(['F'], 'Полноэкранный режим (Full Screen)'),
_ShortcutRow(['L'], 'Повтор видео (Loop on/off)'),
_ShortcutRow(['Esc'], 'Выйти из полноэкранного режима'),
],
),
SizedBox(height: 20),
_ShortcutSection(
icon: Icons.photo_library_rounded,
title: 'Фото и просмотр постов',
items: [
_ShortcutRow(['←', '→'], 'Предыдущее / следующее фото или пост'),
_ShortcutRow(['+'], 'Увеличить масштаб (Zoom In)'),
_ShortcutRow(['-'], 'Уменьшить масштаб (Zoom Out)'),
_ShortcutRow(['0'], 'Сбросить масштаб (100%)'),
_ShortcutRow(['F'], 'Подгонка по экрану / на весь экран'),
_ShortcutRow(['D'], 'Скачать текущее изображение'),
_ShortcutRow(['Ctrl', 'S'], 'Сохранить / Скачать файл'),
_ShortcutRow(['Esc'], 'Сброс зума / назад'),
],
),
SizedBox(height: 20),
_ShortcutSection(
icon: Icons.grid_view_rounded,
title: 'Лента и посты',
items: [
_ShortcutRow(['R'], 'Открыть случайный пост'),
_ShortcutRow(['V'], 'Включить/выключить режим выбора постов'),
],
),
],
),
),
],
),
),
),
),
),
);
}
}
class _ShortcutSection extends StatelessWidget {
const _ShortcutSection({
required this.icon,
required this.title,
required this.items,
});
final IconData icon;
final String title;
final List<_ShortcutRow> items;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final isDark = theme.brightness == Brightness.dark;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(icon, size: 18, color: scheme.primary),
const SizedBox(width: 8),
Text(
title,
style: theme.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.bold,
color: scheme.primary,
letterSpacing: 0.3,
),
),
],
),
const SizedBox(height: 8),
Container(
decoration: BoxDecoration(
color: isDark
? scheme.surface.withValues(alpha: 0.6)
: scheme.surfaceContainerHighest.withValues(alpha: 0.4),
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: isDark
? Colors.white.withValues(alpha: 0.08)
: Colors.black.withValues(alpha: 0.04),
),
),
child: Column(
children: [
for (var i = 0; i < items.length; i++) ...[
if (i > 0)
Divider(
height: 1,
thickness: 1,
color: isDark
? Colors.white.withValues(alpha: 0.05)
: Colors.black.withValues(alpha: 0.04),
),
items[i],
],
],
),
),
],
);
}
}
class _ShortcutRow extends StatelessWidget {
const _ShortcutRow(this.keys, this.description);
final List<String> keys;
final String description;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
child: Row(
children: [
Expanded(
child: Text(
description,
style: theme.textTheme.bodyMedium?.copyWith(
color: scheme.onSurface,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(width: 12),
Wrap(
spacing: 4,
runSpacing: 4,
children: keys.map((key) => _KeyCap(key)).toList(growable: false),
),
],
),
);
}
}
class _KeyCap extends StatelessWidget {
const _KeyCap(this.text);
final String text;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark;
final scheme = theme.colorScheme;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: isDark
? scheme.surfaceContainerHighest.withValues(alpha: 0.9)
: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: isDark
? Colors.white.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.15),
width: 1,
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: isDark ? 0.4 : 0.08),
offset: const Offset(0, 1.5),
blurRadius: 1,
),
],
),
child: Text(
text,
style: TextStyle(
fontFamily: 'monospace',
fontSize: 12,
fontWeight: FontWeight.bold,
color: scheme.onSurface,
letterSpacing: 0.2,
),
),
);
}
}
+18 -11
View File
@@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:collection'; import 'dart:collection';
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -232,7 +233,7 @@ class _PostCardState extends ConsumerState<PostCard>
} }
final dpr = MediaQuery.devicePixelRatioOf(context); final dpr = MediaQuery.devicePixelRatioOf(context);
final cacheWidth = final cacheWidth =
(constraints.maxWidth * dpr).round().clamp(320, 1800); (constraints.maxWidth * dpr).round().clamp(280, 960);
final headers = _headersFor(post); final headers = _headersFor(post);
final videoUrls = MediaUrlSelector.video(post); final videoUrls = MediaUrlSelector.video(post);
if (!mobile && if (!mobile &&
@@ -590,7 +591,15 @@ class _FeedVideoPreviewState extends State<_FeedVideoPreview> {
super.initState(); super.initState();
MediaKit.ensureInitialized(); MediaKit.ensureInitialized();
_player = Player(); _player = Player();
_controller = VideoController(_player); final isDesktop =
Platform.isLinux || Platform.isWindows || Platform.isMacOS;
_controller = VideoController(
_player,
configuration: VideoControllerConfiguration(
enableHardwareAcceleration: !isDesktop,
hwdec: isDesktop ? 'no' : 'auto-safe',
),
);
_player.stream.error.listen((_) { _player.stream.error.listen((_) {
if (mounted) setState(() => _failed = true); if (mounted) setState(() => _failed = true);
}); });
@@ -633,15 +642,13 @@ class _FeedVideoPreviewState extends State<_FeedVideoPreview> {
AnimatedOpacity( AnimatedOpacity(
opacity: _ready ? 1 : 0, opacity: _ready ? 1 : 0,
duration: AppMotion.duration(context, 180), duration: AppMotion.duration(context, 180),
child: ColoredBox( child: Video(
color: Colors.black, controller: _controller,
child: Video( fit: BoxFit.cover,
controller: _controller, fill: Colors.transparent,
fit: BoxFit.cover, controls: null,
controls: null, pauseUponEnteringBackgroundMode: false,
pauseUponEnteringBackgroundMode: false, resumeUponEnteringForegroundMode: false,
resumeUponEnteringForegroundMode: false,
),
), ),
), ),
], ],
+20 -18
View File
@@ -68,24 +68,26 @@ class PostMasonryGrid extends StatelessWidget {
final spacing = mobile ? 8.0 : 12.0; final spacing = mobile ? 8.0 : 12.0;
Widget buildCard(Post post) { Widget buildCard(Post post) {
return PostCard( return RepaintBoundary(
post: post, child: PostCard(
blurExplicit: blurExplicit && !nsfwEnabled, post: post,
showBadges: showBadges, blurExplicit: blurExplicit && !nsfwEnabled,
isFavorite: favoriteKeys.contains(post.cacheKey), showBadges: showBadges,
isViewed: viewedKeys.contains(post.cacheKey), isFavorite: favoriteKeys.contains(post.cacheKey),
isDownloaded: downloadedKeys.contains(post.cacheKey), isViewed: viewedKeys.contains(post.cacheKey),
mediaQualityMode: mediaQualityMode, isDownloaded: downloadedKeys.contains(post.cacheKey),
onOpen: () => onOpen(post), mediaQualityMode: mediaQualityMode,
onFavorite: () => onFavorite(post), onOpen: () => onOpen(post),
onPreview: onPreview == null ? null : () => onPreview!(post), onFavorite: () => onFavorite(post),
onHide: onHide == null ? null : () => onHide!(post), onPreview: onPreview == null ? null : () => onPreview!(post),
selectionMode: selectionMode, onHide: onHide == null ? null : () => onHide!(post),
selected: selectedKeys.contains(post.cacheKey), selectionMode: selectionMode,
onToggleSelected: selected: selectedKeys.contains(post.cacheKey),
onToggleSelected == null ? null : () => onToggleSelected!(post), onToggleSelected:
onAddToCollection: onToggleSelected == null ? null : () => onToggleSelected!(post),
onAddToCollection == null ? null : () => onAddToCollection!(post), onAddToCollection:
onAddToCollection == null ? null : () => onAddToCollection!(post),
),
); );
} }
+1 -1
View File
@@ -1,7 +1,7 @@
name: gel_rule_app name: gel_rule_app
description: Local backend/core layer for a Flutter booru browser app. description: Local backend/core layer for a Flutter booru browser app.
publish_to: "none" publish_to: "none"
version: 3.5.5+81 version: 3.6.4+86
environment: environment:
sdk: ">=3.3.0 <4.0.0" sdk: ">=3.3.0 <4.0.0"