Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/new-ui/pages/send_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ class _NewSendPageState extends State<NewSendPage> {
final balanceByAsset = <CryptoCurrency, CurrencyPickerBalance>{
for (final r in widget.sendViewModel.balanceViewModel.formattedBalances)
r.asset: CurrencyPickerBalance(
amount: "${r.availableBalance} ${r.asset.title}",
amount: "${r.availableBalance} ${r.formattedAssetTitle}",
fiat: isFiatDisabled ? null : "${r.fiatAvailableBalanceRaw} ${r.fiatCurrency?.symbol}",
fiatValue: isFiatDisabled ? null : double.tryParse(r.fiatAvailableBalanceRaw),
),
Expand Down
27 changes: 8 additions & 19 deletions lib/new-ui/pages/swap_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import "package:cake_wallet/src/widgets/primary_button.dart";
import "package:cake_wallet/utils/debounce.dart";
import "package:cake_wallet/utils/payment_request.dart";
import "package:cake_wallet/utils/show_pop_up.dart";
import "package:cake_wallet/view_model/dashboard/balance_view_model.dart";
import "package:cake_wallet/view_model/exchange/exchange_trade_view_model.dart";
import "package:cake_wallet/view_model/exchange/exchange_view_model.dart";
import "package:cake_wallet/view_model/wallet_switcher_view_model.dart";
Expand All @@ -53,7 +52,6 @@ class NewSwapPage extends StatefulWidget {
required this.walletSwitcherViewModel,
CryptoCurrency? initialCurrency,
this.fromSend,
this.balanceViewModel,
}) {
depositWalletName = exchangeViewModel.depositCurrency == CryptoCurrency.xmr
? exchangeViewModel.wallet.name
Expand All @@ -72,7 +70,6 @@ class NewSwapPage extends StatefulWidget {
final AddressResolverService adrResService;
final PaymentRequest? initialPaymentRequest;
final SwapFromSendArgs? fromSend;
final BalanceViewModel? balanceViewModel;
late final String? depositWalletName;
late final String? receiveWalletName;

Expand All @@ -97,16 +94,12 @@ class _NewSwapPageState extends State<NewSwapPage> {
.contains(widget.exchangeViewModel.depositCurrency) &&
!(widget.exchangeViewModel.status is SyncedSyncStatus);

Map<CryptoCurrency, CurrencyPickerBalance>? _depositBalanceByAsset() {
final balanceViewModel = widget.balanceViewModel;
if (balanceViewModel == null) {
return null;
}

Map<CryptoCurrency, CurrencyPickerBalance> _depositBalanceByAsset() {
final balanceViewModel = widget.exchangeViewModel.feesViewModel.balanceViewModel;
return {
for (final r in balanceViewModel.formattedBalances)
r.asset: CurrencyPickerBalance(
amount: "${r.availableBalance} ${r.asset.title}",
amount: "${r.availableBalance} ${r.formattedAssetTitle}",
fiat: balanceViewModel.isFiatDisabled
? null
: "${r.fiatAvailableBalanceRaw} ${r.fiatCurrency?.symbol}",
Expand Down Expand Up @@ -653,15 +646,10 @@ class _NewSwapPageState extends State<NewSwapPage> {
key: depositKey,
title: fromSend != null ? "" : S.of(context).send,
sourceSelectorMode: fromSend != null,
walletName: fromSend != null
? widget.exchangeViewModel.wallet.name
: null,
balanceByAsset:
fromSend != null ? _depositBalanceByAsset() : null,
useSingleNetworkLayout: fromSend != null,
filteredNetwork: fromSend != null
? widget.exchangeViewModel.wallet.type
: null,
walletName: widget.exchangeViewModel.wallet.name,
balanceByAsset: _depositBalanceByAsset(),
useSingleNetworkLayout: true,
filteredNetwork: widget.exchangeViewModel.wallet.type,
currency: widget.exchangeViewModel.depositCurrency,
useBaseUnit: widget.exchangeViewModel.useDepositBaseUnit,
hasRefundAddress: true,
Expand Down Expand Up @@ -758,6 +746,7 @@ class _NewSwapPageState extends State<NewSwapPage> {
svgPath: "assets/new-ui/swap_amounts.svg",
onPressed:
widget.exchangeViewModel.reverseSwapDirection,
semanticLabel: S.of(context).swap_reverse_direction,
),
],
),
Expand Down
1 change: 0 additions & 1 deletion lib/new-ui/widgets/anypay/anypay_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ class AnyPayFlow {
null,
walletSwitcherViewModel: walletSwitcherViewModel,
fromSend: SwapFromSendArgs.fromIntent(intent),
balanceViewModel: sendViewModel.balanceViewModel,
);
await Navigator.of(presentContext).push<void>(
CupertinoPageRoute(
Expand Down
8 changes: 4 additions & 4 deletions lib/new-ui/widgets/currency_picker/chain_chip_strip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _ChainChip extends StatelessWidget {
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsetsDirectional.only(end: 8),
padding: const EdgeInsetsDirectional.only(end: 4),
child: MergeSemantics(
child: Semantics(
button: true,
Expand All @@ -65,18 +65,18 @@ class _ChainChip extends StatelessWidget {
onTap: onTap,
borderRadius: BorderRadius.circular(80),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10),
padding: EdgeInsets.symmetric(horizontal: isSelected ? 12 : 10),
decoration: BoxDecoration(
color: isSelected ? colors.primary : colors.surfaceContainer,
borderRadius: BorderRadius.circular(20),
borderRadius: BorderRadius.circular(80),
),
child: Center(
child: Text(
label,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
fontSize: isSelected ? 14 : 12,
letterSpacing: -0.07,
letterSpacing: isSelected ? -0.07 : -0.06,
color: isSelected ? colors.onPrimary : colors.primary,
),
),
Expand Down
11 changes: 10 additions & 1 deletion lib/new-ui/widgets/currency_picker/currency_picker_args.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ String chainNameForCurrency(CryptoCurrency c) {
return wt != null ? walletTypeToString(wt) : (c.tag ?? "");
}

String assetNameForCurrency(CryptoCurrency c) => c == CryptoCurrency.btcln
? (CryptoCurrency.btc.fullName ?? CryptoCurrency.btc.title)
: (c.fullName ?? c.title);

final Set<String> _stablecoinSymbols = {
for (final c in CryptoCurrency.all)
if (c.groups.contains(CurrencyGroups.stablecoin)) c.title.toUpperCase(),
Expand Down Expand Up @@ -100,9 +104,10 @@ CurrencyPickerBalance? balanceForAsset(
}

final title = asset.title.toUpperCase();
final tag = asset.tag?.toUpperCase();
CurrencyPickerBalance? byTitle;
for (final entry in balances.entries) {
if (entry.key.title.toUpperCase() == title) {
if (entry.key.title.toUpperCase() == title && entry.key.tag?.toUpperCase() == tag) {
if (byTitle != null) {
return null;
}
Expand All @@ -124,6 +129,8 @@ class CurrencyPickerArgs {
required this.symbolResolver,
this.recentsSource = RecentsSource.none,
this.useSingleNetworkLayout = false,
this.walletName,
this.otherAssets,
});

final CryptoCurrency? selected;
Expand All @@ -134,4 +141,6 @@ class CurrencyPickerArgs {
final Map<CryptoCurrency, CurrencyPickerBalance>? balanceByAsset;
final RecentsSource recentsSource;
final bool useSingleNetworkLayout;
final String? walletName;
final CurrencyPickerArgs? otherAssets;
}
74 changes: 74 additions & 0 deletions lib/new-ui/widgets/currency_picker/currency_picker_footer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import "package:cake_wallet/generated/i18n.dart";
import "package:cake_wallet/new-ui/widgets/currency_picker/currency_picker_search_field.dart";
import "package:flutter/material.dart";

class CurrencyPickerFooter extends StatelessWidget {
const CurrencyPickerFooter({
required this.searchController,
this.action,
super.key,
});

final TextEditingController searchController;
final Widget? action;

static const double _actionHeight = 55;
static const double _actionGap = 16;

static const double _searchHeight = 60;
static const double _bottomMargin = 24;

static const double _fadeHeightWithAction = 200;
static const double _fadeHeight = 125;

static double heightFor({required bool hasAction}) =>
(hasAction ? _actionHeight + _actionGap : 0) + _searchHeight + _bottomMargin;

@override
Widget build(BuildContext context) {
final action = this.action;
return Positioned(
left: 0,
right: 0,
bottom: 0,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
IgnorePointer(
child: Container(
height: action == null ? _fadeHeight : _fadeHeightWithAction,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Theme.of(context).colorScheme.surface.withAlpha(0),
Theme.of(context).colorScheme.surface,
],
),
),
),
),
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (action != null) ...[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: SizedBox(height: _actionHeight, child: action),
),
const SizedBox(height: _actionGap),
],
CurrencyPickerSearchField(
controller: searchController,
hintText: S.of(context).search,
),
const SizedBox(height: _bottomMargin),
],
),
],
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class CurrencyPickerListContainer extends StatelessWidget {
height: 1,
thickness: 1,
color: colors.surfaceContainerHigh,
indent: 56,
endIndent: 24,
indent: 52,
endIndent: 12,
));
}
}
Expand Down
Loading
Loading