Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

UI polishes

Nathan Poulsond7a1af12ec58
diff --git a/lib/screens/absorbing_screen.dart b/lib/screens/absorbing_screen.dart
index 4a89848a..00e4f228 100644
--- a/lib/screens/absorbing_screen.dart
+++ b/lib/screens/absorbing_screen.dart
@@ -387,13 +387,16 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
padding: const EdgeInsets.fromLTRB(20, 12, 12, 0),
actions: [
// Offline mode toggle
- GestureDetector(
- onTap: () {
- final newVal = !lib.isManualOffline;
- lib.setManualOffline(newVal);
- if (newVal) _stopAndRefresh(lib);
- },
- child: AnimatedContainer(
+ Material(
+ type: MaterialType.transparency,
+ child: InkWell(
+ onTap: () {
+ final newVal = !lib.isManualOffline;
+ lib.setManualOffline(newVal);
+ if (newVal) _stopAndRefresh(lib);
+ },
+ borderRadius: BorderRadius.circular(20),
+ child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
curve: Curves.easeOutCubic,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
@@ -421,26 +424,30 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
),
),
),
+ ),
const SizedBox(width: 8),
// Unified button: "Sync" when idle, "Stop & Sync" when playing
if (!effectiveOffline)
- GestureDetector(
- onTap: _isSyncing ? null : () {
- if (_player.hasBook) {
- _stopAndRefresh(lib);
- } else {
- _confirmAndSync(lib);
- }
- },
- child: AnimatedContainer(
- duration: const Duration(milliseconds: 200),
- padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
- decoration: BoxDecoration(
- color: subtleBg,
- borderRadius: BorderRadius.circular(20),
- border: Border.all(color: subtleBorder),
- ),
- child: Row(
+ Material(
+ type: MaterialType.transparency,
+ child: InkWell(
+ onTap: _isSyncing ? null : () {
+ if (_player.hasBook) {
+ _stopAndRefresh(lib);
+ } else {
+ _confirmAndSync(lib);
+ }
+ },
+ borderRadius: BorderRadius.circular(20),
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 200),
+ padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
+ decoration: BoxDecoration(
+ color: subtleBg,
+ borderRadius: BorderRadius.circular(20),
+ border: Border.all(color: subtleBorder),
+ ),
+ child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -460,6 +467,7 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
],
),
),
+ ),
)
else
// Offline: just stop button (no sync)
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index d0bf833e..b97f5301 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -23,6 +23,13 @@ class _HomeScreenState extends State<HomeScreen> {
final _player = AudioPlayerService();
bool _hideEbookOnly = false;
+ // Cached filtered sections — invalidated when source data or settings change.
+ List<dynamic>? _cachedSections;
+ List<dynamic>? _cachedClItems;
+ int _lastSectionsLength = -1;
+ bool _lastHideEbook = false;
+ bool _lastIsPodcast = false;
+
@override
void initState() {
super.initState();
@@ -59,6 +66,39 @@ class _HomeScreenState extends State<HomeScreen> {
}).toList();
}
+ /// Recompute cached filtered sections only when input data changes.
+ void _refreshFilteredCache(LibraryProvider lib) {
+ final sections = lib.personalizedSections;
+ final isPod = lib.isPodcastLibrary;
+ if (sections.length == _lastSectionsLength &&
+ _hideEbookOnly == _lastHideEbook &&
+ isPod == _lastIsPodcast &&
+ _cachedSections != null) {
+ return; // cache is still valid
+ }
+ _lastSectionsLength = sections.length;
+ _lastHideEbook = _hideEbookOnly;
+ _lastIsPodcast = isPod;
+
+ // Continue-listening items
+ List<dynamic> clItems = [];
+ for (final section in sections) {
+ if (section['id'] == 'continue-listening') {
+ clItems = _filterEbookOnly((section['entities'] as List<dynamic>?) ?? []);
+ break;
+ }
+ }
+ if (isPod && clItems.isNotEmpty) {
+ final seen = <String>{};
+ clItems = clItems.where((item) {
+ final id = (item as Map<String, dynamic>)['id'] as String? ?? '';
+ return seen.add(id);
+ }).toList();
+ }
+ _cachedClItems = clItems;
+ _cachedSections = _sortSections(sections);
+ }
+
@override
void dispose() {
_player.removeListener(_onPlayerChanged);
@@ -186,6 +226,7 @@ class _HomeScreenState extends State<HomeScreen> {
final lib = context.watch<LibraryProvider>();
final allLibraries = lib.libraries;
final libraryName = lib.selectedLibrary?['name'] as String? ?? 'Library';
+ if (!lib.isLoading) _refreshFilteredCache(lib);
return Scaffold(
body: Container(
@@ -214,16 +255,20 @@ class _HomeScreenState extends State<HomeScreen> {
title: 'Home',
actions: [
if (!lib.isOffline && allLibraries.length > 1)
- GestureDetector(
- onTap: () => _showLibraryPicker(context, cs, tt, allLibraries, lib),
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
- decoration: BoxDecoration(
- color: cs.onSurface.withValues(alpha: 0.06),
- borderRadius: BorderRadius.circular(20),
- border: Border.all(color: cs.onSurface.withValues(alpha: 0.08)),
- ),
- child: Row(
+ Material(
+ color: cs.onSurface.withValues(alpha: 0.06),
+ borderRadius: BorderRadius.circular(20),
+ clipBehavior: Clip.antiAlias,
+ child: InkWell(
+ onTap: () => _showLibraryPicker(context, cs, tt, allLibraries, lib),
+ borderRadius: BorderRadius.circular(20),
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(20),
+ border: Border.all(color: cs.onSurface.withValues(alpha: 0.08)),
+ ),
+ child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(lib.isPodcastLibrary ? Icons.podcasts_rounded : Icons.auto_stories_rounded, size: 14, color: cs.onSurfaceVariant),
@@ -239,6 +284,7 @@ class _HomeScreenState extends State<HomeScreen> {
),
),
),
+ ),
],
),
),
@@ -246,26 +292,7 @@ class _HomeScreenState extends State<HomeScreen> {
// ── Currently Absorbing section ──
if (!lib.isLoading)
...() {
- // Find continue-listening entities
- List<dynamic> clItems = [];
- for (final section in lib.personalizedSections) {
- if (section['id'] == 'continue-listening') {
- clItems = _filterEbookOnly((section['entities'] as List<dynamic>?) ?? []);
- break;
- }
- }
-
- // For podcast libraries, deduplicate by show ID — ABS returns
- // one entity per in-progress episode, all with the same show id.
- // Keep the first occurrence (most recently updated) per show.
- if (lib.isPodcastLibrary && clItems.isNotEmpty) {
- final seen = <String>{};
- clItems = clItems.where((item) {
- final id = (item as Map<String, dynamic>)['id'] as String? ?? '';
- return seen.add(id);
- }).toList();
- }
-
+ final clItems = _cachedClItems ?? [];
if (clItems.isEmpty) return <Widget>[];
return <Widget>[
SliverToBoxAdapter(
@@ -387,7 +414,7 @@ class _HomeScreenState extends State<HomeScreen> {
// ── Other sections ──
if (!lib.isLoading)
- ..._sortSections(lib.personalizedSections).map((section) {
+ ...(_cachedSections ?? []).map((section) {
final id = section['id'] ?? '';
if (id == 'continue-listening' ||
_hiddenSections.contains(id)) {
@@ -491,31 +518,35 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
: (media['duration'] as num?)?.toDouble() ?? 0);
final isCurrentItem = player.currentItemId == itemId;
- return GestureDetector(
- onTap: () {
- if (lib.isPodcastLibrary) {
- if (recentEpisode != null) {
- EpisodeDetailSheet.show(context, item, recentEpisode);
+ return Material(
+ color: isCurrentItem
+ ? cs.primary.withValues(alpha: 0.08)
+ : cs.surfaceContainerHigh,
+ borderRadius: BorderRadius.circular(14),
+ clipBehavior: Clip.antiAlias,
+ child: InkWell(
+ onTap: () {
+ if (lib.isPodcastLibrary) {
+ if (recentEpisode != null) {
+ EpisodeDetailSheet.show(context, item, recentEpisode);
+ } else {
+ EpisodeListSheet.show(context, item);
+ }
} else {
- EpisodeListSheet.show(context, item);
+ showBookDetailSheet(context, itemId);
}
- } else {
- showBookDetailSheet(context, itemId);
- }
- },
- child: Container(
- width: 280,
- padding: const EdgeInsets.all(10),
- decoration: BoxDecoration(
- color: isCurrentItem
- ? cs.primary.withValues(alpha: 0.08)
- : cs.surfaceContainerHigh,
- borderRadius: BorderRadius.circular(14),
- border: isCurrentItem
- ? Border.all(color: cs.primary.withValues(alpha: 0.2))
- : null,
- ),
- child: Row(
+ },
+ borderRadius: BorderRadius.circular(14),
+ child: Container(
+ width: 280,
+ padding: const EdgeInsets.all(10),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(14),
+ border: isCurrentItem
+ ? Border.all(color: cs.primary.withValues(alpha: 0.2))
+ : null,
+ ),
+ child: Row(
children: [
// Cover
ClipRRect(
@@ -530,6 +561,10 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
child: Icon(Icons.headphones_rounded, size: 18, color: cs.onSurfaceVariant)))
: CachedNetworkImage(imageUrl: coverUrl, fit: BoxFit.cover,
httpHeaders: lib.mediaHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
+ placeholder: (_, __) => Container(
+ color: cs.surfaceContainerHighest,
+ child: Icon(Icons.headphones_rounded, size: 18, color: cs.onSurfaceVariant)),
errorWidget: (_, __, ___) => Container(
color: cs.surfaceContainerHighest,
child: Icon(Icons.headphones_rounded, size: 18, color: cs.onSurfaceVariant)))
@@ -584,9 +619,9 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
],
),
),
- const SizedBox(width: 8),
- // Play button
+ // Play button (48x48 hit area, 34x34 visual)
GestureDetector(
+ behavior: HitTestBehavior.opaque,
onTap: _isLoading ? null : () {
if (isCurrentItem) {
player.togglePlayPause();
@@ -594,32 +629,38 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
_startBook(context, itemId);
}
},
- child: Container(
- width: 34, height: 34,
- decoration: BoxDecoration(
- color: cs.primary.withValues(alpha: isCurrentItem ? 1.0 : 0.15),
- shape: BoxShape.circle,
+ child: SizedBox(
+ width: 48, height: 48,
+ child: Center(
+ child: Container(
+ width: 34, height: 34,
+ decoration: BoxDecoration(
+ color: cs.primary.withValues(alpha: isCurrentItem ? 1.0 : 0.15),
+ shape: BoxShape.circle,
+ ),
+ child: _isLoading
+ ? Padding(
+ padding: const EdgeInsets.all(9),
+ child: CircularProgressIndicator(
+ strokeWidth: 2,
+ color: isCurrentItem ? cs.onPrimary : cs.primary,
+ ),
+ )
+ : Icon(
+ isCurrentItem && player.isPlaying
+ ? Icons.pause_rounded
+ : Icons.play_arrow_rounded,
+ size: 18,
+ color: isCurrentItem ? cs.onPrimary : cs.primary,
+ ),
+ ),
),
- child: _isLoading
- ? Padding(
- padding: const EdgeInsets.all(9),
- child: CircularProgressIndicator(
- strokeWidth: 2,
- color: isCurrentItem ? cs.onPrimary : cs.primary,
- ),
- )
- : Icon(
- isCurrentItem && player.isPlaying
- ? Icons.pause_rounded
- : Icons.play_arrow_rounded,
- size: 18,
- color: isCurrentItem ? cs.onPrimary : cs.primary,
- ),
),
),
],
),
),
+ ),
);
}
diff --git a/lib/screens/stats_screen.dart b/lib/screens/stats_screen.dart
index c72fc6e4..a15c150d 100644
--- a/lib/screens/stats_screen.dart
+++ b/lib/screens/stats_screen.dart
@@ -2,7 +2,6 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/auth_provider.dart';
-import '../providers/library_provider.dart';
import '../widgets/absorb_page_header.dart';
import '../widgets/absorb_wave_icon.dart';
@@ -35,6 +34,16 @@ class _StatsScreenState extends State<StatsScreen> with SingleTickerProviderStat
int _booksFinished = 0;
+ // Cached derived values — computed once in _loadStats, not on every build/frame.
+ double _totalSeconds = 0;
+ double _today = 0;
+ double _thisWeek = 0;
+ double _thisMonth = 0;
+ int _streak = 0;
+ int _longestStreakVal = 0;
+ List<_DayData> _weekData = [];
+ List<_DayData> _monthData = [];
+
Future<void> _loadStats() async {
final api = context.read<AuthProvider>().apiService;
if (api == null) return;
@@ -57,6 +66,18 @@ class _StatsScreenState extends State<StatsScreen> with SingleTickerProviderStat
}
if (mounted) {
+ // Pre-compute derived values once, not on every build/frame.
+ if (stats != null) {
+ final dailyMap = _extractDailyMap(stats);
+ _totalSeconds = _safeNum(stats['totalTime']);
+ _today = _todaySeconds(dailyMap);
+ _thisWeek = _weekSeconds(dailyMap);
+ _thisMonth = _monthSeconds(dailyMap);
+ _streak = _currentStreak(dailyMap);
+ _longestStreakVal = _longestStreak(dailyMap);
+ _weekData = _last7Days(dailyMap);
+ _monthData = _last30Days(dailyMap);
+ }
setState(() {
_stats = stats;
_sessions = sessionsData?['sessions'] as List<dynamic>? ?? [];
@@ -124,18 +145,6 @@ class _StatsScreenState extends State<StatsScreen> with SingleTickerProviderStat
}
Widget _buildContent(ColorScheme cs, TextTheme tt) {
- final totalSeconds = _safeNum(_stats!['totalTime']);
- final dailyMap = _extractDailyMap(_stats!);
- final today = _todaySeconds(dailyMap);
- final thisWeek = _weekSeconds(dailyMap);
- final thisMonth = _monthSeconds(dailyMap);
- final streak = _currentStreak(dailyMap);
- final longestStreak = _longestStreak(dailyMap);
- final weekData = _last7Days(dailyMap);
- final monthData = _last30Days(dailyMap);
-
- // Count finished books — loaded from /api/me mediaProgress
- final booksFinished = _booksFinished;
return ListView(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 32),
@@ -148,29 +157,29 @@ class _StatsScreenState extends State<StatsScreen> with SingleTickerProviderStat
const SizedBox(height: 24),
// ── Hero stat ──
- _heroStat(tt, cs, totalSeconds),
+ _heroStat(tt, cs, _totalSeconds),
const SizedBox(height: 24),
// ── Quick stats row ──
Row(children: [
Expanded(child: _statCard(tt, cs, Icons.local_fire_department_rounded, Colors.orange,
- '${streak}d', 'Current\nStreak')),
+ '${_streak}d', 'Current\nStreak')),
const SizedBox(width: 10),
Expanded(child: _statCard(tt, cs, Icons.emoji_events_rounded, Colors.amber,
- '${longestStreak}d', 'Longest\nStreak')),
+ '${_longestStreakVal}d', 'Longest\nStreak')),
const SizedBox(width: 10),
Expanded(child: _statCard(tt, cs, Icons.check_circle_rounded, Colors.green,
- '$booksFinished', 'Books\nFinished')),
+ '$_booksFinished', 'Books\nFinished')),
]),
const SizedBox(height: 24),
// ── Time periods ──
Row(children: [
- Expanded(child: _periodCard(tt, cs, 'Today', today)),
+ Expanded(child: _periodCard(tt, cs, 'Today', _today)),
const SizedBox(width: 10),
- Expanded(child: _periodCard(tt, cs, 'This Week', thisWeek)),
+ Expanded(child: _periodCard(tt, cs, 'This Week', _thisWeek)),
const SizedBox(width: 10),
- Expanded(child: _periodCard(tt, cs, 'This Month', thisMonth)),
+ Expanded(child: _periodCard(tt, cs, 'This Month', _thisMonth)),
]),
const SizedBox(height: 28),
@@ -178,14 +187,14 @@ class _StatsScreenState extends State<StatsScreen> with SingleTickerProviderStat
Text('Last 7 Days', style: tt.titleSmall?.copyWith(
color: cs.onSurface.withValues(alpha: 0.6), fontWeight: FontWeight.w600)),
const SizedBox(height: 12),
- _barChart(weekData, cs),
+ _barChart(_weekData, cs),
const SizedBox(height: 28),
// ── Last 30 days chart ──
Text('Last 30 Days', style: tt.titleSmall?.copyWith(
color: cs.onSurface.withValues(alpha: 0.6), fontWeight: FontWeight.w600)),
const SizedBox(height: 12),
- _heatMap(monthData, tt, cs),
+ _heatMap(_monthData, tt, cs),
const SizedBox(height: 28),
// ── Recent Sessions ──
diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dart
index 7f48b0b9..93d10311 100644
--- a/lib/widgets/absorbing_card.dart
+++ b/lib/widgets/absorbing_card.dart
@@ -479,6 +479,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
errorBuilder: (_, __, ___) => _coverPlaceholder())
: CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,
httpHeaders: mediaHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _coverPlaceholder(),
errorWidget: (_, __, ___) => _coverPlaceholder())
: _coverPlaceholder(),
diff --git a/lib/widgets/author_card.dart b/lib/widgets/author_card.dart
index 613049ea..cb6eb66b 100644
--- a/lib/widgets/author_card.dart
+++ b/lib/widgets/author_card.dart
@@ -47,6 +47,7 @@ class AuthorCard extends StatelessWidget {
imageUrl: imageUrl,
fit: BoxFit.cover,
httpHeaders: headers,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _placeholder(cs),
errorWidget: (_, __, ___) => _placeholder(cs),
)
diff --git a/lib/widgets/book_card.dart b/lib/widgets/book_card.dart
index 0ed57913..5315e15a 100644
--- a/lib/widgets/book_card.dart
+++ b/lib/widgets/book_card.dart
@@ -6,6 +6,7 @@ import '../providers/library_provider.dart';
import '../services/download_service.dart';
import 'book_detail_sheet.dart';
import 'episode_list_sheet.dart';
+import 'pressable_card.dart';
class BookCard extends StatelessWidget {
final Map<String, dynamic> item;
@@ -190,7 +191,7 @@ class BookCard extends StatelessWidget {
// Square cover
AspectRatio(
aspectRatio: 1,
- child: _PressableCard(
+ child: PressableCard(
onTap: () => _navigateToDetail(context),
borderRadius: 12,
child: Card(
@@ -299,6 +300,7 @@ class _CoverImage extends StatelessWidget {
imageUrl: coverUrl!,
fit: fit,
httpHeaders: httpHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _placeholder(),
errorWidget: (_, __, ___) => _placeholder(),
);
@@ -316,61 +318,4 @@ class _CoverImage extends StatelessWidget {
),
);
}
-}
-
-/// Pressable wrapper that scales down slightly on tap for tactile feedback.
-class _PressableCard extends StatefulWidget {
- final Widget child;
- final VoidCallback onTap;
- final double borderRadius;
-
- const _PressableCard({
- required this.child,
- required this.onTap,
- this.borderRadius = 12,
- });
-
- @override
- State<_PressableCard> createState() => _PressableCardState();
-}
-
-class _PressableCardState extends State<_PressableCard>
- with SingleTickerProviderStateMixin {
- late final AnimationController _controller;
- late final Animation<double> _scale;
-
- @override
- void initState() {
- super.initState();
- _controller = AnimationController(
- vsync: this,
- duration: const Duration(milliseconds: 100),
- reverseDuration: const Duration(milliseconds: 200),
- );
- _scale = Tween<double>(begin: 1.0, end: 0.96).animate(
- CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
- );
- }
-
- @override
- void dispose() {
- _controller.dispose();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTapDown: (_) => _controller.forward(),
- onTapUp: (_) {
- _controller.reverse();
- widget.onTap();
- },
- onTapCancel: () => _controller.reverse(),
- child: ScaleTransition(
- scale: _scale,
- child: widget.child,
- ),
- );
- }
-}
+}
\ No newline at end of file
diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dart
index 9fd89d11..4cf2901d 100644
--- a/lib/widgets/book_detail_sheet.dart
+++ b/lib/widgets/book_detail_sheet.dart
@@ -152,6 +152,12 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
return auth.apiService?.getCoverUrl(widget.itemId, width: 800);
}
+ /// Low-res cover for the blurred background (much cheaper to filter).
+ String? get _blurCoverUrl {
+ final auth = context.read<AuthProvider>();
+ return auth.apiService?.getCoverUrl(widget.itemId, width: 200);
+ }
+
@override Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
@@ -159,14 +165,14 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.vertical(top: Radius.circular(24))),
child: Stack(children: [
- if (_coverUrl != null)
+ if (_blurCoverUrl != null)
Positioned.fill(
child: RepaintBoundary(
child: CachedNetworkImage(
- imageUrl: _coverUrl!, fit: BoxFit.cover,
+ imageUrl: _blurCoverUrl!, fit: BoxFit.cover,
httpHeaders: context.read<LibraryProvider>().mediaHeaders,
imageBuilder: (_, p) => ImageFiltered(
- imageFilter: ImageFilter.blur(sigmaX: 50, sigmaY: 50, tileMode: TileMode.decal),
+ imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30, tileMode: TileMode.decal),
child: Image(image: p, fit: BoxFit.cover)),
placeholder: (_, __) => const SizedBox(),
errorWidget: (_, __, ___) => const SizedBox(),
@@ -181,9 +187,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
? Center(child: CircularProgressIndicator(strokeWidth: 2, color: cs.onSurface.withValues(alpha: 0.24)))
: _item == null
? Center(child: Text('Failed to load', style: tt.bodyMedium?.copyWith(color: cs.onSurfaceVariant)))
- : AnimatedOpacity(
- opacity: 1.0, duration: const Duration(milliseconds: 300),
- child: _buildContent(context, cs, tt)),
+ : _buildContent(context, cs, tt),
]),
);
}
diff --git a/lib/widgets/episode_list_sheet.dart b/lib/widgets/episode_list_sheet.dart
index b5d976d6..1b379bf3 100644
--- a/lib/widgets/episode_list_sheet.dart
+++ b/lib/widgets/episode_list_sheet.dart
@@ -204,9 +204,10 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
if (mounted) setState(() => _isDownloadingAll = false);
}
- String? get _coverUrl {
+ /// Low-res cover for the blurred background (much cheaper to filter).
+ String? get _blurCoverUrl {
final auth = context.read<AuthProvider>();
- return auth.apiService?.getCoverUrl(_itemId, width: 800);
+ return auth.apiService?.getCoverUrl(_itemId, width: 200);
}
@override
@@ -214,7 +215,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final lib = context.watch<LibraryProvider>();
- final coverUrl = _coverUrl;
+ final blurCoverUrl = _blurCoverUrl;
return Container(
clipBehavior: Clip.antiAlias,
@@ -224,14 +225,14 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
),
child: Stack(children: [
// Blurred cover background
- if (coverUrl != null)
+ if (blurCoverUrl != null)
Positioned.fill(
child: RepaintBoundary(
child: CachedNetworkImage(
- imageUrl: coverUrl, fit: BoxFit.cover,
+ imageUrl: blurCoverUrl, fit: BoxFit.cover,
httpHeaders: lib.mediaHeaders,
imageBuilder: (_, p) => ImageFiltered(
- imageFilter: ImageFilter.blur(sigmaX: 50, sigmaY: 50, tileMode: TileMode.decal),
+ imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30, tileMode: TileMode.decal),
child: Image(image: p, fit: BoxFit.cover)),
placeholder: (_, __) => const SizedBox(),
errorWidget: (_, __, ___) => const SizedBox(),
@@ -609,9 +610,10 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
}
}
- String? get _coverUrl {
+ /// Low-res cover for the blurred background (much cheaper to filter).
+ String? get _blurCoverUrl {
final auth = context.read<AuthProvider>();
- return auth.apiService?.getCoverUrl(_itemId, width: 800);
+ return auth.apiService?.getCoverUrl(_itemId, width: 200);
}
@override
@@ -619,7 +621,7 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final lib = context.watch<LibraryProvider>();
- final coverUrl = _coverUrl;
+ final blurCoverUrl = _blurCoverUrl;
final dlKey = '$_itemId-$_episodeId';
@@ -653,14 +655,14 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
),
child: Stack(children: [
// Blurred cover background
- if (coverUrl != null)
+ if (blurCoverUrl != null)
Positioned.fill(
child: RepaintBoundary(
child: CachedNetworkImage(
- imageUrl: coverUrl, fit: BoxFit.cover,
+ imageUrl: blurCoverUrl, fit: BoxFit.cover,
httpHeaders: lib.mediaHeaders,
imageBuilder: (_, p) => ImageFiltered(
- imageFilter: ImageFilter.blur(sigmaX: 50, sigmaY: 50, tileMode: TileMode.decal),
+ imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30, tileMode: TileMode.decal),
child: Image(image: p, fit: BoxFit.cover)),
placeholder: (_, __) => const SizedBox(),
errorWidget: (_, __, ___) => const SizedBox(),
diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dart
index 57d53596..cc65c924 100644
--- a/lib/widgets/expanded_card.dart
+++ b/lib/widgets/expanded_card.dart
@@ -584,6 +584,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
errorBuilder: (_, __, ___) => _coverPlaceholder())
: CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,
httpHeaders: mediaHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _coverPlaceholder(),
errorWidget: (_, __, ___) => _coverPlaceholder())
: _coverPlaceholder(),
diff --git a/lib/widgets/home_section.dart b/lib/widgets/home_section.dart
index 625854ed..a5ec7d36 100644
--- a/lib/widgets/home_section.dart
+++ b/lib/widgets/home_section.dart
@@ -1,11 +1,13 @@
import 'dart:io';
import 'package:flutter/material.dart';
+import 'package:cached_network_image/cached_network_image.dart';
import 'package:provider/provider.dart';
import '../providers/library_provider.dart';
import 'book_card.dart';
import 'author_card.dart';
import 'series_card.dart';
import 'episode_list_sheet.dart';
+import 'pressable_card.dart';
class HomeSection extends StatelessWidget {
final String title;
@@ -224,7 +226,7 @@ class _EpisodeCard extends StatelessWidget {
final episode = item['recentEpisode'] as Map<String, dynamic>?;
final episodeTitle = episode?['title'] as String? ?? showTitle;
- return GestureDetector(
+ return PressableCard(
onTap: () {
if (episode != null) {
EpisodeDetailSheet.show(context, item, episode);
@@ -232,6 +234,7 @@ class _EpisodeCard extends StatelessWidget {
EpisodeListSheet.show(context, item);
}
},
+ borderRadius: 12,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
@@ -257,9 +260,14 @@ class _EpisodeCard extends StatelessWidget {
color: cs.surfaceContainerHigh,
child: Icon(Icons.podcasts_rounded, size: 32,
color: cs.onSurfaceVariant.withValues(alpha: 0.3))))
- : Image.network(coverUrl, fit: BoxFit.cover,
- headers: lib.mediaHeaders,
- errorBuilder: (_, __, ___) => Container(
+ : CachedNetworkImage(imageUrl: coverUrl, fit: BoxFit.cover,
+ httpHeaders: lib.mediaHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
+ placeholder: (_, __) => Container(
+ color: cs.surfaceContainerHigh,
+ child: Icon(Icons.podcasts_rounded, size: 32,
+ color: cs.onSurfaceVariant.withValues(alpha: 0.3))),
+ errorWidget: (_, __, ___) => Container(
color: cs.surfaceContainerHigh,
child: Icon(Icons.podcasts_rounded, size: 32,
color: cs.onSurfaceVariant.withValues(alpha: 0.3))))
diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dart
index 61bcbd66..938419c3 100644
--- a/lib/widgets/library_grid_tiles.dart
+++ b/lib/widgets/library_grid_tiles.dart
@@ -7,6 +7,7 @@ import '../providers/library_provider.dart';
import '../services/download_service.dart';
import 'book_detail_sheet.dart';
import 'episode_list_sheet.dart';
+import 'pressable_card.dart';
import 'series_books_sheet.dart';
// ═══════════════════════════════════════════════════════════════
@@ -56,7 +57,7 @@ class _GridBookTileState extends State<GridBookTile> {
final isDownloaded = _dl.isDownloaded(itemId);
final isFinished = lib.getProgressData(itemId)?['isFinished'] == true;
- return GestureDetector(
+ return PressableCard(
onTap: () {
if (itemId.isNotEmpty) {
if (lib.isPodcastLibrary) {
@@ -66,6 +67,7 @@ class _GridBookTileState extends State<GridBookTile> {
}
}
},
+ borderRadius: 10,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -86,6 +88,7 @@ class _GridBookTileState extends State<GridBookTile> {
imageUrl: coverUrl,
fit: BoxFit.cover,
httpHeaders: lib.mediaHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _placeholder(cs),
errorWidget: (_, __, ___) => _placeholder(cs),
)
@@ -221,7 +224,7 @@ class GridSeriesTile extends StatelessWidget {
final author = metadata['authorName'] as String? ?? '';
final coverUrl = lib.getCoverUrl(itemId);
- return GestureDetector(
+ return PressableCard(
onTap: () {
if (seriesId.isNotEmpty) {
showSeriesBooksSheet(
@@ -234,6 +237,7 @@ class GridSeriesTile extends StatelessWidget {
);
}
},
+ borderRadius: 10,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -253,6 +257,7 @@ class GridSeriesTile extends StatelessWidget {
imageUrl: coverUrl,
fit: BoxFit.cover,
httpHeaders: lib.mediaHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _placeholder(cs),
errorWidget: (_, __, ___) => _placeholder(cs),
)
diff --git a/lib/widgets/library_search_results.dart b/lib/widgets/library_search_results.dart
index 25d9ea50..a9c2de04 100644
--- a/lib/widgets/library_search_results.dart
+++ b/lib/widgets/library_search_results.dart
@@ -69,6 +69,7 @@ class BookResultTile extends StatelessWidget {
imageUrl: coverUrl,
fit: BoxFit.cover,
httpHeaders: context.read<LibraryProvider>().mediaHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _ph(cs),
errorWidget: (_, __, ___) => _ph(cs),
)
@@ -264,6 +265,7 @@ class AuthorResultTile extends StatelessWidget {
imageUrl: imageUrl,
fit: BoxFit.cover,
httpHeaders: context.read<LibraryProvider>().mediaHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _ph(cs),
errorWidget: (_, __, ___) => _ph(cs),
)
diff --git a/lib/widgets/metadata_lookup_sheet.dart b/lib/widgets/metadata_lookup_sheet.dart
index 394159f3..6b24e175 100644
--- a/lib/widgets/metadata_lookup_sheet.dart
+++ b/lib/widgets/metadata_lookup_sheet.dart
@@ -406,6 +406,7 @@ class _MetadataLookupSheetState extends State<MetadataLookupSheet> {
? CachedNetworkImage(
imageUrl: cover,
fit: BoxFit.cover,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _placeholder(cs),
errorWidget: (_, __, ___) => _placeholder(cs),
)
diff --git a/lib/widgets/pressable_card.dart b/lib/widgets/pressable_card.dart
new file mode 100644
index 00000000..ae2c954d
--- /dev/null
+++ b/lib/widgets/pressable_card.dart
@@ -0,0 +1,59 @@
+import 'package:flutter/material.dart';
+
+/// Pressable wrapper that scales down slightly on tap for tactile feedback.
+class PressableCard extends StatefulWidget {
+ final Widget child;
+ final VoidCallback onTap;
+ final double borderRadius;
+
+ const PressableCard({
+ super.key,
+ required this.child,
+ required this.onTap,
+ this.borderRadius = 12,
+ });
+
+ @override
+ State<PressableCard> createState() => _PressableCardState();
+}
+
+class _PressableCardState extends State<PressableCard>
+ with SingleTickerProviderStateMixin {
+ late final AnimationController _controller;
+ late final Animation<double> _scale;
+
+ @override
+ void initState() {
+ super.initState();
+ _controller = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 100),
+ reverseDuration: const Duration(milliseconds: 200),
+ );
+ _scale = Tween<double>(begin: 1.0, end: 0.96).animate(
+ CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
+ );
+ }
+
+ @override
+ void dispose() {
+ _controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return GestureDetector(
+ onTapDown: (_) => _controller.forward(),
+ onTapUp: (_) {
+ _controller.reverse();
+ widget.onTap();
+ },
+ onTapCancel: () => _controller.reverse(),
+ child: ScaleTransition(
+ scale: _scale,
+ child: widget.child,
+ ),
+ );
+ }
+}
diff --git a/lib/widgets/series_books_sheet.dart b/lib/widgets/series_books_sheet.dart
index 58248c9c..83157e2f 100644
--- a/lib/widgets/series_books_sheet.dart
+++ b/lib/widgets/series_books_sheet.dart
@@ -322,6 +322,7 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
imageUrl: coverUrl,
fit: BoxFit.cover,
httpHeaders: context.read<LibraryProvider>().mediaHeaders,
+ fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) =>
_placeholder(cs),
errorWidget: (_, __, ___) =>