Skip to content

Commit

Permalink
More flexible ModalBottomSheetInfo
Browse files Browse the repository at this point in the history
By passing in a widget as child from the outside we can use this info model more flexible.
  • Loading branch information
da-kami committed Jul 7, 2023
1 parent 8ef391f commit c4274ef
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
24 changes: 13 additions & 11 deletions mobile/lib/common/modal_bottom_sheet_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -20,7 +22,7 @@ class ModalBottomSheetInfo extends StatelessWidget {
showModalBottomSheet<void>(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
top: Radius.circular(buttonRadius),
),
),
clipBehavior: Clip.antiAliasWithSaveLayer,
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions mobile/lib/features/trade/trade_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
],
),
),
Expand Down
14 changes: 7 additions & 7 deletions mobile/lib/features/trade/trade_bottom_sheet_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ class _TradeBottomSheetTabState extends State<TradeBottomSheetTab> {
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."),
)
],
),
Expand Down Expand Up @@ -254,12 +254,12 @@ class _TradeBottomSheetTabState extends State<TradeBottomSheetTab> {
),
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(
Expand Down
6 changes: 3 additions & 3 deletions mobile/lib/features/wallet/create_invoice_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ class _CreateInvoiceScreenState extends State<CreateInvoiceScreen> {
),
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.")),
],
),
),
Expand Down

0 comments on commit c4274ef

Please sign in to comment.