moodboard_image_card.dart (3561B)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | import 'dart:io'; import 'package:flutter/material.dart'; import 'package:creekui/data/models/image_model.dart'; import 'package:creekui/ui/styles/variables.dart'; import 'package:creekui/ui/widgets/image_context_menu.dart'; class MoodboardImageCard extends StatelessWidget { final ImageModel image; final VoidCallback onTap; final VoidCallback onDeleted; final bool showTags; final double? height; const MoodboardImageCard({ super.key, required this.image, required this.onTap, required this.onDeleted, this.showTags = false, this.height, }); @override Widget build(BuildContext context) { return ImageContextMenu( image: image, onImageDeleted: onDeleted, child: GestureDetector( onTap: onTap, child: Container( height: height, decoration: BoxDecoration( borderRadius: BorderRadius.circular(Variables.radiusMedium), color: Variables.surfaceSubtle, border: Border.all(color: Variables.borderSubtle), ), clipBehavior: Clip.antiAlias, child: Stack( fit: StackFit.expand, children: [ Image.file( File(image.filePath), fit: BoxFit.cover, width: double.infinity, errorBuilder: (_, __, ___) => const Center( child: Icon( Icons.broken_image, color: Variables.textDisabled, ), ), ), if (showTags && image.tags.isNotEmpty) Positioned( bottom: 0, left: 0, right: 0, child: Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomCenter, end: Alignment.topCenter, colors: [ Colors.black.withOpacity(0.8), Colors.transparent, ], ), ), child: Wrap( spacing: 4, runSpacing: 4, children: image.tags.take(3).map((tag) { return Container( padding: const EdgeInsets.symmetric( horizontal: 6, vertical: 2, ), decoration: BoxDecoration( color: Colors.white.withOpacity(0.2), borderRadius: BorderRadius.circular(4), ), child: Text( tag.toUpperCase(), style: const TextStyle( color: Colors.white, fontSize: 9, fontFamily: 'GeneralSans', fontWeight: FontWeight.w600, ), ), ); }).toList(), ), ), ), ], ), ), ), ); } } |