Skip to content

Commit 7af859c

Browse files
authored
Merge pull request #86 from PapyrusReader/fix/content-sized-import-download-sheets
Fix import and download sheet content sizing
2 parents b1cbe8e + 1a9e637 commit 7af859c

6 files changed

Lines changed: 34 additions & 30 deletions

File tree

‎app/lib/widgets/add_book/book_import_drop_zone.dart‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'dart:math' as math;
22

33
import 'package:desktop_drop/desktop_drop.dart';
44
import 'package:flutter/material.dart';
5-
import 'package:papyrus/widgets/shared/expandable_bottom_sheet.dart';
65
import 'package:flutter/services.dart';
76
import 'package:papyrus/themes/design_tokens.dart';
87
import 'package:papyrus/widgets/add_book/book_import_batch_item.dart';
@@ -89,7 +88,7 @@ class _BookImportDropZoneState extends State<BookImportDropZone> {
8988
borderRadius: BorderRadius.circular(AppRadius.xl),
9089
child: LayoutBuilder(
9190
builder: (context, constraints) {
92-
final minimumHeight = constraints.hasBoundedHeight ? constraints.maxHeight : 0.0;
91+
final minimumHeight = constraints.minHeight;
9392

9493
return SingleChildScrollView(
9594
child: ConstrainedBox(
@@ -158,10 +157,7 @@ class _BookImportDropZoneState extends State<BookImportDropZone> {
158157
return SingleChildScrollView(
159158
child: ConstrainedBox(
160159
constraints: BoxConstraints(
161-
minHeight:
162-
context.findAncestorWidgetOfExactType<ExpandableBottomSheet>() == null && constraints.hasBoundedHeight
163-
? constraints.maxHeight
164-
: 0,
160+
minHeight: constraints.minHeight,
165161
),
166162
child: Column(
167163
mainAxisAlignment: MainAxisAlignment.center,

‎app/lib/widgets/add_book/book_import_sheet.dart‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class BookImportSheet extends StatefulWidget {
7979
builder: (sheetContext) {
8080
final effectivePickFiles = pickFiles ?? defaultPickFiles;
8181

82-
Widget buildSheet(ScrollController scrollController) => BookImportSheet(
82+
Widget buildSheet(ScrollController? scrollController) => BookImportSheet(
8383
pickFiles: effectivePickFiles,
8484
processor: effectiveProcessor,
8585
deleteBookFile: effectiveDeleter,
@@ -101,13 +101,7 @@ class BookImportSheet extends StatefulWidget {
101101
return ExpandableBottomSheet(builder: (_, controller) => buildSheet(controller));
102102
}
103103

104-
return DraggableScrollableSheet(
105-
initialChildSize: 0.6,
106-
minChildSize: 0.4,
107-
maxChildSize: 0.95,
108-
expand: false,
109-
builder: (_, controller) => buildSheet(controller),
110-
);
104+
return buildSheet(null);
111105
},
112106
);
113107
}

‎app/lib/widgets/add_book/book_import_sheet_sections.dart‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:flutter/material.dart';
2-
import 'package:papyrus/widgets/shared/expandable_bottom_sheet.dart';
32
import 'package:papyrus/themes/design_tokens.dart';
4-
import 'package:papyrus/widgets/add_book/add_book_sheet_scaffold.dart';
3+
import 'package:papyrus/widgets/shared/app_bottom_sheet.dart';
54
import 'package:papyrus/widgets/add_book/book_import_batch_item.dart';
65
import 'package:papyrus/widgets/add_book/book_import_drop_zone.dart';
76
import 'package:papyrus/widgets/add_book/book_import_item_card.dart';
@@ -39,9 +38,13 @@ class BookImportSelectingSection extends StatelessWidget {
3938
Widget build(BuildContext context) {
4039
final hasFiles = files.isNotEmpty;
4140

42-
return AddBookSheetScaffold(
41+
return AppBottomSheet(
42+
headerKey: const Key('add-book-sheet-header'),
43+
footerKey: const Key('add-book-sheet-footer'),
44+
expandOnScroll: false,
45+
scrollable: false,
46+
contentPadding: EdgeInsets.zero,
4347
title: 'Import books',
44-
footerPadding: const EdgeInsets.symmetric(horizontal: Spacing.md, vertical: Spacing.sm),
4548
canClose: true,
4649
onClose: onClose,
4750
body: hasFiles ? _buildFileList(context) : _buildBrowseOnly(context),
@@ -83,7 +86,7 @@ class BookImportSelectingSection extends StatelessWidget {
8386
final colorScheme = Theme.of(context).colorScheme;
8487

8588
return ListView(
86-
shrinkWrap: context.findAncestorWidgetOfExactType<ExpandableBottomSheet>() != null,
89+
shrinkWrap: true,
8790
controller: scrollController,
8891
padding: const EdgeInsets.symmetric(horizontal: Spacing.lg, vertical: Spacing.md),
8992
children: [
@@ -141,13 +144,17 @@ class BookImportProcessingSection extends StatelessWidget {
141144

142145
@override
143146
Widget build(BuildContext context) {
144-
return AddBookSheetScaffold(
147+
return AppBottomSheet(
148+
headerKey: const Key('add-book-sheet-header'),
149+
footerKey: const Key('add-book-sheet-footer'),
150+
expandOnScroll: false,
151+
scrollable: false,
152+
contentPadding: EdgeInsets.zero,
145153
title: 'Importing books',
146-
footerPadding: const EdgeInsets.symmetric(horizontal: Spacing.md, vertical: Spacing.sm),
147154
canClose: !isClosing,
148155
onClose: onClose,
149156
body: ListView.separated(
150-
shrinkWrap: context.findAncestorWidgetOfExactType<ExpandableBottomSheet>() != null,
157+
shrinkWrap: true,
151158
controller: scrollController,
152159
padding: const EdgeInsets.symmetric(horizontal: Spacing.lg, vertical: Spacing.md),
153160
itemCount: items.length,
@@ -195,13 +202,17 @@ class BookImportSummarySection extends StatelessWidget {
195202
Widget build(BuildContext context) {
196203
final hasFailures = failureCount > 0;
197204

198-
return AddBookSheetScaffold(
205+
return AppBottomSheet(
206+
headerKey: const Key('add-book-sheet-header'),
207+
footerKey: const Key('add-book-sheet-footer'),
208+
expandOnScroll: false,
209+
scrollable: false,
210+
contentPadding: EdgeInsets.zero,
199211
title: 'Import complete',
200-
footerPadding: const EdgeInsets.symmetric(horizontal: Spacing.md, vertical: Spacing.sm),
201212
canClose: !isClosing,
202213
onClose: onDone,
203214
body: ListView(
204-
shrinkWrap: context.findAncestorWidgetOfExactType<ExpandableBottomSheet>() != null,
215+
shrinkWrap: true,
205216
controller: scrollController,
206217
padding: const EdgeInsets.symmetric(horizontal: Spacing.lg, vertical: Spacing.md),
207218
children: items

‎app/lib/widgets/opds/opds_download_panel.dart‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ class _DownloadsList extends StatelessWidget {
6363
final jobs = downloads.jobs;
6464

6565
if (jobs.isEmpty) {
66-
return const EmptyState.compact(icon: Icons.downloading_outlined, title: 'No downloads yet');
66+
return const SingleChildScrollView(
67+
primary: true,
68+
child: EmptyState.compact(icon: Icons.downloading_outlined, title: 'No downloads yet'),
69+
);
6770
}
6871

6972
return ListView.separated(

‎app/lib/widgets/shelves/move_to_shelf_sheet.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class _MoveToShelfSheetState extends State<MoveToShelfSheet> with PersistentSave
166166
shrinkWrap: mobile,
167167
slivers: [
168168
SliverPadding(
169-
padding: const EdgeInsets.all(Spacing.lg),
169+
padding: const EdgeInsets.fromLTRB(Spacing.lg, Spacing.lg, Spacing.lg, Spacing.sm),
170170
sliver: SliverToBoxAdapter(
171171
child: SearchField(
172172
controller: _searchController,
@@ -186,7 +186,7 @@ class _MoveToShelfSheetState extends State<MoveToShelfSheet> with PersistentSave
186186
)
187187
else
188188
SliverPadding(
189-
padding: const EdgeInsets.symmetric(horizontal: Spacing.lg),
189+
padding: const EdgeInsets.fromLTRB(Spacing.lg, 0, Spacing.lg, Spacing.lg - Spacing.xs),
190190
sliver: SliverList.builder(
191191
itemCount: filtered.length,
192192
itemBuilder: (context, index) => _buildShelfTile(context, filtered[index]),

‎app/lib/widgets/topics/manage_topics_sheet.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class _ManageTopicsSheetState extends State<ManageTopicsSheet> with PersistentSa
164164
shrinkWrap: mobile,
165165
slivers: [
166166
SliverPadding(
167-
padding: const EdgeInsets.all(Spacing.lg),
167+
padding: const EdgeInsets.fromLTRB(Spacing.lg, Spacing.lg, Spacing.lg, Spacing.sm),
168168
sliver: SliverToBoxAdapter(
169169
child: SearchField(
170170
controller: _searchController,
@@ -184,7 +184,7 @@ class _ManageTopicsSheetState extends State<ManageTopicsSheet> with PersistentSa
184184
)
185185
else
186186
SliverPadding(
187-
padding: const EdgeInsets.symmetric(horizontal: Spacing.lg),
187+
padding: const EdgeInsets.fromLTRB(Spacing.lg, 0, Spacing.lg, Spacing.lg - Spacing.xs),
188188
sliver: SliverList.builder(
189189
itemCount: filtered.length,
190190
itemBuilder: (context, index) => _buildTagTile(context, filtered[index]),

0 commit comments

Comments
 (0)