Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Make the web app feel at home on desktop and fix browser interactions

Barnabas9f4971a9b80d
diff --git a/lib/screens/absorbing_screen.dart b/lib/screens/absorbing_screen.dart
index bf87dfd8..c8776eba 100644
--- a/lib/screens/absorbing_screen.dart
+++ b/lib/screens/absorbing_screen.dart
@@ -23,6 +23,14 @@ import '../l10n/app_localizations.dart';
import '../services/wording.dart';
import '../utils/desktop_workspace.dart';
+const double kAbsorbingQueuePaneBreakpoint = 1180;
+
+bool shouldEmbedAbsorbingQueue(double paneWidth) =>
+ paneWidth >= kAbsorbingQueuePaneBreakpoint;
+
+double absorbingQueuePaneWidth(double paneWidth) =>
+ (paneWidth * 0.32).clamp(340.0, 400.0).toDouble();
+
class AbsorbingScreen extends StatefulWidget {
const AbsorbingScreen({super.key});
@@ -659,6 +667,8 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
child: SafeArea(
child: Builder(builder: (context) {
final desktopWorkspace = isDesktopWorkspace(context);
+ final embedDesktopQueue = desktopWorkspace &&
+ shouldEmbedAbsorbingQueue(MediaQuery.sizeOf(context).width);
final offlineIcon = OfflineStatusIcon(
onTapWhenOnline: () {
lib.setManualOffline(true);
@@ -720,7 +730,8 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
: Icon(Icons.refresh_rounded, size: 18, color: muted),
),
),
- if (!desktopWorkspace && books.isNotEmpty) ...[
+ if ((!desktopWorkspace || !embedDesktopQueue) &&
+ books.isNotEmpty) ...[
const SizedBox(width: 8),
GestureDetector(
onTap: () => _showReorderSheet(context, lib, books),
@@ -806,8 +817,12 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
strokeWidth: 2,
color: cs.onSurface.withValues(alpha: 0.24)))
: LayoutBuilder(builder: (context, constraints) {
- final queueWidth =
- (constraints.maxWidth * 0.34).clamp(340.0, 420.0);
+ final showQueue = shouldEmbedAbsorbingQueue(
+ constraints.maxWidth,
+ );
+ final queueWidth = absorbingQueuePaneWidth(
+ constraints.maxWidth,
+ );
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -835,30 +850,33 @@ class _AbsorbingScreenState extends State<AbsorbingScreen> {
),
),
),
- VerticalDivider(
- width: 1,
- thickness: 1,
- color:
- cs.outlineVariant.withValues(alpha: 0.45),
- ),
- SizedBox(
- width: queueWidth,
- child: _AbsorbingQueuePanel(
- embedded: true,
- keys: books.map(_absorbingKey).toList(),
- books: books,
- lib: lib,
- scrollController:
- _desktopQueueScrollController,
- absorbingKeyFn: _absorbingKey,
- queueMode: _queueMode,
- isMerged: _mergeLibraries,
- isPodcast: lib.isPodcastLibrary,
- currentItemId: _currentPlayerKey,
- onQueueModeChanged: (mode) =>
- _handleQueueModeChanged(lib, mode),
+ if (showQueue) ...[
+ VerticalDivider(
+ width: 1,
+ thickness: 1,
+ color: cs.outlineVariant.withValues(
+ alpha: 0.45,
+ ),
),
- ),
+ SizedBox(
+ width: queueWidth,
+ child: _AbsorbingQueuePanel(
+ embedded: true,
+ keys: books.map(_absorbingKey).toList(),
+ books: books,
+ lib: lib,
+ scrollController:
+ _desktopQueueScrollController,
+ absorbingKeyFn: _absorbingKey,
+ queueMode: _queueMode,
+ isMerged: _mergeLibraries,
+ isPodcast: lib.isPodcastLibrary,
+ currentItemId: _currentPlayerKey,
+ onQueueModeChanged: (mode) =>
+ _handleQueueModeChanged(lib, mode),
+ ),
+ ),
+ ],
],
);
}),
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dart
index e9e72f46..18566cf9 100644
--- a/lib/screens/app_shell.dart
+++ b/lib/screens/app_shell.dart
@@ -737,13 +737,16 @@ class _AppShellState extends State<AppShell>
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
- final useDesktopWorkspace = AppPlatform.isWeb &&
- constraints.maxWidth >= kDesktopWorkspaceBreakpoint;
+ final workspaceTier = AppPlatform.isWeb
+ ? workspaceLayoutTierForWidth(constraints.maxWidth)
+ : WorkspaceLayoutTier.mobile;
+ final useDesktopWorkspace =
+ workspaceTier != WorkspaceLayoutTier.mobile;
return PopScope(
canPop: false,
onPopInvokedWithResult: _handleBack,
child: useDesktopWorkspace
- ? _buildDesktopWorkspace(context)
+ ? _buildDesktopWorkspace(context, workspaceTier)
: Scaffold(
body: _buildPageStack(context),
bottomNavigationBar: _buildBottomNav(context),
@@ -804,7 +807,10 @@ class _AppShellState extends State<AppShell>
);
}
- Widget _buildDesktopWorkspace(BuildContext context) {
+ Widget _buildDesktopWorkspace(
+ BuildContext context,
+ WorkspaceLayoutTier workspaceTier,
+ ) {
final lib = context.watch<LibraryProvider>();
final podcastsShown = _podcastsShown(lib);
final destinations = _buildDestinations(context, podcastsShown);
@@ -817,6 +823,7 @@ class _AppShellState extends State<AppShell>
lib: lib,
podcastsShown: podcastsShown,
destinations: destinations,
+ workspaceTier: workspaceTier,
),
VerticalDivider(
width: 1,
@@ -862,6 +869,7 @@ class _AppShellState extends State<AppShell>
required LibraryProvider lib,
required bool podcastsShown,
required List<NavigationDestination> destinations,
+ required WorkspaceLayoutTier workspaceTier,
}) {
final theme = Theme.of(context);
final cs = theme.colorScheme;
@@ -878,16 +886,40 @@ class _AppShellState extends State<AppShell>
final serverLabel = parsedServer?.host.isNotEmpty == true
? parsedServer!.host
: serverUrl;
+ final extended = usesExtendedDesktopSidebar(workspaceTier);
+
+ void openSearch() {
+ if (podcastsShown) _syncTabLibrary(1, true);
+ _openSearch();
+ }
+
+ void openAdmin() {
+ _paneNavigatorKey.currentState?.push(
+ MaterialPageRoute<void>(builder: (_) => const AdminScreen()),
+ );
+ }
+
+ final accountAvatar = CircleAvatar(
+ radius: 18,
+ backgroundColor: cs.secondaryContainer,
+ foregroundColor: cs.onSecondaryContainer,
+ child: Text(accountName.characters.first.toUpperCase()),
+ );
return SafeArea(
child: SizedBox(
- width: 248,
+ width: desktopSidebarWidth(workspaceTier),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
- padding: const EdgeInsets.fromLTRB(20, 18, 16, 12),
+ padding: extended
+ ? const EdgeInsets.fromLTRB(20, 18, 16, 12)
+ : const EdgeInsets.fromLTRB(12, 18, 12, 12),
child: Row(
+ mainAxisAlignment: extended
+ ? MainAxisAlignment.start
+ : MainAxisAlignment.center,
children: [
Container(
width: 38,
@@ -901,14 +933,16 @@ class _AppShellState extends State<AppShell>
color: cs.onPrimaryContainer,
),
),
- const SizedBox(width: 12),
- Text(
- l.appTitle,
- style: theme.textTheme.titleMedium?.copyWith(
- fontWeight: FontWeight.w800,
- letterSpacing: 1.4,
+ if (extended) ...[
+ const SizedBox(width: 12),
+ Text(
+ l.appTitle,
+ style: theme.textTheme.titleMedium?.copyWith(
+ fontWeight: FontWeight.w800,
+ letterSpacing: 1.4,
+ ),
),
- ),
+ ],
],
),
),
@@ -934,23 +968,28 @@ class _AppShellState extends State<AppShell>
),
),
child: Row(
+ mainAxisAlignment: extended
+ ? MainAxisAlignment.start
+ : MainAxisAlignment.center,
children: [
Icon(
Icons.library_books_rounded,
size: 20,
color: cs.primary,
),
- const SizedBox(width: 10),
- Expanded(
- child: Text(
- libraryName,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: theme.textTheme.labelLarge,
+ if (extended) ...[
+ const SizedBox(width: 10),
+ Expanded(
+ child: Text(
+ libraryName,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: theme.textTheme.labelLarge,
+ ),
),
- ),
- if (lib.libraries.length > 1)
- const Icon(Icons.expand_more_rounded, size: 20),
+ if (lib.libraries.length > 1)
+ const Icon(Icons.expand_more_rounded, size: 20),
+ ],
],
),
),
@@ -959,23 +998,28 @@ class _AppShellState extends State<AppShell>
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
- child: FilledButton.tonalIcon(
- onPressed: () {
- if (podcastsShown) _syncTabLibrary(1, true);
- _openSearch();
- },
- icon: const Icon(Icons.search_rounded, size: 20),
- label: Text(l.search),
- style: FilledButton.styleFrom(
- alignment: Alignment.centerLeft,
- minimumSize: const Size.fromHeight(44),
- ),
- ),
+ child: extended
+ ? FilledButton.tonalIcon(
+ onPressed: openSearch,
+ icon: const Icon(Icons.search_rounded, size: 20),
+ label: Text(l.search),
+ style: FilledButton.styleFrom(
+ alignment: Alignment.centerLeft,
+ minimumSize: const Size.fromHeight(44),
+ ),
+ )
+ : Tooltip(
+ message: l.search,
+ child: IconButton.filledTonal(
+ onPressed: openSearch,
+ icon: const Icon(Icons.search_rounded, size: 20),
+ ),
+ ),
),
const SizedBox(height: 8),
Expanded(
child: NavigationRail(
- extended: true,
+ extended: extended,
minWidth: 72,
minExtendedWidth: 248,
groupAlignment: -1,
@@ -996,19 +1040,25 @@ class _AppShellState extends State<AppShell>
if (auth.isAdmin)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
- child: TextButton.icon(
- onPressed: () => _paneNavigatorKey.currentState?.push(
- MaterialPageRoute<void>(
- builder: (_) => const AdminScreen(),
- ),
- ),
- icon: const Icon(Icons.admin_panel_settings_outlined),
- label: Text(l.serverAdmin),
- style: TextButton.styleFrom(
- alignment: Alignment.centerLeft,
- minimumSize: const Size.fromHeight(42),
- ),
- ),
+ child: extended
+ ? TextButton.icon(
+ onPressed: openAdmin,
+ icon: const Icon(Icons.admin_panel_settings_outlined),
+ label: Text(l.serverAdmin),
+ style: TextButton.styleFrom(
+ alignment: Alignment.centerLeft,
+ minimumSize: const Size.fromHeight(42),
+ ),
+ )
+ : Tooltip(
+ message: l.serverAdmin,
+ child: IconButton(
+ onPressed: openAdmin,
+ icon: const Icon(
+ Icons.admin_panel_settings_outlined,
+ ),
+ ),
+ ),
),
Divider(
height: 1,
@@ -1016,39 +1066,41 @@ class _AppShellState extends State<AppShell>
),
Padding(
padding: const EdgeInsets.all(16),
- child: Row(
- children: [
- CircleAvatar(
- radius: 18,
- backgroundColor: cs.secondaryContainer,
- foregroundColor: cs.onSecondaryContainer,
- child: Text(accountName.characters.first.toUpperCase()),
- ),
- const SizedBox(width: 11),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
+ child: extended
+ ? Row(
children: [
- Text(
- accountName,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: theme.textTheme.labelLarge,
- ),
- if (serverLabel.isNotEmpty)
- Text(
- serverLabel,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: theme.textTheme.bodySmall?.copyWith(
- color: cs.onSurfaceVariant,
- ),
+ accountAvatar,
+ const SizedBox(width: 11),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ accountName,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: theme.textTheme.labelLarge,
+ ),
+ if (serverLabel.isNotEmpty)
+ Text(
+ serverLabel,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: theme.textTheme.bodySmall?.copyWith(
+ color: cs.onSurfaceVariant,
+ ),
+ ),
+ ],
),
+ ),
],
+ )
+ : Tooltip(
+ message: serverLabel.isEmpty
+ ? accountName
+ : '$accountName\n$serverLabel',
+ child: Center(child: accountAvatar),
),
- ),
- ],
- ),
),
],
),
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index b8f65a44..8bbe1914 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -31,6 +31,8 @@ import 'app_shell.dart';
import '../l10n/app_localizations.dart';
import '../utils/desktop_workspace.dart';
import '../utils/duration_format.dart';
+import '../utils/app_platform.dart';
+import '../utils/media_card_gesture_policy.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@@ -522,7 +524,7 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi
),
),
),
- if (!desktop)
+ if (!desktop && !AppPlatform.isWeb)
const SliverToBoxAdapter(
child: FeatureHint(
prefKey: 'hint_continue_listening_gestures',
@@ -761,6 +763,7 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final l = AppLocalizations.of(context)!;
+ final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.isWeb);
final item = widget.item;
final lib = widget.lib;
@@ -888,8 +891,12 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
),
),
child: InkWell(
- onTap: resume,
- onLongPress: openQuickActions,
+ onTap: gesturePolicy.continueListeningTapOpensDetails
+ ? openDetails
+ : resume,
+ onLongPress: gesturePolicy.allowsLongPressShortcuts
+ ? openQuickActions
+ : null,
borderRadius: BorderRadius.circular(14),
child: SizedBox(
width: isDesktopWorkspace(context) ? 180 : 150,
diff --git a/lib/screens/library_screen.dart b/lib/screens/library_screen.dart
index 1f2c84ed..64bb3027 100644
--- a/lib/screens/library_screen.dart
+++ b/lib/screens/library_screen.dart
@@ -41,15 +41,38 @@ import '../services/user_account_service.dart';
import '../l10n/app_localizations.dart';
import '../utils/desktop_workspace.dart';
-/// Responsive grid column count based on available width.
-/// Returns 3 on phones, scales up on tablets/iPads. The desktop workspace
-/// targets larger ~200px tiles instead of packing phone-sized thumbnails.
-int responsiveGridCount(BuildContext context) {
- final width = MediaQuery.of(context).size.width;
- if (isDesktopWorkspace(context)) {
- return (width / 200).floor().clamp(3, 8);
- }
- return (width / 130).floor().clamp(3, 10);
+const double kDesktopLibraryTileMaxExtent = 220;
+
+SliverGridDelegate libraryGridDelegateForWidth(
+ double width, {
+ required bool desktopWorkspace,
+ required double childAspectRatio,
+}) {
+ if (desktopWorkspace) {
+ return SliverGridDelegateWithMaxCrossAxisExtent(
+ maxCrossAxisExtent: kDesktopLibraryTileMaxExtent,
+ childAspectRatio: childAspectRatio,
+ crossAxisSpacing: 10,
+ mainAxisSpacing: 10,
+ );
+ }
+ return SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: (width / 130).floor().clamp(3, 10),
+ childAspectRatio: childAspectRatio,
+ crossAxisSpacing: 10,
+ mainAxisSpacing: 10,
+ );
+}
+
+SliverGridDelegate libraryGridDelegate(
+ BuildContext context, {
+ required double childAspectRatio,
+}) {
+ return libraryGridDelegateForWidth(
+ MediaQuery.sizeOf(context).width,
+ desktopWorkspace: isDesktopWorkspace(context),
+ childAspectRatio: childAspectRatio,
+ );
}
/// Bottom padding for the library tab grids/lists so the last row clears the
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 5fd22f77..ce61af73 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -2563,10 +2563,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
GestureDetector(
onTap: () => showDialog(
context: context,
- builder: (_) => AlertDialog(
+ builder: (dialogContext) => AlertDialog(
title: Text(l.chapterBarrierInfoTitle),
content: Text(l.chapterBarrierInfoContent,),
- actions: [TextButton(onPressed: () => Navigator.pop(context), child: Text(l.gotIt),
+ actions: [TextButton(onPressed: () => Navigator.pop(dialogContext), child: Text(l.gotIt),
),],
),
),
@@ -2753,10 +2753,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
GestureDetector(
onTap: () => showDialog(
context: context,
- builder: (_) => AlertDialog(
+ builder: (dialogContext) => AlertDialog(
title: Text(l.rewindOnSessionStart),
content: Text(l.rewindOnSessionStartInfoContent,),
- actions: [TextButton(onPressed: () => Navigator.pop(context), child: Text(l.gotIt),
+ actions: [TextButton(onPressed: () => Navigator.pop(dialogContext), child: Text(l.gotIt),
),],
),
),
diff --git a/lib/utils/audible_url.dart b/lib/utils/audible_url.dart
new file mode 100644
index 00000000..2ef133d1
--- /dev/null
+++ b/lib/utils/audible_url.dart
@@ -0,0 +1,27 @@
+String audibleDomainForCountryCode(String? countryCode) {
+ const domains = {
+ 'US': 'audible.com',
+ 'GB': 'audible.co.uk',
+ 'AU': 'audible.com.au',
+ 'CA': 'audible.ca',
+ 'DE': 'audible.de',
+ 'FR': 'audible.fr',
+ 'IT': 'audible.it',
+ 'ES': 'audible.es',
+ 'JP': 'audible.co.jp',
+ 'IN': 'audible.in',
+ 'BR': 'audible.com.br',
+ };
+
+ return domains[countryCode?.toUpperCase()] ?? 'audible.com';
+}
+
+Uri audibleReviewsUri(String asin, {String? countryCode}) {
+ final domain = audibleDomainForCountryCode(countryCode);
+ return Uri(
+ scheme: 'https',
+ host: 'www.$domain',
+ pathSegments: ['pd', asin],
+ fragment: 'customer-reviews',
+ );
+}
diff --git a/lib/utils/desktop_workspace.dart b/lib/utils/desktop_workspace.dart
index f7e676fb..20de8d52 100644
--- a/lib/utils/desktop_workspace.dart
+++ b/lib/utils/desktop_workspace.dart
@@ -2,6 +2,29 @@ import 'package:flutter/widgets.dart';
import 'app_platform.dart';
const double kDesktopWorkspaceBreakpoint = 960;
+const double kStandardWorkspaceBreakpoint = 1200;
+const double kWideWorkspaceBreakpoint = 1440;
+
+enum WorkspaceLayoutTier { mobile, compact, standard, wide }
+
+WorkspaceLayoutTier workspaceLayoutTierForWidth(double width) {
+ if (width < kDesktopWorkspaceBreakpoint) {
+ return WorkspaceLayoutTier.mobile;
+ }
+ if (width < kStandardWorkspaceBreakpoint) {
+ return WorkspaceLayoutTier.compact;
+ }
+ if (width < kWideWorkspaceBreakpoint) {
+ return WorkspaceLayoutTier.standard;
+ }
+ return WorkspaceLayoutTier.wide;
+}
+
+bool usesExtendedDesktopSidebar(WorkspaceLayoutTier tier) =>
+ tier == WorkspaceLayoutTier.standard || tier == WorkspaceLayoutTier.wide;
+
+double desktopSidebarWidth(WorkspaceLayoutTier tier) =>
+ usesExtendedDesktopSidebar(tier) ? 248 : 72;
/// Registration point for the desktop workspace's content-pane navigator.
/// AppShell registers a resolver on mount; anything that pushes full pages
@@ -29,6 +52,6 @@ bool isDesktopWorkspace(BuildContext context) {
// Subscribe to size changes so callers rebuild on window resize.
MediaQuery.sizeOf(context);
final view = View.of(context);
- return view.physicalSize.width / view.devicePixelRatio >=
- kDesktopWorkspaceBreakpoint;
+ final width = view.physicalSize.width / view.devicePixelRatio;
+ return workspaceLayoutTierForWidth(width) != WorkspaceLayoutTier.mobile;
}
diff --git a/lib/utils/media_card_gesture_policy.dart b/lib/utils/media_card_gesture_policy.dart
new file mode 100644
index 00000000..fa6a8ab2
--- /dev/null
+++ b/lib/utils/media_card_gesture_policy.dart
@@ -0,0 +1,9 @@
+class MediaCardGesturePolicy {
+ const MediaCardGesturePolicy({required this.isWeb});
+
+ final bool isWeb;
+
+ bool get allowsLongPressShortcuts => !isWeb;
+
+ bool get continueListeningTapOpensDetails => isWeb;
+}
diff --git a/lib/widgets/absorb_page_header.dart b/lib/widgets/absorb_page_header.dart
index eefd5b8c..e78ca1bb 100644
--- a/lib/widgets/absorb_page_header.dart
+++ b/lib/widgets/absorb_page_header.dart
@@ -34,20 +34,25 @@ class AbsorbPageHeader extends StatelessWidget {
final l = AppLocalizations.of(context)!;
final bColor = brandingColor ?? cs.onSurfaceVariant;
final tColor = titleColor ?? cs.onSurface;
+ final headerActions = actions;
return Padding(
padding: padding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- // Branding row — ABSORB + optional actions
- if (showBranding) ...[
- LayoutBuilder(
- builder: (ctx, lc) {
- return ConstrainedBox(
- constraints: const BoxConstraints(minHeight: 32),
- child: Row(
- children: [
+ LayoutBuilder(
+ builder: (context, constraints) {
+ final reservedWidth = showBranding ? 140.0 : 200.0;
+ final maxActionWidth =
+ (constraints.maxWidth - reservedWidth)
+ .clamp(0.0, double.infinity)
+ .toDouble();
+ return ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 32),
+ child: Row(
+ children: [
+ if (showBranding)
Text(
l.appTitle,
style: tt.labelSmall?.copyWith(
@@ -55,46 +60,57 @@ class AbsorbPageHeader extends StatelessWidget {
letterSpacing: 4,
fontWeight: FontWeight.w300,
),
- ),
- if (trailing != null) ...[
- const SizedBox(width: 8),
- trailing!,
- ],
- 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,
- spacing: 8,
- children: actions!,
- ),
+ )
+ else
+ Expanded(
+ child: Text(
+ title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: tt.headlineMedium?.copyWith(
+ fontWeight: FontWeight.w700,
+ color: tColor,
+ letterSpacing: -0.5,
),
),
+ ),
+ if (trailing != null) ...[
+ const SizedBox(width: 8),
+ trailing!,
],
- ),
- );
- },
- ),
+ if (showBranding)
+ const Spacer()
+ else
+ const SizedBox(width: 12),
+ if (headerActions != null && headerActions.isNotEmpty)
+ ConstrainedBox(
+ constraints: BoxConstraints(maxWidth: maxActionWidth),
+ child: FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.centerRight,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ spacing: 8,
+ children: headerActions,
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ if (showBranding) ...[
const SizedBox(height: 4),
- ],
- // Page title
- Text(
- title,
- style: tt.headlineMedium?.copyWith(
- fontWeight: FontWeight.w700,
- color: tColor,
- letterSpacing: -0.5,
+ Text(
+ title,
+ style: tt.headlineMedium?.copyWith(
+ fontWeight: FontWeight.w700,
+ color: tColor,
+ letterSpacing: -0.5,
+ ),
),
- ),
+ ],
],
),
);
diff --git a/lib/widgets/book_card.dart b/lib/widgets/book_card.dart
index db38422f..02ac2dee 100644
--- a/lib/widgets/book_card.dart
+++ b/lib/widgets/book_card.dart
@@ -12,6 +12,7 @@ import 'absorbing_shared.dart';
import 'book_detail_sheet.dart';
import 'episode_list_sheet.dart';
import 'hover_cover_actions.dart';
+import '../utils/app_platform.dart';
class BookCard extends StatelessWidget {
final Map<String, dynamic> item;
@@ -41,7 +42,6 @@ class BookCard extends StatelessWidget {
final tt = Theme.of(context).textTheme;
final l = AppLocalizations.of(context)!;
final lib = context.watch<LibraryProvider>();
-
final itemId = item['id'] as String?;
final media = item['media'] as Map<String, dynamic>? ?? {};
final metadata = media['metadata'] as Map<String, dynamic>? ?? {};
@@ -161,7 +161,7 @@ class BookCard extends StatelessWidget {
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () => _navigateToDetail(context),
- onLongPress: () => _onLongPress(context),
+ onLongPress: AppPlatform.isWeb ? null : () => _onLongPress(context),
borderRadius: BorderRadius.circular(16),
child: Row(
children: [
@@ -281,7 +281,7 @@ class BookCard extends StatelessWidget {
aspectRatio: coverAspectRatio,
child: _PressableCard(
onTap: () => _navigateToDetail(context),
- onLongPress: () => _onLongPress(context),
+ onLongPress: AppPlatform.isWeb ? null : () => _onLongPress(context),
borderRadius: 12,
child: Card(
elevation: 0,
diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dart
index b4669657..36c297bd 100644
--- a/lib/widgets/book_detail_sheet.dart
+++ b/lib/widgets/book_detail_sheet.dart
@@ -12,6 +12,7 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:palette_generator/palette_generator.dart';
import '../utils/cover_accent.dart';
import '../utils/app_platform.dart';
+import '../utils/audible_url.dart';
import '../utils/desktop_workspace.dart';
import 'package:path_provider/path_provider.dart';
import 'package:file_picker/file_picker.dart';
@@ -1577,34 +1578,23 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
return stars;
}
- static String get _audibleDomain {
- final code = (ui.PlatformDispatcher.instance.locale.countryCode ?? 'US').toUpperCase();
- const domains = {
- 'US': 'audible.com',
- 'GB': 'audible.co.uk',
- 'AU': 'audible.com.au',
- 'CA': 'audible.ca',
- 'DE': 'audible.de',
- 'FR': 'audible.fr',
- 'IT': 'audible.it',
- 'ES': 'audible.es',
- 'JP': 'audible.co.jp',
- 'IN': 'audible.in',
- 'BR': 'audible.com.br',
- };
- return domains[code] ?? 'audible.com';
- }
-
void _showAudibleReviews(BuildContext context) {
final asin = _asin;
if (asin == null) return;
- final url = 'https://www.$_audibleDomain/pd/$asin#customer-reviews';
+ final uri = audibleReviewsUri(
+ asin,
+ countryCode: ui.PlatformDispatcher.instance.locale.countryCode,
+ );
+ if (AppPlatform.isWeb) {
+ unawaited(_launchAudibleReviews(context, uri));
+ return;
+ }
final cs = Theme.of(context).colorScheme;
final controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setBackgroundColor(cs.surface)
- ..loadRequest(Uri.parse(url));
+ ..loadRequest(uri);
showAdaptiveActionMenu(
context: context,
@@ -1662,6 +1652,20 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
);
}
+ Future<void> _launchAudibleReviews(BuildContext context, Uri uri) async {
+ var opened = false;
+ try {
+ opened = await launchUrl(uri, webOnlyWindowName: '_blank');
+ } catch (_) {}
+ if (!opened && context.mounted) {
+ showOverlayToast(
+ context,
+ AppLocalizations.of(context)!.audibleSeriesCouldNotOpenAudible,
+ icon: Icons.error_outline_rounded,
+ );
+ }
+ }
+
Widget _buildAuthorLinks(BuildContext context, Map<String, dynamic> metadata, ColorScheme cs, TextTheme tt, Color accent) {
final authors = metadata['authors'] as List<dynamic>? ?? [];
// Fall back to authorName string if no structured authors array
diff --git a/lib/widgets/episode_row.dart b/lib/widgets/episode_row.dart
index 111b0f76..3c427bae 100644
--- a/lib/widgets/episode_row.dart
+++ b/lib/widgets/episode_row.dart
@@ -4,6 +4,7 @@ import '../l10n/app_localizations.dart';
import '../providers/library_provider.dart';
import '../services/download_service.dart';
import '../utils/app_platform.dart';
+import '../utils/media_card_gesture_policy.dart';
import 'episode_detail_sheet.dart';
class EpisodeRow extends StatefulWidget {
@@ -36,6 +37,7 @@ class _EpisodeRowState extends State<EpisodeRow> {
final cs = Theme.of(context).colorScheme;
final l = AppLocalizations.of(context)!;
final lib = context.watch<LibraryProvider>();
+ final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.isWeb);
final ep = widget.episode;
final title = ep['title'] as String? ?? l.episodeRowEpisode;
@@ -93,12 +95,14 @@ class _EpisodeRowState extends State<EpisodeRow> {
sourcePlaylistId: widget.sourcePlaylistId,
);
},
- onLongPress: () => EpisodeDetailSheet.showQuick(
- context,
- widget.podcastItem,
- ep,
- sourcePlaylistId: widget.sourcePlaylistId,
- ),
+ onLongPress: gesturePolicy.allowsLongPressShortcuts
+ ? () => EpisodeDetailSheet.showQuick(
+ context,
+ widget.podcastItem,
+ ep,
+ sourcePlaylistId: widget.sourcePlaylistId,
+ )
+ : null,
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 10, 12, 10),
child: Column(
diff --git a/lib/widgets/home_section.dart b/lib/widgets/home_section.dart
index 4469b544..f0c6197e 100644
--- a/lib/widgets/home_section.dart
+++ b/lib/widgets/home_section.dart
@@ -11,6 +11,8 @@ import 'hover_cover_actions.dart';
import 'series_card.dart';
import 'episode_list_sheet.dart';
import '../utils/desktop_workspace.dart';
+import '../utils/app_platform.dart';
+import '../utils/media_card_gesture_policy.dart';
class HomeSection extends StatelessWidget {
final String title;
@@ -406,6 +408,7 @@ class _EpisodeCard extends StatelessWidget {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final lib = context.watch<LibraryProvider>();
+ final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.isWeb);
final itemId = item['id'] as String? ?? '';
final media = item['media'] as Map<String, dynamic>? ?? {};
@@ -449,7 +452,7 @@ class _EpisodeCard extends StatelessWidget {
}
},
// Long-press an episode card for its quick-actions sheet (shows stay as-is).
- onLongPress: episode == null ? null
+ onLongPress: episode == null || !gesturePolicy.allowsLongPressShortcuts ? null
: () => EpisodeDetailSheet.showQuick(
context,
item,
diff --git a/lib/widgets/library_authors_tab.dart b/lib/widgets/library_authors_tab.dart
index 39304531..d5153f10 100644
--- a/lib/widgets/library_authors_tab.dart
+++ b/lib/widgets/library_authors_tab.dart
@@ -75,11 +75,9 @@ class LibraryAuthorsTab extends StatelessWidget {
SliverPadding(
padding: EdgeInsets.fromLTRB(16, 8, 16, libraryGridBottomPadding(context)),
sliver: SliverGrid(
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: responsiveGridCount(context),
+ gridDelegate: libraryGridDelegate(
+ context,
childAspectRatio: 0.68,
- crossAxisSpacing: 10,
- mainAxisSpacing: 10,
),
delegate: SliverChildBuilderDelegate(
(context, index) => GridAuthorTile(author: authors[index]),
diff --git a/lib/widgets/library_books_tab.dart b/lib/widgets/library_books_tab.dart
index 810965c8..14ba5f0b 100644
--- a/lib/widgets/library_books_tab.dart
+++ b/lib/widgets/library_books_tab.dart
@@ -143,11 +143,9 @@ class LibraryBooksTab extends StatelessWidget {
SliverPadding(
padding: EdgeInsets.fromLTRB(16, 8, 16, libraryGridBottomPadding(context)),
sliver: SliverGrid(
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: responsiveGridCount(context),
+ gridDelegate: libraryGridDelegate(
+ context,
childAspectRatio: rectangleCovers ? 0.48 : 0.68,
- crossAxisSpacing: 10,
- mainAxisSpacing: 10,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dart
index 444bd9df..e96870c9 100644
--- a/lib/widgets/library_grid_tiles.dart
+++ b/lib/widgets/library_grid_tiles.dart
@@ -14,6 +14,8 @@ import 'episode_list_sheet.dart';
import 'hover_cover_actions.dart';
import 'series_books_sheet.dart';
import 'author_books_sheet.dart';
+import '../utils/app_platform.dart';
+import '../utils/media_card_gesture_policy.dart';
// ═══════════════════════════════════════════════════════════════
// Grid book tile (cover + title + author)
@@ -54,6 +56,7 @@ class _GridBookTileState extends State<GridBookTile> {
final tt = Theme.of(context).textTheme;
final l = AppLocalizations.of(context)!;
final lib = context.watch<LibraryProvider>();
+ final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.isWeb);
final itemId = widget.item['id'] as String? ?? '';
final media = widget.item['media'] as Map<String, dynamic>? ?? {};
@@ -94,7 +97,9 @@ class _GridBookTileState extends State<GridBookTile> {
}
},
// Long-press a book cover for the quick-actions sheet (podcasts skipped).
- onLongPress: (itemId.isNotEmpty && !lib.isPodcastLibrary)
+ onLongPress: (gesturePolicy.allowsLongPressShortcuts &&
+ itemId.isNotEmpty &&
+ !lib.isPodcastLibrary)
? () => showQuickActionsSheet(context, itemId, initialItem: widget.item)
: null,
child: Column(
diff --git a/lib/widgets/library_lists_tab.dart b/lib/widgets/library_lists_tab.dart
index 8095a24f..a066b823 100644
--- a/lib/widgets/library_lists_tab.dart
+++ b/lib/widgets/library_lists_tab.dart
@@ -92,11 +92,9 @@ class LibraryListsTab extends StatelessWidget {
SliverPadding(
padding: EdgeInsets.fromLTRB(16, 8, 16, libraryGridBottomPadding(context)),
sliver: SliverGrid(
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: responsiveGridCount(context),
+ gridDelegate: libraryGridDelegate(
+ context,
childAspectRatio: coverAspectRatio < 1 ? 0.48 : 0.68,
- crossAxisSpacing: 10,
- mainAxisSpacing: 10,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
diff --git a/lib/widgets/library_series_tab.dart b/lib/widgets/library_series_tab.dart
index e7eb3343..91c8c5dc 100644
--- a/lib/widgets/library_series_tab.dart
+++ b/lib/widgets/library_series_tab.dart
@@ -81,11 +81,9 @@ class LibrarySeriesTab extends StatelessWidget {
SliverPadding(
padding: EdgeInsets.fromLTRB(16, 8, 16, libraryGridBottomPadding(context)),
sliver: SliverGrid(
- gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: responsiveGridCount(context),
+ gridDelegate: libraryGridDelegate(
+ context,
childAspectRatio: rectangleCovers ? 0.48 : 0.68,
- crossAxisSpacing: 10,
- mainAxisSpacing: 10,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
diff --git a/web/index.html b/web/index.html
index ceb90959..1fa49de4 100644
--- a/web/index.html
+++ b/web/index.html
@@ -32,8 +32,138 @@
<title>Absorb</title>
<link rel="manifest" href="manifest.json">
+ <style>
+ html,
+ body {
+ width: 100%;
+ height: 100%;
+ }
+
+ body {
+ margin: 0;
+ background: #111318;
+ }
+
+ #absorb-loading {
+ position: fixed;
+ inset: 0;
+ z-index: 9999;
+ display: grid;
+ place-items: center;
+ color: #e3e2e9;
+ background: #111318;
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
+ }
+
+ .absorb-loading-content {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 22px;
+ }
+
+ .absorb-loading-wordmark {
+ color: #c4c5ce;
+ font-size: 13px;
+ font-weight: 300;
+ letter-spacing: 8px;
+ transform: translateX(4px);
+ }
+
+ .absorb-loading-spinner {
+ width: 24px;
+ height: 24px;
+ border: 2px solid rgba(196, 197, 206, 0.2);
+ border-top-color: #bdc2ff;
+ border-radius: 50%;
+ animation: absorb-spin 0.8s linear infinite;
+ }
+
+ .absorb-loading-label {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ padding: 0;
+ margin: -1px;
+ overflow: hidden;
+ clip: rect(0, 0, 0, 0);
+ white-space: nowrap;
+ border: 0;
+ }
+
+ .absorb-loading-help {
+ display: none;
+ max-width: 320px;
+ color: #c4c5ce;
+ font-size: 14px;
+ line-height: 1.5;
+ text-align: center;
+ }
+
+ .absorb-loading-retry {
+ padding: 9px 18px;
+ border: 0;
+ border-radius: 999px;
+ color: #202044;
+ background: #bdc2ff;
+ font: inherit;
+ font-weight: 650;
+ cursor: pointer;
+ }
+
+ #absorb-loading.is-stalled .absorb-loading-spinner {
+ display: none;
+ }
+
+ #absorb-loading.is-stalled .absorb-loading-help {
+ display: block;
+ }
+
+ @keyframes absorb-spin {
+ to { transform: rotate(360deg); }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .absorb-loading-spinner { animation: none; }
+ }
+ </style>
</head>
<body>
+ <div id="absorb-loading" role="status" aria-live="polite">
+ <div class="absorb-loading-content">
+ <div class="absorb-loading-wordmark" aria-hidden="true">A B S O R B</div>
+ <div class="absorb-loading-spinner" aria-hidden="true"></div>
+ <span class="absorb-loading-label">Loading Absorb</span>
+ <div class="absorb-loading-help">
+ <p>Absorb couldn’t finish loading. The server may still be starting.</p>
+ <button class="absorb-loading-retry" type="button">Reload</button>
+ </div>
+ </div>
+ </div>
+ <script>
+ const loadingShell = document.getElementById('absorb-loading');
+ const loadingLabel = loadingShell?.querySelector('.absorb-loading-label');
+ const stalledTimer = window.setTimeout(() => {
+ loadingShell?.classList.add('is-stalled');
+ if (loadingLabel) loadingLabel.textContent = 'Absorb could not finish loading';
+ }, 45000);
+
+ loadingShell?.querySelector('.absorb-loading-retry')?.addEventListener('click', () => {
+ window.location.reload();
+ });
+
+ window.addEventListener('error', (event) => {
+ if (event.target instanceof HTMLScriptElement) {
+ loadingShell?.classList.add('is-stalled');
+ if (loadingLabel) loadingLabel.textContent = 'Absorb could not finish loading';
+ }
+ }, true);
+
+ window.addEventListener('flutter-first-frame', () => {
+ window.clearTimeout(stalledTimer);
+ loadingShell?.remove();
+ }, {once: true});
+ </script>
<!--
You can customize the "flutter_bootstrap.js" script.
This is useful to provide a custom configuration to the Flutter loader