| 1 | import 'package:flutter/material.dart'; |
| 2 | import 'image_placeholder.dart'; |
| 3 | |
| 4 | class CardItem extends StatelessWidget { |
| 5 | CardItem({ |
| 6 | required this.title, |
| 7 | required this.subTitle, |
| 8 | this.isAmount = false, |
| 9 | this.onTap, |
| 10 | this.logoUrl, |
| 11 | }); |
| 12 | |
| 13 | final VoidCallback? onTap; |
| 14 | final String title; |
| 15 | final String subTitle; |
| 16 | final String? logoUrl; |
| 17 | final bool isAmount; |
| 18 | |
| 19 | @override |
| 20 | Widget build(BuildContext context) { |
| 21 | return Theme( |
| 22 | data: ThemeData( |
| 23 | splashColor: Colors.transparent, |
| 24 | highlightColor: Colors.transparent, |
| 25 | ), |
| 26 | child: InkWell( |
| 27 | onTap: onTap, |
| 28 | child: Container( |
| 29 | decoration: BoxDecoration( |
| 30 | color: Theme.of(context).colorScheme.surface, |
| 31 | borderRadius: BorderRadius.circular(10), |
| 32 | ), |
| 33 | child: Row( |
| 34 | children: [ |
| 35 | if (logoUrl != null) |
| 36 | AspectRatio( |
| 37 | aspectRatio: 1.8, |
| 38 | child: ClipRRect( |
| 39 | borderRadius: BorderRadius.all(Radius.circular(10)), |
| 40 | child: Image.network( |
| 41 | logoUrl!, |
| 42 | fit: BoxFit.cover, |
| 43 | loadingBuilder: |
| 44 | (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { |
| 45 | if (loadingProgress == null) return child; |
| 46 | return Center(child: CircularProgressIndicator()); |
| 47 | }, |
| 48 | errorBuilder: (context, error, stackTrace) => CakePayCardImagePlaceholder(), |
| 49 | ), |
| 50 | ), |
| 51 | ), |
| 52 | Expanded( |
| 53 | child: Padding( |
| 54 | padding: const EdgeInsets.symmetric(horizontal: 8), |
| 55 | child: Column( |
| 56 | crossAxisAlignment: CrossAxisAlignment.start, |
| 57 | children: [ |
| 58 | Text(title, |
| 59 | maxLines: 1, |
| 60 | overflow: TextOverflow.ellipsis, |
| 61 | style: Theme.of(context) |
| 62 | .textTheme |
| 63 | .bodyMedium! |
| 64 | .copyWith(fontSize: 18, fontWeight: FontWeight.w700)), |
| 65 | Text(subTitle, |
| 66 | maxLines: 2, |
| 67 | overflow: TextOverflow.ellipsis, |
| 68 | style: Theme.of(context) |
| 69 | .textTheme |
| 70 | .bodySmall! |
| 71 | .copyWith(fontSize: 10, fontWeight: FontWeight.w700)), |
| 72 | ], |
| 73 | ), |
| 74 | ), |
| 75 | ), |
| 76 | ], |
| 77 | ), |
| 78 | ), |
| 79 | ), |
| 80 | ); |
| 81 | } |
| 82 | } |