dev
dart 112 lines 3.7 KB
Raw
1 import 'package:cake_wallet/generated/i18n.dart';
2 import 'package:cake_wallet/new-ui/widgets/confirm_swiper.dart';
3 import 'package:cake_wallet/src/screens/wallet_connect/services/bottom_sheet_service.dart';
4 import 'package:cake_wallet/src/screens/wallet_connect/widgets/wc_dapp_card.dart';
5 import 'package:cake_wallet/src/screens/wallet_connect/widgets/wc_message_card.dart';
6 import 'package:cake_wallet/src/screens/wallet_connect/widgets/wc_scam_banner.dart';
7 import 'package:cake_wallet/src/screens/wallet_connect/widgets/wc_sheet_header.dart';
8 import 'package:cake_wallet/src/screens/wallet_connect/widgets/wc_wallet_card.dart';
9 import 'package:flutter/material.dart';
10 import 'package:reown_walletkit/reown_walletkit.dart';
11
12 class WCSigningRequestSheet extends StatelessWidget {
13 const WCSigningRequestSheet({
14 super.key,
15 required this.title,
16 required this.swipeLabel,
17 required this.dappName,
18 required this.message,
19 required this.walletName,
20 required this.address,
21 this.dappIconUrl,
22 this.dappSubtitle,
23 this.verifyContext,
24 this.messageTitle,
25 this.extraRows = const [],
26 this.signAllCount,
27 });
28
29 final String title;
30 final String swipeLabel;
31 final String dappName;
32 final String? dappIconUrl;
33 final String? dappSubtitle;
34 final String message;
35 final String? messageTitle;
36 final List<WCMessageRow> extraRows;
37 final String walletName;
38 final String address;
39 final VerifyContext? verifyContext;
40 final int? signAllCount;
41
42 @override
43 Widget build(BuildContext context) {
44 final colors = Theme.of(context).colorScheme;
45 final showSignAll = (signAllCount ?? 0) > 1;
46 final isScam = verifyContext?.validation.scam ?? false;
47
48 return Column(
49 mainAxisSize: MainAxisSize.min,
50 children: [
51 WCSheetHeader(title: title),
52 const SizedBox(height: 24),
53 Expanded(
54 child: SingleChildScrollView(
55 child: Column(
56 children: [
57 WCDappCard(
58 name: dappName,
59 iconUrl: dappIconUrl,
60 subtitle: dappSubtitle ?? '',
61 action: WCDappCardAction.sign,
62 verifyContext: verifyContext,
63 ),
64 if (isScam) ...[
65 const SizedBox(height: 16),
66 const WCScamBanner(),
67 ],
68 const SizedBox(height: 24),
69 WCWalletCard(walletName: walletName, address: address),
70 const SizedBox(height: 24),
71 WCMessageCard(
72 title: messageTitle,
73 message: message,
74 extraRows: extraRows,
75 ),
76 ],
77 ),
78 ),
79 ),
80 const SizedBox(height: 24),
81 Padding(
82 padding: const EdgeInsets.symmetric(horizontal: 24),
83 child: ConfirmSwiper(
84 swiperText: swipeLabel,
85 accessibleNavigationModeButtonText: S.of(context).confirm,
86 onConfirmed: () {
87 if (Navigator.canPop(context)) {
88 Navigator.of(context).pop(WCBottomSheetResult.one);
89 }
90 },
91 ),
92 ),
93 if (showSignAll) ...[
94 const SizedBox(height: 24),
95 TextButton(
96 onPressed: () {
97 if (Navigator.canPop(context)) {
98 Navigator.of(context).pop(WCBottomSheetResult.all);
99 }
100 },
101 style: TextButton.styleFrom(
102 foregroundColor: colors.primary,
103 minimumSize: const Size.fromHeight(48),
104 ),
105 child: Text(S.of(context).wc_sign_all_count(signAllCount!.toString())),
106 ),
107 ],
108 const SizedBox(height: 16),
109 ],
110 );
111 }
112 }