diff --git a/lib/redeem_ecash.dart b/lib/redeem_ecash.dart index eef62d53..abac960f 100644 --- a/lib/redeem_ecash.dart +++ b/lib/redeem_ecash.dart @@ -433,6 +433,7 @@ class _EcashRedeemPromptState extends State { ], ], ], + const SizedBox(height: 16), ], ); } diff --git a/lib/scan.dart b/lib/scan.dart index acc20fe2..24dfdd25 100644 --- a/lib/scan.dart +++ b/lib/scan.dart @@ -546,7 +546,7 @@ class _ScanQRPageState extends State { amount: field0, ); }, - heightFactor: 0.5, + fitContent: true, ); invoicePaidToastVisible.value = true; widget.onPay(chosenFederation!, false); diff --git a/lib/theme.dart b/lib/theme.dart index a324dc05..7e502705 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -55,6 +55,9 @@ Future showAppModalBottomSheet({ required Future Function() childBuilder, double? heightFactor, String? errorMessage, + // Size the sheet to its content, capped at [heightFactor] of the screen + // (default 0.9), instead of a fixed fraction. + bool fitContent = false, }) { final childFuture = childBuilder(); return showModalBottomSheet( @@ -65,10 +68,23 @@ Future showAppModalBottomSheet({ borderRadius: BorderRadius.vertical(top: Radius.circular(24)), ), builder: (context) { + Widget sized(Widget child) => + fitContent + ? ConstrainedBox( + constraints: BoxConstraints( + maxHeight: + MediaQuery.sizeOf(context).height * (heightFactor ?? 0.9), + ), + child: child, + ) + : FractionallySizedBox( + heightFactor: heightFactor ?? 0.8, + child: child, + ); + return SafeArea( - child: FractionallySizedBox( - heightFactor: heightFactor ?? 0.8, - child: Padding( + child: sized( + Padding( padding: EdgeInsets.only( bottom: MediaQuery.of(context).viewInsets.bottom, ), @@ -86,12 +102,14 @@ Future showAppModalBottomSheet({ ), ), // Async content - Expanded( + Flexible( + fit: fitContent ? FlexFit.loose : FlexFit.tight, child: FutureBuilder( future: childFuture, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center( + heightFactor: 1, child: Padding( padding: EdgeInsets.all(24.0), child: CircularProgressIndicator(), diff --git a/lib/widgets/transaction_details.dart b/lib/widgets/transaction_details.dart index 7904f06d..0e0b2cad 100644 --- a/lib/widgets/transaction_details.dart +++ b/lib/widgets/transaction_details.dart @@ -117,7 +117,7 @@ class _TransactionDetailsState extends State { amount: amount, ); }, - heightFactor: 0.33, + fitContent: true, ); invoicePaidToastVisible.value = true; }