From c4274ef52c8e570ea511a529dd8b0cd1c8fdee41 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Fri, 7 Jul 2023 14:38:40 +1000 Subject: [PATCH] More flexible `ModalBottomSheetInfo` By passing in a widget as child from the outside we can use this info model more flexible. --- .../lib/common/modal_bottom_sheet_info.dart | 24 ++++++++++--------- .../features/trade/trade_bottom_sheet.dart | 6 ++--- .../trade/trade_bottom_sheet_tab.dart | 14 +++++------ .../wallet/create_invoice_screen.dart | 6 ++--- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/mobile/lib/common/modal_bottom_sheet_info.dart b/mobile/lib/common/modal_bottom_sheet_info.dart index e47b5353e..e5219ee61 100644 --- a/mobile/lib/common/modal_bottom_sheet_info.dart +++ b/mobile/lib/common/modal_bottom_sheet_info.dart @@ -2,15 +2,17 @@ import 'package:flutter/material.dart'; import 'package:get_10101/common/color.dart'; class ModalBottomSheetInfo extends StatelessWidget { - final String infoText; - final String buttonText; - final EdgeInsets padding; + final Widget child; + final String closeButtonText; + final EdgeInsets infoButtonPadding; + + static const double buttonRadius = 20.0; const ModalBottomSheetInfo( {super.key, - required this.infoText, - required this.buttonText, - this.padding = const EdgeInsets.all(8.0)}); + required this.child, + required this.closeButtonText, + this.infoButtonPadding = const EdgeInsets.all(8.0)}); @override Widget build(BuildContext context) { @@ -20,7 +22,7 @@ class ModalBottomSheetInfo extends StatelessWidget { showModalBottomSheet( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical( - top: Radius.circular(20), + top: Radius.circular(buttonRadius), ), ), clipBehavior: Clip.antiAliasWithSaveLayer, @@ -33,16 +35,16 @@ class ModalBottomSheetInfo extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - // TODO: Add link to FAQ - Text(infoText), - ElevatedButton(onPressed: () => Navigator.pop(context), child: Text(buttonText)) + child, + ElevatedButton( + onPressed: () => Navigator.pop(context), child: Text(closeButtonText)) ], ), ); }, ); }, - padding: padding, + padding: infoButtonPadding, constraints: const BoxConstraints(), icon: Icon( Icons.info, diff --git a/mobile/lib/features/trade/trade_bottom_sheet.dart b/mobile/lib/features/trade/trade_bottom_sheet.dart index 021c216ba..7591efdd8 100644 --- a/mobile/lib/features/trade/trade_bottom_sheet.dart +++ b/mobile/lib/features/trade/trade_bottom_sheet.dart @@ -73,11 +73,11 @@ class TradeBottomSheet extends StatelessWidget { style: TextStyle(color: Colors.grey), ), ModalBottomSheetInfo( - infoText: "While in beta only market orders are enabled in the 10101 app.\n\n" + closeButtonText: "Back to order...", + child: Text("While in beta only market orders are enabled in the 10101 app.\n\n" "Market orders are executed at the best market price. \n\nPlease note that the displayed " "price is the best market price at the time but due to fast market " - "movements the market price for order fulfillment can be slightly different.", - buttonText: "Back to order...") + "movements the market price for order fulfillment can be slightly different.")) ], ), ), diff --git a/mobile/lib/features/trade/trade_bottom_sheet_tab.dart b/mobile/lib/features/trade/trade_bottom_sheet_tab.dart index 40e950a51..f3fa3a468 100644 --- a/mobile/lib/features/trade/trade_bottom_sheet_tab.dart +++ b/mobile/lib/features/trade/trade_bottom_sheet_tab.dart @@ -121,13 +121,13 @@ class _TradeBottomSheetTabState extends State { width: 5, ), ModalBottomSheetInfo( - infoText: + closeButtonText: "Back to order...", + infoButtonPadding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Text( "Your usable balance of $usableBalance sats takes a fixed reserve of $totalReserve sats into account. " "\n${channelReserve.sats} is the minimum amount that has to stay in the Lightning channel. " "\n${tradeFeeReserve.sats} is reserved for fees per trade that is needed for publishing on-chain transactions in a worst case scenario. This is needed for the self-custodial setup" - "\n\nWe are working on optimizing the reserve and it might be subject to change after the beta.", - buttonText: "Back to order...", - padding: const EdgeInsets.symmetric(horizontal: 8.0), + "\n\nWe are working on optimizing the reserve and it might be subject to change after the beta."), ) ], ), @@ -254,12 +254,12 @@ class _TradeBottomSheetTabState extends State { ), if (showCapacityInfo) ModalBottomSheetInfo( - infoText: + closeButtonText: "Back to order...", + child: Text( "Your channel capacity is limited to $channelCapacity sats. During the beta channel resize is not available yet" "In order to trade with higher margin you have to reduce your balance" "\n\nYour current usable balance is $usableBalance." - "Please send ${usableBalance - (channelCapacity.sats / coordinatorLiquidityMultiplier)} sats out of your wallet to free up capacity.", - buttonText: "Back to order...") + "Please send ${usableBalance - (channelCapacity.sats / coordinatorLiquidityMultiplier)} sats out of your wallet to free up capacity.")) ], ), LeverageSlider( diff --git a/mobile/lib/features/wallet/create_invoice_screen.dart b/mobile/lib/features/wallet/create_invoice_screen.dart index b41c5629d..5af224249 100644 --- a/mobile/lib/features/wallet/create_invoice_screen.dart +++ b/mobile/lib/features/wallet/create_invoice_screen.dart @@ -146,12 +146,12 @@ class _CreateInvoiceScreenState extends State { ), if (showValidationHint) ModalBottomSheetInfo( - infoText: + closeButtonText: "Back to Receive...", + child: Text( "While in beta, maximum channel capacity is limited to ${formatSats(maxChannelCapacity)}; channels above this capacity might get rejected." "\nThe maximum is enforced initially to ensure users only trade with small stakes until the software has proven to be stable." "\n\nYour current balance is ${formatSats(balance)}, so you can receive up to ${formatSats(maxReceiveAmount)}." - "\nIf you hold less than ${formatSats(minAmountToBeAbleToTrade)} or more than ${formatSats(maxAllowedOutboundCapacity)} in your wallet you might not be able to trade.", - buttonText: "Back to Receive..."), + "\nIf you hold less than ${formatSats(minAmountToBeAbleToTrade)} or more than ${formatSats(maxAllowedOutboundCapacity)} in your wallet you might not be able to trade.")), ], ), ),