Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-add deposit pages #280

Merged
merged 2 commits into from
Nov 6, 2023
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
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ class MessageLookup extends MessageLookupByLibrary {
"Do not support smart contract transfers."),
"depositTipTron": MessageLookupByLibrary.simpleMessage(
"This address supports all TRC-10 and TRC-20 tokens, such as TRX, USDT-TRON, etc."),
"depositUnsupported": MessageLookupByLibrary.simpleMessage(
"This address is an old network address, and deposits to this address are no longer supported."),
"depositing": MessageLookupByLibrary.simpleMessage("Depositing"),
"dontHaveAssets":
MessageLookupByLibrary.simpleMessage("Don\'t have assets?"),
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("不支持合约充值。"),
"depositTipTron": MessageLookupByLibrary.simpleMessage(
"该充值地址支持 TRX 和所有符合 TRC-10 TRC-20 标准的代币。"),
"depositUnsupported":
MessageLookupByLibrary.simpleMessage("此地址为旧网络地址,已不支持充值到此地址"),
"depositing": MessageLookupByLibrary.simpleMessage("充值中"),
"dontHaveAssets": MessageLookupByLibrary.simpleMessage("没有资产?"),
"dontShowAgain": MessageLookupByLibrary.simpleMessage("不再提醒"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,6 @@
"authApprovedAccessDate": "Approved: {approve}, Last Accessed: {access}",
"revokeAccess": "Revoke access",
"revokeConfirmation": "Revoke access {name}?",
"selectContact": "Choose a contact"
"selectContact": "Choose a contact",
"depositUnsupported": "This address is an old network address, and deposits to this address are no longer supported."
}
3 changes: 2 additions & 1 deletion lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,6 @@
"authApprovedAccessDate": "授权时间:{approve}, 上次访问:{access}",
"revokeAccess": "取消授权",
"revokeConfirmation": "取消 {name} 的授权?",
"selectContact": "选择联系人"
"selectContact": "选择联系人",
"depositUnsupported": "此地址为旧网络地址,已不支持充值到此地址"
}
45 changes: 16 additions & 29 deletions lib/ui/page/asset_deposit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import '../../util/web/web_utils.dart';
import '../router/mixin_routes.dart';
import '../widget/action_button.dart';
import '../widget/buttons.dart';
import '../widget/dialog/deposit_choose_network_bottom_sheet.dart';
import '../widget/dialog/request_payment_bottom_sheet.dart';
import '../widget/dialog/request_payment_result_bottom_sheet.dart';
import '../widget/mixin_appbar.dart';
Expand Down Expand Up @@ -171,15 +170,10 @@ class _AssetDepositBody extends HookWidget {

useMemoized(() async {
await Future<void>.delayed(Duration.zero);
await showDepositChooseNetworkBottomSheet(context, asset: asset);
if (tag == null || tag.isEmpty) {
return;
}
await showDialog<void>(
context: context,
barrierDismissible: false,
builder: (context) => _MemoWarningDialog(
symbol: asset.symbol,
builder: (context) => _DepositUnsupportedDialog(
onTap: () {
scheduleMicrotask(() {
Navigator.of(context).pop(true);
Expand Down Expand Up @@ -209,7 +203,6 @@ class _AssetDepositBody extends HookWidget {
_AddressLayout(
asset: asset,
address: address,
showDepositNotice: tag != null && tag.isNotEmpty,
)
else
const _AddressLoadingWidget(),
Expand Down Expand Up @@ -304,7 +297,7 @@ class _MemoLayout extends StatelessWidget {
Align(
alignment: AlignmentDirectional.centerStart,
child: SelectableText(
context.l10n.depositMemoNotice,
context.l10n.depositUnsupported,
enableInteractiveSelection: false,
style: TextStyle(
fontSize: 13,
Expand All @@ -319,13 +312,11 @@ class _MemoLayout extends StatelessWidget {
);
}

class _MemoWarningDialog extends StatelessWidget {
const _MemoWarningDialog({
required this.symbol,
class _DepositUnsupportedDialog extends StatelessWidget {
const _DepositUnsupportedDialog({
required this.onTap,
});

final String symbol;
final VoidCallback onTap;

@override
Expand All @@ -350,7 +341,7 @@ class _MemoWarningDialog extends StatelessWidget {
Padding(
padding: const EdgeInsets.symmetric(
vertical: 0, horizontal: 32),
child: Text(context.l10n.depositNotice(symbol),
child: Text(context.l10n.depositUnsupported,
textAlign: TextAlign.center,
style: const TextStyle(
color: Color(0xFFFF6550),
Expand Down Expand Up @@ -393,14 +384,11 @@ class _AddressLayout extends StatelessWidget {
const _AddressLayout({
required this.asset,
required this.address,
required this.showDepositNotice,
});

final AssetResult asset;
final String address;

final bool showDepositNotice;

@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
Expand All @@ -409,21 +397,20 @@ class _AddressLayout extends StatelessWidget {
_HeaderText(context.l10n.address),
const SizedBox(height: 8),
_CopyableText(address),
if (showDepositNotice)
Align(
alignment: AlignmentDirectional.centerStart,
child: Padding(
padding: const EdgeInsets.only(top: 8),
child: SelectableText(
context.l10n.depositNotice(asset.symbol),
enableInteractiveSelection: false,
style: TextStyle(
fontSize: 13,
color: context.colorScheme.red,
),
Align(
alignment: AlignmentDirectional.centerStart,
child: Padding(
padding: const EdgeInsets.only(top: 8),
child: SelectableText(
context.l10n.depositUnsupported,
enableInteractiveSelection: false,
style: TextStyle(
fontSize: 13,
color: context.colorScheme.red,
),
),
),
),
const SizedBox(height: 32),
_QrcodeImage(data: address, asset: asset),
const SizedBox(height: 32),
Expand Down
13 changes: 13 additions & 0 deletions lib/ui/page/asset_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'package:uuid/uuid.dart';

import '../../db/mixin_database.dart';
import '../../service/account_provider.dart';
import '../../service/profile/profile_manager.dart';
import '../../util/constants.dart';
import '../../util/extension/extension.dart';
import '../../util/hook.dart';
import '../../util/native_scroll.dart';
Expand Down Expand Up @@ -304,10 +306,21 @@ class _HeaderButtonBar extends StatelessWidget {
'id': asset.assetId,
})),
),
if (!_shouldHideReceiveButton(asset))
HeaderButton.text(
text: context.l10n.receive,
onTap: () {
lastSelectedAddress = asset.assetId;
context.push(assetDepositPath.toUri({'id': asset.assetId}));
},
),
]),
);
}

// hide receive button for https://mixin.one/snapshots/815b0b1a-2764-3736-8faa-42d694fa620a.
bool _shouldHideReceiveButton(AssetResult asset) => asset.assetId == omniUSDT;

class _AssetTransactionsHeader extends StatelessWidget {
const _AssetTransactionsHeader({
required this.filter,
Expand Down
6 changes: 6 additions & 0 deletions lib/ui/router/mixin_routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '../../service/account_provider.dart';
import '../../util/extension/extension.dart';
import '../../util/logger.dart';
import '../page/all_transactions.dart';
import '../page/asset_deposit.dart';
import '../page/asset_detail.dart';
import '../page/auth.dart';
import '../page/authentications.dart';
Expand Down Expand Up @@ -97,6 +98,11 @@ List<VRouteElementBuilder> buildMixinRoutes(BuildContext context) => [
path: withdrawalPath,
widget: const Withdrawal(),
),
VWidget(
key: const ValueKey('AssetDeposit'),
path: assetDepositPath,
widget: const AssetDeposit(),
),
VWidget(
key: const ValueKey('NotFound'),
path: notFoundUri.toString(),
Expand Down