Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add configurable card button layouts: 1x3, 2x2, 1x5, 2x3, 3x3

Nathan Poulsonacea4724539e
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 4f7d3527..9d3ee5f2 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -66,6 +66,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
bool _showGoodreadsButton = false;
bool _loggingEnabled = false;
bool _fullScreenPlayer = false;
+ String _cardButtonLayout = 'standard';
bool _snappyTransitions = false;
String _themeMode = 'dark';
String _colorSource = 'wallpaper';
@@ -159,6 +160,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
PlayerSettings.getColorSource(), // 35
PlayerSettings.getStartScreen(), // 36
PlayerSettings.getPodcastQueueMode(), // 37
+ PlayerSettings.getCardButtonLayout(), // 38
]);
final s = results[0] as AutoRewindSettings;
final speed = results[1] as double;
@@ -198,6 +200,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
final colorSource = results[35] as String;
final startScreen = results[36] as int;
final podcastQueueMode = results[37] as String;
+ final cardBtnLayout = results[38] as String;
if (mounted) setState(() {
_rewindSettings = s;
_defaultSpeed = speed;
@@ -241,6 +244,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_localServerController.text = localUrl;
_disableAudioFocus = audioFocusOff;
_startScreen = startScreen;
+ _cardButtonLayout = cardBtnLayout;
_loaded = true;
});
}
@@ -734,6 +738,37 @@ class _SettingsScreenState extends State<SettingsScreen> {
} : null,
),
const Divider(height: 1, indent: 16, endIndent: 16),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Text('Button layout', style: tt.bodyMedium?.copyWith(color: cs.onSurface)),
+ const SizedBox(height: 4),
+ Text('How action buttons are arranged on the card',
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ const SizedBox(height: 8),
+ SizedBox(width: double.infinity, child: SegmentedButton<String>(
+ showSelectedIcon: false,
+ style: ButtonStyle(
+ visualDensity: VisualDensity.compact,
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ padding: WidgetStatePropertyAll(EdgeInsets.symmetric(horizontal: 8, vertical: 6)),
+ ),
+ segments: const [
+ ButtonSegment(value: 'compact', label: Text('1x3', style: TextStyle(fontSize: 13))),
+ ButtonSegment(value: 'standard', label: Text('2x2', style: TextStyle(fontSize: 13))),
+ ButtonSegment(value: 'row', label: Text('1x5', style: TextStyle(fontSize: 13))),
+ ButtonSegment(value: 'expanded', label: Text('2x3', style: TextStyle(fontSize: 13))),
+ ButtonSegment(value: 'full', label: Text('3x3', style: TextStyle(fontSize: 13))),
+ ],
+ selected: {_cardButtonLayout},
+ onSelectionChanged: _loaded ? (v) {
+ setState(() => _cardButtonLayout = v.first);
+ PlayerSettings.setCardButtonLayout(v.first);
+ } : null,
+ )),
+ ]),
+ ),
+ const Divider(height: 1, indent: 16, endIndent: 16),
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
@@ -1639,6 +1674,18 @@ class _SettingsScreenState extends State<SettingsScreen> {
mode: LaunchMode.externalApplication),
),
const Divider(height: 1, indent: 16, endIndent: 16),
+ ListTile(
+ leading: Icon(Icons.discord, color: cs.onSurfaceVariant),
+ title: const Text('Join Discord'),
+ subtitle: Text('Community, support, and updates',
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ trailing: Icon(Icons.open_in_new_rounded,
+ size: 18, color: cs.onSurfaceVariant),
+ onTap: () => launchUrl(
+ Uri.parse('https://discord.gg/pcMJb5SM'),
+ mode: LaunchMode.externalApplication),
+ ),
+ const Divider(height: 1, indent: 16, endIndent: 16),
ListTile(
leading: Icon(Icons.email_outlined, color: cs.primary),
title: const Text('Contact'),
diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dart
index 76447110..a5e68ff5 100644
--- a/lib/widgets/absorbing_card.dart
+++ b/lib/widgets/absorbing_card.dart
@@ -44,6 +44,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
ui.Image? _blurredCover; // Precached blurred background
String? _blurredCoverUrl; // URL the blur was built from
List<String> _buttonOrder = PlayerSettings.defaultButtonOrder;
+ String _buttonLayout = PlayerSettings.defaultButtonLayout;
bool _autoRemoveFinished = false;
@override
@@ -132,6 +133,9 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
PlayerSettings.getCardButtonOrder().then((o) {
if (mounted && o.join(',') != _buttonOrder.join(',')) setState(() => _buttonOrder = o);
});
+ PlayerSettings.getCardButtonLayout().then((l) {
+ if (mounted && l != _buttonLayout) setState(() => _buttonLayout = l);
+ });
}
void _onDownloadChanged() { if (mounted) setState(() {}); }
@@ -706,24 +710,14 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
),
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)),
- ]),
+ ..._buildButtonGrid(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');
+ final castActive = ChromecastService().isCasting && !_buttonOrder.take(_visibleButtonCount).contains('cast');
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: castActive
@@ -937,40 +931,76 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
// ── Dynamic button builders ─────────────────────────────────
- Widget _buildCardButton(String id, Color accent, TextTheme tt, {bool large = false}) {
+ int get _visibleButtonCount => PlayerSettings.buttonCountForLayout(_buttonLayout);
+
+ List<Widget> _buildButtonGrid(Color accent, TextTheme tt) {
+ final count = _visibleButtonCount;
+ final ids = _buttonOrder.take(count).toList();
+
+ // Determine columns per row based on layout
+ int cols;
+ switch (_buttonLayout) {
+ case 'compact': cols = 3; break;
+ case 'row': cols = 5; break;
+ case 'expanded': cols = 3; break;
+ case 'full': cols = 3; break;
+ default: cols = 2; break; // standard
+ }
+
+ final compact = cols >= 5;
+ final short = cols >= 3;
+ final singleRow = count == ids.length && ids.length <= cols;
+ final rows = <Widget>[];
+ if (singleRow) rows.add(const SizedBox(height: 8));
+ for (int r = 0; r < ids.length; r += cols) {
+ if (r > 0) rows.add(const SizedBox(height: 6));
+ final end = (r + cols).clamp(0, ids.length);
+ final rowIds = ids.sublist(r, end);
+ rows.add(Row(children: [
+ for (int c = 0; c < rowIds.length; c++) ...[
+ if (c > 0) const SizedBox(width: 8),
+ Expanded(child: _buildCardButton(rowIds[c], accent, tt, compact: compact, short: short)),
+ ],
+ ]));
+ }
+ if (singleRow) rows.add(const SizedBox(height: 6));
+ return rows;
+ }
+
+ Widget _buildCardButton(String id, Color accent, TextTheme tt, {bool large = false, bool compact = false, bool short = false}) {
switch (id) {
case 'chapters':
return CardWideButton(
icon: Icons.list_rounded, label: 'Chapters',
- accent: accent, isActive: _isPlaybackActive, large: large,
+ accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,
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),
+ accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,
+ child: CardSpeedButtonInline(player: widget.player, accent: accent, isActive: _isActive, large: large, compact: compact, itemId: _itemId),
);
case 'sleep':
return CardWideButton(
- icon: Icons.bedtime_outlined, label: 'Sleep Timer',
- accent: accent, isActive: _isPlaybackActive, large: large,
- child: CardSleepButtonInline(accent: accent, isActive: _isPlaybackActive, large: large),
+ icon: Icons.bedtime_outlined, label: short ? 'Sleep' : 'Sleep Timer',
+ accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,
+ child: CardSleepButtonInline(accent: accent, isActive: _isPlaybackActive, large: large, compact: compact),
);
case 'bookmarks':
return CardWideButton(
icon: Icons.bookmark_outline_rounded, label: 'Bookmarks',
- accent: accent, isActive: _isPlaybackActive, large: large,
+ accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,
child: CardBookmarkButtonInline(
player: widget.player, accent: accent,
- isActive: _isActive, itemId: _itemId, large: large,
+ isActive: _isActive, itemId: _itemId, large: large, compact: compact, short: short,
),
);
case 'details':
return CardWideButton(
icon: (_episodeId != null || _isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,
- label: (_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details',
- accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ label: short ? 'Details' : ((_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details'),
+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () {
if (_episodeId != null || _isPodcastEpisode) {
final episode = _recentEpisode ?? {
@@ -986,8 +1016,8 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
);
case 'equalizer':
return CardWideButton(
- icon: Icons.equalizer_rounded, label: 'Equalizer',
- accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ icon: Icons.equalizer_rounded, label: compact ? 'EQ' : 'Equalizer',
+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () => showEqualizerSheet(context, accent),
);
case 'cast':
@@ -996,7 +1026,9 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
builder: (_, __) {
final cast = ChromecastService();
final String castLabel;
- if (cast.isCasting && cast.castingItemId == _itemId) {
+ if (compact || short) {
+ castLabel = cast.isConnected ? 'Casting' : 'Cast';
+ } else if (cast.isCasting && cast.castingItemId == _itemId) {
castLabel = 'Casting to ${cast.connectedDeviceName ?? "device"}';
} else if (cast.isConnected) {
castLabel = 'Cast to ${cast.connectedDeviceName ?? "device"}';
@@ -1005,33 +1037,33 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
}
return CardWideButton(
icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,
- label: castLabel, accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ label: castLabel, accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () => _handleCastTap(context, accent),
);
},
);
case 'history':
return CardWideButton(
- icon: Icons.history_rounded, label: 'Playback History',
- accent: accent, isActive: _isActive, large: large,
+ icon: Icons.history_rounded, label: (compact || short) ? 'History' : 'Playback History',
+ accent: accent, isActive: _isActive, large: large, compact: compact,
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,
+ icon: Icons.remove_circle_outline_rounded, label: (compact || short) ? 'Remove' : 'Remove from Absorbing',
+ accent: Colors.red.shade300, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: _removeFromAbsorbing,
);
case 'car':
return CardWideButton(
icon: Icons.directions_car_rounded, label: 'Car Mode',
- accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () => _openCarMode(context),
);
case 'notes':
return CardWideButton(
icon: Icons.note_rounded, label: 'Notes',
- accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () => _showNotes(context, accent),
);
default:
@@ -1382,7 +1414,8 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
}
void _showMoreMenu(BuildContext context, Color accent, TextTheme tt) {
- final overflowIds = _buttonOrder.skip(4).toList();
+ final count = _visibleButtonCount;
+ final overflowIds = _buttonOrder.skip(count).toList();
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
@@ -1390,6 +1423,7 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
builder: (ctx) => MoreMenuSheet(
overflowIds: overflowIds,
allIds: _buttonOrder,
+ visibleCount: count,
accent: accent,
buildItem: (id) => _buildMoreMenuItem(id, accent, tt, ctx),
onReorder: (newOrder) {
diff --git a/lib/widgets/card_buttons.dart b/lib/widgets/card_buttons.dart
index f4fd84b1..137fb036 100644
--- a/lib/widgets/card_buttons.dart
+++ b/lib/widgets/card_buttons.dart
@@ -39,6 +39,7 @@ class CardWideButton extends StatelessWidget {
final bool isActive;
final bool alwaysEnabled;
final bool large;
+ final bool compact;
final VoidCallback? onTap;
final Widget? child; // if provided, renders child instead (for stateful buttons)
@@ -46,7 +47,7 @@ class CardWideButton extends StatelessWidget {
super.key,
required this.icon, required this.label,
required this.accent, required this.isActive,
- this.alwaysEnabled = false, this.large = false,
+ this.alwaysEnabled = false, this.large = false, this.compact = false,
this.onTap, this.child,
});
@@ -54,25 +55,31 @@ class CardWideButton extends StatelessWidget {
if (child != null) return child!;
final cs = Theme.of(context).colorScheme;
final enabled = isActive || alwaysEnabled;
+ final iconSize = compact ? 13.0 : (large ? 18.0 : 15.0);
+ final fontSize = compact ? 10.0 : (large ? 13.0 : 11.0);
+ final vPad = compact ? 8.0 : (large ? 14.0 : 10.0);
+ final radius = compact ? 10.0 : (large ? 14.0 : 12.0);
return GestureDetector(
onTap: enabled ? onTap : () => showInactiveToast(context),
child: Container(
- padding: EdgeInsets.symmetric(vertical: large ? 14 : 10),
+ padding: EdgeInsets.symmetric(vertical: vPad),
decoration: BoxDecoration(
color: cs.onSurface.withValues(alpha: 0.06),
- borderRadius: BorderRadius.circular(large ? 14 : 12),
+ borderRadius: BorderRadius.circular(radius),
border: Border.all(color: cs.onSurface.withValues(alpha: 0.08)),
),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(icon, size: large ? 18 : 15, color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24)),
- const SizedBox(width: 6),
- Flexible(child: Text(label, overflow: TextOverflow.ellipsis, style: TextStyle(
- color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24),
- fontSize: large ? 13 : 11, fontWeight: FontWeight.w500))),
- ],
- ),
+ child: compact
+ ? Center(child: Icon(icon, size: iconSize, color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24)))
+ : Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Icon(icon, size: iconSize, color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24)),
+ const SizedBox(width: 6),
+ Flexible(child: Text(label, overflow: TextOverflow.ellipsis, style: TextStyle(
+ color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24),
+ fontSize: fontSize, fontWeight: FontWeight.w500))),
+ ],
+ ),
),
);
}
@@ -124,7 +131,8 @@ class CardSleepButtonInline extends StatelessWidget {
final Color accent;
final bool isActive;
final bool large;
- const CardSleepButtonInline({super.key, required this.accent, required this.isActive, this.large = false});
+ final bool compact;
+ const CardSleepButtonInline({super.key, required this.accent, required this.isActive, this.large = false, this.compact = false});
@override Widget build(BuildContext context) {
return ListenableBuilder(
@@ -145,19 +153,24 @@ class CardSleepButtonInline extends StatelessWidget {
} else if (active) {
label = '${sleep.chaptersRemaining} ch left';
} else {
- label = 'Sleep Timer';
+ label = compact ? 'Sleep' : 'Sleep Timer';
}
+ final h = compact ? 30.0 : (large ? 48.0 : 36.0);
+ final iconSz = compact ? 13.0 : (large ? 20.0 : 16.0);
+ final fontSize = compact ? 10.0 : (large ? (active && isTime ? 15.0 : 14.0) : (active && isTime ? 13.0 : 12.0));
+ final radius = compact ? 10.0 : (large ? 16.0 : 14.0);
+
return GestureDetector(
onTap: isActive ? () {
showSleepTimerSheet(context, accent);
} : () => showInactiveToast(context),
child: Container(
- height: large ? 48 : 36,
+ height: h,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: active ? accent.withValues(alpha: 0.1) : cs.onSurface.withValues(alpha: 0.06),
- borderRadius: BorderRadius.circular(large ? 16 : 14),
+ borderRadius: BorderRadius.circular(radius),
border: Border.all(color: active ? accent.withValues(alpha: 0.3) : cs.onSurface.withValues(alpha: 0.08)),
),
child: Stack(children: [
@@ -167,24 +180,27 @@ class CardSleepButtonInline extends StatelessWidget {
child: Container(
decoration: BoxDecoration(
color: accent.withValues(alpha: 0.15),
- borderRadius: BorderRadius.circular(large ? 15 : 13),
+ borderRadius: BorderRadius.circular(radius - 1),
),
),
),
- Center(child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(Icons.bedtime_outlined, size: large ? 20 : 16,
- color: active ? accent : (isActive ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24))),
- const SizedBox(width: 8),
- Text(label, style: TextStyle(
- color: active ? accent : (isActive ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24)),
- fontSize: large ? (active && isTime ? 15 : 14) : (active && isTime ? 13 : 12),
- fontWeight: active ? FontWeight.w700 : FontWeight.w500,
- fontFeatures: active && isTime ? const [FontFeature.tabularFigures()] : null,
+ Center(child: compact && !active
+ ? Icon(Icons.bedtime_outlined, size: iconSz,
+ color: isActive ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24))
+ : Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Icon(Icons.bedtime_outlined, size: iconSz,
+ color: active ? accent : (isActive ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24))),
+ SizedBox(width: compact ? 4 : 8),
+ Flexible(child: Text(label, overflow: TextOverflow.ellipsis, style: TextStyle(
+ color: active ? accent : (isActive ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24)),
+ fontSize: fontSize,
+ fontWeight: active ? FontWeight.w700 : FontWeight.w500,
+ fontFeatures: active && isTime ? const [FontFeature.tabularFigures()] : null,
+ ))),
+ ],
)),
- ],
- )),
]),
),
);
@@ -200,7 +216,9 @@ class CardBookmarkButtonInline extends StatefulWidget {
final bool isActive;
final String itemId;
final bool large;
- const CardBookmarkButtonInline({super.key, required this.player, required this.accent, required this.isActive, required this.itemId, this.large = false});
+ final bool compact;
+ final bool short;
+ const CardBookmarkButtonInline({super.key, required this.player, required this.accent, required this.isActive, required this.itemId, this.large = false, this.compact = false, this.short = false});
@override State<CardBookmarkButtonInline> createState() => _CardBookmarkButtonInlineState();
}
@@ -214,29 +232,39 @@ class _CardBookmarkButtonInlineState extends State<CardBookmarkButtonInline> {
@override Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
+ final cp = widget.compact;
final lg = widget.large;
final enabled = widget.isActive || _isCasting;
+ final iconSz = cp ? 13.0 : (lg ? 22.0 : 18.0);
+ final fontSize = cp ? 10.0 : (lg ? 14.0 : 12.0);
+ final vPad = cp ? 6.0 : (lg ? 12.0 : 8.0);
+ final radius = cp ? 10.0 : (lg ? 14.0 : 12.0);
+ final sh = widget.short;
+ final label = cp ? (_count > 0 ? '$_count' : 'Bookmark') : sh ? 'Bookmarks' : (_count > 0 ? 'Bookmarks ($_count)' : 'Bookmark');
return GestureDetector(
onTap: enabled ? () => _showBookmarks(context) : () => showInactiveToast(context),
onLongPress: enabled ? () => _quickAdd(context) : null,
child: Container(
- padding: EdgeInsets.symmetric(vertical: lg ? 12 : 8),
+ padding: EdgeInsets.symmetric(vertical: vPad),
decoration: BoxDecoration(
color: cs.onSurface.withValues(alpha: 0.06),
- borderRadius: BorderRadius.circular(lg ? 14 : 12),
+ borderRadius: BorderRadius.circular(radius),
border: Border.all(color: cs.onSurface.withValues(alpha: 0.08)),
),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(Icons.bookmark_outline_rounded, size: lg ? 22 : 18,
- color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24)),
- const SizedBox(width: 8),
- Text(_count > 0 ? 'Bookmarks ($_count)' : 'Bookmark', style: TextStyle(
- color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24),
- fontSize: lg ? 14 : 12, fontWeight: FontWeight.w500)),
- ],
- ),
+ child: cp
+ ? Center(child: Icon(Icons.bookmark_outline_rounded, size: iconSz,
+ color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24)))
+ : Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Icon(Icons.bookmark_outline_rounded, size: iconSz,
+ color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24)),
+ const SizedBox(width: 8),
+ Flexible(child: Text(label, overflow: TextOverflow.ellipsis, style: TextStyle(
+ color: enabled ? cs.onSurfaceVariant : cs.onSurface.withValues(alpha: 0.24),
+ fontSize: fontSize, fontWeight: FontWeight.w500))),
+ ],
+ ),
),
);
}
@@ -284,12 +312,17 @@ class CardSpeedButtonInline extends StatelessWidget {
final Color accent;
final bool isActive;
final bool large;
+ final bool compact;
final String? itemId;
- const CardSpeedButtonInline({super.key, required this.player, required this.accent, required this.isActive, this.large = false, this.itemId});
+ const CardSpeedButtonInline({super.key, required this.player, required this.accent, required this.isActive, this.large = false, this.compact = false, this.itemId});
@override Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
final cast = ChromecastService();
+ final h = compact ? 30.0 : (large ? 48.0 : 36.0);
+ final iconSz = compact ? 13.0 : (large ? 20.0 : 16.0);
+ final fontSize = compact ? 10.0 : (large ? 15.0 : 13.0);
+ final radius = compact ? 10.0 : (large ? 16.0 : 14.0);
return ListenableBuilder(
listenable: cast,
builder: (context, _) {
@@ -303,23 +336,27 @@ class CardSpeedButtonInline extends StatelessWidget {
builder: (ctx) => CardSpeedSheet(player: player, accent: accent, itemId: itemId));
} : () => showInactiveToast(context),
child: Container(
- height: large ? 48 : 36,
+ height: h,
decoration: BoxDecoration(
color: cs.onSurface.withValues(alpha: 0.06),
- borderRadius: BorderRadius.circular(large ? 16 : 14),
+ borderRadius: BorderRadius.circular(radius),
border: Border.all(color: cs.onSurface.withValues(alpha: 0.08)),
),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(Icons.speed_rounded, size: large ? 20 : 16,
- color: enabledNow ? accent : cs.onSurface.withValues(alpha: 0.24)),
- const SizedBox(width: 8),
- Text('${speedNow.toStringAsFixed(2)}x', style: TextStyle(
+ child: compact
+ ? Center(child: Text('${speedNow.toStringAsFixed(1)}x', style: TextStyle(
color: enabledNow ? accent : cs.onSurface.withValues(alpha: 0.24),
- fontSize: large ? 15 : 13, fontWeight: FontWeight.w700)),
- ],
- ),
+ fontSize: fontSize, fontWeight: FontWeight.w700)))
+ : Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Icon(Icons.speed_rounded, size: iconSz,
+ color: enabledNow ? accent : cs.onSurface.withValues(alpha: 0.24)),
+ const SizedBox(width: 8),
+ Text('${speedNow.toStringAsFixed(2)}x', style: TextStyle(
+ color: enabledNow ? accent : cs.onSurface.withValues(alpha: 0.24),
+ fontSize: fontSize, fontWeight: FontWeight.w700)),
+ ],
+ ),
),
);
},
@@ -619,10 +656,11 @@ class _SimpleBookmarkSheetState extends State<SimpleBookmarkSheet> {
class MoreMenuSheet extends StatefulWidget {
final List<String> overflowIds;
final List<String> allIds;
+ final int visibleCount;
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});
+ const MoreMenuSheet({super.key, required this.overflowIds, required this.allIds, this.visibleCount = 4, required this.accent, required this.buildItem, required this.onReorder});
@override State<MoreMenuSheet> createState() => _MoreMenuSheetState();
}
@@ -764,8 +802,8 @@ class _MoreMenuSheetState extends State<MoreMenuSheet> {
final def = buttonDefById(id);
if (def == null) return SizedBox.shrink(key: ValueKey(id));
- final isOnCard = i < 4;
- final showDivider = i == 4;
+ final isOnCard = i < widget.visibleCount;
+ final showDivider = i == widget.visibleCount;
return Column(
key: ValueKey(id),
diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dart
index a79f6269..af80cbed 100644
--- a/lib/widgets/expanded_card.dart
+++ b/lib/widgets/expanded_card.dart
@@ -89,6 +89,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
bool _wasPlaying = false;
bool _isPopping = false; // Prevent double-pop and setState during exit
List<String> _buttonOrder = PlayerSettings.defaultButtonOrder;
+ String _buttonLayout = PlayerSettings.defaultButtonLayout;
bool _autoRemoveFinished = false;
// Our own route, captured for popUntil when modals are stacked above us
@@ -184,6 +185,9 @@ class _ExpandedCardState extends State<ExpandedCard> {
PlayerSettings.getCardButtonOrder().then((o) {
if (mounted && o.join(',') != _buttonOrder.join(',')) setState(() => _buttonOrder = o);
});
+ PlayerSettings.getCardButtonLayout().then((l) {
+ if (mounted && l != _buttonLayout) setState(() => _buttonLayout = l);
+ });
}
void _loadWhenFinished() {
@@ -769,24 +773,14 @@ class _ExpandedCardState extends State<ExpandedCard> {
),
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)),
- ]),
+ ..._buildButtonGrid(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');
+ final castActive = ChromecastService().isCasting && !_buttonOrder.take(_visibleButtonCount).contains('cast');
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: castActive
@@ -1011,41 +1005,76 @@ class _ExpandedCardState extends State<ExpandedCard> {
// ── Dynamic button builders ─────────────────────────────────
- Widget _buildCardButton(String id, Color accent, TextTheme tt) {
+ int get _visibleButtonCount => PlayerSettings.buttonCountForLayout(_buttonLayout);
+
+ List<Widget> _buildButtonGrid(Color accent, TextTheme tt) {
+ final count = _visibleButtonCount;
+ final ids = _buttonOrder.take(count).toList();
+
+ int cols;
+ switch (_buttonLayout) {
+ case 'compact': cols = 3; break;
+ case 'row': cols = 5; break;
+ case 'expanded': cols = 3; break;
+ case 'full': cols = 3; break;
+ default: cols = 2; break;
+ }
+
+ final compact = cols >= 5;
+ final short = cols >= 3;
+ final singleRow = count == ids.length && ids.length <= cols;
+ final rows = <Widget>[];
+ if (singleRow) rows.add(const SizedBox(height: 8));
+ for (int r = 0; r < ids.length; r += cols) {
+ if (r > 0) rows.add(const SizedBox(height: 14));
+ final end = (r + cols).clamp(0, ids.length);
+ final rowIds = ids.sublist(r, end);
+ rows.add(Row(children: [
+ for (int c = 0; c < rowIds.length; c++) ...[
+ if (c > 0) const SizedBox(width: 10),
+ Expanded(child: _buildCardButton(rowIds[c], accent, tt, compact: compact, short: short)),
+ ],
+ ]));
+ }
+ if (singleRow) rows.add(const SizedBox(height: 6));
+ return rows;
+ }
+
+ Widget _buildCardButton(String id, Color accent, TextTheme tt, {bool compact = false, bool short = false}) {
const large = true;
switch (id) {
case 'chapters':
return CardWideButton(
icon: Icons.list_rounded, label: 'Chapters',
- accent: accent, isActive: _isPlaybackActive, large: large,
+ accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,
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),
+ accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,
+ child: CardSpeedButtonInline(player: widget.player, accent: accent, isActive: _isActive, large: large, compact: compact, itemId: _itemId),
);
case 'sleep':
return CardWideButton(
- icon: Icons.bedtime_outlined, label: 'Sleep Timer',
- accent: accent, isActive: _isPlaybackActive, large: large,
- child: CardSleepButtonInline(accent: accent, isActive: _isPlaybackActive, large: large),
+ icon: Icons.bedtime_outlined, label: short ? 'Sleep' : 'Sleep Timer',
+ accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,
+ child: CardSleepButtonInline(accent: accent, isActive: _isPlaybackActive, large: large, compact: compact),
);
case 'bookmarks':
return CardWideButton(
icon: Icons.bookmark_outline_rounded, label: 'Bookmarks',
- accent: accent, isActive: _isPlaybackActive, large: large,
+ accent: accent, isActive: _isPlaybackActive, large: large, compact: compact,
child: CardBookmarkButtonInline(
player: widget.player, accent: accent,
- isActive: _isActive, itemId: _itemId, large: large,
+ isActive: _isActive, itemId: _itemId, large: large, compact: compact, short: short,
),
);
case 'details':
return CardWideButton(
icon: (_episodeId != null || _isPodcastEpisode) ? Icons.podcasts_rounded : Icons.info_outline_rounded,
- label: (_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details',
- accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ label: short ? 'Details' : ((_episodeId != null || _isPodcastEpisode) ? 'Episode Details' : 'Book Details'),
+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () {
if (_episodeId != null || _isPodcastEpisode) {
final episode = _recentEpisode ?? {
@@ -1061,8 +1090,8 @@ class _ExpandedCardState extends State<ExpandedCard> {
);
case 'equalizer':
return CardWideButton(
- icon: Icons.equalizer_rounded, label: 'Equalizer',
- accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ icon: Icons.equalizer_rounded, label: compact ? 'EQ' : 'Equalizer',
+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () => showEqualizerSheet(context, accent),
);
case 'cast':
@@ -1071,7 +1100,9 @@ class _ExpandedCardState extends State<ExpandedCard> {
builder: (_, __) {
final cast = ChromecastService();
final String castLabel;
- if (cast.isCasting && cast.castingItemId == _itemId) {
+ if (compact || short) {
+ castLabel = cast.isConnected ? 'Casting' : 'Cast';
+ } else if (cast.isCasting && cast.castingItemId == _itemId) {
castLabel = 'Casting to ${cast.connectedDeviceName ?? "device"}';
} else if (cast.isConnected) {
castLabel = 'Cast to ${cast.connectedDeviceName ?? "device"}';
@@ -1080,33 +1111,33 @@ class _ExpandedCardState extends State<ExpandedCard> {
}
return CardWideButton(
icon: cast.isConnected ? Icons.cast_connected_rounded : Icons.cast_rounded,
- label: castLabel, accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ label: castLabel, accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () => _handleCastTap(context, accent),
);
},
);
case 'history':
return CardWideButton(
- icon: Icons.history_rounded, label: 'Playback History',
- accent: accent, isActive: _isActive, large: large,
+ icon: Icons.history_rounded, label: (compact || short) ? 'History' : 'Playback History',
+ accent: accent, isActive: _isActive, large: large, compact: compact,
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,
+ icon: Icons.remove_circle_outline_rounded, label: (compact || short) ? 'Remove' : 'Remove from Absorbing',
+ accent: Colors.red.shade300, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () { _removeFromAbsorbing(); _dismissExpanded(); },
);
case 'car':
return CardWideButton(
icon: Icons.directions_car_rounded, label: 'Car Mode',
- accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () => _openCarMode(context),
);
case 'notes':
return CardWideButton(
icon: Icons.note_rounded, label: 'Notes',
- accent: accent, isActive: true, alwaysEnabled: true, large: large,
+ accent: accent, isActive: true, alwaysEnabled: true, large: large, compact: compact,
onTap: () => _showNotes(context, accent),
);
default:
@@ -1447,7 +1478,8 @@ class _ExpandedCardState extends State<ExpandedCard> {
}
void _showMoreMenu(BuildContext context, Color accent, TextTheme tt) {
- final overflowIds = _buttonOrder.skip(4).toList();
+ final count = _visibleButtonCount;
+ final overflowIds = _buttonOrder.skip(count).toList();
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
@@ -1455,6 +1487,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
builder: (ctx) => MoreMenuSheet(
overflowIds: overflowIds,
allIds: _buttonOrder,
+ visibleCount: count,
accent: accent,
buildItem: (id) => _buildMoreMenuItem(id, accent, tt, ctx),
onReorder: (newOrder) {