Skip to content

Commit

Permalink
Fix: #325: Fee breakdown 1/2
Browse files Browse the repository at this point in the history
  • Loading branch information
saiy2k committed Sep 16, 2024
1 parent 4c3619d commit 4dbe74e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 44 deletions.
4 changes: 0 additions & 4 deletions lib/swap/fee_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,24 @@ import 'package:gap/gap.dart';
class FeePopUp extends StatelessWidget {
const FeePopUp({
super.key,
required this.fromWalletName,
required this.lockupFees,
required this.claimFees,
required this.boltzFees,
});

final String fromWalletName;
final int lockupFees;
final int claimFees;
final int boltzFees;

static Future openPopup(
BuildContext context,
String walletName,
int lockupFees,
int claimFees,
int boltzFees,
) {
return showBBBottomSheet(
context: context,
child: FeePopUp(
fromWalletName: walletName,
lockupFees: lockupFees,
claimFees: claimFees,
boltzFees: boltzFees,
Expand Down
37 changes: 0 additions & 37 deletions lib/swap/send.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ class _SwapFees extends StatelessWidget {
),
);

final walletName = context.select(
(SendCubit cubit) =>
cubit.state.selectedWalletBloc?.state.wallet?.name ?? '',
);

return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expand All @@ -97,7 +92,6 @@ class _SwapFees extends StatelessWidget {
onPressed: () {
FeePopUp.openPopup(
context,
walletName,
lockupFee,
swaptx.claimFees ?? 0,
swaptx.boltzFees ?? 0,
Expand Down Expand Up @@ -338,34 +332,3 @@ class SendTick extends StatelessWidget {
);
}
}

class _OnChainWarning extends StatelessWidget {
const _OnChainWarning({required this.swapTx});

final SwapTx swapTx;

@override
Widget build(BuildContext context) {
if (swapTx.isLiquid()) return const SizedBox.shrink();

return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FontAwesomeIcons.triangleExclamation,
color: context.colour.primary,
size: 20,
),
const Gap(8),
const SizedBox(
width: 250,
child: BBText.bodySmall(
'Your onchain payment has been sent, but the swap is still in progress. It will take on on-chain confirmation before the Lightning payment succeeds.',
isRed: true,
fontSize: 10,
),
),
],
);
}
}
1 change: 0 additions & 1 deletion lib/swap/swap_confirmation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ class _Screen extends StatelessWidget {
onPressed: () {
FeePopUp.openPopup(
context,
walletName,
senderFee,
swapTx.claimFees ?? 0,
swapTx.boltzFees ?? 0,
Expand Down
49 changes: 47 additions & 2 deletions lib/transaction/transaction_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:bb_mobile/locator.dart';
import 'package:bb_mobile/network/bloc/network_cubit.dart';
import 'package:bb_mobile/network_fees/bloc/networkfees_cubit.dart';
import 'package:bb_mobile/styles.dart';
import 'package:bb_mobile/swap/fee_popup.dart';
import 'package:bb_mobile/swap/watcher_bloc/watchtxs_bloc.dart';
import 'package:bb_mobile/transaction/bloc/state.dart';
import 'package:bb_mobile/transaction/bloc/transaction_cubit.dart';
Expand Down Expand Up @@ -505,6 +506,9 @@ class _SwapDetails extends StatelessWidget {
),
];

final lockupFee = swap.isReverse() ? 0 : tx.fee;
final claimFee = swap.isReverse() ? tx.fee : swap.claimFees;

return Padding(
padding: const EdgeInsets.all(24.0),
child: AnimatedContainer(
Expand Down Expand Up @@ -543,7 +547,26 @@ class _SwapDetails extends StatelessWidget {
),
if (fees != 0) ...[
const Gap(24),
const BBText.title('Total fees'),
Row(
children: [
const BBText.title('Total fees'),
IconButton(
icon: const Icon(Icons.info_outline),
iconSize: 22.0,
padding: EdgeInsets.zero,
color: context.colour.onPrimaryContainer,
onPressed: () {
FeePopUp.openPopup(
context,
lockupFee ?? 0,
claimFee ?? 0,
swap.boltzFees ?? 0,
);
// show popup
},
),
],
),
const Gap(4),
Row(
children: [
Expand Down Expand Up @@ -899,6 +922,9 @@ class _OnchainSwapDetails extends StatelessWidget {
const Gap(24),
];

final lockupFee = swap.isChainReceive() ? 0 : tx.fee;
final claimFee = swap.isChainReceive() ? tx.fee : swap.claimFees;

return Padding(
padding: const EdgeInsets.all(12.0),
child: AnimatedContainer(
Expand Down Expand Up @@ -940,7 +966,26 @@ class _OnchainSwapDetails extends StatelessWidget {
),
const Gap(24),
if (fees != 0) ...[
const BBText.title('Total fees'),
Row(
children: [
const BBText.title('Total fees'),
IconButton(
icon: const Icon(Icons.info_outline),
iconSize: 22.0,
padding: EdgeInsets.zero,
color: context.colour.onPrimaryContainer,
onPressed: () {
FeePopUp.openPopup(
context,
lockupFee ?? 0,
claimFee ?? 0,
swap.boltzFees ?? 0,
);
// show popup
},
),
],
),
const Gap(4),
Row(
children: [
Expand Down

0 comments on commit 4dbe74e

Please sign in to comment.