Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Redesign absorbing card layout, cover play/pause toggle, remove finished overlay

Nathan Poulson465ae0ab7712
diff --git a/lib/screens/absorbing_screen.dart b/lib/screens/absorbing_screen.dart
index 4ae7046f..0128e4d0 100644
--- a/lib/screens/absorbing_screen.dart
+++ b/lib/screens/absorbing_screen.dart
@@ -573,7 +573,7 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
: books.length == 1
? LayoutBuilder(
builder: (context, constraints) {
- final vPad = (constraints.maxHeight * 0.04).clamp(12.0, 40.0);
+ final vPad = (constraints.maxHeight * 0.02).clamp(6.0, 24.0);
return Padding(
padding: EdgeInsets.symmetric(horizontal: 4, vertical: vPad),
child: RepaintBoundary(child: AbsorbingCard(key: ValueKey(_absorbingKey(books[0])), item: books[0], player: _player)),
@@ -589,7 +589,7 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
itemBuilder: (_, i) => LayoutBuilder(
builder: (context, constraints) {
final cardWidth = constraints.maxWidth;
- final vPad = (constraints.maxHeight * 0.04).clamp(12.0, 40.0);
+ final vPad = (constraints.maxHeight * 0.02).clamp(6.0, 24.0);
return AnimatedBuilder(
animation: _pageController,
builder: (context, child) {
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 64b36973..a379b0e3 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -61,7 +61,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
bool _queueAutoDownload = false;
bool _mergeAbsorbingLibraries = false;
int _maxConcurrentDownloads = 1;
- String _whenFinished = 'overlay';
bool _hideEbookOnly = false;
bool _showGoodreadsButton = false;
bool _loggingEnabled = false;
@@ -69,6 +68,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
String _cardButtonLayout = 'standard';
bool _snappyTransitions = false;
bool _rectangleCovers = false;
+ bool _coverPlayButton = false;
String _themeMode = 'dark';
String _colorSource = 'wallpaper';
int _startScreen = 2;
@@ -142,17 +142,16 @@ class _SettingsScreenState extends State<SettingsScreen> {
PlayerSettings.getQueueAutoDownload(), // 15
PlayerSettings.getMergeAbsorbingLibraries(), // 16
PlayerSettings.getMaxConcurrentDownloads(), // 17
- PlayerSettings.getWhenFinished(), // 18
- PlayerSettings.getHideEbookOnly(), // 19
- PlayerSettings.getShowGoodreadsButton(), // 20
- PlayerSettings.getLoggingEnabled(), // 21
- PlayerSettings.getFullScreenPlayer(), // 22
- PlayerSettings.getThemeMode(), // 23
- PlayerSettings.getSnappyTransitions(), // 24
- DownloadService().downloadLocationLabel, // 25
- DownloadService().totalDownloadSize, // 26
- DownloadService.getDeviceStorage(), // 27
- AutoSleepSettings.load(), // 28
+ PlayerSettings.getHideEbookOnly(), // 18
+ PlayerSettings.getShowGoodreadsButton(), // 19
+ PlayerSettings.getLoggingEnabled(), // 20
+ PlayerSettings.getFullScreenPlayer(), // 21
+ PlayerSettings.getThemeMode(), // 22
+ PlayerSettings.getSnappyTransitions(), // 23
+ DownloadService().downloadLocationLabel, // 24
+ DownloadService().totalDownloadSize, // 25
+ DownloadService.getDeviceStorage(), // 26
+ AutoSleepSettings.load(), // 27
PackageInfo.fromPlatform(), // 29
PlayerSettings.getStreamingCacheSizeMb(), // 30
PlayerSettings.getLocalServerEnabled(), // 31
@@ -165,6 +164,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
PlayerSettings.getCardButtonLayout(), // 38
PlayerSettings.getRectangleCovers(), // 39
PlayerSettings.getTrustAllCerts(), // 40
+ PlayerSettings.getCoverPlayButton(), // 41
]);
final s = results[0] as AutoRewindSettings;
final speed = results[1] as double;
@@ -184,29 +184,29 @@ class _SettingsScreenState extends State<SettingsScreen> {
final queueAutoDl = results[15] as bool;
final mergeLibs = results[16] as bool;
final maxConc = results[17] as int;
- final whenFinished = results[18] as String;
- final hideEbook = results[19] as bool;
- final showGoodreads = results[20] as bool;
- final logging = results[21] as bool;
- final fullScreen = results[22] as bool;
- final theme = results[23] as String;
- final snappyTrans = results[24] as bool;
- final dlLabel = results[25] as String;
- final dlSize = results[26] as int;
- final deviceStorage = results[27] as Map<String, int>?;
- final autoSleep = results[28] as AutoSleepSettings;
- final pkgInfo = results[29] as PackageInfo;
- final cacheSizeMb = results[30] as int;
- final localEnabled = results[31] as bool;
- final localUrl = results[32] as String;
- final audioFocusOff = results[33] as bool;
- final autoDlStream = results[34] as bool;
- final colorSource = results[35] as String;
- final startScreen = results[36] as int;
- final podcastQueueMode = results[37] as String;
- final cardBtnLayout = results[38] as String;
- final rectCovers = results[39] as bool;
- final trustCerts = results[40] as bool;
+ final hideEbook = results[18] as bool;
+ final showGoodreads = results[19] as bool;
+ final logging = results[20] as bool;
+ final fullScreen = results[21] as bool;
+ final theme = results[22] as String;
+ final snappyTrans = results[23] as bool;
+ final dlLabel = results[24] as String;
+ final dlSize = results[25] as int;
+ final deviceStorage = results[26] as Map<String, int>?;
+ final autoSleep = results[27] as AutoSleepSettings;
+ final pkgInfo = results[28] as PackageInfo;
+ final cacheSizeMb = results[29] as int;
+ final localEnabled = results[30] as bool;
+ final localUrl = results[31] as String;
+ final audioFocusOff = results[32] as bool;
+ final autoDlStream = results[33] as bool;
+ final colorSource = results[34] as String;
+ final startScreen = results[35] as int;
+ final podcastQueueMode = results[36] as String;
+ final cardBtnLayout = results[37] as String;
+ final rectCovers = results[38] as bool;
+ final trustCerts = results[39] as bool;
+ final coverPlay = results[40] as bool;
if (mounted) setState(() {
_rewindSettings = s;
_defaultSpeed = speed;
@@ -228,7 +228,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
_queueAutoDownload = queueAutoDl;
_mergeAbsorbingLibraries = mergeLibs;
_maxConcurrentDownloads = maxConc;
- _whenFinished = whenFinished;
_hideEbookOnly = hideEbook;
_showGoodreadsButton = showGoodreads;
_loggingEnabled = logging;
@@ -252,6 +251,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_startScreen = startScreen;
_cardButtonLayout = cardBtnLayout;
_rectangleCovers = rectCovers;
+ _coverPlayButton = coverPlay;
_trustAllCerts = trustCerts;
_loaded = true;
});
@@ -312,9 +312,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
desc: 'Long-press the bookmark button on any card to instantly drop a bookmark at your current position without opening the bookmark sheet.',
),
_tipCard(cs, tt,
- icon: Icons.fullscreen_rounded,
- title: 'Full Screen Player',
- desc: 'Tap the cover art on the active card to open a full screen player view. Tap the cover again to dismiss it. You can also enable "Full screen player" in Settings to auto-open it whenever playback starts.',
+ icon: Icons.touch_app_rounded,
+ title: 'Cover Play/Pause',
+ desc: 'Tap the cover art on any card to play or pause. A faint pause icon shows when playing so you know it\'s tappable. Use the expand icon in the top-right corner to open the full screen player.',
),
_tipCard(cs, tt,
icon: Icons.edit_note_rounded,
@@ -725,7 +725,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
SwitchListTile(
title: const Text('Full screen player'),
subtitle: Text(
- _fullScreenPlayer ? 'On — books open in full screen when played' : 'Off — play within card view',
+ _fullScreenPlayer ? 'On - books open in full screen when played' : 'Off - play within card view',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _fullScreenPlayer,
onChanged: _loaded ? (v) {
@@ -734,10 +734,22 @@ class _SettingsScreenState extends State<SettingsScreen> {
} : null,
),
const Divider(height: 1, indent: 16, endIndent: 16),
+ SwitchListTile(
+ title: const Text('Cover play/pause'),
+ subtitle: Text(
+ _coverPlayButton ? 'On - tap cover art to play/pause' : 'Off - dedicated play/pause button in controls',
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ value: _coverPlayButton,
+ onChanged: _loaded ? (v) {
+ setState(() => _coverPlayButton = v);
+ PlayerSettings.setCoverPlayButton(v);
+ } : null,
+ ),
+ const Divider(height: 1, indent: 16, endIndent: 16),
SwitchListTile(
title: const Text('Full book scrubber'),
subtitle: Text(
- _showBookSlider ? 'On — seekable slider across entire book' : 'Off — progress bar only',
+ _showBookSlider ? 'On - seekable slider across entire book' : 'Off - progress bar only',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _showBookSlider,
onChanged: _loaded ? (v) {
@@ -749,7 +761,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
SwitchListTile(
title: const Text('Speed-adjusted time'),
subtitle: Text(
- _speedAdjustedTime ? 'On — remaining time reflects playback speed' : 'Off — showing raw audio duration',
+ _speedAdjustedTime ? 'On - remaining time reflects playback speed' : 'Off - showing raw audio duration',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _speedAdjustedTime,
onChanged: _loaded ? (v) {
@@ -789,31 +801,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
]),
),
const Divider(height: 1, indent: 16, endIndent: 16),
- Padding(
- padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
- child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
- Row(children: [
- Text('When absorbed', style: tt.bodyMedium?.copyWith(color: cs.onSurface)),
- _infoIcon('When Absorbed', 'Controls what happens to an absorbing card when you finish a book or episode.\n\nShow Overlay: A completion overlay appears on the card, letting you choose what to do next.\n\nAuto-release: The finished card is automatically removed from your Absorbing screen.'),
- ]),
- const SizedBox(height: 4),
- Text('What happens to the absorbing card when a book or episode finishes',
- style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
- const SizedBox(height: 8),
- SizedBox(width: double.infinity, child: SegmentedButton<String>(
- segments: const [
- ButtonSegment(value: 'overlay', icon: Icon(Icons.layers_rounded), label: Text('Show Overlay')),
- ButtonSegment(value: 'auto_remove', icon: Icon(Icons.auto_delete_rounded), label: Text('Auto-release')),
- ],
- selected: {_whenFinished},
- onSelectionChanged: _loaded ? (s) {
- setState(() => _whenFinished = s.first);
- PlayerSettings.setWhenFinished(s.first);
- } : null,
- style: const ButtonStyle(visualDensity: VisualDensity.compact),
- )),
- ]),
- ),
SwitchListTile(
title: Row(children: [
const Text('Merge libraries'),
@@ -931,7 +918,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
subtitle: Text(
_queueAutoDownload
? 'Keep next $_rollingDownloadCount items downloaded'
- : 'Off — manual downloads only',
+ : 'Off - manual downloads only',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _queueAutoDownload,
onChanged: _loaded ? (v) {
@@ -972,7 +959,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
- child: Text('New books start at this speed — each book remembers its own',
+ child: Text('New books start at this speed - each book remembers its own',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant, fontSize: 11)),
),
AbsorbSlider(
@@ -1052,7 +1039,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
SwitchListTile(
title: const Text('Chapter progress in notification'),
subtitle: Text(
- _notifChapterProgress ? 'On — lockscreen shows chapter progress' : 'Off — lockscreen shows full book progress',
+ _notifChapterProgress ? 'On - lockscreen shows chapter progress' : 'Off - lockscreen shows full book progress',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _notifChapterProgress,
onChanged: _loaded ? (v) {
@@ -1066,7 +1053,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
title: const Text('Auto-rewind on resume'),
subtitle: Text(
_rewindSettings.enabled
- ? 'On — ${_rewindSettings.minRewind.round()}s to ${_rewindSettings.maxRewind.round()}s based on pause length'
+ ? 'On -${_rewindSettings.minRewind.round()}s to ${_rewindSettings.maxRewind.round()}s based on pause length'
: 'Off',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _rewindSettings.enabled,
@@ -1377,7 +1364,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
SwitchListTile(
title: const Text('Download over Wi-Fi only'),
subtitle: Text(
- _wifiOnlyDownloads ? 'On — mobile data blocked for downloads' : 'Off — downloads on any connection',
+ _wifiOnlyDownloads ? 'On - mobile data blocked for downloads' : 'Off - downloads on any connection',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _wifiOnlyDownloads,
onChanged: _loaded ? (v) {
@@ -1472,7 +1459,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
subtitle: Text(
_rollingDownloadDeleteFinished
? 'Finished items are removed to save space'
- : 'Off — finished downloads kept',
+ : 'Off - finished downloads kept',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _rollingDownloadDeleteFinished,
onChanged: _loaded ? (v) {
@@ -1529,8 +1516,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
const SizedBox(height: 4),
Text(
_streamingCacheSizeMb == 0
- ? 'Off — audio is streamed without caching'
- : '$_streamingCacheSizeMb MB — recently streamed audio is cached to disk',
+ ? 'Off - audio is streamed without caching'
+ : '$_streamingCacheSizeMb MB - recently streamed audio is cached to disk',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
const SizedBox(height: 8),
SizedBox(width: double.infinity, child: SegmentedButton<int>(
@@ -1582,7 +1569,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
subtitle: Text(
_hideEbookOnly
? 'Books with no audio files are hidden'
- : 'Off — all library items shown',
+ : 'Off - all library items shown',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _hideEbookOnly,
onChanged: _loaded ? (v) {
@@ -1596,7 +1583,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
subtitle: Text(
_showGoodreadsButton
? 'Book detail sheet shows a link to Goodreads'
- : 'Off — Goodreads button hidden',
+ : 'Off - Goodreads button hidden',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _showGoodreadsButton,
onChanged: _loaded ? (v) {
@@ -1738,8 +1725,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
title: const Text('Enable logging'),
subtitle: Text(
_loggingEnabled
- ? 'On — logs saved to file (restart to apply)'
- : 'Off — no logs captured',
+ ? 'On - logs saved to file (restart to apply)'
+ : 'Off - no logs captured',
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
value: _loggingEnabled,
onChanged: _loaded ? (v) {
@@ -1747,8 +1734,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
PlayerSettings.setLoggingEnabled(v);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(v
- ? 'Logging enabled — restart app to start capturing'
- : 'Logging disabled — restart app to stop capturing'),
+ ? 'Logging enabled - restart app to start capturing'
+ : 'Logging disabled - restart app to stop capturing'),
));
} : null,
),
@@ -2101,7 +2088,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
}),
const SizedBox(height: 6),
],
- // Add Account button — always visible
+ // Add Account button - always visible
Material(
color: cs.surfaceContainerHigh,
borderRadius: BorderRadius.circular(14),
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index bdb531a5..3f52c7a0 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -281,6 +281,9 @@ class PlayerSettings {
static Future<bool> getRectangleCovers() => _get('rectangleCovers', false);
static Future<void> setRectangleCovers(bool value) => _set('rectangleCovers', value, notify: true);
+ static Future<bool> getCoverPlayButton() => _get('coverPlayButton', false);
+ static Future<void> setCoverPlayButton(bool value) => _set('coverPlayButton', value, notify: true);
+
// ── Audio focus ──
static Future<bool> getDisableAudioFocus() => _get('disableAudioFocus', false);
@@ -1091,6 +1094,10 @@ class AudioPlayerService extends ChangeNotifier {
}
bool get hasBook => _currentItemId != null;
bool get isPlaying => _player?.playing ?? false;
+ bool get isLoadingOrBuffering {
+ final s = _player?.processingState;
+ return s == ProcessingState.loading || s == ProcessingState.buffering;
+ }
bool get isOfflineMode => _isOfflineMode;
double get volume => _player?.volume ?? 1.0;
Future<void> setVolume(double v) async => _player?.setVolume(v);
diff --git a/lib/services/backup_service.dart b/lib/services/backup_service.dart
index 4eeab79d..88c4f02a 100644
--- a/lib/services/backup_service.dart
+++ b/lib/services/backup_service.dart
@@ -23,7 +23,6 @@ class BackupService {
// Legacy keys for backward compat with older app versions
'autoPlayNextBook': (await PlayerSettings.getQueueMode()) == 'auto_next',
'autoPlayNextPodcast': (await PlayerSettings.getQueueMode()) == 'auto_next',
- 'whenFinished': await PlayerSettings.getWhenFinished(),
'showBookSlider': await PlayerSettings.getShowBookSlider(),
'speedAdjustedTime': await PlayerSettings.getSpeedAdjustedTime(),
'forwardSkip': await PlayerSettings.getForwardSkip(),
@@ -69,6 +68,7 @@ class BackupService {
'startScreen': await PlayerSettings.getStartScreen(),
'cardButtonLayout': await PlayerSettings.getCardButtonLayout(),
'rectangleCovers': await PlayerSettings.getRectangleCovers(),
+ 'coverPlayButton': await PlayerSettings.getCoverPlayButton(),
};
// AutoRewind (scoped)
@@ -251,6 +251,7 @@ class BackupService {
if (s['startScreen'] != null) PlayerSettings.setStartScreen(s['startScreen'] as int);
if (s['cardButtonLayout'] != null) PlayerSettings.setCardButtonLayout(s['cardButtonLayout'] as String);
if (s['rectangleCovers'] != null) PlayerSettings.setRectangleCovers(s['rectangleCovers'] as bool);
+ if (s['coverPlayButton'] != null) PlayerSettings.setCoverPlayButton(s['coverPlayButton'] as bool);
// AutoRewind (scoped via save())
final r = data['autoRewind'] as Map<String, dynamic>?;
diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dart
index 22a4de87..49901734 100644
--- a/lib/widgets/absorbing_card.dart
+++ b/lib/widgets/absorbing_card.dart
@@ -19,7 +19,6 @@ import 'card_buttons.dart';
import 'sleep_timer_sheet.dart';
import 'chromecast_button.dart';
import '../services/chromecast_service.dart';
-import '../services/progress_sync_service.dart';
import 'expanded_card.dart';
import '../screens/car_mode_screen.dart';
import 'notes_sheet.dart';
@@ -45,8 +44,8 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
String? _blurredCoverUrl; // URL the blur was built from
List<String> _buttonOrder = PlayerSettings.defaultButtonOrder;
String _buttonLayout = PlayerSettings.defaultButtonLayout;
- bool _autoRemoveFinished = false;
bool _rectangleCovers = false;
+ bool _coverPlayButton = false;
@override
bool get wantKeepAlive => true;
@@ -121,13 +120,6 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
DownloadService().addListener(_onDownloadChanged);
PlayerSettings.settingsChanged.addListener(_reloadButtonOrder);
_reloadButtonOrder();
- _loadWhenFinished();
- }
-
- void _loadWhenFinished() {
- PlayerSettings.getWhenFinished().then((mode) {
- if (mounted) setState(() => _autoRemoveFinished = mode == 'auto_remove');
- });
}
void _reloadButtonOrder() {
@@ -140,6 +132,9 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
PlayerSettings.getRectangleCovers().then((v) {
if (mounted && v != _rectangleCovers) setState(() => _rectangleCovers = v);
});
+ PlayerSettings.getCoverPlayButton().then((v) {
+ if (mounted && v != _coverPlayButton) setState(() => _coverPlayButton = v);
+ });
}
void _onDownloadChanged() { if (mounted) setState(() {}); }
@@ -355,14 +350,6 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
: (_isPodcastEpisode
? lib.getEpisodeProgress(_itemId, widget.player.currentEpisodeId!)
: lib.getProgress(_itemId));
- final bool isFinished;
- if (_episodeId != null) {
- isFinished = lib.getEpisodeProgressData(_itemId, _episodeId!)?['isFinished'] == true;
- } else if (_isPodcastEpisode) {
- isFinished = lib.getEpisodeProgressData(_itemId, widget.player.currentEpisodeId!)?['isFinished'] == true;
- } else {
- isFinished = lib.getProgressData(_itemId)?['isFinished'] == true;
- }
final chapterIdx = _currentChapterIndex();
final cast = ChromecastService();
final totalChapters = _isCastingThis ? cast.castingChapters.length : (_isActive ? widget.player.chapters.length : _chapters.length);
@@ -483,6 +470,15 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
fontWeight: FontWeight.w700, fontSize: compact ? 11 : 14,
shadows: [Shadow(color: isDark ? Colors.black.withValues(alpha: 0.6) : Colors.white.withValues(alpha: 0.6), blurRadius: 4)],
)),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _expandCard(context),
+ child: Padding(
+ padding: const EdgeInsets.all(8),
+ child: Icon(Icons.open_in_full_rounded, size: compact ? 14 : 17,
+ color: isDark ? Colors.white.withValues(alpha: 0.6) : Colors.black.withValues(alpha: 0.5)),
+ ),
+ ),
],
),
),
@@ -491,16 +487,17 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
padding: const EdgeInsets.symmetric(horizontal: 20),
child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: progress, staticDuration: _effectiveDuration, chapters: _chapters, showBookBar: (!_isPodcastEpisode || _chapters.isNotEmpty) && (!lib.isPodcastLibrary || _chapters.isNotEmpty), showChapterBar: false, itemId: _itemId, compact: compact),
),
- SizedBox(height: compact ? 4 : 10),
+ SizedBox(height: compact ? 2 : 6),
// ── Cover with title/author/chapter overlaid + download badge ──
- Flexible(
+ Expanded(
+ child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: ListenableBuilder(
listenable: ChromecastService(),
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
- final maxW = constraints.maxWidth * 0.85;
+ final maxW = constraints.maxWidth * 0.96;
final maxH = constraints.maxHeight;
double coverW, coverH;
if (_rectangleCovers) {
@@ -516,8 +513,18 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
final isDownloaded = DownloadService().isDownloaded(dlKey);
final castService = ChromecastService();
final isCastingThis = castService.isCasting && castService.castingItemId == _itemId;
+ final coverPlaying = isCastingThis ? castService.isPlaying : (_isActive && widget.player.isPlaying);
+ final coverLoading = _isStarting || (_isActive && widget.player.isLoadingOrBuffering);
return GestureDetector(
- onTap: () => _expandCard(context),
+ onTap: _coverPlayButton ? () {
+ if (isCastingThis) {
+ castService.togglePlayPause();
+ } else if (_isActive) {
+ widget.player.togglePlayPause();
+ } else {
+ _startPlayback();
+ }
+ } : () => _expandCard(context),
child: Container(
width: coverW,
height: coverH,
@@ -596,91 +603,44 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
),
),
],
- // Finished overlay
- if (isFinished && !_autoRemoveFinished) ...[
- Positioned.fill(
- child: Container(
- color: Colors.black.withValues(alpha: 0.78),
+ // Play/pause overlay
+ if (_coverPlayButton) Positioned.fill(
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 200),
+ decoration: BoxDecoration(
+ color: coverPlaying ? Colors.transparent : Colors.black.withValues(alpha: 0.25),
),
- ),
- Positioned.fill(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 14),
- child: LayoutBuilder(
- builder: (ctx, lc) => FittedBox(
- fit: BoxFit.scaleDown,
- child: SizedBox(
- width: lc.maxWidth,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(Icons.check_circle_rounded, size: 32, color: isDark ? Colors.green.shade400 : Colors.green.shade700),
- const SizedBox(height: 6),
- const Text('Finished',
- style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w700)),
- const SizedBox(height: 18),
- SizedBox(
- width: lc.maxWidth,
- child: GestureDetector(
- onTap: _listenAgain,
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 9),
- decoration: BoxDecoration(
- color: Colors.white.withValues(alpha: 0.18),
- borderRadius: BorderRadius.circular(11),
- border: Border.all(color: Colors.white.withValues(alpha: 0.25)),
- ),
- child: const Text('Listen Again',
- textAlign: TextAlign.center,
- style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w600)),
- ),
- ),
+ child: Center(
+ child: coverLoading
+ ? Container(
+ width: 56, height: 56,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: Colors.black.withValues(alpha: 0.5),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(12),
+ child: CircularProgressIndicator(strokeWidth: 3, color: accent),
+ ),
+ )
+ : AnimatedOpacity(
+ opacity: coverPlaying ? 0.2 : 0.9,
+ duration: const Duration(milliseconds: 200),
+ child: Container(
+ width: 64, height: 64,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: Colors.black.withValues(alpha: 0.45),
),
- const SizedBox(height: 8),
- if (isDownloaded)
- Padding(
- padding: const EdgeInsets.only(bottom: 8),
- child: SizedBox(
- width: lc.maxWidth,
- child: GestureDetector(
- onTap: () => _deleteDownload(dlKey),
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 9),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(11),
- border: Border.all(color: Colors.white.withValues(alpha: 0.18)),
- ),
- child: const Text('Delete Download',
- textAlign: TextAlign.center,
- style: TextStyle(color: Colors.white70, fontSize: 12, fontWeight: FontWeight.w500)),
- ),
- ),
- ),
- ),
- SizedBox(
- width: lc.maxWidth,
- child: GestureDetector(
- onTap: _removeFromAbsorbing,
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 9),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(11),
- border: Border.all(color: Colors.white.withValues(alpha: 0.18)),
- ),
- child: const Text('Remove from Absorbing',
- textAlign: TextAlign.center,
- style: TextStyle(color: Colors.white70, fontSize: 12, fontWeight: FontWeight.w500)),
- ),
- ),
+ child: Icon(
+ coverPlaying ? Icons.pause_rounded : Icons.play_arrow_rounded,
+ size: 38, color: accent,
),
- ],
+ ),
),
- ),
- ),
- ),
),
),
- ],
+ ),
],
),
),
@@ -692,38 +652,40 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
),
),
),
- SizedBox(height: compact ? 6 : 16),
- // ── Chapter pill-scrubber (same width as book bar) ──
+ ),
+ SizedBox(height: compact ? 8 : 16),
+ // ── Chapter pill-scrubber ──
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: (_isPodcastEpisode && _chapters.isEmpty) ? 0.0 : progress, staticDuration: (_isPodcastEpisode && _chapters.isEmpty) ? widget.player.totalDuration : _effectiveDuration, chapters: _chapters, showBookBar: false, showChapterBar: true, chapterName: (_isPodcastEpisode && _chapters.isEmpty) ? (widget.player.currentEpisodeTitle ?? widget.player.currentTitle ?? _title) : (_episodeId != null && !_isActive ? (_recentEpisode?['title'] as String? ?? _title) : _chapterName(chapterIdx)), chapterIndex: chapterIdx, totalChapters: totalChapters, itemId: _itemId, compact: compact),
),
- // ── Controls + buttons ──
- Expanded(
- child: LayoutBuilder(
- builder: (context, lc) {
- return FittedBox(
+ // ── Controls ──
+ SizedBox(height: compact ? 6 : 12),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: CardPlaybackControls(
+ player: widget.player,
+ accent: accent,
+ isActive: _isActive,
+ isStarting: _isStarting,
+ onStart: _startPlayback,
+ itemId: _itemId,
+ showPlayButton: !_coverPlayButton,
+ ),
+ ),
+ SizedBox(height: compact ? 6 : 12),
+ // ── Button grid + more menu ──
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: FittedBox(
fit: BoxFit.scaleDown,
- alignment: Alignment.center,
child: SizedBox(
- width: lc.maxWidth - 40,
+ width: cardConstraints.maxWidth - 40,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- SizedBox(height: compact ? 10 : 18),
- CardPlaybackControls(
- player: widget.player,
- accent: accent,
- isActive: _isActive,
- isStarting: _isStarting,
- onStart: _startPlayback,
- itemId: _itemId,
- ),
- SizedBox(height: compact ? 10 : 18),
- // ── Button grid ──
..._buildButtonGrid(accent, tt),
const SizedBox(height: 6),
- // More menu / Cast controls
Center(
child: ListenableBuilder(
listenable: ChromecastService(),
@@ -766,12 +728,11 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
},
),
),
- const SizedBox(height: 4),
+ SizedBox(height: compact ? 4 : 8),
],
),
),
- );
- }),
+ ),
),
],
);
@@ -881,52 +842,6 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
}
}
- Future<void> _listenAgain() async {
- if (_isStarting) return;
- final cast = ChromecastService();
- if (cast.isCasting && cast.castingItemId == _itemId) return;
- setState(() => _isStarting = true);
- final auth = context.read<AuthProvider>();
- final api = auth.apiService;
- if (api == null) { setState(() => _isStarting = false); return; }
- final lib = context.read<LibraryProvider>();
- final progressKey = _episodeId != null ? '$_itemId-$_episodeId' : _itemId;
- if (_episodeId != null) {
- await api.updateEpisodeProgress(_itemId, _episodeId!,
- currentTime: 0, duration: _effectiveDuration, isFinished: false);
- } else {
- await api.resetProgress(_itemId, _duration);
- }
- lib.resetProgressFor(progressKey);
- // Clear the locally saved position so playItem() doesn't override startTime
- // back to the end (where it was saved on completion)
- await ProgressSyncService().deleteLocal(progressKey);
- final error = await widget.player.playItem(
- api: api, itemId: _itemId, title: _title, author: _author,
- coverUrl: _coverUrl, totalDuration: _episodeId != null ? _effectiveDuration : _duration,
- chapters: _chapters,
- episodeId: _episodeId,
- episodeTitle: _recentEpisode?['title'] as String?,
- );
- if (mounted) {
- if (error != null) showErrorSnackBar(context, error);
- setState(() => _isStarting = false);
- }
- }
-
- void _deleteDownload(String dlKey) {
- DownloadService().deleteDownload(dlKey);
- if (mounted) {
- ScaffoldMessenger.of(context)
- ..clearSnackBars()
- ..showSnackBar(const SnackBar(
- content: Text('Download removed'),
- duration: Duration(seconds: 2),
- behavior: SnackBarBehavior.floating,
- ));
- }
- }
-
Future<void> _removeFromAbsorbing() async {
if (widget.player.currentItemId == _itemId) {
await widget.player.pause();
diff --git a/lib/widgets/card_playback_controls.dart b/lib/widgets/card_playback_controls.dart
index 70f15280..f5fef00e 100644
--- a/lib/widgets/card_playback_controls.dart
+++ b/lib/widgets/card_playback_controls.dart
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
-import 'package:just_audio/just_audio.dart' hide PlaybackEvent;
import '../services/audio_player_service.dart';
import '../services/chromecast_service.dart';
@@ -12,30 +11,21 @@ class CardPlaybackControls extends StatefulWidget {
final bool isStarting;
final VoidCallback onStart;
final String? itemId;
- const CardPlaybackControls({super.key, required this.player, required this.accent, required this.isActive, required this.isStarting, required this.onStart, this.itemId});
+ final bool showPlayButton;
+ const CardPlaybackControls({super.key, required this.player, required this.accent, required this.isActive, required this.isStarting, required this.onStart, this.itemId, this.showPlayButton = false});
@override State<CardPlaybackControls> createState() => _CardPlaybackControlsState();
}
-class _CardPlaybackControlsState extends State<CardPlaybackControls> with SingleTickerProviderStateMixin {
+class _CardPlaybackControlsState extends State<CardPlaybackControls> {
int _backSkip = 10;
int _forwardSkip = 30;
- late AnimationController _playPauseController;
@override void initState() {
super.initState();
- _playPauseController = AnimationController(
- vsync: this,
- duration: const Duration(milliseconds: 300),
- value: 0, // 0 = play icon, 1 = pause icon
- );
_loadSkipSettings();
PlayerSettings.settingsChanged.addListener(_loadSkipSettings);
}
- @override void didUpdateWidget(covariant CardPlaybackControls old) {
- super.didUpdateWidget(old);
- }
-
void _loadSkipSettings() {
PlayerSettings.getBackSkip().then((v) { if (mounted && v != _backSkip) setState(() => _backSkip = v); });
PlayerSettings.getForwardSkip().then((v) { if (mounted && v != _forwardSkip) setState(() => _forwardSkip = v); });
@@ -43,7 +33,6 @@ class _CardPlaybackControlsState extends State<CardPlaybackControls> with Single
@override void dispose() {
PlayerSettings.settingsChanged.removeListener(_loadSkipSettings);
- _playPauseController.dispose();
super.dispose();
}
@@ -54,32 +43,16 @@ class _CardPlaybackControlsState extends State<CardPlaybackControls> with Single
IconData icon;
if (isForward) { icon = seconds == 5 ? Icons.forward_5_rounded : seconds == 10 ? Icons.forward_10_rounded : Icons.forward_30_rounded; }
else { icon = seconds == 5 ? Icons.replay_5_rounded : seconds == 10 ? Icons.replay_10_rounded : Icons.replay_30_rounded; }
- return Icon(icon, size: 38, color: active ? cs.onSurface.withValues(alpha: 0.7) : cs.onSurface.withValues(alpha: 0.24));
+ return Icon(icon, size: 42, color: active ? cs.onSurface.withValues(alpha: 0.7) : cs.onSurface.withValues(alpha: 0.24));
}
return Stack(alignment: Alignment.center, children: [
- Icon(isForward ? Icons.rotate_right_rounded : Icons.rotate_left_rounded, size: 38, color: active ? cs.onSurface.withValues(alpha: 0.7) : cs.onSurface.withValues(alpha: 0.24)),
+ Icon(isForward ? Icons.rotate_right_rounded : Icons.rotate_left_rounded, size: 42, color: active ? cs.onSurface.withValues(alpha: 0.7) : cs.onSurface.withValues(alpha: 0.24)),
Padding(padding: const EdgeInsets.only(top: 2), child: Text('$seconds', style: TextStyle(fontSize: 10, fontWeight: FontWeight.w900, color: active ? cs.onSurface : cs.onSurface.withValues(alpha: 0.24)))),
]);
}
@override
Widget build(BuildContext context) {
- final cs = Theme.of(context).colorScheme;
- if (widget.isStarting) {
- return SizedBox(height: 64,
- child: Center(child: SizedBox(width: 64, height: 64,
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: cs.onSurface,
- boxShadow: [BoxShadow(color: widget.accent.withValues(alpha: 0.4), blurRadius: 25, spreadRadius: -5)],
- ),
- child: Center(child: SizedBox(width: 28, height: 28, child: CircularProgressIndicator(strokeWidth: 2, color: widget.accent))),
- ),
- )),
- );
- }
-
final cast = ChromecastService();
return ListenableBuilder(
@@ -98,158 +71,87 @@ class _CardPlaybackControlsState extends State<CardPlaybackControls> with Single
);
}
+ Widget _playPauseButton(ColorScheme cs, {required bool playing, required bool loading, required VoidCallback? onTap}) {
+ return GestureDetector(
+ onTap: onTap,
+ child: Container(
+ width: 56, height: 56,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: cs.onSurface,
+ boxShadow: [BoxShadow(color: widget.accent.withValues(alpha: 0.4), blurRadius: 25, spreadRadius: -5)],
+ ),
+ child: loading
+ ? Center(child: SizedBox(width: 24, height: 24, child: CircularProgressIndicator(strokeWidth: 2, color: widget.accent)))
+ : Icon(playing ? Icons.pause_rounded : Icons.play_arrow_rounded, size: 30, color: cs.surface),
+ ),
+ );
+ }
+
/// Controls that route to ChromecastService
Widget _buildCastControls(ChromecastService cast) {
final cs = Theme.of(context).colorScheme;
- final isPlaying = cast.isPlaying;
-
- if (isPlaying) {
- _playPauseController.forward();
- } else {
- _playPauseController.reverse();
- }
- return FittedBox(
- fit: BoxFit.scaleDown,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
+ return Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: cast.skipToPreviousChapter,
- child: SizedBox(width: 40, height: 40, child: Center(
- child: Icon(Icons.skip_previous_rounded, size: 24, color: cs.onSurfaceVariant),
+ child: SizedBox(width: 52, height: 52, child: Center(
+ child: Icon(Icons.skip_previous_rounded, size: 34, color: cs.onSurfaceVariant),
)),
),
- const SizedBox(width: 4),
GestureDetector(
onTap: () => cast.skipBackward(_backSkip),
- child: SizedBox(width: 52, height: 52, child: Center(child: _skipIcon(_backSkip, false))),
+ child: SizedBox(width: 60, height: 60, child: Center(child: _skipIcon(_backSkip, false))),
),
- const SizedBox(width: 16),
- GestureDetector(
- onTap: cast.togglePlayPause,
- child: SizedBox(
- width: 80, height: 80,
- child: Stack(
- alignment: Alignment.center,
- children: [
- Container(
- width: 64, height: 64,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: cs.onSurface,
- boxShadow: [BoxShadow(color: widget.accent.withValues(alpha: 0.4), blurRadius: 25, spreadRadius: -5)],
- ),
- child: Center(
- child: AnimatedIcon(
- icon: AnimatedIcons.play_pause,
- progress: _playPauseController,
- size: 34,
- color: cs.surface,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- const SizedBox(width: 16),
+ if (widget.showPlayButton)
+ _playPauseButton(cs, playing: cast.isPlaying, loading: false, onTap: cast.togglePlayPause),
GestureDetector(
onTap: () => cast.skipForward(_forwardSkip),
- child: SizedBox(width: 52, height: 52, child: Center(child: _skipIcon(_forwardSkip, true))),
+ child: SizedBox(width: 60, height: 60, child: Center(child: _skipIcon(_forwardSkip, true))),
),
- const SizedBox(width: 4),
GestureDetector(
onTap: cast.skipToNextChapter,
- child: SizedBox(width: 40, height: 40, child: Center(
- child: Icon(Icons.skip_next_rounded, size: 24, color: cs.onSurfaceVariant),
+ child: SizedBox(width: 52, height: 52, child: Center(
+ child: Icon(Icons.skip_next_rounded, size: 34, color: cs.onSurfaceVariant),
)),
),
],
- ));
+ );
}
/// Original local player controls
Widget _buildLocalControls() {
final cs = Theme.of(context).colorScheme;
- return StreamBuilder<PlayerState>(
- stream: widget.isActive ? widget.player.playerStateStream : const Stream.empty(),
- builder: (_, snapshot) {
- // Use synchronous player state as fallback — broadcast streams don't
- // replay the last event, so after an app-resume the snapshot can be
- // null even though audio is actively playing.
- final playing = snapshot.data?.playing ?? widget.player.isPlaying;
- final processingState = snapshot.data?.processingState ?? ProcessingState.ready;
- final isPlaying = widget.isActive && playing;
- final isLoading = widget.isActive && (processingState == ProcessingState.loading || processingState == ProcessingState.buffering);
-
- if (isPlaying) {
- _playPauseController.forward();
- } else {
- _playPauseController.reverse();
- }
-
- return FittedBox(
- fit: BoxFit.scaleDown,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- GestureDetector(
- onTap: widget.isActive ? widget.player.skipToPreviousChapter : null,
- child: SizedBox(width: 40, height: 40, child: Center(
- child: Icon(Icons.skip_previous_rounded, size: 24, color: widget.isActive ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.12)),
- )),
- ),
- const SizedBox(width: 4),
- GestureDetector(
- onTap: widget.isActive ? () => widget.player.skipBackward(_backSkip) : null,
- child: SizedBox(width: 52, height: 52, child: Center(child: _skipIcon(_backSkip, false, active: widget.isActive))),
- ),
- const SizedBox(width: 16),
- GestureDetector(
- onTap: widget.isActive ? widget.player.togglePlayPause : widget.onStart,
- child: SizedBox(
- width: 80, height: 80,
- child: Stack(
- alignment: Alignment.center,
- children: [
- Container(
- width: 64, height: 64,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: cs.onSurface,
- boxShadow: [BoxShadow(color: widget.accent.withValues(alpha: 0.4), blurRadius: 25, spreadRadius: -5)],
- ),
- child: isLoading
- ? Center(child: SizedBox(width: 28, height: 28, child: CircularProgressIndicator(strokeWidth: 2, color: widget.accent)))
- : Center(
- child: AnimatedIcon(
- icon: AnimatedIcons.play_pause,
- progress: _playPauseController,
- size: 34,
- color: cs.surface,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- const SizedBox(width: 16),
- GestureDetector(
- onTap: widget.isActive ? () => widget.player.skipForward(_forwardSkip) : null,
- child: SizedBox(width: 52, height: 52, child: Center(child: _skipIcon(_forwardSkip, true, active: widget.isActive))),
- ),
- const SizedBox(width: 4),
- GestureDetector(
- onTap: widget.isActive ? widget.player.skipToNextChapter : null,
- child: SizedBox(width: 40, height: 40, child: Center(
- child: Icon(Icons.skip_next_rounded, size: 24, color: widget.isActive ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.12)),
- )),
- ),
- ],
- ));
- },
+ final loading = widget.isStarting || (widget.isActive && widget.player.isLoadingOrBuffering);
+ return Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ GestureDetector(
+ onTap: widget.isActive ? widget.player.skipToPreviousChapter : null,
+ child: SizedBox(width: 52, height: 52, child: Center(
+ child: Icon(Icons.skip_previous_rounded, size: 34, color: widget.isActive ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.12)),
+ )),
+ ),
+ GestureDetector(
+ onTap: widget.isActive ? () => widget.player.skipBackward(_backSkip) : null,
+ child: SizedBox(width: 60, height: 60, child: Center(child: _skipIcon(_backSkip, false, active: widget.isActive))),
+ ),
+ if (widget.showPlayButton)
+ _playPauseButton(cs, playing: widget.isActive && widget.player.isPlaying, loading: loading,
+ onTap: widget.isActive ? widget.player.togglePlayPause : widget.onStart),
+ GestureDetector(
+ onTap: widget.isActive ? () => widget.player.skipForward(_forwardSkip) : null,
+ child: SizedBox(width: 60, height: 60, child: Center(child: _skipIcon(_forwardSkip, true, active: widget.isActive))),
+ ),
+ GestureDetector(
+ onTap: widget.isActive ? widget.player.skipToNextChapter : null,
+ child: SizedBox(width: 52, height: 52, child: Center(
+ child: Icon(Icons.skip_next_rounded, size: 34, color: widget.isActive ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.12)),
+ )),
+ ),
+ ],
);
}
}
diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dart
index 19cb480b..fa4a254d 100644
--- a/lib/widgets/expanded_card.dart
+++ b/lib/widgets/expanded_card.dart
@@ -10,7 +10,6 @@ import '../services/audio_player_service.dart';
import '../services/download_service.dart';
import '../services/playback_history_service.dart';
import '../services/chromecast_service.dart';
-import '../services/progress_sync_service.dart';
import 'book_detail_sheet.dart';
import 'episode_list_sheet.dart';
import 'equalizer_sheet.dart';
@@ -90,8 +89,8 @@ class _ExpandedCardState extends State<ExpandedCard> {
bool _isPopping = false; // Prevent double-pop and setState during exit
List<String> _buttonOrder = PlayerSettings.defaultButtonOrder;
String _buttonLayout = PlayerSettings.defaultButtonLayout;
- bool _autoRemoveFinished = false;
bool _rectangleCovers = false;
+ bool _coverPlayButton = false;
// Our own route, captured for popUntil when modals are stacked above us
Route<dynamic>? _ownRoute;
@@ -166,7 +165,6 @@ class _ExpandedCardState extends State<ExpandedCard> {
ChromecastService().addListener(_onCastChanged);
PlayerSettings.settingsChanged.addListener(_reloadButtonOrder);
_reloadButtonOrder();
- _loadWhenFinished();
_startChapterTracking();
_fetchChaptersIfNeeded();
// Generate our own blurred cover
@@ -189,11 +187,8 @@ class _ExpandedCardState extends State<ExpandedCard> {
PlayerSettings.getRectangleCovers().then((v) {
if (mounted && v != _rectangleCovers) setState(() => _rectangleCovers = v);
});
- }
-
- void _loadWhenFinished() {
- PlayerSettings.getWhenFinished().then((mode) {
- if (mounted) setState(() => _autoRemoveFinished = mode == 'auto_remove');
+ PlayerSettings.getCoverPlayButton().then((v) {
+ if (mounted && v != _coverPlayButton) setState(() => _coverPlayButton = v);
});
}
@@ -558,6 +553,15 @@ class _ExpandedCardState extends State<ExpandedCard> {
fontWeight: FontWeight.w700, fontSize: 15,
shadows: [Shadow(color: isDark ? Colors.black.withValues(alpha: 0.6) : Colors.white.withValues(alpha: 0.6), blurRadius: 4)],
)),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: _dismissExpanded,
+ child: Padding(
+ padding: const EdgeInsets.all(8),
+ child: Icon(Icons.close_fullscreen_rounded, size: 17,
+ color: isDark ? Colors.white.withValues(alpha: 0.6) : Colors.black.withValues(alpha: 0.5)),
+ ),
+ ),
],
),
),
@@ -569,10 +573,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
const SizedBox(height: 16),
// ── Cover art (larger — 90% width) ──
Flexible(
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: _dismissExpanded,
- child: Padding(
+ child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: ListenableBuilder(
listenable: ChromecastService(),
@@ -594,7 +595,19 @@ class _ExpandedCardState extends State<ExpandedCard> {
final isDownloaded = DownloadService().isDownloaded(dlKey);
final castService = ChromecastService();
final isCastingThis = castService.isCasting && castService.castingItemId == _itemId;
- return Container(
+ final coverPlaying = isCastingThis ? castService.isPlaying : (_isActive && widget.player.isPlaying);
+ final coverLoading = _isStarting || (_isActive && widget.player.isLoadingOrBuffering);
+ return GestureDetector(
+ onTap: _coverPlayButton ? () {
+ if (isCastingThis) {
+ castService.togglePlayPause();
+ } else if (_isActive) {
+ widget.player.togglePlayPause();
+ } else {
+ _startPlayback();
+ }
+ } : _dismissExpanded,
+ child: Container(
width: coverW,
height: coverH,
decoration: BoxDecoration(
@@ -640,6 +653,45 @@ class _ExpandedCardState extends State<ExpandedCard> {
),
),
),
+ // Play/pause overlay
+ if (_coverPlayButton && !isCastingThis && !isFinished)
+ Positioned.fill(
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 200),
+ decoration: BoxDecoration(
+ color: coverPlaying ? Colors.transparent : Colors.black.withValues(alpha: 0.25),
+ ),
+ child: Center(
+ child: coverLoading
+ ? Container(
+ width: 56, height: 56,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: Colors.black.withValues(alpha: 0.5),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(12),
+ child: CircularProgressIndicator(strokeWidth: 3, color: accent),
+ ),
+ )
+ : AnimatedOpacity(
+ opacity: coverPlaying ? 0.2 : 0.9,
+ duration: const Duration(milliseconds: 200),
+ child: Container(
+ width: 64, height: 64,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: Colors.black.withValues(alpha: 0.45),
+ ),
+ child: Icon(
+ coverPlaying ? Icons.pause_rounded : Icons.play_arrow_rounded,
+ size: 38, color: accent,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
// Casting overlay
if (isCastingThis) ...[
Positioned.fill(
@@ -672,75 +724,16 @@ class _ExpandedCardState extends State<ExpandedCard> {
),
),
],
- // Finished overlay
- if (isFinished && !isCastingThis && !_autoRemoveFinished) ...[
- Positioned.fill(
- child: Container(color: Colors.black.withValues(alpha: 0.78)),
- ),
- Positioned.fill(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 14),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(Icons.check_circle_rounded, size: 32, color: isDark ? Colors.green.shade400 : Colors.green.shade700),
- const SizedBox(height: 6),
- const Text('Finished',
- style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w700)),
- const SizedBox(height: 18),
- SizedBox(
- width: double.infinity,
- child: GestureDetector(
- onTap: _listenAgain,
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 9),
- decoration: BoxDecoration(
- color: Colors.white.withValues(alpha: 0.18),
- borderRadius: BorderRadius.circular(11),
- border: Border.all(color: Colors.white.withValues(alpha: 0.25)),
- ),
- child: const Text('Listen Again',
- textAlign: TextAlign.center,
- style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w600)),
- ),
- ),
- ),
- const SizedBox(height: 8),
- SizedBox(
- width: double.infinity,
- child: GestureDetector(
- onTap: () {
- _removeFromAbsorbing();
- _dismissExpanded();
- },
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 9),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(11),
- border: Border.all(color: Colors.white.withValues(alpha: 0.18)),
- ),
- child: const Text('Remove',
- textAlign: TextAlign.center,
- style: TextStyle(color: Colors.white70, fontSize: 12, fontWeight: FontWeight.w500)),
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ],
],
),
),
),
- );
+ ));
},
),
),
),
),
- ),
const SizedBox(height: 24),
// ── Chapter scrubber ──
Padding(
@@ -767,6 +760,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
isStarting: _isStarting,
onStart: _startPlayback,
itemId: _itemId,
+ showPlayButton: !_coverPlayButton,
),
const SizedBox(height: 24),
// ── Button grid ──
@@ -963,28 +957,6 @@ class _ExpandedCardState extends State<ExpandedCard> {
}
}
- Future<void> _listenAgain() async {
- if (_isStarting) return;
- final cast = ChromecastService();
- if (cast.isCasting && cast.castingItemId == _itemId) return;
- setState(() => _isStarting = true);
- final auth = context.read<AuthProvider>();
- final api = auth.apiService;
- if (api == null) { setState(() => _isStarting = false); return; }
- final lib = context.read<LibraryProvider>();
- await api.resetProgress(_itemId, _duration);
- lib.resetProgressFor(_itemId);
- await ProgressSyncService().deleteLocal(_itemId);
- final error = await widget.player.playItem(
- api: api, itemId: _itemId, title: _title, author: _author,
- coverUrl: _coverUrl, totalDuration: _duration, chapters: _chapters,
- );
- if (mounted) {
- if (error != null) showErrorSnackBar(context, error);
- setState(() => _isStarting = false);
- }
- }
-
Future<void> _removeFromAbsorbing() async {
if (widget.player.currentItemId == _itemId) {
await widget.player.pause();
diff --git a/lib/widgets/welcome_sheet.dart b/lib/widgets/welcome_sheet.dart
index b17b6c6f..5834373f 100644
--- a/lib/widgets/welcome_sheet.dart
+++ b/lib/widgets/welcome_sheet.dart
@@ -113,9 +113,10 @@ class _WelcomeContent extends StatelessWidget {
_subsection(cs, tt,
title: 'Managing your queue',
items: [
+ 'Tap the cover art to play/pause, use the expand icon to open the full screen player',
'Tap the reorder icon to drag cards into your preferred order or swipe to remove',
'Add books manually from any book\'s detail sheet',
- 'When a book finishes, choose to listen again, remove it, or let it auto-release',
+ 'Finished books are automatically removed from your queue',
],
),