Main coves client
at main 79 lines 2.1 kB view raw
1import 'package:flutter/material.dart'; 2import 'package:flutter/services.dart'; 3 4import '../constants/app_colors.dart'; 5import 'icons/share_icon.dart'; 6 7/// Standardized share button used across the app 8/// 9/// Displays the ArrowShareRight icon from Bluesky's design system. 10/// Shows a "Share coming soon!" snackbar when tapped. 11class ShareButton extends StatelessWidget { 12 const ShareButton({ 13 this.size = 18, 14 this.color, 15 this.tooltip = 'Share', 16 this.padding = const EdgeInsets.symmetric(horizontal: 8, vertical: 10), 17 this.useIconButton = false, 18 super.key, 19 }); 20 21 /// Size of the share icon 22 final double size; 23 24 /// Color of the share icon (defaults to theme icon color with 0.6 opacity) 25 final Color? color; 26 27 /// Tooltip text shown on long press 28 final String tooltip; 29 30 /// Padding around the icon (ignored when useIconButton is true) 31 final EdgeInsets padding; 32 33 /// Whether to use IconButton style (for app bars) vs InkWell style (for cards) 34 final bool useIconButton; 35 36 Future<void> _handleTap(BuildContext context) async { 37 try { 38 await HapticFeedback.lightImpact(); 39 } on PlatformException { 40 // Haptics not supported on this platform - ignore 41 } 42 43 if (!context.mounted) return; 44 45 ScaffoldMessenger.of(context).showSnackBar( 46 const SnackBar( 47 content: Text('Share coming soon!'), 48 behavior: SnackBarBehavior.floating, 49 ), 50 ); 51 } 52 53 @override 54 Widget build(BuildContext context) { 55 final effectiveColor = 56 color ?? AppColors.textPrimary.withValues(alpha: 0.6); 57 58 if (useIconButton) { 59 return IconButton( 60 icon: ShareIcon(size: size, color: effectiveColor), 61 onPressed: () => _handleTap(context), 62 tooltip: tooltip, 63 ); 64 } 65 66 return Semantics( 67 button: true, 68 label: tooltip, 69 child: InkWell( 70 onTap: () => _handleTap(context), 71 borderRadius: BorderRadius.circular(8), 72 child: Padding( 73 padding: padding, 74 child: ShareIcon(size: size, color: effectiveColor), 75 ), 76 ), 77 ); 78 } 79}