dev
dart 86 lines 2.49 KB
Raw
1 import 'package:cake_wallet/generated/i18n.dart';
2 import 'package:flutter/material.dart';
3
4 class WCMessageRow {
5 const WCMessageRow({required this.label, required this.value});
6
7 final String label;
8 final String value;
9 }
10
11 class WCMessageCard extends StatelessWidget {
12 const WCMessageCard({
13 super.key,
14 required this.message,
15 this.title,
16 this.extraRows = const [],
17 });
18
19 final String? title;
20 final String message;
21 final List<WCMessageRow> extraRows;
22
23 @override
24 Widget build(BuildContext context) {
25 final colors = Theme.of(context).colorScheme;
26 final resolvedTitle = title ?? S.of(context).wc_message_to_sign;
27
28 return Container(
29 width: double.infinity,
30 decoration: BoxDecoration(
31 color: colors.surfaceContainer,
32 borderRadius: BorderRadius.circular(16),
33 ),
34 padding: const EdgeInsets.all(16),
35 child: Column(
36 crossAxisAlignment: CrossAxisAlignment.start,
37 children: [
38 Text(
39 resolvedTitle,
40 style: Theme.of(context).textTheme.bodyMedium!.copyWith(
41 fontWeight: FontWeight.w600,
42 color: colors.onSurface,
43 ),
44 ),
45 if (message.isNotEmpty) ...[
46 const SizedBox(height: 8),
47 SelectableText(
48 message,
49 style: Theme.of(context).textTheme.bodySmall!.copyWith(
50 color: colors.onSurfaceVariant,
51 height: 1.4,
52 ),
53 ),
54 ],
55 for (final row in extraRows) ...[
56 const SizedBox(height: 12),
57 Divider(height: 1, color: colors.outlineVariant),
58 const SizedBox(height: 12),
59 Row(
60 crossAxisAlignment: CrossAxisAlignment.start,
61 children: [
62 Text(
63 row.label,
64 style: Theme.of(context).textTheme.bodySmall!.copyWith(
65 color: colors.onSurface,
66 fontWeight: FontWeight.w500,
67 ),
68 ),
69 const SizedBox(width: 8),
70 Expanded(
71 child: Text(
72 row.value,
73 textAlign: TextAlign.end,
74 style: Theme.of(context).textTheme.bodySmall!.copyWith(
75 color: colors.onSurfaceVariant,
76 ),
77 ),
78 ),
79 ],
80 ),
81 ],
82 ],
83 ),
84 );
85 }
86 }