CW-1273: Implement USDT0 Bridge (#2855)

* feat: Implement USDT0 Bridging using OFT Standard by Layer Zero. POC available in apps menu.

* feat: Implement USDT0 Bridging using OFT Standard by Layer Zero. POC available in apps menu.

* feat: Implement USDT0 Bridging using OFT Standard by Layer Zero. POC available in apps menu.

* Add transaction history and status polling for USDT0 bridging

* Add  Transaction history and status polling for USDT0 Bridging

* USDT0 Bridging Implementation

* Update Arbitrum USDT token symbol

* fix: Merge conflicts

* fix: Merge conflicts

* chore: Rever formatting

* feat: Implement new flow

* feat: Implement new ui flow

* Add currency to configure

* feat: new ui flow

* Update USDT0 implementation
- Switch to sqlite for storage instead of hive
- Switch bridge history and details to modals
- Switch bridge transfer details page to new tx details ui

* refactor: rearrange modal action buttons

* enhance usdt0 bridge flows

* Update lib/entities/wallet_manager.dart [skip ci]

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
David Adegoke
2026-04-15 05:06:05 +02:00
committed by GitHub
co-authored by Omar Hatem
parent 162e0a5300
commit 586a040e4a
45 changed files with 3958 additions and 43 deletions
@@ -0,0 +1,305 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/new-ui/pages/bridge/bridge_history_page.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/widgets/bottom_sheet/base_bottom_sheet_widget.dart';
import 'package:cake_wallet/src/widgets/bottom_sheet/info_bottom_sheet_widget.dart';
import 'package:cake_wallet/utils/request_review_handler.dart';
import 'package:cake_wallet/new-ui/widgets/keyboard_hide_overlay.dart';
import 'package:cake_wallet/new-ui/widgets/modern_button.dart';
import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
import 'package:cake_wallet/view_model/bridge_history_view_model.dart';
import 'package:cake_wallet/view_model/bridge/bridge_view_model.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
class BridgeAmountPage extends StatefulWidget {
const BridgeAmountPage({
super.key,
required this.bridgeViewModel,
required this.bridgeHistoryViewModel,
required this.initialToken,
});
final BridgeViewModel bridgeViewModel;
final BridgeHistoryViewModel bridgeHistoryViewModel;
final CryptoCurrency initialToken;
@override
State<BridgeAmountPage> createState() => _BridgeAmountPageState();
}
class _BridgeAmountPageState extends State<BridgeAmountPage> {
late final TextEditingController _amountController;
BridgeViewModel get bridgeViewModel => widget.bridgeViewModel;
@override
void initState() {
super.initState();
bridgeViewModel.applyInitialBridgeToken(widget.initialToken);
bridgeViewModel.onBridgeSuccess = _showBridgeSuccessBottomSheet;
_amountController = TextEditingController();
WidgetsBinding.instance.addPostFrameCallback((_) {
bridgeViewModel.ensureFiatPriceForSelectedToken();
});
}
void _showBridgeSuccessBottomSheet() {
if (!mounted) return;
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (!mounted) return;
final ctx = context;
if (!ctx.mounted) return;
await showModalBottomSheet<void>(
context: ctx,
isScrollControlled: true,
builder: (BuildContext bottomSheetContext) {
return InfoBottomSheet(
footerType: FooterType.doubleActionButton,
titleText: 'Bridge initiated!',
contentImage: 'assets/images/birthday_cake.png',
content: 'The bridging will take between 30 seconds and 3 '
'minutes to complete.',
doubleActionLeftButtonText: S.of(bottomSheetContext).close,
doubleActionRightButtonText: 'View history',
onLeftActionButtonPressed: () {
bridgeViewModel.clearBridgeSuccess();
Navigator.of(context, rootNavigator: true).pop();
RequestReviewHandler.requestReview();
},
onRightActionButtonPressed: () {
bridgeViewModel.clearBridgeSuccess();
Navigator.of(context).popUntil((route) => route.isFirst);
showMaterialModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (ctx) => BridgeHistoryPage(widget.bridgeHistoryViewModel),
);
},
);
},
);
});
}
@override
void dispose() {
bridgeViewModel.onBridgeSuccess = null;
bridgeViewModel.setAmount('');
_amountController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return KeyboardHideOverlay(
unfocusOnTap: true,
child: Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
),
child: Column(
children: [
ModalTopBar(
title: 'Enter Amount',
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
onLeadingPressed: () => Navigator.of(context, rootNavigator: true).pop(),
trailingIcon: const Icon(Icons.calendar_month, size: 18),
onTrailingPressed: () {
Navigator.pushNamed(context, Routes.bridgeHistoryPage, arguments: widget.bridgeHistoryViewModel);
},
),
Expanded(
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 18),
child: Observer(
builder: (_) {
final canNext = bridgeViewModel.canProceedToDestinationNetwork;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Spacer(flex: 2),
LayoutBuilder(
builder: (context, constraints) {
return Center(
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: (constraints.maxWidth - 200)
.clamp(40.0, constraints.maxWidth),
minWidth: 40,
),
child: TextFormField(
controller: _amountController,
maxLines: 1,
onChanged: bridgeViewModel.setAmount,
autovalidateMode: AutovalidateMode.always,
validator: bridgeViewModel.decimalAmountValidator,
keyboardType: TextInputType.numberWithOptions(
signed: false,
decimal: true,
),
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(
RegExp(r'^\d*[.,]?\d*$'),
),
],
textAlign: TextAlign.center,
decoration: InputDecoration(
isDense: true,
hintText: '0.00',
hintStyle: theme.textTheme.displayMedium?.copyWith(
fontWeight: FontWeight.w400,
color: theme.colorScheme.onSurfaceVariant,
),
),
style: theme.textTheme.displayMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 45,
color: theme.colorScheme.onSurface,
),
),
),
const SizedBox(width: 8),
Text(
bridgeViewModel.selectedToken?.title ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.displayMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 45,
color: theme.colorScheme.onSurfaceVariant,
),
),
],
),
);
},
),
const SizedBox(height: 12),
Center(
child: Text(
bridgeViewModel.fiatAmountFormatted.isEmpty
? ''
: '~${bridgeViewModel.fiatAmountFormatted} ${bridgeViewModel.fiatCurrencyTitle}',
style: theme.textTheme.headlineSmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w600,
fontSize: 22,
letterSpacing: -0.11,
),
),
),
if (bridgeViewModel.amountError != null) ...[
const SizedBox(height: 10),
Text(
bridgeViewModel.amountError!,
textAlign: TextAlign.center,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.error,
),
),
],
const Spacer(flex: 3),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: RichText(
maxLines: 2,
overflow: TextOverflow.ellipsis,
text: TextSpan(
children: [
TextSpan(
text: 'Available ',
style: theme.textTheme.bodyLarge?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w400,
fontSize: 16,
letterSpacing: -0.08,
),
),
TextSpan(
text: '${bridgeViewModel.tokenBalanceFormatted} '
'${bridgeViewModel.selectedToken?.title ?? ''}',
style: theme.textTheme.bodyLarge?.copyWith(
color: theme.colorScheme.onSurface,
fontWeight: FontWeight.w400,
fontSize: 16,
letterSpacing: -0.08,
),
),
],
),
),
),
const SizedBox(width: 10),
TextButton(
style: TextButton.styleFrom(
textStyle: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: -0.07,
),
foregroundColor: theme.colorScheme.primary,
backgroundColor: theme.colorScheme.surfaceContainer,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(80),
),
),
onPressed: () {
bridgeViewModel.setMaxAmount();
_amountController.text = bridgeViewModel.amount;
_amountController.selection = TextSelection.collapsed(
offset: _amountController.text.length,
);
},
child: Text(S.of(context).max),
),
const SizedBox(width: 10),
IgnorePointer(
ignoring: !canNext,
child: ModernButton(
size: 48,
backgroundColor: theme.colorScheme.primary,
iconColor: theme.colorScheme.onPrimary,
icon: Icon(Icons.arrow_forward, size: 25),
onPressed: () {
_amountController.clear();
Navigator.pushNamed(
context, Routes.bridgeDestinationNetworkPage, arguments: bridgeViewModel);
},
),
),
],
),
],
);
},
),
),
),
),
],
),
),
);
}
}
@@ -0,0 +1,227 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/new-ui/widgets/bridge/confirm_details_card.dart';
import 'package:cake_wallet/new-ui/widgets/bridge/network_path_pill.dart';
import 'package:cake_wallet/new-ui/widgets/confirm_swiper.dart';
import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
import 'package:cake_wallet/new-ui/widgets/send_page/send_confirm_bottom_widget.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:cake_wallet/view_model/bridge/bridge_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
class BridgeConfirmSheet extends StatefulWidget {
const BridgeConfirmSheet(this.bridgeViewModel);
final BridgeViewModel bridgeViewModel;
@override
State<BridgeConfirmSheet> createState() => _BridgeConfirmSheetState();
}
class _BridgeConfirmSheetState extends State<BridgeConfirmSheet> {
late final ReactionDisposer _successDisposer;
BridgeViewModel get bridgeViewModel => widget.bridgeViewModel;
@override
void initState() {
super.initState();
_successDisposer = reaction(
(_) => bridgeViewModel.bridgeSuccess,
(bool success) {
if (success && mounted) {
Navigator.of(context).maybePop();
}
},
);
WidgetsBinding.instance.addPostFrameCallback((_) {
bridgeViewModel.loadQuote();
bridgeViewModel.ensureFiatPriceForSelectedToken();
bridgeViewModel.ensureFiatPriceForNativeCurrency();
});
}
@override
void dispose() {
_successDisposer();
super.dispose();
}
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return Container(
decoration: BoxDecoration(
color: scheme.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
),
child: SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Observer(
builder: (_) {
return ModalTopBar(
title: '',
leadingWidget: Row(
spacing: 8,
children: [
CakeImageWidget(
imageUrl: bridgeViewModel.selectedToken?.iconPath ?? '',
width: 36,
height: 36,
),
Text(
'Bridge',
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.w500,
fontSize: 20,
letterSpacing: -0.1,
color: scheme.onSurface,
),
),
],
),
trailingIcon: const Icon(Icons.close),
onTrailingPressed: () => Navigator.of(context).maybePop(),
);
},
),
SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Observer(
builder: (_) {
if (bridgeViewModel.isQuoteLoading && bridgeViewModel.quote == null) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 48),
child: Center(
child: CircularProgressIndicator(),
),
);
}
if (bridgeViewModel.quoteError != null) {
return Padding(
padding: const EdgeInsets.only(bottom: 24),
child: Column(
children: [
Text(
bridgeViewModel.quoteError!,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: -0.07,
color: scheme.error,
),
),
const SizedBox(height: 16),
FilledButton(
onPressed: () => bridgeViewModel.loadQuote(),
child: Text(
S.of(context).try_again,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
fontSize: 16,
letterSpacing: -0.08,
color: scheme.onPrimary,
),
),
),
],
),
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: 24,
children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
Text(
bridgeViewModel.amountDisplayFormatted,
style: Theme.of(context).textTheme.displaySmall?.copyWith(
fontSize: 36,
fontWeight: FontWeight.w400,
color: scheme.onSurface,
),
),
Text(
bridgeViewModel.selectedToken?.title ?? '',
style: Theme.of(context).textTheme.displaySmall?.copyWith(
fontSize: 36,
fontWeight: FontWeight.w400,
color: scheme.onSurfaceVariant,
),
),
],
),
const SizedBox(height: 4),
Text(
'${bridgeViewModel.fiatCurrencyTitle} ${bridgeViewModel.fiatAmountFormatted}',
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontSize: 20,
fontWeight: FontWeight.w500,
color: scheme.onSurfaceVariant,
letterSpacing: -0.1,
),
),
],
),
NetworkPathPill(
sourceChainName: bridgeViewModel.wallet.type.name,
destChainName: bridgeViewModel.destinationChainInfo?.name ?? '',
),
ConfirmDetailsCard(bridgeViewModel: bridgeViewModel),
if (bridgeViewModel.executeError != null) ...[
Text(
bridgeViewModel.executeError!,
textAlign: TextAlign.center,
style: TextStyle(color: scheme.error),
),
],
const SizedBox(height: 8),
],
);
},
),
),
Padding(
padding: const EdgeInsets.fromLTRB(24, 0, 24, 16),
child: Observer(
builder: (_) {
if (bridgeViewModel.isExecuting) {
return const LoadingBottomWidget(
text: 'Bridging...',
);
}
final canSwipe = bridgeViewModel.quote != null && !bridgeViewModel.isQuoteLoading;
return IgnorePointer(
ignoring: !canSwipe,
child: Opacity(
opacity: canSwipe ? 1 : 0.45,
child: ConfirmSwiper(
onConfirmed: () {
bridgeViewModel.executeBridge();
},
swiperText: 'Swipe to bridge',
),
),
);
},
),
),
],
),
),
);
}
}
@@ -0,0 +1,160 @@
import 'package:cake_wallet/entities/new_ui_entities/list_item/list_item_regular_row.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
import 'package:cake_wallet/src/screens/trade_details/track_trade_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/address_list_item.dart';
import 'package:cake_wallet/src/screens/transaction_details/transaction_details_list_item.dart';
import 'package:cake_wallet/src/widgets/new_list_row/new_list_section.dart';
import 'package:cake_wallet/themes/core/custom_theme_colors.dart';
import 'package:cake_wallet/utils/address_formatter.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/view_model/bridge_details_view_model.dart';
import 'package:cw_core/generate_name.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class BridgeDetailPage extends StatelessWidget {
BridgeDetailPage({super.key, required this.viewModel});
final BridgeDetailsViewModel viewModel;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return DraggableScrollableSheet(
expand: false,
initialChildSize: 0.6,
minChildSize: 0.25,
maxChildSize: 0.9,
snap: true,
snapSizes: const [0.9],
builder: (context, controller) {
return SafeArea(
bottom: false,
child: Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: Column(
children: [
ModalTopBar(
title: "Bridge Transfer Details",
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
onLeadingPressed: () => Navigator.of(context).pop(),
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
NewListSections(
sections: {
"": viewModel.items
.where((item) => item is! TrackTradeListItem)
.map((item) {
return ListItemRegularRow(
onTap: () {
Clipboard.setData(ClipboardData(text: item.value));
showBar<void>(context, S.of(context).copied_to_clipboard);
},
showArrow: false,
keyValue: item.title,
label: item.title,
trailingWidget: _buildTrailingWidget(item, context),
bottomWidget: _buildBottomWidget(item, context),
);
}).toList(),
},
),
SizedBox(height: 16),
NewListSections(sections: {
"": viewModel.items
.where((item) => item is TrackTradeListItem)
.map((item) {
return ListItemRegularRow(
keyValue: "view tx on",
label: item.title,
onTap: () => (item as TrackTradeListItem).onTap(),
foregroundColor: Theme.of(context).colorScheme.primary,
trailingIconPath: "assets/new-ui/link_arrow.svg",
trailingIconSize: 8,
);
}).toList()
}),
],
),
),
),
SizedBox(height: MediaQuery.of(context).viewPadding.bottom)
],
),
),
),
),
);
},
);
}
Widget _buildBottomWidget(TransactionDetailsListItem item, BuildContext context) {
if (item is AddressListItem) {
return AddressFormatter.buildSegmentedAddress(
address: item.value,
evenTextStyle: TextStyle(
fontSize: 12,
fontFamily: "IBM Plex Mono",
color: Theme.of(context).colorScheme.onSurface));
}
final isCompleted = item.value.contains("Completed");
final isInitiated = item.value.contains("initiated");
if (isCompleted || isInitiated) {
return Row(
children: [
Container(
height: 8,
width: 8,
decoration: BoxDecoration(
color: isCompleted ? CustomThemeColors.syncGreen : CustomThemeColors.syncYellow,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Theme.of(context).colorScheme.surface,
width: 1.5,
),
),
),
SizedBox(width: 8),
Text(
item.value,
style: TextStyle(fontSize: 14, color: Theme.of(context).colorScheme.onSurfaceVariant),
),
],
);
}
return SizedBox.shrink();
}
Widget _buildTrailingWidget(TransactionDetailsListItem item, BuildContext context) {
final isCompleted = item.value.contains("Completed");
final isInitiated = item.value.contains("initiated");
if (item is AddressListItem || isCompleted || isInitiated) {
return SizedBox.shrink();
}
return Text(
item.value.capitalized(),
style: TextStyle(
fontWeight: FontWeight.w400,
fontFamily: 'Wix Madefor Text',
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
);
}
}
@@ -0,0 +1,117 @@
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/new-ui/pages/bridge/bridge_detail_page.dart';
import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
import 'package:cake_wallet/view_model/bridge_history_view_model.dart';
import 'package:cake_wallet/new-ui/widgets/bridge/transfer_history_row.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class BridgeHistoryPage extends StatelessWidget {
BridgeHistoryPage(this.viewModel);
final BridgeHistoryViewModel viewModel;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: Column(
children: [
ModalTopBar(
title: "Bridge history",
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
onLeadingPressed: () => Navigator.of(context).pop(),
),
Expanded(
child: Observer(
builder: (_) {
if (viewModel.isEmpty) {
return Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Text(
"No bridge transfers yet.",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyLarge,
),
),
);
}
final active = viewModel.activeTransfers;
final past = viewModel.pastTransfers;
final items = <Widget>[];
if (active.isNotEmpty) {
items.add(
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
"In progress",
style: Theme.of(context).textTheme.titleSmall,
),
),
);
for (final transfer in active) {
items.add(
TransferHistoryRow(
transfer: transfer,
onTap: () {
final page = getIt.get<BridgeDetailPage>(param1: transfer);
showModalBottomSheet(
backgroundColor: Colors.transparent,
isScrollControlled: true,
context: context,
builder: (context) => page,
);
},
),
);
}
}
if (past.isNotEmpty) {
items.add(
Padding(
padding: const EdgeInsets.only(bottom: 8.0, top: 16),
child: Text(
"Past",
style: Theme.of(context).textTheme.titleSmall,
),
),
);
for (final transfer in past) {
items.add(
TransferHistoryRow(
transfer: transfer,
onTap: () {
final page = getIt.get<BridgeDetailPage>(param1: transfer);
showModalBottomSheet(
backgroundColor: Colors.transparent,
isScrollControlled: true,
context: context,
builder: (context) => page,
);
},
),
);
}
}
return ListView(
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 8),
children: items,
);
},
),
),
],
),
);
}
}
@@ -0,0 +1,98 @@
import 'package:cake_wallet/entities/new_ui_entities/list_item/list_item_regular_row.dart';
import 'package:cake_wallet/new-ui/widgets/keyboard_hide_overlay.dart';
import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/widgets/new_list_row/list_item_regular_row_widget.dart';
import 'package:cake_wallet/src/widgets/new_list_row/new_list_section.dart';
import 'package:cake_wallet/view_model/bridge/bridge_view_model.dart';
import 'package:cw_core/generate_name.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class BridgeNetworkPage extends StatelessWidget {
const BridgeNetworkPage(this.bridgeViewModel);
final BridgeViewModel bridgeViewModel;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return KeyboardHideOverlay(
unfocusOnTap: true,
child: Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: Column(
children: [
ModalTopBar(
title: 'Destination Network',
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
onLeadingPressed: () => Navigator.of(context).pop(),
),
SizedBox(height: 48),
Padding(
padding: const EdgeInsets.fromLTRB(18, 8, 18, 16),
child: Text(
'Select what Network to transfer your assets to',
textAlign: TextAlign.center,
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
SizedBox(height: 24),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 18),
child: Column(
children: [
Observer(
builder: (_) {
return NewListSections(
sections: {
'': bridgeViewModel.availableDestinationChains.map(
(chain) {
final chainName = chain.name;
return ListItemRegularRow(
iconPath: 'assets/images/crypto/${chainName.toLowerCase()}.webp',
keyValue: chain.chainId.toString(),
label: chainName,
onTap: () {
bridgeViewModel.setDestinationChain(chain.chainId);
Navigator.pushNamed(context, Routes.bridgeReceivingWalletPage, arguments: bridgeViewModel);
},
);
},
).toList(),
},
);
},
),
SizedBox(height: 24),
Observer(
builder: (_) {
final src = bridgeViewModel.wallet.type.name;
return ListItemRegularRowWidget(
isFirstInSection: true,
isLastInSection: true,
keyValue: 'sending_from',
label: 'Sending from',
trailingIconPath: 'assets/new-ui/chain_badges/${src.toLowerCase()}.svg',
trailingText: src.capitalized(),
);
},
),
],
),
),
),
],
),
),
);
}
}
@@ -0,0 +1,160 @@
import 'package:cake_wallet/core/address_validator.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/new-ui/pages/bridge/bridge_confirm_sheet.dart';
import 'package:cake_wallet/new-ui/widgets/keyboard_hide_overlay.dart';
import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
import 'package:cake_wallet/new-ui/widgets/send_page/send_address_input.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:cake_wallet/view_model/bridge/bridge_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
class BridgeReceiveAddressInputPage extends StatefulWidget {
const BridgeReceiveAddressInputPage({super.key, required this.bridgeViewModel});
final BridgeViewModel bridgeViewModel;
@override
State<BridgeReceiveAddressInputPage> createState() => _BridgeReceiveAddressInputPageState();
}
class _BridgeReceiveAddressInputPageState extends State<BridgeReceiveAddressInputPage> {
BridgeViewModel get bridgeViewModel => widget.bridgeViewModel;
late final TextEditingController _controller;
final FocusNode _focusNode = FocusNode();
@override
void initState() {
super.initState();
_controller = TextEditingController();
_controller.addListener(() => setState(() {}));
}
@override
void dispose() {
_controller.dispose();
_focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return KeyboardHideOverlay(
unfocusOnTap: true,
child: Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: Column(
children: [
ModalTopBar(
title: 'Input Receive Address',
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
onLeadingPressed: () => Navigator.of(context).pop(),
),
SizedBox(height: 48),
Expanded(
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 18),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Observer(
builder: (_) {
final chainName = bridgeViewModel.destinationChainInfo?.name;
return Column(
children: [
Text(
'Make sure it is compatible with:',
textAlign: TextAlign.center,
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
fontSize: 14,
fontWeight: FontWeight.w400,
letterSpacing: -0.07,
),
),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CakeImageWidget(
imageUrl:
'assets/new-ui/chain_badges/${chainName?.toLowerCase()}.svg',
width: 24,
height: 24,
color: theme.colorScheme.onSurfaceVariant,
),
const SizedBox(width: 4),
Text(
chainName ?? '',
style: theme.textTheme.bodyMedium?.copyWith(
fontSize: 14,
color: theme.colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w400,
letterSpacing: -0.07,
),
),
],
),
],
);
},
),
const SizedBox(height: 24),
NewSendAddressInput(
hintText: 'Enter Address',
addressController: _controller,
focusNode: _focusNode,
selectedCurrency: bridgeViewModel.wallet.currency,
onEditingComplete: () {},
validator: AddressValidator(type: bridgeViewModel.destinationChainInfo!.currency),
),
const Spacer(),
Observer(
builder: (_) {
return FilledButton(
onPressed: () {
final overlayCtx = Navigator.of(context).overlay?.context;
bridgeViewModel.setRecipientAddress(_controller.text.trim());
WidgetsBinding.instance.addPostFrameCallback((_) {
if (overlayCtx != null && overlayCtx.mounted) {
showMaterialModalBottomSheet<void>(
context: overlayCtx,
backgroundColor: Colors.transparent,
builder: (ctx) =>
BridgeConfirmSheet(bridgeViewModel),
);
}
});
},
style: FilledButton.styleFrom(
padding: const EdgeInsets.all(16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18),
),
),
child: Text(S.of(context).continue_text),
);
},
),
const SizedBox(height: 12),
],
),
),
),
),
],
),
),
);
}
}
@@ -0,0 +1,264 @@
import 'package:cake_wallet/view_model/bridge/bridge_receiving_wallet_option.dart';
import 'package:cake_wallet/new-ui/pages/bridge/bridge_confirm_sheet.dart';
import 'package:cake_wallet/new-ui/pages/bridge/bridge_receive_address_input_page.dart';
import 'package:cake_wallet/new-ui/widgets/keyboard_hide_overlay.dart';
import 'package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:cake_wallet/src/widgets/new_list_row/list_Item_style_wrapper.dart';
import 'package:cake_wallet/view_model/bridge/bridge_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
class BridgeReceivingWalletPage extends StatefulWidget {
const BridgeReceivingWalletPage(this.bridgeViewModel);
final BridgeViewModel bridgeViewModel;
@override
State<BridgeReceivingWalletPage> createState() => _BridgeReceivingWalletPageState();
}
class _BridgeReceivingWalletPageState extends State<BridgeReceivingWalletPage> {
BridgeViewModel get bridgeViewModel => widget.bridgeViewModel;
@override
void initState() {
super.initState();
bridgeViewModel.loadReceivingWalletOptions();
}
@override
Widget build(BuildContext context) {
return KeyboardHideOverlay(
unfocusOnTap: true,
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
child: Column(
children: [
ModalTopBar(
title: 'Receiving Wallet',
leadingIcon: const Icon(Icons.arrow_back_ios_new, size: 18),
onLeadingPressed: () => Navigator.of(context).pop(),
),
const SizedBox(height: 48),
Expanded(
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 18),
child: Observer(
builder: (_) {
final chain = bridgeViewModel.destinationChainInfo;
final chainName = chain?.name ?? '';
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 8),
Center(
child: CakeImageWidget(
borderRadius: 8,
imageUrl: chainName.isNotEmpty
? 'assets/images/crypto/${chainName.toLowerCase()}.webp'
: null,
width: 72,
height: 72,
),
),
const SizedBox(height: 20),
Text(
'Select a $chainName wallet or address to send '
'the bridged USDT0 to.',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: -0.07,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 24),
if (bridgeViewModel.isBridgeReceivingWalletListLoading)
const Expanded(
child: Center(
child: CircularProgressIndicator(),
),
)
else
Expanded(
child: ListView(
padding: const EdgeInsets.only(bottom: 16),
children: _receivingListRows(context),
),
),
],
);
},
),
),
),
),
],
),
),
);
}
List<Widget> _receivingListRows(BuildContext context) {
final options = bridgeViewModel.bridgeReceivingWalletOptions;
final rows = <Widget>[];
for (int i = 0; i < options.length; i++) {
final option = options[i];
if (i > 0) rows.add(const SizedBox(height: 12));
rows.add(
_BridgeReceivingWalletRow(
option: option,
onTap: () {
bridgeViewModel.setRecipientAddress(option.address, destWalletName: option.name);
showMaterialModalBottomSheet<void>(
context: context,
backgroundColor: Colors.transparent,
builder: (ctx) => BridgeConfirmSheet(bridgeViewModel),
);
},
),
);
}
if (options.isNotEmpty) rows.add(const SizedBox(height: 12));
rows.add(
ListItemStyleWrapper(
isFirstInSection: true,
isLastInSection: true,
height: 48,
contentPadding: const EdgeInsets.all(12),
onTap: () {
showMaterialModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (ctx) => BridgeReceiveAddressInputPage(bridgeViewModel: bridgeViewModel),
);
},
builder: (ctx, textStyle, _) {
final scheme = Theme.of(ctx).colorScheme;
return Row(
children: [
Icon(
Icons.edit_outlined,
size: 24,
color: scheme.primary,
),
const SizedBox(width: 12),
Expanded(
child: Text(
'Input an Address',
style: textStyle.copyWith(
color: scheme.primary,
fontSize: 15,
fontWeight: FontWeight.w500,
letterSpacing: -0.3,
),
),
),
],
);
},
),
);
return rows;
}
}
class _BridgeReceivingWalletRow extends StatelessWidget {
const _BridgeReceivingWalletRow({
required this.option,
required this.onTap,
});
final BridgeReceivingWalletOption option;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final hasGroupRow = option.groupLabel != null;
return ListItemStyleWrapper(
onTap: onTap,
isFirstInSection: true,
isLastInSection: true,
height: hasGroupRow ? 62.0 : 48.0,
builder: (ctx, textStyle, labelStyle) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
option.name,
style: textStyle.copyWith(letterSpacing: -0.07),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
if (hasGroupRow) ...[
const SizedBox(height: 4),
Row(
children: [
Icon(
Icons.account_balance_wallet_outlined,
size: 16,
color: Theme.of(ctx).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 6),
Expanded(
child: Text(
option.groupLabel!,
style: labelStyle.copyWith(
fontSize: 12,
letterSpacing: -0.06,
color: Theme.of(ctx).colorScheme.onSurfaceVariant,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (option.isCurrent) ...[
const SizedBox(width: 8),
Text(
'Current',
style: textStyle.copyWith(
fontSize: 12,
color: Theme.of(ctx).colorScheme.primary,
letterSpacing: -0.06,
),
),
],
],
),
],
],
),
),
CakeImageWidget(
imageUrl: 'assets/new-ui/arrow_forward.svg',
height: 16,
color: Theme.of(ctx).colorScheme.onSurfaceVariant,
),
],
);
},
);
}
}
@@ -0,0 +1,62 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/new-ui/widgets/bridge/expandable_details_card.dart';
import 'package:cake_wallet/view_model/bridge/bridge_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class ConfirmDetailsCard extends StatelessWidget {
const ConfirmDetailsCard({required this.bridgeViewModel});
final BridgeViewModel bridgeViewModel;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return Observer(
builder: (_) {
final feeParts = <String>[
bridgeViewModel.quoteNativeFeeFormattedForDisplay,
bridgeViewModel.quoteNativeFiatFeeFormattedForDisplay,
];
final feeLine = feeParts.join(' ');
return Container(
decoration: BoxDecoration(
color: scheme.surfaceContainer,
borderRadius: BorderRadius.circular(16),
),
child: Column(
children: [
ExpandableBridgeDetailRow(
label: S.of(context).from,
title: bridgeViewModel.wallet.name,
address: bridgeViewModel.sourceAddress,
showChevron: true,
),
Divider(
height: 1,
color: scheme.surfaceContainerHigh,
),
ExpandableBridgeDetailRow(
label: S.of(context).to,
title: bridgeViewModel.destinationWalletName ?? bridgeViewModel.recipientAddress.trim(),
address: bridgeViewModel.recipientAddress.trim(),
showChevron: bridgeViewModel.destinationWalletName != null,
),
Divider(
height: 1,
color: scheme.surfaceContainerHigh,
),
ExpandableBridgeDetailRow(
label: S.of(context).fee,
title: feeLine,
showChevron: false,
),
],
),
);
},
);
}
}
@@ -0,0 +1,113 @@
import 'package:flutter/material.dart';
class ExpandableBridgeDetailRow extends StatefulWidget {
const ExpandableBridgeDetailRow({
required this.label,
required this.title,
this.address,
this.showChevron = false,
});
final String label;
final String title;
final String? address;
final bool showChevron;
@override
State<ExpandableBridgeDetailRow> createState() => ExpandableBridgeDetailRowState();
}
class ExpandableBridgeDetailRowState extends State<ExpandableBridgeDetailRow> {
bool _expanded = false;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final showChevron = widget.showChevron;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
InkWell(
onTap: showChevron ? () => setState(() => _expanded = !_expanded) : null,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.label,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: scheme.onSurface,
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: -0.07,
),
),
const SizedBox(width: 12),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
child: Text(
widget.title,
textAlign: TextAlign.end,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 14,
letterSpacing: -0.07,
color: scheme.onSurfaceVariant,
),
),
),
if (showChevron) ...[
const SizedBox(width: 2),
AnimatedRotation(
turns: _expanded ? 0.5 : 0,
duration: const Duration(milliseconds: 200),
curve: Curves.easeOutCubic,
child: Icon(
Icons.keyboard_arrow_down,
size: 22,
color: scheme.onSurfaceVariant,
),
),
],
],
),
),
],
),
),
),
AnimatedSize(
duration: const Duration(milliseconds: 200),
curve: Curves.easeOutCubic,
alignment: Alignment.topCenter,
child: showChevron && _expanded
? Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 14),
child: Align(
alignment: Alignment.centerRight,
child: SelectableText(
widget.address ?? '',
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 13,
height: 1.35,
color: scheme.onSurfaceVariant,
fontWeight: FontWeight.w400,
),
),
),
)
: const SizedBox.shrink(),
),
],
);
}
}
@@ -0,0 +1,89 @@
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:cw_core/generate_name.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class NetworkPathPill extends StatelessWidget {
const NetworkPathPill({
required this.sourceChainName,
required this.destChainName,
this.showBackground = true,
});
final String sourceChainName;
final String destChainName;
final bool showBackground;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final body = Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
CakeImageWidget(
imageUrl: 'assets/new-ui/chain_badges/${sourceChainName.toLowerCase()}.svg',
width: 24,
height: 24,
color: scheme.onSurfaceVariant,
),
const SizedBox(width: 8),
Flexible(
child: Text(
sourceChainName.capitalized(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
color: scheme.onSurface,
fontWeight: FontWeight.w400,
fontSize: 16,
letterSpacing: -0.08,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Icon(
Icons.arrow_forward,
size: 16,
color: scheme.primary,
),
),
CakeImageWidget(
imageUrl: 'assets/new-ui/chain_badges/${destChainName.toLowerCase()}.svg',
width: 24,
height: 24,
color: scheme.onSurfaceVariant,
),
const SizedBox(width: 8),
Flexible(
child: Text(
destChainName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
color: scheme.onSurface,
fontWeight: FontWeight.w400,
fontSize: 16,
letterSpacing: -0.08,
),
),
),
],
);
return Observer(
builder: (_) {
return showBackground
? Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
color: scheme.surfaceContainer,
borderRadius: BorderRadius.circular(80),
),
child: body,
)
: body;
},
);
}
}
@@ -0,0 +1,180 @@
import 'package:cake_wallet/entities/bridge_transfer.dart';
import 'package:cake_wallet/evm/evm.dart';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:cake_wallet/themes/core/custom_theme_colors.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class TransferHistoryRow extends StatelessWidget {
const TransferHistoryRow({
required this.transfer,
required this.onTap,
super.key,
});
final BridgeTransfer transfer;
final VoidCallback onTap;
String _statusLabel(String status) {
switch (status) {
case 'submitted':
return "Submitted";
case 'confirming':
return "Confirming on source";
case 'initiated':
return "Bridge initiated";
case 'completed':
return "Completed";
case 'failed':
return "Failed";
default:
return status;
}
}
Color _statusColor(BuildContext context, String status) {
switch (status) {
case 'completed':
return CustomThemeColors.syncGreen;
case 'failed':
return Theme.of(context).colorScheme.error;
case 'submitted':
case 'confirming':
case 'initiated':
default:
return CustomThemeColors.syncYellow;
}
}
@override
Widget build(BuildContext context) {
final sourceChainName = evm?.getChainInfoByChainId(transfer.sourceChainId)?.name;
final destChainName = evm?.getChainInfoByChainId(transfer.destinationChainId)?.name;
final formattedDate = DateFormat('HH:mm').format(transfer.createdAt);
final statusText = _statusLabel(transfer.status);
return InkWell(
onTap: onTap,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
margin: const EdgeInsets.only(bottom: 16),
width: double.infinity,
height: 72,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Theme.of(context).colorScheme.surfaceContainerHigh,
Theme.of(context).colorScheme.surfaceContainer,
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
borderRadius: BorderRadius.all(Radius.circular(20)),
border: Border.all(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
width: 1,
),
),
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 42,
width: 42,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
),
child: Stack(
children: [
CakeImageWidget(
imageUrl: 'assets/images/crypto/${sourceChainName?.toLowerCase()}.webp',
width: 28,
height: 28,
),
Positioned(
top: 14,
left: 12,
child: CakeImageWidget(
imageUrl: 'assets/images/crypto/${destChainName?.toLowerCase()}.webp',
width: 28,
height: 28,
),
),
],
),
),
const SizedBox(width: 8),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'$sourceChainName → $destChainName',
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface,
),
),
Text(
'${transfer.amount} ${transfer.tokenSymbol}',
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface,
),
),
],
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: [
Container(
height: 8,
width: 8,
decoration: BoxDecoration(
color: _statusColor(context, transfer.status),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Theme.of(context).colorScheme.surface,
width: 1.5,
),
),
),
SizedBox(width: 8),
Text(
statusText,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
overflow: TextOverflow.ellipsis,
),
],
),
Text(
formattedDate,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
),
],
),
),
],
),
),
);
}
}
@@ -2,6 +2,7 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/new-ui/modal_navigator.dart';
import 'package:cake_wallet/new-ui/pages/bridge/bridge_amount_page.dart';
import 'package:cake_wallet/new-ui/pages/receive_page.dart';
import 'package:cake_wallet/new-ui/pages/send_page.dart';
import 'package:cake_wallet/new-ui/pages/swap_page.dart';
@@ -31,6 +32,7 @@ class AssetDetailsModal extends StatelessWidget {
required this.mode,
required this.wallet,
required this.showSwap,
required this.showBridgeButton,
this.asset});
final String title;
@@ -44,6 +46,7 @@ class AssetDetailsModal extends StatelessWidget {
final String chainIconPath;
final WalletBase wallet;
final bool showSwap;
final bool showBridgeButton;
final AssetDetailsModalModes mode;
@override
@@ -59,7 +62,7 @@ class AssetDetailsModal extends StatelessWidget {
title: "",
trailingIcon: Icon(Icons.close),
onTrailingPressed: Navigator.of(context).pop,
padding: EdgeInsets.only(top:12,right:18),
padding: EdgeInsets.only(top: 12, right: 18),
),
SafeArea(
child: Column(
@@ -125,21 +128,20 @@ class AssetDetailsModal extends StatelessWidget {
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface),
),
if(asset != null)
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(999999999)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4),
child: Text(
asset?.title??"",
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant),
if (asset != null)
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(999999999)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4),
child: Text(
asset?.title ?? "",
style: TextStyle(
color: Theme.of(context).colorScheme.onSurfaceVariant),
),
),
),
)
)
],
),
if (subtitle.isNotEmpty)
@@ -147,11 +149,15 @@ class AssetDetailsModal extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
spacing: 4,
children: [
if(chainIconPath.isNotEmpty)
CakeImageWidget(
imageUrl: chainIconPath,
width:16,height:16,colorFilter: ColorFilter.mode(Theme.of(context).colorScheme.onSurfaceVariant,BlendMode.srcIn),
),
if (chainIconPath.isNotEmpty)
CakeImageWidget(
imageUrl: chainIconPath,
width: 16,
height: 16,
colorFilter: ColorFilter.mode(
Theme.of(context).colorScheme.onSurfaceVariant,
BlendMode.srcIn),
),
Text(
subtitle,
style: TextStyle(
@@ -227,6 +233,18 @@ class AssetDetailsModal extends StatelessWidget {
),
),
),
if (showSwap && mode != AssetDetailsModalModes.ltcPrivate)
AssetDetailsModalBottomButton(
iconPath: "assets/new-ui/exchange.svg",
title: S.of(context).swap,
onPressed: () => openPage<NewSwapPage>(context, param2: asset),
),
if (showBridgeButton)
AssetDetailsModalBottomButton(
iconPath: "assets/new-ui/bridge.svg",
title: "Bridge",
onPressed: () => openPage<BridgeAmountPage>(context, param1: asset),
),
AssetDetailsModalBottomButton(
iconPath: "assets/new-ui/receive.svg",
title: S.of(context).receive,
@@ -240,12 +258,6 @@ class AssetDetailsModal extends StatelessWidget {
openPage<NewReceivePage>(context, param2: asset);
},
),
if (showSwap && mode != AssetDetailsModalModes.ltcPrivate)
AssetDetailsModalBottomButton(
iconPath: "assets/new-ui/exchange.svg",
title: S.of(context).swap,
onPressed: () => openPage<NewSwapPage>(context, param2: asset),
),
],
),
SizedBox()
@@ -14,6 +14,7 @@ class AssetTile extends StatelessWidget {
required this.balance,
required this.chainIconPath,
this.showSecondary = false,
this.showBridgeButton = false,
this.title,
this.trailingText,
this.modalMode = AssetDetailsModalModes.normal,
@@ -22,6 +23,7 @@ class AssetTile extends StatelessWidget {
final BalanceRecord balance;
final bool showSecondary;
final bool showSwap;
final bool showBridgeButton;
final String chainIconPath;
final String? title;
final String? trailingText;
@@ -42,6 +44,7 @@ class AssetTile extends StatelessWidget {
builder: (context) {
return AssetDetailsModal(
showSwap: showSwap,
showBridgeButton: showBridgeButton,
asset: balance.asset,
title: title ?? balance.asset.fullName ?? balance.asset.name,
chainTitle: "",
@@ -59,6 +59,7 @@ class AssetsSection extends StatelessWidget {
final balance = dashboardViewModel.balanceViewModel.formattedBalances.elementAt(index);
return AssetTile(
showSwap: dashboardViewModel.isEnabledSwapAction,
showBridgeButton: dashboardViewModel.showBridge(balance.asset),
balance: balance,
wallet: dashboardViewModel.wallet,
isFirst: index == 0,
@@ -23,6 +23,7 @@ class NewSendAddressInput extends StatefulWidget {
this.validator,
this.focusNode,
this.displayName,
this.hintText,
});
final TextEditingController addressController;
@@ -36,7 +37,8 @@ class NewSendAddressInput extends StatefulWidget {
final bool bottomPadding;
final FormFieldValidator<String>? validator;
final FocusNode? focusNode;
final String? hintText;
@override
State<NewSendAddressInput> createState() => _NewSendAddressInputState();
}
@@ -96,7 +98,7 @@ class _NewSendAddressInputState extends State<NewSendAddressInput> {
},
controller: widget.addressController,
decoration: InputDecoration(
hintText: S.of(context).search_or_enter,
hintText: widget.hintText ?? S.of(context).search_or_enter,
errorMaxLines: 3,
),
),