Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Support landscape mode

Barnabasa8e8119b9b5d
diff --git a/lib/main.dart b/lib/main.dart
index 1bdc8318..b8b8f225 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -113,6 +113,8 @@ void main() async {
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
+ DeviceOrientation.landscapeLeft,
+ DeviceOrientation.landscapeRight,
]).timeout(const Duration(seconds: 2));
} catch (_) {}
diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dart
index 073a7a64..b707b743 100644
--- a/lib/widgets/absorbing_card.dart
+++ b/lib/widgets/absorbing_card.dart
@@ -522,10 +522,11 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
builder: (context, cardConstraints) {
final textScale = MediaQuery.textScalerOf(context).scale(1.0).clamp(1.0, 1.5);
final compact = cardConstraints.maxHeight < 600 * textScale;
- return Column(
- children: [
- // ── Stats row (fades when edge bar expands) ──
- ValueListenableBuilder<bool>(
+ // In landscape the card is wider than tall — switch to a two-pane
+ // layout with the cover on the left and everything else on the right.
+ final wide = cardConstraints.maxWidth > cardConstraints.maxHeight;
+
+ final statsRow = ValueListenableBuilder<bool>(
valueListenable: _edgeBarExpanded,
builder: (_, expanded, child) => AnimatedOpacity(
opacity: expanded ? 0.0 : 1.0,
@@ -586,9 +587,9 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
},
),
),
- ),
- // ── Cover with title/author/chapter overlaid ──
- Expanded(child: Padding(
+ );
+
+ final coverArea = Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: ListenableBuilder(
listenable: Listenable.merge([ChromecastService(), widget.player]),
@@ -762,17 +763,14 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
},
),
),
- ),
- ),
- // ── Chapter pill-scrubber ──
- SizedBox(height: compact ? 6 : 10),
- Padding(
+ );
+
+ final scrubberBar = 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 ──
- SizedBox(height: compact ? 6 : 10),
- Padding(
+ );
+
+ final controlsRow = Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: CardPlaybackControls(
player: widget.player,
@@ -783,19 +781,19 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
itemId: _itemId,
showPlayButton: !_coverPlayButton,
),
- ),
- SizedBox(height: compact ? 6 : 12),
- // ── Button grid + more menu ──
- MediaQuery(
+ );
+
+ final buttonGrid = MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaler: TextScaler.noScaling,
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
- child: FittedBox(
+ child: LayoutBuilder(
+ builder: (context, buttonsConstraints) => FittedBox(
fit: BoxFit.scaleDown,
child: SizedBox(
- width: cardConstraints.maxWidth - 40,
+ width: buttonsConstraints.maxWidth - 40,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
@@ -841,9 +839,42 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
),
),
),
+ ),
),
- ),
+ );
+
+ if (wide) {
+ return Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Expanded(child: coverArea),
+ Expanded(child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ statsRow,
+ SizedBox(height: compact ? 6 : 10),
+ scrubberBar,
+ SizedBox(height: compact ? 6 : 10),
+ controlsRow,
+ SizedBox(height: compact ? 6 : 12),
+ buttonGrid,
+ ],
+ )),
],
+ );
+ }
+
+ return Column(
+ children: [
+ statsRow,
+ Expanded(child: coverArea),
+ SizedBox(height: compact ? 6 : 10),
+ scrubberBar,
+ SizedBox(height: compact ? 6 : 10),
+ controlsRow,
+ SizedBox(height: compact ? 6 : 12),
+ buttonGrid,
+ ],
);
}),
// Edge progress bar (thin strip at top of card)
diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dart
index eb6eeb86..525299a8 100644
--- a/lib/widgets/expanded_card.dart
+++ b/lib/widgets/expanded_card.dart
@@ -581,10 +581,10 @@ class _ExpandedCardState extends State<ExpandedCard> {
child: LayoutBuilder(
builder: (context, outerConstraints) {
final compact = outerConstraints.maxHeight < 600;
- return Column(
- children: [
- // ── Stats row ──
- Padding(
+ // Landscape: split into left (cover) + right (controls/info).
+ final wide = outerConstraints.maxWidth > outerConstraints.maxHeight;
+
+ final statsRow = Padding(
padding: EdgeInsets.fromLTRB(24, compact ? 4 : 12, 24, 0),
child: Center(
child: Text('${(bookProgress * 100).clamp(0, 100).toStringAsFixed(1)}%',
@@ -595,16 +595,14 @@ class _ExpandedCardState extends State<ExpandedCard> {
shadows: [Shadow(color: isDark ? Colors.black.withValues(alpha: 0.6) : Colors.white.withValues(alpha: 0.6), blurRadius: 4)],
)),
),
- ),
- // ── Book progress bar ──
- Padding(
+ );
+
+ 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: (!_isPodcastEpisode || _chapters.isNotEmpty) && (!lib.isPodcastLibrary || _chapters.isNotEmpty), showChapterBar: false, itemId: _itemId),
- ),
- SizedBox(height: compact ? 4 : 16),
- // ── Cover art (larger — 90% width) ──
- Expanded(
- child: Padding(
+ );
+
+ final coverArea = Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: ListenableBuilder(
listenable: ChromecastService(),
@@ -778,16 +776,14 @@ class _ExpandedCardState extends State<ExpandedCard> {
},
),
),
- ),
- ),
- SizedBox(height: compact ? 6 : 24),
- // ── Chapter scrubber ──
- Padding(
+ );
+
+ final chapterScrubber = 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),
- ),
- // ── Controls + buttons ──
- MediaQuery(
+ );
+
+ final controlsAndButtons = MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaler: TextScaler.noScaling,
),
@@ -808,11 +804,9 @@ class _ExpandedCardState extends State<ExpandedCard> {
playButtonSize: 70,
),
SizedBox(height: compact ? 8 : 24),
- // ── Button grid ──
..._buildButtonGrid(accent, tt),
SizedBox(height: compact ? 4 : 14),
if (!_moreInline) ...[
- // More menu / Cast controls
Center(
child: ListenableBuilder(
listenable: ChromecastService(),
@@ -851,9 +845,38 @@ class _ExpandedCardState extends State<ExpandedCard> {
],
),
),
- ),
- ],
- );
+ );
+
+ if (wide) {
+ return Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Expanded(child: coverArea),
+ Expanded(child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ statsRow,
+ bookProgressBar,
+ SizedBox(height: compact ? 4 : 16),
+ chapterScrubber,
+ controlsAndButtons,
+ ],
+ )),
+ ],
+ );
+ }
+
+ return Column(
+ children: [
+ statsRow,
+ bookProgressBar,
+ SizedBox(height: compact ? 4 : 16),
+ Expanded(child: coverArea),
+ SizedBox(height: compact ? 6 : 24),
+ chapterScrubber,
+ controlsAndButtons,
+ ],
+ );
}),
),
],