Skip to content

Commit 9109ec3

Browse files
committed
Add form for adding physical book.
1 parent e803470 commit 9109ec3

3 files changed

Lines changed: 721 additions & 256 deletions

File tree

client/lib/widgets/add_book/add_book_choice_sheet.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import 'package:papyrus/widgets/shared/bottom_sheet_handle.dart';
55

66
/// Choice sheet for selecting how to add a book: digital import or physical.
77
class AddBookChoiceSheet extends StatelessWidget {
8-
const AddBookChoiceSheet({super.key});
8+
const AddBookChoiceSheet({required this.callerContext, super.key});
9+
10+
/// The context of the page that opened this sheet.
11+
///
12+
/// Used to show follow-up sheets after this one is dismissed, since the
13+
/// dialog/bottom-sheet's own context becomes invalid after popping.
14+
final BuildContext callerContext;
915

1016
/// Show the choice sheet (bottom sheet on mobile, dialog on desktop).
1117
static Future<void> show(BuildContext context) {
@@ -15,15 +21,15 @@ class AddBookChoiceSheet extends StatelessWidget {
1521
if (isDesktop) {
1622
return showDialog(
1723
context: context,
18-
builder: (context) => Dialog(
24+
builder: (_) => Dialog(
1925
shape: RoundedRectangleBorder(
2026
borderRadius: BorderRadius.circular(AppRadius.dialog),
2127
),
2228
child: ConstrainedBox(
2329
constraints: const BoxConstraints(maxWidth: 480),
24-
child: const Padding(
25-
padding: EdgeInsets.all(Spacing.lg),
26-
child: AddBookChoiceSheet(),
30+
child: Padding(
31+
padding: const EdgeInsets.all(Spacing.lg),
32+
child: AddBookChoiceSheet(callerContext: context),
2733
),
2834
),
2935
),
@@ -35,14 +41,14 @@ class AddBookChoiceSheet extends StatelessWidget {
3541
shape: const RoundedRectangleBorder(
3642
borderRadius: BorderRadius.vertical(top: Radius.circular(AppRadius.xl)),
3743
),
38-
builder: (context) => Padding(
44+
builder: (_) => Padding(
3945
padding: const EdgeInsets.only(
4046
left: Spacing.lg,
4147
right: Spacing.lg,
4248
top: Spacing.md,
4349
bottom: Spacing.lg,
4450
),
45-
child: const AddBookChoiceSheet(),
51+
child: AddBookChoiceSheet(callerContext: context),
4652
),
4753
);
4854
}
@@ -52,10 +58,6 @@ class AddBookChoiceSheet extends StatelessWidget {
5258
final textTheme = Theme.of(context).textTheme;
5359
final isDesktop =
5460
MediaQuery.of(context).size.width >= Breakpoints.desktopSmall;
55-
// Capture the navigator before popping so we can use the parent route's
56-
// context (which stays mounted) for the next sheet/dialog.
57-
final navigator = Navigator.of(context);
58-
final parentContext = navigator.context;
5961

6062
return Column(
6163
mainAxisSize: MainAxisSize.min,
@@ -79,8 +81,8 @@ class AddBookChoiceSheet extends StatelessWidget {
7981
title: 'Add physical book',
8082
subtitle: 'Enter details manually',
8183
onTap: () {
82-
navigator.pop();
83-
AddPhysicalBookSheet.show(parentContext);
84+
Navigator.of(context).pop();
85+
AddPhysicalBookSheet.show(callerContext);
8486
},
8587
),
8688
],

0 commit comments

Comments
 (0)