| 1 | import 'package:cake_wallet/src/screens/wallet_connect/utils/wc_permissions_mapper.dart'; |
| 2 | import 'package:cake_wallet/src/widgets/cake_image_widget.dart'; |
| 3 | import 'package:flutter/material.dart'; |
| 4 | |
| 5 | class WCPermissionsCard extends StatelessWidget { |
| 6 | const WCPermissionsCard({super.key, required this.permissions}); |
| 7 | |
| 8 | final List<WCPermission> permissions; |
| 9 | |
| 10 | @override |
| 11 | Widget build(BuildContext context) { |
| 12 | final colors = Theme.of(context).colorScheme; |
| 13 | |
| 14 | if (permissions.isEmpty) return const SizedBox.shrink(); |
| 15 | |
| 16 | return Container( |
| 17 | width: double.infinity, |
| 18 | decoration: BoxDecoration( |
| 19 | color: colors.surfaceContainer, |
| 20 | borderRadius: BorderRadius.circular(20), |
| 21 | ), |
| 22 | padding: const EdgeInsets.symmetric(horizontal: 16), |
| 23 | child: Column( |
| 24 | children: [ |
| 25 | for (int i = 0; i < permissions.length; i++) ...[ |
| 26 | if (i > 0) Divider(height: 1, color: colors.outlineVariant, indent: 44), |
| 27 | _PermissionRow(permission: permissions[i]), |
| 28 | ], |
| 29 | ], |
| 30 | ), |
| 31 | ); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | class _PermissionRow extends StatelessWidget { |
| 36 | const _PermissionRow({required this.permission}); |
| 37 | |
| 38 | final WCPermission permission; |
| 39 | |
| 40 | @override |
| 41 | Widget build(BuildContext context) { |
| 42 | return Padding( |
| 43 | padding: const EdgeInsets.symmetric(vertical: 14), |
| 44 | child: Row( |
| 45 | children: [ |
| 46 | Container( |
| 47 | child: CakeImageWidget( |
| 48 | imageUrl: permission.iconUrl, |
| 49 | width: 28, |
| 50 | height: 28, |
| 51 | ), |
| 52 | ), |
| 53 | const SizedBox(width: 12), |
| 54 | Expanded( |
| 55 | child: Text( |
| 56 | permission.label, |
| 57 | style: Theme.of(context).textTheme.bodyMedium, |
| 58 | ), |
| 59 | ), |
| 60 | ], |
| 61 | ), |
| 62 | ); |
| 63 | } |
| 64 | } |