Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Give the full screen player a bigger cover and fold the percent into the timestamps row

Barnabas46136f10ab06
diff --git a/lib/widgets/card_progress_bar.dart b/lib/widgets/card_progress_bar.dart
index 8e01db94..23b5b930 100644
--- a/lib/widgets/card_progress_bar.dart
+++ b/lib/widgets/card_progress_bar.dart
@@ -23,7 +23,11 @@ class CardDualProgressBar extends StatefulWidget {
final int totalChapters;
final String? itemId;
final bool compact;
- const CardDualProgressBar({super.key, required this.player, required this.accent, required this.isActive, required this.staticProgress, required this.staticDuration, required this.chapters, this.showBookBar = true, this.showChapterBar = true, this.chapterName, this.chapterIndex = 0, this.totalChapters = 0, this.itemId, this.compact = false});
+ /// Render the book percentage centered in the book bar's own time row
+ /// (between elapsed and remaining) instead of the caller stacking a
+ /// separate percent line above - saves a row on the full screen player.
+ final bool showCenterPercent;
+ const CardDualProgressBar({super.key, required this.player, required this.accent, required this.isActive, required this.staticProgress, required this.staticDuration, required this.chapters, this.showBookBar = true, this.showChapterBar = true, this.chapterName, this.chapterIndex = 0, this.totalChapters = 0, this.itemId, this.compact = false, this.showCenterPercent = false});
@override State<CardDualProgressBar> createState() => _CardDualProgressBarState();
}
@@ -353,15 +357,30 @@ class _CardDualProgressBarState extends State<CardDualProgressBar> with WidgetsB
child: CustomPaint(size: Size(w, 32), painter: AbsorbProgressPainter(progress: p, accent: widget.accent.withValues(alpha: 0.5), isDragging: _bookDragValue != null)),
);
})),
- Padding(padding: const EdgeInsets.only(top: 2, bottom: 6), child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ Padding(padding: const EdgeInsets.only(top: 2, bottom: 6), child: Stack(
+ alignment: Alignment.center,
children: [
- Text(_fmt(_bookDragValue != null ? _bookDragValue! * totalDur / speedDiv : bookElapsed), style: tt.labelSmall?.copyWith(color: _bookDragValue != null ? cs.onSurface.withValues(alpha: 0.7) : cs.onSurfaceVariant, fontSize: 12 * _progressTextScale, fontWeight: FontWeight.w600, shadows: [Shadow(color: Theme.of(context).brightness == Brightness.dark ? Colors.black.withValues(alpha: 0.5) : Colors.white.withValues(alpha: 0.5), blurRadius: 3)])),
- if (_bookDragValue != null && _bookScrubSpeed < 1.0) Text(_scrubSpeedLabel(l, _bookScrubSpeed), style: tt.labelSmall?.copyWith(color: widget.accent, fontSize: 11, fontWeight: FontWeight.w500)),
- Text('-${_fmt(_bookDragValue != null ? (1.0 - _bookDragValue!) * totalDur / speedDiv : bookRemaining)}', style: tt.labelSmall?.copyWith(color: _bookDragValue != null ? cs.onSurface.withValues(alpha: 0.7) : cs.onSurfaceVariant, fontSize: 12 * _progressTextScale, fontWeight: FontWeight.w600, shadows: [Shadow(color: Theme.of(context).brightness == Brightness.dark ? Colors.black.withValues(alpha: 0.5) : Colors.white.withValues(alpha: 0.5), blurRadius: 3)])),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(_fmt(_bookDragValue != null ? _bookDragValue! * totalDur / speedDiv : bookElapsed), style: tt.labelSmall?.copyWith(color: _bookDragValue != null ? cs.onSurface.withValues(alpha: 0.7) : cs.onSurfaceVariant, fontSize: 12 * _progressTextScale, fontWeight: FontWeight.w600, shadows: [Shadow(color: Theme.of(context).brightness == Brightness.dark ? Colors.black.withValues(alpha: 0.5) : Colors.white.withValues(alpha: 0.5), blurRadius: 3)])),
+ Text('-${_fmt(_bookDragValue != null ? (1.0 - _bookDragValue!) * totalDur / speedDiv : bookRemaining)}', style: tt.labelSmall?.copyWith(color: _bookDragValue != null ? cs.onSurface.withValues(alpha: 0.7) : cs.onSurfaceVariant, fontSize: 12 * _progressTextScale, fontWeight: FontWeight.w600, shadows: [Shadow(color: Theme.of(context).brightness == Brightness.dark ? Colors.black.withValues(alpha: 0.5) : Colors.white.withValues(alpha: 0.5), blurRadius: 3)])),
+ ],
+ ),
+ if (_bookDragValue != null && _bookScrubSpeed < 1.0)
+ Text(_scrubSpeedLabel(l, _bookScrubSpeed), style: tt.labelSmall?.copyWith(color: widget.accent, fontSize: 11, fontWeight: FontWeight.w500))
+ else if (widget.showCenterPercent)
+ Text('${(( _bookDragValue ?? bookProgress) * 100).clamp(0, 100).toStringAsFixed(1)}%', style: tt.labelSmall?.copyWith(color: cs.onSurfaceVariant, fontSize: 12 * _progressTextScale, fontWeight: FontWeight.w600, shadows: [Shadow(color: Theme.of(context).brightness == Brightness.dark ? Colors.black.withValues(alpha: 0.5) : Colors.white.withValues(alpha: 0.5), blurRadius: 3)])),
],
)),
] else ...[
+ // No book seeking: the caller relying on showCenterPercent has
+ // dropped its own percent line, so render one here instead.
+ if (widget.showCenterPercent)
+ Padding(
+ padding: const EdgeInsets.only(bottom: 2),
+ child: Text('${(bookProgress * 100).clamp(0, 100).toStringAsFixed(1)}%', style: tt.labelSmall?.copyWith(color: cs.onSurfaceVariant, fontSize: 11 * _progressTextScale, fontWeight: FontWeight.w500, shadows: [Shadow(color: Theme.of(context).brightness == Brightness.dark ? Colors.black.withValues(alpha: 0.5) : Colors.white.withValues(alpha: 0.5), blurRadius: 3)])),
+ ),
Row(children: [
Text(_fmt(_bookDragValue != null ? _bookDragValue! * totalDur / speedDiv : bookElapsed), style: tt.labelSmall?.copyWith(color: _bookDragValue != null ? cs.onSurface.withValues(alpha: 0.6) : cs.onSurface.withValues(alpha: 0.5), fontSize: 11 * _progressTextScale, fontWeight: FontWeight.w500, shadows: [Shadow(color: Theme.of(context).brightness == Brightness.dark ? Colors.black.withValues(alpha: 0.5) : Colors.white.withValues(alpha: 0.5), blurRadius: 3)])),
const SizedBox(width: 8),
diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dart
index 5fb68b88..da221e37 100644
--- a/lib/widgets/expanded_card.dart
+++ b/lib/widgets/expanded_card.dart
@@ -719,7 +719,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
isDark ? 0.3 : 0.4,
));
final statsRow = Padding(
- padding: EdgeInsets.fromLTRB(24, compact ? 4 : 12, 24, 0),
+ padding: EdgeInsets.fromLTRB(24, compact ? 4 : 6, 24, 0),
child: Center(
child: Text('${(bookProgress * 100).clamp(0, 100).toStringAsFixed(1)}%',
style: tt.labelSmall?.copyWith(
@@ -734,7 +734,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
final bookProgressBar = Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
- child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: progress, staticDuration: _effectiveDuration, chapters: _chapters, showBookBar: showBookBar, showChapterBar: false, itemId: _itemId),
+ child: CardDualProgressBar(player: widget.player, accent: accent, isActive: _isActive, staticProgress: progress, staticDuration: _effectiveDuration, chapters: _chapters, showBookBar: showBookBar, showChapterBar: false, itemId: _itemId, showCenterPercent: true),
);
final coverArea = Padding(
@@ -743,7 +743,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
listenable: ChromecastService(),
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
- final maxW = constraints.maxWidth * 0.90;
+ final maxW = constraints.maxWidth * 0.95;
final maxH = constraints.maxHeight - 24;
double coverW, coverH;
if (_rectangleCovers) {
@@ -989,7 +989,10 @@ class _ExpandedCardState extends State<ExpandedCard> {
Expanded(child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
- statsRow,
+ // The book bar carries the percent centered in
+ // its time row; the standalone line is only for
+ // layouts with no book bar at all.
+ if (!showBookBar) statsRow,
if (showBookBar) bookProgressBar,
if (showBookBar) SizedBox(height: compact ? 4 : 16),
chapterScrubber,
@@ -1002,11 +1005,14 @@ class _ExpandedCardState extends State<ExpandedCard> {
return Column(
children: [
- statsRow,
+ // The book bar carries the percent centered in its
+ // time row; the standalone line is only for layouts
+ // with no book bar at all.
+ if (!showBookBar) statsRow,
if (showBookBar) bookProgressBar,
- if (showBookBar) SizedBox(height: compact ? 4 : 16),
+ if (showBookBar) SizedBox(height: compact ? 4 : 8),
Expanded(child: coverArea),
- SizedBox(height: compact ? 6 : 24),
+ SizedBox(height: compact ? 6 : 12),
chapterScrubber,
controlsAndButtons,
],