Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Scale UI elements proportionally on high display zoom settings

Nathan Poulson2c0ab1d00620
diff --git a/lib/widgets/absorb_page_header.dart b/lib/widgets/absorb_page_header.dart
index 93db52a1..3f173ddd 100644
--- a/lib/widgets/absorb_page_header.dart
+++ b/lib/widgets/absorb_page_header.dart
@@ -35,19 +35,33 @@ class AbsorbPageHeader extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Branding row — ABSORB + optional actions
- Row(
- children: [
- Text(
- 'A B S O R B',
- style: tt.labelSmall?.copyWith(
- color: bColor,
- letterSpacing: 4,
- fontWeight: FontWeight.w300,
- ),
- ),
- const Spacer(),
- if (actions != null) ...actions!,
- ],
+ LayoutBuilder(
+ builder: (ctx, lc) {
+ return Row(
+ children: [
+ Text(
+ 'A B S O R B',
+ style: tt.labelSmall?.copyWith(
+ color: bColor,
+ letterSpacing: 4,
+ fontWeight: FontWeight.w300,
+ ),
+ ),
+ const Spacer(),
+ if (actions != null)
+ ConstrainedBox(
+ constraints: BoxConstraints(
+ maxWidth: (lc.maxWidth - 140).clamp(0.0, double.infinity),
+ ),
+ child: FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.centerRight,
+ child: Row(mainAxisSize: MainAxisSize.min, children: actions!),
+ ),
+ ),
+ ],
+ );
+ },
),
const SizedBox(height: 4),
// Page title
diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dart
index d0c7e842..bd3b1d09 100644
--- a/lib/widgets/absorbing_card.dart
+++ b/lib/widgets/absorbing_card.dart
@@ -450,7 +450,8 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
// Layer 3: Content
LayoutBuilder(
builder: (context, cardConstraints) {
- final compact = cardConstraints.maxHeight < 600;
+ final textScale = MediaQuery.textScalerOf(context).scale(1.0).clamp(1.0, 1.5);
+ final compact = cardConstraints.maxHeight < 600 * textScale;
return Column(
children: [
// ── Stats row ──
@@ -461,7 +462,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
Text('${(bookProgress * 100).clamp(0, 100).toStringAsFixed(1)}%',
style: tt.labelMedium?.copyWith(
color: isDark ? Colors.white.withValues(alpha: 0.95) : Colors.black.withValues(alpha: 0.85),
- fontWeight: FontWeight.w800, fontSize: 15,
+ fontWeight: FontWeight.w800, fontSize: compact ? 12 : 15,
shadows: [Shadow(color: isDark ? Colors.black.withValues(alpha: 0.6) : Colors.white.withValues(alpha: 0.6), blurRadius: 4)],
)),
const Spacer(),
@@ -469,7 +470,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
Text('Ch ${(chapterIdx + 1).clamp(1, totalChapters)} / $totalChapters',
style: tt.labelMedium?.copyWith(
color: isDark ? Colors.white.withValues(alpha: 0.85) : Colors.black.withValues(alpha: 0.75),
- fontWeight: FontWeight.w700, fontSize: 14,
+ 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)],
)),
],
@@ -478,7 +479,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
// ── Book progress bar ──
Padding(
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),
+ 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),
// ── Cover with title/author/chapter overlaid + download badge ──
@@ -588,69 +589,77 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
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),
- if (isDownloaded)
- Padding(
- padding: const EdgeInsets.only(bottom: 8),
- child: SizedBox(
- width: double.infinity,
- 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: 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: const Text('Delete Download',
- textAlign: TextAlign.center,
- style: TextStyle(color: Colors.white70, fontSize: 12, fontWeight: FontWeight.w500)),
),
),
- ),
- ),
- SizedBox(
- width: double.infinity,
- 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)),
+ 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: const Text('Remove from Absorbing',
- textAlign: TextAlign.center,
- style: TextStyle(color: Colors.white70, fontSize: 12, fontWeight: FontWeight.w500)),
- ),
+ ],
),
),
- ],
+ ),
),
),
),
@@ -670,105 +679,92 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
// ── Chapter pill-scrubber (same width as book bar) ──
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),
+ 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: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20),
- child: Column(
- children: [
- Spacer(flex: compact ? 1 : 2),
- CardPlaybackControls(
- player: widget.player,
- accent: accent,
- isActive: _isActive,
- isStarting: _isStarting,
- onStart: _startPlayback,
- itemId: _itemId,
- ),
- Spacer(flex: compact ? 1 : 3),
- // ── Button grid (hugs bottom) ──
- if (compact) Transform(
- alignment: Alignment.bottomCenter,
- transform: Matrix4.identity()..scale(1.0, 0.85),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Row(children: [
- Expanded(child: _buildCardButton(_buttonOrder[0], accent, tt)),
- const SizedBox(width: 8),
- Expanded(child: _buildCardButton(_buttonOrder[1], accent, tt)),
- ]),
- const SizedBox(height: 4),
- Row(children: [
- Expanded(child: _buildCardButton(_buttonOrder[2], accent, tt)),
- const SizedBox(width: 8),
- Expanded(child: _buildCardButton(_buttonOrder[3], accent, tt)),
- ]),
- ],
- ),
- ) else ...[
- Row(children: [
- Expanded(child: _buildCardButton(_buttonOrder[0], accent, tt)),
- const SizedBox(width: 8),
- Expanded(child: _buildCardButton(_buttonOrder[1], accent, tt)),
- ]),
- const SizedBox(height: 8),
- Row(children: [
- Expanded(child: _buildCardButton(_buttonOrder[2], accent, tt)),
- const SizedBox(width: 8),
- Expanded(child: _buildCardButton(_buttonOrder[3], accent, tt)),
- ]),
- ],
- SizedBox(height: compact ? 2 : 8),
- // More menu / Cast controls (centered below buttons)
- Center(
- child: ListenableBuilder(
- listenable: ChromecastService(),
- builder: (context, _) {
- final castActive = ChromecastService().isCasting && !_buttonOrder.take(4).contains('cast');
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: castActive
- ? () => showModalBottomSheet(
- context: context,
- backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,
- shape: const RoundedRectangleBorder(
- borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
- ),
- builder: (_) => const CastControlSheet(),
- )
- : () => _showMoreMenu(context, accent, tt),
- child: Container(
- padding: EdgeInsets.symmetric(horizontal: compact ? 16 : 20, vertical: compact ? 5 : 8),
- decoration: BoxDecoration(
- color: castActive ? accent.withValues(alpha: 0.15) : cs.onSurface.withValues(alpha: 0.08),
- borderRadius: BorderRadius.circular(20),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: castActive
- ? [
- Icon(Icons.cast_connected_rounded, size: 18, color: accent),
- const SizedBox(width: 4),
- Text('Casting', style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: accent)),
- ]
- : [
- Icon(Icons.more_horiz_rounded, size: 18, color: cs.onSurface.withValues(alpha: 0.54)),
- const SizedBox(width: 4),
- Text('More', style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: cs.onSurface.withValues(alpha: 0.54))),
- ],
- ),
- ),
- );
- },
- ),
+ child: LayoutBuilder(
+ builder: (context, lc) {
+ return FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.center,
+ child: SizedBox(
+ width: lc.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 ──
+ Row(children: [
+ Expanded(child: _buildCardButton(_buttonOrder[0], accent, tt)),
+ const SizedBox(width: 8),
+ Expanded(child: _buildCardButton(_buttonOrder[1], accent, tt)),
+ ]),
+ const SizedBox(height: 6),
+ Row(children: [
+ Expanded(child: _buildCardButton(_buttonOrder[2], accent, tt)),
+ const SizedBox(width: 8),
+ Expanded(child: _buildCardButton(_buttonOrder[3], accent, tt)),
+ ]),
+ const SizedBox(height: 6),
+ // More menu / Cast controls
+ Center(
+ child: ListenableBuilder(
+ listenable: ChromecastService(),
+ builder: (context, _) {
+ final castActive = ChromecastService().isCasting && !_buttonOrder.take(4).contains('cast');
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: castActive
+ ? () => showModalBottomSheet(
+ context: context,
+ backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,
+ shape: const RoundedRectangleBorder(
+ borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
+ ),
+ builder: (_) => const CastControlSheet(),
+ )
+ : () => _showMoreMenu(context, accent, tt),
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
+ decoration: BoxDecoration(
+ color: castActive ? accent.withValues(alpha: 0.15) : cs.onSurface.withValues(alpha: 0.08),
+ borderRadius: BorderRadius.circular(20),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: castActive
+ ? [
+ Icon(Icons.cast_connected_rounded, size: 18, color: accent),
+ const SizedBox(width: 4),
+ Text('Casting', style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: accent)),
+ ]
+ : [
+ Icon(Icons.more_horiz_rounded, size: 18, color: cs.onSurface.withValues(alpha: 0.54)),
+ const SizedBox(width: 4),
+ Text('More', style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: cs.onSurface.withValues(alpha: 0.54))),
+ ],
+ ),
+ ),
+ );
+ },
+ ),
+ ),
+ const SizedBox(height: 4),
+ ],
),
- if (!compact) const SizedBox(height: 4),
- ],
- ),
- ),
+ ),
+ );
+ }),
),
],
);
diff --git a/lib/widgets/card_progress_bar.dart b/lib/widgets/card_progress_bar.dart
index 8b3afe86..205029c3 100644
--- a/lib/widgets/card_progress_bar.dart
+++ b/lib/widgets/card_progress_bar.dart
@@ -20,7 +20,8 @@ class CardDualProgressBar extends StatefulWidget {
final int chapterIndex;
final int totalChapters;
final String? itemId;
- 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});
+ 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});
@override State<CardDualProgressBar> createState() => _CardDualProgressBarState();
}
@@ -281,13 +282,13 @@ class _CardDualProgressBarState extends State<CardDualProgressBar> with TickerPr
const SizedBox(width: 8),
Text('-${_fmt(_bookDragValue != null ? (1.0 - _bookDragValue!) * totalDur : bookRemaining)}', style: tt.labelSmall?.copyWith(color: _bookDragValue != null ? cs.onSurface.withValues(alpha: 0.6) : cs.onSurface.withValues(alpha: 0.5), fontSize: 11, 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(height: 10),
+ SizedBox(height: widget.compact ? 4 : 10),
],
], // end showBookBar
// Chapter bar
if (widget.showChapterBar) ...[
// ── Chapter pill-scrubber ──
- SizedBox(height: 30, child: LayoutBuilder(builder: (_, cons) {
+ SizedBox(height: widget.compact ? 22 : 30, child: LayoutBuilder(builder: (_, cons) {
final w = cons.maxWidth;
final p = _chapterDragValue ?? chapterProgress;
final isDragging = _chapterDragValue != null;
@@ -331,7 +332,7 @@ class _CardDualProgressBarState extends State<CardDualProgressBar> with TickerPr
);
})),
// Time labels below pill — update during drag
- Padding(padding: const EdgeInsets.only(top: 3), child: Row(
+ Padding(padding: EdgeInsets.only(top: widget.compact ? 1 : 3), child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(_fmt(_chapterDragValue != null ? (_chapterDragValue! * chapterDur) / speedDiv : chapterElapsed),
@@ -525,15 +526,19 @@ class MarqueeText extends StatefulWidget {
class _MarqueeTextState extends State<MarqueeText> with SingleTickerProviderStateMixin {
late ScrollController _scrollController;
late AnimationController _animController;
- double _maxScroll = 0;
+ bool _duplicated = false;
+ double _loopWidth = 0; // distance to scroll for one seamless loop
+
+ static const double _gap = 48.0; // space between the two text copies
+ static const double _speed = 38.0; // pixels per second
@override
void initState() {
super.initState();
_scrollController = ScrollController();
- _animController = AnimationController(vsync: this, duration: const Duration(seconds: 6));
+ _animController = AnimationController(vsync: this, duration: const Duration(seconds: 8));
_animController.addListener(_onTick);
- WidgetsBinding.instance.addPostFrameCallback((_) => _checkOverflow());
+ WidgetsBinding.instance.addPostFrameCallback((_) => _measure());
}
@override
@@ -542,36 +547,40 @@ class _MarqueeTextState extends State<MarqueeText> with SingleTickerProviderStat
if (old.text != widget.text) {
_animController.stop();
_animController.reset();
+ _duplicated = false;
+ _loopWidth = 0;
if (_scrollController.hasClients) _scrollController.jumpTo(0);
- WidgetsBinding.instance.addPostFrameCallback((_) => _checkOverflow());
- }
- }
-
- void _onTick() {
- if (_scrollController.hasClients && _maxScroll > 0) {
- _scrollController.jumpTo(_animController.value * _maxScroll);
+ WidgetsBinding.instance.addPostFrameCallback((_) => _measure());
}
}
- void _checkOverflow() {
+ void _measure() {
if (!mounted || !_scrollController.hasClients) return;
- _maxScroll = _scrollController.position.maxScrollExtent;
- if (_maxScroll > 0) {
- final dur = Duration(milliseconds: (_maxScroll * 25).round().clamp(2000, 15000));
- _animController.duration = dur;
- _startLoop();
- }
+ final maxScroll = _scrollController.position.maxScrollExtent;
+ if (maxScroll <= 0) return; // text fits, nothing to do
+
+ // In single-text mode: maxScroll = textWidth - viewportWidth
+ // loopWidth = textWidth + gap (one seamless cycle in duplicated mode)
+ _loopWidth = maxScroll + _scrollController.position.viewportDimension + _gap;
+
+ setState(() => _duplicated = true);
+
+ // After duplicated layout settles, start the continuous loop
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (!mounted) return;
+ final durationMs = (_loopWidth / _speed * 1000).round();
+ _animController.duration = Duration(milliseconds: durationMs);
+ Future.delayed(const Duration(seconds: 2), () {
+ if (mounted) _animController.repeat();
+ });
+ });
}
- void _startLoop() async {
- await Future.delayed(const Duration(seconds: 2));
- if (!mounted) return;
- await _animController.forward(from: 0);
- if (!mounted) return;
- await Future.delayed(const Duration(seconds: 2));
- if (!mounted) return;
- if (_scrollController.hasClients) _scrollController.jumpTo(0);
- _startLoop();
+ void _onTick() {
+ if (!_scrollController.hasClients || _loopWidth <= 0) return;
+ // value 0→1 maps to 0→loopWidth; repeat() resets value to 0 seamlessly
+ final pos = _animController.value * _loopWidth;
+ _scrollController.jumpTo(pos.clamp(0.0, _scrollController.position.maxScrollExtent));
}
@override
@@ -582,16 +591,24 @@ class _MarqueeTextState extends State<MarqueeText> with SingleTickerProviderStat
super.dispose();
}
+ Widget _textSpan() => Padding(
+ padding: const EdgeInsets.symmetric(vertical: 2),
+ child: Text(widget.text, style: widget.style, maxLines: 1, softWrap: false),
+ );
+
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
controller: _scrollController,
scrollDirection: Axis.horizontal,
physics: const NeverScrollableScrollPhysics(),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 2),
- child: Text(widget.text, style: widget.style, maxLines: 1, softWrap: false),
- ),
+ child: _duplicated
+ ? Row(mainAxisSize: MainAxisSize.min, children: [
+ _textSpan(),
+ const SizedBox(width: _gap),
+ _textSpan(),
+ ])
+ : _textSpan(),
);
}
}
diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dart
index b0c0a779..fa74fef9 100644
--- a/lib/widgets/expanded_card.dart
+++ b/lib/widgets/expanded_card.dart
@@ -746,79 +746,88 @@ class _ExpandedCardState extends State<ExpandedCard> {
),
// ── Controls + buttons ──
Expanded(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 28),
- child: Column(
- children: [
- const Spacer(flex: 2),
- CardPlaybackControls(
- player: widget.player,
- accent: accent,
- isActive: _isActive,
- isStarting: _isStarting,
- onStart: _startPlayback,
- itemId: _itemId,
- ),
- const Spacer(flex: 4),
- // ── Button grid ──
- Row(children: [
- Expanded(child: _buildCardButton(_buttonOrder[0], accent, tt)),
- const SizedBox(width: 10),
- Expanded(child: _buildCardButton(_buttonOrder[1], accent, tt)),
- ]),
- const SizedBox(height: 14),
- Row(children: [
- Expanded(child: _buildCardButton(_buttonOrder[2], accent, tt)),
- const SizedBox(width: 10),
- Expanded(child: _buildCardButton(_buttonOrder[3], accent, tt)),
- ]),
- const SizedBox(height: 14),
- // More menu / Cast controls
- Center(
- child: ListenableBuilder(
- listenable: ChromecastService(),
- builder: (context, _) {
- final castActive = ChromecastService().isCasting && !_buttonOrder.take(4).contains('cast');
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: castActive
- ? () => showModalBottomSheet(
- context: context,
- backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,
- shape: const RoundedRectangleBorder(
- borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
- ),
- builder: (_) => const CastControlSheet(),
- )
- : () => _showMoreMenu(context, accent, tt),
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
- decoration: BoxDecoration(
- color: castActive ? accent.withValues(alpha: 0.15) : cs.onSurface.withValues(alpha: 0.08),
- borderRadius: BorderRadius.circular(22),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: castActive
- ? [
- Icon(Icons.cast_connected_rounded, size: 20, color: accent),
- const SizedBox(width: 6),
- Text('Casting', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: accent)),
- ]
- : [
- Icon(Icons.more_horiz_rounded, size: 20, color: cs.onSurface.withValues(alpha: 0.54)),
- const SizedBox(width: 6),
- Text('More', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: cs.onSurface.withValues(alpha: 0.54))),
- ],
- ),
+ child: LayoutBuilder(
+ builder: (context, lc) {
+ return FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.center,
+ child: SizedBox(
+ width: lc.maxWidth - 56,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(height: 18),
+ CardPlaybackControls(
+ player: widget.player,
+ accent: accent,
+ isActive: _isActive,
+ isStarting: _isStarting,
+ onStart: _startPlayback,
+ itemId: _itemId,
+ ),
+ const SizedBox(height: 24),
+ // ── Button grid ──
+ Row(children: [
+ Expanded(child: _buildCardButton(_buttonOrder[0], accent, tt)),
+ const SizedBox(width: 10),
+ Expanded(child: _buildCardButton(_buttonOrder[1], accent, tt)),
+ ]),
+ const SizedBox(height: 14),
+ Row(children: [
+ Expanded(child: _buildCardButton(_buttonOrder[2], accent, tt)),
+ const SizedBox(width: 10),
+ Expanded(child: _buildCardButton(_buttonOrder[3], accent, tt)),
+ ]),
+ const SizedBox(height: 14),
+ // More menu / Cast controls
+ Center(
+ child: ListenableBuilder(
+ listenable: ChromecastService(),
+ builder: (context, _) {
+ final castActive = ChromecastService().isCasting && !_buttonOrder.take(4).contains('cast');
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: castActive
+ ? () => showModalBottomSheet(
+ context: context,
+ backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,
+ shape: const RoundedRectangleBorder(
+ borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
+ ),
+ builder: (_) => const CastControlSheet(),
+ )
+ : () => _showMoreMenu(context, accent, tt),
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
+ decoration: BoxDecoration(
+ color: castActive ? accent.withValues(alpha: 0.15) : cs.onSurface.withValues(alpha: 0.08),
+ borderRadius: BorderRadius.circular(22),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: castActive
+ ? [
+ Icon(Icons.cast_connected_rounded, size: 20, color: accent),
+ const SizedBox(width: 6),
+ Text('Casting', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: accent)),
+ ]
+ : [
+ Icon(Icons.more_horiz_rounded, size: 20, color: cs.onSurface.withValues(alpha: 0.54)),
+ const SizedBox(width: 6),
+ Text('More', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: cs.onSurface.withValues(alpha: 0.54))),
+ ],
+ ),
+ ),
+ );
+ },
),
- );
- },
+ ),
+ const SizedBox(height: 12),
+ ],
),
),
- const SizedBox(height: 12),
- ],
- ),
+ );
+ },
),
),
],