Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix offline mode, next-in-series ordering, BT disconnect, debug playback, cast navigation, and customizable player buttons

Nathan Poulson1ac21f04ad5c
diff --git a/lib/providers/library_provider.dart b/lib/providers/library_provider.dart
index 935b51fa..b397f0c9 100644
--- a/lib/providers/library_provider.dart
+++ b/lib/providers/library_provider.dart
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';
+import 'dart:io';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
@@ -26,6 +27,12 @@ class LibraryProvider extends ChangeNotifier {
bool _isLoadingSeries = false;
String? _errorMessage;
+ // Fetch deduplication for loadPersonalizedView
+ Future<void>? _personalizedInFlight;
+ DateTime? _lastPersonalizedFetchAt;
+ String? _lastPersonalizedFetchLibraryId;
+ static const _personalizedFetchCooldown = Duration(seconds: 5);
+
// Offline mode
bool _manualOffline = false;
bool _networkOffline = false;
@@ -40,8 +47,10 @@ class LibraryProvider extends ChangeNotifier {
_manualOffline = value;
final prefs = await SharedPreferences.getInstance();
await prefs.setBool('manual_offline_mode', value);
- if (!value && !_networkOffline) {
- // Going back online — flush pending syncs and refresh
+ if (!value) {
+ // Going back online — clear any stale network-offline flag too
+ _networkOffline = false;
+ _stopServerPingTimer();
if (_api != null) {
debugPrint('[Library] Manual offline off — flushing pending syncs');
ProgressSyncService().flushPendingSync(api: _api!);
@@ -303,6 +312,12 @@ class LibraryProvider extends ChangeNotifier {
_manualAbsorbRemoves.clear();
_absorbingBookIds.clear();
_absorbingItemCache.clear();
+ _personalizedInFlight = null;
+ _lastPersonalizedFetchAt = null;
+ _lastPersonalizedFetchLibraryId = null;
+ _networkOffline = false;
+ _connectivitySub?.cancel();
+ _stopServerPingTimer();
_isLoading = true;
notifyListeners(); // Immediately clear old user's data from UI
}
@@ -346,6 +361,9 @@ class LibraryProvider extends ChangeNotifier {
_errorMessage = null;
_connectivitySub?.cancel();
_stopServerPingTimer();
+ _personalizedInFlight = null;
+ _lastPersonalizedFetchAt = null;
+ _lastPersonalizedFetchLibraryId = null;
notifyListeners();
}
}
@@ -407,6 +425,27 @@ class LibraryProvider extends ChangeNotifier {
_serverPingTimer = null;
}
+ /// Returns true for exceptions that indicate a real network problem
+ /// (unreachable server, DNS failure, TLS error). Non-network errors like
+ /// server 500s or JSON parse failures should not trigger offline mode.
+ bool _isLikelyNetworkError(Object error) {
+ return error is SocketException ||
+ error is TimeoutException ||
+ error is HandshakeException ||
+ error is HttpException;
+ }
+
+ /// Go offline due to a network error. Builds offline sections and starts
+ /// pinging the server for recovery if the device still has connectivity.
+ void _goOffline() {
+ if (_networkOffline) return;
+ debugPrint('[Library] Network error — going offline');
+ _networkOffline = true;
+ _buildOfflineSections();
+ notifyListeners();
+ if (_deviceHasConnectivity && !_manualOffline) _startServerPingTimer();
+ }
+
void _buildProgressMap(AuthProvider auth) {
_progressMap = {};
final userJson = auth.userJson;
@@ -459,14 +498,13 @@ class LibraryProvider extends ChangeNotifier {
? bookLibraries.first['id']
: _libraries.first['id'];
}
- await loadPersonalizedView();
+ await loadPersonalizedView(force: true);
}
} catch (e) {
- // Network error — auto-switch to offline view
- if (!_networkOffline) {
- _networkOffline = true;
- _buildOfflineSections();
- if (_deviceHasConnectivity && !_manualOffline) _startServerPingTimer();
+ if (_isLikelyNetworkError(e)) {
+ _goOffline();
+ } else {
+ debugPrint('[Library] Non-network error (staying online): $e');
}
}
@@ -480,11 +518,39 @@ class LibraryProvider extends ChangeNotifier {
_series = [];
await ScopedPrefs.setString('last_selected_library', libraryId);
notifyListeners();
- await loadPersonalizedView();
+ await loadPersonalizedView(force: true);
}
/// Fetch personalized home sections for the selected library.
- Future<void> loadPersonalizedView() async {
+ /// Deduplicates concurrent calls and enforces a cooldown unless [force] is true.
+ Future<void> loadPersonalizedView({bool force = false}) async {
+ // If a fetch is already in flight, just await it
+ final existing = _personalizedInFlight;
+ if (existing != null) {
+ await existing;
+ return;
+ }
+
+ // Skip if within cooldown (same library, not forced)
+ if (!force &&
+ _lastPersonalizedFetchAt != null &&
+ _lastPersonalizedFetchLibraryId == _selectedLibraryId &&
+ DateTime.now().difference(_lastPersonalizedFetchAt!) < _personalizedFetchCooldown) {
+ return;
+ }
+
+ final inFlight = _doLoadPersonalizedView();
+ _personalizedInFlight = inFlight;
+ try {
+ await inFlight;
+ } finally {
+ if (identical(_personalizedInFlight, inFlight)) {
+ _personalizedInFlight = null;
+ }
+ }
+ }
+
+ Future<void> _doLoadPersonalizedView() async {
if (_api == null || _selectedLibraryId == null) return;
if (isOffline) {
@@ -501,16 +567,17 @@ class LibraryProvider extends ChangeNotifier {
}
try {
+ _lastPersonalizedFetchAt = DateTime.now();
+ _lastPersonalizedFetchLibraryId = _selectedLibraryId;
await _refreshProgress();
_personalizedSections =
await _api!.getPersonalizedView(_selectedLibraryId!);
await _updateAbsorbingCache();
} catch (e) {
- // Network error — auto-switch to offline view
- if (!_networkOffline) {
- _networkOffline = true;
- _buildOfflineSections();
- if (_deviceHasConnectivity && !_manualOffline) _startServerPingTimer();
+ if (_isLikelyNetworkError(e)) {
+ _goOffline();
+ } else {
+ debugPrint('[Library] Non-network error (staying online): $e');
}
}
@@ -553,7 +620,7 @@ class LibraryProvider extends ChangeNotifier {
await ProgressSyncService().flushPendingSync(api: _api!);
}
await Future.wait([
- loadPersonalizedView(),
+ loadPersonalizedView(force: true),
_refreshProgress(),
]);
// Clear stale local overrides — server data is now authoritative
@@ -664,17 +731,29 @@ class LibraryProvider extends ChangeNotifier {
List<String> get absorbingBookIds => _absorbingBookIds;
/// Add a key to _absorbingBookIds if not already present.
- /// If [afterKey] is provided and exists, insert right after it.
- void _absorbingIdsAdd(String key, {String? afterKey}) {
- if (_absorbingBookIds.contains(key)) return;
+ /// If [afterKey] is provided and exists, insert right after it —
+ /// and reposition the key if it's already in the list elsewhere.
+ /// Add a key to _absorbingBookIds.
+ /// [atFront] — if true (default), new items go to index 0 (stack behavior).
+ /// Set false for background section refreshes where new items
+ /// should append without disrupting the current order.
+ /// [afterKey] — insert right after this key (e.g. next-in-series after
+ /// the finished book). Repositions even if already in list.
+ void _absorbingIdsAdd(String key, {String? afterKey, bool atFront = true}) {
if (afterKey != null) {
- final idx = _absorbingBookIds.indexOf(afterKey);
- if (idx >= 0) {
- _absorbingBookIds.insert(idx + 1, key);
+ final afterIdx = _absorbingBookIds.indexOf(afterKey);
+ if (afterIdx >= 0) {
+ _absorbingBookIds.remove(key);
+ _absorbingBookIds.insert(afterIdx + 1, key);
return;
}
}
- _absorbingIdsAdd(key);
+ if (_absorbingBookIds.contains(key)) return;
+ if (atFront) {
+ _absorbingBookIds.insert(0, key);
+ } else {
+ _absorbingBookIds.add(key);
+ }
}
Map<String, Map<String, dynamic>> get absorbingItemCache => _absorbingItemCache;
@@ -716,12 +795,17 @@ class LibraryProvider extends ChangeNotifier {
// Map showId -> show entity from sections (for cloning into episode entries)
final showEntities = <String, Map<String, dynamic>>{};
+ // Keys from continue-series that should be positioned after the finished book
+ final continueSeriesKeys = <String>[];
+
+ // Snapshot existing IDs so we only reposition truly NEW series continuations
+ final existingIds = Set<String>.from(_absorbingBookIds);
+
for (final section in _personalizedSections) {
final id = section['id'] as String? ?? '';
if (id == 'continue-listening' || id == 'continue-series' ||
id == 'downloaded-books') {
- // For continue-series items, insert right after the finished book
- final insertAfter = id == 'continue-series' ? _lastFinishedItemId : null;
+ final isContinueSeries = id == 'continue-series';
for (final e in (section['entities'] as List<dynamic>? ?? [])) {
if (e is Map<String, dynamic>) {
final itemId = e['id'] as String?;
@@ -735,16 +819,18 @@ class LibraryProvider extends ChangeNotifier {
allowedKeys.add(key);
showEntities[itemId] = e;
if (!_manualAbsorbRemoves.contains(key)) {
- _absorbingIdsAdd(key, afterKey: insertAfter);
+ _absorbingIdsAdd(key, atFront: false);
_absorbingItemCache[key] = {...e, '_absorbingKey': key};
+ if (isContinueSeries) continueSeriesKeys.add(key);
}
}
} else {
// Book — use plain itemId
allowedKeys.add(itemId);
if (!_manualAbsorbRemoves.contains(itemId)) {
- _absorbingIdsAdd(itemId, afterKey: insertAfter);
+ _absorbingIdsAdd(itemId, atFront: false);
_absorbingItemCache[itemId] = e;
+ if (isContinueSeries) continueSeriesKeys.add(itemId);
}
}
}
@@ -752,6 +838,18 @@ class LibraryProvider extends ChangeNotifier {
}
}
+ // Reposition continue-series items right after the finished book.
+ // Done after all sections so the order is correct regardless of which
+ // section the item appeared in first. Only move NEW items — ones already
+ // in the list keep their position to avoid shuffling.
+ if (_lastFinishedItemId != null && continueSeriesKeys.isNotEmpty) {
+ for (final key in continueSeriesKeys) {
+ if (!existingIds.contains(key)) {
+ _absorbingIdsAdd(key, afterKey: _lastFinishedItemId);
+ }
+ }
+ }
+
// For podcast libraries, scan _progressMap for additional in-progress
// episodes not already represented in continue-listening sections.
if (isPodcastLibrary) {
@@ -802,7 +900,7 @@ class LibraryProvider extends ChangeNotifier {
'title': 'Episode',
};
syntheticEntry['_absorbingKey'] = key;
- _absorbingIdsAdd(key);
+ _absorbingIdsAdd(key, atFront: false);
_absorbingItemCache[key] = syntheticEntry;
allowedKeys.add(key);
}
@@ -851,7 +949,7 @@ class LibraryProvider extends ChangeNotifier {
_absorbingItemCache.remove(old);
}
for (final entry in migrateAdd.entries) {
- _absorbingIdsAdd(entry.key);
+ _absorbingIdsAdd(entry.key, atFront: false);
_absorbingItemCache[entry.key] = entry.value;
}
@@ -949,17 +1047,23 @@ class LibraryProvider extends ChangeNotifier {
/// Mark an item as finished locally so the overlay appears immediately,
/// before the next server refresh confirms isFinished.
- /// Then refresh sections so next-in-series appears without navigating away.
- void markFinishedLocally(String itemId) {
+ /// If [skipRefresh] is true, the caller handles refreshing (e.g.
+ /// book_detail_sheet calls refresh() after api.markFinished).
+ void markFinishedLocally(String itemId, {bool skipRefresh = false}) {
if (_resetItems.contains(itemId)) return;
final existing = _progressMap[itemId] ?? {};
_progressMap[itemId] = {...existing, 'isFinished': true};
_localProgressOverrides[itemId] = 1.0;
_lastFinishedItemId = itemId;
+ // Move finished book to front so the series continuation lands at index 1
+ _absorbingBookIds.remove(itemId);
+ _absorbingBookIds.insert(0, itemId);
notifyListeners();
- // Refresh sections so continue-series items appear immediately
- if (_api != null && _selectedLibraryId != null && !isOffline) {
- loadPersonalizedView();
+ if (!skipRefresh && _api != null && _selectedLibraryId != null && !isOffline) {
+ // Brief delay so the server has time to populate continue-series
+ Future.delayed(const Duration(milliseconds: 500), () {
+ loadPersonalizedView(force: true);
+ });
}
}
diff --git a/lib/screens/absorbing_screen.dart b/lib/screens/absorbing_screen.dart
index 00e4f228..fd26ae51 100644
--- a/lib/screens/absorbing_screen.dart
+++ b/lib/screens/absorbing_screen.dart
@@ -106,9 +106,15 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
}
}
- // Track cast state — when casting stops/disconnects, keep that card at front
+ // Track cast state — when casting starts, scroll to the card;
+ // when it stops/disconnects, keep that card at front.
final nowCasting = _cast.isCasting;
- if (nowCasting) {
+ if (nowCasting && !_wasCasting) {
+ // Casting just started — scroll to the cast card
+ _lastCastItemId = _cast.castingItemId;
+ _lastCastEpisodeId = _cast.castingEpisodeId;
+ WidgetsBinding.instance.addPostFrameCallback((_) => _scrollToActiveCard());
+ } else if (nowCasting) {
_lastCastItemId = _cast.castingItemId;
_lastCastEpisodeId = _cast.castingEpisodeId;
} else if (_wasCasting && _lastCastItemId != null) {
@@ -126,12 +132,23 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
}
void _scrollToActiveCard({int retries = 2}) {
- if (!_player.hasBook || !mounted) return;
+ if (!mounted) return;
+
+ // Determine the active key — local player takes priority, then cast
+ String? playingKey;
+ if (_player.hasBook && _player.currentItemId != null) {
+ playingKey = _player.currentEpisodeId != null
+ ? '${_player.currentItemId!}-${_player.currentEpisodeId!}'
+ : _player.currentItemId!;
+ } else if (_cast.isCasting && _cast.castingItemId != null) {
+ playingKey = _cast.castingEpisodeId != null
+ ? '${_cast.castingItemId!}-${_cast.castingEpisodeId!}'
+ : _cast.castingItemId!;
+ }
+ if (playingKey == null) return;
+
final lib = context.read<LibraryProvider>();
final books = _getAbsorbingBooks(lib);
- final playingKey = _player.currentEpisodeId != null
- ? '${_player.currentItemId!}-${_player.currentEpisodeId!}'
- : _player.currentItemId!;
final idx = books.indexWhere((b) => _absorbingKey(b) == playingKey);
if (idx >= 0 && _pageController.hasClients) {
if (_suppressReorder) {
@@ -364,10 +381,24 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
final dl = DownloadService();
var books = _getAbsorbingBooks(lib);
- // Force offline mode when actually offline
+ // When offline, only show downloaded books — but always keep the
+ // currently playing/casting item visible so controls remain accessible.
final effectiveOffline = lib.isOffline;
if (effectiveOffline) {
- books = books.where((b) => dl.isDownloaded(b['id'] as String? ?? '')).toList();
+ String? activeKey;
+ if (_player.hasBook && _player.currentItemId != null) {
+ activeKey = _player.currentEpisodeId != null
+ ? '${_player.currentItemId!}-${_player.currentEpisodeId!}'
+ : _player.currentItemId!;
+ } else if (_cast.isCasting && _cast.castingItemId != null) {
+ activeKey = _cast.castingEpisodeId != null
+ ? '${_cast.castingItemId!}-${_cast.castingEpisodeId!}'
+ : _cast.castingItemId!;
+ }
+ books = books.where((b) {
+ if (activeKey != null && _absorbingKey(b) == activeKey) return true;
+ return dl.isDownloaded(b['id'] as String? ?? '');
+ }).toList();
}
final muted = cs.onSurfaceVariant;
@@ -387,16 +418,13 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
padding: const EdgeInsets.fromLTRB(20, 12, 12, 0),
actions: [
// Offline mode toggle
- Material(
- type: MaterialType.transparency,
- child: InkWell(
- onTap: () {
- final newVal = !lib.isManualOffline;
- lib.setManualOffline(newVal);
- if (newVal) _stopAndRefresh(lib);
- },
- borderRadius: BorderRadius.circular(20),
- child: AnimatedContainer(
+ GestureDetector(
+ onTap: () {
+ final newVal = !lib.isManualOffline;
+ lib.setManualOffline(newVal);
+ if (newVal) _stopAndRefresh(lib);
+ },
+ child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
curve: Curves.easeOutCubic,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
@@ -424,30 +452,26 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
),
),
),
- ),
const SizedBox(width: 8),
// Unified button: "Sync" when idle, "Stop & Sync" when playing
if (!effectiveOffline)
- 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(
+ 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(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -467,7 +491,6 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
],
),
),
- ),
)
else
// Offline: just stop button (no sync)
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dart
index fcbd8513..84014f33 100644
--- a/lib/screens/app_shell.dart
+++ b/lib/screens/app_shell.dart
@@ -45,10 +45,12 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
int _currentIndex = 2;
final _libraryKey = GlobalKey<LibraryScreenState>();
final _player = AudioPlayerService();
+ final _cast = ChromecastService();
bool _playerHadBook = false;
bool _wasPlaying = false;
String? _lastItemId;
bool _expandedIsOpen = false;
+ bool _wasCasting = false;
Timer? _castDisconnectTimer;
void _switchToAbsorbing() {
@@ -86,11 +88,14 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
WidgetsBinding.instance.addObserver(this);
AudioPlayerService.setOnEpisodePlayStartedCallback(AppShell.goToAbsorbingGlobal);
_player.addListener(_onPlayerChanged);
+ _wasCasting = _cast.isCasting;
+ _cast.addListener(_onCastChanged);
}
@override
void dispose() {
_player.removeListener(_onPlayerChanged);
+ _cast.removeListener(_onCastChanged);
if (_instance == this) _instance = null;
WidgetsBinding.instance.removeObserver(this);
super.dispose();
@@ -115,6 +120,14 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
}
}
+ void _onCastChanged() {
+ final casting = _cast.isCasting;
+ if (casting && !_wasCasting) {
+ _switchToAbsorbing();
+ }
+ _wasCasting = casting;
+ }
+
Future<void> _maybeAutoExpand() async {
final enabled = await PlayerSettings.getFullScreenPlayer();
if (!enabled || !mounted || !_player.hasBook) return;
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index b97f5301..42a9f78c 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -620,8 +620,7 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
),
),
// Play button (48x48 hit area, 34x34 visual)
- GestureDetector(
- behavior: HitTestBehavior.opaque,
+ InkWell(
onTap: _isLoading ? null : () {
if (isCurrentItem) {
player.togglePlayPause();
@@ -629,6 +628,7 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
_startBook(context, itemId);
}
},
+ customBorder: const CircleBorder(),
child: SizedBox(
width: 48, height: 48,
child: Center(
diff --git a/lib/screens/stats_screen.dart b/lib/screens/stats_screen.dart
index a15c150d..ca562bcf 100644
--- a/lib/screens/stats_screen.dart
+++ b/lib/screens/stats_screen.dart
@@ -2,6 +2,7 @@ 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';
@@ -34,16 +35,6 @@ 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;
@@ -66,18 +57,6 @@ 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>? ?? [];
@@ -145,6 +124,18 @@ 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),
@@ -157,29 +148,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,
- '${_longestStreakVal}d', 'Longest\nStreak')),
+ '${longestStreak}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),
@@ -187,14 +178,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 ──
@@ -378,10 +369,13 @@ class _StatsScreenState extends State<StatsScreen> with SingleTickerProviderStat
List<Widget> _buildSessions(TextTheme tt, ColorScheme cs) {
return _sessions.take(15).map((s) {
if (s is! Map<String, dynamic>) return const SizedBox.shrink();
- final title = s['displayTitle'] as String? ??
- (s['mediaMetadata'] as Map<String, dynamic>?)?['title'] as String? ?? 'Unknown';
- final author = s['displayAuthor'] as String? ??
- (s['mediaMetadata'] as Map<String, dynamic>?)?['authorName'] as String? ?? '';
+ final rawTitle = s['displayTitle'] as String?;
+ final rawAuthor = s['displayAuthor'] as String?;
+ final meta = s['mediaMetadata'] as Map<String, dynamic>?;
+ final title = (rawTitle != null && !_looksLikeId(rawTitle)) ? rawTitle
+ : meta?['title'] as String? ?? 'Unknown';
+ final author = (rawAuthor != null && !_looksLikeId(rawAuthor)) ? rawAuthor
+ : meta?['authorName'] as String? ?? '';
final duration = _safeNum(s['timeListening']);
final updatedAt = s['updatedAt'] is num
? DateTime.fromMillisecondsSinceEpoch((s['updatedAt'] as num).toInt())
@@ -485,6 +479,14 @@ class _StatsScreenState extends State<StatsScreen> with SingleTickerProviderStat
static double _safeNum(dynamic val) => val is num ? val.toDouble() : 0;
+ /// Detects UUIDs and ABS prefixed IDs (li_, ep_, etc.) that the server
+ /// sometimes stores as displayTitle/displayAuthor for admin accounts.
+ static final _idPattern = RegExp(
+ r'^([a-z]{2,4}_)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$',
+ caseSensitive: false,
+ );
+ static bool _looksLikeId(String v) => _idPattern.hasMatch(v);
+
Map<String, dynamic> _extractDailyMap(Map<String, dynamic> stats) {
for (final key in ['dayListeningMap', 'days']) {
final val = stats[key];
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index 4c0cea3d..febc3c23 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -146,6 +146,23 @@ class PlayerSettings {
static Future<bool> getFullScreenPlayer() => _get('fullScreenPlayer', false);
static Future<void> setFullScreenPlayer(bool value) => _set('fullScreenPlayer', value);
+ // ── Card button order ──
+
+ static const defaultButtonOrder = ['chapters', 'speed', 'sleep', 'bookmarks', 'details', 'equalizer', 'cast', 'history', 'remove'];
+
+ static Future<List<String>> getCardButtonOrder() async {
+ final prefs = await SharedPreferences.getInstance();
+ final stored = prefs.getStringList('card_button_order');
+ if (stored != null && stored.length == defaultButtonOrder.length) return stored;
+ return List.from(defaultButtonOrder);
+ }
+
+ static Future<void> setCardButtonOrder(List<String> order) async {
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setStringList('card_button_order', order);
+ _notify();
+ }
+
// ── Appearance ──
static Future<String> getThemeMode() => _get('themeMode', 'dark');
@@ -506,6 +523,7 @@ class AudioPlayerService extends ChangeNotifier {
}
static AudioPlayerHandler? _handler;
+ static Completer<void> _initCompleter = Completer<void>();
AudioPlayer? get _player => _handler?.player;
String? _currentItemId;
@@ -674,36 +692,46 @@ class AudioPlayerService extends ChangeNotifier {
/// MUST be called after Activity is ready.
static Future<void> init() async {
- _handler = await AudioService.init<AudioPlayerHandler>(
- builder: () => AudioPlayerHandler(),
- config: AudioServiceConfig(
- androidNotificationChannelId: 'com.audiobookshelf.app.channel.audio',
- androidNotificationChannelName: 'Absorb',
- androidNotificationOngoing: true,
- // Keep foreground service alive when paused — prevents Android from
- // killing audio after notification interruptions on locked screen.
- androidStopForegroundOnPause: false,
- androidNotificationIcon: 'drawable/ic_notification',
- androidBrowsableRootExtras: {
- AndroidContentStyle.supportedKey: true,
- AndroidContentStyle.browsableHintKey:
- AndroidContentStyle.categoryListItemHintValue,
- AndroidContentStyle.playableHintKey:
- AndroidContentStyle.gridItemHintValue,
- 'android.media.browse.SEARCH_SUPPORTED': true,
- },
- ),
- );
- // Bind service so handler routes play/pause through service (for auto-rewind)
- _handler!.bindService(_instance);
- debugPrint('[Player] AudioService initialized');
-
- // Configure audio session for audiobook playback
- await _configureAudioSession();
+ // Reset for hot restart — previous completer may already be completed
+ // while _handler was reset to null by the Dart VM restart.
+ if (_initCompleter.isCompleted) {
+ _initCompleter = Completer<void>();
+ }
+ try {
+ _handler = await AudioService.init<AudioPlayerHandler>(
+ builder: () => AudioPlayerHandler(),
+ config: AudioServiceConfig(
+ androidNotificationChannelId: 'com.audiobookshelf.app.channel.audio',
+ androidNotificationChannelName: 'Absorb',
+ // Keep foreground service alive when paused — prevents Android from
+ // killing audio after notification interruptions on locked screen.
+ androidStopForegroundOnPause: false,
+ androidNotificationIcon: 'drawable/ic_notification',
+ androidBrowsableRootExtras: {
+ AndroidContentStyle.supportedKey: true,
+ AndroidContentStyle.browsableHintKey:
+ AndroidContentStyle.categoryListItemHintValue,
+ AndroidContentStyle.playableHintKey:
+ AndroidContentStyle.gridItemHintValue,
+ 'android.media.browse.SEARCH_SUPPORTED': true,
+ },
+ ),
+ );
+ // Bind service so handler routes play/pause through service (for auto-rewind)
+ _handler!.bindService(_instance);
+ debugPrint('[Player] AudioService initialized');
+ // Configure audio session for audiobook playback
+ await _configureAudioSession();
+ } finally {
+ if (!_initCompleter.isCompleted) _initCompleter.complete();
+ }
}
static StreamSubscription? _interruptSub;
static StreamSubscription? _noisySub;
+ // Set true when BT/headphones disconnect so the interruption handler
+ // won't auto-resume playback onto the phone speaker.
+ static bool _noisyPause = false;
static Future<void> _configureAudioSession() async {
final session = await AudioSession.instance;
@@ -726,22 +754,34 @@ class AudioPlayerService extends ChangeNotifier {
service._wasPlayingBeforeInterrupt = true;
}
} else {
+ // Don't auto-resume if the pause was caused by BT/headphone disconnect.
+ // Some devices fire interruption-end AFTER becoming-noisy, which would
+ // resume playback on the phone speaker.
+ if (_noisyPause) {
+ debugPrint('[AudioSession] Interruption ended after noisy — skipping resume');
+ service._wasPlayingBeforeInterrupt = false;
+ return;
+ }
if (service._wasPlayingBeforeInterrupt) {
debugPrint('[AudioSession] Interruption ended — resuming');
service._wasPlayingBeforeInterrupt = false;
await Future.delayed(const Duration(milliseconds: 300));
+ // Re-check: another event (like becoming-noisy) might have fired
+ // during the delay.
+ if (_noisyPause) return;
await service.play();
}
}
});
- // Headphones unplugged — pause, no auto-resume
+ // Headphones unplugged / BT disconnected — pause, no auto-resume
_noisySub?.cancel();
_noisySub = session.becomingNoisyEventStream.listen((_) async {
final service = _instance;
+ debugPrint('[AudioSession] Becoming noisy — pausing');
+ _noisyPause = true;
+ service._wasPlayingBeforeInterrupt = false;
if (service.isPlaying) {
- debugPrint('[AudioSession] Becoming noisy — pausing');
- service._wasPlayingBeforeInterrupt = false;
await service.pause();
}
});
@@ -766,7 +806,11 @@ class AudioPlayerService extends ChangeNotifier {
String? episodeTitle,
}) async {
if (_handler == null) {
- debugPrint('[Player] Handler not initialized!');
+ debugPrint('[Player] Handler not yet initialized, waiting…');
+ await _initCompleter.future;
+ }
+ if (_handler == null) {
+ debugPrint('[Player] Handler init failed, cannot play');
return false;
}
@@ -1458,6 +1502,7 @@ class AudioPlayerService extends ChangeNotifier {
Future<void> play() async {
debugPrint('[Service] play() called — lastPause=${_lastPauseTime != null}');
+ _noisyPause = false; // User explicitly resumed — allow interrupt-resume again
// Auto-rewind on resume if enabled
if (_lastPauseTime != null && _player != null) {
final settings = await AutoRewindSettings.load();
diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dart
index 93d10311..373a46f0 100644
--- a/lib/widgets/absorbing_card.dart
+++ b/lib/widgets/absorbing_card.dart
@@ -17,6 +17,7 @@ import 'equalizer_sheet.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 '../services/progress_sync_service.dart';
@@ -40,6 +41,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
StreamSubscription<Duration>? _chapterTrackSub;
int _lastChapterIdx = -1;
ui.Image? _blurredCover; // Precached blurred background
+ List<String> _buttonOrder = PlayerSettings.defaultButtonOrder;
@override
bool get wantKeepAlive => true;
@@ -99,6 +101,14 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
_fetchChaptersIfNeeded();
_startChapterTracking();
ChromecastService().addListener(_onCastChanged);
+ PlayerSettings.settingsChanged.addListener(_reloadButtonOrder);
+ _reloadButtonOrder();
+ }
+
+ void _reloadButtonOrder() {
+ PlayerSettings.getCardButtonOrder().then((o) {
+ if (mounted && o.join(',') != _buttonOrder.join(',')) setState(() => _buttonOrder = o);
+ });
}
void _onCastChanged() {
@@ -216,6 +226,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
@override
void dispose() {
+ PlayerSettings.settingsChanged.removeListener(_reloadButtonOrder);
ChromecastService().removeListener(_onCastChanged);
_chapterTrackSub?.cancel();
_blurredCover?.dispose();
@@ -479,7 +490,6 @@ 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(),
@@ -647,35 +657,15 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
const Spacer(flex: 3),
// ── Button grid (hugs bottom) ──
Row(children: [
- Expanded(child: CardWideButton(
- icon: Icons.list_rounded, label: 'Chapters',
- accent: accent, isActive: _isPlaybackActive,
- onTap: () => _showChapters(context, accent, tt),
- )),
+ Expanded(child: _buildCardButton(_buttonOrder[0], accent, tt)),
const SizedBox(width: 8),
- Expanded(child: CardWideButton(
- icon: Icons.speed_rounded, label: 'Speed',
- accent: accent, isActive: _isPlaybackActive,
- child: CardSpeedButtonInline(player: widget.player, accent: accent, isActive: _isActive, itemId: _itemId),
- )),
+ Expanded(child: _buildCardButton(_buttonOrder[1], accent, tt)),
]),
const SizedBox(height: 8),
- // Secondary actions: Sleep Timer + Bookmarks
Row(children: [
- Expanded(child: CardWideButton(
- icon: Icons.bedtime_outlined, label: 'Sleep Timer',
- accent: accent, isActive: _isPlaybackActive,
- child: CardSleepButtonInline(accent: accent, isActive: _isPlaybackActive),
- )),
+ Expanded(child: _buildCardButton(_buttonOrder[2], accent, tt)),
const SizedBox(width: 8),
- Expanded(child: CardWideButton(
- icon: Icons.bookmark_outline_rounded, label: 'Bookmarks',
- accent: accent, isActive: _isPlaybackActive,
- child: CardBookmarkButtonInline(
- player: widget.player, accent: accent,
- isActive: _isActive, itemId: _itemId,
- ),
- )),
+ Expanded(child: _buildCardButton(_buttonOrder[3], accent, tt)),
]),
const SizedBox(height: 8),
// More menu / Cast controls (centered below buttons)
@@ -863,6 +853,229 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
}
}
+ // ── Dynamic button builders ─────────────────────────────────
+
+ Widget _buildCardButton(String id, Color accent, TextTheme tt, {bool large = false}) {
+ switch (id) {
+ case 'chapters':
+ return CardWideButton(
+ icon: Icons.list_rounded, label: 'Chapters',
+ accent: accent, isActive: _isPlaybackActive, large: large,
+ onTap: () => _showChapters(context, accent, tt),
+ );
+ case 'speed':
+ return CardWideButton(
+ icon: Icons.speed_rounded, label: 'Speed',
+ accent: accent, isActive: _isPlaybackActive, large: large,
+ child: CardSpeedButtonInline(player: widget.player, accent: accent, isActive: _isActive, large: large, itemId: _itemId),
+ );
+ case 'sleep':
+ return CardWideButton(
+ icon: Icons.bedtime_outlined, label: 'Sleep Timer',
+ accent: accent, isActive: _isPlaybackActive, large: large,
+ child: CardSleepButtonInline(accent: accent, isActive: _isPlaybackActive, large: large),
+ );
+ case 'bookmarks':
+ return CardWideButton(
+ icon: Icons.bookmark_outline_rounded, label: 'Bookmarks',
+ accent: accent, isActive: _isPlaybackActive, large: large,
+ child: CardBookmarkButtonInline(
+ player: widget.player, accent: accent,
+ isActive: _isActive, itemId: _itemId, large: large,
+ ),
+ );
+ case 'details':
+ return CardWideButton(
+ icon: (_episodeId != null || _isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,
+ label: (_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details',
+ accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ onTap: () {
+ if (_episodeId != null || _isPodcastEpisode) {
+ final episode = _recentEpisode ?? {
+ 'id': widget.player.currentEpisodeId,
+ 'title': widget.player.currentEpisodeTitle,
+ 'duration': widget.player.totalDuration,
+ };
+ EpisodeDetailSheet.show(context, widget.item, episode);
+ } else {
+ showBookDetailSheet(context, _itemId);
+ }
+ },
+ );
+ case 'equalizer':
+ return CardWideButton(
+ icon: Icons.equalizer_rounded, label: 'Audio Enhancements',
+ accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ onTap: () => 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 CardWideButton(
+ icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,
+ label: castLabel, accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ onTap: () => _handleCastTap(context, accent),
+ );
+ },
+ );
+ case 'history':
+ return CardWideButton(
+ icon: Icons.history_rounded, label: 'Playback History',
+ accent: accent, isActive: _isActive, large: large,
+ onTap: () => _showHistory(context, accent, tt),
+ );
+ case 'remove':
+ return CardWideButton(
+ icon: Icons.remove_circle_outline_rounded, label: 'Remove from Absorbing',
+ accent: Colors.red.shade300, isActive: true, alwaysEnabled: true, large: large,
+ onTap: _removeFromAbsorbing,
+ );
+ 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: _isPlaybackActive,
+ onTap: () { Navigator.pop(ctx); _showChapters(context, accent, tt); },
+ );
+ case 'speed':
+ return MoreMenuItem(
+ icon: Icons.speed_rounded, label: 'Speed', accent: accent,
+ enabled: _isPlaybackActive,
+ 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: _isPlaybackActive,
+ 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, 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: () {
+ Navigator.pop(ctx);
+ if (_episodeId != null || _isPodcastEpisode) {
+ final episode = _recentEpisode ?? {
+ 'id': widget.player.currentEpisodeId,
+ 'title': widget.player.currentEpisodeTitle,
+ 'duration': widget.player.totalDuration,
+ };
+ EpisodeDetailSheet.show(context, widget.item, episode);
+ } else {
+ showBookDetailSheet(context, _itemId);
+ }
+ },
+ );
+ case 'equalizer':
+ return MoreMenuItem(
+ icon: Icons.equalizer_rounded, label: 'Audio Enhancements', 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: _isActive,
+ 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(); },
+ );
+ default:
+ return const SizedBox.shrink();
+ }
+ }
+
+ 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);
@@ -1014,125 +1227,20 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
}
void _showMoreMenu(BuildContext context, Color accent, TextTheme tt) {
+ final overflowIds = _buttonOrder.skip(4).toList();
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
- builder: (ctx) => 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: SafeArea(
- child: Padding(
- padding: const EdgeInsets.fromLTRB(16, 8, 16, 12),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- // Drag handle
- Container(width: 40, height: 4, decoration: BoxDecoration(color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.24), borderRadius: BorderRadius.circular(2))),
- const SizedBox(height: 16),
- // Details option
- 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);
- if (_episodeId != null || _isPodcastEpisode) {
- final episode = _recentEpisode ?? {
- 'id': widget.player.currentEpisodeId,
- 'title': widget.player.currentEpisodeTitle,
- 'duration': widget.player.totalDuration,
- };
- EpisodeDetailSheet.show(context, widget.item, episode);
- } else {
- showBookDetailSheet(context, _itemId);
- }
- },
- ),
- const SizedBox(height: 6),
- // Equalizer / Audio Enhancements
- MoreMenuItem(
- icon: Icons.equalizer_rounded,
- label: 'Audio Enhancements',
- accent: accent,
- onTap: () { Navigator.pop(ctx); showEqualizerSheet(context, accent); },
- ),
- const SizedBox(height: 6),
- // Cast to device
- 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: () {
- final auth = context.read<AuthProvider>();
- final api = auth.apiService;
- Navigator.pop(ctx);
- 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);
- }
- },
- );
- },
- ),
- const SizedBox(height: 6),
- // History option
- MoreMenuItem(
- icon: Icons.history_rounded,
- label: 'Playback History',
- accent: accent,
- enabled: _isActive,
- onTap: () { Navigator.pop(ctx); _showHistory(context, accent, tt); },
- ),
- const SizedBox(height: 6),
- // Remove from Absorbing
- MoreMenuItem(
- icon: Icons.remove_circle_outline_rounded,
- label: 'Remove from Absorbing',
- accent: Colors.red.shade300,
- onTap: () {
- Navigator.pop(ctx);
- _removeFromAbsorbing();
- },
- ),
- const SizedBox(height: 8),
- ],
- ),
- ),
- ),
+ isScrollControlled: true,
+ builder: (ctx) => MoreMenuSheet(
+ overflowIds: overflowIds,
+ allIds: _buttonOrder,
+ accent: accent,
+ buildItem: (id) => _buildMoreMenuItem(id, accent, tt, ctx),
+ onReorder: (newOrder) {
+ setState(() => _buttonOrder = newOrder);
+ PlayerSettings.setCardButtonOrder(newOrder);
+ },
),
);
}
@@ -1177,3 +1285,4 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
return '${m}m ${sec}s';
}
}
+
diff --git a/lib/widgets/author_card.dart b/lib/widgets/author_card.dart
index cb6eb66b..613049ea 100644
--- a/lib/widgets/author_card.dart
+++ b/lib/widgets/author_card.dart
@@ -47,7 +47,6 @@ 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 5315e15a..0ed57913 100644
--- a/lib/widgets/book_card.dart
+++ b/lib/widgets/book_card.dart
@@ -6,7 +6,6 @@ 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;
@@ -191,7 +190,7 @@ class BookCard extends StatelessWidget {
// Square cover
AspectRatio(
aspectRatio: 1,
- child: PressableCard(
+ child: _PressableCard(
onTap: () => _navigateToDetail(context),
borderRadius: 12,
child: Card(
@@ -300,7 +299,6 @@ class _CoverImage extends StatelessWidget {
imageUrl: coverUrl!,
fit: fit,
httpHeaders: httpHeaders,
- fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _placeholder(),
errorWidget: (_, __, ___) => _placeholder(),
);
@@ -318,4 +316,61 @@ class _CoverImage extends StatelessWidget {
),
);
}
-}
\ No newline at end of file
+}
+
+/// 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,
+ ),
+ );
+ }
+}
diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dart
index 4cf2901d..5ce4ffab 100644
--- a/lib/widgets/book_detail_sheet.dart
+++ b/lib/widgets/book_detail_sheet.dart
@@ -152,12 +152,6 @@ 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;
@@ -165,14 +159,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 (_blurCoverUrl != null)
+ if (_coverUrl != null)
Positioned.fill(
child: RepaintBoundary(
child: CachedNetworkImage(
- imageUrl: _blurCoverUrl!, fit: BoxFit.cover,
+ imageUrl: _coverUrl!, fit: BoxFit.cover,
httpHeaders: context.read<LibraryProvider>().mediaHeaders,
imageBuilder: (_, p) => ImageFiltered(
- imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30, tileMode: TileMode.decal),
+ imageFilter: ImageFilter.blur(sigmaX: 50, sigmaY: 50, tileMode: TileMode.decal),
child: Image(image: p, fit: BoxFit.cover)),
placeholder: (_, __) => const SizedBox(),
errorWidget: (_, __, ___) => const SizedBox(),
@@ -187,7 +181,9 @@ 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)))
- : _buildContent(context, cs, tt),
+ : AnimatedOpacity(
+ opacity: 1.0, duration: const Duration(milliseconds: 300),
+ child: _buildContent(context, cs, tt)),
]),
);
}
@@ -649,7 +645,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
// Mark finished locally first so the absorbing card shows the overlay
// immediately when the player stops (which triggers the expanded card to pop)
if (context.mounted) {
- context.read<LibraryProvider>().markFinishedLocally(widget.itemId);
+ context.read<LibraryProvider>().markFinishedLocally(widget.itemId, skipRefresh: true);
}
if (player.currentItemId == widget.itemId) await player.stop();
try {
diff --git a/lib/widgets/card_button_config.dart b/lib/widgets/card_button_config.dart
new file mode 100644
index 00000000..346c43e1
--- /dev/null
+++ b/lib/widgets/card_button_config.dart
@@ -0,0 +1,28 @@
+import 'package:flutter/material.dart';
+
+class CardButtonDef {
+ final String id;
+ final String label;
+ final IconData icon;
+ const CardButtonDef(this.id, this.label, this.icon);
+}
+
+const allCardButtons = [
+ CardButtonDef('chapters', 'Chapters', Icons.list_rounded),
+ CardButtonDef('speed', 'Speed', Icons.speed_rounded),
+ CardButtonDef('sleep', 'Sleep Timer', Icons.bedtime_outlined),
+ CardButtonDef('bookmarks', 'Bookmarks', Icons.bookmark_outline_rounded),
+ CardButtonDef('details', 'Book Details', Icons.info_outline_rounded),
+ CardButtonDef('equalizer', 'Audio Enhancements', Icons.equalizer_rounded),
+ CardButtonDef('cast', 'Cast to Device', Icons.cast_rounded),
+ CardButtonDef('history', 'Playback History', Icons.history_rounded),
+ CardButtonDef('remove', 'Remove from Absorbing', Icons.remove_circle_outline_rounded),
+];
+
+/// Look up a button definition by ID.
+CardButtonDef? buttonDefById(String id) {
+ for (final b in allCardButtons) {
+ if (b.id == id) return b;
+ }
+ return null;
+}
diff --git a/lib/widgets/card_buttons.dart b/lib/widgets/card_buttons.dart
index 880180ce..4fe9e3a7 100644
--- a/lib/widgets/card_buttons.dart
+++ b/lib/widgets/card_buttons.dart
@@ -5,6 +5,7 @@ import '../services/bookmark_service.dart';
import '../services/chromecast_service.dart';
import '../services/sleep_timer_service.dart';
import 'absorb_slider.dart';
+import 'card_button_config.dart';
import 'sleep_timer_sheet.dart';
/// Show a toast when the user taps a button that requires active playback.
@@ -565,3 +566,187 @@ class _SimpleBookmarkSheetState extends State<SimpleBookmarkSheet> {
}
}
}
+
+// ─── MORE MENU SHEET (with edit/reorder mode) ────────────────
+
+class MoreMenuSheet extends StatefulWidget {
+ final List<String> overflowIds;
+ final List<String> allIds;
+ final Color accent;
+ final Widget Function(String id) buildItem;
+ final ValueChanged<List<String>> onReorder;
+ const MoreMenuSheet({super.key, required this.overflowIds, required this.allIds, required this.accent, required this.buildItem, required this.onReorder});
+ @override State<MoreMenuSheet> createState() => _MoreMenuSheetState();
+}
+
+class _MoreMenuSheetState extends State<MoreMenuSheet> {
+ bool _editing = false;
+ late List<String> _order;
+
+ @override
+ void initState() {
+ super.initState();
+ _order = List.from(widget.allIds);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final cs = Theme.of(context).colorScheme;
+ final tt = Theme.of(context).textTheme;
+ if (_editing) return _buildEditMode(cs, tt);
+ return _buildNormalMode(cs, tt);
+ }
+
+ Widget _buildNormalMode(ColorScheme cs, TextTheme tt) {
+ return Container(
+ decoration: BoxDecoration(
+ color: Theme.of(context).bottomSheetTheme.backgroundColor,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
+ border: Border(top: BorderSide(color: widget.accent.withValues(alpha: 0.2), width: 1)),
+ ),
+ child: SafeArea(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(16, 8, 16, 12),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ // Drag handle + edit button
+ Stack(
+ alignment: Alignment.center,
+ children: [
+ Container(width: 40, height: 4, decoration: BoxDecoration(color: cs.onSurface.withValues(alpha: 0.24), borderRadius: BorderRadius.circular(2))),
+ Align(
+ alignment: Alignment.centerRight,
+ child: GestureDetector(
+ onTap: () => setState(() => _editing = true),
+ child: Padding(
+ padding: const EdgeInsets.all(8),
+ child: Icon(Icons.edit_rounded, size: 18, color: cs.onSurface.withValues(alpha: 0.5)),
+ ),
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 12),
+ for (int i = 0; i < widget.overflowIds.length; i++) ...[
+ widget.buildItem(widget.overflowIds[i]),
+ if (i < widget.overflowIds.length - 1) const SizedBox(height: 6),
+ ],
+ const SizedBox(height: 8),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildEditMode(ColorScheme cs, TextTheme tt) {
+ return Container(
+ constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.7),
+ decoration: BoxDecoration(
+ color: Theme.of(context).bottomSheetTheme.backgroundColor,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
+ border: Border(top: BorderSide(color: widget.accent.withValues(alpha: 0.2), width: 1)),
+ ),
+ child: SafeArea(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 12, 8, 0),
+ child: Row(children: [
+ Text('Edit Layout', style: tt.titleSmall?.copyWith(fontWeight: FontWeight.w600)),
+ const Spacer(),
+ IconButton(
+ icon: Icon(Icons.check_rounded, color: widget.accent),
+ onPressed: () {
+ widget.onReorder(_order);
+ Navigator.pop(context);
+ },
+ ),
+ ]),
+ ),
+ const SizedBox(height: 4),
+ Flexible(
+ child: ReorderableListView.builder(
+ shrinkWrap: true,
+ buildDefaultDragHandles: false,
+ proxyDecorator: (child, index, animation) {
+ return AnimatedBuilder(
+ animation: animation,
+ builder: (context, child) => Material(
+ elevation: 4,
+ borderRadius: BorderRadius.circular(12),
+ color: cs.surfaceContainer,
+ child: child,
+ ),
+ child: child,
+ );
+ },
+ itemCount: _order.length,
+ onReorder: (oldIdx, newIdx) {
+ setState(() {
+ if (newIdx > oldIdx) newIdx--;
+ final item = _order.removeAt(oldIdx);
+ _order.insert(newIdx, item);
+ });
+ },
+ itemBuilder: (context, i) {
+ final id = _order[i];
+ final def = buttonDefById(id);
+ if (def == null) return SizedBox.shrink(key: ValueKey(id));
+
+ final isOnCard = i < 4;
+ final showDivider = i == 4;
+
+ return Column(
+ key: ValueKey(id),
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (showDivider)
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
+ child: Row(children: [
+ Expanded(child: Divider(color: cs.onSurface.withValues(alpha: 0.12))),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ child: Text('In menu', style: tt.labelSmall?.copyWith(color: cs.onSurface.withValues(alpha: 0.4))),
+ ),
+ Expanded(child: Divider(color: cs.onSurface.withValues(alpha: 0.12))),
+ ]),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
+ decoration: BoxDecoration(
+ color: isOnCard ? widget.accent.withValues(alpha: 0.08) : Colors.transparent,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Row(children: [
+ Icon(def.icon, size: 20, color: id == 'remove' ? Colors.red.shade300 : cs.onSurface.withValues(alpha: 0.7)),
+ const SizedBox(width: 12),
+ Expanded(child: Text(def.label, style: tt.bodyMedium)),
+ if (isOnCard)
+ Padding(
+ padding: const EdgeInsets.only(right: 8),
+ child: Text('${i + 1}', style: tt.labelSmall?.copyWith(color: widget.accent, fontWeight: FontWeight.w700)),
+ ),
+ ReorderableDragStartListener(
+ index: i,
+ child: Icon(Icons.drag_handle_rounded, size: 20, color: cs.onSurface.withValues(alpha: 0.3)),
+ ),
+ ]),
+ ),
+ ),
+ ],
+ );
+ },
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/widgets/episode_list_sheet.dart b/lib/widgets/episode_list_sheet.dart
index 1b379bf3..b5d976d6 100644
--- a/lib/widgets/episode_list_sheet.dart
+++ b/lib/widgets/episode_list_sheet.dart
@@ -204,10 +204,9 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
if (mounted) setState(() => _isDownloadingAll = false);
}
- /// Low-res cover for the blurred background (much cheaper to filter).
- String? get _blurCoverUrl {
+ String? get _coverUrl {
final auth = context.read<AuthProvider>();
- return auth.apiService?.getCoverUrl(_itemId, width: 200);
+ return auth.apiService?.getCoverUrl(_itemId, width: 800);
}
@override
@@ -215,7 +214,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final lib = context.watch<LibraryProvider>();
- final blurCoverUrl = _blurCoverUrl;
+ final coverUrl = _coverUrl;
return Container(
clipBehavior: Clip.antiAlias,
@@ -225,14 +224,14 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
),
child: Stack(children: [
// Blurred cover background
- if (blurCoverUrl != null)
+ if (coverUrl != null)
Positioned.fill(
child: RepaintBoundary(
child: CachedNetworkImage(
- imageUrl: blurCoverUrl, fit: BoxFit.cover,
+ imageUrl: coverUrl, fit: BoxFit.cover,
httpHeaders: lib.mediaHeaders,
imageBuilder: (_, p) => ImageFiltered(
- imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30, tileMode: TileMode.decal),
+ imageFilter: ImageFilter.blur(sigmaX: 50, sigmaY: 50, tileMode: TileMode.decal),
child: Image(image: p, fit: BoxFit.cover)),
placeholder: (_, __) => const SizedBox(),
errorWidget: (_, __, ___) => const SizedBox(),
@@ -610,10 +609,9 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
}
}
- /// Low-res cover for the blurred background (much cheaper to filter).
- String? get _blurCoverUrl {
+ String? get _coverUrl {
final auth = context.read<AuthProvider>();
- return auth.apiService?.getCoverUrl(_itemId, width: 200);
+ return auth.apiService?.getCoverUrl(_itemId, width: 800);
}
@override
@@ -621,7 +619,7 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final lib = context.watch<LibraryProvider>();
- final blurCoverUrl = _blurCoverUrl;
+ final coverUrl = _coverUrl;
final dlKey = '$_itemId-$_episodeId';
@@ -655,14 +653,14 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
),
child: Stack(children: [
// Blurred cover background
- if (blurCoverUrl != null)
+ if (coverUrl != null)
Positioned.fill(
child: RepaintBoundary(
child: CachedNetworkImage(
- imageUrl: blurCoverUrl, fit: BoxFit.cover,
+ imageUrl: coverUrl, fit: BoxFit.cover,
httpHeaders: lib.mediaHeaders,
imageBuilder: (_, p) => ImageFiltered(
- imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30, tileMode: TileMode.decal),
+ imageFilter: ImageFilter.blur(sigmaX: 50, sigmaY: 50, 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 cc65c924..81a01969 100644
--- a/lib/widgets/expanded_card.dart
+++ b/lib/widgets/expanded_card.dart
@@ -18,6 +18,7 @@ import 'card_progress_bar.dart';
import 'card_playback_controls.dart';
import 'card_buttons.dart';
import 'chromecast_button.dart';
+import 'sleep_timer_sheet.dart';
// ─── Custom route: slide-up + fade ────────────────────────────
@@ -85,6 +86,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
late String? _currentEpisodeId;
bool _wasPlaying = false;
bool _isPopping = false; // Prevent double-pop and setState during exit
+ List<String> _buttonOrder = PlayerSettings.defaultButtonOrder;
// Our own route, captured for popUntil when modals are stacked above us
Route<dynamic>? _ownRoute;
@@ -149,6 +151,8 @@ class _ExpandedCardState extends State<ExpandedCard> {
_wasPlaying = widget.player.hasBook;
widget.player.addListener(_onPlayerChanged);
ChromecastService().addListener(_onCastChanged);
+ PlayerSettings.settingsChanged.addListener(_reloadButtonOrder);
+ _reloadButtonOrder();
_startChapterTracking();
_fetchChaptersIfNeeded();
// Generate our own blurred cover
@@ -161,6 +165,12 @@ class _ExpandedCardState extends State<ExpandedCard> {
setState(() {});
}
+ void _reloadButtonOrder() {
+ PlayerSettings.getCardButtonOrder().then((o) {
+ if (mounted && o.join(',') != _buttonOrder.join(',')) setState(() => _buttonOrder = o);
+ });
+ }
+
@override
void didChangeDependencies() {
super.didChangeDependencies();
@@ -170,6 +180,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
@override
void dispose() {
+ PlayerSettings.settingsChanged.removeListener(_reloadButtonOrder);
if (!_isPopping) {
widget.player.removeListener(_onPlayerChanged);
ChromecastService().removeListener(_onCastChanged);
@@ -584,7 +595,6 @@ 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(),
@@ -732,34 +742,15 @@ class _ExpandedCardState extends State<ExpandedCard> {
const Spacer(flex: 3),
// ── Button grid ──
Row(children: [
- Expanded(child: CardWideButton(
- icon: Icons.list_rounded, label: 'Chapters',
- accent: accent, isActive: _isPlaybackActive, large: true,
- onTap: () => _showChapters(context, accent, tt),
- )),
+ Expanded(child: _buildCardButton(_buttonOrder[0], accent, tt)),
const SizedBox(width: 10),
- Expanded(child: CardWideButton(
- icon: Icons.speed_rounded, label: 'Speed',
- accent: accent, isActive: _isPlaybackActive, large: true,
- child: CardSpeedButtonInline(player: widget.player, accent: accent, isActive: _isActive, large: true, itemId: _itemId),
- )),
+ Expanded(child: _buildCardButton(_buttonOrder[1], accent, tt)),
]),
const SizedBox(height: 10),
Row(children: [
- Expanded(child: CardWideButton(
- icon: Icons.bedtime_outlined, label: 'Sleep Timer',
- accent: accent, isActive: _isPlaybackActive, large: true,
- child: CardSleepButtonInline(accent: accent, isActive: _isPlaybackActive, large: true),
- )),
+ Expanded(child: _buildCardButton(_buttonOrder[2], accent, tt)),
const SizedBox(width: 10),
- Expanded(child: CardWideButton(
- icon: Icons.bookmark_outline_rounded, label: 'Bookmarks',
- accent: accent, isActive: _isPlaybackActive, large: true,
- child: CardBookmarkButtonInline(
- player: widget.player, accent: accent,
- isActive: _isActive, itemId: _itemId, large: true,
- ),
- )),
+ Expanded(child: _buildCardButton(_buttonOrder[3], accent, tt)),
]),
const SizedBox(height: 10),
// More menu / Cast controls
@@ -981,6 +972,230 @@ class _ExpandedCardState extends State<ExpandedCard> {
}
}
+ // ── Dynamic button builders ─────────────────────────────────
+
+ Widget _buildCardButton(String id, Color accent, TextTheme tt) {
+ const large = true;
+ switch (id) {
+ case 'chapters':
+ return CardWideButton(
+ icon: Icons.list_rounded, label: 'Chapters',
+ accent: accent, isActive: _isPlaybackActive, large: large,
+ onTap: () => _showChapters(context, accent, tt),
+ );
+ case 'speed':
+ return CardWideButton(
+ icon: Icons.speed_rounded, label: 'Speed',
+ accent: accent, isActive: _isPlaybackActive, large: large,
+ child: CardSpeedButtonInline(player: widget.player, accent: accent, isActive: _isActive, large: large, itemId: _itemId),
+ );
+ case 'sleep':
+ return CardWideButton(
+ icon: Icons.bedtime_outlined, label: 'Sleep Timer',
+ accent: accent, isActive: _isPlaybackActive, large: large,
+ child: CardSleepButtonInline(accent: accent, isActive: _isPlaybackActive, large: large),
+ );
+ case 'bookmarks':
+ return CardWideButton(
+ icon: Icons.bookmark_outline_rounded, label: 'Bookmarks',
+ accent: accent, isActive: _isPlaybackActive, large: large,
+ child: CardBookmarkButtonInline(
+ player: widget.player, accent: accent,
+ isActive: _isActive, itemId: _itemId, large: large,
+ ),
+ );
+ case 'details':
+ return CardWideButton(
+ icon: (_episodeId != null || _isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,
+ label: (_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details',
+ accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ onTap: () {
+ if (_episodeId != null || _isPodcastEpisode) {
+ final episode = _recentEpisode ?? {
+ 'id': widget.player.currentEpisodeId,
+ 'title': widget.player.currentEpisodeTitle,
+ 'duration': widget.player.totalDuration,
+ };
+ EpisodeDetailSheet.show(context, _item, episode);
+ } else {
+ showBookDetailSheet(context, _itemId);
+ }
+ },
+ );
+ case 'equalizer':
+ return CardWideButton(
+ icon: Icons.equalizer_rounded, label: 'Audio Enhancements',
+ accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ onTap: () => 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 CardWideButton(
+ icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,
+ label: castLabel, accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ onTap: () => _handleCastTap(context, accent),
+ );
+ },
+ );
+ case 'history':
+ return CardWideButton(
+ icon: Icons.history_rounded, label: 'Playback History',
+ accent: accent, isActive: _isActive, large: large,
+ onTap: () => _showHistory(context, accent, tt),
+ );
+ case 'remove':
+ return CardWideButton(
+ icon: Icons.remove_circle_outline_rounded, label: 'Remove from Absorbing',
+ accent: Colors.red.shade300, isActive: true, alwaysEnabled: true, large: large,
+ onTap: () { _removeFromAbsorbing(); _dismissExpanded(); },
+ );
+ 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: _isPlaybackActive,
+ onTap: () { Navigator.pop(ctx); _showChapters(context, accent, tt); },
+ );
+ case 'speed':
+ return MoreMenuItem(
+ icon: Icons.speed_rounded, label: 'Speed', accent: accent,
+ enabled: _isPlaybackActive,
+ 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: _isPlaybackActive,
+ 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, 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: () {
+ Navigator.pop(ctx);
+ if (_episodeId != null || _isPodcastEpisode) {
+ final episode = _recentEpisode ?? {
+ 'id': widget.player.currentEpisodeId,
+ 'title': widget.player.currentEpisodeTitle,
+ 'duration': widget.player.totalDuration,
+ };
+ EpisodeDetailSheet.show(context, _item, episode);
+ } else {
+ showBookDetailSheet(context, _itemId);
+ }
+ },
+ );
+ case 'equalizer':
+ return MoreMenuItem(
+ icon: Icons.equalizer_rounded, label: 'Audio Enhancements', 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: _isActive,
+ 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(); },
+ );
+ default:
+ return const SizedBox.shrink();
+ }
+ }
+
+ 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) {
@@ -1122,120 +1337,20 @@ class _ExpandedCardState extends State<ExpandedCard> {
}
void _showMoreMenu(BuildContext context, Color accent, TextTheme tt) {
+ final overflowIds = _buttonOrder.skip(4).toList();
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
- builder: (ctx) => 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: SafeArea(
- child: Padding(
- padding: const EdgeInsets.fromLTRB(16, 8, 16, 12),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(width: 40, height: 4, decoration: BoxDecoration(color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.24), borderRadius: BorderRadius.circular(2))),
- const SizedBox(height: 16),
- 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);
- if (_episodeId != null || _isPodcastEpisode) {
- final episode = _recentEpisode ?? {
- 'id': widget.player.currentEpisodeId,
- 'title': widget.player.currentEpisodeTitle,
- 'duration': widget.player.totalDuration,
- };
- EpisodeDetailSheet.show(context, _item, episode);
- } else {
- showBookDetailSheet(context, _itemId);
- }
- },
- ),
- const SizedBox(height: 6),
- MoreMenuItem(
- icon: Icons.equalizer_rounded,
- label: 'Audio Enhancements',
- accent: accent,
- onTap: () { Navigator.pop(ctx); showEqualizerSheet(context, accent); },
- ),
- const SizedBox(height: 6),
- 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: () {
- final auth = context.read<AuthProvider>();
- final api = auth.apiService;
- Navigator.pop(ctx);
- 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: (_) => const 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);
- }
- },
- );
- },
- ),
- const SizedBox(height: 6),
- MoreMenuItem(
- icon: Icons.history_rounded,
- label: 'Playback History',
- accent: accent,
- enabled: _isActive,
- onTap: () { Navigator.pop(ctx); _showHistory(context, accent, tt); },
- ),
- const SizedBox(height: 6),
- MoreMenuItem(
- icon: Icons.remove_circle_outline_rounded,
- label: 'Remove from Absorbing',
- accent: Colors.red.shade300,
- onTap: () {
- Navigator.pop(ctx);
- _removeFromAbsorbing();
- _dismissExpanded();
- },
- ),
- const SizedBox(height: 8),
- ],
- ),
- ),
- ),
+ isScrollControlled: true,
+ builder: (ctx) => MoreMenuSheet(
+ overflowIds: overflowIds,
+ allIds: _buttonOrder,
+ accent: accent,
+ buildItem: (id) => _buildMoreMenuItem(id, accent, tt, ctx),
+ onReorder: (newOrder) {
+ setState(() => _buttonOrder = newOrder);
+ PlayerSettings.setCardButtonOrder(newOrder);
+ },
),
);
}
diff --git a/lib/widgets/home_section.dart b/lib/widgets/home_section.dart
index a5ec7d36..625854ed 100644
--- a/lib/widgets/home_section.dart
+++ b/lib/widgets/home_section.dart
@@ -1,13 +1,11 @@
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;
@@ -226,7 +224,7 @@ class _EpisodeCard extends StatelessWidget {
final episode = item['recentEpisode'] as Map<String, dynamic>?;
final episodeTitle = episode?['title'] as String? ?? showTitle;
- return PressableCard(
+ return GestureDetector(
onTap: () {
if (episode != null) {
EpisodeDetailSheet.show(context, item, episode);
@@ -234,7 +232,6 @@ class _EpisodeCard extends StatelessWidget {
EpisodeListSheet.show(context, item);
}
},
- borderRadius: 12,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
@@ -260,14 +257,9 @@ class _EpisodeCard extends StatelessWidget {
color: cs.surfaceContainerHigh,
child: Icon(Icons.podcasts_rounded, size: 32,
color: cs.onSurfaceVariant.withValues(alpha: 0.3))))
- : 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(
+ : 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))))
diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dart
index 938419c3..61bcbd66 100644
--- a/lib/widgets/library_grid_tiles.dart
+++ b/lib/widgets/library_grid_tiles.dart
@@ -7,7 +7,6 @@ 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';
// ═══════════════════════════════════════════════════════════════
@@ -57,7 +56,7 @@ class _GridBookTileState extends State<GridBookTile> {
final isDownloaded = _dl.isDownloaded(itemId);
final isFinished = lib.getProgressData(itemId)?['isFinished'] == true;
- return PressableCard(
+ return GestureDetector(
onTap: () {
if (itemId.isNotEmpty) {
if (lib.isPodcastLibrary) {
@@ -67,7 +66,6 @@ class _GridBookTileState extends State<GridBookTile> {
}
}
},
- borderRadius: 10,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -88,7 +86,6 @@ class _GridBookTileState extends State<GridBookTile> {
imageUrl: coverUrl,
fit: BoxFit.cover,
httpHeaders: lib.mediaHeaders,
- fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) => _placeholder(cs),
errorWidget: (_, __, ___) => _placeholder(cs),
)
@@ -224,7 +221,7 @@ class GridSeriesTile extends StatelessWidget {
final author = metadata['authorName'] as String? ?? '';
final coverUrl = lib.getCoverUrl(itemId);
- return PressableCard(
+ return GestureDetector(
onTap: () {
if (seriesId.isNotEmpty) {
showSeriesBooksSheet(
@@ -237,7 +234,6 @@ class GridSeriesTile extends StatelessWidget {
);
}
},
- borderRadius: 10,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -257,7 +253,6 @@ 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 a9c2de04..25d9ea50 100644
--- a/lib/widgets/library_search_results.dart
+++ b/lib/widgets/library_search_results.dart
@@ -69,7 +69,6 @@ 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),
)
@@ -265,7 +264,6 @@ 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 6b24e175..394159f3 100644
--- a/lib/widgets/metadata_lookup_sheet.dart
+++ b/lib/widgets/metadata_lookup_sheet.dart
@@ -406,7 +406,6 @@ 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/series_books_sheet.dart b/lib/widgets/series_books_sheet.dart
index 83157e2f..58248c9c 100644
--- a/lib/widgets/series_books_sheet.dart
+++ b/lib/widgets/series_books_sheet.dart
@@ -322,7 +322,6 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
imageUrl: coverUrl,
fit: BoxFit.cover,
httpHeaders: context.read<LibraryProvider>().mediaHeaders,
- fadeInDuration: const Duration(milliseconds: 300),
placeholder: (_, __) =>
_placeholder(cs),
errorWidget: (_, __, ___) =>