| 1 | import 'package:cake_wallet/entities/hardware_wallet/hardware_wallet_device.dart'; |
| 2 | import 'package:cake_wallet/src/widgets/cake_image_widget.dart'; |
| 3 | import 'package:flutter/material.dart'; |
| 4 | import 'package:flutter_svg/flutter_svg.dart'; |
| 5 | |
| 6 | class DeviceTile extends StatelessWidget { |
| 7 | const DeviceTile({ |
| 8 | required this.onPressed, |
| 9 | required this.title, |
| 10 | this.leading, |
| 11 | this.connectionType, |
| 12 | }); |
| 13 | |
| 14 | final VoidCallback onPressed; |
| 15 | final String title; |
| 16 | final String? leading; |
| 17 | final HardwareWalletConnectionType? connectionType; |
| 18 | |
| 19 | String? get connectionTypeIcon { |
| 20 | switch (connectionType) { |
| 21 | case HardwareWalletConnectionType.ble: |
| 22 | return 'assets/images/bluetooth.png'; |
| 23 | case HardwareWalletConnectionType.usb: |
| 24 | return 'assets/images/usb.png'; |
| 25 | default: |
| 26 | return null; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | @override |
| 31 | Widget build(BuildContext context) { |
| 32 | return GestureDetector( |
| 33 | onTap: onPressed, |
| 34 | child: Container( |
| 35 | width: double.infinity, |
| 36 | padding: EdgeInsets.all(24), |
| 37 | alignment: Alignment.center, |
| 38 | decoration: BoxDecoration( |
| 39 | borderRadius: BorderRadius.all(Radius.circular(12)), |
| 40 | color: Theme.of(context).colorScheme.surfaceContainer, |
| 41 | ), |
| 42 | child: Row( |
| 43 | mainAxisSize: MainAxisSize.max, |
| 44 | mainAxisAlignment: MainAxisAlignment.center, |
| 45 | crossAxisAlignment: CrossAxisAlignment.center, |
| 46 | children: <Widget>[ |
| 47 | CakeImageWidget( |
| 48 | height: 30, |
| 49 | imageUrl: leading, |
| 50 | colorFilter: |
| 51 | ColorFilter.mode(Theme.of(context).colorScheme.onSurface, BlendMode.srcIn), |
| 52 | ), |
| 53 | Expanded( |
| 54 | child: Padding( |
| 55 | padding: EdgeInsets.only(left: 16), |
| 56 | child: Text( |
| 57 | title, |
| 58 | style: Theme.of(context).textTheme.bodyMedium!.copyWith( |
| 59 | fontSize: 20, |
| 60 | fontWeight: FontWeight.w500, |
| 61 | ), |
| 62 | ), |
| 63 | ), |
| 64 | ), |
| 65 | if (connectionTypeIcon != null) |
| 66 | Center( |
| 67 | child: Image.asset( |
| 68 | connectionTypeIcon!, |
| 69 | height: 25, |
| 70 | color: Theme.of(context).colorScheme.onSurface, |
| 71 | ), |
| 72 | ) |
| 73 | ], |
| 74 | ), |
| 75 | ), |
| 76 | ); |
| 77 | } |
| 78 | } |