Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 41 additions & 39 deletions lib/core/swaps/domain/entity/swap.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:bb_mobile/core/settings/domain/settings_entity.dart';
import 'package:bb_mobile/core/utils/build_context_x.dart';
import 'package:bb_mobile/core/utils/constants.dart';
import 'package:bb_mobile/core/utils/percentage.dart';
import 'package:bb_mobile/core/utils/string_formatting.dart';
import 'package:bolt11_decoder/bolt11_decoder.dart';
import 'package:decimal/decimal.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'swap.freezed.dart';
Expand Down Expand Up @@ -38,21 +40,21 @@ enum SwapStatus {
expired,
failed;

String get displayName {
String displayName(BuildContext context) {
switch (this) {
case SwapStatus.pending:
return 'Pending';
return context.loc.coreSwapsStatusPending;
case SwapStatus.paid:
case SwapStatus.claimable:
case SwapStatus.refundable:
case SwapStatus.canCoop:
return 'In Progress';
return context.loc.coreSwapsStatusInProgress;
case SwapStatus.completed:
return 'Completed';
return context.loc.coreSwapsStatusCompleted;
case SwapStatus.expired:
return 'Expired';
return context.loc.coreSwapsStatusExpired;
case SwapStatus.failed:
return 'Failed';
return context.loc.coreSwapsStatusFailed;
}
}
}
Expand Down Expand Up @@ -311,13 +313,13 @@ sealed class Swap with _$Swap {
bool get isChainSwapExternal =>
this is ChainSwap && (this as ChainSwap).receiveWalletId == null;

String get swapAction =>
String swapAction(BuildContext context) =>
status == SwapStatus.claimable
? 'Claim'
? context.loc.coreSwapsActionClaim
: status == SwapStatus.canCoop
? 'Close'
? context.loc.coreSwapsActionClose
: status == SwapStatus.refundable
? 'Refund'
? context.loc.coreSwapsActionRefund
: '';

bool get swapCompleted => status == SwapStatus.completed;
Expand Down Expand Up @@ -426,82 +428,82 @@ class Invoice {
}

extension SwapStatusMessage on Swap {
String getDisplayMessage() {
String getDisplayMessage(BuildContext context) {
if (isLnReceiveSwap) {
switch (status) {
case SwapStatus.pending:
return "Swap is not yet initialized.";
return context.loc.coreSwapsLnReceivePending;
case SwapStatus.paid:
return "Sender has paid the invoice.";
return context.loc.coreSwapsLnReceivePaid;
case SwapStatus.claimable:
return "Swap is ready to be claimed.";
return context.loc.coreSwapsLnReceiveClaimable;
case SwapStatus.refundable:
return "Swap is ready to be refunded.";
return context.loc.coreSwapsLnReceiveRefundable;
case SwapStatus.canCoop:
return "Swap will complete momentarily.";
return context.loc.coreSwapsLnReceiveCanCoop;
case SwapStatus.completed:
return "Swap is completed.";
return context.loc.coreSwapsLnReceiveCompleted;
case SwapStatus.expired:
return "Swap Expired.";
return context.loc.coreSwapsLnReceiveExpired;
case SwapStatus.failed:
return "Swap Failed.";
return context.loc.coreSwapsLnReceiveFailed;
}
} else if (isLnSendSwap) {
switch (status) {
case SwapStatus.pending:
return "Swap is not yet initialized.";
return context.loc.coreSwapsLnSendPending;
case SwapStatus.paid:
return "Invoice will be paid after you payment receives confirmation.";
return context.loc.coreSwapsLnSendPaid;
case SwapStatus.claimable:
return "Swap is ready to be claimed.";
return context.loc.coreSwapsLnSendClaimable;
case SwapStatus.refundable:
return "Swap is ready to be refunded.";
return context.loc.coreSwapsLnSendRefundable;
case SwapStatus.canCoop:
return "Swap will complete momentarily.";
return context.loc.coreSwapsLnSendCanCoop;
case SwapStatus.completed:
final swap = this;
if (swap is LnSendSwap && swap.refundTxid != null) {
return "Swap has been refunded.";
return context.loc.coreSwapsLnSendCompletedRefunded;
} else {
return "Swap is completed successfully.";
return context.loc.coreSwapsLnSendCompletedSuccess;
}
case SwapStatus.expired:
return "Swap Expired";
return context.loc.coreSwapsLnSendExpired;
case SwapStatus.failed:
final swap = this;
if (swap is LnSendSwap && swap.sendTxid != null) {
return "Swap will be refunded shortly.";
return context.loc.coreSwapsLnSendFailedRefunding;
} else {
return "Swap Failed.";
return context.loc.coreSwapsLnSendFailed;
}
}
} else if (isChainSwap) {
switch (status) {
case SwapStatus.pending:
return "Transfer is not yet initialized.";
return context.loc.coreSwapsChainPending;
case SwapStatus.paid:
return "Waiting for transfer provider's payment to receive confirmation. This may take a while to complete.";
return context.loc.coreSwapsChainPaid;
case SwapStatus.claimable:
return "Transfer is ready to be claimed.";
return context.loc.coreSwapsChainClaimable;
case SwapStatus.refundable:
return "Transfer is ready to be refunded.";
return context.loc.coreSwapsChainRefundable;
case SwapStatus.canCoop:
return "Transfer will complete momentarily.";
return context.loc.coreSwapsChainCanCoop;
case SwapStatus.completed:
final swap = this;
if (swap is ChainSwap && swap.refundTxid != null) {
return "Transfer has been refunded.";
return context.loc.coreSwapsChainCompletedRefunded;
} else {
return "Transfer is completed successfully.";
return context.loc.coreSwapsChainCompletedSuccess;
}
case SwapStatus.expired:
return "Transfer Expired";
return context.loc.coreSwapsChainExpired;
case SwapStatus.failed:
final swap = this;
if (swap is ChainSwap && swap.sendTxid != null) {
return "Transfer will be refunded shortly.";
return context.loc.coreSwapsChainFailedRefunding;
} else {
return "Transfer Failed.";
return context.loc.coreSwapsChainFailed;
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions lib/core/wallet/domain/entities/wallet_transaction.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:bb_mobile/core/utils/build_context_x.dart';
import 'package:bb_mobile/core/wallet/domain/entities/transaction_input.dart';
import 'package:bb_mobile/core/wallet/domain/entities/transaction_output.dart';
import 'package:bb_mobile/core/wallet/domain/entities/wallet.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'wallet_transaction.freezed.dart';
Expand All @@ -11,12 +13,12 @@ enum WalletTransactionStatus {
pending,
confirmed;

String get displayName {
String displayName(BuildContext context) {
switch (this) {
case WalletTransactionStatus.pending:
return 'Pending';
return context.loc.coreWalletTransactionStatusPending;
case WalletTransactionStatus.confirmed:
return 'Confirmed';
return context.loc.coreWalletTransactionStatusConfirmed;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TransactionDetailsScreen extends StatelessWidget {
final isOrderType = tx?.isOrder == true;
final walletTransaction = tx?.walletTransaction;
final swap = tx?.swap;
final swapAction = swap?.swapAction ?? '';
final swapAction = swap?.swapAction(context) ?? '';
final isChainSwap = swap?.isChainSwap ?? false;
final retryingSwap = context.select(
(TransactionDetailsCubit bloc) => bloc.state.retryingSwap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class TransactionDetailsTable extends StatelessWidget {
),
DetailsTableItem(
label: context.loc.transactionDetailLabelStatus,
displayValue: walletTransaction.status.displayName,
displayValue: walletTransaction.status.displayName(context),
),
if (walletTransaction.confirmationTime != null)
DetailsTableItem(
Expand Down Expand Up @@ -740,9 +740,9 @@ class TransactionDetailsTable extends StatelessWidget {
swap.isLnSendSwap &&
(swap as LnSendSwap).refundTxid != null)
? context.loc.transactionDetailLabelRefunded
: swap.status.displayName,
: swap.status.displayName(context),
expandableChild: BBText(
swap.getDisplayMessage(),
swap.getDisplayMessage(context),
style: context.font.bodySmall?.copyWith(
color: context.appColors.secondary,
),
Expand Down
152 changes: 152 additions & 0 deletions localization/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,158 @@
}
}
},
"coreSwapsStatusPending": "Pending",
"@coreSwapsStatusPending": {
"description": "Display name for pending swap status"
},
"coreSwapsStatusInProgress": "In Progress",
"@coreSwapsStatusInProgress": {
"description": "Display name for in-progress swap status (paid, claimable, refundable, canCoop)"
},
"coreSwapsStatusCompleted": "Completed",
"@coreSwapsStatusCompleted": {
"description": "Display name for completed swap status"
},
"coreSwapsStatusExpired": "Expired",
"@coreSwapsStatusExpired": {
"description": "Display name for expired swap status"
},
"coreSwapsStatusFailed": "Failed",
"@coreSwapsStatusFailed": {
"description": "Display name for failed swap status"
},
"coreSwapsActionClaim": "Claim",
"@coreSwapsActionClaim": {
"description": "Action label for claiming a swap"
},
"coreSwapsActionClose": "Close",
"@coreSwapsActionClose": {
"description": "Action label for closing a swap cooperatively"
},
"coreSwapsActionRefund": "Refund",
"@coreSwapsActionRefund": {
"description": "Action label for refunding a swap"
},
"coreSwapsLnReceivePending": "Swap is not yet initialized.",
"@coreSwapsLnReceivePending": {
"description": "Status message for pending Lightning receive swap"
},
"coreSwapsLnReceivePaid": "Sender has paid the invoice.",
"@coreSwapsLnReceivePaid": {
"description": "Status message for paid Lightning receive swap"
},
"coreSwapsLnReceiveClaimable": "Swap is ready to be claimed.",
"@coreSwapsLnReceiveClaimable": {
"description": "Status message for claimable Lightning receive swap"
},
"coreSwapsLnReceiveRefundable": "Swap is ready to be refunded.",
"@coreSwapsLnReceiveRefundable": {
"description": "Status message for refundable Lightning receive swap"
},
"coreSwapsLnReceiveCanCoop": "Swap will complete momentarily.",
"@coreSwapsLnReceiveCanCoop": {
"description": "Status message for Lightning receive swap that can complete cooperatively"
},
"coreSwapsLnReceiveCompleted": "Swap is completed.",
"@coreSwapsLnReceiveCompleted": {
"description": "Status message for completed Lightning receive swap"
},
"coreSwapsLnReceiveExpired": "Swap Expired.",
"@coreSwapsLnReceiveExpired": {
"description": "Status message for expired Lightning receive swap"
},
"coreSwapsLnReceiveFailed": "Swap Failed.",
"@coreSwapsLnReceiveFailed": {
"description": "Status message for failed Lightning receive swap"
},
"coreSwapsLnSendPending": "Swap is not yet initialized.",
"@coreSwapsLnSendPending": {
"description": "Status message for pending Lightning send swap"
},
"coreSwapsLnSendPaid": "Invoice will be paid after your payment receives confirmation.",
"@coreSwapsLnSendPaid": {
"description": "Status message for paid Lightning send swap"
},
"coreSwapsLnSendClaimable": "Swap is ready to be claimed.",
"@coreSwapsLnSendClaimable": {
"description": "Status message for claimable Lightning send swap"
},
"coreSwapsLnSendRefundable": "Swap is ready to be refunded.",
"@coreSwapsLnSendRefundable": {
"description": "Status message for refundable Lightning send swap"
},
"coreSwapsLnSendCanCoop": "Swap will complete momentarily.",
"@coreSwapsLnSendCanCoop": {
"description": "Status message for Lightning send swap that can complete cooperatively"
},
"coreSwapsLnSendCompletedRefunded": "Swap has been refunded.",
"@coreSwapsLnSendCompletedRefunded": {
"description": "Status message for Lightning send swap completed via refund"
},
"coreSwapsLnSendCompletedSuccess": "Swap is completed successfully.",
"@coreSwapsLnSendCompletedSuccess": {
"description": "Status message for successfully completed Lightning send swap"
},
"coreSwapsLnSendExpired": "Swap Expired",
"@coreSwapsLnSendExpired": {
"description": "Status message for expired Lightning send swap"
},
"coreSwapsLnSendFailedRefunding": "Swap will be refunded shortly.",
"@coreSwapsLnSendFailedRefunding": {
"description": "Status message for failed Lightning send swap that will be refunded"
},
"coreSwapsLnSendFailed": "Swap Failed.",
"@coreSwapsLnSendFailed": {
"description": "Status message for failed Lightning send swap"
},
"coreSwapsChainPending": "Transfer is not yet initialized.",
"@coreSwapsChainPending": {
"description": "Status message for pending chain swap"
},
"coreSwapsChainPaid": "Waiting for transfer provider's payment to receive confirmation. This may take a while to complete.",
"@coreSwapsChainPaid": {
"description": "Status message for paid chain swap"
},
"coreSwapsChainClaimable": "Transfer is ready to be claimed.",
"@coreSwapsChainClaimable": {
"description": "Status message for claimable chain swap"
},
"coreSwapsChainRefundable": "Transfer is ready to be refunded.",
"@coreSwapsChainRefundable": {
"description": "Status message for refundable chain swap"
},
"coreSwapsChainCanCoop": "Transfer will complete momentarily.",
"@coreSwapsChainCanCoop": {
"description": "Status message for chain swap that can complete cooperatively"
},
"coreSwapsChainCompletedRefunded": "Transfer has been refunded.",
"@coreSwapsChainCompletedRefunded": {
"description": "Status message for chain swap completed via refund"
},
"coreSwapsChainCompletedSuccess": "Transfer is completed successfully.",
"@coreSwapsChainCompletedSuccess": {
"description": "Status message for successfully completed chain swap"
},
"coreSwapsChainExpired": "Transfer Expired",
"@coreSwapsChainExpired": {
"description": "Status message for expired chain swap"
},
"coreSwapsChainFailedRefunding": "Transfer will be refunded shortly.",
"@coreSwapsChainFailedRefunding": {
"description": "Status message for failed chain swap that will be refunded"
},
"coreSwapsChainFailed": "Transfer Failed.",
"@coreSwapsChainFailed": {
"description": "Status message for failed chain swap"
},
"coreWalletTransactionStatusPending": "Pending",
"@coreWalletTransactionStatusPending": {
"description": "Display name for pending wallet transaction status"
},
"coreWalletTransactionStatusConfirmed": "Confirmed",
"@coreWalletTransactionStatusConfirmed": {
"description": "Display name for confirmed wallet transaction status"
},
"onboardingScreenTitle": "Welcome",
"@onboardingScreenTitle": {
"description": "The title of the onboarding screen"
Expand Down
Loading