A cross platform Audiobookshelf client for Android and iOS
Dart
Blur-pad square covers, fix expanded history timestamps, deduplicate card button logic
Barnabas75cf62934f1a
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dartindex f2c5fa2c..b79d66d9 100644--- a/lib/screens/app_shell.dart+++ b/lib/screens/app_shell.dart@@ -21,7 +21,6 @@ import 'stats_screen.dart';import 'settings_screen.dart';import '../widgets/welcome_sheet.dart';import '../services/update_checker_service.dart';-import '../services/player_settings.dart';import 'package:url_launcher/url_launcher.dart';class AppShell extends StatefulWidget {diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dartindex 827bc901..d9af5d32 100644--- a/lib/screens/home_screen.dart+++ b/lib/screens/home_screen.dart@@ -6,6 +6,7 @@ import '../providers/auth_provider.dart';import '../providers/library_provider.dart';import '../services/audio_player_service.dart';import '../services/download_service.dart';+import '../widgets/absorbing_shared.dart';import '../widgets/home_section.dart';import '../widgets/absorb_page_header.dart';import '../widgets/shimmer.dart';@@ -772,23 +773,31 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {Positioned.fill(child: coverUrl != null? coverUrl.startsWith('/')- ? Image.file(File(coverUrl), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => Container(- color: cs.surfaceContainerHighest,- child: Icon(Icons.headphones_rounded,- size: 22, 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: 22, color: cs.onSurfaceVariant)),- errorWidget: (_, __, ___) => Container(- color: cs.surfaceContainerHighest,- child: Icon(Icons.headphones_rounded,- size: 22, color: cs.onSurfaceVariant)))+ ? BlurPaddedCover(+ child: Image.file(File(coverUrl), fit: BoxFit.contain,+ errorBuilder: (_, __, ___) => Container(+ color: cs.surfaceContainerHighest,+ child: Icon(Icons.headphones_rounded,+ size: 22, color: cs.onSurfaceVariant))),+ blurChild: Image.file(File(coverUrl), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => const SizedBox.shrink()))+ : BlurPaddedCover(+ child: CachedNetworkImage(+ imageUrl: coverUrl, fit: BoxFit.contain,+ httpHeaders: lib.mediaHeaders,+ fadeInDuration: const Duration(milliseconds: 300),+ placeholder: (_, __) => Container(+ color: cs.surfaceContainerHighest,+ child: Icon(Icons.headphones_rounded,+ size: 22, color: cs.onSurfaceVariant)),+ errorWidget: (_, __, ___) => Container(+ color: cs.surfaceContainerHighest,+ child: Icon(Icons.headphones_rounded,+ size: 22, color: cs.onSurfaceVariant))),+ blurChild: CachedNetworkImage(+ imageUrl: coverUrl, fit: BoxFit.cover,+ httpHeaders: lib.mediaHeaders,+ errorWidget: (_, __, ___) => const SizedBox.shrink())): Container(color: cs.surfaceContainerHighest,child: Icon(Icons.headphones_rounded,diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dartindex 559ef59b..688bd3ce 100644--- a/lib/widgets/absorbing_card.dart+++ b/lib/widgets/absorbing_card.dart@@ -9,22 +9,13 @@ import '../providers/library_provider.dart';import '../screens/app_shell.dart';import '../services/audio_player_service.dart';import '../services/download_service.dart';-import '../services/playback_history_service.dart';-import 'book_detail_sheet.dart';-import 'episode_list_sheet.dart';-import 'equalizer_sheet.dart';import 'absorbing_shared.dart';-import 'card_chapters_sheet.dart';import 'card_edge_progress_bar.dart';import 'card_progress_bar.dart';import 'card_playback_controls.dart';import 'card_buttons.dart';-import 'sleep_timer_sheet.dart';-import 'chromecast_button.dart';import '../services/chromecast_service.dart';import 'expanded_card.dart';-import '../screens/car_mode_screen.dart';-import 'notes_sheet.dart';class AbsorbingCard extends StatefulWidget {final Map<String, dynamic> item;@@ -93,36 +84,6 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCliMap<String, dynamic>? get _recentEpisode => widget.item['recentEpisode'] as Map<String, dynamic>?;/// Resolve full episode data for the current episode.- /// Prefers full episode data from media.episodes or API over the- /// stripped-down recentEpisode from continue-listening.- Future<Map<String, dynamic>> _resolveEpisode() async {- final epId = _episodeId ?? widget.player.currentEpisodeId;- // Check episodes embedded in the podcast item (full data)- final episodes = _media['episodes'] as List<dynamic>? ?? [];- for (final ep in episodes) {- if (ep is Map<String, dynamic> && ep['id'] == epId) return ep;- }- // Fetch full item from API- final api = context.read<AuthProvider>().apiService;- if (api != null) {- final fullItem = await api.getLibraryItem(_itemId);- if (fullItem != null) {- final media = fullItem['media'] as Map<String, dynamic>? ?? {};- final eps = media['episodes'] as List<dynamic>? ?? [];- for (final ep in eps) {- if (ep is Map<String, dynamic> && ep['id'] == epId) return ep;- }- }- }- // Fall back to recentEpisode (may be missing description/chapters/etc.)- if (_recentEpisode != null) return _recentEpisode!;- // Last resort: minimal data from player- return {- 'id': epId,- 'title': widget.player.currentEpisodeTitle,- 'duration': widget.player.totalDuration,- };- }// Episode ID: prefer recentEpisode, fall back to compound absorbing keyString? get _episodeId {final re = _recentEpisode;@@ -633,12 +594,19 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli// Cover image_coverUrl != null? _isLocalCover- ? Image.file(File(_coverUrl!), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => const CoverPlaceholder())- : CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,+ ? BlurPaddedCover(child: Image.file(File(_coverUrl!), fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,+ errorBuilder: (_, __, ___) => const CoverPlaceholder()),+ blurChild: Image.file(File(_coverUrl!), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => const SizedBox.shrink()),+ enabled: !_rectangleCovers)+ : BlurPaddedCover(child: CachedNetworkImage(imageUrl: _coverUrl!, fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,httpHeaders: mediaHeaders,placeholder: (_, __) => const CoverPlaceholder(),- errorWidget: (_, __, ___) => const CoverPlaceholder())+ errorWidget: (_, __, ___) => const CoverPlaceholder()),+ blurChild: CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,+ httpHeaders: mediaHeaders,+ errorWidget: (_, __, ___) => const SizedBox.shrink()),+ enabled: !_rectangleCovers): const CoverPlaceholder(),// Downloaded badge (top-right)if (isDownloaded)@@ -942,459 +910,41 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli}}- // ── Dynamic button builders ─────────────────────────────────+ // ── Dynamic button builders (delegated) ─────────────────────++ CardActionDelegate _makeActions() => CardActionDelegate(+ context: context,+ player: widget.player,+ item: widget.item,+ itemId: _itemId,+ episodeId: _episodeId,+ isPodcastEpisode: _isPodcastEpisode,+ title: _title,+ author: _author,+ coverUrl: _coverUrl,+ duration: _duration,+ effectiveDuration: _effectiveDuration,+ chapters: _chapters,+ recentEpisode: _recentEpisode,+ isActive: _isActive,+ isPlaybackActive: _isPlaybackActive,+ isCastingThis: _isCastingThis,+ speedAdjustedTime: _speedAdjustedTime,+ savedSpeed: _savedSpeed,+ buttonLayout: _buttonLayout,+ buttonOrder: _buttonOrder,+ removeFromAbsorbing: _removeFromAbsorbing,+ onReorder: (newOrder) {+ setState(() => _buttonOrder = newOrder);+ PlayerSettings.setCardButtonOrder(newOrder);+ },+ );int get _visibleButtonCount => PlayerSettings.buttonCountForLayout(_buttonLayout);- List<Widget> _buildButtonGrid(Color accent, TextTheme tt) {- final count = _visibleButtonCount;- final ids = _buttonOrder.take(count).toList();-- // Determine columns per row based on layout- int cols;- switch (_buttonLayout) {- case 'compact': cols = 3; break;- case 'row': cols = 5; break;- case 'expanded': cols = 3; break;- case 'full': cols = 3; break;- default: cols = 2; break; // standard- }-- final compact = cols >= 5;- final short = cols >= 3;- final singleRow = count == ids.length && ids.length <= cols;- final rows = <Widget>[];- if (singleRow) rows.add(const SizedBox(height: 8));- for (int r = 0; r < ids.length; r += cols) {- if (r > 0) rows.add(const SizedBox(height: 6));- final end = (r + cols).clamp(0, ids.length);- final rowIds = ids.sublist(r, end);- rows.add(Row(children: [- for (int c = 0; c < rowIds.length; c++) ...[- if (c > 0) const SizedBox(width: 8),- Expanded(child: _buildCardButton(rowIds[c], accent, tt, compact: compact, short: short)),- ],- ]));- }- if (singleRow) rows.add(const SizedBox(height: 6));- return rows;- }-- Widget _buildCardButton(String id, Color accent, TextTheme tt, {bool large = false, bool compact = false, bool short = false}) {- switch (id) {- case 'chapters':- return CardWideButton(- icon: Icons.list_rounded, label: 'Chapters',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: _chapters.isNotEmpty ? () => _showChapters(context, accent, tt) : null,- );- case 'speed':- return CardWideButton(- icon: Icons.speed_rounded, label: 'Speed',- accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,- child: CardSpeedButtonInline(player: widget.player, accent: accent, isActive: _isActive, large: large, compact: compact, itemId: _itemId),- );- case 'sleep':- return CardWideButton(- icon: Icons.bedtime_outlined, label: short ? 'Sleep' : 'Sleep Timer',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- child: CardSleepButtonInline(accent: accent, isActive: _isPlaybackActive, large: large, compact: compact),- );- case 'bookmarks':- return CardWideButton(- icon: Icons.bookmark_outline_rounded, label: 'Bookmarks',- accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,- child: CardBookmarkButtonInline(- player: widget.player, accent: accent,- isActive: _isActive, itemId: _itemId, large: large, compact: compact, short: short,- ),- );- case 'details':- return CardWideButton(- icon: (_episodeId != null || _isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,- label: short ? 'Details' : ((_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details'),- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () async {- if (_episodeId != null || _isPodcastEpisode) {- final episode = await _resolveEpisode();- if (mounted) EpisodeDetailSheet.show(context, widget.item, episode);- } else {- showBookDetailSheet(context, _itemId);- }- },- );- case 'equalizer':- return CardWideButton(- icon: Icons.equalizer_rounded, label: compact ? 'EQ' : 'Equalizer',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => showEqualizerSheet(context, accent),- );- case 'cast':- return ListenableBuilder(- listenable: ChromecastService(),- builder: (_, __) {- final cast = ChromecastService();- final String castLabel;- if (compact || short) {- castLabel = cast.isConnected ? 'Casting' : 'Cast';- } else if (cast.isCasting && cast.castingItemId == _itemId) {- castLabel = 'Casting to ${cast.connectedDeviceName ?? "device"}';- } else if (cast.isConnected) {- castLabel = 'Cast to ${cast.connectedDeviceName ?? "device"}';- } else {- castLabel = 'Cast to Device';- }- return CardWideButton(- icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,- label: castLabel, accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => _handleCastTap(context, accent),- );- },- );- case 'history':- return CardWideButton(- icon: Icons.history_rounded, label: (compact || short) ? 'History' : 'Playback History',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => _showHistory(context, accent, tt),- );- case 'remove':- return CardWideButton(- icon: Icons.remove_circle_outline_rounded, label: (compact || short) ? 'Remove' : 'Remove from Absorbing',- accent: Colors.red.shade300, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: _removeFromAbsorbing,- );- case 'car':- return CardWideButton(- icon: Icons.directions_car_rounded, label: 'Car Mode',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => _openCarMode(context),- );- case 'notes':- return CardWideButton(- icon: Icons.note_rounded, label: 'Notes',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => _showNotes(context, accent),- );- default:- return const SizedBox.shrink();- }- }-- Widget _buildMoreMenuItem(String id, Color accent, TextTheme tt, BuildContext ctx) {- switch (id) {- case 'chapters':- return MoreMenuItem(- icon: Icons.list_rounded, label: 'Chapters', accent: accent,- enabled: _chapters.isNotEmpty,- onTap: () { Navigator.pop(ctx); _showChapters(context, accent, tt); },- );- case 'speed':- return MoreMenuItem(- icon: Icons.speed_rounded, label: 'Speed', accent: accent,- enabled: true,- onTap: () {- Navigator.pop(ctx);- showModalBottomSheet(context: context, backgroundColor: Colors.transparent, useSafeArea: true,- builder: (_) => CardSpeedSheet(player: widget.player, accent: accent, itemId: _itemId));- },- );- case 'sleep':- return MoreMenuItem(- icon: Icons.bedtime_outlined, label: 'Sleep Timer', accent: accent,- enabled: true,- onTap: () {- Navigator.pop(ctx);- showSleepTimerSheet(context, accent);- },- );- case 'bookmarks':- return MoreMenuItem(- icon: Icons.bookmark_outline_rounded, label: 'Bookmarks', accent: accent,- enabled: _isPlaybackActive,- onTap: () {- Navigator.pop(ctx);- showModalBottomSheet(context: context, backgroundColor: Colors.transparent, isScrollControlled: true, useSafeArea: true,- builder: (_) => DraggableScrollableSheet(- initialChildSize: 0.6, minChildSize: 0.05, snap: true, maxChildSize: 0.9, expand: false,- builder: (_, sc) => SimpleBookmarkSheet(itemId: _itemId, player: widget.player, accent: accent, scrollController: sc, onChanged: () {}),- ),- );- },- );- case 'details':- return MoreMenuItem(- icon: (_episodeId != null || _isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,- label: (_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details',- accent: accent,- onTap: () async {- Navigator.pop(ctx);- if (_episodeId != null || _isPodcastEpisode) {- final episode = await _resolveEpisode();- if (mounted) EpisodeDetailSheet.show(context, widget.item, episode);- } else {- showBookDetailSheet(context, _itemId);- }- },- );- case 'equalizer':- return MoreMenuItem(- icon: Icons.equalizer_rounded, label: 'Equalizer', accent: accent,- onTap: () { Navigator.pop(ctx); showEqualizerSheet(context, accent); },- );- case 'cast':- return ListenableBuilder(- listenable: ChromecastService(),- builder: (_, __) {- final cast = ChromecastService();- final String castLabel;- if (cast.isCasting && cast.castingItemId == _itemId) {- castLabel = 'Casting to ${cast.connectedDeviceName ?? "device"}';- } else if (cast.isConnected) {- castLabel = 'Cast to ${cast.connectedDeviceName ?? "device"}';- } else {- castLabel = 'Cast to Device';- }- return MoreMenuItem(- icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,- label: castLabel, accent: accent,- onTap: () { Navigator.pop(ctx); _handleCastTap(context, accent); },- );- },- );- case 'history':- return MoreMenuItem(- icon: Icons.history_rounded, label: 'Playback History', accent: accent,- enabled: true,- onTap: () { Navigator.pop(ctx); _showHistory(context, accent, tt); },- );- case 'remove':- return MoreMenuItem(- icon: Icons.remove_circle_outline_rounded, label: 'Remove from Absorbing',- accent: Colors.red.shade300,- onTap: () { Navigator.pop(ctx); _removeFromAbsorbing(); },- );- case 'car':- return MoreMenuItem(- icon: Icons.directions_car_rounded, label: 'Car Mode', accent: accent,- onTap: () { Navigator.pop(ctx); _openCarMode(context); },- );- case 'notes':- return MoreMenuItem(- icon: Icons.note_rounded, label: 'Notes', accent: accent,- onTap: () { Navigator.pop(ctx); _showNotes(context, accent); },- );- default:- return const SizedBox.shrink();- }- }-- void _showNotes(BuildContext context, Color accent) {- NotesSheet.show(context,- itemId: _itemId,- itemTitle: _title,- accent: accent,- );- }-- void _openCarMode(BuildContext context) {- Navigator.of(context).push(MaterialPageRoute(- builder: (_) => CarModeScreen(- player: widget.player,- itemId: _itemId,- fallbackTitle: _title,- fallbackAuthor: _author,- fallbackCoverUrl: _coverUrl,- fallbackDuration: _effectiveDuration,- fallbackChapters: _chapters,- episodeId: _episodeId,- episodeTitle: _recentEpisode?['title'] as String?,- ),- ));- }+ List<Widget> _buildButtonGrid(Color accent, TextTheme tt) => _makeActions().buildButtonGrid(accent, tt);- void _handleCastTap(BuildContext context, Color accent) {- final cast = ChromecastService();- final auth = context.read<AuthProvider>();- final api = auth.apiService;- if (cast.isCasting && cast.castingItemId == _itemId) {- showModalBottomSheet(- context: context,- backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,- shape: const RoundedRectangleBorder(- borderRadius: BorderRadius.vertical(top: Radius.circular(24)),- ),- builder: (_) => CastControlSheet(),- );- } else if (cast.isConnected) {- if (api != null) {- cast.castItem(- api: api, itemId: _itemId, title: _title, author: _author,- coverUrl: _coverUrl, totalDuration: _duration, chapters: _chapters,- episodeId: _episodeId ?? widget.player.currentEpisodeId,- );- }- } else {- showCastDevicePicker(context,- api: api, itemId: _itemId, title: _title, author: _author,- coverUrl: _coverUrl, totalDuration: _duration, chapters: _chapters,- episodeId: _episodeId ?? widget.player.currentEpisodeId);- }- }-- void _showChapters(BuildContext context, Color accent, TextTheme tt) {- final cast = ChromecastService();- final chapters = _isCastingThis ? cast.castingChapters : (_isActive ? widget.player.chapters : _chapters);- if (chapters.isEmpty) return;- double pos = 0;- if (_isCastingThis) {- pos = cast.castPosition.inMilliseconds / 1000.0;- } else if (_isActive) {- pos = widget.player.position.inMilliseconds / 1000.0;- } else {- final lib = context.read<LibraryProvider>();- final pd = _episodeId != null- ? lib.getEpisodeProgressData(_itemId, _episodeId!)- : lib.getProgressData(_itemId);- pos = (pd?['currentTime'] as num?)?.toDouble() ?? 0;- }- showChaptersSheet(- context: context, accent: accent, tt: tt,- chapters: chapters,- totalDuration: _isCastingThis ? cast.castingDuration : (_isActive ? widget.player.totalDuration : _duration),- currentPosition: pos,- isPlaybackActive: _isPlaybackActive,- isCastingThis: _isCastingThis,- displaySpeed: _speedAdjustedTime ? (_isActive ? widget.player.speed : _savedSpeed) : 1.0,- player: widget.player,- itemId: _itemId,- );- }-- void _showHistory(BuildContext context, Color accent, TextTheme tt) {- showModalBottomSheet(- context: context, isScrollControlled: true, useSafeArea: true,- backgroundColor: Colors.transparent,- builder: (ctx) => DraggableScrollableSheet(- expand: false, initialChildSize: 0.6, minChildSize: 0.05, snap: true, maxChildSize: 0.9,- builder: (_, sc) => Container(- decoration: BoxDecoration(- color: Theme.of(context).bottomSheetTheme.backgroundColor,- borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),- border: Border(top: BorderSide(color: accent.withValues(alpha: 0.2), width: 1)),- ),- child: Column(children: [- Padding(padding: const EdgeInsets.symmetric(vertical: 12),- child: Container(width: 40, height: 4, decoration: BoxDecoration(color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.24), borderRadius: BorderRadius.circular(2)))),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Row(children: [- const Spacer(),- Text('Playback History', style: tt.titleMedium?.copyWith(fontWeight: FontWeight.w600)),- const Spacer(),- IconButton(- icon: Icon(Icons.delete_outline_rounded, size: 20, color: Theme.of(context).colorScheme.onSurfaceVariant),- onPressed: () async {- await PlaybackHistoryService().clearHistory(_itemId);- Navigator.pop(ctx);- },- tooltip: 'Clear history',- ),- ]),- ),- if (_isActive)- Padding(- padding: const EdgeInsets.fromLTRB(16, 4, 16, 8),- child: Text('Tap an event to jump to that position',- style: tt.bodySmall?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant.withValues(alpha: 0.6), fontStyle: FontStyle.italic)),- )- else- const SizedBox(height: 8),- Expanded(child: FutureBuilder<List<PlaybackEvent>>(- future: PlaybackHistoryService().getHistory(_itemId),- builder: (ctx, snap) {- if (!snap.hasData) return const Center(child: CircularProgressIndicator(strokeWidth: 2));- final events = snap.data!;- if (events.isEmpty) return Center(child: Text('No history yet', style: tt.bodyMedium?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant)));-- // Build list items with session date headers- final items = <Widget>[];- String? lastDateLabel;- for (int i = 0; i < events.length; i++) {- final e = events[i];- final dateLabel = _dateLabel(e.timestamp);- if (dateLabel != lastDateLabel) {- lastDateLabel = dateLabel;- items.add(Padding(- padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),- child: Text(dateLabel, style: tt.labelSmall?.copyWith(- color: accent.withValues(alpha: 0.6), fontWeight: FontWeight.w600, letterSpacing: 0.5)),- ));- }- final posLabel = fmtTime(e.positionSeconds);- final timeStr = _timeOfDay(e.timestamp);- items.add(ListTile(- dense: true, visualDensity: const VisualDensity(vertical: -2),- leading: Icon(historyIcon(e.type), size: 18, color: accent.withValues(alpha: 0.7)),- title: Text(e.label, style: tt.bodySmall?.copyWith(color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7))),- subtitle: Text('at $posLabel', style: tt.labelSmall?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant)),- trailing: Text(timeStr, style: tt.labelSmall?.copyWith(color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.3))),- onTap: _isActive ? () {- widget.player.seekTo(Duration(seconds: e.positionSeconds.round()));- Navigator.pop(ctx);- ScaffoldMessenger.of(context).showSnackBar(SnackBar(duration: const Duration(seconds: 3), content: Text('Jumped to $posLabel')));- } : null,- ));- }-- return ListView(controller: sc, children: items);- },- )),- ]),- ),- ),- );- }-- void _showMoreMenu(BuildContext context, Color accent, TextTheme tt) {- final count = _visibleButtonCount;- final overflowIds = _buttonOrder.skip(count).toList();- showModalBottomSheet(- context: context,- backgroundColor: Colors.transparent,- isScrollControlled: true,- builder: (ctx) => MoreMenuSheet(- overflowIds: overflowIds,- allIds: _buttonOrder,- visibleCount: count,- accent: accent,- buildItem: (id) => _buildMoreMenuItem(id, accent, tt, ctx),- onReorder: (newOrder) {- setState(() => _buttonOrder = newOrder);- PlayerSettings.setCardButtonOrder(newOrder);- },- ),- );- }-- String _dateLabel(DateTime dt) {- final now = DateTime.now();- final today = DateTime(now.year, now.month, now.day);- final date = DateTime(dt.year, dt.month, dt.day);- if (date == today) return 'Today';- if (date == today.subtract(const Duration(days: 1))) return 'Yesterday';- if (now.difference(dt).inDays < 7) {- const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];- return days[dt.weekday - 1];- }- return '${dt.month}/${dt.day}/${dt.year}';- }-- String _timeOfDay(DateTime dt) {- final h = dt.hour % 12 == 0 ? 12 : dt.hour % 12;- final m = dt.minute.toString().padLeft(2, '0');- final ampm = dt.hour < 12 ? 'AM' : 'PM';- return '$h:$m $ampm';- }+ void _showMoreMenu(BuildContext context, Color accent, TextTheme tt) => _makeActions().showMoreMenu(accent, tt);}diff --git a/lib/widgets/absorbing_shared.dart b/lib/widgets/absorbing_shared.dartindex c0c87260..9466c57e 100644--- a/lib/widgets/absorbing_shared.dart+++ b/lib/widgets/absorbing_shared.dart@@ -1,10 +1,31 @@import 'dart:math' as math;+import 'dart:ui';import 'package:flutter/material.dart';import 'package:provider/provider.dart';import '../providers/auth_provider.dart';import '../services/download_service.dart';import '../services/playback_history_service.dart';+String dateLabel(DateTime dt) {+ final now = DateTime.now();+ final today = DateTime(now.year, now.month, now.day);+ final date = DateTime(dt.year, dt.month, dt.day);+ if (date == today) return 'Today';+ if (date == today.subtract(const Duration(days: 1))) return 'Yesterday';+ if (now.difference(dt).inDays < 7) {+ const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];+ return days[dt.weekday - 1];+ }+ return '${dt.month}/${dt.day}/${dt.year}';+}++String timeOfDay(DateTime dt) {+ final h = dt.hour % 12 == 0 ? 12 : dt.hour % 12;+ final m = dt.minute.toString().padLeft(2, '0');+ final ampm = dt.hour < 12 ? 'AM' : 'PM';+ return '$h:$m $ampm';+}+String fmtTime(double s) {if (s < 0) s = 0;final h = (s / 3600).floor(); final m = ((s % 3600) / 60).floor(); final sec = (s % 60).floor();@@ -45,6 +66,35 @@ class CoverPlaceholder extends StatelessWidget {}}+/// Shows [child] with BoxFit.contain; when the image doesn't fill the square,+/// a blurred copy of the cover is drawn behind it to fill the empty sides.+/// Set [enabled] to false to skip the blur and just render [child] directly.+class BlurPaddedCover extends StatelessWidget {+ final Widget child;+ final Widget blurChild;+ final bool enabled;+ const BlurPaddedCover({super.key, required this.child, required this.blurChild, this.enabled = true});++ @override+ Widget build(BuildContext context) {+ if (!enabled) return child;+ return Stack(+ fit: StackFit.expand,+ children: [+ // Blurred background fill+ ImageFiltered(+ imageFilter: ImageFilter.blur(sigmaX: 24, sigmaY: 24, tileMode: TileMode.decal),+ child: blurChild,+ ),+ // Darkening scrim so the foreground cover pops+ Container(color: Colors.black.withValues(alpha: 0.15)),+ // Actual cover, contained (no crop)+ child,+ ],+ );+ }+}+// ─── DOWNLOAD BUTTON WITH FILL BAR (wide card style) ────────class DownloadWideButton extends StatefulWidget {diff --git a/lib/widgets/book_card.dart b/lib/widgets/book_card.dartindex 6d1fb12c..7d14b7dd 100644--- a/lib/widgets/book_card.dart+++ b/lib/widgets/book_card.dart@@ -5,6 +5,7 @@ import 'package:cached_network_image/cached_network_image.dart';import '../providers/library_provider.dart';import '../services/audio_player_service.dart';import '../services/download_service.dart';+import 'absorbing_shared.dart';import 'book_detail_sheet.dart';import 'episode_list_sheet.dart';@@ -223,7 +224,7 @@ class BookCard extends StatelessWidget {child: Stack(fit: StackFit.expand,children: [- _CoverImage(coverUrl: coverUrl, cs: cs, httpHeaders: headers),+ _CoverImage(coverUrl: coverUrl, cs: cs, httpHeaders: headers, coverAspectRatio: coverAspectRatio),if (progress > 0 && !isFinished)Positioned(left: 0,@@ -343,8 +344,9 @@ class _CoverImage extends StatelessWidget {final ColorScheme cs;final BoxFit fit;final Map<String, String> httpHeaders;+ final double coverAspectRatio;- const _CoverImage({required this.coverUrl, required this.cs, this.fit = BoxFit.cover, this.httpHeaders = const {}});+ const _CoverImage({required this.coverUrl, required this.cs, this.fit = BoxFit.cover, this.httpHeaders = const {}, this.coverAspectRatio = 1.0});@overrideWidget build(BuildContext context) {@@ -352,21 +354,37 @@ class _CoverImage extends StatelessWidget {return _placeholder();}+ final isSquare = (coverAspectRatio - 1.0).abs() < 0.01;+ final effectiveFit = isSquare ? BoxFit.contain : fit;+// Local file path (offline cached cover)if (coverUrl!.startsWith('/')) {final file = File(coverUrl!);if (file.existsSync()) {- return Image.file(file, fit: fit, errorBuilder: (_, __, ___) => _placeholder());+ return BlurPaddedCover(+ enabled: isSquare,+ child: Image.file(file, fit: effectiveFit, errorBuilder: (_, __, ___) => _placeholder()),+ blurChild: Image.file(file, fit: BoxFit.cover, errorBuilder: (_, __, ___) => const SizedBox.shrink()),+ );}return _placeholder();}- return CachedNetworkImage(- imageUrl: coverUrl!,- fit: fit,- httpHeaders: httpHeaders,- placeholder: (_, __) => _placeholder(),- errorWidget: (_, __, ___) => _placeholder(),+ return BlurPaddedCover(+ enabled: isSquare,+ child: CachedNetworkImage(+ imageUrl: coverUrl!,+ fit: effectiveFit,+ httpHeaders: httpHeaders,+ placeholder: (_, __) => _placeholder(),+ errorWidget: (_, __, ___) => _placeholder(),+ ),+ blurChild: CachedNetworkImage(+ imageUrl: coverUrl!,+ fit: BoxFit.cover,+ httpHeaders: httpHeaders,+ errorWidget: (_, __, ___) => const SizedBox.shrink(),+ ),);}diff --git a/lib/widgets/card_buttons.dart b/lib/widgets/card_buttons.dartindex 85508e35..4b8cd7e5 100644--- a/lib/widgets/card_buttons.dart+++ b/lib/widgets/card_buttons.dart@@ -4,13 +4,23 @@ import 'package:provider/provider.dart';import '../providers/auth_provider.dart';import '../providers/library_provider.dart';import '../screens/app_shell.dart';+import '../screens/car_mode_screen.dart';import '../services/audio_player_service.dart';import '../services/bookmark_service.dart';import '../services/chromecast_service.dart';+import '../services/playback_history_service.dart';import '../services/sleep_timer_service.dart';import 'absorb_slider.dart';+import 'absorbing_shared.dart';import 'audio_output_sheet.dart';+import 'book_detail_sheet.dart';import 'card_button_config.dart';+import 'card_chapters_sheet.dart';+import 'chromecast_button.dart';+import 'episode_detail_sheet.dart';+import 'episode_list_sheet.dart';+import 'equalizer_sheet.dart';+import 'notes_sheet.dart';import 'sleep_timer_sheet.dart';/// Wrapper that gives any child a press-down opacity+scale effect.@@ -997,3 +1007,505 @@ class _MoreMenuSheetState extends State<MoreMenuSheet> {);}}++// ═══════════════════════════════════════════════════════════════+// Shared action delegate for absorbing card & expanded card+// Eliminates duplicated button/sheet logic between the two.+// ═══════════════════════════════════════════════════════════════++class CardActionDelegate {+ final BuildContext context;+ final AudioPlayerService player;+ final Map<String, dynamic> item;+ final String itemId;+ final String? episodeId;+ final bool isPodcastEpisode;+ final String title;+ final String? author;+ final String? coverUrl;+ final double duration;+ final double effectiveDuration;+ final List<dynamic> chapters;+ final Map<String, dynamic>? recentEpisode;+ final bool isActive;+ final bool isPlaybackActive;+ final bool isCastingThis;+ final bool speedAdjustedTime;+ final double savedSpeed;+ final String buttonLayout;+ final List<String> buttonOrder;+ final VoidCallback removeFromAbsorbing;+ final VoidCallback? onRemoveExtra;+ final void Function(List<String>) onReorder;++ CardActionDelegate({+ required this.context,+ required this.player,+ required this.item,+ required this.itemId,+ this.episodeId,+ this.isPodcastEpisode = false,+ required this.title,+ this.author,+ this.coverUrl,+ required this.duration,+ required this.effectiveDuration,+ required this.chapters,+ this.recentEpisode,+ required this.isActive,+ required this.isPlaybackActive,+ required this.isCastingThis,+ required this.speedAdjustedTime,+ required this.savedSpeed,+ required this.buttonLayout,+ required this.buttonOrder,+ required this.removeFromAbsorbing,+ this.onRemoveExtra,+ required this.onReorder,+ });++ Map<String, dynamic> get _media => item['media'] as Map<String, dynamic>? ?? {};++ int get visibleButtonCount => PlayerSettings.buttonCountForLayout(buttonLayout);++ List<Widget> buildButtonGrid(Color accent, TextTheme tt) {+ final count = visibleButtonCount;+ final ids = buttonOrder.take(count).toList();++ int cols;+ switch (buttonLayout) {+ case 'compact': cols = 3; break;+ case 'row': cols = 5; break;+ case 'expanded': cols = 3; break;+ case 'full': cols = 3; break;+ default: cols = 2; break;+ }++ final compact = cols >= 5;+ final short = cols >= 3;+ final singleRow = count == ids.length && ids.length <= cols;+ final rows = <Widget>[];+ if (singleRow) rows.add(const SizedBox(height: 8));+ for (int r = 0; r < ids.length; r += cols) {+ if (r > 0) rows.add(const SizedBox(height: 6));+ final end = (r + cols).clamp(0, ids.length);+ final rowIds = ids.sublist(r, end);+ rows.add(Row(children: [+ for (int c = 0; c < rowIds.length; c++) ...[+ if (c > 0) const SizedBox(width: 8),+ Expanded(child: buildCardButton(rowIds[c], accent, tt, compact: compact, short: short)),+ ],+ ]));+ }+ if (singleRow) rows.add(const SizedBox(height: 6));+ return rows;+ }++ Widget buildCardButton(String id, Color accent, TextTheme tt, {bool compact = false, bool short = false}) {+ final large = MediaQuery.sizeOf(context).height > 700;+ switch (id) {+ case 'chapters':+ return CardWideButton(+ icon: Icons.list_rounded, label: 'Chapters',+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,+ onTap: chapters.isNotEmpty ? () => showChapters(context, accent, tt) : null,+ );+ case 'speed':+ return CardWideButton(+ icon: Icons.speed_rounded, label: 'Speed',+ accent: accent, isActive: isPlaybackActive, large: large, compact: compact,+ child: CardSpeedButtonInline(player: player, accent: accent, isActive: isActive, large: large, compact: compact, itemId: itemId),+ );+ case 'sleep':+ return CardWideButton(+ icon: Icons.bedtime_outlined, label: short ? 'Sleep' : 'Sleep Timer',+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,+ child: CardSleepButtonInline(accent: accent, isActive: isPlaybackActive, large: large, compact: compact),+ );+ case 'bookmarks':+ return CardWideButton(+ icon: Icons.bookmark_outline_rounded, label: 'Bookmarks',+ accent: accent, isActive: isPlaybackActive, large: large, compact: compact,+ child: CardBookmarkButtonInline(+ player: player, accent: accent,+ isActive: isActive, itemId: itemId, large: large, compact: compact, short: short,+ ),+ );+ case 'details':+ return CardWideButton(+ icon: (episodeId != null || isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,+ label: short ? 'Details' : ((episodeId != null || isPodcastEpisode) ? 'Episode Details' : 'Book Details'),+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,+ onTap: () => _openDetails(),+ );+ case 'equalizer':+ return CardWideButton(+ icon: Icons.equalizer_rounded, label: compact ? 'EQ' : 'Equalizer',+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,+ onTap: () => showEqualizerSheet(context, accent),+ );+ case 'cast':+ return ListenableBuilder(+ listenable: ChromecastService(),+ builder: (_, __) {+ final cast = ChromecastService();+ final String castLabel;+ if (compact || short) {+ castLabel = cast.isConnected ? 'Casting' : 'Cast';+ } else if (cast.isCasting && cast.castingItemId == itemId) {+ castLabel = 'Casting to ${cast.connectedDeviceName ?? "device"}';+ } else if (cast.isConnected) {+ castLabel = 'Cast to ${cast.connectedDeviceName ?? "device"}';+ } else {+ castLabel = 'Cast to Device';+ }+ return CardWideButton(+ icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,+ label: castLabel, accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,+ onTap: () => handleCastTap(context, accent),+ );+ },+ );+ case 'history':+ return CardWideButton(+ icon: Icons.history_rounded, label: (compact || short) ? 'History' : 'Playback History',+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,+ onTap: () => showHistory(context, accent, tt),+ );+ case 'remove':+ return CardWideButton(+ icon: Icons.remove_circle_outline_rounded, label: (compact || short) ? 'Remove' : 'Remove from Absorbing',+ accent: Colors.red.shade300, isActive: true, alwaysEnabled: true, large: large, compact: compact,+ onTap: () { removeFromAbsorbing(); onRemoveExtra?.call(); },+ );+ case 'car':+ return CardWideButton(+ icon: Icons.directions_car_rounded, label: 'Car Mode',+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,+ onTap: () => openCarMode(context),+ );+ case 'notes':+ return CardWideButton(+ icon: Icons.note_rounded, label: 'Notes',+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,+ onTap: () => showNotes(context, accent),+ );+ default:+ return const SizedBox.shrink();+ }+ }++ Widget buildMoreMenuItem(String id, Color accent, TextTheme tt, BuildContext ctx) {+ switch (id) {+ case 'chapters':+ return MoreMenuItem(+ icon: Icons.list_rounded, label: 'Chapters', accent: accent,+ enabled: chapters.isNotEmpty,+ onTap: () { Navigator.pop(ctx); showChapters(context, accent, tt); },+ );+ case 'speed':+ return MoreMenuItem(+ icon: Icons.speed_rounded, label: 'Speed', accent: accent,+ enabled: true,+ onTap: () {+ Navigator.pop(ctx);+ showModalBottomSheet(context: context, backgroundColor: Colors.transparent, useSafeArea: true,+ builder: (_) => CardSpeedSheet(player: player, accent: accent, itemId: itemId));+ },+ );+ case 'sleep':+ return MoreMenuItem(+ icon: Icons.bedtime_outlined, label: 'Sleep Timer', accent: accent,+ enabled: true,+ onTap: () {+ Navigator.pop(ctx);+ showSleepTimerSheet(context, accent);+ },+ );+ case 'bookmarks':+ return MoreMenuItem(+ icon: Icons.bookmark_outline_rounded, label: 'Bookmarks', accent: accent,+ enabled: isPlaybackActive,+ onTap: () {+ Navigator.pop(ctx);+ showModalBottomSheet(context: context, backgroundColor: Colors.transparent, isScrollControlled: true, useSafeArea: true,+ builder: (_) => DraggableScrollableSheet(+ initialChildSize: 0.6, minChildSize: 0.05, snap: true, maxChildSize: 0.9, expand: false,+ builder: (_, sc) => SimpleBookmarkSheet(itemId: itemId, player: player, accent: accent, scrollController: sc, onChanged: () {}),+ ),+ );+ },+ );+ case 'details':+ return MoreMenuItem(+ icon: (episodeId != null || isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,+ label: (episodeId != null || isPodcastEpisode) ? 'Episode Details' : 'Book Details',+ accent: accent,+ onTap: () { Navigator.pop(ctx); _openDetails(); },+ );+ case 'equalizer':+ return MoreMenuItem(+ icon: Icons.equalizer_rounded, label: 'Equalizer', accent: accent,+ onTap: () { Navigator.pop(ctx); showEqualizerSheet(context, accent); },+ );+ case 'cast':+ return ListenableBuilder(+ listenable: ChromecastService(),+ builder: (_, __) {+ final cast = ChromecastService();+ final String castLabel;+ if (cast.isCasting && cast.castingItemId == itemId) {+ castLabel = 'Casting to ${cast.connectedDeviceName ?? "device"}';+ } else if (cast.isConnected) {+ castLabel = 'Cast to ${cast.connectedDeviceName ?? "device"}';+ } else {+ castLabel = 'Cast to Device';+ }+ return MoreMenuItem(+ icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,+ label: castLabel, accent: accent,+ onTap: () { Navigator.pop(ctx); handleCastTap(context, accent); },+ );+ },+ );+ case 'history':+ return MoreMenuItem(+ icon: Icons.history_rounded, label: 'Playback History', accent: accent,+ enabled: true,+ onTap: () { Navigator.pop(ctx); showHistory(context, accent, tt); },+ );+ case 'remove':+ return MoreMenuItem(+ icon: Icons.remove_circle_outline_rounded, label: 'Remove from Absorbing',+ accent: Colors.red.shade300,+ onTap: () { Navigator.pop(ctx); removeFromAbsorbing(); onRemoveExtra?.call(); },+ );+ case 'car':+ return MoreMenuItem(+ icon: Icons.directions_car_rounded, label: 'Car Mode', accent: accent,+ onTap: () { Navigator.pop(ctx); openCarMode(context); },+ );+ case 'notes':+ return MoreMenuItem(+ icon: Icons.note_rounded, label: 'Notes', accent: accent,+ onTap: () { Navigator.pop(ctx); showNotes(context, accent); },+ );+ default:+ return const SizedBox.shrink();+ }+ }++ void showMoreMenu(Color accent, TextTheme tt) {+ final count = visibleButtonCount;+ final overflowIds = buttonOrder.skip(count).toList();+ showModalBottomSheet(+ context: context,+ backgroundColor: Colors.transparent,+ isScrollControlled: true,+ builder: (ctx) => MoreMenuSheet(+ overflowIds: overflowIds,+ allIds: buttonOrder,+ visibleCount: count,+ accent: accent,+ buildItem: (id) => buildMoreMenuItem(id, accent, tt, ctx),+ onReorder: onReorder,+ ),+ );+ }++ void showNotes(BuildContext ctx, Color accent) {+ NotesSheet.show(ctx, itemId: itemId, itemTitle: title, accent: accent);+ }++ void openCarMode(BuildContext ctx) {+ Navigator.of(ctx).push(MaterialPageRoute(+ builder: (_) => CarModeScreen(+ player: player,+ itemId: itemId,+ fallbackTitle: title,+ fallbackAuthor: author,+ fallbackCoverUrl: coverUrl,+ fallbackDuration: effectiveDuration,+ fallbackChapters: chapters,+ episodeId: episodeId,+ episodeTitle: recentEpisode?['title'] as String?,+ ),+ ));+ }++ void handleCastTap(BuildContext ctx, Color accent) {+ final cast = ChromecastService();+ final auth = ctx.read<AuthProvider>();+ final api = auth.apiService;+ if (cast.isCasting && cast.castingItemId == itemId) {+ showModalBottomSheet(+ context: ctx,+ backgroundColor: Theme.of(ctx).bottomSheetTheme.backgroundColor,+ shape: const RoundedRectangleBorder(+ borderRadius: BorderRadius.vertical(top: Radius.circular(24)),+ ),+ builder: (_) => CastControlSheet(),+ );+ } else if (cast.isConnected) {+ if (api != null) {+ cast.castItem(+ api: api, itemId: itemId, title: title, author: author ?? '',+ coverUrl: coverUrl, totalDuration: duration, chapters: chapters,+ episodeId: episodeId ?? player.currentEpisodeId,+ );+ }+ } else {+ showCastDevicePicker(ctx,+ api: api, itemId: itemId, title: title, author: author ?? '',+ coverUrl: coverUrl, totalDuration: duration, chapters: chapters,+ episodeId: episodeId ?? player.currentEpisodeId);+ }+ }++ void showChapters(BuildContext ctx, Color accent, TextTheme tt) {+ final cast = ChromecastService();+ final chaps = isCastingThis ? cast.castingChapters : (isActive ? player.chapters : chapters);+ if (chaps.isEmpty) return;+ double pos = 0;+ if (isCastingThis) {+ pos = cast.castPosition.inMilliseconds / 1000.0;+ } else if (isActive) {+ pos = player.position.inMilliseconds / 1000.0;+ } else {+ final lib = ctx.read<LibraryProvider>();+ final pd = episodeId != null+ ? lib.getEpisodeProgressData(itemId, episodeId!)+ : lib.getProgressData(itemId);+ pos = (pd?['currentTime'] as num?)?.toDouble() ?? 0;+ }+ showChaptersSheet(+ context: ctx, accent: accent, tt: tt,+ chapters: chaps,+ totalDuration: isCastingThis ? cast.castingDuration : (isActive ? player.totalDuration : duration),+ currentPosition: pos,+ isPlaybackActive: isPlaybackActive,+ isCastingThis: isCastingThis,+ displaySpeed: speedAdjustedTime ? (isActive ? player.speed : savedSpeed) : 1.0,+ player: player,+ itemId: itemId,+ );+ }++ void showHistory(BuildContext ctx, Color accent, TextTheme tt) {+ showModalBottomSheet(+ context: ctx, isScrollControlled: true, useSafeArea: true,+ backgroundColor: Colors.transparent,+ builder: (sheetCtx) => DraggableScrollableSheet(+ expand: false, initialChildSize: 0.6, minChildSize: 0.05, snap: true, maxChildSize: 0.9,+ builder: (_, sc) => Container(+ decoration: BoxDecoration(+ color: Theme.of(ctx).bottomSheetTheme.backgroundColor,+ borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),+ border: Border(top: BorderSide(color: accent.withValues(alpha: 0.2), width: 1)),+ ),+ child: Column(children: [+ Padding(padding: const EdgeInsets.symmetric(vertical: 12),+ child: Container(width: 40, height: 4, decoration: BoxDecoration(color: Theme.of(ctx).colorScheme.onSurface.withValues(alpha: 0.24), borderRadius: BorderRadius.circular(2)))),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16),+ child: Row(children: [+ const Spacer(),+ Text('Playback History', style: tt.titleMedium?.copyWith(fontWeight: FontWeight.w600)),+ const Spacer(),+ IconButton(+ icon: Icon(Icons.delete_outline_rounded, size: 20, color: Theme.of(ctx).colorScheme.onSurfaceVariant),+ onPressed: () async {+ await PlaybackHistoryService().clearHistory(itemId);+ if (sheetCtx.mounted) Navigator.pop(sheetCtx);+ },+ tooltip: 'Clear history',+ ),+ ]),+ ),+ if (isActive)+ Padding(+ padding: const EdgeInsets.fromLTRB(16, 4, 16, 8),+ child: Text('Tap an event to jump to that position',+ style: tt.bodySmall?.copyWith(color: Theme.of(ctx).colorScheme.onSurfaceVariant.withValues(alpha: 0.6), fontStyle: FontStyle.italic)),+ )+ else+ const SizedBox(height: 8),+ Expanded(child: FutureBuilder<List<PlaybackEvent>>(+ future: PlaybackHistoryService().getHistory(itemId),+ builder: (futureCtx, snap) {+ if (!snap.hasData) return const Center(child: CircularProgressIndicator(strokeWidth: 2));+ final events = snap.data!;+ if (events.isEmpty) return Center(child: Text('No history yet', style: tt.bodyMedium?.copyWith(color: Theme.of(ctx).colorScheme.onSurfaceVariant)));++ final items = <Widget>[];+ String? lastDate;+ for (int i = 0; i < events.length; i++) {+ final e = events[i];+ final dl = dateLabel(e.timestamp);+ if (dl != lastDate) {+ lastDate = dl;+ items.add(Padding(+ padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),+ child: Text(dl, style: tt.labelSmall?.copyWith(+ color: accent.withValues(alpha: 0.6), fontWeight: FontWeight.w600, letterSpacing: 0.5)),+ ));+ }+ final posLabel = fmtTime(e.positionSeconds);+ final timeStr = timeOfDay(e.timestamp);+ items.add(ListTile(+ dense: true, visualDensity: const VisualDensity(vertical: -2),+ leading: Icon(historyIcon(e.type), size: 18, color: accent.withValues(alpha: 0.7)),+ title: Text(e.label, style: tt.bodySmall?.copyWith(color: Theme.of(ctx).colorScheme.onSurface.withValues(alpha: 0.7))),+ subtitle: Text('at $posLabel', style: tt.labelSmall?.copyWith(color: Theme.of(ctx).colorScheme.onSurfaceVariant)),+ trailing: Text(timeStr, style: tt.labelSmall?.copyWith(color: Theme.of(ctx).colorScheme.onSurface.withValues(alpha: 0.3))),+ onTap: isActive ? () {+ player.seekTo(Duration(seconds: e.positionSeconds.round()));+ Navigator.pop(futureCtx);+ ScaffoldMessenger.of(ctx).showSnackBar(SnackBar(duration: const Duration(seconds: 3), content: Text('Jumped to $posLabel')));+ } : null,+ ));+ }++ return ListView(controller: sc, children: items);+ },+ )),+ ]),+ ),+ ),+ );+ }++ Future<void> _openDetails() async {+ if (episodeId != null || isPodcastEpisode) {+ final episode = await _resolveEpisode();+ if (context.mounted) EpisodeDetailSheet.show(context, item, episode);+ } else {+ showBookDetailSheet(context, itemId);+ }+ }++ Future<Map<String, dynamic>> _resolveEpisode() async {+ final epId = episodeId ?? player.currentEpisodeId;+ final episodes = _media['episodes'] as List<dynamic>? ?? [];+ for (final ep in episodes) {+ if (ep is Map<String, dynamic> && ep['id'] == epId) return ep;+ }+ final api = context.read<AuthProvider>().apiService;+ if (api != null) {+ final fullItem = await api.getLibraryItem(itemId);+ if (fullItem != null) {+ final media = fullItem['media'] as Map<String, dynamic>? ?? {};+ final eps = media['episodes'] as List<dynamic>? ?? [];+ for (final ep in eps) {+ if (ep is Map<String, dynamic> && ep['id'] == epId) return ep;+ }+ }+ }+ if (recentEpisode != null) return recentEpisode!;+ return {+ 'id': epId,+ 'title': player.currentEpisodeTitle,+ 'duration': player.totalDuration,+ };+ }+}diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dartindex 9b00c2b6..bb7b715e 100644--- a/lib/widgets/expanded_card.dart+++ b/lib/widgets/expanded_card.dart@@ -8,20 +8,11 @@ import '../providers/auth_provider.dart';import '../providers/library_provider.dart';import '../services/audio_player_service.dart';import '../services/download_service.dart';-import '../services/playback_history_service.dart';import '../services/chromecast_service.dart';-import 'book_detail_sheet.dart';-import 'episode_list_sheet.dart';-import 'equalizer_sheet.dart';import 'absorbing_shared.dart';-import 'card_chapters_sheet.dart';import 'card_progress_bar.dart';import 'card_playback_controls.dart';import 'card_buttons.dart';-import 'chromecast_button.dart';-import 'sleep_timer_sheet.dart';-import '../screens/car_mode_screen.dart';-import 'notes_sheet.dart';// ─── Custom route: slide-up + fade ────────────────────────────@@ -135,33 +126,6 @@ class _ExpandedCardState extends State<ExpandedCard> {Map<String, dynamic>? get _recentEpisode => _item['recentEpisode'] as Map<String, dynamic>?;/// Resolve full episode data for the current episode.- /// Prefers full episode data from media.episodes or API over the- /// stripped-down recentEpisode from continue-listening.- Future<Map<String, dynamic>> _resolveEpisode() async {- final epId = _episodeId ?? widget.player.currentEpisodeId;- final episodes = _media['episodes'] as List<dynamic>? ?? [];- for (final ep in episodes) {- if (ep is Map<String, dynamic> && ep['id'] == epId) return ep;- }- final api = context.read<AuthProvider>().apiService;- if (api != null) {- final fullItem = await api.getLibraryItem(_itemId);- if (fullItem != null) {- final media = fullItem['media'] as Map<String, dynamic>? ?? {};- final eps = media['episodes'] as List<dynamic>? ?? [];- for (final ep in eps) {- if (ep is Map<String, dynamic> && ep['id'] == epId) return ep;- }- }- }- if (_recentEpisode != null) return _recentEpisode!;- return {- 'id': epId,- 'title': widget.player.currentEpisodeTitle,- 'duration': widget.player.totalDuration,- };- }-// Episode ID: prefer recentEpisode, fall back to compound absorbing keyString? get _episodeId {final re = _recentEpisode;@@ -667,12 +631,19 @@ class _ExpandedCardState extends State<ExpandedCard> {// Cover image_coverUrl != null? _isLocalCover- ? Image.file(File(_coverUrl!), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => const CoverPlaceholder())- : CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,+ ? BlurPaddedCover(child: Image.file(File(_coverUrl!), fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,+ errorBuilder: (_, __, ___) => const CoverPlaceholder()),+ blurChild: Image.file(File(_coverUrl!), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => const SizedBox.shrink()),+ enabled: !_rectangleCovers)+ : BlurPaddedCover(child: CachedNetworkImage(imageUrl: _coverUrl!, fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,httpHeaders: mediaHeaders,placeholder: (_, __) => const CoverPlaceholder(),- errorWidget: (_, __, ___) => const CoverPlaceholder())+ errorWidget: (_, __, ___) => const CoverPlaceholder()),+ blurChild: CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,+ httpHeaders: mediaHeaders,+ errorWidget: (_, __, ___) => const SizedBox.shrink()),+ enabled: !_rectangleCovers): const CoverPlaceholder(),// Downloaded badgeif (isDownloaded)@@ -978,433 +949,41 @@ class _ExpandedCardState extends State<ExpandedCard> {}}- // ── Dynamic button builders ─────────────────────────────────+ // ── Dynamic button builders (delegated) ─────────────────────++ CardActionDelegate _makeActions() => CardActionDelegate(+ context: context,+ player: widget.player,+ item: _item,+ itemId: _itemId,+ episodeId: _episodeId,+ isPodcastEpisode: _isPodcastEpisode,+ title: _title,+ author: _author,+ coverUrl: _coverUrl,+ duration: _duration,+ effectiveDuration: _effectiveDuration,+ chapters: _chapters,+ recentEpisode: _recentEpisode,+ isActive: _isActive,+ isPlaybackActive: _isPlaybackActive,+ isCastingThis: _isCastingThis,+ speedAdjustedTime: _speedAdjustedTime,+ savedSpeed: 1.0,+ buttonLayout: _buttonLayout,+ buttonOrder: _buttonOrder,+ removeFromAbsorbing: _removeFromAbsorbing,+ onRemoveExtra: _dismissExpanded,+ onReorder: (newOrder) {+ setState(() => _buttonOrder = newOrder);+ PlayerSettings.setCardButtonOrder(newOrder);+ },+ );int get _visibleButtonCount => PlayerSettings.buttonCountForLayout(_buttonLayout);- List<Widget> _buildButtonGrid(Color accent, TextTheme tt) {- final count = _visibleButtonCount;- final ids = _buttonOrder.take(count).toList();-- int cols;- switch (_buttonLayout) {- case 'compact': cols = 3; break;- case 'row': cols = 5; break;- case 'expanded': cols = 3; break;- case 'full': cols = 3; break;- default: cols = 2; break;- }-- final compact = cols >= 5;- final short = cols >= 3;- final singleRow = count == ids.length && ids.length <= cols;- final rows = <Widget>[];- if (singleRow) rows.add(const SizedBox(height: 8));- for (int r = 0; r < ids.length; r += cols) {- if (r > 0) rows.add(const SizedBox(height: 14));- final end = (r + cols).clamp(0, ids.length);- final rowIds = ids.sublist(r, end);- rows.add(Row(children: [- for (int c = 0; c < rowIds.length; c++) ...[- if (c > 0) const SizedBox(width: 10),- Expanded(child: _buildCardButton(rowIds[c], accent, tt, compact: compact, short: short)),- ],- ]));- }- if (singleRow) rows.add(const SizedBox(height: 6));- return rows;- }-- Widget _buildCardButton(String id, Color accent, TextTheme tt, {bool compact = false, bool short = false}) {- final large = MediaQuery.sizeOf(context).height > 700;- switch (id) {- case 'chapters':- return CardWideButton(- icon: Icons.list_rounded, label: 'Chapters',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: _chapters.isNotEmpty ? () => _showChapters(context, accent, tt) : null,- );- case 'speed':- return CardWideButton(- icon: Icons.speed_rounded, label: 'Speed',- accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,- child: CardSpeedButtonInline(player: widget.player, accent: accent, isActive: _isActive, large: large, compact: compact, itemId: _itemId),- );- case 'sleep':- return CardWideButton(- icon: Icons.bedtime_outlined, label: short ? 'Sleep' : 'Sleep Timer',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- child: CardSleepButtonInline(accent: accent, isActive: true, large: large, compact: compact),- );- case 'bookmarks':- return CardWideButton(- icon: Icons.bookmark_outline_rounded, label: 'Bookmarks',- accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,- child: CardBookmarkButtonInline(- player: widget.player, accent: accent,- isActive: _isActive, itemId: _itemId, large: large, compact: compact, short: short,- ),- );- case 'details':- return CardWideButton(- icon: (_episodeId != null || _isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,- label: short ? 'Details' : ((_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details'),- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () async {- if (_episodeId != null || _isPodcastEpisode) {- final episode = await _resolveEpisode();- if (mounted) EpisodeDetailSheet.show(context, _item, episode);- } else {- showBookDetailSheet(context, _itemId);- }- },- );- case 'equalizer':- return CardWideButton(- icon: Icons.equalizer_rounded, label: compact ? 'EQ' : 'Equalizer',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => showEqualizerSheet(context, accent),- );- case 'cast':- return ListenableBuilder(- listenable: ChromecastService(),- builder: (_, __) {- final cast = ChromecastService();- final String castLabel;- if (compact || short) {- castLabel = cast.isConnected ? 'Casting' : 'Cast';- } else if (cast.isCasting && cast.castingItemId == _itemId) {- castLabel = 'Casting to ${cast.connectedDeviceName ?? "device"}';- } else if (cast.isConnected) {- castLabel = 'Cast to ${cast.connectedDeviceName ?? "device"}';- } else {- castLabel = 'Cast to Device';- }- return CardWideButton(- icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,- label: castLabel, accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => _handleCastTap(context, accent),- );- },- );- case 'history':- return CardWideButton(- icon: Icons.history_rounded, label: (compact || short) ? 'History' : 'Playback History',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => _showHistory(context, accent, tt),- );- case 'remove':- return CardWideButton(- icon: Icons.remove_circle_outline_rounded, label: (compact || short) ? 'Remove' : 'Remove from Absorbing',- accent: Colors.red.shade300, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () { _removeFromAbsorbing(); _dismissExpanded(); },- );- case 'car':- return CardWideButton(- icon: Icons.directions_car_rounded, label: 'Car Mode',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => _openCarMode(context),- );- case 'notes':- return CardWideButton(- icon: Icons.note_rounded, label: 'Notes',- accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,- onTap: () => _showNotes(context, accent),- );- default:- return const SizedBox.shrink();- }- }-- Widget _buildMoreMenuItem(String id, Color accent, TextTheme tt, BuildContext ctx) {- switch (id) {- case 'chapters':- return MoreMenuItem(- icon: Icons.list_rounded, label: 'Chapters', accent: accent,- enabled: _chapters.isNotEmpty,- onTap: () { Navigator.pop(ctx); _showChapters(context, accent, tt); },- );- case 'speed':- return MoreMenuItem(- icon: Icons.speed_rounded, label: 'Speed', accent: accent,- enabled: true,- onTap: () {- Navigator.pop(ctx);- showModalBottomSheet(context: context, backgroundColor: Colors.transparent, useSafeArea: true,- builder: (_) => CardSpeedSheet(player: widget.player, accent: accent, itemId: _itemId));- },- );- case 'sleep':- return MoreMenuItem(- icon: Icons.bedtime_outlined, label: 'Sleep Timer', accent: accent,- enabled: true,- onTap: () {- Navigator.pop(ctx);- showSleepTimerSheet(context, accent);- },- );- case 'bookmarks':- return MoreMenuItem(- icon: Icons.bookmark_outline_rounded, label: 'Bookmarks', accent: accent,- enabled: _isPlaybackActive,- onTap: () {- Navigator.pop(ctx);- showModalBottomSheet(context: context, backgroundColor: Colors.transparent, isScrollControlled: true, useSafeArea: true,- builder: (_) => DraggableScrollableSheet(- initialChildSize: 0.6, minChildSize: 0.05, snap: true, maxChildSize: 0.9, expand: false,- builder: (_, sc) => SimpleBookmarkSheet(itemId: _itemId, player: widget.player, accent: accent, scrollController: sc, onChanged: () {}),- ),- );- },- );- case 'details':- return MoreMenuItem(- icon: (_episodeId != null || _isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,- label: (_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details',- accent: accent,- onTap: () async {- Navigator.pop(ctx);- if (_episodeId != null || _isPodcastEpisode) {- final episode = await _resolveEpisode();- if (mounted) EpisodeDetailSheet.show(context, _item, episode);- } else {- showBookDetailSheet(context, _itemId);- }- },- );- case 'equalizer':- return MoreMenuItem(- icon: Icons.equalizer_rounded, label: 'Equalizer', accent: accent,- onTap: () { Navigator.pop(ctx); showEqualizerSheet(context, accent); },- );- case 'cast':- return ListenableBuilder(- listenable: ChromecastService(),- builder: (_, __) {- final cast = ChromecastService();- final String castLabel;- if (cast.isCasting && cast.castingItemId == _itemId) {- castLabel = 'Casting to ${cast.connectedDeviceName ?? "device"}';- } else if (cast.isConnected) {- castLabel = 'Cast to ${cast.connectedDeviceName ?? "device"}';- } else {- castLabel = 'Cast to Device';- }- return MoreMenuItem(- icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,- label: castLabel, accent: accent,- onTap: () { Navigator.pop(ctx); _handleCastTap(context, accent); },- );- },- );- case 'history':- return MoreMenuItem(- icon: Icons.history_rounded, label: 'Playback History', accent: accent,- enabled: true,- onTap: () { Navigator.pop(ctx); _showHistory(context, accent, tt); },- );- case 'remove':- return MoreMenuItem(- icon: Icons.remove_circle_outline_rounded, label: 'Remove from Absorbing',- accent: Colors.red.shade300,- onTap: () { Navigator.pop(ctx); _removeFromAbsorbing(); _dismissExpanded(); },- );- case 'car':- return MoreMenuItem(- icon: Icons.directions_car_rounded, label: 'Car Mode', accent: accent,- onTap: () { Navigator.pop(ctx); _openCarMode(context); },- );- case 'notes':- return MoreMenuItem(- icon: Icons.note_rounded, label: 'Notes', accent: accent,- onTap: () { Navigator.pop(ctx); _showNotes(context, accent); },- );- default:- return const SizedBox.shrink();- }- }+ List<Widget> _buildButtonGrid(Color accent, TextTheme tt) => _makeActions().buildButtonGrid(accent, tt);- void _showNotes(BuildContext context, Color accent) {- NotesSheet.show(context,- itemId: _itemId,- itemTitle: _title,- accent: accent,- );- }-- void _openCarMode(BuildContext context) {- Navigator.of(context).push(MaterialPageRoute(- builder: (_) => CarModeScreen(- player: widget.player,- itemId: _itemId,- fallbackTitle: _title,- fallbackAuthor: _author,- fallbackCoverUrl: _coverUrl,- fallbackDuration: _effectiveDuration,- fallbackChapters: _chapters,- episodeId: _episodeId,- episodeTitle: _recentEpisode?['title'] as String?,- ),- ));- }-- void _handleCastTap(BuildContext context, Color accent) {- final cast = ChromecastService();- final auth = context.read<AuthProvider>();- final api = auth.apiService;- if (cast.isCasting && cast.castingItemId == _itemId) {- showModalBottomSheet(- context: context,- backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,- shape: const RoundedRectangleBorder(- borderRadius: BorderRadius.vertical(top: Radius.circular(24)),- ),- builder: (_) => CastControlSheet(),- );- } else if (cast.isConnected) {- if (api != null) {- cast.castItem(- api: api, itemId: _itemId, title: _title, author: _author,- coverUrl: _coverUrl, totalDuration: _duration, chapters: _chapters,- episodeId: _episodeId ?? widget.player.currentEpisodeId,- );- }- } else {- showCastDevicePicker(context,- api: api, itemId: _itemId, title: _title, author: _author,- coverUrl: _coverUrl, totalDuration: _duration, chapters: _chapters,- episodeId: _episodeId ?? widget.player.currentEpisodeId);- }- }-- // ── Bottom sheets ──-- void _showChapters(BuildContext context, Color accent, TextTheme tt) {- final cast = ChromecastService();- final chapters = _isCastingThis ? cast.castingChapters : (_isActive ? widget.player.chapters : _chapters);- if (chapters.isEmpty) return;- double pos = 0;- if (_isCastingThis) {- pos = cast.castPosition.inMilliseconds / 1000.0;- } else if (_isActive) {- pos = widget.player.position.inMilliseconds / 1000.0;- } else {- final lib = context.read<LibraryProvider>();- final pd = lib.getProgressData(_itemId);- pos = (pd?['currentTime'] as num?)?.toDouble() ?? 0;- }- showChaptersSheet(- context: context, accent: accent, tt: tt,- chapters: chapters,- totalDuration: _isCastingThis ? cast.castingDuration : (_isActive ? widget.player.totalDuration : _duration),- currentPosition: pos,- isPlaybackActive: _isPlaybackActive,- isCastingThis: _isCastingThis,- displaySpeed: _speedAdjustedTime && _isActive ? widget.player.speed : 1.0,- player: widget.player,- itemId: _itemId,- );- }-- void _showHistory(BuildContext context, Color accent, TextTheme tt) {- showModalBottomSheet(- context: context, isScrollControlled: true, useSafeArea: true,- backgroundColor: Colors.transparent,- builder: (ctx) => DraggableScrollableSheet(- expand: false, initialChildSize: 0.6, minChildSize: 0.05, snap: true, maxChildSize: 0.9,- builder: (_, sc) => Container(- decoration: BoxDecoration(- color: Theme.of(context).bottomSheetTheme.backgroundColor,- borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),- border: Border(top: BorderSide(color: accent.withValues(alpha: 0.2), width: 1)),- ),- child: Column(children: [- Padding(padding: const EdgeInsets.symmetric(vertical: 12),- child: Container(width: 40, height: 4, decoration: BoxDecoration(color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.24), borderRadius: BorderRadius.circular(2)))),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Row(children: [- const Spacer(),- Text('Playback History', style: tt.titleMedium?.copyWith(fontWeight: FontWeight.w600)),- const Spacer(),- IconButton(- icon: Icon(Icons.delete_outline_rounded, size: 20, color: Theme.of(context).colorScheme.onSurfaceVariant),- onPressed: () async {- await PlaybackHistoryService().clearHistory(_itemId);- if (ctx.mounted) Navigator.pop(ctx);- },- tooltip: 'Clear history',- ),- ]),- ),- if (_isActive)- Padding(- padding: const EdgeInsets.fromLTRB(16, 4, 16, 8),- child: Text('Tap an event to jump to that position',- style: tt.bodySmall?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant.withValues(alpha: 0.6), fontStyle: FontStyle.italic)),- )- else- const SizedBox(height: 8),- Expanded(child: FutureBuilder<List<PlaybackEvent>>(- future: PlaybackHistoryService().getHistory(_itemId),- builder: (ctx, snap) {- if (!snap.hasData) return const Center(child: CircularProgressIndicator(strokeWidth: 2));- final events = snap.data!;- if (events.isEmpty) return Center(child: Text('No history yet', style: tt.bodyMedium?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant)));- return ListView.builder(- controller: sc, itemCount: events.length,- itemBuilder: (_, i) {- final e = events[i];- final posLabel = fmtTime(e.positionSeconds);- final timeAgo = _timeAgo(e.timestamp);- return ListTile(- dense: true,- leading: Icon(historyIcon(e.type), size: 18, color: accent.withValues(alpha: 0.7)),- title: Text(e.label, style: tt.bodySmall?.copyWith(color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7))),- subtitle: Text('at $posLabel', style: tt.labelSmall?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant)),- trailing: Text(timeAgo, style: tt.labelSmall?.copyWith(color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.3))),- onTap: _isActive ? () {- widget.player.seekTo(Duration(seconds: e.positionSeconds.round()));- Navigator.pop(ctx);- ScaffoldMessenger.of(context).showSnackBar(SnackBar(duration: const Duration(seconds: 3), content: Text('Jumped to $posLabel')));- } : null,- );- },- );- },- )),- ]),- ),- ),- );- }-- void _showMoreMenu(BuildContext context, Color accent, TextTheme tt) {- final count = _visibleButtonCount;- final overflowIds = _buttonOrder.skip(count).toList();- showModalBottomSheet(- context: context,- backgroundColor: Colors.transparent,- isScrollControlled: true,- builder: (ctx) => MoreMenuSheet(- overflowIds: overflowIds,- allIds: _buttonOrder,- visibleCount: count,- accent: accent,- buildItem: (id) => _buildMoreMenuItem(id, accent, tt, ctx),- onReorder: (newOrder) {- setState(() => _buttonOrder = newOrder);- PlayerSettings.setCardButtonOrder(newOrder);- },- ),- );- }-- String _timeAgo(DateTime dt) {- final diff = DateTime.now().difference(dt);- if (diff.inSeconds < 60) return 'just now';- if (diff.inMinutes < 60) return '${diff.inMinutes}m ago';- if (diff.inHours < 24) return '${diff.inHours}h ago';- return '${diff.inDays}d ago';- }+ void _showMoreMenu(BuildContext context, Color accent, TextTheme tt) => _makeActions().showMoreMenu(accent, tt);}+diff --git a/lib/widgets/home_section.dart b/lib/widgets/home_section.dartindex 0e602d75..10e2de1f 100644--- a/lib/widgets/home_section.dart+++ b/lib/widgets/home_section.dart@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';import 'package:provider/provider.dart';import '../providers/library_provider.dart';import '../services/download_service.dart';+import 'absorbing_shared.dart';import 'book_card.dart';import 'author_card.dart';import 'series_card.dart';@@ -287,17 +288,24 @@ class _EpisodeCard extends StatelessWidget {children: [if (coverUrl != null)coverUrl.startsWith('/')- ? Image.file(File(coverUrl), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => Container(- 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(- color: cs.surfaceContainerHigh,- child: Icon(Icons.podcasts_rounded, size: 32,- color: cs.onSurfaceVariant.withValues(alpha: 0.3))))+ ? BlurPaddedCover(+ child: Image.file(File(coverUrl), fit: BoxFit.contain,+ errorBuilder: (_, __, ___) => Container(+ color: cs.surfaceContainerHigh,+ child: Icon(Icons.podcasts_rounded, size: 32,+ color: cs.onSurfaceVariant.withValues(alpha: 0.3)))),+ blurChild: Image.file(File(coverUrl), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => const SizedBox.shrink()))+ : BlurPaddedCover(+ child: Image.network(coverUrl, fit: BoxFit.contain,+ headers: lib.mediaHeaders,+ errorBuilder: (_, __, ___) => Container(+ color: cs.surfaceContainerHigh,+ child: Icon(Icons.podcasts_rounded, size: 32,+ color: cs.onSurfaceVariant.withValues(alpha: 0.3)))),+ blurChild: Image.network(coverUrl, fit: BoxFit.cover,+ headers: lib.mediaHeaders,+ errorBuilder: (_, __, ___) => const SizedBox.shrink()))elseContainer(color: cs.surfaceContainerHigh,diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dartindex 38b522c0..81307397 100644--- a/lib/widgets/library_grid_tiles.dart+++ b/lib/widgets/library_grid_tiles.dart@@ -6,6 +6,7 @@ import '../providers/auth_provider.dart';import '../providers/library_provider.dart';import '../services/audio_player_service.dart';import '../services/download_service.dart';+import 'absorbing_shared.dart';import 'book_detail_sheet.dart';import 'episode_list_sheet.dart';import 'series_books_sheet.dart';@@ -85,16 +86,7 @@ class _GridBookTileState extends State<GridBookTile> {children: [// Cover imagecoverUrl != null- ? coverUrl.startsWith('/')- ? Image.file(File(coverUrl), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => _placeholder(cs))- : CachedNetworkImage(- imageUrl: coverUrl,- fit: BoxFit.cover,- httpHeaders: lib.mediaHeaders,- placeholder: (_, __) => _placeholder(cs),- errorWidget: (_, __, ___) => _placeholder(cs),- )+ ? _blurCover(coverUrl, lib.mediaHeaders, cs, widget.coverAspectRatio): _placeholder(cs),// Progress bar at bottom of cover@@ -238,6 +230,27 @@ class _GridBookTileState extends State<GridBookTile> {);}+ Widget _blurCover(String coverUrl, Map<String, String> headers, ColorScheme cs, double aspectRatio) {+ final isSquare = (aspectRatio - 1.0).abs() < 0.01;+ if (coverUrl.startsWith('/')) {+ return BlurPaddedCover(+ enabled: isSquare,+ child: Image.file(File(coverUrl), fit: isSquare ? BoxFit.contain : BoxFit.cover,+ errorBuilder: (_, __, ___) => _placeholder(cs)),+ blurChild: Image.file(File(coverUrl), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => const SizedBox.shrink()),+ );+ }+ return BlurPaddedCover(+ enabled: isSquare,+ child: CachedNetworkImage(imageUrl: coverUrl, fit: isSquare ? BoxFit.contain : BoxFit.cover,+ httpHeaders: headers, placeholder: (_, __) => _placeholder(cs),+ errorWidget: (_, __, ___) => _placeholder(cs)),+ blurChild: CachedNetworkImage(imageUrl: coverUrl, fit: BoxFit.cover,+ httpHeaders: headers, errorWidget: (_, __, ___) => const SizedBox.shrink()),+ );+ }+Widget _placeholder(ColorScheme cs) {return Container(color: cs.surfaceContainerHighest,@@ -412,16 +425,23 @@ class _StackedCovers extends StatelessWidget {Widget _coverImage(String? url) {if (url == null) return _placeholder();+ final isSquare = (coverAspectRatio - 1.0).abs() < 0.01;if (url.startsWith('/')) {- return Image.file(File(url), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => _placeholder());+ return BlurPaddedCover(+ enabled: isSquare,+ child: Image.file(File(url), fit: isSquare ? BoxFit.contain : BoxFit.cover,+ errorBuilder: (_, __, ___) => _placeholder()),+ blurChild: Image.file(File(url), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => const SizedBox.shrink()),+ );}- return CachedNetworkImage(- imageUrl: url,- fit: BoxFit.cover,- httpHeaders: mediaHeaders,- placeholder: (_, __) => _placeholder(),- errorWidget: (_, __, ___) => _placeholder(),+ return BlurPaddedCover(+ enabled: isSquare,+ child: CachedNetworkImage(imageUrl: url, fit: isSquare ? BoxFit.contain : BoxFit.cover,+ httpHeaders: mediaHeaders, placeholder: (_, __) => _placeholder(),+ errorWidget: (_, __, ___) => _placeholder()),+ blurChild: CachedNetworkImage(imageUrl: url, fit: BoxFit.cover,+ httpHeaders: mediaHeaders, errorWidget: (_, __, ___) => const SizedBox.shrink()),);}diff --git a/lib/widgets/series_card.dart b/lib/widgets/series_card.dartindex af4280e5..d15e3549 100644--- a/lib/widgets/series_card.dart+++ b/lib/widgets/series_card.dart@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';import 'package:cached_network_image/cached_network_image.dart';import '../providers/auth_provider.dart';import '../providers/library_provider.dart';+import 'absorbing_shared.dart';import 'series_books_sheet.dart';class SeriesCard extends StatelessWidget {@@ -76,6 +77,7 @@ class SeriesCard extends StatelessWidget {cs: cs,seriesProgress: seriesProgress,booksFinished: finished,+ coverAspectRatio: coverAspectRatio,),),const SizedBox(height: 5),@@ -116,6 +118,7 @@ class _StackedCovers extends StatelessWidget {final ColorScheme cs;final double seriesProgress;final int booksFinished;+ final double coverAspectRatio;const _StackedCovers({required this.coverUrls,@@ -124,6 +127,7 @@ class _StackedCovers extends StatelessWidget {required this.cs,this.seriesProgress = 0,this.booksFinished = 0,+ this.coverAspectRatio = 1.0,});@override@@ -250,16 +254,23 @@ class _StackedCovers extends StatelessWidget {Widget _coverImage(String? url) {if (url == null) return _placeholder();+ final isSquare = (coverAspectRatio - 1.0).abs() < 0.01;if (url.startsWith('/')) {- return Image.file(File(url), fit: BoxFit.cover,- errorBuilder: (_, __, ___) => _placeholder());+ return BlurPaddedCover(+ enabled: isSquare,+ child: Image.file(File(url), fit: isSquare ? BoxFit.contain : BoxFit.cover,+ errorBuilder: (_, __, ___) => _placeholder()),+ blurChild: Image.file(File(url), fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => const SizedBox.shrink()),+ );}- return CachedNetworkImage(- imageUrl: url,- fit: BoxFit.cover,- httpHeaders: mediaHeaders,- placeholder: (_, __) => _placeholder(),- errorWidget: (_, __, ___) => _placeholder(),+ return BlurPaddedCover(+ enabled: isSquare,+ child: CachedNetworkImage(imageUrl: url, fit: isSquare ? BoxFit.contain : BoxFit.cover,+ httpHeaders: mediaHeaders, placeholder: (_, __) => _placeholder(),+ errorWidget: (_, __, ___) => _placeholder()),+ blurChild: CachedNetworkImage(imageUrl: url, fit: BoxFit.cover,+ httpHeaders: mediaHeaders, errorWidget: (_, __, ___) => const SizedBox.shrink()),);}