A cross platform Audiobookshelf client for Android and iOS
Dart
Move account controls to the sidebar and clean up desktop pages
Barnabas6d31c919099d
diff --git a/lib/screens/admin_podcasts_screen.dart b/lib/screens/admin_podcasts_screen.dartindex 61930576..80a083cb 100644--- a/lib/screens/admin_podcasts_screen.dart+++ b/lib/screens/admin_podcasts_screen.dart@@ -8,9 +8,11 @@ import '../services/socket_service.dart';import 'podcast_edit_screen.dart';import '../widgets/absorb_page_header.dart';import '../widgets/adaptive_modal.dart';+import '../widgets/desktop_page_body.dart';import '../widgets/html_description.dart';import '../widgets/overlay_toast.dart';import '../l10n/app_localizations.dart';+import '../utils/desktop_workspace.dart';import '../utils/duration_format.dart';/// Opens the podcast lookup used by the admin podcast manager.@@ -47,13 +49,21 @@ Future<void> showPodcastAdminSettings(required VoidCallback onChanged,}) async {if (!context.read<AuthProvider>().isAdmin) return;- await Navigator.of(context).push<void>(+ final navigator = contentNavigator(context);+ final sourceContext = context;+ final sourceRoute = ModalRoute.of(context);+ if (isDesktopWorkspace(context) && sourceRoute is PopupRoute<dynamic>) {+ Navigator.of(context, rootNavigator: true).removeRoute(sourceRoute);+ }+ await navigator.push<void>(MaterialPageRoute<void>(builder: (_) => _PodcastDetailScreen(item: item,libraryId: libraryId,initialTab: 2,- onChanged: onChanged,+ onChanged: () {+ if (sourceContext.mounted) onChanged();+ },),),);@@ -138,7 +148,7 @@ class _AdminPodcastsScreenState extends State<AdminPodcastsScreen> {onPressed: () => _showSearchSheet(),child: Icon(Icons.add_rounded, color: cs.onPrimary),),- body: SafeArea(child: Column(children: [+ body: DesktopPageBody(maxWidth: 1040, child: SafeArea(child: Column(children: [Padding(padding: const EdgeInsets.fromLTRB(20, 12, 8, 0),child: Row(children: [@@ -159,7 +169,7 @@ class _AdminPodcastsScreenState extends State<AdminPodcastsScreen> {? const Center(child: CircularProgressIndicator(strokeWidth: 2)): RefreshIndicator(onRefresh: _loadShows, child: _buildShowList(cs, tt)),),- ])),+ ]))),);}@@ -244,7 +254,7 @@ class _AdminPodcastsScreenState extends State<AdminPodcastsScreen> {// ─── Show Detail ────────────────────────────────────────────void _openShowDetail(Map<String, dynamic> item) {- Navigator.push(context, MaterialPageRoute(+ contentNavigator(context).push(MaterialPageRoute(builder: (_) => _PodcastDetailScreen(item: item, libraryId: _libraryId, onChanged: _loadShows)));}}@@ -439,11 +449,12 @@ class _PodcastSearchSheetState extends State<_PodcastSearchSheet> {color: cs.surfaceContainerHigh,borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),),- child: DraggableScrollableSheet(+ child: AdaptiveDraggableScrollableSheet(initialChildSize: 0.85,minChildSize: 0.05,maxChildSize: 0.95,expand: false,+ desktopMaxHeight: 680,builder: (ctx, sc) {return Column(children: [@@ -806,7 +817,7 @@ class _PodcastPreviewScreenState extends State<_PodcastPreviewScreen> {return Scaffold(backgroundColor: Theme.of(context).scaffoldBackgroundColor,- body: SafeArea(+ body: DesktopPageBody(maxWidth: 1040, child: SafeArea(child: Column(children: [// Header@@ -965,7 +976,7 @@ class _PodcastPreviewScreenState extends State<_PodcastPreviewScreen> {),],),- ),+ )),);}@@ -1222,7 +1233,7 @@ class _PodcastDetailScreenState extends State<_PodcastDetailScreen> with SingleTreturn Scaffold(backgroundColor: Theme.of(context).scaffoldBackgroundColor,- body: SafeArea(child: Column(children: [+ body: DesktopPageBody(maxWidth: 1040, child: SafeArea(child: Column(children: [// Back buttonPadding(padding: const EdgeInsets.fromLTRB(4, 4, 8, 0),child: Row(children: [@@ -1297,7 +1308,7 @@ class _PodcastDetailScreenState extends State<_PodcastDetailScreen> with SingleT_buildFeedTab(cs, tt),_buildSettingsTab(cs, tt),])),- ])),+ ]))),);}@@ -2068,7 +2079,7 @@ class _PodcastDetailScreenState extends State<_PodcastDetailScreen> with SingleTvoid _openEditInfo() {final tags = (_media['tags'] as List<dynamic>?)?.whereType<String>().toList() ?? <String>[];- Navigator.push(context, MaterialPageRoute(+ contentNavigator(context).push(MaterialPageRoute(builder: (_) => PodcastEditScreen(itemId: _podcastId,metadata: Map<String, dynamic>.from(_metadata),@@ -2578,11 +2589,12 @@ class _PodcastMatchSheetState extends State<_PodcastMatchSheet> {color: cs.surfaceContainerHigh,borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),),- child: DraggableScrollableSheet(+ child: AdaptiveDraggableScrollableSheet(initialChildSize: 0.75,minChildSize: 0.05,maxChildSize: 0.95,expand: false,+ desktopMaxHeight: 680,builder: (ctx, sc) => Column(children: [Padding(padding: const EdgeInsets.fromLTRB(20, 14, 8, 0),diff --git a/lib/screens/admin_sessions_screen.dart b/lib/screens/admin_sessions_screen.dartindex 6b4665fe..27483dee 100644--- a/lib/screens/admin_sessions_screen.dart+++ b/lib/screens/admin_sessions_screen.dart@@ -97,6 +97,7 @@ class _AdminSessionsScreenState extends State<AdminSessionsScreen> {isScrollControlled: true,backgroundColor: Colors.transparent,desktopWidth: 520,+ desktopScrollWrap: false,builder: (_) =>SessionDetailsSheet(session: s, allowEdit: ownerId == myId),);diff --git a/lib/screens/admin_users_screen.dart b/lib/screens/admin_users_screen.dartindex 8dd72e7b..5600ecca 100644--- a/lib/screens/admin_users_screen.dart+++ b/lib/screens/admin_users_screen.dart@@ -1247,6 +1247,7 @@ class _AdminSessionDetailsSheet extends StatelessWidget {final cs = Theme.of(context).colorScheme;final tt = Theme.of(context).textTheme;final l = AppLocalizations.of(context)!;+ final desktopMode = ModalSurface.isDesktopOf(context);final s = session;final meta = s['mediaMetadata'] as Map<String, dynamic>? ?? {};@@ -1288,7 +1289,7 @@ class _AdminSessionDetailsSheet extends StatelessWidget {final lib = context.read<LibraryProvider>();final coverUrl = itemId != null ? lib.getCoverUrl(itemId) : null;- return DraggableScrollableSheet(+ return AdaptiveDraggableScrollableSheet(initialChildSize: 0.6,minChildSize: 0.4,maxChildSize: 0.95,@@ -1297,20 +1298,37 @@ class _AdminSessionDetailsSheet extends StatelessWidget {return Container(decoration: BoxDecoration(color: cs.surface,- borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),+ borderRadius: desktopMode+ ? BorderRadius.zero+ : const BorderRadius.vertical(top: Radius.circular(24)),),child: Column(children: [- Padding(- padding: const EdgeInsets.only(top: 10, bottom: 4),- child: Container(- width: 36,- height: 4,- decoration: BoxDecoration(- color: cs.onSurface.withValues(alpha: 0.2),- borderRadius: BorderRadius.circular(2),+ if (desktopMode)+ Align(+ alignment: Alignment.centerRight,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(8, 6, 8, 0),+ child: IconButton(+ tooltip: MaterialLocalizations.of(+ context,+ ).closeButtonTooltip,+ onPressed: () => Navigator.pop(context),+ icon: const Icon(Icons.close_rounded),+ ),+ ),+ )+ else+ Padding(+ padding: const EdgeInsets.only(top: 10, bottom: 4),+ child: Container(+ width: 36,+ height: 4,+ decoration: BoxDecoration(+ color: cs.onSurface.withValues(alpha: 0.2),+ borderRadius: BorderRadius.circular(2),+ ),),),- ),Expanded(child: ListView(controller: scrollController,diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dartindex 9d880ed5..3f8e479d 100644--- a/lib/screens/app_shell.dart+++ b/lib/screens/app_shell.dart@@ -25,6 +25,7 @@ import '../services/wording.dart';import '../services/android_auto_service.dart';import '../services/carplay_service.dart';import '../widgets/expanded_card.dart';+import '../widgets/desktop_account_button.dart';import '../widgets/desktop_now_playing_bar.dart';import 'absorbing_screen.dart';import 'admin_screen.dart';@@ -151,6 +152,7 @@ class _AppShellState extends State<AppShell>String _podcastTabLibraryId = '';final _homeKey = GlobalKey<HomeScreenState>();final _libraryKey = GlobalKey<LibraryScreenState>();+ final _settingsKey = GlobalKey<SettingsScreenState>();final _player = AudioPlayerService();final _cast = ChromecastService();bool _playerHadBook = false;@@ -315,7 +317,7 @@ class _AppShellState extends State<AppShell>_pages[index] = const StatsScreen();break;case 4:- _pages[index] = const SettingsScreen();+ _pages[index] = SettingsScreen(key: _settingsKey);break;}}@@ -901,12 +903,32 @@ class _AppShellState extends State<AppShell>);}- final accountAvatar = CircleAvatar(- radius: 18,- backgroundColor: cs.secondaryContainer,- foregroundColor: cs.onSecondaryContainer,- child: Text(accountName.characters.first.toUpperCase()),- );+ void openAccountMenu() {+ final wasBuilt = _pages[4] != null;+ _ensurePageBuilt(4);++ final state = _settingsKey.currentState;+ if (state != null) {+ state.showAccountMenu();+ return;+ }++ if (!wasBuilt) setState(() {});+ var attempts = 0;+ void tryOpen() {+ if (!mounted) return;+ final settings = _settingsKey.currentState;+ if (settings != null) {+ settings.showAccountMenu();+ return;+ }+ if (++attempts < 10) {+ WidgetsBinding.instance.addPostFrameCallback((_) => tryOpen());+ }+ }++ WidgetsBinding.instance.addPostFrameCallback((_) => tryOpen());+ }return SafeArea(child: SizedBox(@@ -1066,43 +1088,11 @@ class _AppShellState extends State<AppShell>height: 1,color: cs.outlineVariant.withValues(alpha: 0.45),),- Padding(- padding: const EdgeInsets.all(16),- child: extended- ? Row(- children: [- 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),- ),+ DesktopAccountButton(+ accountName: accountName,+ serverLabel: serverLabel,+ extended: extended,+ onPressed: openAccountMenu,),],),diff --git a/lib/screens/podcast_edit_screen.dart b/lib/screens/podcast_edit_screen.dartindex e79e1022..6960a6e0 100644--- a/lib/screens/podcast_edit_screen.dart+++ b/lib/screens/podcast_edit_screen.dart@@ -6,6 +6,8 @@ import 'package:cached_network_image/cached_network_image.dart';import '../l10n/app_localizations.dart';import '../providers/auth_provider.dart';import '../providers/library_provider.dart';+import '../utils/desktop_workspace.dart';+import '../widgets/desktop_page_body.dart';import '../widgets/overlay_toast.dart';/// Full-screen editor for a podcast show's info (title, author, description,@@ -155,6 +157,7 @@ class _PodcastEditScreenState extends State<PodcastEditScreen> {final l = AppLocalizations.of(context)!;final auth = context.read<AuthProvider>();final serverCover = '${auth.serverUrl}/api/items/${widget.itemId}/cover';+ final isDesktop = isDesktopWorkspace(context);return Scaffold(appBar: AppBar(@@ -173,10 +176,12 @@ class _PodcastEditScreenState extends State<PodcastEditScreen> {),],),- body: ListView(- padding: EdgeInsets.fromLTRB(20, 12, 20,- 32 + MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).viewPadding.bottom),- children: [+ body: DesktopPageBody(+ maxWidth: 760,+ child: ListView(+ padding: EdgeInsets.fromLTRB(20, 12, 20,+ 32 + MediaQuery.of(context).viewInsets.bottom + MediaQuery.of(context).viewPadding.bottom),+ children: [// CoverCenter(child: ClipRRect(@@ -266,7 +271,13 @@ class _PodcastEditScreenState extends State<PodcastEditScreen> {// Text fields_field(l.titleLabel, _titleCtrl, tt),_field(l.authorLabel, _authorCtrl, tt),- _field(l.descriptionLabel, _descCtrl, tt, maxLines: 6),+ _field(+ l.descriptionLabel,+ _descCtrl,+ tt,+ minLines: isDesktop ? 10 : null,+ maxLines: isDesktop ? null : 6,+ ),_field(l.genresLabel, _genresCtrl, tt, hint: l.commaSeparated),_field(l.tagsLabel, _tagsCtrl, tt, hint: l.commaSeparated),Row(children: [@@ -276,18 +287,23 @@ class _PodcastEditScreenState extends State<PodcastEditScreen> {]),const SizedBox(height: 4),// Explicit- Container(- padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 4),- decoration: BoxDecoration(color: cs.surfaceContainerHigh, borderRadius: BorderRadius.circular(12)),- child: SwitchListTile(- contentPadding: EdgeInsets.zero,- title: Text(l.adminPodcastsExplicit, style: tt.bodyMedium?.copyWith(fontWeight: FontWeight.w600, color: cs.onSurface)),- subtitle: Text(l.adminPodcastsExplicitSubtitle, style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),- value: _explicit,- onChanged: (v) => setState(() => _explicit = v),+ Material(+ color: cs.surfaceContainerHigh,+ borderRadius: BorderRadius.circular(12),+ clipBehavior: Clip.antiAlias,+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 4),+ child: SwitchListTile(+ contentPadding: EdgeInsets.zero,+ title: Text(l.adminPodcastsExplicit, style: tt.bodyMedium?.copyWith(fontWeight: FontWeight.w600, color: cs.onSurface)),+ subtitle: Text(l.adminPodcastsExplicitSubtitle, style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),+ value: _explicit,+ onChanged: (v) => setState(() => _explicit = v),+ ),),),- ],+ ],+ ),),);}@@ -316,11 +332,13 @@ class _PodcastEditScreenState extends State<PodcastEditScreen> {child: Icon(Icons.podcasts_rounded, color: cs.onSurfaceVariant.withValues(alpha: 0.3), size: 32),);- Widget _field(String label, TextEditingController ctrl, TextTheme tt, {int maxLines = 1, String? hint}) {+ Widget _field(String label, TextEditingController ctrl, TextTheme tt,+ {int? minLines, int? maxLines = 1, String? hint}) {return Padding(padding: const EdgeInsets.only(bottom: 12),child: TextField(controller: ctrl,+ minLines: minLines,maxLines: maxLines,decoration: InputDecoration(labelText: label,diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex ce61af73..156913e9 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -193,10 +193,10 @@ class SettingsScreen extends StatefulWidget {const SettingsScreen({super.key});@override- State<SettingsScreen> createState() => _SettingsScreenState();+ State<SettingsScreen> createState() => SettingsScreenState();}-class _SettingsScreenState extends State<SettingsScreen> {+class SettingsScreenState extends State<SettingsScreen> {static const _isPlayStoreBuild = bool.fromEnvironment('PLAYSTORE_BUILD');static const _isGithubBuild = bool.fromEnvironment('GITHUB_BUILD');// Distribution label shown next to the version. The F-Droid build passes@@ -328,6 +328,10 @@ class _SettingsScreenState extends State<SettingsScreen> {final ScrollController _settingsScrollController = ScrollController();final Map<String, GlobalKey> _sectionKeys = {};+ void showAccountMenu() {+ if (mounted) _showAccountSheet(context);+ }+GlobalKey _keyFor(String section) => _sectionKeys.putIfAbsent(section, () => GlobalKey());void _onSectionExpanded(String section, bool expanded) {@@ -1390,13 +1394,14 @@ class _SettingsScreenState extends State<SettingsScreen> {builder: (context, constraints) {final isDesktopSettings = isDesktopWorkspace(context);final expandedSection = _expandedSection ??- (isDesktopSettings ? 'Account' : null);+ (isDesktopSettings ? 'Appearance' : null);final destinations = <_SettingsSectionDestination>[- _SettingsSectionDestination(- 'Account',- Icons.person_outline_rounded,- l.userFallback,- ),+ if (!isDesktopSettings)+ _SettingsSectionDestination(+ 'Account',+ Icons.person_outline_rounded,+ l.userFallback,+ ),_SettingsSectionDestination('Appearance',Icons.palette_outlined,@@ -1500,7 +1505,7 @@ class _SettingsScreenState extends State<SettingsScreen> {const SizedBox(height: 8),// ── User Profile ──- if (!isDesktopSettings || expandedSection == 'Account')+ if (!isDesktopSettings)Padding(key: _keyFor('Account'),padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),diff --git a/lib/screens/stats_screen.dart b/lib/screens/stats_screen.dartindex 0fcccfdb..00abc252 100644--- a/lib/screens/stats_screen.dart+++ b/lib/screens/stats_screen.dart@@ -2257,6 +2257,7 @@ class SessionDetailsSheetState extends State<SessionDetailsSheet> {final cs = Theme.of(context).colorScheme;final tt = Theme.of(context).textTheme;final l = AppLocalizations.of(context)!;+ final desktopMode = ModalSurface.isDesktopOf(context);final s = widget.session;final meta = s['mediaMetadata'] as Map<String, dynamic>? ?? {};@@ -2298,7 +2299,7 @@ class SessionDetailsSheetState extends State<SessionDetailsSheet> {final lib = context.read<LibraryProvider>();final coverUrl = itemId != null ? lib.getCoverUrl(itemId) : null;- return DraggableScrollableSheet(+ return AdaptiveDraggableScrollableSheet(initialChildSize: 0.7,minChildSize: 0.4,maxChildSize: 0.95,@@ -2307,20 +2308,37 @@ class SessionDetailsSheetState extends State<SessionDetailsSheet> {return Container(decoration: BoxDecoration(color: cs.surface,- borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),+ borderRadius: desktopMode+ ? BorderRadius.zero+ : const BorderRadius.vertical(top: Radius.circular(24)),),child: Column(children: [- Padding(- padding: const EdgeInsets.only(top: 10, bottom: 4),- child: Container(- width: 36,- height: 4,- decoration: BoxDecoration(- color: cs.onSurface.withValues(alpha: 0.2),- borderRadius: BorderRadius.circular(2),+ if (desktopMode)+ Align(+ alignment: Alignment.centerRight,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(8, 6, 8, 0),+ child: IconButton(+ tooltip: MaterialLocalizations.of(+ context,+ ).closeButtonTooltip,+ onPressed: () => Navigator.pop(context),+ icon: const Icon(Icons.close_rounded),+ ),+ ),+ )+ else+ Padding(+ padding: const EdgeInsets.only(top: 10, bottom: 4),+ child: Container(+ width: 36,+ height: 4,+ decoration: BoxDecoration(+ color: cs.onSurface.withValues(alpha: 0.2),+ borderRadius: BorderRadius.circular(2),+ ),),),- ),Expanded(child: ListView(controller: scrollController,diff --git a/lib/screens/upcoming_releases_screen.dart b/lib/screens/upcoming_releases_screen.dartindex 2d9bc4ee..7192ded9 100644--- a/lib/screens/upcoming_releases_screen.dart+++ b/lib/screens/upcoming_releases_screen.dart@@ -8,8 +8,10 @@ import '../services/audio_player_service.dart';import '../services/rmab_service.dart';import '../services/scoped_prefs.dart';import '../services/upcoming_releases_service.dart';+import '../utils/desktop_workspace.dart';import '../widgets/absorb_page_header.dart';import '../widgets/audible_series_sheet.dart';+import '../widgets/desktop_page_body.dart';import '../widgets/overlay_toast.dart';import '../widgets/rmab_book_detail_sheet.dart';import '../widgets/rmab_config_sheet.dart'@@ -250,10 +252,13 @@ class _UpcomingReleasesScreenState extends State<UpcomingReleasesScreen> {final cs = Theme.of(context).colorScheme;final tt = Theme.of(context).textTheme;final l = AppLocalizations.of(context)!;+ final desktopWorkspace = isDesktopWorkspace(context);return Scaffold(body: SafeArea(- child: Column(+ child: DesktopPageBody(+ maxWidth: 1080,+ child: Column(children: [AbsorbPageHeader(title: l.upcomingReleasesTitle,@@ -315,6 +320,16 @@ class _UpcomingReleasesScreenState extends State<UpcomingReleasesScreen> {]),),),+ if (desktopWorkspace)+ IconButton(+ key: const Key('upcoming-releases-close'),+ tooltip: MaterialLocalizations.of(context).closeButtonTooltip,+ onPressed: () => Navigator.of(context).maybePop(),+ icon: Icon(+ Icons.close_rounded,+ color: cs.onSurfaceVariant,+ ),+ ),],),@@ -374,6 +389,7 @@ class _UpcomingReleasesScreenState extends State<UpcomingReleasesScreen> {child: _buildContent(cs, tt, l),),],+ ),),),);diff --git a/lib/widgets/absorb_page_header.dart b/lib/widgets/absorb_page_header.dartindex e78ca1bb..8e17f715 100644--- a/lib/widgets/absorb_page_header.dart+++ b/lib/widgets/absorb_page_header.dart@@ -1,5 +1,6 @@import 'package:flutter/material.dart';import '../l10n/app_localizations.dart';+import '../utils/desktop_workspace.dart';/// Consistent page header used across all screens.///@@ -13,7 +14,7 @@ class AbsorbPageHeader extends StatelessWidget {final Color? titleColor;final List<Widget>? actions;final Widget? trailing;- final bool showBranding;+ final bool? showBranding;final EdgeInsetsGeometry padding;const AbsorbPageHeader({@@ -23,7 +24,7 @@ class AbsorbPageHeader extends StatelessWidget {this.titleColor,this.actions,this.trailing,- this.showBranding = true,+ this.showBranding,this.padding = const EdgeInsets.fromLTRB(20, 12, 20, 0),});@@ -35,6 +36,7 @@ class AbsorbPageHeader extends StatelessWidget {final bColor = brandingColor ?? cs.onSurfaceVariant;final tColor = titleColor ?? cs.onSurface;final headerActions = actions;+ final shouldShowBranding = showBranding ?? !isDesktopWorkspace(context);return Padding(padding: padding,@@ -43,16 +45,15 @@ class AbsorbPageHeader extends StatelessWidget {children: [LayoutBuilder(builder: (context, constraints) {- final reservedWidth = showBranding ? 140.0 : 200.0;- final maxActionWidth =- (constraints.maxWidth - reservedWidth)- .clamp(0.0, double.infinity)- .toDouble();+ final reservedWidth = shouldShowBranding ? 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)+ if (shouldShowBranding)Text(l.appTitle,style: tt.labelSmall?.copyWith(@@ -78,7 +79,7 @@ class AbsorbPageHeader extends StatelessWidget {const SizedBox(width: 8),trailing!,],- if (showBranding)+ if (shouldShowBranding)const Spacer()elseconst SizedBox(width: 12),@@ -100,7 +101,7 @@ class AbsorbPageHeader extends StatelessWidget {);},),- if (showBranding) ...[+ if (shouldShowBranding) ...[const SizedBox(height: 4),Text(title,diff --git a/lib/widgets/adaptive_modal.dart b/lib/widgets/adaptive_modal.dartindex b483ad59..a6a98f42 100644--- a/lib/widgets/adaptive_modal.dart+++ b/lib/widgets/adaptive_modal.dart@@ -25,6 +25,53 @@ class ModalSurface extends InheritedWidget {oldWidget.desktop != desktop;}+/// Keeps sheet-style content draggable on mobile while giving it a finite,+/// conventional dialog height on desktop. The same builder and scroll+/// controller work in both surfaces.+class AdaptiveDraggableScrollableSheet extends StatelessWidget {+ const AdaptiveDraggableScrollableSheet({+ super.key,+ required this.builder,+ this.initialChildSize = 0.5,+ this.minChildSize = 0.25,+ this.maxChildSize = 1.0,+ this.expand = true,+ this.desktopHeightFraction = 0.76,+ this.desktopMaxHeight = 720,+ });++ final ScrollableWidgetBuilder builder;+ final double initialChildSize;+ final double minChildSize;+ final double maxChildSize;+ final bool expand;+ final double desktopHeightFraction;+ final double desktopMaxHeight;++ @override+ Widget build(BuildContext context) {+ if (ModalSurface.isDesktopOf(context)) {+ final availableHeight =+ MediaQuery.sizeOf(context).height * desktopHeightFraction;+ final height = availableHeight < desktopMaxHeight+ ? availableHeight+ : desktopMaxHeight;+ return SizedBox(+ height: height,+ child: _SheetDialogScrollHost(builder: builder),+ );+ }++ return DraggableScrollableSheet(+ initialChildSize: initialChildSize,+ minChildSize: minChildSize,+ maxChildSize: maxChildSize,+ expand: expand,+ builder: builder,+ );+ }+}+/// Scrollable browse/detail surface: draggable bottom sheet on mobile,/// centered dialog on the desktop workspace. The builder's ScrollController/// comes from the DraggableScrollableSheet on mobile and a dialog-owned@@ -129,18 +176,17 @@ Future<T?> showDesktopSheetDialog<T>({bool isDismissible = true,void Function(Route<dynamic>)? onRouteCaptured,void Function(Route<dynamic>)? onRouteDisposed,-}) =>- showDesktopModalDialog<T>(- context: context,- maxWidth: maxWidth,- maxHeightFraction: maxHeightFraction,- closeButton: closeButton,- backgroundColor: backgroundColor,- isDismissible: isDismissible,- onRouteCaptured: onRouteCaptured,- onRouteDisposed: onRouteDisposed,- builder: (ctx) => _SheetDialogScrollHost(builder: builder),- );+}) => showDesktopModalDialog<T>(+ context: context,+ maxWidth: maxWidth,+ maxHeightFraction: maxHeightFraction,+ closeButton: closeButton,+ backgroundColor: backgroundColor,+ isDismissible: isDismissible,+ onRouteCaptured: onRouteCaptured,+ onRouteDisposed: onRouteDisposed,+ builder: (ctx) => _SheetDialogScrollHost(builder: builder),+);/// Centered dialog with the shared desktop modal chrome (matches the/// settings surfaces). Always presents on the root navigator so it covers@@ -271,8 +317,11 @@ class _DesktopDialogBodyState extends State<_DesktopDialogBody> {clipBehavior: Clip.antiAlias,child: IconButton(visualDensity: VisualDensity.compact,- icon: Icon(Icons.close_rounded,- size: 20, color: cs.onSurfaceVariant),+ icon: Icon(+ Icons.close_rounded,+ size: 20,+ color: cs.onSurfaceVariant,+ ),onPressed: () => Navigator.of(context).pop(),),),diff --git a/lib/widgets/day_sessions_sheet.dart b/lib/widgets/day_sessions_sheet.dartindex af0cdc8d..9cfe7066 100644--- a/lib/widgets/day_sessions_sheet.dart+++ b/lib/widgets/day_sessions_sheet.dart@@ -1,6 +1,7 @@import 'package:flutter/material.dart';import '../l10n/app_localizations.dart';+import 'adaptive_modal.dart';import 'listening_session_card.dart';typedef DaySessionLoader =@@ -150,6 +151,7 @@ class _DaySessionsSheetState extends State<DaySessionsSheet> {final cs = Theme.of(context).colorScheme;final tt = Theme.of(context).textTheme;final l = AppLocalizations.of(context)!;+ final desktopMode = ModalSurface.isDesktopOf(context);final dateLabel = MaterialLocalizations.of(context).formatFullDate(_date);final filtered = _sessions.where(@@ -166,7 +168,7 @@ class _DaySessionsSheetState extends State<DaySessionsSheet> {? l.statsScreenSessionCountOne(filtered.length): l.statsScreenSessionCountOther(filtered.length);- return DraggableScrollableSheet(+ return AdaptiveDraggableScrollableSheet(initialChildSize: 0.82,minChildSize: 0.5,maxChildSize: 0.96,@@ -175,7 +177,9 @@ class _DaySessionsSheetState extends State<DaySessionsSheet> {return Container(decoration: BoxDecoration(color: cs.surface,- borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),+ borderRadius: desktopMode+ ? BorderRadius.zero+ : const BorderRadius.vertical(top: Radius.circular(24)),),child: Column(children: [diff --git a/lib/widgets/desktop_account_button.dart b/lib/widgets/desktop_account_button.dartnew file mode 100644index 00000000..7334c5d3--- /dev/null+++ b/lib/widgets/desktop_account_button.dart@@ -0,0 +1,89 @@+import 'package:flutter/material.dart';++class DesktopAccountButton extends StatelessWidget {+ const DesktopAccountButton({+ super.key,+ required this.accountName,+ required this.serverLabel,+ required this.extended,+ required this.onPressed,+ });++ static const buttonKey = ValueKey<String>('desktop-account-menu-button');++ final String accountName;+ final String serverLabel;+ final bool extended;+ final VoidCallback onPressed;++ @override+ Widget build(BuildContext context) {+ final theme = Theme.of(context);+ final cs = theme.colorScheme;+ final tooltip = serverLabel.isEmpty+ ? accountName+ : '$accountName\n$serverLabel';+ final avatar = CircleAvatar(+ radius: 18,+ backgroundColor: cs.secondaryContainer,+ foregroundColor: cs.onSecondaryContainer,+ child: Text(accountName.characters.first.toUpperCase()),+ );++ return Padding(+ padding: const EdgeInsets.all(8),+ child: Tooltip(+ message: tooltip,+ child: Material(+ color: Colors.transparent,+ borderRadius: BorderRadius.circular(12),+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ key: buttonKey,+ onTap: onPressed,+ borderRadius: BorderRadius.circular(12),+ child: Padding(+ padding: const EdgeInsets.all(8),+ child: extended+ ? Row(+ children: [+ avatar,+ 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,+ ),+ ),+ ],+ ),+ ),+ const SizedBox(width: 8),+ Icon(+ Icons.manage_accounts_outlined,+ size: 20,+ color: cs.onSurfaceVariant,+ ),+ ],+ )+ : Center(child: avatar),+ ),+ ),+ ),+ ),+ );+ }+}diff --git a/lib/widgets/ebook_reader_view.dart b/lib/widgets/ebook_reader_view.dartindex 7bc870a1..1f5ceb8f 100644--- a/lib/widgets/ebook_reader_view.dart+++ b/lib/widgets/ebook_reader_view.dart@@ -1563,7 +1563,7 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObsborderRadius: BorderRadius.vertical(top: Radius.circular(20)),),desktopScrollWrap: false,- builder: (ctx) => DraggableScrollableSheet(+ builder: (ctx) => AdaptiveDraggableScrollableSheet(expand: false,initialChildSize: 0.6,maxChildSize: 0.9,@@ -1582,6 +1582,16 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObs'${_annotations.length}',style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),),+ if (ModalSurface.isDesktopOf(ctx)) ...[+ const SizedBox(width: 4),+ IconButton(+ tooltip: MaterialLocalizations.of(+ ctx,+ ).closeButtonTooltip,+ onPressed: () => Navigator.pop(ctx),+ icon: const Icon(Icons.close_rounded),+ ),+ ],],),),diff --git a/lib/widgets/edit_metadata_sheet.dart b/lib/widgets/edit_metadata_sheet.dartindex 867a092c..f4bc6b23 100644--- a/lib/widgets/edit_metadata_sheet.dart+++ b/lib/widgets/edit_metadata_sheet.dart@@ -8,6 +8,9 @@ import '../providers/auth_provider.dart';import '../providers/library_provider.dart';import '../services/socket_service.dart';import '../screens/chapter_editor_screen.dart';+import '../utils/desktop_workspace.dart';+import 'metadata_lookup_sheet.dart'+ show metadataFieldPickerDialogConstraints;import 'overlay_toast.dart';enum _ETab { details, cover, chapters, match, encode, embed }@@ -516,6 +519,10 @@ class _MetadataEditViewState extends State<MetadataEditView>final cs = Theme.of(ctx).colorScheme;final tt = Theme.of(ctx).textTheme;return AlertDialog(+ constraints: metadataFieldPickerDialogConstraints(+ desktop: isDesktopWorkspace(ctx),+ viewportHeight: MediaQuery.sizeOf(ctx).height,+ ),title: Text(l.metadataLookupChooseFields),content: SizedBox(width: double.maxFinite,diff --git a/lib/widgets/foliate_reader_view.dart b/lib/widgets/foliate_reader_view.dartindex c4f9b711..3daf5db2 100644--- a/lib/widgets/foliate_reader_view.dart+++ b/lib/widgets/foliate_reader_view.dart@@ -12,6 +12,7 @@ import '../services/ebook_cache.dart';import '../services/progress_sync_service.dart';import '../services/foliate_book_server.dart';import '../services/volume_key_service.dart';+import 'adaptive_modal.dart';/// A table-of-contents entry from foliate-js.class _TocItem {@@ -293,26 +294,73 @@ class _FoliateReaderViewState extends State<FoliateReaderView> with WidgetsBindivoid _showToc() {final cs = Theme.of(context).colorScheme;- showModalBottomSheet(+ Widget header(BuildContext ctx, {required bool showClose}) => Padding(+ padding: showClose+ ? const EdgeInsets.fromLTRB(16, 8, 8, 8)+ : const EdgeInsets.all(16),+ child: Row(+ children: [+ Expanded(+ child: Text(+ AppLocalizations.of(ctx)!.readerChapters,+ style: Theme.of(ctx).textTheme.titleMedium?.copyWith(+ fontWeight: FontWeight.w600,+ color: cs.onSurface,+ ),+ ),+ ),+ if (showClose)+ IconButton(+ tooltip: MaterialLocalizations.of(ctx).closeButtonTooltip,+ onPressed: () => Navigator.pop(ctx),+ icon: const Icon(Icons.close_rounded),+ ),+ ],+ ),+ );++ showAdaptiveActionMenu<void>(context: context,backgroundColor: cs.surface,+ desktopWidth: 520,+ desktopScrollWrap: false,shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(20)),),- builder: (ctx) => SafeArea(- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Padding(- padding: const EdgeInsets.all(16),- child: Text(AppLocalizations.of(ctx)!.readerChapters,- style: Theme.of(ctx).textTheme.titleMedium?.copyWith(- fontWeight: FontWeight.w600, color: cs.onSurface)),+ builder: (ctx) {+ if (!ModalSurface.isDesktopOf(ctx)) {+ return SafeArea(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ header(ctx, showClose: false),+ Flexible(+ child: ListView(+ shrinkWrap: true,+ children: _tocTiles(_toc, ctx, 0),+ ),+ ),+ ],),- Flexible(child: ListView(shrinkWrap: true, children: _tocTiles(_toc, ctx, 0))),- ],- ),- ),+ );+ }+ return AdaptiveDraggableScrollableSheet(+ expand: false,+ builder: (_, scrollController) => SafeArea(+ child: Column(+ children: [+ header(ctx, showClose: true),+ Expanded(+ child: ListView(+ controller: scrollController,+ children: _tocTiles(_toc, ctx, 0),+ ),+ ),+ ],+ ),+ ),+ );+ },);}diff --git a/lib/widgets/metadata_lookup_sheet.dart b/lib/widgets/metadata_lookup_sheet.dartindex 53826f03..6887f9ae 100644--- a/lib/widgets/metadata_lookup_sheet.dart+++ b/lib/widgets/metadata_lookup_sheet.dart@@ -4,8 +4,28 @@ import 'package:cached_network_image/cached_network_image.dart';import '../l10n/app_localizations.dart';import '../services/api_service.dart';import '../services/metadata_override_service.dart';+import '../utils/desktop_workspace.dart';import 'overlay_toast.dart';+const double metadataFieldPickerDesktopMaxWidth = 540;+const double metadataFieldPickerDesktopMaxHeight = 720;+const double metadataFieldPickerDesktopHeightFraction = 0.8;++BoxConstraints? metadataFieldPickerDialogConstraints({+ required bool desktop,+ required double viewportHeight,+}) {+ if (!desktop) return null;+ final availableHeight =+ viewportHeight * metadataFieldPickerDesktopHeightFraction;+ return BoxConstraints(+ maxWidth: metadataFieldPickerDesktopMaxWidth,+ maxHeight: availableHeight < metadataFieldPickerDesktopMaxHeight+ ? availableHeight+ : metadataFieldPickerDesktopMaxHeight,+ );+}+/// Bottom sheet that lets users search for book metadata via the ABS server/// and pick a result to store as a local override, or manually edit fields.class MetadataLookupSheet extends StatefulWidget {@@ -208,6 +228,10 @@ class _MetadataLookupSheetState extends State<MetadataLookupSheet>final cs = Theme.of(ctx).colorScheme;final tt = Theme.of(ctx).textTheme;return AlertDialog(+ constraints: metadataFieldPickerDialogConstraints(+ desktop: isDesktopWorkspace(ctx),+ viewportHeight: MediaQuery.sizeOf(ctx).height,+ ),title: Text(l.metadataLookupChooseFields),content: SizedBox(width: double.maxFinite,diff --git a/lib/widgets/pdf_reader_view.dart b/lib/widgets/pdf_reader_view.dartindex c752a43b..7285d589 100644--- a/lib/widgets/pdf_reader_view.dart+++ b/lib/widgets/pdf_reader_view.dart@@ -10,6 +10,7 @@ import '../services/api_service.dart';import '../services/ebook_cache.dart';import '../services/progress_sync_service.dart';import '../services/volume_key_service.dart';+import 'adaptive_modal.dart';/// Full-screen PDF reader. PDFs are fixed-layout, so this is deliberately/// simpler than the EPUB reader (no font/margin/theme reflow): page scrolling,@@ -146,26 +147,73 @@ class _PdfReaderViewState extends State<PdfReaderView> with WidgetsBindingObservvoid _showOutline() {final cs = Theme.of(context).colorScheme;- showModalBottomSheet(+ Widget header(BuildContext ctx, {required bool showClose}) => Padding(+ padding: showClose+ ? const EdgeInsets.fromLTRB(16, 8, 8, 8)+ : const EdgeInsets.all(16),+ child: Row(+ children: [+ Expanded(+ child: Text(+ AppLocalizations.of(ctx)!.readerChapters,+ style: Theme.of(ctx).textTheme.titleMedium?.copyWith(+ fontWeight: FontWeight.w600,+ color: cs.onSurface,+ ),+ ),+ ),+ if (showClose)+ IconButton(+ tooltip: MaterialLocalizations.of(ctx).closeButtonTooltip,+ onPressed: () => Navigator.pop(ctx),+ icon: const Icon(Icons.close_rounded),+ ),+ ],+ ),+ );++ showAdaptiveActionMenu<void>(context: context,backgroundColor: cs.surface,+ desktopWidth: 520,+ desktopScrollWrap: false,shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(20)),),- builder: (ctx) => SafeArea(- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Padding(- padding: const EdgeInsets.all(16),- child: Text(AppLocalizations.of(ctx)!.readerChapters,- style: Theme.of(ctx).textTheme.titleMedium?.copyWith(- fontWeight: FontWeight.w600, color: cs.onSurface)),+ builder: (ctx) {+ if (!ModalSurface.isDesktopOf(ctx)) {+ return SafeArea(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ header(ctx, showClose: false),+ Flexible(+ child: ListView(+ shrinkWrap: true,+ children: _outlineTiles(_outline, ctx, 0),+ ),+ ),+ ],),- Flexible(child: ListView(shrinkWrap: true, children: _outlineTiles(_outline, ctx, 0))),- ],- ),- ),+ );+ }+ return AdaptiveDraggableScrollableSheet(+ expand: false,+ builder: (_, scrollController) => SafeArea(+ child: Column(+ children: [+ header(ctx, showClose: true),+ Expanded(+ child: ListView(+ controller: scrollController,+ children: _outlineTiles(_outline, ctx, 0),+ ),+ ),+ ],+ ),+ ),+ );+ },);}