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